chore: App.vue updates for player and editor
This commit is contained in:
@@ -49,7 +49,7 @@ function importJSON() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function testScene(id: string) {
|
function testScene(id: string) {
|
||||||
window.open('/?scene=' + id, '_blank')
|
window.open('/?scene=/scenes/demo.json&startScene=' + id, '_blank')
|
||||||
}
|
}
|
||||||
|
|
||||||
async function onFileSelected(e: Event) {
|
async function onFileSelected(e: Event) {
|
||||||
|
|||||||
42
src/App.vue
42
src/App.vue
@@ -81,7 +81,49 @@ async function init() {
|
|||||||
|
|
||||||
if (store.introVideo) {
|
if (store.introVideo) {
|
||||||
introWatched.value = await isSceneWatched('__intro__')
|
introWatched.value = await isSceneWatched('__intro__')
|
||||||
|
const params = new URLSearchParams(location.search)
|
||||||
|
if (params.get('startScene')) {
|
||||||
|
showIntro.value = false
|
||||||
|
handleStartFromScene(params.get('startScene')!)
|
||||||
|
return
|
||||||
|
}
|
||||||
showIntro.value = true
|
showIntro.value = true
|
||||||
|
} else {
|
||||||
|
const params = new URLSearchParams(location.search)
|
||||||
|
const startSceneId = params.get('startScene')
|
||||||
|
if (startSceneId) {
|
||||||
|
handleStartFromScene(startSceneId)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleStartFromScene(sceneId: string) {
|
||||||
|
started.value = true
|
||||||
|
applyQteParams()
|
||||||
|
const ch = engine.sceneManager.chapters.find(c => {
|
||||||
|
const reachable = new Set<string>()
|
||||||
|
const queue = [c.startScene]
|
||||||
|
while (queue.length > 0) {
|
||||||
|
const id = queue.shift()!
|
||||||
|
if (reachable.has(id)) continue
|
||||||
|
const sc = engine.sceneManager.getScene(id)
|
||||||
|
if (!sc) continue
|
||||||
|
reachable.add(id)
|
||||||
|
if (sc.choices) for (const ch2 of sc.choices) if (ch2.targetScene) queue.push(ch2.targetScene)
|
||||||
|
if (sc.nextScene) {
|
||||||
|
if (Array.isArray(sc.nextScene)) for (const r of sc.nextScene) if (r.targetScene) queue.push(r.targetScene)
|
||||||
|
else queue.push(sc.nextScene)
|
||||||
|
}
|
||||||
|
if (sc.qte) { if (sc.qte.successScene) queue.push(sc.qte.successScene); if (sc.qte.failScene) queue.push(sc.qte.failScene) }
|
||||||
|
if (sc.hotspots) for (const h of sc.hotspots) if (h.targetScene) queue.push(h.targetScene)
|
||||||
|
}
|
||||||
|
return reachable.has(sceneId)
|
||||||
|
})
|
||||||
|
if (ch) {
|
||||||
|
engine.startAtScene(ch.id, sceneId)
|
||||||
|
} else {
|
||||||
|
const scene = engine.sceneManager.getScene(sceneId)
|
||||||
|
if (scene) engine.goToScene(scene)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user