Implement WebGL page reserve navigation

This commit is contained in:
2026-06-08 10:25:54 +02:00
parent 3e28d7db23
commit efd1e6cfff
13 changed files with 571 additions and 52 deletions
+19 -1
View File
@@ -54,7 +54,9 @@ class GameLoopModule extends BaseModule {
'requestStartGame',
'requestSaveGame',
'requestLoadGame',
'resetClientPlaybackAndDisplay'
'resetClientPlaybackAndDisplay',
'getWebGLBookState',
'applyWebGLBookState'
]);
}
@@ -322,6 +324,7 @@ class GameLoopModule extends BaseModule {
if (typeof storyHistory.saveSlot === 'function') {
await storyHistory.saveSlot(this.autoSaveSlot, {
inkState: null,
webglBookState: this.getWebGLBookState(),
choices: [],
inputMode: 'none',
running: false
@@ -347,6 +350,7 @@ class GameLoopModule extends BaseModule {
if (!isCurrentOperation()) return;
await storyHistory.saveSlot(this.autoSaveSlot, {
inkState: response.savedState,
webglBookState: this.getWebGLBookState(),
choices: [],
inputMode: 'none',
running: true
@@ -372,6 +376,7 @@ class GameLoopModule extends BaseModule {
latestRenderedBlockId: storyHistory.latestRenderedBlockId || 0,
renderedLineCount: storyHistory.renderedLineCount || 0,
musicState: audioManager?.getMusicState?.() || null,
webglBookState: this.getWebGLBookState(),
choices: this.currentChoices,
inputMode: this.currentInputMode,
running: this.gameState.started && !this.gameState.ended
@@ -453,6 +458,7 @@ class GameLoopModule extends BaseModule {
browserSave.renderedLineCount || 0
);
}
this.applyWebGLBookState(browserSave.webglBookState);
const uiController = this.getModule('ui-controller');
if (browserSave && uiController?.displayHandler?.restoreFromHistory) {
await uiController.displayHandler.restoreFromHistory(browserSave);
@@ -516,6 +522,17 @@ class GameLoopModule extends BaseModule {
}
}
getWebGLBookState() {
return window.WebGLBookPreferenceBridge?.getBookState?.()
|| window.BookLabDebug?.getBookState?.()
|| null;
}
applyWebGLBookState(state = null) {
if (!state || typeof state !== 'object') return;
window.WebGLBookPreferenceBridge?.applyBookState?.(state);
}
hasUnrenderedHistory(browserSave) {
return Boolean(browserSave) &&
Number(browserSave.latestBlockId || 0) > Number(browserSave.latestRenderedBlockId || 0);
@@ -565,6 +582,7 @@ class GameLoopModule extends BaseModule {
latestRenderedBlockId: storyHistory.latestRenderedBlockId || 0,
renderedLineCount: storyHistory.renderedLineCount || 0,
musicState: audioManager?.getMusicState?.() || null,
webglBookState: this.getWebGLBookState(),
choices: this.currentChoices,
inputMode: this.currentInputMode,
running: this.gameState.started && !this.gameState.ended