Merge pull request #2905 from DeltaNedas/uinames

add names to lots of ui elements
This commit is contained in:
Anuken
2020-10-11 10:36:18 -04:00
committed by GitHub
7 changed files with 80 additions and 52 deletions

View File

@@ -38,14 +38,15 @@ public class PausedDialog extends BaseDialog{
cont.label(() -> state.getSector() == null ? "" : cont.label(() -> state.getSector() == null ? "" :
("[lightgray]Next turn in [accent]" + state.getSector().displayTimeRemaining() + ("[lightgray]Next turn in [accent]" + state.getSector().displayTimeRemaining() +
(state.rules.winWave > 0 && !state.getSector().isCaptured() ? "\n[lightgray]Reach wave[accent] " + state.rules.winWave + "[] to capture" : ""))) (state.rules.winWave > 0 && !state.getSector().isCaptured() ? "\n[lightgray]Reach wave[accent] " + state.rules.winWave + "[] to capture" : "")))
.visible(() -> state.getSector() != null).colspan(2); .visible(() -> state.getSector() != null).colspan(2)
.name("turn");
cont.row(); cont.row();
float dw = 220f; float dw = 220f;
cont.defaults().width(dw).height(55).pad(5f); cont.defaults().width(dw).height(55).pad(5f);
cont.button("@back", Icon.left, this::hide); cont.button("@back", Icon.left, this::hide).name("back");
cont.button("@settings", Icon.settings, ui.settings::show); cont.button("@settings", Icon.settings, ui.settings::show).name("settings");
if(!state.rules.tutorial){ if(!state.rules.tutorial){
if(!state.isCampaign() && !state.isEditor()){ if(!state.isCampaign() && !state.isEditor()){

View File

@@ -32,18 +32,18 @@ public class PlanetDialog extends BaseDialog implements PlanetInterfaceRenderer{
//if true, enables launching anywhere for testing //if true, enables launching anywhere for testing
public static boolean debugSelect = false; public static boolean debugSelect = false;
final FrameBuffer buffer = new FrameBuffer(2, 2, true); public final FrameBuffer buffer = new FrameBuffer(2, 2, true);
final PlanetRenderer planets = renderer.planets; public final PlanetRenderer planets = renderer.planets;
final LaunchLoadoutDialog loadouts = new LaunchLoadoutDialog(); public final LaunchLoadoutDialog loadouts = new LaunchLoadoutDialog();
final Table stable = new Table().background(Styles.black3); public final Table stable = new Table().background(Styles.black3);
int launchRange; public int launchRange;
float zoom = 1f, selectAlpha = 1f; public float zoom = 1f, selectAlpha = 1f;
@Nullable Sector selected, hovered, launchSector; public @Nullable Sector selected, hovered, launchSector;
CoreBuild launcher; public CoreBuild launcher;
Mode mode = look; public Mode mode = look;
boolean launching; public boolean launching;
Cons<Sector> listener = s -> {}; public Cons<Sector> listener = s -> {};
public PlanetDialog(){ public PlanetDialog(){
super("", Styles.fullDialog); super("", Styles.fullDialog);
@@ -237,7 +237,6 @@ public class PlanetDialog extends BaseDialog implements PlanetInterfaceRenderer{
cont.clear(); cont.clear();
titleTable.remove(); titleTable.remove();
cont.stack( cont.stack(
new Element(){ new Element(){
{ {
@@ -468,7 +467,7 @@ public class PlanetDialog extends BaseDialog implements PlanetInterfaceRenderer{
stable.act(0f); stable.act(0f);
} }
enum Mode{ public enum Mode{
/** Look around for existing sectors. Can only deploy. */ /** Look around for existing sectors. Can only deploy. */
look, look,
/** Launch to a new location. */ /** Launch to a new location. */

View File

@@ -31,14 +31,14 @@ import java.util.*;
import static mindustry.Vars.*; import static mindustry.Vars.*;
public class ResearchDialog extends BaseDialog{ public class ResearchDialog extends BaseDialog{
final float nodeSize = Scl.scl(60f); public final float nodeSize = Scl.scl(60f);
ObjectSet<TechTreeNode> nodes = new ObjectSet<>(); public ObjectSet<TechTreeNode> nodes = new ObjectSet<>();
TechTreeNode root = new TechTreeNode(TechTree.root, null); public TechTreeNode root = new TechTreeNode(TechTree.root, null);
Rect bounds = new Rect(); public Rect bounds = new Rect();
ItemsDisplay itemDisplay; public ItemsDisplay itemDisplay;
View view; public View view;
ItemSeq items; public ItemSeq items;
public ResearchDialog(){ public ResearchDialog(){
super(""); super("");
@@ -114,7 +114,7 @@ public class ResearchDialog extends BaseDialog{
buttons.button("@database", Icon.book, () -> { buttons.button("@database", Icon.book, () -> {
hide(); hide();
ui.database.show(); ui.database.show();
}).size(210f, 64f); }).size(210f, 64f).name("database");
//scaling/drag input //scaling/drag input
addListener(new InputListener(){ addListener(new InputListener(){
@@ -250,7 +250,7 @@ public class ResearchDialog extends BaseDialog{
return node.content.unlocked() || !node.objectives.contains(i -> !i.complete()); return node.content.unlocked() || !node.objectives.contains(i -> !i.complete());
} }
void showToast(String info){ public void showToast(String info){
Table table = new Table(); Table table = new Table();
table.actions(Actions.fadeOut(0.5f, Interp.fade), Actions.remove()); table.actions(Actions.fadeOut(0.5f, Interp.fade), Actions.remove());
table.top().add(info); table.top().add(info);
@@ -279,11 +279,11 @@ public class ResearchDialog extends BaseDialog{
} }
} }
class TechTreeNode extends TreeNode<TechTreeNode>{ public class TechTreeNode extends TreeNode<TechTreeNode>{
final TechNode node; public final TechNode node;
boolean visible = true, selectable = true; public boolean visible = true, selectable = true;
TechTreeNode(TechNode node, TechTreeNode parent){ public TechTreeNode(TechNode node, TechTreeNode parent){
this.node = node; this.node = node;
this.parent = parent; this.parent = parent;
this.width = this.height = nodeSize; this.width = this.height = nodeSize;
@@ -297,11 +297,11 @@ public class ResearchDialog extends BaseDialog{
} }
} }
class View extends Group{ public class View extends Group{
float panX = 0, panY = -200, lastZoom = -1; public float panX = 0, panY = -200, lastZoom = -1;
boolean moved = false; public boolean moved = false;
ImageButton hoverNode; public ImageButton hoverNode;
Table infoTable = new Table(); public Table infoTable = new Table();
{ {
infoTable.touchable = Touchable.enabled; infoTable.touchable = Touchable.enabled;

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;