Merge branch 'master' of https://code.digitalcash.fun/wangjunxiao/branch-engine
This commit is contained in:
@@ -2,12 +2,15 @@ const { app, BrowserWindow } = require('electron')
|
|||||||
const path = require('path')
|
const path = require('path')
|
||||||
|
|
||||||
app.whenReady().then(() => {
|
app.whenReady().then(() => {
|
||||||
|
const sceneArg = process.argv.find(a => a.startsWith('--scene='))
|
||||||
|
const query = sceneArg ? { scene: sceneArg.split('=')[1] } : {}
|
||||||
|
|
||||||
const win = new BrowserWindow({
|
const win = new BrowserWindow({
|
||||||
fullscreen: true,
|
fullscreen: true,
|
||||||
autoHideMenuBar: true,
|
autoHideMenuBar: true,
|
||||||
webPreferences: { nodeIntegration: false }
|
webPreferences: { nodeIntegration: false }
|
||||||
})
|
})
|
||||||
win.loadFile(path.join(__dirname, '..', 'dist', 'index.html'))
|
win.loadFile(path.join(__dirname, '..', 'dist', 'index.html'), { query })
|
||||||
})
|
})
|
||||||
|
|
||||||
app.on('window-all-closed', () => app.quit())
|
app.on('window-all-closed', () => app.quit())
|
||||||
|
|||||||
19
src/App.vue
19
src/App.vue
@@ -43,8 +43,25 @@ const { loadGame, start, resumeAutoSave, makeChoice, clickHotspot, startChapter,
|
|||||||
saveGame, loadGameFromSlot, refreshSaves, saveSystem, engine } =
|
saveGame, loadGameFromSlot, refreshSaves, saveSystem, engine } =
|
||||||
useGameEngine(() => [videoElA.value, videoElB.value])
|
useGameEngine(() => [videoElA.value, videoElB.value])
|
||||||
|
|
||||||
|
async function resolveScenePath(): Promise<string> {
|
||||||
|
const params = new URLSearchParams(location.search)
|
||||||
|
const queryScene = params.get('scene')
|
||||||
|
if (queryScene) return queryScene.startsWith('/') ? queryScene : '/' + queryScene
|
||||||
|
|
||||||
|
try {
|
||||||
|
const resp = await fetch('/scenes/config.json')
|
||||||
|
if (resp.ok) {
|
||||||
|
const config = await resp.json()
|
||||||
|
if (config.sceneFile) return '/scenes/' + config.sceneFile
|
||||||
|
}
|
||||||
|
} catch { /* config.json optional */ }
|
||||||
|
|
||||||
|
return '/scenes/main.json'
|
||||||
|
}
|
||||||
|
|
||||||
async function init() {
|
async function init() {
|
||||||
await loadGame('/scenes/demo.json')
|
const scenePath = await resolveScenePath()
|
||||||
|
await loadGame(scenePath)
|
||||||
loading.value = false
|
loading.value = false
|
||||||
hasAutoSave.value = (await saveSystem.load(0)) !== null
|
hasAutoSave.value = (await saveSystem.load(0)) !== null
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user