mirror of
https://github.com/yawaflua/Informatis.git
synced 2025-12-15 17:56:24 +02:00
add ToolDisplay
This commit is contained in:
@@ -1,64 +0,0 @@
|
||||
package UnitInfo.ui.windows;
|
||||
|
||||
import UnitInfo.ui.OverScrollPane;
|
||||
import arc.Core;
|
||||
import arc.math.geom.Vec2;
|
||||
import arc.scene.ui.TextField;
|
||||
import arc.scene.ui.layout.Table;
|
||||
import arc.scene.utils.Elem;
|
||||
import arc.struct.Seq;
|
||||
import arc.util.CommandHandler;
|
||||
import mindustry.Vars;
|
||||
import mindustry.gen.Icon;
|
||||
import mindustry.graphics.Pal;
|
||||
import mindustry.ui.Styles;
|
||||
|
||||
public class CommandDisplay extends WindowTable {
|
||||
Vec2 scrollPos = new Vec2(0, 0);
|
||||
|
||||
public CommandDisplay() {
|
||||
super("Command Display", Icon.commandRally, t -> {
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void build() {
|
||||
scrollPos = new Vec2(0, 0);
|
||||
top();
|
||||
topBar();
|
||||
|
||||
table(Styles.black8, table -> {
|
||||
table.add(new OverScrollPane(rebuild(), Styles.nonePane, scrollPos).disableScroll(true, false)).grow().name("player-pane");
|
||||
}).top().right().grow().get().parent = null;
|
||||
|
||||
resizeButton();
|
||||
}
|
||||
|
||||
public Table rebuild() {
|
||||
return new Table(table -> {
|
||||
for(CommandHandler.Command cmd : Vars.netServer.clientCommands.getCommandList()) {
|
||||
table.table(cmdtable-> {
|
||||
Seq<TextField> fields = new Seq<>();
|
||||
cmdtable.table(body->{
|
||||
body.left();
|
||||
body.table(main->{
|
||||
main.add(cmd.text);
|
||||
for(CommandHandler.CommandParam param : cmd.params) {
|
||||
TextField field = main.field(null, f->{}).get();
|
||||
field.setMessageText(param.name);
|
||||
fields.add(field);
|
||||
}
|
||||
}).left().row();
|
||||
body.add(cmd.description).color(Pal.gray).left().row();
|
||||
}).minWidth(400f).left();
|
||||
cmdtable.button(Icon.play, ()->{
|
||||
final String[] params = {""};
|
||||
fields.each(f-> params[0] +=" "+f.getText());
|
||||
Vars.netServer.clientCommands.handleMessage(Vars.netServer.clientCommands.getPrefix()+cmd.text+params[0], Vars.player);
|
||||
});
|
||||
}).row();
|
||||
table.image().height(4f).color(Pal.gray).growX().row();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
85
src/UnitInfo/ui/windows/ToolDisplay.java
Normal file
85
src/UnitInfo/ui/windows/ToolDisplay.java
Normal file
@@ -0,0 +1,85 @@
|
||||
package UnitInfo.ui.windows;
|
||||
|
||||
import UnitInfo.ui.OverScrollPane;
|
||||
import UnitInfo.ui.Updatable;
|
||||
import UnitInfo.ui.draws.OverDraw;
|
||||
import UnitInfo.ui.draws.OverDraws;
|
||||
import UnitInfo.ui.draws.UnitDraw;
|
||||
import arc.math.Scaled;
|
||||
import arc.math.geom.Vec2;
|
||||
import arc.scene.ui.ScrollPane;
|
||||
import arc.scene.ui.layout.Table;
|
||||
import arc.util.Scaling;
|
||||
import arc.util.Time;
|
||||
import mindustry.gen.Icon;
|
||||
import mindustry.gen.Tex;
|
||||
import mindustry.graphics.Pal;
|
||||
import mindustry.ui.Styles;
|
||||
|
||||
public class ToolDisplay extends WindowTable implements Updatable {
|
||||
Vec2 scrollPos = new Vec2(0, 0);
|
||||
OverDraw selected;
|
||||
float heat;
|
||||
|
||||
public ToolDisplay() {
|
||||
super("Tool Display", Icon.edit, t -> {
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void build() {
|
||||
scrollPos = new Vec2(0, 0);
|
||||
|
||||
top();
|
||||
topBar();
|
||||
|
||||
table(Styles.black8, t -> {
|
||||
t.left();
|
||||
t.table(pane->{
|
||||
pane.add(new OverScrollPane(rebuild(), Styles.nonePane, scrollPos).disableScroll(true, false)).name("tool-pane");
|
||||
}).top().marginLeft(4f).marginRight(12f);
|
||||
t.table(stats->{
|
||||
stats.top();
|
||||
stats.add(rebuildStats()).name("tool-stats");
|
||||
}).growY();
|
||||
}).top().right().grow().get().parent = null;
|
||||
|
||||
resizeButton();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update() {
|
||||
heat += Time.delta;
|
||||
if(heat >= 60f) {
|
||||
heat = 0f;
|
||||
ScrollPane pane = find("tool-pane");
|
||||
pane.setWidget(rebuild());
|
||||
}
|
||||
}
|
||||
|
||||
Table rebuild() {
|
||||
return new Table(icons->{
|
||||
for(OverDraw draw : OverDraws.all) {
|
||||
icons.button(draw.icon, ()->{
|
||||
selected=draw;
|
||||
Table table = find("tool-stats");
|
||||
table.clearChildren();
|
||||
table.add(rebuildStats());
|
||||
}).grow().tooltip(t->t.background(Styles.black8).add(draw.name).color(Pal.accent)).row();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Table rebuildStats() {
|
||||
return new Table(tool->{
|
||||
if(selected==null) return;
|
||||
tool.top();
|
||||
tool.table(Tex.underline2, label->label.add(selected.name).color(Pal.accent)).row();
|
||||
tool.table(des-> selected.displayStats(des)).name("unit-stats").row();
|
||||
tool.check("enable", selected.enabled, c->{
|
||||
selected.enabled=c;
|
||||
selected.onEnabled(find("unit-stats"));
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -2,13 +2,13 @@ package UnitInfo.ui.windows;
|
||||
|
||||
public class WindowTables {
|
||||
public static WindowTable
|
||||
unitTable, waveTable, coreTable, playerTable, commandTable;
|
||||
unitTable, waveTable, coreTable, playerTable, toolTable;
|
||||
|
||||
public static void init() {
|
||||
unitTable = new UnitDisplay();
|
||||
waveTable = new WaveDisplay();
|
||||
coreTable = new CoreDisplay();
|
||||
playerTable = new PlayerDisplay();
|
||||
commandTable = new CommandDisplay();
|
||||
toolTable = new ToolDisplay();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user