mirror of
https://github.com/yawaflua/Informatis.git
synced 2025-12-10 03:59:26 +02:00
command window
This commit is contained in:
@@ -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()) {
|
||||
|
||||
64
src/UnitInfo/ui/windows/CommandDisplay.java
Normal file
64
src/UnitInfo/ui/windows/CommandDisplay.java
Normal 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();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user