use of io.anuke.mindustry.io.Saves.SaveSlot 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();
}
Aggregations