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

@@ -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);
}
});
}