feat: full-screen StoryGallery with flow layout, startAtScene engine method, clickable flow nodes

This commit is contained in:
2026-06-12 11:37:14 +08:00
parent 6417a9de43
commit 0379548a29
5 changed files with 327 additions and 389 deletions

View File

@@ -357,17 +357,30 @@ export class Engine {
const scene = this.sceneManager.getScene(chapter.startScene)
if (!scene) return
const defaultVars = chapter.defaultVariables
if (defaultVars) {
this.stateManager.variables = { ...defaultVars }
this.initChapterState(chapter)
this.ended = false
this.isInitialScene = false
this.goToScene(scene)
}
private initChapterState(chapter: { defaultVariables?: Record<string, number> }) {
if (chapter.defaultVariables) {
this.stateManager.variables = { ...chapter.defaultVariables }
} else {
this.stateManager.init(this.sceneManager.chapters.length > 0
? {} // from chapters, use the chapter's defaultVariables or empty
: {})
this.stateManager.init({})
}
this.stateManager.flags = new Set()
this.stateManager.history = []
}
startAtScene(chapterId: string, sceneId: string) {
const chapter = this.sceneManager.getChapter(chapterId)
if (!chapter) return
const scene = this.sceneManager.getScene(sceneId)
if (!scene) return
this.initChapterState(chapter)
this.ended = false
this.isInitialScene = false
this.goToScene(scene)