New server dialog style
This commit is contained in:
@@ -82,7 +82,6 @@ public class Blocks{
|
|||||||
|
|
||||||
//defense - erekir
|
//defense - erekir
|
||||||
buildTower,
|
buildTower,
|
||||||
//TODO name
|
|
||||||
regenProjector, barrierProjector,
|
regenProjector, barrierProjector,
|
||||||
|
|
||||||
//transport
|
//transport
|
||||||
|
|||||||
@@ -687,6 +687,7 @@ public class LExecutor{
|
|||||||
//radar instructions are special in that they cache their output and only change it at fixed intervals.
|
//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
|
//this prevents lag from spam of radar instructions
|
||||||
public Healthc lastTarget;
|
public Healthc lastTarget;
|
||||||
|
public Object lastSourceBuild;
|
||||||
public Interval timer = new Interval();
|
public Interval timer = new Interval();
|
||||||
|
|
||||||
static float bestValue = 0f;
|
static float bestValue = 0f;
|
||||||
@@ -720,7 +721,7 @@ public class LExecutor{
|
|||||||
|
|
||||||
//timers update on a fixed 30 tick interval
|
//timers update on a fixed 30 tick interval
|
||||||
//units update on a special timer per controller instance
|
//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
|
//if any of the targets involve enemies
|
||||||
boolean enemies = target1 == RadarTarget.enemy || target2 == RadarTarget.enemy || target3 == RadarTarget.enemy;
|
boolean enemies = target1 == RadarTarget.enemy || target2 == RadarTarget.enemy || target3 == RadarTarget.enemy;
|
||||||
boolean allies = target1 == RadarTarget.ally || target2 == RadarTarget.ally || target3 == RadarTarget.ally;
|
boolean allies = target1 == RadarTarget.ally || target2 == RadarTarget.ally || target3 == RadarTarget.ally;
|
||||||
@@ -744,9 +745,18 @@ public class LExecutor{
|
|||||||
find(r, range, sortDir, r.team());
|
find(r, range, sortDir, r.team());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(ai != null){
|
||||||
|
ai.execCache.put(this, best);
|
||||||
|
}
|
||||||
|
|
||||||
|
lastSourceBuild = base;
|
||||||
lastTarget = targeted = best;
|
lastTarget = targeted = best;
|
||||||
}else{
|
}else{
|
||||||
targeted = lastTarget;
|
if(ai != null){
|
||||||
|
targeted = (Healthc)ai.execCache.get(this);
|
||||||
|
}else{
|
||||||
|
targeted = lastTarget;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
exec.setobj(output, targeted);
|
exec.setobj(output, targeted);
|
||||||
|
|||||||
@@ -129,9 +129,9 @@ public class JoinDialog extends BaseDialog{
|
|||||||
|
|
||||||
for(Server server : servers){
|
for(Server server : servers){
|
||||||
//why are java lambdas this bad
|
//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(!buttons[0].childrenPressed()){
|
||||||
if(server.lastHost != null){
|
if(server.lastHost != null){
|
||||||
Events.fire(new ClientPreConnectEvent(server.lastHost));
|
Events.fire(new ClientPreConnectEvent(server.lastHost));
|
||||||
@@ -142,13 +142,13 @@ public class JoinDialog extends BaseDialog{
|
|||||||
}
|
}
|
||||||
}).width(targetWidth()).pad(4f).get();
|
}).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.clearChildren();
|
||||||
button.add(inner).growX();
|
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, () -> {
|
inner.button(Icon.upOpen, Styles.emptyi, () -> {
|
||||||
moveRemote(server, -1);
|
moveRemote(server, -1);
|
||||||
@@ -214,11 +214,16 @@ public class JoinDialog extends BaseDialog{
|
|||||||
|
|
||||||
void refreshServer(Server server){
|
void refreshServer(Server server){
|
||||||
server.content.clear();
|
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 -> {
|
net.pingHost(server.ip, server.port, host -> setupServer(server, host), e -> {
|
||||||
server.content.clear();
|
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);
|
versionString = Core.bundle.format("server.version", host.version, host.versionType);
|
||||||
}
|
}
|
||||||
|
|
||||||
content.table(t -> {
|
float twidth = targetWidth() - 40f;
|
||||||
t.add("[lightgray]" + host.name + " " + versionString).width(targetWidth() - 10f).left().get().setEllipsis(true);
|
|
||||||
t.row();
|
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()){
|
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.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("players" + (host.players == 1 && host.playerLimit <= 0 ? ".single" : ""),
|
||||||
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);
|
(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){
|
if(host.ping > 0){
|
||||||
t.row();
|
t.add(Iconc.chartBar + " " + host.ping + "ms").style(Styles.outlineLabel).color(Pal.gray).left();
|
||||||
t.add(Iconc.chartBar + " " + host.ping + "ms").color(Color.gray).left();
|
|
||||||
}
|
}
|
||||||
}).expand().left().bottom().padLeft(12f).padBottom(8);
|
}).growX().left().bottom();
|
||||||
}
|
}
|
||||||
|
|
||||||
void setup(){
|
void setup(){
|
||||||
@@ -407,7 +440,7 @@ public class JoinDialog extends BaseDialog{
|
|||||||
}).width(targetWidth()).padBottom(-2).row();
|
}).width(targetWidth()).padBottom(-2).row();
|
||||||
}
|
}
|
||||||
|
|
||||||
addGlobalHost(res, groupTable[0]);
|
addCommunityHost(res, groupTable[0]);
|
||||||
|
|
||||||
groupTable[0].margin(5f);
|
groupTable[0].margin(5f);
|
||||||
groupTable[0].pack();
|
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);
|
global.background(null);
|
||||||
float w = targetWidth();
|
float w = targetWidth();
|
||||||
|
|
||||||
@@ -433,7 +466,7 @@ public class JoinDialog extends BaseDialog{
|
|||||||
}else{
|
}else{
|
||||||
safeConnect(host.address, host.port, host.version);
|
safeConnect(host.address, host.port, host.version);
|
||||||
}
|
}
|
||||||
}).width(w).row();
|
}).width(w).padBottom(7).row();
|
||||||
}
|
}
|
||||||
|
|
||||||
void finishLocalHosts(){
|
void finishLocalHosts(){
|
||||||
@@ -521,7 +554,7 @@ public class JoinDialog extends BaseDialog{
|
|||||||
}
|
}
|
||||||
|
|
||||||
float targetWidth(){
|
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")
|
@SuppressWarnings("unchecked")
|
||||||
|
|||||||
@@ -24,4 +24,4 @@ android.useAndroidX=true
|
|||||||
#used for slow jitpack builds; TODO see if this actually works
|
#used for slow jitpack builds; TODO see if this actually works
|
||||||
org.gradle.internal.http.socketTimeout=100000
|
org.gradle.internal.http.socketTimeout=100000
|
||||||
org.gradle.internal.http.connectionTimeout=100000
|
org.gradle.internal.http.connectionTimeout=100000
|
||||||
archash=ff834fe5c9
|
archash=b139bee16f
|
||||||
|
|||||||
Reference in New Issue
Block a user