New server dialog style
This commit is contained in:
@@ -129,9 +129,9 @@ public class JoinDialog extends BaseDialog{
|
||||
|
||||
for(Server server : servers){
|
||||
//why are java lambdas this bad
|
||||
TextButton[] buttons = {null};
|
||||
Button[] buttons = {null};
|
||||
|
||||
TextButton button = buttons[0] = remote.button("[accent]" + server.displayIP(), style, () -> {
|
||||
Button button = buttons[0] = remote.button(b -> {}, style, () -> {
|
||||
if(!buttons[0].childrenPressed()){
|
||||
if(server.lastHost != null){
|
||||
Events.fire(new ClientPreConnectEvent(server.lastHost));
|
||||
@@ -142,13 +142,13 @@ public class JoinDialog extends BaseDialog{
|
||||
}
|
||||
}).width(targetWidth()).pad(4f).get();
|
||||
|
||||
button.getLabel().setWrap(true);
|
||||
Table inner = new Table(Tex.whiteui);
|
||||
inner.setColor(Pal.gray);
|
||||
|
||||
Table inner = new Table();
|
||||
button.clearChildren();
|
||||
button.add(inner).growX();
|
||||
|
||||
inner.add(button.getLabel()).growX();
|
||||
inner.add("[accent]" + server.displayIP()).left().padLeft(10f).wrap().style(Styles.outlineLabel).growX();
|
||||
|
||||
inner.button(Icon.upOpen, Styles.emptyi, () -> {
|
||||
moveRemote(server, -1);
|
||||
@@ -214,11 +214,16 @@ public class JoinDialog extends BaseDialog{
|
||||
|
||||
void refreshServer(Server server){
|
||||
server.content.clear();
|
||||
server.content.label(() -> Core.bundle.get("server.refreshing") + Strings.animated(Time.time, 4, 11, "."));
|
||||
|
||||
server.content.background(Tex.whitePane).setColor(Pal.gray);
|
||||
|
||||
server.content.label(() -> Core.bundle.get("server.refreshing") + Strings.animated(Time.time, 4, 11, ".")).padBottom(4);
|
||||
|
||||
net.pingHost(server.ip, server.port, host -> setupServer(server, host), e -> {
|
||||
server.content.clear();
|
||||
server.content.add("@host.invalid").padBottom(4);
|
||||
|
||||
server.content.background(Tex.whitePane).setColor(Pal.gray);
|
||||
server.content.add("@host.invalid");
|
||||
});
|
||||
}
|
||||
|
||||
@@ -248,21 +253,49 @@ public class JoinDialog extends BaseDialog{
|
||||
versionString = Core.bundle.format("server.version", host.version, host.versionType);
|
||||
}
|
||||
|
||||
content.table(t -> {
|
||||
t.add("[lightgray]" + host.name + " " + versionString).width(targetWidth() - 10f).left().get().setEllipsis(true);
|
||||
t.row();
|
||||
float twidth = targetWidth() - 40f;
|
||||
|
||||
content.background(null);
|
||||
|
||||
Color color = Pal.gray;
|
||||
|
||||
content.table(Tex.whiteui, t -> {
|
||||
t.left();
|
||||
t.setColor(color);
|
||||
|
||||
t.add(host.name + " " + versionString).style(Styles.outlineLabel).padLeft(10f).width(twidth).left().ellipsis(true);
|
||||
}).growX().height(36f).row();
|
||||
|
||||
content.table(Tex.whitePane, t -> {
|
||||
t.setColor(color);
|
||||
t.left();
|
||||
|
||||
if(!host.description.isEmpty()){
|
||||
t.add("[gray]" + host.description).width(targetWidth() - 10f).left().wrap();
|
||||
//limit newlines.
|
||||
int count = 0;
|
||||
StringBuilder result = new StringBuilder(host.description.length());
|
||||
for(int i = 0; i < host.description.length(); i++){
|
||||
char c = host.description.charAt(i);
|
||||
if(c == '\n'){
|
||||
count ++;
|
||||
if(count < 3) result.append(c);
|
||||
}else{
|
||||
result.append(c);
|
||||
}
|
||||
}
|
||||
t.add("[gray]" + result).width(twidth).left().wrap();
|
||||
t.row();
|
||||
}
|
||||
t.add("[lightgray]" + (Core.bundle.format("players" + (host.players == 1 && host.playerLimit <= 0 ? ".single" : ""), (host.players == 0 ? "[lightgray]" : "[accent]") + host.players + (host.playerLimit > 0 ? "[lightgray]/[accent]" + host.playerLimit : "")+ "[lightgray]"))).left();
|
||||
t.row();
|
||||
t.add("[lightgray]" + Core.bundle.format("save.map", host.mapname) + "[lightgray] / " + (host.modeName == null ? host.mode.toString() : host.modeName)).width(targetWidth() - 10f).left().get().setEllipsis(true);
|
||||
|
||||
t.add("[lightgray]" + (Core.bundle.format("players" + (host.players == 1 && host.playerLimit <= 0 ? ".single" : ""),
|
||||
(host.players == 0 ? "[lightgray]" : "[accent]") + host.players + (host.playerLimit > 0 ? "[lightgray]/[accent]" + host.playerLimit : "")+ "[lightgray]"))).left().row();
|
||||
|
||||
t.add("[lightgray]" + Core.bundle.format("save.map", host.mapname) + "[lightgray] / " + (host.modeName == null ? host.mode.toString() : host.modeName)).width(twidth).left().ellipsis(true).row();
|
||||
|
||||
if(host.ping > 0){
|
||||
t.row();
|
||||
t.add(Iconc.chartBar + " " + host.ping + "ms").color(Color.gray).left();
|
||||
t.add(Iconc.chartBar + " " + host.ping + "ms").style(Styles.outlineLabel).color(Pal.gray).left();
|
||||
}
|
||||
}).expand().left().bottom().padLeft(12f).padBottom(8);
|
||||
}).growX().left().bottom();
|
||||
}
|
||||
|
||||
void setup(){
|
||||
@@ -407,7 +440,7 @@ public class JoinDialog extends BaseDialog{
|
||||
}).width(targetWidth()).padBottom(-2).row();
|
||||
}
|
||||
|
||||
addGlobalHost(res, groupTable[0]);
|
||||
addCommunityHost(res, groupTable[0]);
|
||||
|
||||
groupTable[0].margin(5f);
|
||||
groupTable[0].pack();
|
||||
@@ -416,7 +449,7 @@ public class JoinDialog extends BaseDialog{
|
||||
}
|
||||
}
|
||||
|
||||
void addGlobalHost(Host host, Table container){
|
||||
void addCommunityHost(Host host, Table container){
|
||||
global.background(null);
|
||||
float w = targetWidth();
|
||||
|
||||
@@ -433,7 +466,7 @@ public class JoinDialog extends BaseDialog{
|
||||
}else{
|
||||
safeConnect(host.address, host.port, host.version);
|
||||
}
|
||||
}).width(w).row();
|
||||
}).width(w).padBottom(7).row();
|
||||
}
|
||||
|
||||
void finishLocalHosts(){
|
||||
@@ -521,7 +554,7 @@ public class JoinDialog extends BaseDialog{
|
||||
}
|
||||
|
||||
float targetWidth(){
|
||||
return Math.min(Core.graphics.getWidth() / Scl.scl() * 0.9f, 500f);
|
||||
return Math.min(Core.graphics.getWidth() / Scl.scl() * 0.9f, 550f);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
|
||||
Reference in New Issue
Block a user