mirror of
https://github.com/He4eT/elseifplayer.git
synced 2026-05-05 01:17:22 +00:00
Player: explicitly override Engine arguments
This commit is contained in:
parent
8a79c5dd3d
commit
2fdc39c1f0
2 changed files with 10 additions and 4 deletions
|
|
@ -20,17 +20,18 @@ const INITIAL_STATUS = {
|
||||||
|
|
||||||
const runMachine = ({ engine: Engine, wasmBinary, storyfile, handlers }) => {
|
const runMachine = ({ engine: Engine, wasmBinary, storyfile, handlers }) => {
|
||||||
const { Dialog, GlkOte, send } = CheapGlkOte(handlers)
|
const { Dialog, GlkOte, send } = CheapGlkOte(handlers)
|
||||||
const vm = new Engine()
|
const instance = new Engine()
|
||||||
|
|
||||||
vm.init(storyfile, {
|
instance.init(storyfile, {
|
||||||
Dialog,
|
Dialog,
|
||||||
GlkOte,
|
GlkOte,
|
||||||
Glk: {},
|
Glk: {},
|
||||||
wasmBinary,
|
wasmBinary,
|
||||||
|
arguments: ['storyfile'],
|
||||||
})
|
})
|
||||||
vm.start()
|
instance.start()
|
||||||
|
|
||||||
return { send, instance: vm }
|
return { send, instance }
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function Player ({
|
export default function Player ({
|
||||||
|
|
@ -68,6 +69,7 @@ export default function Player ({
|
||||||
window.addEventListener('unhandledrejection', rejectionHandler)
|
window.addEventListener('unhandledrejection', rejectionHandler)
|
||||||
|
|
||||||
return () => {
|
return () => {
|
||||||
|
setVm(null)
|
||||||
window.removeEventListener('unhandledrejection', rejectionHandler)
|
window.removeEventListener('unhandledrejection', rejectionHandler)
|
||||||
}
|
}
|
||||||
}, [storyfile, engine, wasmBinary])
|
}, [storyfile, engine, wasmBinary])
|
||||||
|
|
@ -76,6 +78,8 @@ export default function Player ({
|
||||||
setSendMessage(() => vm
|
setSendMessage(() => vm
|
||||||
? vm.send
|
? vm.send
|
||||||
: null)
|
: null)
|
||||||
|
|
||||||
|
return () => setSendMessage(null)
|
||||||
}, [vm])
|
}, [vm])
|
||||||
|
|
||||||
const textWindow = (inbox) => (currentWindow) => {
|
const textWindow = (inbox) => (currentWindow) => {
|
||||||
|
|
|
||||||
|
|
@ -66,6 +66,8 @@ export default function UrlPlayer ({ url, singleWindow }) {
|
||||||
setParts(null)
|
setParts(null)
|
||||||
|
|
||||||
prepareVM({ url, setStatus, setParts })
|
prepareVM({ url, setStatus, setParts })
|
||||||
|
|
||||||
|
return () => setParts(null)
|
||||||
}, [url])
|
}, [url])
|
||||||
|
|
||||||
return vmParts
|
return vmParts
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue