New server dialog style

This commit is contained in:
Anuken 2022-01-20 10:08:52 -05:00
parent 9593765742
commit 1f2fa331ce
4 changed files with 67 additions and 25 deletions

View file

@ -82,7 +82,6 @@ public class Blocks{
//defense - erekir
buildTower,
//TODO name
regenProjector, barrierProjector,
//transport

View file

@ -687,6 +687,7 @@ public class LExecutor{
//radar instructions are special in that they cache their output and only change it at fixed intervals.
//this prevents lag from spam of radar instructions
public Healthc lastTarget;
public Object lastSourceBuild;
public Interval timer = new Interval();
static float bestValue = 0f;
@ -720,7 +721,7 @@ public class LExecutor{
//timers update on a fixed 30 tick interval
//units update on a special timer per controller instance
if((base instanceof Building && timer.get(30f)) || (ai != null && ai.checkTargetTimer(this))){
if((base instanceof Building && (timer.get(30f) || lastSourceBuild != base)) || (ai != null && ai.checkTargetTimer(this))){
//if any of the targets involve enemies
boolean enemies = target1 == RadarTarget.enemy || target2 == RadarTarget.enemy || target3 == RadarTarget.enemy;
boolean allies = target1 == RadarTarget.ally || target2 == RadarTarget.ally || target3 == RadarTarget.ally;
@ -744,9 +745,18 @@ public class LExecutor{
find(r, range, sortDir, r.team());
}
if(ai != null){
ai.execCache.put(this, best);
}
lastSourceBuild = base;
lastTarget = targeted = best;
}else{
targeted = lastTarget;
if(ai != null){
targeted = (Healthc)ai.execCache.get(this);
}else{
targeted = lastTarget;
}
}
exec.setobj(output, targeted);

View file

@ -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")

View file

@ -24,4 +24,4 @@ android.useAndroidX=true
#used for slow jitpack builds; TODO see if this actually works
org.gradle.internal.http.socketTimeout=100000
org.gradle.internal.http.connectionTimeout=100000
archash=ff834fe5c9
archash=b139bee16f