Mod corruption load warnings

This commit is contained in:
Anuken
2019-10-02 21:23:29 -04:00
parent ec29bd3682
commit ffd4297b17
7 changed files with 49 additions and 33 deletions

View File

@@ -103,19 +103,21 @@ public class DeployDialog extends FloatingDialog{
}
TextButton button = Elements.newButton(Core.bundle.format("resume", slot.getZone().localizedName()), Styles.squaret, () -> {
hide();
ui.loadAnd(() -> {
logic.reset();
net.reset();
try{
control.saves.getZoneSlot().load();
state.set(State.playing);
}catch(SaveException e){ //make sure to handle any save load errors!
e.printStackTrace();
if(control.saves.getZoneSlot() != null) control.saves.getZoneSlot().delete();
Core.app.post(() -> ui.showInfo("$save.corrupted"));
show();
}
control.saves.getZoneSlot().cautiousLoad(() -> {
hide();
ui.loadAnd(() -> {
logic.reset();
net.reset();
try{
slot.load();
state.set(State.playing);
}catch(SaveException e){ //make sure to handle any save load errors!
e.printStackTrace();
if(control.saves.getZoneSlot() != null) control.saves.getZoneSlot().delete();
Core.app.post(() -> ui.showInfo("$save.corrupted"));
show();
}
});
});
});

View File

@@ -186,22 +186,23 @@ public class LoadDialog extends FloatingDialog{
}
public void runLoadSave(SaveSlot slot){
hide();
ui.paused.hide();
ui.loadAnd(() -> {
try{
net.reset();
slot.load();
state.rules.editor = false;
state.rules.zone = null;
state.set(State.playing);
}catch(SaveException e){
Log.err(e);
state.set(State.menu);
logic.reset();
ui.showErrorMessage("$save.corrupted");
}
slot.cautiousLoad(() -> {
ui.loadAnd(() -> {
hide();
ui.paused.hide();
try{
net.reset();
slot.load();
state.rules.editor = false;
state.rules.zone = null;
state.set(State.playing);
}catch(SaveException e){
Log.err(e);
state.set(State.menu);
logic.reset();
ui.showErrorMessage("$save.corrupted");
}
});
});
}