use of io.anuke.ucore.scene.ui.layout.Table in project Mindustry by Anuken.
the class SettingsMenuDialog method visible.
private void visible(int index) {
prefs.clearChildren();
Table table = Mathf.select(index, game, graphics, sound);
prefs.add(table);
}
use of io.anuke.ucore.scene.ui.layout.Table in project Mindustry by Anuken.
the class BlocksFragment method showBlockInfo.
public void showBlockInfo(Block block) {
statlist.clear();
block.getStats(statlist);
Label desclabel = new Label(block.fullDescription);
desclabel.setWrap(true);
boolean wasPaused = state.is(State.paused);
state.set(State.paused);
FloatingDialog d = new FloatingDialog("$text.blocks.blockinfo");
Table table = new Table();
table.defaults().pad(1f);
ScrollPane pane = new ScrollPane(table, "clear");
pane.setFadeScrollBars(false);
Table top = new Table();
top.left();
top.add(new Image(Draw.region(block.name))).size(8 * 5 * block.width);
top.add("[accent]" + block.formalName).padLeft(6f);
table.add(top).fill().left();
table.row();
table.add(desclabel).width(600);
table.row();
d.content().add(pane).grow();
if (statlist.size > 0) {
table.add("$text.blocks.extrainfo").padTop(6).padBottom(5).left();
table.row();
}
for (String s : statlist) {
if (s.contains(":")) {
String color = s.substring(0, s.indexOf("]") + 1);
String first = s.substring(color.length(), s.indexOf(":")).replace("/", "").replace(" ", "").toLowerCase();
String last = s.substring(s.indexOf(":"), s.length());
s = color + Bundles.get("text.blocks." + first) + last;
}
table.add(s).left();
table.row();
}
d.buttons().addButton("$text.ok", () -> {
if (!wasPaused)
state.set(State.playing);
d.hide();
}).size(110, 50).pad(10f);
d.show();
}
use of io.anuke.ucore.scene.ui.layout.Table in project Mindustry by Anuken.
the class BlocksFragment method updateRecipe.
void updateRecipe(Recipe recipe) {
if (recipe == null) {
desctable.clear();
return;
}
desctable.clear();
desctable.setTouchable(Touchable.enabled);
desctable.defaults().left();
desctable.left();
desctable.margin(12);
Table header = new Table();
desctable.add(header).left();
desctable.row();
TextureRegion region = Draw.hasRegion(recipe.result.name() + "-icon") ? Draw.region(recipe.result.name() + "-icon") : Draw.region(recipe.result.name());
header.addImage(region).size(8 * 5).padTop(4);
Label nameLabel = new Label(recipe.result.formalName);
nameLabel.setWrap(true);
header.add(nameLabel).padLeft(2).width(120f);
// extra info
if (recipe.result.fullDescription != null) {
header.addButton("?", () -> showBlockInfo(recipe.result)).expandX().padLeft(3).top().right().size(40f, 44f).padTop(-2);
}
desctable.add().pad(2);
Table requirements = new Table();
desctable.row();
desctable.add(requirements);
desctable.left();
for (ItemStack stack : recipe.requirements) {
requirements.addImage(Draw.region("icon-" + stack.item.name)).size(8 * 3);
Label reqlabel = new Label("");
reqlabel.update(() -> {
int current = state.inventory.getAmount(stack.item);
String text = Mathf.clamp(current, 0, stack.amount) + "/" + stack.amount;
reqlabel.setColor(current < stack.amount ? Colors.get("missingitems") : Color.WHITE);
reqlabel.setText(text);
});
requirements.add(reqlabel).left();
requirements.row();
}
desctable.row();
Label label = new Label("[health]" + Bundles.get("text.health") + ": " + recipe.result.health);
label.setWrap(true);
desctable.add(label).width(200).padTop(4).padBottom(2);
}
use of io.anuke.ucore.scene.ui.layout.Table in project Mindustry by Anuken.
the class PlayerListFragment method build.
@Override
public void build() {
new table() {
{
new table("pane") {
{
margin(14f);
new label(() -> Bundles.format(playerGroup.size() == 1 ? "text.players.single" : "text.players", playerGroup.size()));
row();
content.marginRight(13f).marginLeft(13f);
ScrollPane pane = new ScrollPane(content, "clear");
pane.setScrollingDisabled(true, false);
pane.setFadeScrollBars(false);
add(pane).grow();
row();
new table("pane") {
{
margin(12f);
get().addCheck("$text.server.friendlyfire", b -> {
state.friendlyFire = b;
NetEvents.handleFriendlyFireChange(b);
}).growX().update(i -> i.setChecked(state.friendlyFire)).disabled(b -> Net.client()).padRight(5);
new button("$text.server.bans", () -> {
ui.bans.show();
}).padTop(-12).padBottom(-12).fillY().cell.disabled(b -> Net.client());
new button("$text.server.admins", () -> {
ui.admins.show();
}).padTop(-12).padBottom(-12).padRight(-12).fillY().cell.disabled(b -> Net.client());
}
}.pad(10f).growX().end();
}
}.end();
update(t -> {
if (!android) {
visible = Inputs.keyDown("player_list");
}
if (!(Net.active() && !state.is(State.menu))) {
visible = false;
}
if (playerGroup.size() != last) {
rebuild();
last = playerGroup.size();
}
});
visible(() -> visible);
}
}.end();
rebuild();
}
use of io.anuke.ucore.scene.ui.layout.Table in project Mindustry by Anuken.
the class PlayerListFragment method rebuild.
public void rebuild() {
content.clear();
float h = 74f;
for (Player player : playerGroup.all()) {
NetConnection connection = gwt ? null : Net.getConnection(player.clientid);
if (connection == null && Net.server() && !player.isLocal)
continue;
Table button = new Table("button");
button.left();
button.margin(5).marginBottom(10);
Stack stack = new Stack();
BorderImage image = new BorderImage(Draw.region(player.isAndroid ? "ship-standard" : "mech-standard-icon"), 3f);
stack.add(image);
if (!player.isAndroid) {
stack.add(new Element() {
public void draw() {
float s = getWidth() / 12f;
for (int i : Mathf.signs) {
Draw.rect((i < 0 ? player.weaponLeft.name : player.weaponRight.name) + "-equip", x + s * 6 + i * 3 * s, y + s * 6 + 2 * s, -8 * s * i, 8 * s);
}
}
});
}
button.add(stack).size(h);
button.labelWrap("[#" + player.getColor().toString().toUpperCase() + "]" + player.name).width(170f).pad(10);
button.add().grow();
button.addImage("icon-admin").size(14 * 2).visible(() -> player.isAdmin && !(!player.isLocal && Net.server())).padRight(5);
if ((Net.server() || Vars.player.isAdmin) && !player.isLocal && (!player.isAdmin || Net.server())) {
button.add().growY();
float bs = (h + 14) / 2f;
button.table(t -> {
t.defaults().size(bs - 1, bs + 3);
t.addImageButton("icon-ban", 14 * 2, () -> {
ui.showConfirm("$text.confirm", "$text.confirmban", () -> {
if (Net.server()) {
netServer.admins.banPlayerIP(connection.address);
netServer.kick(player.clientid, KickReason.banned);
} else {
NetEvents.handleAdministerRequest(player, AdminAction.ban);
}
});
}).padBottom(-5.1f);
t.addImageButton("icon-cancel", 14 * 2, () -> {
if (Net.server()) {
netServer.kick(player.clientid, KickReason.kick);
} else {
NetEvents.handleAdministerRequest(player, AdminAction.kick);
}
}).padBottom(-5.1f);
t.row();
t.addImageButton("icon-admin", "toggle", 14 * 2, () -> {
if (Net.client())
return;
String id = netServer.admins.getTrace(connection.address).uuid;
if (netServer.admins.isAdmin(id, connection.address)) {
ui.showConfirm("$text.confirm", "$text.confirmunadmin", () -> {
netServer.admins.unAdminPlayer(id);
NetEvents.handleAdminSet(player, false);
});
} else {
ui.showConfirm("$text.confirm", "$text.confirmadmin", () -> {
netServer.admins.adminPlayer(id, connection.address);
NetEvents.handleAdminSet(player, true);
});
}
}).update(b -> {
b.setChecked(player.isAdmin);
b.setDisabled(Net.client());
}).get().setTouchable(() -> Net.client() ? Touchable.disabled : Touchable.enabled);
t.addImageButton("icon-zoom-small", 14 * 2, () -> NetEvents.handleTraceRequest(player));
}).padRight(12).padTop(-5).padLeft(0).padBottom(-10).size(bs + 10f, bs);
}
content.add(button).padBottom(-6).width(350f).maxHeight(h + 14);
content.row();
}
content.marginBottom(5);
}
Aggregations