Some remaining work to get the delayed show guide script set up.
This commit is contained in:
parent
4929f81fcc
commit
037dbe97c6
4 changed files with 39 additions and 17 deletions
app
lib/scripts
models
schemas/subscriptions
views/play/level/modal
|
@ -59,6 +59,7 @@ module.exports = ScriptManager = class ScriptManager extends CocoClass
|
||||||
@initProperties()
|
@initProperties()
|
||||||
@loadFromSession()
|
@loadFromSession()
|
||||||
@quiet = false
|
@quiet = false
|
||||||
|
@addScriptSubscriptions()
|
||||||
@run()
|
@run()
|
||||||
|
|
||||||
initProperties: ->
|
initProperties: ->
|
||||||
|
@ -108,6 +109,7 @@ module.exports = ScriptManager = class ScriptManager extends CocoClass
|
||||||
return unless script
|
return unless script
|
||||||
@triggered.push(script.id)
|
@triggered.push(script.id)
|
||||||
noteChain = @processScript(script)
|
noteChain = @processScript(script)
|
||||||
|
return unless noteChain
|
||||||
if scripts.currentScriptOffset
|
if scripts.currentScriptOffset
|
||||||
noteGroup.skipMe = true for noteGroup in noteChain[..scripts.currentScriptOffset-1]
|
noteGroup.skipMe = true for noteGroup in noteChain[..scripts.currentScriptOffset-1]
|
||||||
@addNoteChain(noteChain, false)
|
@addNoteChain(noteChain, false)
|
||||||
|
@ -127,6 +129,7 @@ module.exports = ScriptManager = class ScriptManager extends CocoClass
|
||||||
@triggered.push(scriptID)
|
@triggered.push(scriptID)
|
||||||
@ended.push(scriptID)
|
@ended.push(scriptID)
|
||||||
noteChain = @processScript(script)
|
noteChain = @processScript(script)
|
||||||
|
return unless noteChain
|
||||||
noteGroup.skipMe = true for noteGroup in noteChain
|
noteGroup.skipMe = true for noteGroup in noteChain
|
||||||
@addNoteChain(noteChain, false)
|
@addNoteChain(noteChain, false)
|
||||||
|
|
||||||
|
@ -168,10 +171,11 @@ module.exports = ScriptManager = class ScriptManager extends CocoClass
|
||||||
continue unless @scriptPrereqsSatisfied(script)
|
continue unless @scriptPrereqsSatisfied(script)
|
||||||
continue unless scriptMatchesEventPrereqs(script, event)
|
continue unless scriptMatchesEventPrereqs(script, event)
|
||||||
# everything passed!
|
# everything passed!
|
||||||
console.log "SCRIPT: Running script '#{script.id}'" if @debugScripts
|
console.debug "SCRIPT: Running script '#{script.id}'" if @debugScripts
|
||||||
script.lastTriggered = new Date().getTime()
|
script.lastTriggered = new Date().getTime()
|
||||||
@triggered.push(script.id) unless alreadyTriggered
|
@triggered.push(script.id) unless alreadyTriggered
|
||||||
noteChain = @processScript(script)
|
noteChain = @processScript(script)
|
||||||
|
if not noteChain then return @trackScriptCompletions (script.id)
|
||||||
@addNoteChain(noteChain)
|
@addNoteChain(noteChain)
|
||||||
@run()
|
@run()
|
||||||
|
|
||||||
|
@ -180,10 +184,10 @@ module.exports = ScriptManager = class ScriptManager extends CocoClass
|
||||||
|
|
||||||
processScript: (script) ->
|
processScript: (script) ->
|
||||||
noteChain = script.noteChain
|
noteChain = script.noteChain
|
||||||
|
return null unless noteChain?.length
|
||||||
noteGroup.scriptID = script.id for noteGroup in noteChain
|
noteGroup.scriptID = script.id for noteGroup in noteChain
|
||||||
if noteChain.length
|
lastNoteGroup = noteChain[noteChain.length - 1]
|
||||||
lastNoteGroup = noteChain[noteChain.length - 1]
|
lastNoteGroup.isLast = true
|
||||||
lastNoteGroup.isLast = true
|
|
||||||
return noteChain
|
return noteChain
|
||||||
|
|
||||||
addNoteChain: (noteChain, clearYields=true) ->
|
addNoteChain: (noteChain, clearYields=true) ->
|
||||||
|
@ -228,7 +232,7 @@ module.exports = ScriptManager = class ScriptManager extends CocoClass
|
||||||
@notifyScriptStateChanged()
|
@notifyScriptStateChanged()
|
||||||
@scriptInProgress = true
|
@scriptInProgress = true
|
||||||
@currentTimeouts = []
|
@currentTimeouts = []
|
||||||
console.log "SCRIPT: Starting note group '#{nextNoteGroup.name}'" if @debugScripts
|
console.debug "SCRIPT: Starting note group '#{nextNoteGroup.name}'" if @debugScripts
|
||||||
for module in nextNoteGroup.modules
|
for module in nextNoteGroup.modules
|
||||||
@processNote(note, nextNoteGroup) for note in module.startNotes()
|
@processNote(note, nextNoteGroup) for note in module.startNotes()
|
||||||
if nextNoteGroup.script.duration
|
if nextNoteGroup.script.duration
|
||||||
|
@ -242,12 +246,12 @@ module.exports = ScriptManager = class ScriptManager extends CocoClass
|
||||||
@ignoreEvents = true
|
@ignoreEvents = true
|
||||||
for noteGroup, i in @noteGroupQueue
|
for noteGroup, i in @noteGroupQueue
|
||||||
break unless noteGroup.skipMe
|
break unless noteGroup.skipMe
|
||||||
console.log "SCRIPT: Skipping note group '#{noteGroup.name}'" if @debugScripts
|
console.debug "SCRIPT: Skipping note group '#{noteGroup.name}'" if @debugScripts
|
||||||
@processNoteGroup(noteGroup)
|
@processNoteGroup(noteGroup)
|
||||||
for module in noteGroup.modules
|
for module in noteGroup.modules
|
||||||
notes = module.skipNotes()
|
notes = module.skipNotes()
|
||||||
@processNote(note, noteGroup) for note in notes
|
@processNote(note, noteGroup) for note in notes
|
||||||
@trackScriptCompletions(noteGroup)
|
@trackScriptCompletionsFromNoteGroup(noteGroup)
|
||||||
@noteGroupQueue = @noteGroupQueue[i..]
|
@noteGroupQueue = @noteGroupQueue[i..]
|
||||||
@ignoreEvents = false
|
@ignoreEvents = false
|
||||||
|
|
||||||
|
@ -289,13 +293,13 @@ module.exports = ScriptManager = class ScriptManager extends CocoClass
|
||||||
return if @ending # kill infinite loops right here
|
return if @ending # kill infinite loops right here
|
||||||
@ending = true
|
@ending = true
|
||||||
return unless @currentNoteGroup?
|
return unless @currentNoteGroup?
|
||||||
console.log "SCRIPT: Ending note group '#{@currentNoteGroup.name}'" if @debugScripts
|
console.debug "SCRIPT: Ending note group '#{@currentNoteGroup.name}'" if @debugScripts
|
||||||
clearTimeout(timeout) for timeout in @currentTimeouts
|
clearTimeout(timeout) for timeout in @currentTimeouts
|
||||||
for module in @currentNoteGroup.modules
|
for module in @currentNoteGroup.modules
|
||||||
@processNote(note, @currentNoteGroup) for note in module.endNotes()
|
@processNote(note, @currentNoteGroup) for note in module.endNotes()
|
||||||
Backbone.Mediator.publish 'note-group-ended' unless @quiet
|
Backbone.Mediator.publish 'note-group-ended' unless @quiet
|
||||||
@scriptInProgress = false
|
@scriptInProgress = false
|
||||||
@trackScriptCompletions(@currentNoteGroup)
|
@trackScriptCompletionsFromNoteGroup(@currentNoteGroup)
|
||||||
@currentNoteGroup = null
|
@currentNoteGroup = null
|
||||||
unless @noteGroupQueue.length
|
unless @noteGroupQueue.length
|
||||||
@notifyScriptStateChanged()
|
@notifyScriptStateChanged()
|
||||||
|
@ -322,7 +326,7 @@ module.exports = ScriptManager = class ScriptManager extends CocoClass
|
||||||
for module in noteGroup.modules
|
for module in noteGroup.modules
|
||||||
notes = module.skipNotes()
|
notes = module.skipNotes()
|
||||||
@processNote(note, noteGroup) for note in notes unless @quiet
|
@processNote(note, noteGroup) for note in notes unless @quiet
|
||||||
@trackScriptCompletions(noteGroup) unless @quiet
|
@trackScriptCompletionsFromNoteGroup(noteGroup) unless @quiet
|
||||||
|
|
||||||
@noteGroupQueue = []
|
@noteGroupQueue = []
|
||||||
|
|
||||||
|
@ -337,15 +341,18 @@ module.exports = ScriptManager = class ScriptManager extends CocoClass
|
||||||
Backbone.Mediator.publish 'level-enable-controls', {}
|
Backbone.Mediator.publish 'level-enable-controls', {}
|
||||||
Backbone.Mediator.publish 'level-set-letterbox', { on: false }
|
Backbone.Mediator.publish 'level-set-letterbox', { on: false }
|
||||||
|
|
||||||
trackScriptCompletions: (noteGroup) ->
|
trackScriptCompletionsFromNoteGroup: (noteGroup) ->
|
||||||
return if @quiet
|
|
||||||
return unless noteGroup.isLast
|
return unless noteGroup.isLast
|
||||||
@ended.push(noteGroup.scriptID) unless noteGroup.scriptID in @ended
|
@trackScriptCompletions(noteGroup.scriptID)
|
||||||
|
|
||||||
|
trackScriptCompletions: (scriptID) ->
|
||||||
|
return if @quiet
|
||||||
|
@ended.push(scriptID) unless scriptID in @ended
|
||||||
for script in @scripts
|
for script in @scripts
|
||||||
if script.id is noteGroup.scriptID
|
if script.id is scriptID
|
||||||
script.lastEnded = new Date()
|
script.lastEnded = new Date()
|
||||||
@lastScriptEnded = new Date()
|
@lastScriptEnded = new Date()
|
||||||
Backbone.Mediator.publish 'script:ended', {scriptID: noteGroup.scriptID}
|
Backbone.Mediator.publish 'script:ended', {scriptID: scriptID}
|
||||||
|
|
||||||
notifyScriptStateChanged: ->
|
notifyScriptStateChanged: ->
|
||||||
return if @quiet
|
return if @quiet
|
||||||
|
|
|
@ -16,6 +16,16 @@ module.exports = class SuperModel extends Backbone.Model
|
||||||
# retries, progress, and filling the cache. Note that the resource it passes back will not
|
# retries, progress, and filling the cache. Note that the resource it passes back will not
|
||||||
# necessarily have the same model or collection that was passed in, if it was fetched from
|
# necessarily have the same model or collection that was passed in, if it was fetched from
|
||||||
# the cache.
|
# the cache.
|
||||||
|
|
||||||
|
report: ->
|
||||||
|
# Useful for debugging why a SuperModel never finishes loading.
|
||||||
|
console.info "SuperModel report ------------------------"
|
||||||
|
console.info "#{_.values(@resources).length} resources."
|
||||||
|
unfinished = []
|
||||||
|
for resource in _.values(@resources)
|
||||||
|
console.info '\t', resource.name, "loaded", resource.isLoaded
|
||||||
|
unfinished.push resource unless resource.isLoaded
|
||||||
|
unfinished
|
||||||
|
|
||||||
loadModel: (model, name, fetchOptions, value=1) ->
|
loadModel: (model, name, fetchOptions, value=1) ->
|
||||||
cachedModel = @getModelByURL(model.getURL())
|
cachedModel = @getModelByURL(model.getURL())
|
||||||
|
|
|
@ -53,8 +53,9 @@ module.exports =
|
||||||
"level:team-set":
|
"level:team-set":
|
||||||
{} # TODO schema
|
{} # TODO schema
|
||||||
|
|
||||||
"level:docs-hidden":
|
"level:docs-shown": {}
|
||||||
{} # TODO schema
|
|
||||||
|
"level:docs-hidden": {}
|
||||||
|
|
||||||
"level:victory-hidden":
|
"level:victory-hidden":
|
||||||
{} # TODO schema
|
{} # TODO schema
|
||||||
|
|
|
@ -49,6 +49,10 @@ module.exports = class DocsModal extends View
|
||||||
|
|
||||||
clickTab: (e) =>
|
clickTab: (e) =>
|
||||||
@$el.find('li.active').removeClass('active')
|
@$el.find('li.active').removeClass('active')
|
||||||
|
|
||||||
|
afterInsert: ->
|
||||||
|
super()
|
||||||
|
Backbone.Mediator.publish 'level:docs-shown'
|
||||||
|
|
||||||
onHidden: ->
|
onHidden: ->
|
||||||
Backbone.Mediator.publish 'level:docs-hidden'
|
Backbone.Mediator.publish 'level:docs-hidden'
|
||||||
|
|
Reference in a new issue