use of io.anuke.mindustry.ui.BorderImage 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);
}
use of io.anuke.mindustry.ui.BorderImage in project Mindustry by Anuken.
the class MapLoadDialog method rebuild.
public void rebuild() {
content().clear();
selected = world.maps().getMap(0);
ButtonGroup<TextButton> group = new ButtonGroup<>();
int maxcol = 3;
int i = 0;
Table table = new Table();
table.defaults().size(200f, 90f).pad(4f);
table.margin(10f);
ScrollPane pane = new ScrollPane(table, "horizontal");
pane.setFadeScrollBars(false);
for (Map map : world.maps().list()) {
if (!map.visible)
continue;
TextButton button = new TextButton(map.localized(), "toggle");
button.add(new BorderImage(map.texture, 2f)).size(16 * 4f);
button.getCells().reverse();
button.clicked(() -> selected = map);
button.getLabelCell().grow().left().padLeft(5f);
group.add(button);
table.add(button);
if (++i % maxcol == 0)
table.row();
}
content().add("$text.editor.loadmap");
content().row();
content().add(pane);
}
Aggregations