Some more sharing revisions

This commit is contained in:
Anuken
2018-05-19 20:19:47 -07:00
parent 8ca861360b
commit 8d66d43a98
25 changed files with 57 additions and 37 deletions

View File

@ -105,7 +105,7 @@ text.savefail=Failed to save game!
text.save.delete.confirm=Are you sure you want to delete this save?
text.save.delete=Delete
text.save.export=Export Save
text.save.import.invalid=[orange]This save is invalid!
text.save.import.invalid=[orange]This save is invalid!\n\nNote that[scarlet]importing saves with custom maps[orange]\nfrom other devices does not work!
text.save.import.fail=[crimson]Failed to import save: [orange]{0}
text.save.export.fail=[crimson]Failed to export save: [orange]{0}
text.save.import=Import Save

View File

@ -86,7 +86,7 @@ public class Saves {
current = slot;
}
public void importSave(FileHandle file) throws IOException{
public SaveSlot importSave(FileHandle file) throws IOException{
SaveSlot slot = new SaveSlot(nextSlot);
slot.importFile(file);
nextSlot ++;
@ -94,6 +94,7 @@ public class Saves {
saves.add(slot);
slot.meta = SaveIO.getData(slot.index);
current = slot;
return slot;
}
public Array<SaveSlot> getSaveSlots(){

View File

@ -165,26 +165,30 @@ public class LoadDialog extends FloatingDialog{
}).fillX().margin(10f).minWidth(300f).height(70f).pad(4f).padRight(-4);
}
public void runLoadSave(SaveSlot slot){
ui.loadfrag.show();
Timers.runTask(3f, () -> {
ui.loadfrag.hide();
hide();
try{
slot.load();
state.set(State.playing);
ui.paused.hide();
}catch(Exception e){
Log.err(e);
ui.paused.hide();
state.set(State.menu);
logic.reset();
ui.showError("$text.save.corrupted");
}
});
}
public void modifyButton(TextButton button, SaveSlot slot){
button.clicked(() -> {
if(!button.childrenPressed()){
ui.loadfrag.show();
Timers.runTask(3f, () -> {
ui.loadfrag.hide();
hide();
try{
slot.load();
state.set(State.playing);
ui.paused.hide();
}catch(Exception e){
Log.err(e);
ui.paused.hide();
state.set(State.menu);
logic.reset();
ui.showError("$text.save.corrupted");
}
});
runLoadSave(slot);
}
});
}