Skip to content

Commit 6f2f6fd

Browse files
feat(core): Auto-load auto-saved settings
Relates to #801 Fixes #806
1 parent bc8f6a3 commit 6f2f6fd

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

packages/kitten-scientists/source/KittenScientists.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,10 @@ export class KittenScientists {
120120
| undefined;
121121

122122
if (!state) {
123-
cinfo("The Kittens Game save data did not contain a script state.");
123+
cinfo(
124+
"The Kittens Game save data did not contain a script state. Trying to load Auto-Save settings...",
125+
);
126+
this._userInterface.stateManagementUi.loadAutoSave();
124127
return;
125128
}
126129

packages/kitten-scientists/source/ui/StateManagementUi.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -569,6 +569,17 @@ export class StateManagementUi extends SettingsPanel<StateSettings> {
569569
this._host.refreshUi();
570570
}
571571

572+
loadAutoSave() {
573+
const existing = this.states.find(state => state.unwrap().label === "Auto-Save");
574+
if (isNil(existing)) {
575+
cinfo("No Auto-Save settings found.");
576+
return;
577+
}
578+
579+
cinfo("Loading Auto-Save...");
580+
this.loadState(existing.unwrap().state);
581+
}
582+
572583
updateGame(game: Unique<StoredGame>, newGame: KGSaveData) {
573584
if (this._destructiveActionPrevented()) {
574585
return;

0 commit comments

Comments
 (0)