add names to major fragment elements

This commit is contained in:
DeltaNedas
2020-10-11 12:56:55 +01:00
parent bcb248907c
commit a60ae3a060
4 changed files with 46 additions and 18 deletions

View File

@@ -79,20 +79,23 @@ public class HudFragment extends Fragment{
//paused table //paused table
parent.fill(t -> { parent.fill(t -> {
t.name = "paused";
t.top().visible(() -> state.isPaused()).touchable = Touchable.disabled; t.top().visible(() -> state.isPaused()).touchable = Touchable.disabled;
t.table(Styles.black5, top -> top.add("@paused").style(Styles.outlineLabel).pad(8f)).growX(); t.table(Styles.black5, top -> top.add("@paused").style(Styles.outlineLabel).pad(8f)).growX();
}); });
//minimap + position //minimap + position
parent.fill(t -> { parent.fill(t -> {
t.name = "minimap/position";
t.visible(() -> Core.settings.getBool("minimap") && !state.rules.tutorial && shown); t.visible(() -> Core.settings.getBool("minimap") && !state.rules.tutorial && shown);
//minimap //minimap
t.add(new Minimap()); t.add(new Minimap()).name("minimap");
t.row(); t.row();
//position //position
t.label(() -> player.tileX() + "," + player.tileY()) t.label(() -> player.tileX() + "," + player.tileY())
.visible(() -> Core.settings.getBool("position") && !state.rules.tutorial) .visible(() -> Core.settings.getBool("position") && !state.rules.tutorial)
.touchable(Touchable.disabled); .touchable(Touchable.disabled)
.name("position");
t.top().right(); t.top().right();
}); });
@@ -104,15 +107,18 @@ public class HudFragment extends Fragment{
if(mobile){ if(mobile){
cont.table(select -> { cont.table(select -> {
select.name = "mobile buttons";
select.left(); select.left();
select.defaults().size(dsize).left(); select.defaults().size(dsize).left();
ImageButtonStyle style = Styles.clearTransi; ImageButtonStyle style = Styles.clearTransi;
select.button(Icon.menu, style, ui.paused::show); select.button(Icon.menu, style, ui.paused::show).name("menu");
flip = select.button(Icon.upOpen, style, this::toggleMenus).get(); flip = select.button(Icon.upOpen, style, this::toggleMenus).get();
flip.name = "flip";
select.button(Icon.paste, style, ui.schematics::show); select.button(Icon.paste, style, ui.schematics::show)
.name("schematics");
select.button(Icon.pause, style, () -> { select.button(Icon.pause, style, () -> {
if(net.active()){ if(net.active()){
@@ -141,7 +147,7 @@ public class HudFragment extends Fragment{
}else{ }else{
ui.database.show(); ui.database.show();
} }
}).update(i -> { }).name("chat").update(i -> {
if(net.active() && mobile){ if(net.active() && mobile){
i.getStyle().imageUp = Icon.chat; i.getStyle().imageUp = Icon.chat;
}else if(state.isCampaign()){ }else if(state.isCampaign()){
@@ -167,14 +173,15 @@ public class HudFragment extends Fragment{
Table wavesMain, editorMain; Table wavesMain, editorMain;
cont.stack(wavesMain = new Table(), editorMain = new Table()).height(wavesMain.getPrefHeight()); cont.stack(wavesMain = new Table(), editorMain = new Table()).height(wavesMain.getPrefHeight())
.name("waves/editor");
wavesMain.visible(() -> shown && !state.isEditor()); wavesMain.visible(() -> shown && !state.isEditor());
wavesMain.top().left(); wavesMain.top().left().name = "waves";
wavesMain.table(s -> { wavesMain.table(s -> {
//wave info button with text //wave info button with text
s.add(makeStatusTable()).grow(); s.add(makeStatusTable()).grow().name("status");
//table with button to skip wave //table with button to skip wave
s.button(Icon.play, Styles.righti, 30f, () -> { s.button(Icon.play, Styles.righti, 30f, () -> {
@@ -183,18 +190,22 @@ public class HudFragment extends Fragment{
}else{ }else{
logic.skipWave(); logic.skipWave();
} }
}).growY().fillX().right().width(40f).disabled(b -> !canSkipWave()).visible(() -> state.rules.waves); }).growY().fillX().right().width(40f).disabled(b -> !canSkipWave())
.visible(() -> state.rules.waves).name("skip");
}).width(dsize * 5 + 4f); }).width(dsize * 5 + 4f);
wavesMain.row(); wavesMain.row();
wavesMain.table(Tex.button, t -> t.margin(10f).add(new Bar("boss.health", Pal.health, () -> state.boss() == null ? 0f : state.boss().healthf()).blink(Color.white)) wavesMain.table(Tex.button, t -> t.margin(10f).add(new Bar("boss.health", Pal.health, () -> state.boss() == null ? 0f : state.boss().healthf()).blink(Color.white))
.grow()).fillX().visible(() -> state.rules.waves && state.boss() != null).height(60f).get(); .grow()).fillX().visible(() -> state.rules.waves && state.boss() != null).height(60f).get()
.name = "boss";
wavesMain.row(); wavesMain.row();
editorMain.name = "editor";
editorMain.table(Tex.buttonEdge4, t -> { editorMain.table(Tex.buttonEdge4, t -> {
//t.margin(0f); //t.margin(0f);
t.name("teams");
t.add("@editor.teams").growX().left(); t.add("@editor.teams").growX().left();
t.row(); t.row();
t.table(teams -> { t.table(teams -> {
@@ -215,29 +226,33 @@ public class HudFragment extends Fragment{
}).width(dsize * 5 + 4f); }).width(dsize * 5 + 4f);
editorMain.visible(() -> shown && state.isEditor()); editorMain.visible(() -> shown && state.isEditor());
//fps display //fps display
cont.table(info -> { cont.table(info -> {
info.name = "fps/ping";
info.touchable = Touchable.disabled; info.touchable = Touchable.disabled;
info.top().left().margin(4).visible(() -> Core.settings.getBool("fps") && shown); info.top().left().margin(4).visible(() -> Core.settings.getBool("fps") && shown);
info.update(() -> info.setTranslation(state.rules.waves || state.isEditor() ? 0f : -Scl.scl(dsize * 4 + 3), 0)); info.update(() -> info.setTranslation(state.rules.waves || state.isEditor() ? 0f : -Scl.scl(dsize * 4 + 3), 0));
IntFormat fps = new IntFormat("fps"); IntFormat fps = new IntFormat("fps");
IntFormat ping = new IntFormat("ping"); IntFormat ping = new IntFormat("ping");
info.label(() -> fps.get(Core.graphics.getFramesPerSecond())).left().style(Styles.outlineLabel); info.label(() -> fps.get(Core.graphics.getFramesPerSecond())).left()
.style(Styles.outlineLabel).name("fps");
info.row(); info.row();
info.label(() -> ping.get(netClient.getPing())).visible(net::client).left().style(Styles.outlineLabel); info.label(() -> ping.get(netClient.getPing())).visible(net::client).left()
.style(Styles.outlineLabel).name("ping");
}).top().left(); }).top().left();
}); });
//core items //core items
parent.fill(t -> { parent.fill(t -> {
t.name = "coreitems";
t.top().add(coreItems); t.top().add(coreItems);
t.visible(() -> Core.settings.getBool("coreitems") && !mobile && !state.isPaused() && shown); t.visible(() -> Core.settings.getBool("coreitems") && !mobile && !state.isPaused() && shown);
}); });
//spawner warning //spawner warning
parent.fill(t -> { parent.fill(t -> {
t.name = "nearpoint";
t.touchable = Touchable.disabled; t.touchable = Touchable.disabled;
t.table(Styles.black, c -> c.add("@nearpoint") t.table(Styles.black, c -> c.add("@nearpoint")
.update(l -> l.setColor(Tmp.c1.set(Color.white).lerp(Color.scarlet, Mathf.absin(Time.time(), 10f, 1f)))) .update(l -> l.setColor(Tmp.c1.set(Color.white).lerp(Color.scarlet, Mathf.absin(Time.time(), 10f, 1f))))
@@ -246,12 +261,14 @@ public class HudFragment extends Fragment{
}); });
parent.fill(t -> { parent.fill(t -> {
t.name = "waiting";
t.visible(() -> netServer.isWaitingForPlayers()); t.visible(() -> netServer.isWaitingForPlayers());
t.table(Tex.button, c -> c.add("@waiting.players")); t.table(Tex.button, c -> c.add("@waiting.players"));
}); });
//'core is under attack' table //'core is under attack' table
parent.fill(t -> { parent.fill(t -> {
t.name = "coreattack";
t.touchable = Touchable.disabled; t.touchable = Touchable.disabled;
float notifDuration = 240f; float notifDuration = 240f;
float[] coreAttackTime = {0}; float[] coreAttackTime = {0};
@@ -285,6 +302,7 @@ public class HudFragment extends Fragment{
//tutorial text //tutorial text
parent.fill(t -> { parent.fill(t -> {
t.name = "tutorial";
Runnable resize = () -> { Runnable resize = () -> {
t.clearChildren(); t.clearChildren();
t.top().right().visible(() -> state.rules.tutorial); t.top().right().visible(() -> state.rules.tutorial);
@@ -307,11 +325,13 @@ public class HudFragment extends Fragment{
//'saving' indicator //'saving' indicator
parent.fill(t -> { parent.fill(t -> {
t.name = "saving";
t.bottom().visible(() -> control.saves.isSaving()); t.bottom().visible(() -> control.saves.isSaving());
t.add("@saving").style(Styles.outlineLabel); t.add("@saving").style(Styles.outlineLabel);
}); });
parent.fill(p -> { parent.fill(p -> {
p.name = "hudtext";
p.top().table(Styles.black3, t -> t.margin(4).label(() -> hudText) p.top().table(Styles.black3, t -> t.margin(4).label(() -> hudText)
.style(Styles.outlineLabel)).padTop(10).visible(p.color.a >= 0.001f); .style(Styles.outlineLabel)).padTop(10).visible(p.color.a >= 0.001f);
p.update(() -> { p.update(() -> {
@@ -327,6 +347,7 @@ public class HudFragment extends Fragment{
//TODO DEBUG: rate table //TODO DEBUG: rate table
if(false) if(false)
parent.fill(t -> { parent.fill(t -> {
t.name = "rates";
t.bottom().left(); t.bottom().left();
t.table(Styles.black6, c -> { t.table(Styles.black6, c -> {
Bits used = new Bits(content.items().size); Bits used = new Bits(content.items().size);

View File

@@ -45,6 +45,7 @@ public class MenuFragment extends Fragment{
parent.fill(c -> { parent.fill(c -> {
container = c; container = c;
c.name = "menu container";
if(!mobile){ if(!mobile){
buildDesktop(); buildDesktop();
@@ -57,8 +58,8 @@ public class MenuFragment extends Fragment{
//info icon //info icon
if(mobile){ if(mobile){
parent.fill(c -> c.bottom().left().button("", Styles.infot, ui.about::show).size(84, 45)); parent.fill(c -> c.bottom().left().button("", Styles.infot, ui.about::show).size(84, 45).name("info"));
parent.fill(c -> c.bottom().right().button("", Styles.discordt, ui.discord::show).size(84, 45)); parent.fill(c -> c.bottom().right().button("", Styles.discordt, ui.discord::show).size(84, 45).name("discord"));
}else if(becontrol.active()){ }else if(becontrol.active()){
parent.fill(c -> c.bottom().right().button("@be.check", Icon.refresh, () -> { parent.fill(c -> c.bottom().right().button("@be.check", Icon.refresh, () -> {
ui.loadfrag.show(); ui.loadfrag.show();
@@ -68,7 +69,7 @@ public class MenuFragment extends Fragment{
ui.showInfo("@be.noupdates"); ui.showInfo("@be.noupdates");
} }
}); });
}).size(200, 60).update(t -> { }).size(200, 60).name("becheck").update(t -> {
t.getLabel().setColor(becontrol.isUpdateAvailable() ? Tmp.c1.set(Color.white).lerp(Pal.accent, Mathf.absin(5f, 1f)) : Color.white); t.getLabel().setColor(becontrol.isUpdateAvailable() ? Tmp.c1.set(Color.white).lerp(Pal.accent, Mathf.absin(5f, 1f)) : Color.white);
})); }));
} }
@@ -93,6 +94,7 @@ public class MenuFragment extends Fragment{
private void buildMobile(){ private void buildMobile(){
container.clear(); container.clear();
container.name = "buttons";
container.setSize(Core.graphics.getWidth(), Core.graphics.getHeight()); container.setSize(Core.graphics.getWidth(), Core.graphics.getHeight());
float size = 120f; float size = 120f;
@@ -153,7 +155,6 @@ public class MenuFragment extends Fragment{
container.clear(); container.clear();
container.setSize(Core.graphics.getWidth(), Core.graphics.getHeight()); container.setSize(Core.graphics.getWidth(), Core.graphics.getHeight());
float width = 230f; float width = 230f;
Drawable background = Styles.black6; Drawable background = Styles.black6;
@@ -161,6 +162,7 @@ public class MenuFragment extends Fragment{
container.add().width(Core.graphics.getWidth()/10f); container.add().width(Core.graphics.getWidth()/10f);
container.table(background, t -> { container.table(background, t -> {
t.defaults().width(width).height(70f); t.defaults().width(width).height(70f);
t.name = "buttons";
buttons(t, buttons(t,
new Buttoni("@play", Icon.play, new Buttoni("@play", Icon.play,
@@ -183,6 +185,7 @@ public class MenuFragment extends Fragment{
container.table(background, t -> { container.table(background, t -> {
submenu = t; submenu = t;
t.name = "submenu";
t.color.a = 0f; t.color.a = 0f;
t.top(); t.top();
t.defaults().width(width).height(70f); t.defaults().width(width).height(70f);

View File

@@ -24,7 +24,9 @@ public class PlayerListFragment extends Fragment{
@Override @Override
public void build(Group parent){ public void build(Group parent){
content.name = "players";
parent.fill(cont -> { parent.fill(cont -> {
cont.name = "playerlist";
cont.visible(() -> visible); cont.visible(() -> visible);
cont.update(() -> { cont.update(() -> {
if(!(net.active() && state.isGame())){ if(!(net.active() && state.isGame())){
@@ -47,6 +49,7 @@ public class PlayerListFragment extends Fragment{
sField = pane.field(null, text -> { sField = pane.field(null, text -> {
rebuild(); rebuild();
}).grow().pad(8).get(); }).grow().pad(8).get();
sField.name = "search";
sField.setMaxLength(maxNameLength); sField.setMaxLength(maxNameLength);
sField.setMessageText(Core.bundle.format("players.search")); sField.setMessageText(Core.bundle.format("players.search"));
@@ -56,6 +59,7 @@ public class PlayerListFragment extends Fragment{
pane.table(menu -> { pane.table(menu -> {
menu.defaults().growX().height(50f).fillY(); menu.defaults().growX().height(50f).fillY();
menu.name = "menu";
menu.button("@server.bans", ui.bans::show).disabled(b -> net.client()); menu.button("@server.bans", ui.bans::show).disabled(b -> net.client());
menu.button("@server.admins", ui.admins::show).disabled(b -> net.client()); menu.button("@server.admins", ui.admins::show).disabled(b -> net.client());
@@ -99,6 +103,7 @@ public class PlayerListFragment extends Fragment{
}; };
table.margin(8); table.margin(8);
table.add(new Image(user.icon()).setScaling(Scaling.bounded)).grow(); table.add(new Image(user.icon()).setScaling(Scaling.bounded)).grow();
table.name = user.name();
button.add(table).size(h); button.add(table).size(h);
button.labelWrap("[#" + user.color().toString().toUpperCase() + "]" + user.name()).width(170f).pad(10); button.labelWrap("[#" + user.color().toString().toUpperCase() + "]" + user.name()).width(170f).pad(10);

View File

@@ -39,7 +39,6 @@ public class ScriptConsoleFragment extends Table{
}; };
public ScriptConsoleFragment(){ public ScriptConsoleFragment(){
setFillParent(true); setFillParent(true);
font = Fonts.def; font = Fonts.def;