use of io.anuke.ucore.scene.ui.ScrollPane 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.ScrollPane 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.ScrollPane in project Mindustry by Anuken.
the class BansDialog method setup.
private void setup() {
content().clear();
if (gwt)
return;
float w = 400f, h = 80f;
Table table = new Table();
ScrollPane pane = new ScrollPane(table, "clear");
pane.setFadeScrollBars(false);
if (netServer.admins.getBanned().size == 0) {
table.add("$text.server.bans.none");
}
for (PlayerInfo info : netServer.admins.getBanned()) {
Table res = new Table("button");
res.margin(14f);
res.labelWrap("IP: [LIGHT_GRAY]" + info.lastIP + "\n[]Name: [LIGHT_GRAY]" + info.lastName).width(w - h - 24f);
res.add().growX();
res.addImageButton("icon-cancel", 14 * 3, () -> {
ui.showConfirm("$text.confirm", "$text.confirmunban", () -> {
netServer.admins.unbanPlayerID(info.id);
setup();
});
}).size(h).pad(-14f);
table.add(res).width(w).height(h);
table.row();
}
content().add(pane);
}
use of io.anuke.ucore.scene.ui.ScrollPane in project Mindustry by Anuken.
the class ChangelogDialog method setup.
void setup() {
Table table = new Table();
ScrollPane pane = new ScrollPane(table, "clear");
content().clear();
content().add(pane).grow();
if (versions == null) {
table.add("$text.changelog.error");
if (Vars.android) {
table.row();
table.add("$text.changelog.error.android").padTop(8);
}
} else {
for (VersionInfo info : versions) {
Table in = new Table("clear");
in.top().left().margin(10);
in.add("[accent]" + info.name);
if (info.build == Version.build) {
in.row();
in.add("$text.changelog.current");
} else if (info == versions.first()) {
in.row();
in.add("$text.changelog.latest");
}
in.row();
in.labelWrap("[lightgray]" + info.description).width(vw - 20).padTop(12);
table.add(in).width(vw).pad(8).row();
}
int lastid = Settings.getInt("lastBuild");
if (lastid != 0 && versions.peek().build > lastid) {
Settings.putInt("lastBuild", versions.peek().build);
Settings.save();
show();
}
}
}
use of io.anuke.ucore.scene.ui.ScrollPane in project Mindustry by Anuken.
the class JoinDialog method setup.
void setup() {
hosts.clear();
hosts.add(remote).growX();
hosts.row();
hosts.add(local).width(w);
ScrollPane pane = new ScrollPane(hosts, "clear");
pane.setFadeScrollBars(false);
pane.setScrollingDisabled(true, false);
setupRemote();
refreshRemote();
content().clear();
content().table(t -> {
t.add("$text.name").padRight(10);
t.addField(Settings.getString("name"), text -> {
if (text.isEmpty())
return;
Vars.player.name = text;
Settings.put("name", text);
Settings.save();
}).grow().pad(8).get().setMaxLength(40);
ImageButton button = t.addImageButton("white", 40, () -> {
new ColorPickDialog().show(color -> {
player.color.set(color);
Settings.putInt("color", Color.rgba8888(color));
Settings.save();
});
}).size(50f, 54f).get();
button.update(() -> button.getStyle().imageUpColor = player.getColor());
}).width(w).height(70f).pad(4);
content().row();
content().add(pane).width(w + 34).pad(0);
content().row();
content().addCenteredImageTextButton("$text.server.add", "icon-add", "clear", 14 * 3, () -> {
renaming = null;
add.show();
}).marginLeft(6).width(w).height(80f).update(button -> {
float pw = w;
float pad = 0f;
if (pane.getChildren().first().getPrefHeight() > pane.getHeight()) {
pw = w + 30;
pad = 6;
}
Cell<TextButton> cell = ((Table) pane.getParent()).getCell(button);
if (!MathUtils.isEqual(cell.getMinWidth(), pw)) {
cell.width(pw);
cell.padLeft(pad);
pane.getParent().invalidateHierarchy();
}
});
}
Aggregations