feat: playback bar component, save system improvements, demo and roadmap updates
This commit is contained in:
@@ -25,11 +25,16 @@ export class Engine {
|
||||
private justCameFromImage = false
|
||||
private loopActive = false
|
||||
private onUnlockChapter: ((chapterId: string) => void) | null = null
|
||||
private onMarkWatched: ((sceneId: string) => void) | null = null
|
||||
|
||||
setChapterUnlockHandler(handler: (chapterId: string) => void) {
|
||||
this.onUnlockChapter = handler
|
||||
}
|
||||
|
||||
setMarkWatchedHandler(handler: (sceneId: string) => void) {
|
||||
this.onMarkWatched = handler
|
||||
}
|
||||
|
||||
constructor() {
|
||||
this.sceneManager = new SceneManager()
|
||||
this.videoManager = new VideoManager()
|
||||
@@ -277,6 +282,8 @@ export class Engine {
|
||||
}
|
||||
|
||||
private onVideoEnd(scene: SceneNode) {
|
||||
this.onMarkWatched?.(scene.id)
|
||||
|
||||
if (this.loopActive) return
|
||||
|
||||
const validChoices = this.getValidChoices(scene)
|
||||
@@ -348,6 +355,13 @@ export class Engine {
|
||||
this.emit('gameEnd')
|
||||
}
|
||||
|
||||
skipCurrentScene() {
|
||||
const scene = this.currentScene
|
||||
if (!scene) return
|
||||
this.videoManager.getActiveVideoElement()?.pause()
|
||||
this.onVideoEnd(scene)
|
||||
}
|
||||
|
||||
startChapter(chapterId: string) {
|
||||
const chapter = this.sceneManager.getChapter(chapterId)
|
||||
if (!chapter) return
|
||||
|
||||
@@ -155,6 +155,15 @@ export class VideoManager {
|
||||
this.active.currentTime = time
|
||||
}
|
||||
|
||||
setPlaybackRate(rate: number) {
|
||||
if (this.elA) this.elA.playbackRate = rate
|
||||
if (this.elB) this.elB.playbackRate = rate
|
||||
}
|
||||
|
||||
getPlaybackRate(): number {
|
||||
return this.active?.playbackRate ?? 1
|
||||
}
|
||||
|
||||
setMuted(muted: boolean) {
|
||||
if (this.elA) this.elA.muted = muted
|
||||
if (this.elB) this.elB.muted = muted
|
||||
|
||||
Reference in New Issue
Block a user