use of io.anuke.ucore.scene.ui.layout.Table in project Mindustry by Anuken.
the class ToolFragment method build.
public void build() {
InputHandler input = control.input();
float isize = 14 * 3;
tools = new Table();
tools.addImageButton("icon-cancel", isize, () -> {
if (input.placeMode == PlaceMode.areaDelete && confirming) {
confirming = false;
} else {
input.recipe = null;
}
});
tools.addImageButton("icon-rotate", isize, () -> {
input.rotation++;
input.rotation %= 4;
});
tools.addImageButton("icon-check", isize, () -> {
if (input.placeMode == PlaceMode.areaDelete && confirming) {
input.placeMode.released(px, py, px2, py2);
confirming = false;
} else {
input.placeMode.tapped(control.input().getBlockX(), control.input().getBlockY());
}
});
Core.scene.add(tools);
tools.setVisible(() -> !state.is(State.menu) && android && ((input.recipe != null && state.inventory.hasItems(input.recipe.requirements) && input.placeMode == PlaceMode.cursor) || confirming));
tools.update(() -> {
if (confirming) {
Vector2 v = Graphics.screen((px + px2) / 2f * tilesize, Math.min(py, py2) * tilesize - tilesize * 1.5f);
tools.setPosition(v.x, v.y, Align.top);
} else {
tools.setPosition(control.input().getCursorX(), Gdx.graphics.getHeight() - control.input().getCursorY() - 15 * Core.cameraScale, Align.top);
}
if (input.placeMode != PlaceMode.areaDelete) {
confirming = false;
}
});
}
use of io.anuke.ucore.scene.ui.layout.Table in project Mindustry by Anuken.
the class JoinDialog method setupRemote.
void setupRemote() {
remote.clear();
for (Server server : servers) {
// why are java lambdas this bad
TextButton[] buttons = { null };
TextButton button = buttons[0] = remote.addButton("[accent]" + server.ip, "clear", () -> {
if (!buttons[0].childrenPressed())
connect(server.ip, Vars.port);
}).width(w).height(150f).pad(4f).get();
button.getLabel().setWrap(true);
Table inner = new Table();
button.clearChildren();
button.add(inner).growX();
inner.add(button.getLabel()).growX();
inner.addImageButton("icon-loading", "empty", 16 * 2, () -> {
refreshServer(server);
}).margin(3f).padTop(6f).top().right();
inner.addImageButton("icon-pencil", "empty", 16 * 2, () -> {
renaming = server;
add.show();
}).margin(3f).padTop(6f).top().right();
inner.addImageButton("icon-trash-16", "empty", 16 * 2, () -> {
ui.showConfirm("$text.confirm", "$text.server.delete", () -> {
servers.removeValue(server, true);
saveServers();
setupRemote();
refreshRemote();
});
}).margin(3f).pad(6).top().right();
button.row();
server.content = button.table(t -> {
}).grow().get();
remote.row();
}
}
use of io.anuke.ucore.scene.ui.layout.Table in project Mindustry by Anuken.
the class LoadDialog method setup.
protected void setup() {
content().clear();
slots = new Table();
pane = new ScrollPane(slots, "clear-black");
pane.setFadeScrollBars(false);
pane.setScrollingDisabled(true, false);
slots.marginRight(24);
Timers.runTask(2f, () -> Core.scene.setScrollFocus(pane));
Array<SaveSlot> array = control.getSaves().getSaveSlots();
for (SaveSlot slot : array) {
TextButton button = new TextButton("[accent]" + slot.getName(), "clear");
button.getLabelCell().growX().left();
button.getLabelCell().padBottom(8f);
button.getLabelCell().top().left().growX();
button.defaults().left();
button.table(t -> {
t.right();
t.addImageButton("icon-floppy", "emptytoggle", 14 * 3, () -> {
slot.setAutosave(!slot.isAutosave());
}).checked(slot.isAutosave()).right();
t.addImageButton("icon-trash", "empty", 14 * 3, () -> {
ui.showConfirm("$text.confirm", "$text.save.delete.confirm", () -> {
slot.delete();
setup();
});
}).size(14 * 3).right();
t.addImageButton("icon-pencil-small", "empty", 14 * 3, () -> {
ui.showTextInput("$text.save.rename", "$text.save.rename.text", slot.getName(), text -> {
slot.setName(text);
setup();
});
}).size(14 * 3).right();
if (!gwt) {
t.addImageButton("icon-save", "empty", 14 * 3, () -> {
new FileChooser("$text.save.export", false, file -> {
try {
slot.exportFile(file);
setup();
} catch (IOException e) {
ui.showError(Bundles.format("text.save.export.fail", Strings.parseException(e, false)));
}
}).show();
}).size(14 * 3).right();
}
}).padRight(-10).growX();
String color = "[lightgray]";
button.defaults().padBottom(3);
button.row();
button.add(Bundles.format("text.save.map", color + slot.getMap().localized()));
button.row();
button.add(Bundles.get("text.level.mode") + " " + color + slot.getMode());
button.row();
button.add(Bundles.format("text.save.wave", color + slot.getWave()));
button.row();
button.add(Bundles.format("text.save.difficulty", color + slot.getDifficulty()));
button.row();
button.label(() -> Bundles.format("text.save.autosave", color + Bundles.get(slot.isAutosave() ? "text.on" : "text.off")));
button.row();
button.add();
button.add(Bundles.format("text.save.date", color + slot.getDate()));
button.row();
modifyButton(button, slot);
slots.add(button).uniformX().fillX().pad(4).padRight(-4).margin(10f).marginLeft(20f).marginRight(20f);
slots.row();
}
content().add(pane);
addSetup();
}
use of io.anuke.ucore.scene.ui.layout.Table in project Mindustry by Anuken.
the class TraceDialog method show.
public void show(Player player, TraceInfo info) {
content().clear();
Table table = new Table("button");
table.margin(14);
table.defaults().pad(1);
table.defaults().left();
table.add(Bundles.format("text.trace.playername", player.name));
table.row();
table.add(Bundles.format("text.trace.ip", info.ip));
table.row();
table.add(Bundles.format("text.trace.id", info.uuid));
table.row();
table.add(Bundles.format("text.trace.modclient", info.modclient));
table.row();
table.add(Bundles.format("text.trace.android", info.android));
table.row();
table.add().pad(5);
table.row();
table.add(Bundles.format("text.trace.totalblocksbroken", info.totalBlocksBroken));
table.row();
table.add(Bundles.format("text.trace.structureblocksbroken", info.structureBlocksBroken));
table.row();
table.add(Bundles.format("text.trace.lastblockbroken", info.lastBlockBroken.formalName));
table.row();
table.add().pad(5);
table.row();
table.add(Bundles.format("text.trace.totalblocksplaced", info.totalBlocksPlaced));
table.row();
table.add(Bundles.format("text.trace.lastblockplaced", info.lastBlockPlaced.formalName));
table.row();
content().add(table);
show();
}
use of io.anuke.ucore.scene.ui.layout.Table in project Mindustry by Anuken.
the class BlockConfigFragment method build.
@Override
public void build() {
table = new Table();
Core.scene.add(table);
}
Aggregations