command window

This commit is contained in:
sharlottes
2022-04-13 01:12:44 +09:00
parent 35e6b5550b
commit e7db1dfbfe
3 changed files with 69 additions and 2 deletions

View File

@@ -18,7 +18,8 @@ public class HUDFragment extends Fragment{
unitTable,
waveTable,
coreTable,
playerTable
playerTable,
commandTable
)).visible(TaskbarTable.visibility);
// windows (totally not a copyright violation)
@@ -26,6 +27,7 @@ public class HUDFragment extends Fragment{
t.add(waveTable).size(250f).visible(false);
t.add(coreTable).size(250f).visible(false);
t.add(playerTable).size(250f).visible(false);
t.add(commandTable).size(250f).visible(false);
t.update(()->{
for (Element child : t.getChildren()) {

View File

@@ -0,0 +1,64 @@
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.forEach(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();
}
});
}
}

View File

@@ -2,12 +2,13 @@ package UnitInfo.ui.windows;
public class WindowTables {
public static WindowTable
unitTable, waveTable, coreTable, playerTable;
unitTable, waveTable, coreTable, playerTable, commandTable;
public static void init() {
unitTable = new UnitDisplay();
waveTable = new WaveDisplay();
coreTable = new CoreDisplay();
playerTable = new PlayerDisplay();
commandTable = new CommandDisplay();
}
}