Skip to content

Commit

Permalink
feat(core): Auto-load auto-saved settings
Browse files Browse the repository at this point in the history
Relates to #801

Fixes #806
  • Loading branch information
oliversalzburg committed Dec 8, 2024
1 parent bc8f6a3 commit 6f2f6fd
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
5 changes: 4 additions & 1 deletion packages/kitten-scientists/source/KittenScientists.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,10 @@ export class KittenScientists {
| undefined;

if (!state) {
cinfo("The Kittens Game save data did not contain a script state.");
cinfo(
"The Kittens Game save data did not contain a script state. Trying to load Auto-Save settings...",
);
this._userInterface.stateManagementUi.loadAutoSave();
return;
}

Expand Down
11 changes: 11 additions & 0 deletions packages/kitten-scientists/source/ui/StateManagementUi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -569,6 +569,17 @@ export class StateManagementUi extends SettingsPanel<StateSettings> {
this._host.refreshUi();
}

loadAutoSave() {
const existing = this.states.find(state => state.unwrap().label === "Auto-Save");
if (isNil(existing)) {
cinfo("No Auto-Save settings found.");
return;
}

cinfo("Loading Auto-Save...");
this.loadState(existing.unwrap().state);
}

updateGame(game: Unique<StoredGame>, newGame: KGSaveData) {
if (this._destructiveActionPrevented()) {
return;
Expand Down

0 comments on commit 6f2f6fd

Please sign in to comment.