2014-01-03 13:32:13 -05:00
|
|
|
ScriptModule = require './ScriptModule'
|
|
|
|
|
|
|
|
module.exports = class DOMScriptModule extends ScriptModule
|
|
|
|
@neededFor: (noteGroup) ->
|
|
|
|
return noteGroup.dom?
|
|
|
|
|
|
|
|
startNotes: ->
|
|
|
|
notes = []
|
|
|
|
notes.push(@highlightNote()) if @noteGroup.dom.highlight?
|
|
|
|
notes.push(@lockNote()) if @noteGroup.dom.lock?
|
|
|
|
notes.push(@focusNote()) if @noteGroup.dom.focus?
|
|
|
|
notes.push(@showVictoryNote()) if @noteGroup.dom.showVictory
|
|
|
|
notes.push(@letterboxNote()) if @noteGroup.dom.letterbox?
|
|
|
|
return notes
|
|
|
|
|
|
|
|
endNotes: ->
|
|
|
|
notes = []
|
2014-08-27 15:24:03 -04:00
|
|
|
notes.push({'channel': 'level:end-highlight-dom'}) if @noteGroup.dom.highlight?
|
|
|
|
notes.push({'channel': 'level:enable-controls'}) if @noteGroup.dom.lock?
|
2014-01-03 13:32:13 -05:00
|
|
|
return notes
|
|
|
|
|
|
|
|
skipNotes: ->
|
|
|
|
notes = []
|
|
|
|
notes.push(@showVictoryNote(false)) if @noteGroup.dom.showVictory?
|
|
|
|
notes.push(@letterboxNote()) if @noteGroup.dom.letterbox?
|
|
|
|
notes
|
|
|
|
|
|
|
|
highlightNote: ->
|
|
|
|
dom = @noteGroup.dom
|
|
|
|
note =
|
2014-08-27 15:24:03 -04:00
|
|
|
channel: 'level:highlight-dom'
|
2014-01-03 13:32:13 -05:00
|
|
|
event:
|
|
|
|
selector: dom.highlight.target
|
|
|
|
delay: dom.highlight.delay
|
|
|
|
sides: dom.highlight.sides
|
|
|
|
offset: dom.highlight.offset
|
|
|
|
rotation: dom.highlight.rotation
|
2014-05-20 18:31:49 -04:00
|
|
|
note.event = _.pick note.event, (value) -> not _.isUndefined value
|
2014-01-03 13:32:13 -05:00
|
|
|
@maybeApplyDelayToNote note
|
|
|
|
note
|
|
|
|
|
|
|
|
focusNote: ->
|
|
|
|
note =
|
2014-08-27 15:24:03 -04:00
|
|
|
channel: 'level:focus-dom'
|
2014-01-03 13:32:13 -05:00
|
|
|
event:
|
|
|
|
selector: @noteGroup.dom.focus
|
|
|
|
note
|
|
|
|
|
|
|
|
showVictoryNote: (showModal) ->
|
|
|
|
e = {}
|
|
|
|
e.showModal = @noteGroup.dom.showVictory in [true, 'Done Button And Modal']
|
|
|
|
e.showModal = showModal if showModal?
|
|
|
|
note =
|
2014-08-27 15:24:03 -04:00
|
|
|
channel: 'level:show-victory'
|
2014-01-03 13:32:13 -05:00
|
|
|
event: e
|
|
|
|
note
|
|
|
|
|
|
|
|
lockNote: ->
|
|
|
|
event = {}
|
|
|
|
lock = @noteGroup.dom.lock
|
|
|
|
event.controls = lock if _.isArray lock # array: subset of controls
|
2014-08-27 15:24:03 -04:00
|
|
|
channel = if lock then 'level:disable-controls' else 'level:enable-controls'
|
2014-06-30 22:16:26 -04:00
|
|
|
return {channel: channel, event: event}
|
2014-01-03 13:32:13 -05:00
|
|
|
|
|
|
|
letterboxNote: ->
|
2014-08-27 15:24:03 -04:00
|
|
|
return {channel: 'level:set-letterbox', event: {on: @noteGroup.dom.letterbox}}
|