Sort community servers by ping
This commit is contained in:
@@ -836,7 +836,6 @@ public class MobileInput extends InputHandler implements GestureListener{
|
|||||||
if(type == null) return;
|
if(type == null) return;
|
||||||
|
|
||||||
boolean omni = unit.type.omniMovement;
|
boolean omni = unit.type.omniMovement;
|
||||||
boolean ground = unit.isGrounded();
|
|
||||||
boolean allowHealing = type.canHeal;
|
boolean allowHealing = type.canHeal;
|
||||||
boolean validHealTarget = allowHealing && target instanceof Building && ((Building)target).isValid() && target.team() == unit.team &&
|
boolean validHealTarget = allowHealing && target instanceof Building && ((Building)target).isValid() && target.team() == unit.team &&
|
||||||
((Building)target).damaged() && target.within(unit, type.range);
|
((Building)target).damaged() && target.within(unit, type.range);
|
||||||
|
|||||||
@@ -356,43 +356,45 @@ public class JoinDialog extends BaseDialog{
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Table[] groupTable = {null};
|
||||||
|
|
||||||
//table containing all groups
|
//table containing all groups
|
||||||
global.table(g -> {
|
for(String address : group.addresses){
|
||||||
for(String address : group.addresses){
|
String resaddress = address.contains(":") ? address.split(":")[0] : address;
|
||||||
String resaddress = address.contains(":") ? address.split(":")[0] : address;
|
int resport = address.contains(":") ? Strings.parseInt(address.split(":")[1]) : port;
|
||||||
int resport = address.contains(":") ? Strings.parseInt(address.split(":")[1]) : port;
|
net.pingHost(resaddress, resport, res -> {
|
||||||
net.pingHost(resaddress, resport, res -> {
|
if(refreshes != cur) return;
|
||||||
if(refreshes != cur) return;
|
res.port = resport;
|
||||||
res.port = resport;
|
|
||||||
|
|
||||||
//add header
|
//add header
|
||||||
if(g.getChildren().isEmpty()){
|
if(groupTable[0] == null){
|
||||||
g.table(head -> {
|
global.table(t -> groupTable[0] = t).row();
|
||||||
if(!group.name.isEmpty()){
|
|
||||||
head.add(group.name).color(Color.lightGray).padRight(4);
|
|
||||||
}
|
|
||||||
head.image().height(3f).growX().color(Color.lightGray);
|
|
||||||
|
|
||||||
//button for showing/hiding servers
|
groupTable[0].table(head -> {
|
||||||
ImageButton[] image = {null};
|
if(!group.name.isEmpty()){
|
||||||
image[0] = head.button(hidden ? Icon.eyeOffSmall : Icon.eyeSmall, Styles.accenti, () -> {
|
head.add(group.name).color(Color.lightGray).padRight(4);
|
||||||
group.setHidden(!group.hidden());
|
}
|
||||||
image[0].getStyle().imageUp = group.hidden() ? Icon.eyeOffSmall : Icon.eyeSmall;
|
head.image().height(3f).growX().color(Color.lightGray);
|
||||||
if(group.hidden() && !showHidden){
|
|
||||||
g.remove();
|
|
||||||
}
|
|
||||||
}).size(40f).get();
|
|
||||||
image[0].addListener(new Tooltip(t -> t.background(Styles.black6).margin(4).label(() -> !group.hidden() ? "@server.shown" : "@server.hidden")));
|
|
||||||
}).width(targetWidth()).padBottom(-2).row();
|
|
||||||
}
|
|
||||||
|
|
||||||
addGlobalHost(res, g);
|
//button for showing/hiding servers
|
||||||
|
ImageButton[] image = {null};
|
||||||
|
image[0] = head.button(hidden ? Icon.eyeOffSmall : Icon.eyeSmall, Styles.accenti, () -> {
|
||||||
|
group.setHidden(!group.hidden());
|
||||||
|
image[0].getStyle().imageUp = group.hidden() ? Icon.eyeOffSmall : Icon.eyeSmall;
|
||||||
|
if(group.hidden() && !showHidden){
|
||||||
|
groupTable[0].remove();
|
||||||
|
}
|
||||||
|
}).size(40f).get();
|
||||||
|
image[0].addListener(new Tooltip(t -> t.background(Styles.black6).margin(4).label(() -> !group.hidden() ? "@server.shown" : "@server.hidden")));
|
||||||
|
}).width(targetWidth()).padBottom(-2).row();
|
||||||
|
}
|
||||||
|
|
||||||
g.margin(5f);
|
addGlobalHost(res, groupTable[0]);
|
||||||
g.pack();
|
|
||||||
}, e -> {});
|
groupTable[0].margin(5f);
|
||||||
}
|
groupTable[0].pack();
|
||||||
}).row();
|
}, e -> {});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user