feat: chapter select system, multi-chapter support, scene manager refactor, and docs update

This commit is contained in:
2026-06-09 11:35:11 +08:00
parent 655b9a23d0
commit ace5ed1fb3
14 changed files with 413 additions and 17 deletions

View File

@@ -12,13 +12,19 @@ interface SaveRecord {
thumbnail?: string
}
interface UnlockRecord {
chapterId: string
}
class SaveDB extends Dexie {
saves!: Table<SaveRecord, number>
unlocks!: Table<UnlockRecord, string>
constructor() {
super('MovieGameSaves')
this.version(2).stores({
this.version(3).stores({
saves: '++id, slot',
unlocks: 'chapterId',
})
}
}
@@ -73,4 +79,21 @@ export class SaveSystem {
async delete(slot: number): Promise<void> {
await db.saves.where('slot').equals(slot).delete()
}
async unlockChapter(chapterId: string) {
const exists = await db.unlocks.get(chapterId)
if (!exists) {
await db.unlocks.put({ chapterId })
}
}
async isChapterUnlocked(chapterId: string): Promise<boolean> {
const record = await db.unlocks.get(chapterId)
return !!record
}
async getUnlockedChapters(): Promise<string[]> {
const records = await db.unlocks.toArray()
return records.map((r) => r.chapterId)
}
}