-
-
Notifications
You must be signed in to change notification settings - Fork 228
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #481 from OpenWebGAL/dev
4.4.13
- Loading branch information
Showing
30 changed files
with
440 additions
and
220 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
{ | ||
"name":"Default Template", | ||
"webgal-version":"4.4.12" | ||
"webgal-version":"4.4.13" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
packages/webgal/src/Core/controller/storage/savesController.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import localforage from 'localforage'; | ||
import { WebGAL } from '@/Core/WebGAL'; | ||
import { logger } from '@/Core/util/logger'; | ||
import { webgalStore } from '@/store/store'; | ||
import { saveActions } from '@/store/savesReducer'; | ||
import { ISaveData } from '@/store/userDataInterface'; | ||
|
||
export function dumpSavesToStorage(startIndex: number, endIndex: number) { | ||
for (let i = startIndex; i <= endIndex; i++) { | ||
const save = webgalStore.getState().saveData.saveData[i]; | ||
localforage.setItem(`${WebGAL.gameKey}-saves${i}`, save).then(() => { | ||
logger.info(`存档${i}写入本地存储`); | ||
}); | ||
} | ||
} | ||
|
||
export function getSavesFromStorage(startIndex: number, endIndex: number) { | ||
for (let i = startIndex; i <= endIndex; i++) { | ||
localforage.getItem(`${WebGAL.gameKey}-saves${i}`).then((save) => { | ||
webgalStore.dispatch(saveActions.saveGame({ index: i, saveData: save as ISaveData })); | ||
logger.info(`存档${i}读取自本地存储`); | ||
}); | ||
} | ||
} | ||
|
||
export async function dumpFastSaveToStorage() { | ||
const save = webgalStore.getState().saveData.quickSaveData; | ||
await localforage.setItem(`${WebGAL.gameKey}-saves-fast`, save); | ||
logger.info(`快速存档写入本地存储`); | ||
} | ||
|
||
export async function getFastSaveFromStorage() { | ||
const save = await localforage.getItem(`${WebGAL.gameKey}-saves-fast`); | ||
webgalStore.dispatch(saveActions.setFastSave(save as ISaveData)); | ||
logger.info(`快速存档读取自本地存储`); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.