mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2024-11-27 09:35:39 -05:00
Fixed #828. Added many other minor refactorings.
This commit is contained in:
parent
d5b1010a47
commit
ee9e453896
105 changed files with 911 additions and 1304 deletions
|
@ -10,7 +10,7 @@ module.exports = class CocoRouter extends Backbone.Router
|
|||
initialize: ->
|
||||
# http://nerds.airbnb.com/how-to-add-google-analytics-page-tracking-to-57536
|
||||
@bind 'route', @_trackPageView
|
||||
Backbone.Mediator.subscribe 'gapi-loaded', @onGPlusAPILoaded, @
|
||||
Backbone.Mediator.subscribe 'auth:gplus-api-loaded', @onGPlusAPILoaded, @
|
||||
Backbone.Mediator.subscribe 'router:navigate', @onNavigate, @
|
||||
|
||||
routes:
|
||||
|
|
|
@ -2,7 +2,7 @@ Backbone.Mediator.setValidationEnabled false
|
|||
app = require 'application'
|
||||
|
||||
channelSchemas =
|
||||
'app': require './schemas/subscriptions/app'
|
||||
'auth': require './schemas/subscriptions/auth'
|
||||
'bus': require './schemas/subscriptions/bus'
|
||||
'editor': require './schemas/subscriptions/editor'
|
||||
'errors': require './schemas/subscriptions/errors'
|
||||
|
@ -10,8 +10,8 @@ channelSchemas =
|
|||
'play': require './schemas/subscriptions/play'
|
||||
'surface': require './schemas/subscriptions/surface'
|
||||
'tome': require './schemas/subscriptions/tome'
|
||||
'user': require './schemas/subscriptions/user'
|
||||
'world': require './schemas/subscriptions/world'
|
||||
'god': require './schemas/subscriptions/god'
|
||||
'scripts': require './schemas/subscriptions/scripts'
|
||||
|
||||
definitionSchemas =
|
||||
'bus': require './schemas/definitions/bus'
|
||||
|
|
|
@ -91,7 +91,7 @@ module.exports = class Angel extends CocoClass
|
|||
when 'user-code-problem'
|
||||
Backbone.Mediator.publish 'god:user-code-problem', problem: event.data.problem
|
||||
when 'world-load-progress-changed'
|
||||
Backbone.Mediator.publish 'god:world-load-progress-changed', event.data
|
||||
Backbone.Mediator.publish 'god:world-load-progress-changed', progress: event.data.progress
|
||||
unless event.data.progress is 1 or @work.preload or @work.headless or @work.synchronous or @deserializationQueue.length or @shared.firstWorld
|
||||
@worker.postMessage func: 'serializeFramesSoFar' # Stream it!
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@ class Media
|
|||
|
||||
class AudioPlayer extends CocoClass
|
||||
subscriptions:
|
||||
'play-sound': (e) -> @playInterfaceSound e.trigger, e.volume
|
||||
'audio-player:play-sound': (e) -> @playInterfaceSound e.trigger, e.volume
|
||||
|
||||
constructor: () ->
|
||||
super()
|
||||
|
|
|
@ -19,11 +19,7 @@ module.exports = Bus = class Bus extends CocoClass
|
|||
Bus.activeBuses[@docName] = @
|
||||
|
||||
subscriptions:
|
||||
'level-bus-echo-states': 'onEchoStates'
|
||||
'me:synced': 'onMeSynced'
|
||||
|
||||
onEchoStates: ->
|
||||
@notifyStateChanges()
|
||||
'auth:me-synced': 'onMeSynced'
|
||||
|
||||
connect: ->
|
||||
Backbone.Mediator.publish 'bus:connecting', {bus: @}
|
||||
|
@ -99,7 +95,7 @@ module.exports = Bus = class Bus extends CocoClass
|
|||
@onPlayerJoined(snapshot) if player.connected and not wasConnected
|
||||
Backbone.Mediator.publish('bus:player-states-changed', {states: @players, bus: @})
|
||||
|
||||
onMeSynced: =>
|
||||
onMeSynced: ->
|
||||
@myConnection?.child('name').set(me.get('name'))
|
||||
|
||||
countPlayers: -> _.size(@players)
|
||||
|
|
|
@ -11,7 +11,7 @@ module.exports = [
|
|||
scriptPrereqs: ["Introduction"]
|
||||
}
|
||||
{
|
||||
channel: "level-set-playing"
|
||||
channel: "level:set-playing"
|
||||
noteChain: []
|
||||
scriptPrereqs: ["Victory Playback"]
|
||||
id: "Victory Playback Started"
|
||||
|
@ -22,4 +22,4 @@ module.exports = [
|
|||
scriptPrereqs: ["Victory Playback Started"]
|
||||
id: "Show Victory"
|
||||
}
|
||||
]
|
||||
]
|
||||
|
|
|
@ -14,10 +14,9 @@ userPropsToSave =
|
|||
|
||||
module.exports = FacebookHandler = class FacebookHandler extends CocoClass
|
||||
subscriptions:
|
||||
'facebook-logged-in':'onFacebookLogin'
|
||||
'facebook-logged-out': 'onFacebookLogout'
|
||||
'auth:logged-in-with-facebook': 'onFacebookLoggedIn'
|
||||
|
||||
onFacebookLogin: (e) =>
|
||||
onFacebookLoggedIn: (e) ->
|
||||
# user is logged in also when the page first loads, so check to see
|
||||
# if we really need to do the lookup
|
||||
return if not me
|
||||
|
@ -30,9 +29,6 @@ module.exports = FacebookHandler = class FacebookHandler extends CocoClass
|
|||
break
|
||||
FB.api('/me', @onReceiveMeInfo) if doIt
|
||||
|
||||
onFacebookLogout: (e) =>
|
||||
console.warn('On facebook logout not implemented.')
|
||||
|
||||
onReceiveMeInfo: (r) =>
|
||||
unless r.email
|
||||
console.error('could not get data, since no email provided')
|
||||
|
@ -45,7 +41,7 @@ module.exports = FacebookHandler = class FacebookHandler extends CocoClass
|
|||
me.set('email', r.email) if r.email
|
||||
me.set('facebookID', r.id) if r.id
|
||||
|
||||
Backbone.Mediator.publish('logging-in-with-facebook')
|
||||
Backbone.Mediator.publish 'auth:logging-in-with-facebook', {}
|
||||
window.tracker?.trackEvent 'Facebook Login'
|
||||
window.tracker?.identify()
|
||||
me.patch({
|
||||
|
|
|
@ -23,8 +23,8 @@ module.exports = GPlusHandler = class GPlusHandler extends CocoClass
|
|||
super()
|
||||
|
||||
subscriptions:
|
||||
'gplus-logged-in':'onGPlusLogin'
|
||||
'gapi-loaded':'onGPlusLoaded'
|
||||
'auth:logged-in-with-gplus':'onGPlusLogin'
|
||||
'auth:gplus-api-loaded':'onGPlusLoaded'
|
||||
|
||||
onGPlusLoaded: ->
|
||||
session_state = null
|
||||
|
@ -88,7 +88,7 @@ module.exports = GPlusHandler = class GPlusHandler extends CocoClass
|
|||
return unless @responsesComplete is 2
|
||||
return unless me.get('email') and me.get('gplusID')
|
||||
|
||||
Backbone.Mediator.publish('logging-in-with-gplus')
|
||||
Backbone.Mediator.publish 'auth:logging-in-with-gplus', {}
|
||||
gplusID = me.get('gplusID')
|
||||
window.tracker?.trackEvent 'Google Login'
|
||||
window.tracker?.identify()
|
||||
|
|
|
@ -6,14 +6,14 @@ module.exports = class GitHubHandler extends CocoClass
|
|||
scopes: 'user:email'
|
||||
|
||||
subscriptions:
|
||||
'github-login': 'commenceGitHubLogin'
|
||||
'auth:log-in-with-github': 'commenceGitHubLogin'
|
||||
|
||||
constructor: ->
|
||||
super arguments...
|
||||
@clientID = if application.isProduction() then '9b405bf5fb84590d1f02' else 'fd5c9d34eb171131bc87'
|
||||
@redirectURI = if application.isProduction() then 'http://codecombat.com/github/auth_callback' else 'http://localhost:3000/github/auth_callback'
|
||||
|
||||
commenceGitHubLogin: ->
|
||||
commenceGitHubLogin: (e) ->
|
||||
request =
|
||||
scope: @scopes
|
||||
client_id: @clientID
|
||||
|
|
|
@ -127,7 +127,7 @@ module.exports = class God extends CocoClass
|
|||
when 'debug-value-return'
|
||||
Backbone.Mediator.publish 'god:debug-value-return', event.data.serialized
|
||||
when 'debug-world-load-progress-changed'
|
||||
Backbone.Mediator.publish 'god:debug-world-load-progress-changed', event.data
|
||||
Backbone.Mediator.publish 'god:debug-world-load-progress-changed', progress: event.data.progress
|
||||
|
||||
onNewWorldCreated: (e) ->
|
||||
@currentUserCodeMap = @filterUserCodeMapWhenFromWorld e.world.userCodeMap
|
||||
|
|
|
@ -11,6 +11,7 @@ module.exports = class LevelBus extends Bus
|
|||
|
||||
subscriptions:
|
||||
'self-wizard:target-changed': 'onSelfWizardTargetChanged'
|
||||
'self-wizard:created': 'onSelfWizardCreated'
|
||||
'tome:editing-began': 'onEditingBegan'
|
||||
'tome:editing-ended': 'onEditingEnded'
|
||||
'script:state-changed': 'onScriptStateChanged'
|
||||
|
@ -18,8 +19,8 @@ module.exports = class LevelBus extends Bus
|
|||
'script:reset': 'onScriptReset'
|
||||
'surface:frame-changed': 'onFrameChanged'
|
||||
'surface:sprite-selected': 'onSpriteSelected'
|
||||
'level-set-playing': 'onSetPlaying'
|
||||
'level-show-victory': 'onVictory'
|
||||
'level:set-playing': 'onSetPlaying'
|
||||
'level:show-victory': 'onVictory'
|
||||
'tome:spell-changed': 'onSpellChanged'
|
||||
'tome:spell-created': 'onSpellCreated'
|
||||
'application:idle-changed': 'onIdleChanged'
|
||||
|
@ -51,10 +52,12 @@ module.exports = class LevelBus extends Bus
|
|||
return true unless @session?.get('multiplayer')
|
||||
super()
|
||||
|
||||
onSelfWizardTargetChanged: =>
|
||||
wizardSprite = @getSelfWizard()
|
||||
@wizardRef?.child('targetPos').set(wizardSprite?.targetPos or null)
|
||||
@wizardRef?.child('targetSprite').set(wizardSprite?.targetSprite?.thang.id or null)
|
||||
onSelfWizardCreated: (e) ->
|
||||
@selfWizardSprite = e.sprite
|
||||
|
||||
onSelfWizardTargetChanged: (e) ->
|
||||
@wizardRef?.child('targetPos').set(@selfWizardSprite?.targetPos or null)
|
||||
@wizardRef?.child('targetSprite').set(@selfWizardSprite?.targetSprite?.thang.id or null)
|
||||
|
||||
onMeSynced: =>
|
||||
super()
|
||||
|
@ -63,9 +66,8 @@ module.exports = class LevelBus extends Bus
|
|||
join: ->
|
||||
super()
|
||||
@wizardRef = @myConnection.child('wizard')
|
||||
wizardSprite = @getSelfWizard()
|
||||
@wizardRef?.child('targetPos').set(wizardSprite?.targetPos or null)
|
||||
@wizardRef?.child('targetSprite').set(wizardSprite?.targetSprite?.thang.id or null)
|
||||
@wizardRef?.child('targetPos').set(@selfWizardSprite?.targetPos or null)
|
||||
@wizardRef?.child('targetSprite').set(@selfWizardSprite?.targetSprite?.thang.id or null)
|
||||
@wizardRef?.child('wizardColor1').set(me.get('wizardColor1') or 0.0)
|
||||
|
||||
disconnect: ->
|
||||
|
@ -81,11 +83,6 @@ module.exports = class LevelBus extends Bus
|
|||
@fireRef.remove()
|
||||
@onDisconnect.cancel(-> callback?())
|
||||
|
||||
getSelfWizard: ->
|
||||
e = {}
|
||||
Backbone.Mediator.publish('echo-self-wizard-sprite', e)
|
||||
return e.payload
|
||||
|
||||
# UPDATING FIREBASE AND SESSION
|
||||
|
||||
onEditingBegan: -> @wizardRef?.child('editing').set(true)
|
||||
|
|
|
@ -9,7 +9,7 @@ module.exports = LinkedInHandler = class LinkedInHandler extends CocoClass
|
|||
super()
|
||||
|
||||
subscriptions:
|
||||
'linkedin-loaded': 'onLinkedInLoaded'
|
||||
'auth:linkedin-api-loaded': 'onLinkedInLoaded'
|
||||
|
||||
onLinkedInLoaded: (e) ->
|
||||
IN.Event.on IN, 'auth', @onLinkedInAuth
|
||||
|
|
|
@ -12,7 +12,7 @@ init = ->
|
|||
me.set 'testGroupNumber', Math.floor(Math.random() * 256)
|
||||
me.patch()
|
||||
|
||||
Backbone.listenTo(me, 'sync', -> Backbone.Mediator.publish('me:synced', {me: me}))
|
||||
Backbone.listenTo me, 'sync', -> Backbone.Mediator.publish('auth:me-synced', me: me)
|
||||
|
||||
module.exports.createUser = (userObject, failure=backboneFailure, nextURL=null) ->
|
||||
user = new User(userObject)
|
||||
|
@ -57,7 +57,7 @@ onSetVolume = (e) ->
|
|||
me.set('volume', e.volume)
|
||||
me.save()
|
||||
|
||||
Backbone.Mediator.subscribe('level-set-volume', onSetVolume, module.exports)
|
||||
Backbone.Mediator.subscribe('level:set-volume', onSetVolume, module.exports)
|
||||
|
||||
trackFirstArrival = ->
|
||||
# will have to filter out users who log in with existing accounts separately
|
||||
|
|
|
@ -15,8 +15,8 @@ module.exports = class DOMScriptModule extends ScriptModule
|
|||
|
||||
endNotes: ->
|
||||
notes = []
|
||||
notes.push({'channel': 'end-level-highlight-dom'}) if @noteGroup.dom.highlight?
|
||||
notes.push({'channel': 'level-enable-controls'}) if @noteGroup.dom.lock?
|
||||
notes.push({'channel': 'level:end-highlight-dom'}) if @noteGroup.dom.highlight?
|
||||
notes.push({'channel': 'level:enable-controls'}) if @noteGroup.dom.lock?
|
||||
return notes
|
||||
|
||||
skipNotes: ->
|
||||
|
@ -28,7 +28,7 @@ module.exports = class DOMScriptModule extends ScriptModule
|
|||
highlightNote: ->
|
||||
dom = @noteGroup.dom
|
||||
note =
|
||||
channel: 'level-highlight-dom'
|
||||
channel: 'level:highlight-dom'
|
||||
event:
|
||||
selector: dom.highlight.target
|
||||
delay: dom.highlight.delay
|
||||
|
@ -41,7 +41,7 @@ module.exports = class DOMScriptModule extends ScriptModule
|
|||
|
||||
focusNote: ->
|
||||
note =
|
||||
channel: 'level-focus-dom'
|
||||
channel: 'level:focus-dom'
|
||||
event:
|
||||
selector: @noteGroup.dom.focus
|
||||
note
|
||||
|
@ -51,7 +51,7 @@ module.exports = class DOMScriptModule extends ScriptModule
|
|||
e.showModal = @noteGroup.dom.showVictory in [true, 'Done Button And Modal']
|
||||
e.showModal = showModal if showModal?
|
||||
note =
|
||||
channel: 'level-show-victory'
|
||||
channel: 'level:show-victory'
|
||||
event: e
|
||||
note
|
||||
|
||||
|
@ -59,8 +59,8 @@ module.exports = class DOMScriptModule extends ScriptModule
|
|||
event = {}
|
||||
lock = @noteGroup.dom.lock
|
||||
event.controls = lock if _.isArray lock # array: subset of controls
|
||||
channel = if lock then 'level-disable-controls' else 'level-enable-controls'
|
||||
channel = if lock then 'level:disable-controls' else 'level:enable-controls'
|
||||
return {channel: channel, event: event}
|
||||
|
||||
letterboxNote: ->
|
||||
return {channel: 'level-set-letterbox', event: {on: @noteGroup.dom.letterbox}}
|
||||
return {channel: 'level:set-letterbox', event: {on: @noteGroup.dom.letterbox}}
|
||||
|
|
|
@ -1,31 +0,0 @@
|
|||
ScriptModule = require './ScriptModule'
|
||||
|
||||
module.exports = class GoalsScriptModule extends ScriptModule
|
||||
@neededFor: (noteGroup) ->
|
||||
return noteGroup.goals?
|
||||
|
||||
startNotes: ->
|
||||
notes = []
|
||||
notes.push(@addNote()) if @noteGroup.goals.add?
|
||||
notes.push(@removeNote()) if @noteGroup.goals.remove?
|
||||
return notes
|
||||
|
||||
endNotes: ->
|
||||
return []
|
||||
|
||||
skipNotes: ->
|
||||
return @startNotes()
|
||||
|
||||
addNote: ->
|
||||
note =
|
||||
channel: 'level-add-goals'
|
||||
event:
|
||||
goals: @noteGroup.goals.add
|
||||
return note
|
||||
|
||||
removeNote: ->
|
||||
note =
|
||||
channel: 'level-remove-goals'
|
||||
event:
|
||||
goals: @noteGroup.goals.remove
|
||||
return note
|
|
@ -25,18 +25,17 @@ module.exports = class PlaybackScriptModule extends ScriptModule
|
|||
|
||||
playingNote: ->
|
||||
note =
|
||||
channel: 'level-set-playing'
|
||||
channel: 'level:set-playing'
|
||||
event: {playing: @noteGroup.playback.playing}
|
||||
return note
|
||||
|
||||
scrubNote: (instant=false) ->
|
||||
scrub = @noteGroup.playback.scrub
|
||||
note =
|
||||
channel: 'level-set-time'
|
||||
channel: 'level:set-time'
|
||||
event:
|
||||
frameOffset: scrub.frameOffset or 2
|
||||
scrubDuration: if instant then 0 else scrub.duration
|
||||
note.event.time = scrub.toTime if scrub.toTime?
|
||||
note.event.ratio = scrub.toRatio if scrub.toRatio?
|
||||
return note
|
||||
|
||||
|
|
|
@ -1,6 +1,3 @@
|
|||
# * search for how various places handle or call 'end-current-script' event
|
||||
|
||||
|
||||
CocoClass = require 'lib/CocoClass'
|
||||
CocoView = require 'views/kinds/CocoView'
|
||||
{scriptMatchesEventPrereqs} = require './../world/script_event_prereqs'
|
||||
|
@ -10,8 +7,6 @@ allScriptModules.push(require './SpriteScriptModule')
|
|||
allScriptModules.push(require './DOMScriptModule')
|
||||
allScriptModules.push(require './SurfaceScriptModule')
|
||||
allScriptModules.push(require './PlaybackScriptModule')
|
||||
GoalScriptsModule = require './GoalsScriptModule'
|
||||
allScriptModules.push(GoalScriptsModule)
|
||||
allScriptModules.push(require './SoundScriptModule')
|
||||
|
||||
|
||||
|
@ -32,16 +27,15 @@ module.exports = ScriptManager = class ScriptManager extends CocoClass
|
|||
originalScripts: [] # use these later when you want to revert to an original state
|
||||
|
||||
subscriptions:
|
||||
'end-current-script': 'onEndNoteGroup'
|
||||
'end-all-scripts': 'onEndAll'
|
||||
'script:end-current-script': 'onEndNoteGroup'
|
||||
'level:started': -> @setWorldLoading(false)
|
||||
'level:restarted': 'onLevelRestarted'
|
||||
'level:shift-space-pressed': 'onEndNoteGroup'
|
||||
'level:escape-pressed': 'onEndAll'
|
||||
|
||||
shortcuts:
|
||||
'⇧+space, space, enter': -> Backbone.Mediator.publish 'level:shift-space-pressed'
|
||||
'escape': -> Backbone.Mediator.publish 'level:escape-pressed'
|
||||
'⇧+space, space, enter': -> Backbone.Mediator.publish 'level:shift-space-pressed', {}
|
||||
'escape': -> Backbone.Mediator.publish 'level:escape-pressed', {}
|
||||
|
||||
# SETUP / TEARDOWN
|
||||
|
||||
|
@ -94,13 +88,14 @@ module.exports = ScriptManager = class ScriptManager extends CocoClass
|
|||
scriptStates: scriptStates
|
||||
timeSinceLastScriptEnded: (if @lastScriptEnded then now - @lastScriptEnded else 0) / 1000
|
||||
|
||||
Backbone.Mediator.publish 'script-manager:tick', stateEvent
|
||||
Backbone.Mediator.publish 'script:tick', stateEvent # Is this even needed?
|
||||
|
||||
loadFromSession: ->
|
||||
# load the queue with note groups to skip through
|
||||
@addEndedScriptsFromSession()
|
||||
@addPartiallyEndedScriptFromSession()
|
||||
@fireGoalNotesEarly()
|
||||
for noteGroup in @noteGroupQueue
|
||||
@processNoteGroup(noteGroup)
|
||||
|
||||
addPartiallyEndedScriptFromSession: ->
|
||||
scripts = @session.get('state').scripts
|
||||
|
@ -133,14 +128,6 @@ module.exports = ScriptManager = class ScriptManager extends CocoClass
|
|||
noteGroup.skipMe = true for noteGroup in noteChain
|
||||
@addNoteChain(noteChain, false)
|
||||
|
||||
fireGoalNotesEarly: ->
|
||||
for noteGroup in @noteGroupQueue
|
||||
@processNoteGroup(noteGroup)
|
||||
for module in noteGroup.modules
|
||||
if module instanceof GoalScriptsModule
|
||||
notes = module.skipNotes()
|
||||
@processNote(note, noteGroup) for note in notes
|
||||
|
||||
setWorldLoading: (@worldLoading) ->
|
||||
@run() unless @worldLoading
|
||||
|
||||
|
@ -238,7 +225,7 @@ module.exports = ScriptManager = class ScriptManager extends CocoClass
|
|||
if nextNoteGroup.script.duration
|
||||
f = => @onNoteGroupTimeout? nextNoteGroup
|
||||
setTimeout(f, nextNoteGroup.script.duration)
|
||||
Backbone.Mediator.publish('note-group-started')
|
||||
Backbone.Mediator.publish 'script:note-group-started', {}
|
||||
|
||||
skipAhead: ->
|
||||
return if @worldLoading
|
||||
|
@ -270,7 +257,7 @@ module.exports = ScriptManager = class ScriptManager extends CocoClass
|
|||
|
||||
publishNote: (note) ->
|
||||
Backbone.Mediator.publish 'playback:real-time-playback-ended', {}
|
||||
Backbone.Mediator.publish(note.channel, note.event)
|
||||
Backbone.Mediator.publish note.channel, note.event ? {}
|
||||
|
||||
# ENDING NOTES
|
||||
|
||||
|
@ -279,7 +266,7 @@ module.exports = ScriptManager = class ScriptManager extends CocoClass
|
|||
@endAll({force:true})
|
||||
@initProperties()
|
||||
@resetThings()
|
||||
Backbone.Mediator.publish 'script:reset'
|
||||
Backbone.Mediator.publish 'script:reset', {}
|
||||
@quiet = false
|
||||
@run()
|
||||
|
||||
|
@ -298,7 +285,7 @@ module.exports = ScriptManager = class ScriptManager extends CocoClass
|
|||
clearTimeout(timeout) for timeout in @currentTimeouts
|
||||
for module in @currentNoteGroup.modules
|
||||
@processNote(note, @currentNoteGroup) for note in module.endNotes()
|
||||
Backbone.Mediator.publish 'note-group-ended' unless @quiet
|
||||
Backbone.Mediator.publish 'script:note-group-ended' unless @quiet
|
||||
@scriptInProgress = false
|
||||
@trackScriptCompletionsFromNoteGroup(@currentNoteGroup)
|
||||
@currentNoteGroup = null
|
||||
|
@ -307,8 +294,8 @@ module.exports = ScriptManager = class ScriptManager extends CocoClass
|
|||
@resetThings()
|
||||
@ending = false
|
||||
|
||||
onEndAll: ->
|
||||
# press escape
|
||||
onEndAll: (e) ->
|
||||
# Escape was pressed.
|
||||
@endAll()
|
||||
|
||||
endAll: (options) ->
|
||||
|
@ -341,8 +328,8 @@ module.exports = ScriptManager = class ScriptManager extends CocoClass
|
|||
@run()
|
||||
|
||||
resetThings: ->
|
||||
Backbone.Mediator.publish 'level-enable-controls', {}
|
||||
Backbone.Mediator.publish 'level-set-letterbox', { on: false }
|
||||
Backbone.Mediator.publish 'level:enable-controls', {}
|
||||
Backbone.Mediator.publish 'level:set-letterbox', { on: false }
|
||||
|
||||
trackScriptCompletionsFromNoteGroup: (noteGroup) ->
|
||||
return unless noteGroup.isLast
|
||||
|
|
|
@ -23,12 +23,12 @@ module.exports = class SoundScriptModule extends ScriptModule
|
|||
|
||||
addSuppressSelectionSoundsNote: ->
|
||||
note =
|
||||
channel: 'level-suppress-selection-sounds'
|
||||
channel: 'level:suppress-selection-sounds'
|
||||
event: {suppress: @noteGroup.sound.suppressSelectionSounds}
|
||||
return note
|
||||
|
||||
addMusicNote: ->
|
||||
note =
|
||||
channel: 'level-play-music'
|
||||
channel: 'music-player:play-music'
|
||||
event: @noteGroup.sound.music
|
||||
return note
|
||||
|
|
|
@ -20,7 +20,7 @@ module.exports = class SpritesScriptModule extends ScriptModule
|
|||
spriteMoveNote: (sprite, instant=false) ->
|
||||
duration = if instant then 0 else sprite.move.duration
|
||||
note =
|
||||
channel: 'level-sprite-move'
|
||||
channel: 'sprite:move'
|
||||
event:
|
||||
pos: sprite.move.target
|
||||
duration: duration
|
||||
|
@ -41,7 +41,7 @@ module.exports = class SpritesScriptModule extends ScriptModule
|
|||
blurb = utils.i18n sprite.say, 'blurb'
|
||||
sound = sprite.say.sound # TODO support sound i18n
|
||||
note =
|
||||
channel: 'level-sprite-dialogue'
|
||||
channel: 'level:sprite-dialogue'
|
||||
event:
|
||||
message: text
|
||||
blurb: blurb
|
||||
|
@ -54,7 +54,7 @@ module.exports = class SpritesScriptModule extends ScriptModule
|
|||
|
||||
spriteSelectNote: (sprite) ->
|
||||
note =
|
||||
channel: 'level-select-sprite'
|
||||
channel: 'level:select-sprite'
|
||||
event:
|
||||
thangID: if sprite.select then sprite.id else null
|
||||
return note
|
||||
|
@ -64,7 +64,7 @@ module.exports = class SpritesScriptModule extends ScriptModule
|
|||
for sprite in @noteGroup.sprites or []
|
||||
notes[sprite.id] ?= {}
|
||||
notes[sprite.id]['move'] = (@spriteMoveNote sprite, true) if sprite.move?
|
||||
notes[sprite.id]['say'] = { channel: 'level-sprite-clear-dialogue' } if sprite.say?
|
||||
notes[sprite.id]['say'] = { channel: 'level:sprite-clear-dialogue' } if sprite.say?
|
||||
noteArray = []
|
||||
for spriteID of notes
|
||||
for type of notes[spriteID]
|
||||
|
|
|
@ -13,7 +13,7 @@ module.exports = class SurfaceScriptModule extends ScriptModule
|
|||
|
||||
endNotes: ->
|
||||
notes = []
|
||||
notes.push({channel:'level-highlight-sprites', event: {thangIDs: []}}) if @noteGroup.surface.highlight?
|
||||
notes.push({channel:'sprite:highlight-sprites', event: {thangIDs: []}}) if @noteGroup.surface.highlight?
|
||||
notes.push(@surfaceCameraNote(true)) if @noteGroup.surface.focus?
|
||||
notes.push(@surfaceLockSelectNote()) if @noteGroup.surface.lockSelect?
|
||||
return notes
|
||||
|
@ -33,12 +33,12 @@ module.exports = class SurfaceScriptModule extends ScriptModule
|
|||
e.duration = if focus.duration? then focus.duration else 1500
|
||||
e.duration = 0 if instant
|
||||
e.bounds = focus.bounds if focus.bounds?
|
||||
return { channel: 'level-set-surface-camera', event: e }
|
||||
return { channel: 'camera:set-camera', event: e }
|
||||
|
||||
surfaceHighlightNote: ->
|
||||
highlight = @noteGroup.surface.highlight
|
||||
note =
|
||||
channel: 'level-highlight-sprites'
|
||||
channel: 'sprite:highlight-sprites'
|
||||
event:
|
||||
thangIDs: highlight.targets
|
||||
delay: highlight.delay
|
||||
|
@ -46,4 +46,4 @@ module.exports = class SurfaceScriptModule extends ScriptModule
|
|||
return note
|
||||
|
||||
surfaceLockSelectNote: ->
|
||||
return { channel: 'level-lock-select', event: {lock: @noteGroup.surface.lockSelect} }
|
||||
return { channel: 'level:lock-select', event: {lock: @noteGroup.surface.lockSelect} }
|
||||
|
|
|
@ -8,7 +8,7 @@ module.exports = initializeFacebook = ->
|
|||
cookie: true # enable cookies to allow the server to access the session
|
||||
xfbml: true # parse XFBML
|
||||
|
||||
Backbone.Mediator.publish 'fbapi-loaded'
|
||||
Backbone.Mediator.publish 'auth:facebook-api-loaded', {}
|
||||
|
||||
# This is fired for any auth related change, such as login, logout or session refresh.
|
||||
FB.Event.subscribe 'auth.authResponseChange', (response) ->
|
||||
|
@ -17,13 +17,12 @@ module.exports = initializeFacebook = ->
|
|||
if response.status is 'connected'
|
||||
|
||||
# They have logged in to the app.
|
||||
Backbone.Mediator.publish 'facebook-logged-in',
|
||||
response: response
|
||||
Backbone.Mediator.publish 'facebook-logged-in', response: response
|
||||
|
||||
else if response.status is 'not_authorized'
|
||||
#
|
||||
else
|
||||
#
|
||||
#
|
||||
|
||||
# Load the SDK asynchronously
|
||||
((d) ->
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
module.exports = initializeGoogle = ->
|
||||
window.onGPlusLoaded = ->
|
||||
Backbone.Mediator.publish 'gapi-loaded'
|
||||
Backbone.Mediator.publish 'auth:gplus-api-loaded', {}
|
||||
return
|
||||
window.signinCallback = (authResult) ->
|
||||
Backbone.Mediator.publish 'gplus-logged-in', authResult if authResult['access_token']
|
||||
Backbone.Mediator.publish 'auth:logged-in-with-gplus', authResult if authResult.access_token
|
||||
return
|
||||
(->
|
||||
po = document.createElement('script')
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
module.exports = initializeLinkedIn = ->
|
||||
window.linkedInAsyncInit = ->
|
||||
#console.log 'Linkedin async init success!'
|
||||
Backbone.Mediator.publish 'linkedin-loaded'
|
||||
Backbone.Mediator.publish 'auth:linkedin-api-loaded', {}
|
||||
|
||||
linkedInSnippet =
|
||||
''
|
||||
|
|
|
@ -40,9 +40,9 @@ module.exports = class Camera extends CocoClass
|
|||
# INIT
|
||||
|
||||
subscriptions:
|
||||
'camera-zoom-in': 'onZoomIn'
|
||||
'camera-zoom-out': 'onZoomOut'
|
||||
'camera-zoom-to': 'onZoomTo'
|
||||
'camera:zoom-in': 'onZoomIn'
|
||||
'camera:zoom-out': 'onZoomOut'
|
||||
'camera:zoom-to': 'onZoomTo'
|
||||
'level:restarted': 'onLevelRestarted'
|
||||
'surface:mouse-scrolled': 'onMouseScrolled'
|
||||
'sprite:mouse-down': 'onMouseDown'
|
||||
|
@ -187,7 +187,7 @@ module.exports = class Camera extends CocoClass
|
|||
y: target.y + (@lastPos.y - e.originalEvent.rawY) / @zoom
|
||||
@zoomTo newPos, @zoom, 0
|
||||
@lastPos = {x: e.originalEvent.rawX, y: e.originalEvent.rawY}
|
||||
Backbone.Mediator.publish 'camera:dragged'
|
||||
Backbone.Mediator.publish 'camera:dragged', {}
|
||||
|
||||
onLevelRestarted: ->
|
||||
@setBounds(@firstBounds, false)
|
||||
|
@ -322,5 +322,5 @@ module.exports = class Camera extends CocoClass
|
|||
createjs.Tween.removeTweens @
|
||||
super()
|
||||
|
||||
onZoomTo: (pos, time) ->
|
||||
@zoomTo @worldToSurface(pos), @zoom, time
|
||||
onZoomTo: (e) ->
|
||||
@zoomTo @worldToSurface(e.pos), @zoom, e.duration
|
||||
|
|
|
@ -57,11 +57,11 @@ module.exports = CocoSprite = class CocoSprite extends CocoClass
|
|||
currentAction: null # related action that is right now playing
|
||||
|
||||
subscriptions:
|
||||
'level-sprite-dialogue': 'onDialogue'
|
||||
'level-sprite-clear-dialogue': 'onClearDialogue'
|
||||
'level-set-letterbox': 'onSetLetterbox'
|
||||
'level:sprite-dialogue': 'onDialogue'
|
||||
'level:sprite-clear-dialogue': 'onClearDialogue'
|
||||
'level:set-letterbox': 'onSetLetterbox'
|
||||
'surface:ticked': 'onSurfaceTicked'
|
||||
'level-sprite-move': 'onMove'
|
||||
'sprite:move': 'onMove'
|
||||
|
||||
constructor: (@thangType, options) ->
|
||||
super()
|
||||
|
@ -519,14 +519,11 @@ module.exports = CocoSprite = class CocoSprite extends CocoClass
|
|||
@imageObject.on 'pressmove', @onMouseEvent, @, false, 'sprite:dragged'
|
||||
@imageObject.on 'pressup', @onMouseEvent, @, false, 'sprite:mouse-up'
|
||||
|
||||
onSetLetterbox: (e) ->
|
||||
@letterboxOn = e.on
|
||||
|
||||
onMouseEvent: (e, ourEventName) ->
|
||||
return if @letterboxOn or not @imageObject
|
||||
p = @imageObject
|
||||
p = p.parent while p.parent
|
||||
newEvent = sprite: @, thang: @thang, originalEvent: e, canvas:p.canvas
|
||||
newEvent = sprite: @, thang: @thang, originalEvent: e, canvas: p.canvas
|
||||
@trigger ourEventName, newEvent
|
||||
Backbone.Mediator.publish ourEventName, newEvent
|
||||
|
||||
|
@ -680,7 +677,7 @@ module.exports = CocoSprite = class CocoSprite extends CocoClass
|
|||
sound = e.sound ? AudioPlayer.soundForDialogue e.message, @thangType.get 'soundTriggers'
|
||||
@dialogueSoundInstance?.stop()
|
||||
if @dialogueSoundInstance = @playSound sound, false
|
||||
@dialogueSoundInstance.addEventListener 'complete', -> Backbone.Mediator.publish 'dialogue-sound-completed'
|
||||
@dialogueSoundInstance.addEventListener 'complete', -> Backbone.Mediator.publish 'sprite:dialogue-sound-completed', {}
|
||||
@notifySpeechUpdated e
|
||||
|
||||
onClearDialogue: (e) ->
|
||||
|
@ -688,6 +685,9 @@ module.exports = CocoSprite = class CocoSprite extends CocoClass
|
|||
@dialogueSoundInstance?.stop()
|
||||
@notifySpeechUpdated {}
|
||||
|
||||
onSetLetterbox: (e) ->
|
||||
@letterboxOn = e.on
|
||||
|
||||
setNameLabel: (name) ->
|
||||
label = @addLabel 'name', Label.STYLE_NAME
|
||||
label.setText name
|
||||
|
@ -750,7 +750,7 @@ module.exports = CocoSprite = class CocoSprite extends CocoClass
|
|||
distance = @thang.pos.distance target.pos
|
||||
offset = Math.max(target.width, target.height, 2) / 2 + 3
|
||||
pos = Vector.add(@thang.pos, heading.multiply(distance - offset))
|
||||
Backbone.Mediator.publish 'level-sprite-clear-dialogue', {}
|
||||
Backbone.Mediator.publish 'level:sprite-clear-dialogue', {}
|
||||
@onClearDialogue()
|
||||
args = [pos]
|
||||
args.push(e.duration) if e.duration?
|
||||
|
|
|
@ -2,7 +2,7 @@ CocoClass = require 'lib/CocoClass'
|
|||
|
||||
module.exports = class CoordinateGrid extends CocoClass
|
||||
subscriptions:
|
||||
'level-toggle-grid': 'onToggleGrid'
|
||||
'level:toggle-grid': 'onToggleGrid'
|
||||
|
||||
shortcuts:
|
||||
'ctrl+g, ⌘+g': 'onToggleGrid'
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
module.exports = class DebugDisplay extends createjs.Container
|
||||
layerPriority: 20
|
||||
subscriptions:
|
||||
'level-set-debug': 'onSetDebug'
|
||||
'level:set-debug': 'onSetDebug'
|
||||
|
||||
constructor: (options) ->
|
||||
super()
|
||||
|
|
|
@ -2,9 +2,9 @@ CocoClass = require 'lib/CocoClass'
|
|||
|
||||
module.exports = class Dimmer extends CocoClass
|
||||
subscriptions:
|
||||
'level-disable-controls': 'onDisableControls'
|
||||
'level-enable-controls': 'onEnableControls'
|
||||
'level-highlight-sprites': 'onHighlightSprites'
|
||||
'level:disable-controls': 'onDisableControls'
|
||||
'level:enable-controls': 'onEnableControls'
|
||||
'sprite:highlight-sprites': 'onHighlightSprites'
|
||||
'sprite:speech-updated': 'onSpriteSpeechUpdated'
|
||||
'surface:frame-changed': 'onFrameChanged'
|
||||
'camera:zoom-updated': 'onZoomUpdated'
|
||||
|
|
|
@ -4,8 +4,8 @@ CocoSprite = require 'lib/surface/CocoSprite'
|
|||
module.exports = IndieSprite = class IndieSprite extends CocoSprite
|
||||
notOfThisWorld: true
|
||||
subscriptions:
|
||||
'note-group-started': 'onNoteGroupStarted'
|
||||
'note-group-ended': 'onNoteGroupEnded'
|
||||
'script:note-group-started': 'onNoteGroupStarted'
|
||||
'script:note-group-ended': 'onNoteGroupEnded'
|
||||
|
||||
constructor: (thangType, options) ->
|
||||
options.thang = @makeIndieThang thangType, options
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
module.exports = class Letterbox extends createjs.Container
|
||||
subscriptions:
|
||||
'level-set-letterbox': 'onSetLetterbox'
|
||||
'level:set-letterbox': 'onSetLetterbox'
|
||||
|
||||
constructor: (options) ->
|
||||
super()
|
||||
|
|
|
@ -216,7 +216,7 @@ module.exports = class Mark extends CocoClass
|
|||
onLoadedThangType: ->
|
||||
@build()
|
||||
@toggle(@toggleTo) if @toggleTo?
|
||||
Backbone.Mediator.publish 'sprite:loaded'
|
||||
Backbone.Mediator.publish 'sprite:loaded', {sprite: @}
|
||||
|
||||
update: (pos=null) ->
|
||||
return false unless @on and @mark
|
||||
|
|
|
@ -9,7 +9,7 @@ module.exports = class MusicPlayer extends CocoClass
|
|||
standingBy: null
|
||||
|
||||
subscriptions:
|
||||
'level-play-music': 'onPlayMusic'
|
||||
'music-player:play-music': 'onPlayMusic'
|
||||
'audio-player:loaded': 'onAudioLoaded'
|
||||
|
||||
constructor: ->
|
||||
|
|
|
@ -24,10 +24,9 @@ module.exports = class PointChooser extends CocoClass
|
|||
@shape.layerIndex = 100
|
||||
|
||||
onMouseDown: (e) =>
|
||||
console.log 'got stagemousedown', e, key.shift
|
||||
return unless key.shift
|
||||
@setPoint @options.camera.screenToWorld {x: e.stageX, y: e.stageY}
|
||||
Backbone.Mediator.publish 'choose-point', point: @point
|
||||
Backbone.Mediator.publish 'surface:choose-point', point: @point
|
||||
|
||||
updateShape: ->
|
||||
sup = @options.camera.worldToSurface @point
|
||||
|
|
|
@ -27,7 +27,7 @@ module.exports = class RegionChooser extends CocoClass
|
|||
|
||||
onMouseUp: (e) =>
|
||||
return unless @firstPoint
|
||||
Backbone.Mediator.publish 'choose-region', points: [@firstPoint, @secondPoint]
|
||||
Backbone.Mediator.publish 'surface:choose-region', points: [@firstPoint, @secondPoint]
|
||||
@firstPoint = null
|
||||
@secondPoint = null
|
||||
@options.camera.dragDisabled = false
|
||||
|
|
|
@ -12,12 +12,12 @@ module.exports = class SpriteBoss extends CocoClass
|
|||
subscriptions:
|
||||
'bus:player-joined': 'onPlayerJoined'
|
||||
'bus:player-left': 'onPlayerLeft'
|
||||
'level-set-debug': 'onSetDebug'
|
||||
'level-highlight-sprites': 'onHighlightSprites'
|
||||
'level:set-debug': 'onSetDebug'
|
||||
'sprite:highlight-sprites': 'onHighlightSprites'
|
||||
'surface:stage-mouse-down': 'onStageMouseDown'
|
||||
'level-select-sprite': 'onSelectSprite'
|
||||
'level-suppress-selection-sounds': 'onSuppressSelectionSounds'
|
||||
'level-lock-select': 'onSetLockSelect'
|
||||
'level:select-sprite': 'onSelectSprite'
|
||||
'level:suppress-selection-sounds': 'onSuppressSelectionSounds'
|
||||
'level:lock-select': 'onSetLockSelect'
|
||||
'level:restarted': 'onLevelRestarted'
|
||||
'god:new-world-created': 'onNewWorld'
|
||||
'god:streaming-world-updated': 'onNewWorld'
|
||||
|
@ -198,7 +198,7 @@ module.exports = class SpriteBoss extends CocoClass
|
|||
sprite.setThang thang # make sure Sprite has latest Thang
|
||||
else
|
||||
sprite = @addThangToSprites(thang)
|
||||
Backbone.Mediator.publish 'surface:new-thang-added', thang:thang, sprite:sprite
|
||||
Backbone.Mediator.publish 'surface:new-thang-added', thang: thang, sprite: sprite
|
||||
updateCache = updateCache or sprite.imageObject.parent is @spriteLayers['Obstacle']
|
||||
sprite.playSounds()
|
||||
item.modifyStats() for item in itemsJustEquipped
|
||||
|
@ -319,9 +319,9 @@ module.exports = class SpriteBoss extends CocoClass
|
|||
if alive and not @suppressSelectionSounds
|
||||
instance = sprite.playSound 'selected'
|
||||
if instance?.playState is 'playSucceeded'
|
||||
Backbone.Mediator.publish 'thang-began-talking', thang: sprite?.thang
|
||||
Backbone.Mediator.publish 'sprite:thang-began-talking', thang: sprite?.thang
|
||||
instance.addEventListener 'complete', ->
|
||||
Backbone.Mediator.publish 'thang-finished-talking', thang: sprite?.thang
|
||||
Backbone.Mediator.publish 'sprite:thang-finished-talking', thang: sprite?.thang
|
||||
|
||||
onFlagColorSelected: (e) ->
|
||||
@removeSprite @flagCursorSprite if @flagCursorSprite
|
||||
|
|
|
@ -52,19 +52,19 @@ module.exports = Surface = class Surface extends CocoClass
|
|||
frameRate: 30 # Best as a divisor of 60, like 15, 30, 60, with RAF_SYNCHED timing.
|
||||
|
||||
subscriptions:
|
||||
'level-disable-controls': 'onDisableControls'
|
||||
'level-enable-controls': 'onEnableControls'
|
||||
'level-set-playing': 'onSetPlaying'
|
||||
'level-set-debug': 'onSetDebug'
|
||||
'level-toggle-debug': 'onToggleDebug'
|
||||
'level-toggle-pathfinding': 'onTogglePathFinding'
|
||||
'level-set-time': 'onSetTime'
|
||||
'level-set-surface-camera': 'onSetCamera'
|
||||
'level:disable-controls': 'onDisableControls'
|
||||
'level:enable-controls': 'onEnableControls'
|
||||
'level:set-playing': 'onSetPlaying'
|
||||
'level:set-debug': 'onSetDebug'
|
||||
'level:toggle-debug': 'onToggleDebug'
|
||||
'level:toggle-pathfinding': 'onTogglePathFinding'
|
||||
'level:set-time': 'onSetTime'
|
||||
'camera:set-camera': 'onSetCamera'
|
||||
'level:restarted': 'onLevelRestarted'
|
||||
'god:new-world-created': 'onNewWorld'
|
||||
'god:streaming-world-updated': 'onNewWorld'
|
||||
'tome:cast-spells': 'onCastSpells'
|
||||
'level-set-letterbox': 'onSetLetterbox'
|
||||
'level:set-letterbox': 'onSetLetterbox'
|
||||
'application:idle-changed': 'onIdleChanged'
|
||||
'camera:zoom-updated': 'onZoomUpdated'
|
||||
'playback:real-time-playback-started': 'onRealTimePlaybackStarted'
|
||||
|
@ -127,7 +127,7 @@ module.exports = Surface = class Surface extends CocoClass
|
|||
@showLevel()
|
||||
@updateState true if @loaded
|
||||
@onFrameChanged()
|
||||
Backbone.Mediator.publish 'surface:world-set-up'
|
||||
Backbone.Mediator.publish 'surface:world-set-up', {world: @world}
|
||||
|
||||
onTogglePathFinding: (e) ->
|
||||
e?.preventDefault?()
|
||||
|
@ -311,7 +311,6 @@ module.exports = Surface = class Surface extends CocoClass
|
|||
return if @currentFrame is @lastFrame and not force
|
||||
progress = @getProgress()
|
||||
Backbone.Mediator.publish('surface:frame-changed',
|
||||
type: 'frame-changed'
|
||||
selectedThang: @spriteBoss.selectedSprite?.thang
|
||||
progress: progress
|
||||
frame: @currentFrame
|
||||
|
@ -321,11 +320,11 @@ module.exports = Surface = class Surface extends CocoClass
|
|||
if @lastFrame < @world.frames.length and @currentFrame >= @world.totalFrames - 1
|
||||
@ended = true
|
||||
@setPaused true
|
||||
Backbone.Mediator.publish 'surface:playback-ended'
|
||||
Backbone.Mediator.publish 'surface:playback-ended', {}
|
||||
else if @currentFrame < @world.totalFrames and @ended
|
||||
@ended = false
|
||||
@setPaused false
|
||||
Backbone.Mediator.publish 'surface:playback-restarted'
|
||||
Backbone.Mediator.publish 'surface:playback-restarted', {}
|
||||
|
||||
@lastFrame = @currentFrame
|
||||
|
||||
|
@ -368,7 +367,7 @@ module.exports = Surface = class Surface extends CocoClass
|
|||
|
||||
# This has a tendency to break scripts that are waiting for playback to change when the level is loaded
|
||||
# so only run it after the first world is created.
|
||||
Backbone.Mediator.publish 'level-set-playing', {playing: true} unless event.firstWorld or @setPlayingCalled
|
||||
Backbone.Mediator.publish 'level:set-playing', {playing: true} unless event.firstWorld or @setPlayingCalled
|
||||
|
||||
@setWorld event.world
|
||||
@onFrameChanged(true)
|
||||
|
@ -450,11 +449,10 @@ module.exports = Surface = class Surface extends CocoClass
|
|||
@loaded = true
|
||||
@spriteBoss.createMarks()
|
||||
@spriteBoss.createIndieSprites @world.indieSprites, @options.wizards
|
||||
Backbone.Mediator.publish 'registrar-echo-states'
|
||||
@updateState true
|
||||
@drawCurrentFrame()
|
||||
createjs.Ticker.addEventListener 'tick', @tick
|
||||
Backbone.Mediator.publish 'level:started'
|
||||
Backbone.Mediator.publish 'level:started', {}
|
||||
|
||||
createOpponentWizard: (opponent) ->
|
||||
@spriteBoss.createOpponentWizard opponent
|
||||
|
@ -464,7 +462,7 @@ module.exports = Surface = class Surface extends CocoClass
|
|||
|
||||
onToggleDebug: (e) ->
|
||||
e?.preventDefault?()
|
||||
Backbone.Mediator.publish 'level-set-debug', {debug: not @debug}
|
||||
Backbone.Mediator.publish 'level:set-debug', {debug: not @debug}
|
||||
|
||||
onSetDebug: (e) ->
|
||||
return if e.debug is @debug
|
||||
|
@ -488,6 +486,7 @@ module.exports = Surface = class Surface extends CocoClass
|
|||
|
||||
onMouseUp: (e) =>
|
||||
return if @disabled
|
||||
console.log 'yo on mouse up', e
|
||||
onBackground = not @stage.hitTest e.stageX, e.stageY
|
||||
Backbone.Mediator.publish 'surface:stage-mouse-up', onBackground: onBackground, x: e.stageX, y: e.stageY, originalEvent: e
|
||||
|
||||
|
|
|
@ -16,10 +16,9 @@ module.exports = class WizardSprite extends IndieSprite
|
|||
|
||||
subscriptions:
|
||||
'bus:player-states-changed': 'onPlayerStatesChanged'
|
||||
'me:synced': 'onMeSynced'
|
||||
'auth:me-synced': 'onMeSynced'
|
||||
'surface:sprite-selected': 'onSpriteSelected'
|
||||
'echo-self-wizard-sprite': 'onEchoSelfWizardSprite'
|
||||
'echo-all-wizard-sprites': 'onEchoAllWizardSprites'
|
||||
'sprite:echo-all-wizard-sprites': 'onEchoAllWizardSprites'
|
||||
|
||||
shortcuts:
|
||||
'up': 'onMoveKey'
|
||||
|
@ -36,6 +35,7 @@ module.exports = class WizardSprite extends IndieSprite
|
|||
@setNameLabel me.displayName()
|
||||
else if options.name
|
||||
@setNameLabel options.name
|
||||
Backbone.Mediator.publish 'self-wizard:created', sprite: @
|
||||
|
||||
makeIndieThang: (thangType, options) ->
|
||||
thang = super thangType, options
|
||||
|
@ -112,7 +112,6 @@ module.exports = class WizardSprite extends IndieSprite
|
|||
@targetPos = @getPosFromTarget(@targetSprite or targetPos)
|
||||
@endMoveTween()
|
||||
|
||||
onEchoSelfWizardSprite: (e) -> e.payload = @ if @isSelf
|
||||
onEchoAllWizardSprites: (e) -> e.payload.push @
|
||||
defaultPos: -> x: 35, y: 24, z: @thang.depth / 2 + @thang.bobHeight
|
||||
move: (pos, duration) -> @setTarget(pos, duration)
|
||||
|
@ -132,7 +131,7 @@ module.exports = class WizardSprite extends IndieSprite
|
|||
@targetPos = @boundWizard targetPos
|
||||
@beginMoveTween(duration, isLinear)
|
||||
@shoveOtherWizards()
|
||||
Backbone.Mediator.publish('self-wizard:target-changed', {sender: @}) if @isSelf
|
||||
Backbone.Mediator.publish('self-wizard:target-changed', {sprite: @}) if @isSelf
|
||||
|
||||
boundWizard: (target) ->
|
||||
# Passed an {x, y} in world coordinates, returns {x, y} within world bounds
|
||||
|
@ -179,7 +178,7 @@ module.exports = class WizardSprite extends IndieSprite
|
|||
shoveOtherWizards: (removeMe) ->
|
||||
return unless @targetSprite
|
||||
allWizards = []
|
||||
Backbone.Mediator.publish('echo-all-wizard-sprites', {payload: allWizards})
|
||||
Backbone.Mediator.publish 'sprite:echo-all-wizard-sprites', payload: allWizards
|
||||
allOfUs = (wizard for wizard in allWizards when wizard.targetSprite is @targetSprite)
|
||||
allOfUs = (wizard for wizard in allOfUs when wizard isnt @) if removeMe
|
||||
|
||||
|
@ -271,4 +270,4 @@ module.exports = class WizardSprite extends IndieSprite
|
|||
position = {x: @targetPos.x + x, y: @targetPos.y + y}
|
||||
@setTarget(position, interval, true)
|
||||
@updatePosition()
|
||||
Backbone.Mediator.publish 'camera-zoom-to', position, interval
|
||||
Backbone.Mediator.publish 'camera:zoom-to', pos: position, duration: interval
|
||||
|
|
|
@ -312,7 +312,7 @@ class CocoModel extends Backbone.Model
|
|||
achievements = new NewAchievementCollection
|
||||
achievements.fetch
|
||||
success: (collection) ->
|
||||
me.fetch (success: -> Backbone.Mediator.publish('achievements:new', collection)) unless _.isEmpty(collection.models)
|
||||
me.fetch (success: -> Backbone.Mediator.publish('achievements:new', earnedAchievements: collection)) unless _.isEmpty(collection.models)
|
||||
error: ->
|
||||
console.error 'Miserably failed to fetch unnotified achievements', arguments
|
||||
|
||||
|
|
|
@ -65,7 +65,7 @@ GoalSchema = c.object {title: 'Goal', description: 'A goal that the player can a
|
|||
|
||||
ResponseSchema = c.object {title: 'Dialogue Button', description: 'A button to be shown to the user with the dialogue.', required: ['text']},
|
||||
text: {title: 'Title', description: 'The text that will be on the button', 'default': 'Okay', type: 'string', maxLength: 30}
|
||||
channel: c.shortString(title: 'Channel', format: 'event-channel', description: 'Channel that this event will be broadcast over, like "level-set-playing".')
|
||||
channel: c.shortString(title: 'Channel', format: 'event-channel', description: 'Channel that this event will be broadcast over, like "level:set-playing".')
|
||||
event: {type: 'object', title: 'Event', description: 'Event that will be broadcast when this button is pressed, like {playing: true}.'}
|
||||
buttonClass: c.shortString(title: 'Button Class', description: 'CSS class that will be added to the button, like "btn-primary".')
|
||||
i18n: {type: 'object', format: 'i18n', props: ['text'], description: 'Help translate this button'}
|
||||
|
|
|
@ -1,45 +0,0 @@
|
|||
module.exports =
|
||||
'application: idle-changed':
|
||||
{} # TODO schema
|
||||
|
||||
'fbapi-loaded':
|
||||
{} # TODO schema
|
||||
|
||||
'logging-in-with-facebook':
|
||||
{} # TODO schema
|
||||
|
||||
'facebook-logged-in':
|
||||
title: 'Facebook logged in'
|
||||
$schema: 'http://json-schema.org/draft-04/schema#'
|
||||
description: 'Published when you successfully logged in with facebook'
|
||||
type: 'object'
|
||||
properties:
|
||||
response:
|
||||
type: 'object'
|
||||
properties:
|
||||
status: {type: 'string'}
|
||||
authResponse:
|
||||
type: 'object'
|
||||
properties:
|
||||
accessToken: {type: 'string'}
|
||||
expiresIn: {type: 'number'}
|
||||
signedRequest: {type: 'string'}
|
||||
userID: {type: 'string'}
|
||||
required: ['response']
|
||||
|
||||
'facebook-logged-out': {}
|
||||
|
||||
'linkedin-loaded': {}
|
||||
|
||||
'gapi-loaded':
|
||||
{} # TODO schema
|
||||
|
||||
'logging-in-with-gplus':
|
||||
{} # TODO schema
|
||||
|
||||
'gplus-logged-in':
|
||||
title: 'G+ logged in'
|
||||
$schema: 'http://json-schema.org/draft-04/schema#'
|
||||
description: 'Published when you successfully logged in with G+'
|
||||
type: 'object'
|
||||
required: ['access_token']
|
39
app/schemas/subscriptions/auth.coffee
Normal file
39
app/schemas/subscriptions/auth.coffee
Normal file
|
@ -0,0 +1,39 @@
|
|||
c = require 'schemas/schemas'
|
||||
|
||||
module.exports =
|
||||
'auth:me-synced': c.object {required: ['me']},
|
||||
me: {type: 'object'}
|
||||
|
||||
'auth:facebook-api-loaded': c.object {}
|
||||
|
||||
'auth:logging-in-with-facebook': c.object {}
|
||||
|
||||
'auth:logged-in-with-facebook': c.object {title: 'Facebook logged in', description: 'Published when you successfully logged in with Facebook', required: ['response']},
|
||||
response:
|
||||
type: 'object'
|
||||
properties:
|
||||
status: {type: 'string'}
|
||||
authResponse:
|
||||
type: 'object'
|
||||
properties:
|
||||
accessToken: {type: 'string'}
|
||||
expiresIn: {type: 'number'}
|
||||
signedRequest: {type: 'string'}
|
||||
userID: {type: 'string'}
|
||||
|
||||
'auth:linkedin-api-loaded': c.object {}
|
||||
|
||||
'auth:gplus-api-loaded': c.object {}
|
||||
|
||||
'auth:logging-in-with-gplus': c.object {}
|
||||
|
||||
'auth:logged-in-with-gplus':
|
||||
title: 'G+ logged in'
|
||||
description: 'Published when you successfully logged in with G+'
|
||||
type: 'object'
|
||||
required: ['access_token']
|
||||
properties:
|
||||
access_token: {type: 'string'}
|
||||
# Could be some other stuff
|
||||
|
||||
'auth:log-in-with-github': c.object {}
|
|
@ -1,71 +1,27 @@
|
|||
c = require 'schemas/schemas'
|
||||
|
||||
module.exports =
|
||||
'bus:connecting':
|
||||
title: 'Bus Connecting'
|
||||
$schema: 'http://json-schema.org/draft-04/schema#'
|
||||
description: 'Published when a Bus starts connecting'
|
||||
type: 'object'
|
||||
properties:
|
||||
bus:
|
||||
$ref: 'bus'
|
||||
'bus:connecting': c.object {title: 'Bus Connecting', description: 'Published when a Bus starts connecting'},
|
||||
bus: {$ref: 'bus'}
|
||||
|
||||
'bus:connected':
|
||||
title: 'Bus Connected'
|
||||
$schema: 'http://json-schema.org/draft-04/schema#'
|
||||
description: 'Published when a Bus has connected'
|
||||
type: 'object'
|
||||
properties:
|
||||
bus:
|
||||
$ref: 'bus'
|
||||
'bus:connected': c.object {title: 'Bus Connected', description: 'Published when a Bus has connected'},
|
||||
bus: {$ref: 'bus'}
|
||||
|
||||
'bus:disconnected':
|
||||
title: 'Bus Disconnected'
|
||||
$schema: 'http://json-schema.org/draft-04/schema#'
|
||||
description: 'Published when a Bus has disconnected'
|
||||
type: 'object'
|
||||
properties:
|
||||
bus:
|
||||
$ref: 'bus'
|
||||
'bus:disconnected': c.object {title: 'Bus Disconnected', description: 'Published when a Bus has disconnected'},
|
||||
bus: {$ref: 'bus'}
|
||||
|
||||
'bus:new-message':
|
||||
title: 'Message sent'
|
||||
$schema: 'http://json-schema.org/draft-04/schema#'
|
||||
description: 'A new message was sent'
|
||||
type: 'object'
|
||||
properties:
|
||||
message:
|
||||
type: 'object'
|
||||
bus:
|
||||
$ref: 'bus'
|
||||
'bus:new-message': c.object {title: 'Message sent', description: 'A new message was sent'},
|
||||
message: {type: 'object'}
|
||||
bus: {$ref: 'bus'}
|
||||
|
||||
'bus:player-joined':
|
||||
title: 'Player joined'
|
||||
$schema: 'http://json-schema.org/draft-04/schema#'
|
||||
description: 'A new player has joined'
|
||||
type: 'object'
|
||||
properties:
|
||||
player:
|
||||
type: 'object'
|
||||
bus:
|
||||
$ref: 'bus'
|
||||
'bus:player-joined': c.object {title: 'Player joined', description: 'A new player has joined'},
|
||||
player: {type: 'object'}
|
||||
bus: {$ref: 'bus'}
|
||||
|
||||
'bus:player-left':
|
||||
title: 'Player left'
|
||||
$schema: 'http://json-schema.org/draft-04/schema#'
|
||||
description: 'A player has left'
|
||||
type: 'object'
|
||||
properties:
|
||||
player:
|
||||
type: 'object'
|
||||
bus:
|
||||
$ref: 'bus'
|
||||
'bus:player-left': c.object {title: 'Player left', description: 'A player has left'},
|
||||
player: {type: 'object'}
|
||||
bus: {$ref: 'bus'}
|
||||
|
||||
'bus:player-states-changed':
|
||||
title: 'Player state changes'
|
||||
$schema: 'http://json-schema.org/draft-04/schema#'
|
||||
description: 'State of the players has changed'
|
||||
type: 'object'
|
||||
properties:
|
||||
player:
|
||||
type: 'array'
|
||||
bus:
|
||||
$ref: 'bus'
|
||||
'bus:player-states-changed': c.object {title: 'Player state changes', description: 'State of the players has changed'},
|
||||
states: c.array {}, {type: 'object'}
|
||||
bus: {$ref: 'bus'}
|
||||
|
|
|
@ -1,78 +1,43 @@
|
|||
c = require 'schemas/schemas'
|
||||
|
||||
module.exports =
|
||||
'save-new-version':
|
||||
title: 'Save New Version'
|
||||
$schema: 'http://json-schema.org/draft-04/schema#'
|
||||
description: 'Published when a version gets saved'
|
||||
type: 'object'
|
||||
properties:
|
||||
major:
|
||||
type: 'boolean'
|
||||
commitMessage:
|
||||
type: 'string'
|
||||
required: ['major', 'commitMessage']
|
||||
additionalProperties: false
|
||||
'editor:save-new-version': c.object {title: 'Save New Version', description: 'Published when a version gets saved', required: ['major', 'commitMessage']},
|
||||
major: {type: 'boolean'}
|
||||
commitMessage: {type: 'string'}
|
||||
|
||||
# TODO all these events starting with 'level:' should have 'editor' in their name
|
||||
# to avoid confusion with level play events
|
||||
'editor:view-switched': c.object {title: 'Level View Switched', description: 'Published whenever the view switches'}
|
||||
|
||||
'level:view-switched':
|
||||
title: 'Level View Switched'
|
||||
$schema: 'http://json-schema.org/draft-04/schema#'
|
||||
description: 'Published whenever the view switches'
|
||||
$ref: 'jQueryEvent'
|
||||
'editor:level-component-editing-ended': c.object {required: ['component']},
|
||||
component: {type: 'object'}
|
||||
|
||||
'level-components-changed':
|
||||
{} # TODO schema
|
||||
'editor:edit-level-system': c.object {required: ['original', 'majorVersion']},
|
||||
original: {type: 'string'}
|
||||
majorVersion: {type: 'integer', minimum: 0}
|
||||
|
||||
'edit-level-component':
|
||||
{} # TODO schema
|
||||
'editor:level-system-added': c.object {required: ['system']},
|
||||
system: {type: 'object'}
|
||||
|
||||
'level-component-edited':
|
||||
{} # TODO schema
|
||||
'editor:level-system-editing-ended': c.object {required: ['system']},
|
||||
system: {type: 'object'}
|
||||
|
||||
'level-component-editing-ended':
|
||||
{} # TODO schema
|
||||
'editor:edit-level-thang': c.object {required: ['thangID']},
|
||||
thangID: {type: 'string'}
|
||||
|
||||
'level-systems-changed':
|
||||
{} # TODO schema
|
||||
'editor:level-thang-edited': c.object {required: ['thangID', 'thangData']},
|
||||
thangID: {type: 'string'}
|
||||
thangData: {type: 'object'}
|
||||
|
||||
'edit-level-system':
|
||||
{} # TODO schema
|
||||
'editor:level-thang-done-editing': c.object {}
|
||||
|
||||
'level-system-added':
|
||||
{} # TODO schema
|
||||
'editor:level-loaded': c.object {required: ['level']},
|
||||
level: {type: 'object'}
|
||||
|
||||
'level-system-edited':
|
||||
{} # TODO schema
|
||||
'level:reload-from-data': c.object {required: ['level', 'supermodel']},
|
||||
level: {type: 'object'}
|
||||
supermodel: {type: 'object'}
|
||||
|
||||
'level-system-editing-ended':
|
||||
{} # TODO schema
|
||||
'level:reload-thang-type': c.object {required: ['thangType']},
|
||||
thangType: {type: 'object'}
|
||||
|
||||
'level-thangs-changed':
|
||||
title: 'Level Thangs Changed'
|
||||
$schema: 'http://json-schema.org/draft-04/schema#'
|
||||
description: 'Published when a Thang changes'
|
||||
type: 'object'
|
||||
properties:
|
||||
thangsData:
|
||||
type: 'array'
|
||||
required: ['thangsData']
|
||||
additionalProperties: false
|
||||
|
||||
'edit-level-thang':
|
||||
{} # TODO schema
|
||||
|
||||
'level-thang-edited':
|
||||
{} # TODO schema
|
||||
|
||||
'level-thang-done-editing':
|
||||
{} # TODO schema
|
||||
|
||||
'level-loaded':
|
||||
{} # TODO schema
|
||||
|
||||
'level-reload-from-data':
|
||||
{} # TODO schema
|
||||
|
||||
'save-new-version':
|
||||
{} # TODO schema
|
||||
'editor:random-terrain-generated': c.object {required: ['thangs']},
|
||||
thangs: c.array {}, {type: 'object'}
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
c = require 'schemas/schemas'
|
||||
|
||||
module.exports =
|
||||
# app/lib/errors
|
||||
'server-error':
|
||||
{} # TODO schema
|
||||
'errors:server-error': c.object {required: ['response']},
|
||||
response: {type: 'object'}
|
||||
|
|
53
app/schemas/subscriptions/god.coffee
Normal file
53
app/schemas/subscriptions/god.coffee
Normal file
|
@ -0,0 +1,53 @@
|
|||
c = require 'schemas/schemas'
|
||||
|
||||
goalStatesSchema =
|
||||
type: 'object'
|
||||
additionalProperties:
|
||||
type: 'object'
|
||||
required: ['status']
|
||||
properties:
|
||||
status:
|
||||
oneOf: [
|
||||
{type: 'null'}
|
||||
{type: 'string', enum: ['success', 'failure', 'incomplete']}
|
||||
]
|
||||
keyFrame:
|
||||
oneOf: [
|
||||
{type: 'integer', minimum: 0}
|
||||
{type: 'string', enum: ['end']}
|
||||
]
|
||||
team: {type: ['null', 'string']}
|
||||
|
||||
worldUpdatedEventSchema = c.object {required: ['world', 'firstWorld', 'goalStates', 'team', 'firstChangedFrame']},
|
||||
world: {type: 'object'}
|
||||
firstWorld: {type: 'boolean'}
|
||||
goalStates: goalStatesSchema
|
||||
team: {type: 'string'}
|
||||
firstChangedFrame: {type: 'integer', minimum: 0}
|
||||
|
||||
module.exports =
|
||||
'god:user-code-problem': c.object {required: ['problem']},
|
||||
problem: {type: 'object'}
|
||||
|
||||
'god:non-user-code-problem': c.object {required: ['problem']},
|
||||
problem: {type: 'object'}
|
||||
|
||||
'god:infinite-loop': c.object {required: ['firstWorld']},
|
||||
firstWorld: {type: 'boolean'}
|
||||
|
||||
'god:new-world-created': worldUpdatedEventSchema
|
||||
|
||||
'god:streaming-world-updated': worldUpdatedEventSchema
|
||||
|
||||
'god:goals-calculated': c.object {required: ['goalStates']},
|
||||
goalStates: goalStatesSchema
|
||||
|
||||
'god:world-load-progress-changed': c.object {required: ['progress']},
|
||||
progress: {type: 'number', minimum: 0, maximum: 1}
|
||||
|
||||
'god:debug-world-load-progress-changed': c.object {required: ['progress']},
|
||||
progress: {type: 'number', minimum: 0, maximum: 1}
|
||||
|
||||
'god:debug-value-return': c.object {required: ['key']},
|
||||
key: {type: 'string'}
|
||||
value: {type: 'any'}
|
|
@ -1,23 +1,29 @@
|
|||
c = require 'schemas/schemas'
|
||||
|
||||
module.exports =
|
||||
'audio-played:loaded':
|
||||
{} # TODO schema
|
||||
'application:idle-changed': c.object {},
|
||||
idle: {type: 'boolean'}
|
||||
|
||||
# TODO location is debatable
|
||||
'note-group-started':
|
||||
{} # TODO schema
|
||||
'audio-player:loaded': c.object {required: ['sender']},
|
||||
sender: {type: 'object'}
|
||||
|
||||
'note-group-ended':
|
||||
{} # TODO schema
|
||||
'audio-player:play-sound': c.object {required: ['trigger']},
|
||||
trigger: {type: 'string'}
|
||||
volume: {type: 'number', minimum: 0, maximum: 1}
|
||||
|
||||
'modal-opened':
|
||||
{} # TODO schema
|
||||
'music-player:play-music': c.object {required: ['play']},
|
||||
play: {type: 'boolean'}
|
||||
file: {type: 'string'}
|
||||
|
||||
'modal-closed':
|
||||
{} # TODO schema
|
||||
'modal:opened': c.object {}
|
||||
|
||||
# TODO I propose prepending 'modal:'
|
||||
'save-new-version':
|
||||
{} # TODO schema
|
||||
'modal:closed': c.object {}
|
||||
|
||||
'router:navigate':
|
||||
{} # TODO schema
|
||||
'router:navigate': c.object {required: ['route']},
|
||||
route: {type: 'string'}
|
||||
view: {type: 'object'}
|
||||
viewClass: {type: 'object'}
|
||||
viewArgs: {type: 'array'}
|
||||
|
||||
'achievements:new': c.object {required: 'earnedAchievements'},
|
||||
earnedAchievements: {type: 'object'}
|
||||
|
|
|
@ -1,203 +1,153 @@
|
|||
c = require 'schemas/schemas'
|
||||
|
||||
module.exports =
|
||||
# TODO There should be a better way to divide these channels into smaller ones
|
||||
|
||||
# TODO location is debatable
|
||||
'echo-self-wizard-sprite':
|
||||
{} # TODO schema
|
||||
'level:session-will-save': c.object {required: ['session']},
|
||||
session: {type: 'object'}
|
||||
|
||||
'level:session-will-save':
|
||||
{} # TODO schema
|
||||
'level:shift-space-pressed': c.object {}
|
||||
|
||||
'level-loader:progress-changed':
|
||||
{} # TODO schema
|
||||
'level:escape-pressed': c.object {}
|
||||
|
||||
'level:shift-space-pressed':
|
||||
{} # TODO schema
|
||||
'level:enable-controls': c.object {},
|
||||
controls: c.array {},
|
||||
c.shortString()
|
||||
|
||||
'level:escape-pressed':
|
||||
{} # TODO schema
|
||||
'level:disable-controls': c.object {},
|
||||
controls: c.array {},
|
||||
c.shortString()
|
||||
|
||||
'level-enable-controls':
|
||||
{} # TODO schema
|
||||
|
||||
'level-set-letterbox':
|
||||
{} # TODO schema
|
||||
'level:set-letterbox': c.object {},
|
||||
on: {type: 'boolean'}
|
||||
|
||||
'level:started':
|
||||
{} # TODO schema
|
||||
'level:started': c.object {}
|
||||
|
||||
'level-set-debug':
|
||||
{} # TODO schema
|
||||
'level:set-debug': c.object {required: ['debug']},
|
||||
debug: {type: 'boolean'}
|
||||
|
||||
'level:restarted':
|
||||
{} # TODO schema
|
||||
'level:restart': c.object {}
|
||||
|
||||
'level-set-volume':
|
||||
{} # TODO schema
|
||||
'level:restarted': c.object {}
|
||||
|
||||
'level-set-time':
|
||||
{} # TODO schema
|
||||
'level:set-volume': c.object {required: ['volume']},
|
||||
volume: {type: 'number', minimum: 0, maximum: 1}
|
||||
|
||||
'level-select-sprite':
|
||||
{} # TODO schema
|
||||
'level:set-time': c.object {},
|
||||
time: {type: 'number', minimum: 0}
|
||||
ratio: {type: 'number', minimum: 0, maximum: 1}
|
||||
frameOffset: {type: 'integer'}
|
||||
scrubDuration: {type: 'integer', minimum: 0}
|
||||
|
||||
'level-set-playing':
|
||||
{} # TODO schema
|
||||
'level:select-sprite': c.object {},
|
||||
thangID: {type: ['string', 'null', 'undefined']}
|
||||
spellName: {type: ['string', 'null', 'undefined']}
|
||||
|
||||
'level:team-set':
|
||||
{} # TODO schema
|
||||
'level:set-playing': c.object {required: ['playing']},
|
||||
playing: {type: 'boolean'}
|
||||
|
||||
'level:docs-shown': {}
|
||||
'level:team-set': c.object {required: ['team']},
|
||||
team: c.shortString()
|
||||
|
||||
'level:docs-hidden': {}
|
||||
'level:docs-shown': c.object {}
|
||||
|
||||
'level:victory-hidden':
|
||||
{} # TODO schema
|
||||
'level:docs-hidden': c.object {}
|
||||
|
||||
'level:flag-color-selected':
|
||||
type: 'object'
|
||||
additionalProperties: false
|
||||
properties:
|
||||
color:
|
||||
oneOf: [
|
||||
{type: 'null'}
|
||||
{type: 'string', enum: ['green', 'black', 'violet'], description: 'The flag color to place next, or omitted/null if deselected.'}
|
||||
]
|
||||
pos:
|
||||
'level:flag-color-selected': c.object {},
|
||||
color:
|
||||
oneOf: [
|
||||
{type: 'null'}
|
||||
{type: 'string', enum: ['green', 'black', 'violet'], description: 'The flag color to place next, or omitted/null if deselected.'}
|
||||
]
|
||||
pos: c.object {required: ['x', 'y']},
|
||||
x: {type: 'number'}
|
||||
y: {type: 'number'}
|
||||
|
||||
'level:flag-updated': c.object {required: ['player', 'color', 'time', 'active']},
|
||||
player: {type: 'string'}
|
||||
team: {type: 'string'}
|
||||
color: {type: 'string', enum: ['green', 'black', 'violet']}
|
||||
time: {type: 'number', minimum: 0}
|
||||
active: {type: 'boolean'}
|
||||
pos: c.object {required: ['x', 'y']},
|
||||
x: {type: 'number'}
|
||||
y: {type: 'number'}
|
||||
|
||||
'level:next-game-pressed': c.object {}
|
||||
|
||||
'level:loading-view-unveiled': c.object {required: ['view']},
|
||||
view: {type: 'object'}
|
||||
|
||||
'playback:manually-scrubbed': c.object {required: ['ratio']},
|
||||
ratio: {type: 'number', minimum: 0, maximum: 1}
|
||||
|
||||
'playback:stop-real-time-playback': c.object {}
|
||||
|
||||
'playback:real-time-playback-started': c.object {}
|
||||
|
||||
'playback:real-time-playback-ended': c.object {}
|
||||
|
||||
'level:play-next-level': c.object {}
|
||||
|
||||
'level:toggle-playing': c.object {}
|
||||
|
||||
'level:toggle-grid': c.object {}
|
||||
|
||||
'level:toggle-debug': c.object {}
|
||||
|
||||
'level:toggle-pathfinding': c.object {}
|
||||
|
||||
'level:scrub-forward': c.object {}
|
||||
|
||||
'level:scrub-back': c.object {}
|
||||
|
||||
'level:show-victory': c.object {required: ['showModal']},
|
||||
showModal: {type: 'boolean'}
|
||||
|
||||
'level:highlight-dom': c.object {required: ['selector']},
|
||||
selector: {type: 'string'}
|
||||
delay: {type: 'number'}
|
||||
sides: {type: 'array', items: {'enum': ['left', 'right', 'top', 'bottom']}}
|
||||
offset: {type: 'object'}
|
||||
rotation: {type: 'number'}
|
||||
|
||||
'level:end-highlight-dom': c.object {}
|
||||
|
||||
'level:focus-dom': c.object {},
|
||||
selector: {type: 'string'}
|
||||
|
||||
'level:lock-select': c.object {},
|
||||
lock: {type: ['boolean', 'array']}
|
||||
|
||||
'level:suppress-selection-sounds': c.object {required: ['suppress']},
|
||||
suppress: {type: 'boolean'}
|
||||
|
||||
'goal-manager:new-goal-states': c.object {required: ['goalStates', 'goals', 'overallStatus', 'timedOut']},
|
||||
goalStates:
|
||||
type: 'object'
|
||||
additionalProperties:
|
||||
type: 'object'
|
||||
additionalProperties: false
|
||||
required: ['x', 'y']
|
||||
required: ['status']
|
||||
properties:
|
||||
x: {type: 'number'}
|
||||
y: {type: 'number'}
|
||||
status:
|
||||
oneOf: [
|
||||
{type: 'null'}
|
||||
{type: 'string', enum: ['success', 'failure', 'incomplete']}
|
||||
]
|
||||
keyFrame:
|
||||
oneOf: [
|
||||
{type: 'integer', minimum: 0}
|
||||
{type: 'string', enum: ['end']}
|
||||
]
|
||||
team: {type: ['null', 'string']}
|
||||
goals: c.array {},
|
||||
{type: 'object'}
|
||||
overallStatus:
|
||||
oneOf: [
|
||||
{type: 'null'}
|
||||
{type: 'string', enum: ['success', 'failure', 'incomplete']}
|
||||
]
|
||||
timedOut: {type: 'boolean'}
|
||||
|
||||
'level:flag-updated':
|
||||
type: 'object'
|
||||
additionalProperties: false
|
||||
required: ['player', 'color', 'time', 'active']
|
||||
properties:
|
||||
player:
|
||||
type: 'string'
|
||||
team:
|
||||
type: 'string'
|
||||
color:
|
||||
type: 'string'
|
||||
enum: ['green', 'black', 'violet']
|
||||
time:
|
||||
type: 'number'
|
||||
minimum: 0
|
||||
active:
|
||||
type: 'boolean'
|
||||
pos:
|
||||
type: 'object'
|
||||
additionalProperties: false
|
||||
required: ['x', 'y']
|
||||
properties:
|
||||
x: {type: 'number'}
|
||||
y: {type: 'number'}
|
||||
|
||||
'next-game-pressed':
|
||||
{} # TODO schema
|
||||
|
||||
'end-current-script':
|
||||
{} # TODO schema
|
||||
|
||||
'script:reset':
|
||||
{} # TODO schema
|
||||
|
||||
'script:ended':
|
||||
{} # TODO schema
|
||||
|
||||
'end-all-scripts': {}
|
||||
|
||||
'script:state-changed':
|
||||
{} # TODO schema
|
||||
|
||||
'script-manager:tick':
|
||||
type: 'object'
|
||||
additionalProperties: false
|
||||
properties:
|
||||
scriptRunning: {type: 'string'}
|
||||
noteGroupRunning: {type: 'string'}
|
||||
timeSinceLastScriptEnded: {type: 'number'}
|
||||
scriptStates:
|
||||
type: 'object'
|
||||
additionalProperties:
|
||||
title: 'Script State'
|
||||
type: 'object'
|
||||
additionalProperties: false
|
||||
properties:
|
||||
timeSinceLastEnded:
|
||||
type: 'number'
|
||||
description: 'seconds since this script ended last'
|
||||
timeSinceLastTriggered:
|
||||
type: 'number'
|
||||
description: 'seconds since this script was triggered last'
|
||||
|
||||
'play-sound':
|
||||
{} # TODO schema
|
||||
|
||||
# TODO refactor name
|
||||
'onLoadingViewUnveiled':
|
||||
{} # TODO schema
|
||||
|
||||
'playback:manually-scrubbed':
|
||||
{} # TODO schema
|
||||
|
||||
'playback:stop-real-time-playback':
|
||||
type: 'object'
|
||||
additionalProperties: false
|
||||
|
||||
'playback:real-time-playback-started':
|
||||
type: 'object'
|
||||
additionalProperties: false
|
||||
|
||||
'playback:real-time-playback-ended':
|
||||
type: 'object'
|
||||
additionalProperties: false
|
||||
|
||||
'change:editor-config':
|
||||
{} # TODO schema
|
||||
|
||||
'restart-level':
|
||||
{} # TODO schema
|
||||
|
||||
'play-next-level':
|
||||
{} # TODO schema
|
||||
|
||||
'level-select-sprite':
|
||||
{} # TODO schema
|
||||
|
||||
'level-toggle-grid':
|
||||
{} # TODO schema
|
||||
|
||||
'level-toggle-debug':
|
||||
{} # TODO schema
|
||||
|
||||
'level-toggle-pathfinding':
|
||||
{} # TODO schema
|
||||
|
||||
'level-scrub-forward':
|
||||
{} # TODO schema
|
||||
|
||||
'level-scrub-back':
|
||||
{} # TODO schema
|
||||
|
||||
'level-show-victory':
|
||||
type: 'object'
|
||||
additionalProperties: false
|
||||
properties:
|
||||
showModal: {type: 'boolean'}
|
||||
|
||||
'level-highlight-dom':
|
||||
type: 'object'
|
||||
additionalProperties: false
|
||||
properties:
|
||||
selector: {type: 'string'}
|
||||
delay: {type: 'number'}
|
||||
sides: {type: 'array', items: {'enum': ['left', 'right', 'top', 'bottom']}}
|
||||
offset: {type: 'object'}
|
||||
rotation: {type: 'number'}
|
||||
|
||||
'goal-manager:new-goal-states':
|
||||
{} # TODO schema
|
||||
'level:edit-wizard-settings': c.object {}
|
||||
|
|
27
app/schemas/subscriptions/scripts.coffee
Normal file
27
app/schemas/subscriptions/scripts.coffee
Normal file
|
@ -0,0 +1,27 @@
|
|||
c = require 'schemas/schemas'
|
||||
|
||||
module.exports =
|
||||
'script:end-current-script': c.object {}
|
||||
|
||||
'script:reset': c.object {}
|
||||
|
||||
'script:ended': c.object {required: ['scriptID']},
|
||||
scriptID: {type: 'string'}
|
||||
|
||||
'script:state-changed': c.object {required: ['currentScript', 'currentScriptOffset']},
|
||||
currentScript: {type: ['string', 'null']}
|
||||
currentScriptOffset: {type: 'integer', minimum: 0}
|
||||
|
||||
'script:tick': c.object {required: ['scriptRunning', 'noteGroupRunning', 'scriptStates', 'timeSinceLastScriptEnded']},
|
||||
scriptRunning: {type: 'string'}
|
||||
noteGroupRunning: {type: 'string'}
|
||||
timeSinceLastScriptEnded: {type: 'number'}
|
||||
scriptStates:
|
||||
type: 'object'
|
||||
additionalProperties: c.object {title: 'Script State'},
|
||||
timeSinceLastEnded: {type: 'number', minimum: 0, description: 'seconds since this script ended last'}
|
||||
timeSinceLastTriggered: {type: 'number', minimum: 0, description: 'seconds since this script was triggered last'}
|
||||
|
||||
'script:note-group-started': c.object {}
|
||||
|
||||
'script:note-group-ended': c.object {}
|
|
@ -1,108 +1,180 @@
|
|||
c = require 'schemas/schemas'
|
||||
|
||||
spriteMouseEventSchema = c.object {required: ['sprite', 'thang', 'originalEvent', 'canvas']},
|
||||
sprite: {type: 'object'}
|
||||
thang: {type: 'object'}
|
||||
originalEvent: {type: 'object'}
|
||||
canvas: {type: 'object'}
|
||||
|
||||
module.exports = # /app/lib/surface
|
||||
'camera-dragged':
|
||||
{} # TODO schema
|
||||
'camera:dragged': c.object {}
|
||||
|
||||
'camera-zoom-in':
|
||||
{} # TODO schema
|
||||
'camera:zoom-in': c.object {}
|
||||
|
||||
'camera-zoom-out':
|
||||
{} # TODO schema
|
||||
'camera:zoom-out': c.object {}
|
||||
|
||||
'camera-zoom-to':
|
||||
{} # TODO schema
|
||||
'camera:zoom-to': c.object {required: ['pos']},
|
||||
pos: c.object {required: ['x', 'y']},
|
||||
x: {type: 'number'}
|
||||
y: {type: 'number'}
|
||||
duration: {type: 'number', minimum: 0}
|
||||
|
||||
'camera:zoom-updated':
|
||||
{} # TODO schema
|
||||
'camera:zoom-updated': c.object {required: ['camera', 'zoom', 'surfaceViewport']},
|
||||
camera: {type: 'object'}
|
||||
zoom: {type: 'number', minimum: 0, exclusiveMinimum: true}
|
||||
surfaceViewport: {type: 'object'}
|
||||
|
||||
'sprite:speech-updated':
|
||||
{} # TODO schema
|
||||
'camera:set-camera': c.object {},
|
||||
pos: c.object {required: ['x', 'y']},
|
||||
x: {type: 'number'}
|
||||
y: {type: 'number'}
|
||||
thangID: {type: 'string'}
|
||||
zoom: {type: 'number'}
|
||||
duration: {type: 'number', minimum: 0}
|
||||
bounds: c.array {maxItems: 2, minItems: 2},
|
||||
c.object {required: ['x', 'y']},
|
||||
x: {type: 'number'}
|
||||
y: {type: 'number'}
|
||||
|
||||
'dialogue-sound-completed':
|
||||
{} # TODO schema
|
||||
'sprite:speech-updated': c.object {required: ['sprite', 'thang']},
|
||||
sprite: {type: 'object'}
|
||||
thang: {type: 'object'}
|
||||
blurb: {type: 'string'}
|
||||
message: {type: 'string'}
|
||||
mood: {type: 'string'}
|
||||
responses: {type: 'array'}
|
||||
spriteID: {type: 'string'}
|
||||
sound: {type: ['null', 'undefined', 'object']}
|
||||
|
||||
'surface:gold-changed':
|
||||
{} # TODO schema
|
||||
'level:sprite-dialogue': c.object {required: ['spriteID', 'message']},
|
||||
blurb: {type: 'string'}
|
||||
message: {type: 'string'}
|
||||
mood: {type: 'string'}
|
||||
responses: {type: 'array'}
|
||||
spriteID: {type: 'string'}
|
||||
sound: {type: ['null', 'undefined', 'object']}
|
||||
|
||||
'surface:coordinate-selected':
|
||||
{} # TODO schema
|
||||
'sprite:dialogue-sound-completed': c.object {}
|
||||
|
||||
'surface:coordinates-shown':
|
||||
{} # TODO schema
|
||||
'level:sprite-clear-dialogue': c.object {}
|
||||
|
||||
'level-sprite-clear-dialogue':
|
||||
{} # TODO schema
|
||||
'surface:gold-changed': c.object {required: ['team', 'gold']},
|
||||
team: {type: 'string'}
|
||||
gold: {type: 'number'}
|
||||
goldEarned: {type: 'number'}
|
||||
|
||||
'sprite:loaded':
|
||||
{} # TODO schema
|
||||
'surface:coordinate-selected': c.object {required: ['x', 'y']},
|
||||
x: {type: 'number'}
|
||||
y: {type: 'number'}
|
||||
|
||||
'choose-point':
|
||||
{} # TODO schema
|
||||
'surface:coordinates-shown': c.object {}
|
||||
|
||||
'choose-region':
|
||||
{} # TODO schema
|
||||
'sprite:loaded': c.object {},
|
||||
sprite: {type: 'object'}
|
||||
|
||||
'surface:new-thang-added':
|
||||
{} # TODO schema
|
||||
'surface:choose-point': c.object {required: ['point']},
|
||||
point: c.object {required: ['x', 'y']},
|
||||
x: {type: 'number'}
|
||||
y: {type: 'number'}
|
||||
|
||||
'surface:sprite-selected':
|
||||
{} # TODO schema
|
||||
'surface:choose-region': c.object {required: ['points']},
|
||||
points: c.array {minItems: 2, maxItems: 2},
|
||||
c.object {required: ['x', 'y']},
|
||||
x: {type: 'number'}
|
||||
y: {type: 'number'}
|
||||
|
||||
'thang-began-talking':
|
||||
{} # TODO schema
|
||||
'surface:new-thang-added': c.object {required: ['thang', 'sprite']},
|
||||
thang: {type: 'object'}
|
||||
sprite: {type: 'object'}
|
||||
|
||||
'thang-finished-talking':
|
||||
{} # TODO schema
|
||||
'surface:sprite-selected': c.object {required: ['thang', 'sprite']},
|
||||
thang: {type: ['object', 'null', 'undefined']}
|
||||
sprite: {type: ['object', 'null', 'undefined']}
|
||||
spellName: {type: ['string', 'null', 'undefined']}
|
||||
originalEvent: {type: ['object', 'null', 'undefined']}
|
||||
worldPos: {type: ['object', 'null', 'undefined']}
|
||||
|
||||
'surface:world-set-up':
|
||||
{} # TODO schema
|
||||
'sprite:thang-began-talking': c.object {},
|
||||
thang: {type: 'object'}
|
||||
|
||||
'surface:frame-changed':
|
||||
{} # TODO schema
|
||||
'sprite:thang-finished-talking': c.object {},
|
||||
thang: {type: 'object'}
|
||||
|
||||
'surface:playback-ended':
|
||||
{} # TODO schema
|
||||
'sprite:highlight-sprites': c.object {},
|
||||
thangIDs: c.array {}, {type: 'string'}
|
||||
delay: {type: 'number'}
|
||||
|
||||
'surface:playback-restarted':
|
||||
{} # TODO schema
|
||||
'sprite:move': c.object {required: ['spriteID', 'pos']},
|
||||
spriteID: {type: 'string'}
|
||||
pos: c.object {required: ['x', 'y']},
|
||||
x: {type: 'number'}
|
||||
y: {type: 'number'}
|
||||
duration: {type: 'number', minimum: 0}
|
||||
|
||||
'level-set-playing':
|
||||
{} # TODO schema
|
||||
'sprite:mouse-down': spriteMouseEventSchema
|
||||
'sprite:clicked': spriteMouseEventSchema
|
||||
'sprite:double-clicked': spriteMouseEventSchema
|
||||
'sprite:dragged': spriteMouseEventSchema
|
||||
'sprite:mouse-up': spriteMouseEventSchema
|
||||
|
||||
'registrar-echo-states':
|
||||
{} # TODO schema
|
||||
'surface:world-set-up': c.object {},
|
||||
world: {type: 'object'}
|
||||
|
||||
'surface:mouse-moved':
|
||||
{} # TODO schema
|
||||
'surface:frame-changed': c.object {required: ['frame', 'world', 'progress']},
|
||||
frame: {type: 'number', minimum: 0}
|
||||
world: {type: 'object'}
|
||||
progress: {type: 'number', minimum: 0, maximum: 1}
|
||||
selectedThang: {type: ['object', 'null', 'undefined']}
|
||||
|
||||
'surface:stage-mouse-down':
|
||||
{} # TODO schema
|
||||
'surface:playback-ended': c.object {}
|
||||
|
||||
'surface:mouse-scrolled':
|
||||
{} # TODO schema
|
||||
'surface:playback-restarted': c.object {}
|
||||
|
||||
'surface:ticked':
|
||||
{} # TODO schema
|
||||
'surface:mouse-moved': c.object {required: ['x', 'y']},
|
||||
x: {type: 'number'}
|
||||
y: {type: 'number'}
|
||||
|
||||
'surface:mouse-over':
|
||||
{} # TODO schema
|
||||
'surface:stage-mouse-down': c.object {required: ['onBackground', 'x', 'y', 'originalEvent']},
|
||||
onBackground: {type: 'boolean'}
|
||||
x: {type: 'number'}
|
||||
y: {type: 'number'}
|
||||
originalEvent: {type: 'object'}
|
||||
worldPos: {type: ['object', 'null', 'undefined']}
|
||||
|
||||
'surface:mouse-out':
|
||||
{} # TODO schema
|
||||
'surface:stage-mouse-up': c.object {required: ['onBackground', 'x', 'y', 'originalEvent']},
|
||||
onBackground: {type: 'boolean'}
|
||||
x: {type: 'number'}
|
||||
y: {type: 'number'}
|
||||
originalEvent: {type: 'object'}
|
||||
|
||||
'self-wizard:target-changed':
|
||||
{} # TODO schema
|
||||
'surface:mouse-scrolled': c.object {required: ['deltaX', 'deltaY', 'screenPos', 'canvas']},
|
||||
deltaX: {type: 'number'}
|
||||
deltaY: {type: 'number'}
|
||||
screenPos: c.object {required: ['x', 'y']},
|
||||
x: {type: 'number'}
|
||||
y: {type: 'number'}
|
||||
canvas: {type: 'object'}
|
||||
|
||||
'echo-all-wizard-sprites':
|
||||
{} # TODO schema
|
||||
'surface:ticked': c.object {required: ['dt']},
|
||||
dt: {type: 'number'}
|
||||
|
||||
'surface:flag-appeared':
|
||||
type: 'object'
|
||||
additionalProperties: false
|
||||
required: ['sprite']
|
||||
properties:
|
||||
sprite:
|
||||
type: 'object'
|
||||
'surface:mouse-over': c.object {}
|
||||
|
||||
'surface:remove-selected-flag':
|
||||
type: 'object'
|
||||
additionalProperties: false
|
||||
'surface:mouse-out': c.object {}
|
||||
|
||||
'sprite:echo-all-wizard-sprites': c.object {required: ['payload']},
|
||||
payload: c.array {}, {type: 'object'}
|
||||
|
||||
'self-wizard:created': c.object {required: ['sprite']},
|
||||
sprite: {type: 'object'}
|
||||
|
||||
'self-wizard:target-changed': c.object {required: ['sprite']},
|
||||
sprite: {type: 'object'}
|
||||
|
||||
'surface:flag-appeared': c.object {required: ['sprite']},
|
||||
sprite: {type: 'object'}
|
||||
|
||||
'surface:remove-selected-flag': c.object {}
|
||||
|
||||
'surface:remove-flag': c.object {required: 'color'},
|
||||
color: {type: 'string'}
|
||||
|
|
|
@ -1,277 +1,109 @@
|
|||
c = require 'schemas/schemas'
|
||||
|
||||
module.exports =
|
||||
"tome:cast-spell":
|
||||
title: "Cast Spell"
|
||||
$schema: "http://json-schema.org/draft-04/schema#"
|
||||
description: "Published when a spell is cast"
|
||||
type: ["object", "undefined"]
|
||||
properties:
|
||||
spell:
|
||||
type: "object"
|
||||
thang:
|
||||
type: "object"
|
||||
preload:
|
||||
type: "boolean"
|
||||
realTime:
|
||||
type: "boolean"
|
||||
required: []
|
||||
additionalProperties: false
|
||||
'tome:cast-spell': c.object {title: 'Cast Spell', description: 'Published when a spell is cast', required: ['spell', 'thang', 'preload', 'realTime']},
|
||||
spell: {type: 'object'}
|
||||
thang: {type: 'object'}
|
||||
preload: {type: 'boolean'}
|
||||
realTime: {type: 'boolean'}
|
||||
|
||||
"tome:cast-spells":
|
||||
title: "Cast Spells"
|
||||
$schema: "http://json-schema.org/draft-04/schema#"
|
||||
description: "Published when spells are cast"
|
||||
type: ["object", "undefined"]
|
||||
properties:
|
||||
spells:
|
||||
type: "object"
|
||||
preload:
|
||||
type: "boolean"
|
||||
realTime:
|
||||
type: "boolean"
|
||||
required: []
|
||||
additionalProperties: false
|
||||
'tome:cast-spells': c.object {title: 'Cast Spells', description: 'Published when spells are cast', required: ['spells', 'preload', 'realTime']},
|
||||
spells: [type: 'object']
|
||||
preload: [type: 'boolean']
|
||||
realTime: [type: 'boolean']
|
||||
|
||||
"tome:manual-cast":
|
||||
title: "Manually Cast Spells"
|
||||
$schema: "http://json-schema.org/draft-04/schema#"
|
||||
description: "Published when you wish to manually recast all spells"
|
||||
type: "object"
|
||||
properties:
|
||||
realTime:
|
||||
type: "boolean"
|
||||
required: []
|
||||
additionalProperties: false
|
||||
'tome:manual-cast': c.object {title: 'Manually Cast Spells', description: 'Published when you wish to manually recast all spells', required: []},
|
||||
realTime: {type: 'boolean'}
|
||||
|
||||
"tome:spell-created":
|
||||
title: "Spell Created"
|
||||
$schema: "http://json-schema.org/draft-04/schema#"
|
||||
description: "Published after a new spell has been created"
|
||||
type: "object"
|
||||
properties:
|
||||
"spell": "object"
|
||||
required: ["spell"]
|
||||
additionalProperties: false
|
||||
'tome:spell-created': c.object {title: 'Spell Created', description: 'Published after a new spell has been created', required: ['spell']},
|
||||
spell: {type: 'object'}
|
||||
|
||||
"tome:spell-debug-property-hovered":
|
||||
title: "Spell Debug Property Hovered"
|
||||
$schema: "http://json-schema.org/draft-04/schema#"
|
||||
description: "Published when you hover over a spell property"
|
||||
type: "object"
|
||||
properties:
|
||||
"property": "string"
|
||||
"owner": "string"
|
||||
required: []
|
||||
additionalProperties: false
|
||||
'tome:spell-has-changed-significantly-calculation': c.object {title: 'Has Changed Significantly Calculation', description: 'Let anyone know that the spell has changed significantly.', required: ['hasChangedSignificantly']},
|
||||
hasChangedSignificantly: {type: 'boolean'}
|
||||
|
||||
"tome:toggle-spell-list":
|
||||
title: "Toggle Spell List"
|
||||
$schema: "http://json-schema.org/draft-04/schema#"
|
||||
description: "Published when you toggle the dropdown for a thang's spells"
|
||||
type: "undefined"
|
||||
additionalProperties: false
|
||||
'tome:spell-debug-property-hovered': c.object {title: 'Spell Debug Property Hovered', description: 'Published when you hover over a spell property', required: []},
|
||||
property: {type: 'string'}
|
||||
owner: {type: 'string'}
|
||||
|
||||
"tome:reload-code":
|
||||
title: "Reload Code"
|
||||
$schema: "http://json-schema.org/draft-04/schema#"
|
||||
description: "Published when you reset a spell to its original source"
|
||||
type: "object"
|
||||
properties:
|
||||
"spell": "object"
|
||||
required: ["spell"]
|
||||
additionalProperties: false
|
||||
'tome:spell-debug-value-request': c.object {title: 'Spell Debug Value Request', description: 'Published when the SpellDebugView wants to retrieve a debug value.', required: ['thangID', 'spellID', 'variableChain', 'frame']},
|
||||
thangID: {type: 'string'}
|
||||
spellID: {type: 'string'}
|
||||
variableChain: c.array {}, {type: 'string'}
|
||||
frame: {type: 'integer', minimum: 0}
|
||||
|
||||
"tome:palette-hovered":
|
||||
title: "Palette Hovered"
|
||||
$schema: "http://json-schema.org/draft-04/schema#"
|
||||
description: "Published when you hover over a Thang in the spell palette"
|
||||
type: "object"
|
||||
properties:
|
||||
"thang": "object"
|
||||
"prop": "string"
|
||||
"entry": "object"
|
||||
required: ["thang", "prop", "entry"]
|
||||
additionalProperties: false
|
||||
'tome:toggle-spell-list': c.object {title: 'Toggle Spell List', description: 'Published when you toggle the dropdown for a thang\'s spells'}
|
||||
|
||||
"tome:palette-pin-toggled":
|
||||
title: "Palette Pin Toggled"
|
||||
$schema: "http://json-schema.org/draft-04/schema#"
|
||||
description: "Published when you pin or unpin the spell palette"
|
||||
type: "object"
|
||||
properties:
|
||||
"entry": "object"
|
||||
"pinned": "boolean"
|
||||
required: ["entry", "pinned"]
|
||||
additionalProperties: false
|
||||
'tome:reload-code': c.object {title: 'Reload Code', description: 'Published when you reset a spell to its original source', required: ['spell']},
|
||||
spell: {type: 'object'}
|
||||
|
||||
"tome:palette-clicked":
|
||||
title: "Palette Clicked"
|
||||
$schema: "http://json-schema.org/draft-04/schema#"
|
||||
description: "Published when you click on the spell palette"
|
||||
type: "object"
|
||||
properties:
|
||||
"thang": "object"
|
||||
"prop": "string"
|
||||
"entry": "object"
|
||||
required: ["thang", "prop", "entry"]
|
||||
additionalProperties: false
|
||||
'tome:palette-hovered': c.object {title: 'Palette Hovered', description: 'Published when you hover over a Thang in the spell palette', required: ['thang', 'prop', 'entry']},
|
||||
thang: {type: 'object'}
|
||||
prop: {type: 'string'}
|
||||
entry: {type: 'object'}
|
||||
|
||||
"tome:spell-statement-index-updated":
|
||||
title: "Spell Statement Index Updated"
|
||||
$schema: "http://json-schema.org/draft-04/schema#"
|
||||
description: "Published when the spell index is updated"
|
||||
type: "object"
|
||||
properties:
|
||||
"statementIndex": "object"
|
||||
"ace": "object"
|
||||
required: ["statementIndex", "ace"]
|
||||
additionalProperties: false
|
||||
'tome:palette-pin-toggled': c.object {title: 'Palette Pin Toggled', description: 'Published when you pin or unpin the spell palette', required: ['entry', 'pinned']},
|
||||
entry: {type: 'object'}
|
||||
pinned: {type: 'boolean'}
|
||||
|
||||
# TODO proposition: refactor 'tome' into spell events
|
||||
"spell-beautify":
|
||||
title: "Beautify"
|
||||
$schema: "http://json-schema.org/draft-04/schema#"
|
||||
description: "Published when you click the \"beautify\" button"
|
||||
type: "object"
|
||||
properties:
|
||||
"spell": "object"
|
||||
required: []
|
||||
additionalProperties: false
|
||||
'tome:palette-clicked': c.object {title: 'Palette Clicked', description: 'Published when you click on the spell palette', required: ['thang', 'prop', 'entry']},
|
||||
thang: {type: 'object'}
|
||||
prop: {type: 'string'}
|
||||
entry: {type: 'object'}
|
||||
|
||||
"spell-step-forward":
|
||||
title: "Step Forward"
|
||||
$schema: "http://json-schema.org/draft-04/schema#"
|
||||
description: "Published when you step forward in time"
|
||||
type: "undefined"
|
||||
additionalProperties: false
|
||||
'tome:spell-statement-index-updated': c.object {title: 'Spell Statement Index Updated', description: 'Published when the spell index is updated', required: ['statementIndex', 'ace']},
|
||||
statementIndex: {type: 'object'}
|
||||
ace: {type: 'object'}
|
||||
|
||||
"spell-step-backward":
|
||||
title: "Step Backward"
|
||||
$schema: "http://json-schema.org/draft-04/schema#"
|
||||
description: "Published when you step backward in time"
|
||||
type: "undefined"
|
||||
additionalProperties: false
|
||||
'tome:spell-beautify': c.object {title: 'Beautify', description: 'Published when you click the \'beautify\' button', required: []},
|
||||
spell: {type: 'object'}
|
||||
|
||||
"tome:spell-loaded":
|
||||
title: "Spell Loaded"
|
||||
$schema: "http://json-schema.org/draft-04/schema#"
|
||||
description: "Published when a spell is loaded"
|
||||
type: "object"
|
||||
properties:
|
||||
"spell": "object"
|
||||
required: ["spell"]
|
||||
additionalProperties: false
|
||||
'tome:spell-step-forward': c.object {title: 'Step Forward', description: 'Published when you step forward in time'}
|
||||
|
||||
"tome:spell-changed":
|
||||
title: "Spell Changed"
|
||||
$schema: "http://json-schema.org/draft-04/schema#"
|
||||
description: "Published when a spell is changed"
|
||||
type: "object"
|
||||
properties:
|
||||
"spell": "object"
|
||||
required: ["spell"]
|
||||
additionalProperties: false
|
||||
'tome:spell-step-backward': c.object {title: 'Step Backward', description: 'Published when you step backward in time'}
|
||||
|
||||
"tome:editing-began":
|
||||
title: "Editing Began"
|
||||
$schema: "http://json-schema.org/draft-04/schema#"
|
||||
description: "Published when you have begun changing code"
|
||||
type: "undefined"
|
||||
additionalProperties: false
|
||||
'tome:spell-loaded': c.object {title: 'Spell Loaded', description: 'Published when a spell is loaded', required: ['spell']},
|
||||
spell: {type: 'object'}
|
||||
|
||||
"tome:editing-ended":
|
||||
title: "Editing Ended"
|
||||
$schema: "http://json-schema.org/draft-04/schema#"
|
||||
description: "Published when you have stopped changing code"
|
||||
type: "undefined"
|
||||
additionalProperties: false
|
||||
'tome:spell-changed': c.object {title: 'Spell Changed', description: 'Published when a spell is changed', required: ['spell']},
|
||||
spell: {type: 'object'}
|
||||
|
||||
"tome:problems-updated":
|
||||
title: "Problems Updated"
|
||||
$schema: "http://json-schema.org/draft-04/schema#"
|
||||
description: "Published when problems have been updated"
|
||||
type: "object"
|
||||
properties:
|
||||
"spell": "object"
|
||||
"problems": "array"
|
||||
"isCast": "boolean"
|
||||
required: ["spell", "problems", "isCast"]
|
||||
additionalProperties: false
|
||||
'tome:editing-began': c.object {title: 'Editing Began', description: 'Published when you have begun changing code'}
|
||||
|
||||
"tome:thang-list-entry-popover-shown":
|
||||
title: "Thang List Entry Popover Shown"
|
||||
$schema: "http://json-schema.org/draft-04/schema#"
|
||||
description: "Published when we show the popover for a thang in the master list"
|
||||
type: "object"
|
||||
properties:
|
||||
"entry": "object"
|
||||
required: ["entry"]
|
||||
additionalProperties: false
|
||||
'tome:editing-ended': c.object {title: 'Editing Ended', description: 'Published when you have stopped changing code'}
|
||||
|
||||
"tome:spell-shown":
|
||||
title: "Spell Shown"
|
||||
$schema: "http://json-schema.org/draft-04/schema#"
|
||||
description: "Published when we show a spell"
|
||||
type: "object"
|
||||
properties:
|
||||
"thang": "object"
|
||||
"spell": "object"
|
||||
required: ["thang", "spell"]
|
||||
additionalProperties: false
|
||||
'tome:problems-updated': c.object {title: 'Problems Updated', description: 'Published when problems have been updated', required: ['spell', 'problems', 'isCast']},
|
||||
spell: {type: 'object'}
|
||||
problems: {type: 'array'}
|
||||
isCast: {type: 'boolean'}
|
||||
|
||||
'tome:change-language':
|
||||
title: 'Tome Change Language'
|
||||
$schema: 'http://json-schema.org/draft-04/schema#'
|
||||
description: 'Published when the Tome should update its programming language.'
|
||||
type: 'object'
|
||||
additionalProperties: false
|
||||
properties:
|
||||
language:
|
||||
type: 'string'
|
||||
required: ['language']
|
||||
'tome:thang-list-entry-popover-shown': c.object {title: 'Thang List Entry Popover Shown', description: 'Published when we show the popover for a thang in the master list', required: ['entry']},
|
||||
entry: {type: 'object'}
|
||||
|
||||
'tome:spell-changed-language':
|
||||
title: 'Spell Changed Language'
|
||||
$schema: 'http://json-schema.org/draft-04/schema#'
|
||||
description: 'Published when an individual spell has updated its code language.'
|
||||
type: 'object'
|
||||
additionalProperties: false
|
||||
properties:
|
||||
spell:
|
||||
type: 'object'
|
||||
language:
|
||||
type: 'string'
|
||||
required: ['spell']
|
||||
'tome:spell-shown': c.object {title: 'Spell Shown', description: 'Published when we show a spell', required: ['thang', 'spell']},
|
||||
thang: {type: 'object'}
|
||||
spell: {type: 'object'}
|
||||
|
||||
"tome:comment-my-code":
|
||||
title: "Comment My Code"
|
||||
$schema: "http://json-schema.org/draft-04/schema#"
|
||||
description: "Published when we comment out a chunk of your code"
|
||||
type: "undefined"
|
||||
additionalProperties: false
|
||||
'tome:change-language': c.object {title: 'Tome Change Language', description: 'Published when the Tome should update its programming language', required: ['language']},
|
||||
language: {type: 'string'}
|
||||
|
||||
"tome:change-config":
|
||||
title: "Change Config"
|
||||
$schema: "http://json-schema.org/draft-04/schema#"
|
||||
description: "Published when you change your tome settings"
|
||||
type: "undefined"
|
||||
additionalProperties: false
|
||||
'tome:spell-changed-language': c.object {title: 'Spell Changed Language', description: 'Published when an individual spell has updated its code language', required: ['spell']},
|
||||
spell: {type: 'object'}
|
||||
language: {type: 'string'}
|
||||
|
||||
"tome:update-snippets":
|
||||
title: "Update Snippets"
|
||||
$schema: "http://json-schema.org/draft-04/schema#"
|
||||
description: "Published when we need to add Zatanna Snippets"
|
||||
type: "object"
|
||||
properties:
|
||||
"propGroups": "object"
|
||||
"allDocs": "object"
|
||||
"language": "string"
|
||||
required: ["propGroups", "allDocs"]
|
||||
additionalProperties: false
|
||||
'tome:comment-my-code': c.object {title: 'Comment My Code', description: 'Published when we comment out a chunk of your code'}
|
||||
|
||||
# TODO proposition: add tome to name
|
||||
"focus-editor":
|
||||
title: "Focus Editor"
|
||||
$schema: "http://json-schema.org/draft-04/schema#"
|
||||
description: "Published whenever we want to give focus back to the editor"
|
||||
type: "undefined"
|
||||
additionalProperties: false
|
||||
'tome:change-config': c.object {title: 'Change Config', description: 'Published when you change your tome settings'}
|
||||
|
||||
'tome:update-snippets': c.object {title: 'Update Snippets', description: 'Published when we need to add Zatanna snippets', required: ['propGroups', 'allDocs']},
|
||||
propGroups: {type: 'object'}
|
||||
allDocs: {type: 'object'}
|
||||
language: {type: 'string'}
|
||||
|
||||
'tome:insert-snippet': c.object {title: 'Insert Snippet', description: 'Published when we need to insert a Zatanna snippet', required: ['doc', 'language', 'formatted']},
|
||||
doc: {type: 'object'}
|
||||
language: {type: 'string'}
|
||||
formatted: {type: 'object'}
|
||||
|
||||
'tome:focus-editor': c.object {title: 'Focus Editor', description: 'Published whenever we want to give focus back to the editor'}
|
||||
|
||||
'tome:fullscreen-view': c.object {title: 'Fullscreen View', description: 'Published when we want to make the Tome take up most of the screen'}
|
||||
|
|
|
@ -1,9 +0,0 @@
|
|||
module.exports =
|
||||
'me:synced':
|
||||
{} # TODO schema
|
||||
|
||||
'user-fetched':
|
||||
{} # TODO schema
|
||||
|
||||
'edit-wizard-settings':
|
||||
{} # TODO schema
|
|
@ -1,18 +0,0 @@
|
|||
module.exports =
|
||||
'god:user-code-problem':
|
||||
{} # TODO schema
|
||||
|
||||
'god:infinite-loop':
|
||||
{} # TODO schema
|
||||
|
||||
'god:user-code-problem':
|
||||
{} # TODO schema
|
||||
|
||||
'god:new-world-created':
|
||||
{} # TODO schema
|
||||
|
||||
'god:streaming-world-updated':
|
||||
{} # TODO schema
|
||||
|
||||
'god:world-load-progress-changed':
|
||||
{} # TODO schema
|
|
@ -225,6 +225,14 @@ table.table
|
|||
.ui-slider-handle
|
||||
border: 1px solid black !important
|
||||
|
||||
// Override jQuery UI widget images that we don't use
|
||||
.ui-widget-content, .ui-widget-header, .ui-widget-overlay, .ui-widget-shadow
|
||||
background-image: none
|
||||
|
||||
.ui-widget-content, .ui-state-default, .ui-widget-header
|
||||
.ui-state-default, .ui-state-focus, .ui-state-active, .ui-state-highlight, .ui-state-error
|
||||
background-image: none
|
||||
|
||||
// Fonts
|
||||
|
||||
.header-font
|
||||
|
|
|
@ -15,7 +15,7 @@ module.exports = class ArticleEditView extends RootView
|
|||
'click #save-button': 'openSaveModal'
|
||||
|
||||
subscriptions:
|
||||
'save-new-version': 'saveNewArticle'
|
||||
'editor:save-new-version': 'saveNewArticle'
|
||||
|
||||
constructor: (options, @articleID) ->
|
||||
super options
|
||||
|
@ -98,4 +98,4 @@ module.exports = class ArticleEditView extends RootView
|
|||
showVersionHistory: (e) ->
|
||||
versionHistoryView = new VersionHistoryView article: @article, @articleID
|
||||
@openModalView versionHistoryView
|
||||
Backbone.Mediator.publish 'level:view-switched', e
|
||||
Backbone.Mediator.publish 'editor:view-switched', {}
|
||||
|
|
|
@ -72,7 +72,7 @@ module.exports = class LevelEditView extends RootView
|
|||
super()
|
||||
return unless @supermodel.finished()
|
||||
@$el.find('a[data-toggle="tab"]').on 'shown.bs.tab', (e) =>
|
||||
Backbone.Mediator.publish 'level:view-switched', e
|
||||
Backbone.Mediator.publish 'editor:view-switched', {}
|
||||
@insertSubView new ThangsTabView world: @world, supermodel: @supermodel, level: @level
|
||||
@insertSubView new SettingsTabView supermodel: @supermodel
|
||||
@insertSubView new ScriptsTabView world: @world, supermodel: @supermodel, files: @files
|
||||
|
@ -81,7 +81,7 @@ module.exports = class LevelEditView extends RootView
|
|||
@insertSubView new RelatedAchievementsView supermodel: @supermodel, level: @level
|
||||
@insertSubView new ComponentDocsView # Don't give it the supermodel, it'll pollute it!
|
||||
|
||||
Backbone.Mediator.publish 'level-loaded', level: @level
|
||||
Backbone.Mediator.publish 'editor:level-loaded', level: @level
|
||||
@showReadOnly() if me.get('anonymous')
|
||||
@patchesView = @insertSubView(new PatchesView(@level), @$el.find('.patches-view'))
|
||||
@listenTo @patchesView, 'accepted-patch', -> location.reload()
|
||||
|
@ -96,7 +96,7 @@ module.exports = class LevelEditView extends RootView
|
|||
onPlayLevel: (e) ->
|
||||
team = $(e.target).data('team')
|
||||
sendLevel = =>
|
||||
@childWindow.Backbone.Mediator.publish 'level-reload-from-data', level: @level, supermodel: @supermodel
|
||||
@childWindow.Backbone.Mediator.publish 'level:reload-from-data', level: @level, supermodel: @supermodel
|
||||
if @childWindow and not @childWindow.closed
|
||||
# Reset the LevelView's world, but leave the rest of the state alone
|
||||
sendLevel()
|
||||
|
@ -134,20 +134,20 @@ module.exports = class LevelEditView extends RootView
|
|||
|
||||
startPatchingLevel: (e) ->
|
||||
@openModalView new SaveVersionModal({model: @level})
|
||||
Backbone.Mediator.publish 'level:view-switched', e
|
||||
Backbone.Mediator.publish 'editor:view-switched', {}
|
||||
|
||||
startCommittingLevel: (e) ->
|
||||
@openModalView new SaveLevelModal level: @level, supermodel: @supermodel
|
||||
Backbone.Mediator.publish 'level:view-switched', e
|
||||
Backbone.Mediator.publish 'editor:view-switched', {}
|
||||
|
||||
startForking: (e) ->
|
||||
@openModalView new ForkModal model: @level, editorPath: 'level'
|
||||
Backbone.Mediator.publish 'level:view-switched', e
|
||||
Backbone.Mediator.publish 'editor:view-switched', {}
|
||||
|
||||
showVersionHistory: (e) ->
|
||||
versionHistoryView = new VersionHistoryView level: @level, @levelID
|
||||
@openModalView versionHistoryView
|
||||
Backbone.Mediator.publish 'level:view-switched', e
|
||||
Backbone.Mediator.publish 'editor:view-switched', {}
|
||||
|
||||
toggleWatchLevel: ->
|
||||
button = @$el.find('#level-watch-button')
|
||||
|
|
|
@ -14,9 +14,7 @@ module.exports = class ComponentsTabView extends CocoView
|
|||
className: 'tab-pane'
|
||||
|
||||
subscriptions:
|
||||
'edit-level-component': 'editLevelComponent'
|
||||
'level-component-edited': 'onLevelComponentEdited'
|
||||
'level-component-editing-ended': 'onLevelComponentEditingEnded'
|
||||
'editor:level-component-editing-ended': 'onLevelComponentEditingEnded'
|
||||
|
||||
events:
|
||||
'click #create-new-component-button': 'createNewLevelComponent'
|
||||
|
@ -66,14 +64,11 @@ module.exports = class ComponentsTabView extends CocoView
|
|||
createNewLevelComponent: (e) ->
|
||||
levelComponentNewView = new LevelComponentNewView supermodel: @supermodel
|
||||
@openModalView levelComponentNewView
|
||||
Backbone.Mediator.publish 'level:view-switched', e
|
||||
Backbone.Mediator.publish 'editor:view-switched', {}
|
||||
|
||||
editLevelComponent: (e) ->
|
||||
@levelComponentEditView = @insertSubView new LevelComponentEditView(original: e.original, majorVersion: e.majorVersion, supermodel: @supermodel)
|
||||
|
||||
onLevelComponentEdited: (e) ->
|
||||
Backbone.Mediator.publish 'level-components-changed', {}
|
||||
|
||||
onLevelComponentEditingEnded: (e) ->
|
||||
@removeSubView @levelComponentEditView
|
||||
@levelComponentEditView = null
|
||||
|
@ -90,6 +85,3 @@ class LevelComponentNode extends TreemaObjectNode
|
|||
m.get('original') is @data.original and m.get('version').major is @data.majorVersion
|
||||
name = "#{comp.get('system')}.#{comp.get('name')} v#{comp.get('version').major}"
|
||||
@buildValueForDisplaySimply valEl, "#{name} (#{count})"
|
||||
|
||||
onEnterPressed: ->
|
||||
Backbone.Mediator.publish 'edit-level-component', original: @data.original, majorVersion: @data.majorVersion
|
||||
|
|
|
@ -64,7 +64,6 @@ module.exports = class LevelComponentEditView extends CocoView
|
|||
# Make sure it validates first?
|
||||
for key, value of @componentSettingsTreema.data
|
||||
@levelComponent.set key, value unless key is 'js' # will compile code if needed
|
||||
Backbone.Mediator.publish 'level-component-edited', levelComponent: @levelComponent
|
||||
null
|
||||
|
||||
buildConfigSchemaTreema: ->
|
||||
|
@ -82,7 +81,6 @@ module.exports = class LevelComponentEditView extends CocoView
|
|||
|
||||
onConfigSchemaEdited: =>
|
||||
@levelComponent.set 'configSchema', @configSchemaTreema.data
|
||||
Backbone.Mediator.publish 'level-component-edited', levelComponent: @levelComponent
|
||||
|
||||
buildCodeEditor: ->
|
||||
@editor?.destroy()
|
||||
|
@ -100,21 +98,20 @@ module.exports = class LevelComponentEditView extends CocoView
|
|||
onEditorChange: =>
|
||||
return if @destroyed
|
||||
@levelComponent.set 'code', @editor.getValue()
|
||||
Backbone.Mediator.publish 'level-component-edited', levelComponent: @levelComponent
|
||||
null
|
||||
|
||||
endEditing: (e) ->
|
||||
Backbone.Mediator.publish 'level-component-editing-ended', levelComponent: @levelComponent
|
||||
Backbone.Mediator.publish 'editor:level-component-editing-ended', component: @levelComponent
|
||||
null
|
||||
|
||||
showVersionHistory: (e) ->
|
||||
componentVersionsModal = new ComponentVersionsModal {}, @levelComponent.id
|
||||
@openModalView componentVersionsModal
|
||||
Backbone.Mediator.publish 'level:view-switched', e
|
||||
Backbone.Mediator.publish 'editor:view-switched', {}
|
||||
|
||||
startPatchingComponent: (e) ->
|
||||
@openModalView new SaveVersionModal({model: @levelComponent})
|
||||
Backbone.Mediator.publish 'level:view-switched', e
|
||||
Backbone.Mediator.publish 'editor:view-switched', {}
|
||||
|
||||
toggleWatchComponent: ->
|
||||
button = @$el.find('#component-watch-button')
|
||||
|
|
|
@ -13,12 +13,12 @@ module.exports = class NewLevelComponentModal extends ModalView
|
|||
events:
|
||||
'click #new-level-component-submit': 'makeNewLevelComponent'
|
||||
'submit form': 'makeNewLevelComponent'
|
||||
|
||||
|
||||
getRenderData: ->
|
||||
c = super()
|
||||
c.systems = LevelComponent.schema.properties.system.enum
|
||||
c
|
||||
|
||||
|
||||
makeNewLevelComponent: (e) ->
|
||||
e.preventDefault()
|
||||
system = @$el.find('#level-component-system').val()
|
||||
|
@ -38,5 +38,4 @@ module.exports = class NewLevelComponentModal extends ModalView
|
|||
forms.applyErrorsToForm(@$el, JSON.parse(res.responseText))
|
||||
res.success =>
|
||||
@supermodel.registerModel component
|
||||
Backbone.Mediator.publish 'edit-level-component', original: component.get('_id'), majorVersion: 0
|
||||
@hide()
|
||||
|
|
|
@ -102,7 +102,7 @@ presets = {
|
|||
'width': [8, 12]
|
||||
'height': [8, 12]
|
||||
'numBarrels': [4,6]
|
||||
'cluster': 'barrel'
|
||||
'cluster': 'barrel'
|
||||
}
|
||||
'cave': {
|
||||
'num':[1,1]
|
||||
|
@ -215,9 +215,7 @@ module.exports = class TerrainRandomizeModal extends ModalView
|
|||
presetType = target.attr 'data-preset-type'
|
||||
presetSize = target.attr 'data-preset-size'
|
||||
@randomizeThangs presetType, presetSize
|
||||
Backbone.Mediator.publish('randomize:terrain-generated',
|
||||
'thangs': @thangs
|
||||
)
|
||||
Backbone.Mediator.publish 'editor:random-terrain-generated', thangs: @thangs
|
||||
@hide()
|
||||
|
||||
randomizeThangs: (presetName, presetSize) ->
|
||||
|
@ -272,29 +270,29 @@ module.exports = class TerrainRandomizeModal extends ModalView
|
|||
@addThang {
|
||||
'id': @getRandomThang(clusters[preset.borders].thangs)
|
||||
'pos': {
|
||||
'x': i + preset.borderSize/2
|
||||
'x': i + preset.borderSize/2
|
||||
'y': presetSize.y - 3 * preset.borderSize/2
|
||||
}
|
||||
'margin': clusters[preset.borders].margin
|
||||
}
|
||||
}
|
||||
if ( i / preset.borderSize ) % 2 and i isnt presetSize.x - thangSizes.borderSize.x
|
||||
@addThang {
|
||||
'id': @getRandomThang(clusters['torch'].thangs)
|
||||
'pos': {
|
||||
'x': i + preset.borderSize
|
||||
'x': i + preset.borderSize
|
||||
'y': presetSize.y - preset.borderSize
|
||||
}
|
||||
'margin': clusters['torch'].margin
|
||||
}
|
||||
}
|
||||
else if ( i / preset.borderSize ) % 2 is 0 and i and _.random(100) < 30
|
||||
@addThang {
|
||||
'id': @getRandomThang(clusters['chains'].thangs)
|
||||
'pos': {
|
||||
'x': i + preset.borderSize
|
||||
'x': i + preset.borderSize
|
||||
'y': presetSize.y - preset.borderSize
|
||||
}
|
||||
'margin': clusters['chains'].margin
|
||||
}
|
||||
}
|
||||
|
||||
for i in _.range(0, presetSize.y, thangSizes.borderSize.y)
|
||||
for j in _.range(preset.borderThickness)
|
||||
|
@ -395,7 +393,7 @@ module.exports = class TerrainRandomizeModal extends ModalView
|
|||
'pos': {
|
||||
'x': thang.pos.x - preset.borderSize / 2
|
||||
'y': thang.pos.y + preset.borderSize / 2
|
||||
}
|
||||
}
|
||||
'margin': clusters['torch'].margin
|
||||
}
|
||||
|
||||
|
@ -415,7 +413,7 @@ module.exports = class TerrainRandomizeModal extends ModalView
|
|||
|
||||
for t in _.range(0, roomThickness)
|
||||
for i in _.range(rect.y - rect.height/2 - t * preset.borderSize, rect.y + rect.height/2 + (t+1) * preset.borderSize, preset.borderSize)
|
||||
# Left wall
|
||||
# Left wall
|
||||
@addThang {
|
||||
'id': @getRandomThang(clusters[room.cluster].thangs)
|
||||
'pos': {
|
||||
|
@ -425,7 +423,7 @@ module.exports = class TerrainRandomizeModal extends ModalView
|
|||
'margin': clusters[room.cluster].margin
|
||||
}
|
||||
|
||||
# Right wall
|
||||
# Right wall
|
||||
@addThang {
|
||||
'id': @getRandomThang(clusters[room.cluster].thangs)
|
||||
'pos': {
|
||||
|
|
|
@ -10,8 +10,8 @@ module.exports = class WorldSelectModal extends ModalView
|
|||
cache: false
|
||||
|
||||
subscriptions:
|
||||
'choose-region': 'selectionMade'
|
||||
'choose-point': 'selectionMade'
|
||||
'surface:choose-region': 'selectionMade'
|
||||
'surface:choose-point': 'selectionMade'
|
||||
|
||||
events:
|
||||
'click #done-button': 'done'
|
||||
|
|
|
@ -11,7 +11,7 @@ module.exports = class ScriptsTabView extends CocoView
|
|||
className: 'tab-pane'
|
||||
|
||||
subscriptions:
|
||||
'level-loaded': 'onLevelLoaded'
|
||||
'editor:level-loaded': 'onLevelLoaded'
|
||||
|
||||
constructor: (options) ->
|
||||
super options
|
||||
|
@ -133,7 +133,7 @@ class ScriptNode extends TreemaObjectNode
|
|||
onDeletePressed: (e) ->
|
||||
returnVal = super(e)
|
||||
if @callbacks.removeChild
|
||||
@callbacks.removeChild()
|
||||
@callbacks.removeChild()
|
||||
returnVal
|
||||
|
||||
onRightArrowPressed: ->
|
||||
|
@ -159,7 +159,7 @@ class EventPropsNode extends TreemaNode.nodeMap.string
|
|||
joined = '(unset)' if not joined.length
|
||||
@buildValueForDisplaySimply valEl, joined
|
||||
|
||||
buildValueForEditing: (valEl) ->
|
||||
buildValueForEditing: (valEl) ->
|
||||
super(valEl)
|
||||
channel = @getRoot().data.channel
|
||||
channelSchema = Backbone.Mediator.channelSchemas[channel]
|
||||
|
|
|
@ -17,7 +17,7 @@ module.exports = class SettingsTabView extends CocoView
|
|||
]
|
||||
|
||||
subscriptions:
|
||||
'level-loaded': 'onLevelLoaded'
|
||||
'editor:level-loaded': 'onLevelLoaded'
|
||||
|
||||
constructor: (options) ->
|
||||
super options
|
||||
|
@ -56,4 +56,4 @@ module.exports = class SettingsTabView extends CocoView
|
|||
@level.set key, @settingsTreema.data[key]
|
||||
|
||||
class SettingsNode extends TreemaObjectNode
|
||||
nodeDescription: 'Settings'
|
||||
nodeDescription: 'Settings'
|
||||
|
|
|
@ -58,7 +58,6 @@ module.exports = class LevelSystemEditView extends CocoView
|
|||
# Make sure it validates first?
|
||||
for key, value of @systemSettingsTreema.data
|
||||
@levelSystem.set key, value unless key is 'js' # will compile code if needed
|
||||
Backbone.Mediator.publish 'level-system-edited', levelSystem: @levelSystem
|
||||
null
|
||||
|
||||
buildConfigSchemaTreema: ->
|
||||
|
@ -76,7 +75,6 @@ module.exports = class LevelSystemEditView extends CocoView
|
|||
|
||||
onConfigSchemaEdited: =>
|
||||
@levelSystem.set 'configSchema', @configSchemaTreema.data
|
||||
Backbone.Mediator.publish 'level-system-edited', levelSystem: @levelSystem
|
||||
|
||||
buildCodeEditor: ->
|
||||
@editor?.destroy()
|
||||
|
@ -93,21 +91,20 @@ module.exports = class LevelSystemEditView extends CocoView
|
|||
|
||||
onEditorChange: =>
|
||||
@levelSystem.set 'code', @editor.getValue()
|
||||
Backbone.Mediator.publish 'level-system-edited', levelSystem: @levelSystem
|
||||
null
|
||||
|
||||
endEditing: (e) ->
|
||||
Backbone.Mediator.publish 'level-system-editing-ended', levelSystem: @levelSystem
|
||||
Backbone.Mediator.publish 'editor:level-system-editing-ended', system: @levelSystem
|
||||
null
|
||||
|
||||
showVersionHistory: (e) ->
|
||||
systemVersionsModal = new SystemVersionsModal {}, @levelSystem.id
|
||||
@openModalView systemVersionsModal
|
||||
Backbone.Mediator.publish 'level:view-switched', e
|
||||
Backbone.Mediator.publish 'editor:view-switched', {}
|
||||
|
||||
startPatchingSystem: (e) ->
|
||||
@openModalView new SaveVersionModal({model: @levelSystem})
|
||||
Backbone.Mediator.publish 'level:view-switched', e
|
||||
Backbone.Mediator.publish 'editor:view-switched', {}
|
||||
|
||||
toggleWatchSystem: ->
|
||||
console.log 'toggle watch system?'
|
||||
|
|
|
@ -32,5 +32,5 @@ module.exports = class NewLevelSystemModal extends ModalView
|
|||
forms.applyErrorsToForm(@$el, JSON.parse(res.responseText))
|
||||
res.success =>
|
||||
@supermodel.registerModel system
|
||||
Backbone.Mediator.publish 'edit-level-system', original: system.get('_id'), majorVersion: 0
|
||||
Backbone.Mediator.publish 'editor:edit-level-system', original: system.get('_id'), majorVersion: 0
|
||||
@hide()
|
||||
|
|
|
@ -13,11 +13,10 @@ module.exports = class SystemsTabView extends CocoView
|
|||
className: 'tab-pane'
|
||||
|
||||
subscriptions:
|
||||
'level-system-added': 'onLevelSystemAdded'
|
||||
'edit-level-system': 'editLevelSystem'
|
||||
'level-system-edited': 'onLevelSystemEdited'
|
||||
'level-system-editing-ended': 'onLevelSystemEditingEnded'
|
||||
'level-loaded': 'onLevelLoaded'
|
||||
'editor:level-system-added': 'onLevelSystemAdded'
|
||||
'editor:edit-level-system': 'editLevelSystem'
|
||||
'editor:level-system-editing-ended': 'onLevelSystemEditingEnded'
|
||||
'editor:level-loaded': 'onLevelLoaded'
|
||||
|
||||
events:
|
||||
'click #add-system-button': 'addLevelSystem'
|
||||
|
@ -91,18 +90,15 @@ module.exports = class SystemsTabView extends CocoView
|
|||
|
||||
addLevelSystem: (e) ->
|
||||
@openModalView new AddLevelSystemModal supermodel: @supermodel, extantSystems: _.cloneDeep @systemsTreema.data
|
||||
Backbone.Mediator.publish 'level:view-switched', e
|
||||
Backbone.Mediator.publish 'editor:view-switched', {}
|
||||
|
||||
createNewLevelSystem: (e) ->
|
||||
@openModalView new NewLevelSystemModal supermodel: @supermodel
|
||||
Backbone.Mediator.publish 'level:view-switched', e
|
||||
Backbone.Mediator.publish 'editor:view-switched', {}
|
||||
|
||||
editLevelSystem: (e) ->
|
||||
@levelSystemEditView = @insertSubView new LevelSystemEditView(original: e.original, majorVersion: e.majorVersion, supermodel: @supermodel)
|
||||
|
||||
onLevelSystemEdited: (e) ->
|
||||
Backbone.Mediator.publish 'level-systems-changed', systemsData: @systemsTreema.data
|
||||
|
||||
onLevelSystemEditingEnded: (e) ->
|
||||
@removeSubView @levelSystemEditView
|
||||
@levelSystemEditView = null
|
||||
|
@ -150,7 +146,7 @@ class LevelSystemNode extends TreemaObjectNode
|
|||
|
||||
onEnterPressed: (e) ->
|
||||
super e
|
||||
Backbone.Mediator.publish 'edit-level-system', original: @data.original, majorVersion: @data.majorVersion
|
||||
Backbone.Mediator.publish 'editor:edit-level-system', original: @data.original, majorVersion: @data.majorVersion
|
||||
|
||||
open: (depth) ->
|
||||
super depth
|
||||
|
|
|
@ -56,13 +56,10 @@ module.exports = class LevelThangEditView extends CocoView
|
|||
|
||||
saveThang: (e) ->
|
||||
# Make sure it validates first?
|
||||
event =
|
||||
thangData: @thangData
|
||||
id: @oldID
|
||||
Backbone.Mediator.publish 'level-thang-edited', event
|
||||
Backbone.Mediator.publish 'editor:level-thang-edited', thangData: @thangData, thangID: @oldID
|
||||
|
||||
navigateToAllThangs: ->
|
||||
Backbone.Mediator.publish 'level-thang-done-editing'
|
||||
Backbone.Mediator.publish 'editor:level-thang-done-editing', {}
|
||||
|
||||
toggleNameEdit: ->
|
||||
link = @$el.find '#thang-name-link'
|
||||
|
|
|
@ -34,15 +34,15 @@ module.exports = class ThangsTabView extends CocoView
|
|||
'surface:mouse-moved': 'onSurfaceMouseMoved'
|
||||
'surface:mouse-over': 'onSurfaceMouseOver'
|
||||
'surface:mouse-out': 'onSurfaceMouseOut'
|
||||
'edit-level-thang': 'editThang'
|
||||
'level-thang-edited': 'onLevelThangEdited'
|
||||
'level-thang-done-editing': 'onLevelThangDoneEditing'
|
||||
'level:view-switched': 'onViewSwitched'
|
||||
'editor:edit-level-thang': 'editThang'
|
||||
'editor:level-thang-edited': 'onLevelThangEdited'
|
||||
'editor:level-thang-done-editing': 'onLevelThangDoneEditing'
|
||||
'editor:view-switched': 'onViewSwitched'
|
||||
'sprite:dragged': 'onSpriteDragged'
|
||||
'sprite:mouse-up': 'onSpriteMouseUp'
|
||||
'sprite:double-clicked': 'onSpriteDoubleClicked'
|
||||
'surface:stage-mouse-up': 'onStageMouseUp'
|
||||
'randomize:terrain-generated': 'onRandomizeTerrain'
|
||||
'editor:random-terrain-generated': 'onRandomTerrainGenerated'
|
||||
|
||||
events:
|
||||
'click #extant-thangs-filter button': 'onFilterExtantThangs'
|
||||
|
@ -232,7 +232,7 @@ module.exports = class ThangsTabView extends CocoView
|
|||
return unless e.thang
|
||||
@editThang thangID: e.thang.id
|
||||
|
||||
onRandomizeTerrain: (e) ->
|
||||
onRandomTerrainGenerated: (e) ->
|
||||
@thangsBatch = []
|
||||
nonRandomThangs = (thang for thang in @thangsTreema.get('') when not /Random/.test thang.id)
|
||||
@thangsTreema.set '', nonRandomThangs
|
||||
|
@ -402,7 +402,6 @@ module.exports = class ThangsTabView extends CocoView
|
|||
thang.isSelectable = not thang.isLand for thang in @world.thangs # let us select walls and such
|
||||
@surface?.setWorld @world
|
||||
@selectAddThangType @addThangType, @cloneSourceThang if @addThangType # make another addThang sprite, since the World just refreshed
|
||||
Backbone.Mediator.publish 'level-thangs-changed', thangsData: @thangsTreema.data
|
||||
null
|
||||
|
||||
onTreemaThangSelected: (e, selectedTreemas) =>
|
||||
|
@ -449,13 +448,13 @@ module.exports = class ThangsTabView extends CocoView
|
|||
@editThangView = new LevelThangEditView thangData: thangData, level: @level, world: @world, supermodel: @supermodel # supermodel needed for checkForMissingSystems
|
||||
@insertSubView @editThangView
|
||||
@$el.find('.thangs-column').hide()
|
||||
Backbone.Mediator.publish 'level:view-switched', e
|
||||
Backbone.Mediator.publish 'editor:view-switched', {}
|
||||
|
||||
onLevelThangEdited: (e) ->
|
||||
newThang = e.thangData
|
||||
@thangsTreema.set "id=#{e.id}", newThang
|
||||
@thangsTreema.set "id=#{e.thangID}", newThang
|
||||
|
||||
onLevelThangDoneEditing: ->
|
||||
onLevelThangDoneEditing: (e) ->
|
||||
@removeSubView @editThangView
|
||||
@editThangView = null
|
||||
@onThangsChanged()
|
||||
|
@ -530,4 +529,4 @@ class ThangNode extends TreemaObjectNode
|
|||
@buildValueForDisplaySimply valEl, s
|
||||
|
||||
onEnterPressed: ->
|
||||
Backbone.Mediator.publish 'edit-level-thang', thangID: @data.id
|
||||
Backbone.Mediator.publish 'editor:edit-level-thang', thangID: @data.id
|
||||
|
|
|
@ -44,7 +44,7 @@ module.exports = class ThangTypeEditView extends RootView
|
|||
'keyup .play-with-level-input': 'onPlayLevelKeyUp'
|
||||
|
||||
subscriptions:
|
||||
'save-new-version': 'saveNewThangType'
|
||||
'editor:save-new-version': 'saveNewThangType'
|
||||
|
||||
# init / render
|
||||
|
||||
|
@ -438,7 +438,7 @@ module.exports = class ThangTypeEditView extends RootView
|
|||
level = _.string.slugify level
|
||||
if @childWindow and not @childWindow.closed
|
||||
# Reset the LevelView's world, but leave the rest of the state alone
|
||||
@childWindow.Backbone.Mediator.publish 'level-reload-thang-type', thangType: @thangType
|
||||
@childWindow.Backbone.Mediator.publish 'level:reload-thang-type', thangType: @thangType
|
||||
else
|
||||
# Create a new Window with a blank LevelView
|
||||
scratchLevelID = level + '?dev=true'
|
||||
|
|
|
@ -9,7 +9,7 @@ module.exports = class ChooseHeroView extends CocoView
|
|||
template: template
|
||||
|
||||
events:
|
||||
'click #restart-level-confirm-button': -> Backbone.Mediator.publish 'restart-level'
|
||||
'click #restart-level-confirm-button': -> Backbone.Mediator.publish 'level:restart-level', {}
|
||||
|
||||
getRenderData: (context={}) ->
|
||||
context = super(context)
|
||||
|
|
|
@ -61,7 +61,7 @@ module.exports = class OptionsView extends CocoView
|
|||
volume = @volumeSlider.slider('value')
|
||||
me.set 'volume', volume
|
||||
@$el.find('#option-volume-value').text (volume * 100).toFixed(0) + '%'
|
||||
Backbone.Mediator.publish 'level-set-volume', volume: volume
|
||||
Backbone.Mediator.publish 'level:set-volume', volume: volume
|
||||
|
||||
onHidden: ->
|
||||
if @playerName and @playerName isnt me.get('name')
|
||||
|
@ -72,7 +72,7 @@ module.exports = class OptionsView extends CocoView
|
|||
@aceConfig.behaviors = @$el.find('#option-behaviors').prop('checked')
|
||||
@aceConfig.liveCompletion = @$el.find('#option-live-completion').prop('checked')
|
||||
me.set 'aceConfig', @aceConfig
|
||||
Backbone.Mediator.publish 'tome:change-config'
|
||||
Backbone.Mediator.publish 'tome:change-config', {}
|
||||
|
||||
updateMusic: ->
|
||||
me.set 'music', @$el.find('#option-music').prop('checked')
|
||||
|
|
|
@ -179,7 +179,7 @@ module.exports = class CocoView extends Backbone.View
|
|||
$('#modal-wrapper .modal').modal(modalOptions).on 'hidden.bs.modal', @modalClosed
|
||||
window.currentModal = modalView
|
||||
@getRootView().stopListeningToShortcuts(true)
|
||||
Backbone.Mediator.publish 'modal-opened', {}
|
||||
Backbone.Mediator.publish 'modal:opened', {}
|
||||
|
||||
modalClosed: =>
|
||||
visibleModal.willDisappear() if visibleModal
|
||||
|
@ -193,7 +193,7 @@ module.exports = class CocoView extends Backbone.View
|
|||
@openModalView(wm)
|
||||
else
|
||||
@getRootView().listenToShortcuts(true)
|
||||
Backbone.Mediator.publish 'modal-closed', {}
|
||||
Backbone.Mediator.publish 'modal:closed', {}
|
||||
|
||||
# Loading RootViews
|
||||
|
||||
|
@ -268,7 +268,7 @@ module.exports = class CocoView extends Backbone.View
|
|||
view.parentKey = key
|
||||
@subviews[key] = view
|
||||
view
|
||||
|
||||
|
||||
makeSubViewKey: (view) ->
|
||||
key = view.id or (view.constructor.name+classCount++)
|
||||
key = _.string.underscored(key) # handy for autocomplete in dev console
|
||||
|
|
|
@ -36,8 +36,8 @@ module.exports = class RootView extends CocoView
|
|||
showNewAchievement: (achievement, earnedAchievement) ->
|
||||
popup = new AchievementPopup achievement: achievement, earnedAchievement: earnedAchievement
|
||||
|
||||
handleNewAchievements: (earnedAchievements) ->
|
||||
_.each earnedAchievements.models, (earnedAchievement) =>
|
||||
handleNewAchievements: (e) ->
|
||||
_.each e.earnedAchievements.models, (earnedAchievement) =>
|
||||
achievement = new Achievement(_id: earnedAchievement.get('achievement'))
|
||||
achievement.fetch
|
||||
success: (achievement) => @showNewAchievement(achievement, earnedAchievement)
|
||||
|
|
|
@ -19,8 +19,8 @@ module.exports = class AuthModal extends ModalView
|
|||
'keyup #name': 'onNameChange'
|
||||
|
||||
subscriptions:
|
||||
'server-error': 'onServerError'
|
||||
'logging-in-with-facebook': 'onLoggingInWithFacebook'
|
||||
'errors:server-error': 'onServerError'
|
||||
'auth:logging-in-with-facebook': 'onLoggingInWithFacebook'
|
||||
|
||||
constructor: (options) ->
|
||||
@onNameChange = _.debounce @checkNameExists, 500
|
||||
|
@ -39,7 +39,7 @@ module.exports = class AuthModal extends ModalView
|
|||
c.onEmployersPage = Backbone.history.fragment is "employers"
|
||||
c.me = me
|
||||
c
|
||||
|
||||
|
||||
afterInsert: ->
|
||||
super()
|
||||
_.delay application.router.renderLoginButtons, 500
|
||||
|
@ -104,4 +104,4 @@ module.exports = class AuthModal extends ModalView
|
|||
forms.setErrorToProperty @$el, 'name', "That name is taken! How about #{newName}?", true
|
||||
|
||||
onGitHubLoginClicked: ->
|
||||
Backbone.Mediator.publish 'github-login'
|
||||
Backbone.Mediator.publish 'auth:log-in-with-github', {}
|
||||
|
|
|
@ -11,8 +11,8 @@ module.exports = class EmployerSignupModal extends ModalView
|
|||
closeButton: true
|
||||
|
||||
subscriptions:
|
||||
'server-error': 'onServerError'
|
||||
'linkedin-loaded': 'onLinkedInLoaded'
|
||||
'errors:server-error': 'onServerError'
|
||||
'auth:linkedin-api-loaded': 'onLinkedInLoaded'
|
||||
'created-user-without-reload': 'createdAccount'
|
||||
|
||||
events:
|
||||
|
|
|
@ -18,7 +18,7 @@ module.exports = class RecoverModal extends ModalView
|
|||
'keydown input': 'recoverAccount'
|
||||
|
||||
subscriptions:
|
||||
'server-error': 'onServerError'
|
||||
'errors:server-error': 'onServerError'
|
||||
|
||||
onServerError: (e) -> # TODO: work error handling into a separate forms system
|
||||
@disableModalInProgress(@$el)
|
||||
|
|
|
@ -43,9 +43,9 @@ module.exports = class SaveVersionModal extends ModalView
|
|||
onSubmitForm: (e) ->
|
||||
e.preventDefault()
|
||||
if @isPatch then @submitPatch() else @saveChanges()
|
||||
|
||||
|
||||
saveChanges: ->
|
||||
Backbone.Mediator.publish 'save-new-version', {
|
||||
Backbone.Mediator.publish 'editor:save-new-version', {
|
||||
major: @$el.find('#major-version').prop('checked')
|
||||
commitMessage: @$el.find('#commit-message').val()
|
||||
}
|
||||
|
|
|
@ -37,38 +37,21 @@ module.exports = class SpectateLevelView extends RootView
|
|||
id: 'spectate-level-view'
|
||||
template: template
|
||||
cache: false
|
||||
shortcutsEnabled: true
|
||||
isEditorPreview: false
|
||||
|
||||
subscriptions:
|
||||
'level-set-volume': (e) -> createjs.Sound.setVolume(e.volume)
|
||||
'level-highlight-dom': 'onHighlightDom'
|
||||
'end-level-highlight-dom': 'onEndHighlight'
|
||||
'level-focus-dom': 'onFocusDom'
|
||||
'level-disable-controls': 'onDisableControls'
|
||||
'level-enable-controls': 'onEnableControls'
|
||||
'level:set-volume': (e) -> createjs.Sound.setVolume(e.volume)
|
||||
'god:new-world-created': 'onNewWorld'
|
||||
'god:streaming-world-updated': 'onNewWorld'
|
||||
'god:infinite-loop': 'onInfiniteLoop'
|
||||
'level-reload-from-data': 'onLevelReloadFromData'
|
||||
'play-next-level': 'onPlayNextLevel'
|
||||
'surface:world-set-up': 'onSurfaceSetUpNewWorld'
|
||||
'level:set-team': 'setTeam'
|
||||
'god:new-world-created': 'loadSoundsForWorld'
|
||||
'god:streaming-world-updated': 'loadSoundsForWorld'
|
||||
'next-game-pressed': 'onNextGamePressed'
|
||||
'level:next-game-pressed': 'onNextGamePressed'
|
||||
'level:started': 'onLevelStarted'
|
||||
'level:loading-view-unveiled': 'onLoadingViewUnveiled'
|
||||
|
||||
events:
|
||||
'click #level-done-button': 'onDonePressed'
|
||||
|
||||
shortcuts:
|
||||
'ctrl+s': 'onCtrlS'
|
||||
|
||||
constructor: (options, @levelID) ->
|
||||
console.profile?() if PROFILE_ME
|
||||
super options
|
||||
$(window).on('resize', @onWindowResize)
|
||||
|
||||
@sessionOne = @getQueryVariable 'session-one'
|
||||
@sessionTwo = @getQueryVariable 'session-two'
|
||||
|
@ -207,143 +190,16 @@ module.exports = class SpectateLevelView extends RootView
|
|||
@insertSubView new HUDView {}
|
||||
worldName = utils.i18n @level.attributes, 'name'
|
||||
@controlBar = @insertSubView new ControlBarView {worldName: worldName, session: @session, level: @level, supermodel: @supermodel, playableTeams: @world.playableTeams, spectateGame: true}
|
||||
#Backbone.Mediator.publish('level-set-debug', debug: true) if me.displayName() is 'Nick'
|
||||
|
||||
afterInsert: ->
|
||||
super()
|
||||
|
||||
# callbacks
|
||||
|
||||
onCtrlS: (e) ->
|
||||
e.preventDefault()
|
||||
|
||||
onLevelReloadFromData: (e) ->
|
||||
isReload = Boolean @world
|
||||
@setLevel e.level, e.supermodel
|
||||
if isReload
|
||||
@scriptManager.setScripts(e.level.get('scripts'))
|
||||
Backbone.Mediator.publish 'tome:cast-spell' # a bit hacky
|
||||
|
||||
onWindowResize: (s...) ->
|
||||
$('#pointer').css('opacity', 0.0)
|
||||
|
||||
onDisableControls: (e) ->
|
||||
return if e.controls and not ('level' in e.controls)
|
||||
@shortcutsEnabled = false
|
||||
@wasFocusedOn = document.activeElement
|
||||
$('body').focus()
|
||||
|
||||
onEnableControls: (e) ->
|
||||
return if e.controls? and not ('level' in e.controls)
|
||||
@shortcutsEnabled = true
|
||||
$(@wasFocusedOn).focus() if @wasFocusedOn
|
||||
@wasFocusedOn = null
|
||||
|
||||
onDonePressed: -> return
|
||||
|
||||
|
||||
onNewWorld: (e) ->
|
||||
@world = e.world
|
||||
|
||||
onInfiniteLoop: (e) ->
|
||||
return unless e.firstWorld
|
||||
@openModalView new InfiniteLoopModal()
|
||||
window.tracker?.trackEvent 'Saw Initial Infinite Loop', level: @world.name, label: @world.name
|
||||
|
||||
onPlayNextLevel: ->
|
||||
nextLevel = @getNextLevel()
|
||||
nextLevelID = nextLevel.get('slug') or nextLevel.id
|
||||
url = "/play/level/#{nextLevelID}"
|
||||
Backbone.Mediator.publish 'router:navigate', {
|
||||
route: url,
|
||||
viewClass: PlayLevelView,
|
||||
viewArgs: [{supermodel:@supermodel}, nextLevelID]}
|
||||
|
||||
getNextLevel: ->
|
||||
nextLevelOriginal = @level.get('nextLevel')?.original
|
||||
levels = @supermodel.getModels(Level)
|
||||
return l for l in levels when l.get('original') is nextLevelOriginal
|
||||
|
||||
onHighlightDom: (e) ->
|
||||
if e.delay
|
||||
delay = e.delay
|
||||
delete e.delay
|
||||
@pointerInterval = _.delay((=> @onHighlightDom e), delay)
|
||||
return
|
||||
@addPointer()
|
||||
selector = e.selector + ':visible'
|
||||
dom = $(selector)
|
||||
return if parseFloat(dom.css('opacity')) is 0.0
|
||||
offset = dom.offset()
|
||||
return if not offset
|
||||
target_left = offset.left + dom.outerWidth() * 0.5
|
||||
target_top = offset.top + dom.outerHeight() * 0.5
|
||||
body = $('#level-view')
|
||||
|
||||
if e.sides
|
||||
if 'left' in e.sides then target_left = offset.left
|
||||
if 'right' in e.sides then target_left = offset.left + dom.outerWidth()
|
||||
if 'top' in e.sides then target_top = offset.top
|
||||
if 'bottom' in e.sides then target_top = offset.top + dom.outerHeight()
|
||||
else
|
||||
# aim to hit the side if the target is entirely on one side of the screen
|
||||
if offset.left > body.outerWidth()*0.5
|
||||
target_left = offset.left
|
||||
else if offset.left + dom.outerWidth() < body.outerWidth()*0.5
|
||||
target_left = offset.left + dom.outerWidth()
|
||||
|
||||
# aim to hit the bottom or top if the target is entirely on the top or bottom of the screen
|
||||
if offset.top > body.outerWidth()*0.5
|
||||
target_top = offset.top
|
||||
else if offset.top + dom.outerHeight() < body.outerHeight()*0.5
|
||||
target_top = offset.top + dom.outerHeight()
|
||||
|
||||
if e.offset
|
||||
target_left += e.offset.x
|
||||
target_top += e.offset.y
|
||||
|
||||
@pointerRadialDistance = -47 # - Math.sqrt(Math.pow(dom.outerHeight()*0.5, 2), Math.pow(dom.outerWidth()*0.5))
|
||||
@pointerRotation = e.rotation ? Math.atan2(body.outerWidth()*0.5 - target_left, target_top - body.outerHeight()*0.5)
|
||||
pointer = $('#pointer')
|
||||
pointer
|
||||
.css('opacity', 1.0)
|
||||
.css('transition', 'none')
|
||||
.css('transform', "rotate(#{@pointerRotation}rad) translate(-3px, #{@pointerRadialDistance}px)")
|
||||
.css('top', target_top - 50)
|
||||
.css('left', target_left - 50)
|
||||
setTimeout((=>
|
||||
@animatePointer()
|
||||
clearInterval(@pointerInterval)
|
||||
@pointerInterval = setInterval(@animatePointer, 1200)
|
||||
), 1)
|
||||
|
||||
animatePointer: ->
|
||||
pointer = $('#pointer')
|
||||
pointer.css('transition', 'all 0.6s ease-out')
|
||||
pointer.css('transform', "rotate(#{@pointerRotation}rad) translate(-3px, #{@pointerRadialDistance-50}px)")
|
||||
setTimeout((=>
|
||||
pointer.css('transform', "rotate(#{@pointerRotation}rad) translate(-3px, #{@pointerRadialDistance}px)").css('transition', 'all 0.4s ease-in')), 800)
|
||||
|
||||
onFocusDom: (e) -> $(e.selector).focus()
|
||||
|
||||
onEndHighlight: ->
|
||||
$('#pointer').css('opacity', 0.0)
|
||||
clearInterval(@pointerInterval)
|
||||
|
||||
onMultiplayerChanged: (e) ->
|
||||
if @session.get('multiplayer')
|
||||
@bus.connect()
|
||||
else
|
||||
@bus.removeFirebaseData =>
|
||||
@bus.disconnect()
|
||||
|
||||
# initialization
|
||||
|
||||
addPointer: ->
|
||||
p = $('#pointer')
|
||||
return if p.length
|
||||
@$el.append($('<img src="/images/level/pointer.png" id="pointer">'))
|
||||
|
||||
initSurface: ->
|
||||
surfaceCanvas = $('canvas#surface', @$el)
|
||||
@surface = new Surface(@world, surfaceCanvas, thangTypes: @supermodel.getModels(ThangType), playJingle: not @isEditorPreview, spectateGame: true)
|
||||
|
@ -372,14 +228,14 @@ module.exports = class SpectateLevelView extends RootView
|
|||
initVolume: ->
|
||||
volume = me.get('volume')
|
||||
volume = 1.0 unless volume?
|
||||
Backbone.Mediator.publish 'level-set-volume', volume: volume
|
||||
Backbone.Mediator.publish 'level:set-volume', volume: volume
|
||||
|
||||
onSurfaceSetUpNewWorld: ->
|
||||
return if @alreadyLoadedState
|
||||
@alreadyLoadedState = true
|
||||
state = @originalSessionState
|
||||
if state.playing?
|
||||
Backbone.Mediator.publish 'level-set-playing', { playing: state.playing }
|
||||
Backbone.Mediator.publish 'level:set-playing', playing: state.playing
|
||||
|
||||
register: -> return
|
||||
|
||||
|
@ -400,17 +256,22 @@ module.exports = class SpectateLevelView extends RootView
|
|||
|
||||
# Dynamic sound loading
|
||||
|
||||
loadSoundsForWorld: (e) ->
|
||||
onNewWorld: (e) ->
|
||||
return if @headless
|
||||
world = e.world
|
||||
scripts = @world.scripts # Since these worlds don't have scripts, preserve them.
|
||||
@world = e.world
|
||||
thangTypes = @supermodel.getModels(ThangType)
|
||||
for [spriteName, message] in world.thangDialogueSounds()
|
||||
startFrame = @lastWorldFramesLoaded ? 0
|
||||
if @world.frames.length is @world.totalFrames # Finished loading
|
||||
@lastWorldFramesLoaded = 0
|
||||
else
|
||||
@lastWorldFramesLoaded = @world.frames.length
|
||||
for [spriteName, message] in @world.thangDialogueSounds startFrame
|
||||
continue unless thangType = _.find thangTypes, (m) -> m.get('name') is spriteName
|
||||
continue unless sound = AudioPlayer.soundForDialogue message, thangType.get('soundTriggers')
|
||||
AudioPlayer.preloadSoundReference sound
|
||||
|
||||
onNextGamePressed: (e) ->
|
||||
console.log 'You want to see the next game!'
|
||||
@fetchRandomSessionPair (err, data) =>
|
||||
if err? then return console.log "There was an error fetching the random session pair: #{data}"
|
||||
@sessionOne = data[0]._id
|
||||
|
@ -445,10 +306,8 @@ module.exports = class SpectateLevelView extends RootView
|
|||
@levelLoader?.destroy()
|
||||
@surface?.destroy()
|
||||
@god?.destroy()
|
||||
$(window).off('resize', @onWindowResize)
|
||||
@goalManager?.destroy()
|
||||
@scriptManager?.destroy()
|
||||
delete window.world # not sure where this is set, but this is one way to clean it up
|
||||
clearInterval(@pointerInterval)
|
||||
console.profileEnd?() if PROFILE_ME
|
||||
super()
|
||||
|
|
|
@ -21,10 +21,10 @@ module.exports = class LadderTabView extends CocoView
|
|||
'click .load-more-ladder-entries': 'onLoadMoreLadderEntries'
|
||||
|
||||
subscriptions:
|
||||
'fbapi-loaded': 'checkFriends'
|
||||
'gapi-loaded': 'checkFriends'
|
||||
'facebook-logged-in': 'onConnectedWithFacebook'
|
||||
'gplus-logged-in': 'onConnectedWithGPlus'
|
||||
'auth:facebook-api-loaded': 'checkFriends'
|
||||
'auth:gplus-api-loaded': 'checkFriends'
|
||||
'auth:logged-in-with-facebook': 'onConnectedWithFacebook'
|
||||
'auth:logged-in-with-gplus': 'onConnectedWithGPlus'
|
||||
|
||||
constructor: (options, @level, @sessions) ->
|
||||
super(options)
|
||||
|
|
|
@ -61,7 +61,7 @@ module.exports = class MyMatchesTabView extends CocoView
|
|||
state = 'tie' if match.metrics.rank is opponent.metrics.rank
|
||||
fresh = match.date > (new Date(new Date() - 20 * 1000)).toISOString()
|
||||
if fresh
|
||||
Backbone.Mediator.publish 'play-sound', trigger: 'chat_received'
|
||||
Backbone.Mediator.publish 'audio-player:play-sound', trigger: 'chat_received'
|
||||
{
|
||||
state: state
|
||||
opponentName: @nameMap[opponent.userID]
|
||||
|
@ -88,7 +88,7 @@ module.exports = class MyMatchesTabView extends CocoView
|
|||
team.scoreHistory = scoreHistory
|
||||
|
||||
if not team.isRanking and @previouslyRankingTeams[team.id]
|
||||
Backbone.Mediator.publish 'play-sound', trigger: 'cast-end'
|
||||
Backbone.Mediator.publish 'audio-player:play-sound', trigger: 'cast-end'
|
||||
@previouslyRankingTeams[team.id] = team.isRanking
|
||||
|
||||
ctx
|
||||
|
|
|
@ -16,7 +16,7 @@ module.exports = class ControlBarView extends CocoView
|
|||
window.tracker?.trackEvent 'Clicked Docs', level: @level.get('name'), label: @level.get('name')
|
||||
@showGuideModal()
|
||||
|
||||
'click #next-game-button': -> Backbone.Mediator.publish 'next-game-pressed', {}
|
||||
'click #next-game-button': -> Backbone.Mediator.publish 'level:next-game-pressed', {}
|
||||
|
||||
'click #game-menu-button': 'showGameMenuModal'
|
||||
|
||||
|
|
|
@ -51,7 +51,7 @@ module.exports = class LevelChatView extends CocoView
|
|||
@playNoise() if e.message.authorID isnt me.id
|
||||
|
||||
playNoise: ->
|
||||
Backbone.Mediator.publish 'play-sound', trigger: 'chat_received'
|
||||
Backbone.Mediator.publish 'audio-player:play-sound', trigger: 'chat_received'
|
||||
|
||||
messageObjectToJQuery: (message) ->
|
||||
td = $('<td></td>')
|
||||
|
|
|
@ -14,7 +14,7 @@ module.exports = class LevelGoalsView extends CocoView
|
|||
|
||||
subscriptions:
|
||||
'goal-manager:new-goal-states': 'onNewGoalStates'
|
||||
'level-set-letterbox': 'onSetLetterbox'
|
||||
'level:set-letterbox': 'onSetLetterbox'
|
||||
'surface:playback-restarted': 'onSurfacePlaybackRestarted'
|
||||
'surface:playback-ended': 'onSurfacePlaybackEnded'
|
||||
|
||||
|
|
|
@ -8,14 +8,14 @@ module.exports = class LevelGoldView extends CocoView
|
|||
|
||||
subscriptions:
|
||||
'surface:gold-changed': 'onGoldChanged'
|
||||
'level-set-letterbox': 'onSetLetterbox'
|
||||
'level:set-letterbox': 'onSetLetterbox'
|
||||
|
||||
constructor: (options) ->
|
||||
super options
|
||||
@teamGold = {}
|
||||
@teamGoldEarned = {}
|
||||
@shownOnce = false
|
||||
|
||||
|
||||
onGoldChanged: (e) ->
|
||||
return if @teamGold[e.team] is e.gold and @teamGoldEarned[e.team] is e.goldEarned
|
||||
@teamGold[e.team] = e.gold
|
||||
|
|
|
@ -11,16 +11,16 @@ module.exports = class LevelHUDView extends CocoView
|
|||
|
||||
subscriptions:
|
||||
'surface:frame-changed': 'onFrameChanged'
|
||||
'level-disable-controls': 'onDisableControls'
|
||||
'level-enable-controls': 'onEnableControls'
|
||||
'level:disable-controls': 'onDisableControls'
|
||||
'level:enable-controls': 'onEnableControls'
|
||||
'surface:sprite-selected': 'onSpriteSelected'
|
||||
'sprite:speech-updated': 'onSpriteDialogue'
|
||||
'level-sprite-clear-dialogue': 'onSpriteClearDialogue'
|
||||
'level:sprite-clear-dialogue': 'onSpriteClearDialogue'
|
||||
'level:shift-space-pressed': 'onShiftSpacePressed'
|
||||
'level:escape-pressed': 'onEscapePressed'
|
||||
'dialogue-sound-completed': 'onDialogueSoundCompleted'
|
||||
'thang-began-talking': 'onThangBeganTalking'
|
||||
'thang-finished-talking': 'onThangFinishedTalking'
|
||||
'sprite:dialogue-sound-completed': 'onDialogueSoundCompleted'
|
||||
'sprite:thang-began-talking': 'onThangBeganTalking'
|
||||
'sprite:thang-finished-talking': 'onThangFinishedTalking'
|
||||
'god:new-world-created': 'onNewWorld'
|
||||
|
||||
events:
|
||||
|
@ -210,13 +210,13 @@ module.exports = class LevelHUDView extends CocoView
|
|||
f = (r) => => setTimeout((-> Backbone.Mediator.publish(r.channel, r.event)), 10)
|
||||
$(buttons[i]).click(f(response))
|
||||
else
|
||||
$('.enter', @bubble).click(-> Backbone.Mediator.publish('end-current-script'))
|
||||
$('.enter', @bubble).click(-> Backbone.Mediator.publish('script:end-current-script'))
|
||||
return
|
||||
@animator.tick()
|
||||
|
||||
onShiftSpacePressed: (e) ->
|
||||
@shiftSpacePressed = (@shiftSpacePressed || 0) + 1
|
||||
# We don't need to handle end-current-script--that's done--but if we do have
|
||||
# We don't need to handle script:end-current-script--that's done--but if we do have
|
||||
# custom buttons, then we need to trigger the one that should fire (the last one).
|
||||
# If we decide that always having the last one fire is bad, we should make it smarter.
|
||||
return unless @lastResponses?.length
|
||||
|
|
|
@ -18,7 +18,7 @@ module.exports = class LevelLoadingView extends CocoView
|
|||
@shownReady = true
|
||||
ready = $.i18n.t('play_level.loading_ready', defaultValue: 'Ready!')
|
||||
@$el.find('#tip-wrapper .tip').addClass('ready').text ready
|
||||
Backbone.Mediator.publish 'play-sound', trigger: 'level_loaded', volume: 0.75 # old: loading_ready
|
||||
Backbone.Mediator.publish 'audio-player:play-sound', trigger: 'level_loaded', volume: 0.75 # old: loading_ready
|
||||
|
||||
unveil: ->
|
||||
_.delay @reallyUnveil, 1000
|
||||
|
|
|
@ -10,18 +10,18 @@ module.exports = class LevelPlaybackView extends CocoView
|
|||
template: template
|
||||
|
||||
subscriptions:
|
||||
'level-disable-controls': 'onDisableControls'
|
||||
'level-enable-controls': 'onEnableControls'
|
||||
'level-set-playing': 'onSetPlaying'
|
||||
'level-toggle-playing': 'onTogglePlay'
|
||||
'level-scrub-forward': 'onScrubForward'
|
||||
'level-scrub-back': 'onScrubBack'
|
||||
'level-set-volume': 'onSetVolume'
|
||||
'level-set-debug': 'onSetDebug'
|
||||
'level:disable-controls': 'onDisableControls'
|
||||
'level:enable-controls': 'onEnableControls'
|
||||
'level:set-playing': 'onSetPlaying'
|
||||
'level:toggle-playing': 'onTogglePlay'
|
||||
'level:scrub-forward': 'onScrubForward'
|
||||
'level:scrub-back': 'onScrubBack'
|
||||
'level:set-volume': 'onSetVolume'
|
||||
'level:set-debug': 'onSetDebug'
|
||||
'surface:frame-changed': 'onFrameChanged'
|
||||
'god:new-world-created': 'onNewWorld'
|
||||
'god:streaming-world-updated': 'onNewWorld'
|
||||
'level-set-letterbox': 'onSetLetterbox'
|
||||
'level:set-letterbox': 'onSetLetterbox'
|
||||
'tome:cast-spells': 'onTomeCast'
|
||||
'playback:real-time-playback-ended': 'onRealTimePlaybackEnded'
|
||||
'playback:stop-real-time-playback': 'onStopRealTimePlayback'
|
||||
|
@ -32,8 +32,8 @@ module.exports = class LevelPlaybackView extends CocoView
|
|||
'click #edit-editor-config': 'onEditEditorConfig'
|
||||
'click #view-keyboard-shortcuts': 'onViewKeyboardShortcuts'
|
||||
'click #music-button': 'onToggleMusic'
|
||||
'click #zoom-in-button': -> Backbone.Mediator.publish('camera-zoom-in', {}) unless @shouldIgnore()
|
||||
'click #zoom-out-button': -> Backbone.Mediator.publish('camera-zoom-out', {}) unless @shouldIgnore()
|
||||
'click #zoom-in-button': -> Backbone.Mediator.publish 'camera:zoom-in', {} unless @shouldIgnore()
|
||||
'click #zoom-out-button': -> Backbone.Mediator.publish 'camera:zoom-out', {} unless @shouldIgnore()
|
||||
'click #volume-button': 'onToggleVolume'
|
||||
'click #play-button': 'onTogglePlay'
|
||||
'click': -> Backbone.Mediator.publish 'tome:focus-editor', {} unless @realTime
|
||||
|
@ -183,10 +183,10 @@ module.exports = class LevelPlaybackView extends CocoView
|
|||
onToggleDebug: ->
|
||||
return if @shouldIgnore()
|
||||
flag = $('#debug-toggle i.icon-ok')
|
||||
Backbone.Mediator.publish('level-set-debug', {debug: flag.hasClass('invisible')})
|
||||
Backbone.Mediator.publish('level:set-debug', {debug: flag.hasClass('invisible')})
|
||||
|
||||
onEditWizardSettings: ->
|
||||
Backbone.Mediator.publish 'edit-wizard-settings'
|
||||
Backbone.Mediator.publish 'level:edit-wizard-settings', {}
|
||||
|
||||
onEditEditorConfig: ->
|
||||
@openModalView new EditorConfigModal session: @options.session
|
||||
|
@ -236,7 +236,7 @@ module.exports = class LevelPlaybackView extends CocoView
|
|||
onScrub: (e, options) ->
|
||||
e?.preventDefault()
|
||||
options.scrubDuration = 500
|
||||
Backbone.Mediator.publish('level-set-time', options)
|
||||
Backbone.Mediator.publish('level:set-time', options)
|
||||
|
||||
onScrubForward: (e) ->
|
||||
@onScrub e, ratioOffset: 0.05
|
||||
|
@ -324,16 +324,16 @@ module.exports = class LevelPlaybackView extends CocoView
|
|||
return if @shouldIgnore()
|
||||
@slideCount = 0
|
||||
@wasPlaying = @playing
|
||||
Backbone.Mediator.publish 'level-set-playing', {playing: false}
|
||||
Backbone.Mediator.publish 'level:set-playing', {playing: false}
|
||||
|
||||
stop: (event, ui) =>
|
||||
return if @shouldIgnore()
|
||||
@actualProgress = ui.value / @sliderIncrements
|
||||
Backbone.Mediator.publish 'playback:manually-scrubbed', ratio: @actualProgress
|
||||
Backbone.Mediator.publish 'level-set-playing', {playing: @wasPlaying}
|
||||
Backbone.Mediator.publish 'playback:manually-scrubbed', ratio: @actualProgress # For scripts
|
||||
Backbone.Mediator.publish 'level:set-playing', {playing: @wasPlaying}
|
||||
if @slideCount < 3
|
||||
@wasPlaying = false
|
||||
Backbone.Mediator.publish 'level-set-playing', {playing: false}
|
||||
Backbone.Mediator.publish 'level:set-playing', {playing: false}
|
||||
@$el.find('.scrubber-handle').effect('bounce', {times: 2})
|
||||
)
|
||||
|
||||
|
@ -342,7 +342,7 @@ module.exports = class LevelPlaybackView extends CocoView
|
|||
|
||||
scrubTo: (ratio, duration=0) ->
|
||||
return if @shouldIgnore()
|
||||
Backbone.Mediator.publish 'level-set-time', ratio: ratio, scrubDuration: duration
|
||||
Backbone.Mediator.publish 'level:set-time', ratio: ratio, scrubDuration: duration
|
||||
|
||||
shouldIgnore: -> return @disabled or @realTime
|
||||
|
||||
|
@ -351,7 +351,7 @@ module.exports = class LevelPlaybackView extends CocoView
|
|||
return if @shouldIgnore()
|
||||
button = $('#play-button')
|
||||
willPlay = button.hasClass('paused') or button.hasClass('ended')
|
||||
Backbone.Mediator.publish 'level-set-playing', playing: willPlay
|
||||
Backbone.Mediator.publish 'level:set-playing', playing: willPlay
|
||||
$(document.activeElement).blur()
|
||||
|
||||
onToggleVolume: (e) ->
|
||||
|
@ -364,7 +364,7 @@ module.exports = class LevelPlaybackView extends CocoView
|
|||
break
|
||||
else if i is classes.length - 1 # no oldClass
|
||||
newI = 2
|
||||
Backbone.Mediator.publish 'level-set-volume', volume: volumes[newI]
|
||||
Backbone.Mediator.publish 'level:set-volume', volume: volumes[newI]
|
||||
$(document.activeElement).blur()
|
||||
|
||||
onToggleMusic: (e) ->
|
||||
|
|
|
@ -44,24 +44,23 @@ module.exports = class PlayLevelView extends RootView
|
|||
isEditorPreview: false
|
||||
|
||||
subscriptions:
|
||||
'level-set-volume': (e) -> createjs.Sound.setVolume(e.volume)
|
||||
'level-show-victory': 'onShowVictory'
|
||||
'restart-level': 'onRestartLevel'
|
||||
'level-highlight-dom': 'onHighlightDom'
|
||||
'end-level-highlight-dom': 'onEndHighlight'
|
||||
'level-focus-dom': 'onFocusDom'
|
||||
'level-disable-controls': 'onDisableControls'
|
||||
'level-enable-controls': 'onEnableControls'
|
||||
'level:set-volume': (e) -> createjs.Sound.setVolume(e.volume)
|
||||
'level:show-victory': 'onShowVictory'
|
||||
'level:restart': 'onRestartLevel'
|
||||
'level:highlight-dom': 'onHighlightDom'
|
||||
'level:end-highlight-dom': 'onEndHighlight'
|
||||
'level:focus-dom': 'onFocusDom'
|
||||
'level:disable-controls': 'onDisableControls'
|
||||
'level:enable-controls': 'onEnableControls'
|
||||
'god:new-world-created': 'onNewWorld'
|
||||
'god:streaming-world-updated': 'onNewWorld'
|
||||
'god:infinite-loop': 'onInfiniteLoop'
|
||||
'level-reload-from-data': 'onLevelReloadFromData'
|
||||
'level-reload-thang-type': 'onLevelReloadThangType'
|
||||
'play-next-level': 'onPlayNextLevel'
|
||||
'edit-wizard-settings': 'showWizardSettingsModal'
|
||||
'level:reload-from-data': 'onLevelReloadFromData'
|
||||
'level:reload-thang-type': 'onLevelReloadThangType'
|
||||
'level:play-next-level': 'onPlayNextLevel'
|
||||
'level:edit-wizard-settings': 'showWizardSettingsModal'
|
||||
'surface:world-set-up': 'onSurfaceSetUpNewWorld'
|
||||
'level:session-will-save': 'onSessionWillSave'
|
||||
'level:set-team': 'setTeam'
|
||||
'level:started': 'onLevelStarted'
|
||||
'level:loading-view-unveiled': 'onLoadingViewUnveiled'
|
||||
'playback:real-time-playback-started': 'onRealTimePlaybackStarted'
|
||||
|
@ -143,13 +142,13 @@ module.exports = class PlayLevelView extends RootView
|
|||
supermodel: @supermodel
|
||||
firstOnly: true
|
||||
@openModalView(new LevelGuideModal(options), true)
|
||||
onGuideOpened = ->
|
||||
onGuideOpened = (e) ->
|
||||
@guideOpenTime = new Date()
|
||||
onGuideClosed = ->
|
||||
onGuideClosed = (e) ->
|
||||
application.tracker?.trackTiming new Date() - @guideOpenTime, 'Intro Guide Time', @levelID, @levelID, 100
|
||||
@onLevelStarted()
|
||||
Backbone.Mediator.subscribeOnce 'modal-opened', onGuideOpened, @
|
||||
Backbone.Mediator.subscribeOnce 'modal-closed', onGuideClosed, @
|
||||
Backbone.Mediator.subscribeOnce 'modal:opened', onGuideOpened, @
|
||||
Backbone.Mediator.subscribeOnce 'modal:closed', onGuideClosed, @
|
||||
return true
|
||||
|
||||
getRenderData: ->
|
||||
|
@ -224,7 +223,7 @@ module.exports = class PlayLevelView extends RootView
|
|||
team = team?.team unless _.isString team
|
||||
team ?= 'humans'
|
||||
me.team = team
|
||||
Backbone.Mediator.publish 'level:team-set', team: team
|
||||
Backbone.Mediator.publish 'level:team-set', team: team # Needed for scripts
|
||||
@team = team
|
||||
|
||||
initGoalManager: ->
|
||||
|
@ -241,12 +240,12 @@ module.exports = class PlayLevelView extends RootView
|
|||
@insertSubView new ChatView levelID: @levelID, sessionID: @session.id, session: @session
|
||||
worldName = utils.i18n @level.attributes, 'name'
|
||||
@controlBar = @insertSubView new ControlBarView {worldName: worldName, session: @session, level: @level, supermodel: @supermodel, playableTeams: @world.playableTeams}
|
||||
#Backbone.Mediator.publish('level-set-debug', debug: true) if me.displayName() is 'Nick'
|
||||
#Backbone.Mediator.publish('level:set-debug', debug: true) if me.displayName() is 'Nick'
|
||||
|
||||
initVolume: ->
|
||||
volume = me.get('volume')
|
||||
volume = 1.0 unless volume?
|
||||
Backbone.Mediator.publish 'level-set-volume', volume: volume
|
||||
Backbone.Mediator.publish 'level:set-volume', volume: volume
|
||||
|
||||
initScriptManager: ->
|
||||
@scriptManager = new ScriptManager({scripts: @world.scripts or [], view: @, session: @session})
|
||||
|
@ -289,7 +288,7 @@ module.exports = class PlayLevelView extends RootView
|
|||
return unless @surface?
|
||||
@loadingView.showReady()
|
||||
if window.currentModal and not window.currentModal.destroyed
|
||||
return Backbone.Mediator.subscribeOnce 'modal-closed', @onLevelStarted, @
|
||||
return Backbone.Mediator.subscribeOnce 'modal:closed', @onLevelStarted, @
|
||||
@surface.showLevel()
|
||||
if @otherSession
|
||||
# TODO: colorize name and cloud by team, colorize wizard by user's color config
|
||||
|
@ -312,12 +311,12 @@ module.exports = class PlayLevelView extends RootView
|
|||
@alreadyLoadedState = true
|
||||
state = @originalSessionState
|
||||
if state.frame and @level.get('type') isnt 'ladder' # https://github.com/codecombat/codecombat/issues/714
|
||||
Backbone.Mediator.publish 'level-set-time', { time: 0, frameOffset: state.frame }
|
||||
Backbone.Mediator.publish 'level:set-time', time: 0, frameOffset: state.frame
|
||||
if state.selected
|
||||
# TODO: Should also restore selected spell here by saving spellName
|
||||
Backbone.Mediator.publish 'level-select-sprite', { thangID: state.selected, spellName: null }
|
||||
Backbone.Mediator.publish 'level:select-sprite', thangID: state.selected, spellName: null
|
||||
if state.playing?
|
||||
Backbone.Mediator.publish 'level-set-playing', { playing: state.playing }
|
||||
Backbone.Mediator.publish 'level:set-playing', playing: state.playing
|
||||
|
||||
# callbacks
|
||||
|
||||
|
@ -377,7 +376,7 @@ module.exports = class PlayLevelView extends RootView
|
|||
|
||||
onRestartLevel: ->
|
||||
@tome.reloadAllCode()
|
||||
Backbone.Mediator.publish 'level:restarted'
|
||||
Backbone.Mediator.publish 'level:restarted', {}
|
||||
$('#level-done-button', @$el).hide()
|
||||
application.tracker?.trackEvent 'Confirmed Restart', level: @level.get('name'), label: @level.get('name')
|
||||
|
||||
|
@ -421,7 +420,6 @@ module.exports = class PlayLevelView extends RootView
|
|||
return if not offset
|
||||
target_left = offset.left + dom.outerWidth() * 0.5
|
||||
target_top = offset.top + dom.outerHeight() * 0.5
|
||||
body = $('#level-view')
|
||||
|
||||
if e.sides
|
||||
if 'left' in e.sides then target_left = offset.left
|
||||
|
@ -430,15 +428,15 @@ module.exports = class PlayLevelView extends RootView
|
|||
if 'bottom' in e.sides then target_top = offset.top + dom.outerHeight()
|
||||
else
|
||||
# aim to hit the side if the target is entirely on one side of the screen
|
||||
if offset.left > body.outerWidth()*0.5
|
||||
if offset.left > @$el.outerWidth()*0.5
|
||||
target_left = offset.left
|
||||
else if offset.left + dom.outerWidth() < body.outerWidth()*0.5
|
||||
else if offset.left + dom.outerWidth() < @$el.outerWidth()*0.5
|
||||
target_left = offset.left + dom.outerWidth()
|
||||
|
||||
# aim to hit the bottom or top if the target is entirely on the top or bottom of the screen
|
||||
if offset.top > body.outerWidth()*0.5
|
||||
if offset.top > @$el.outerWidth()*0.5
|
||||
target_top = offset.top
|
||||
else if offset.top + dom.outerHeight() < body.outerHeight()*0.5
|
||||
else if offset.top + dom.outerHeight() < @$el.outerHeight()*0.5
|
||||
target_top = offset.top + dom.outerHeight()
|
||||
|
||||
if e.offset
|
||||
|
@ -446,7 +444,7 @@ module.exports = class PlayLevelView extends RootView
|
|||
target_top += e.offset.y
|
||||
|
||||
@pointerRadialDistance = -47 # - Math.sqrt(Math.pow(dom.outerHeight()*0.5, 2), Math.pow(dom.outerWidth()*0.5))
|
||||
@pointerRotation = e.rotation ? Math.atan2(body.outerWidth()*0.5 - target_left, target_top - body.outerHeight()*0.5)
|
||||
@pointerRotation = e.rotation ? Math.atan2(@$el.outerWidth()*0.5 - target_left, target_top - @$el.outerHeight()*0.5)
|
||||
pointer = $('#pointer')
|
||||
pointer
|
||||
.css('opacity', 1.0)
|
||||
|
@ -465,7 +463,7 @@ module.exports = class PlayLevelView extends RootView
|
|||
pointer = $('#pointer')
|
||||
pointer.css('transition', 'all 0.6s ease-out')
|
||||
pointer.css('transform', "rotate(#{@pointerRotation}rad) translate(-3px, #{@pointerRadialDistance-50}px)")
|
||||
Backbone.Mediator.publish 'play-sound', trigger: 'dom_highlight', volume: 0.75
|
||||
Backbone.Mediator.publish 'audio-player:play-sound', trigger: 'dom_highlight', volume: 0.75
|
||||
setTimeout((=>
|
||||
pointer.css('transform', "rotate(#{@pointerRotation}rad) translate(-3px, #{@pointerRadialDistance}px)").css('transition', 'all 0.4s ease-in')), 800)
|
||||
|
||||
|
|
|
@ -6,6 +6,6 @@ module.exports = class InfiniteLoopModal extends ModalView
|
|||
template: template
|
||||
|
||||
events:
|
||||
'click #restart-level-infinite-loop-retry-button': -> Backbone.Mediator.publish 'tome:cast-spell'
|
||||
'click #restart-level-infinite-loop-confirm-button': -> Backbone.Mediator.publish 'restart-level'
|
||||
'click #restart-level-infinite-loop-comment-button': -> Backbone.Mediator.publish 'tome:comment-my-code'
|
||||
'click #restart-level-infinite-loop-retry-button': -> Backbone.Mediator.publish 'tome:cast-spell', {}
|
||||
'click #restart-level-infinite-loop-confirm-button': -> Backbone.Mediator.publish 'level:restart', {}
|
||||
'click #restart-level-infinite-loop-comment-button': -> Backbone.Mediator.publish 'tome:comment-my-code', {}
|
||||
|
|
|
@ -52,7 +52,7 @@ module.exports = class LevelGuideModal extends ModalView
|
|||
|
||||
afterInsert: ->
|
||||
super()
|
||||
Backbone.Mediator.publish 'level:docs-shown'
|
||||
Backbone.Mediator.publish 'level:docs-shown', {}
|
||||
|
||||
onHidden: ->
|
||||
Backbone.Mediator.publish 'level:docs-hidden'
|
||||
Backbone.Mediator.publish 'level:docs-hidden', {}
|
||||
|
|
|
@ -59,7 +59,7 @@ module.exports = class VictoryModal extends ModalView
|
|||
|
||||
onPlayNextLevel: ->
|
||||
@saveReview() if @$el.find('.review textarea').val()
|
||||
Backbone.Mediator.publish('play-next-level')
|
||||
Backbone.Mediator.publish 'level:play-next-level', {}
|
||||
|
||||
onGameSubmitted: (e) ->
|
||||
ladderURL = "/play/ladder/#{@level.get('slug')}#my-matches"
|
||||
|
@ -95,14 +95,11 @@ module.exports = class VictoryModal extends ModalView
|
|||
|
||||
afterInsert: ->
|
||||
super()
|
||||
Backbone.Mediator.publish 'play-sound', trigger: 'victory'
|
||||
Backbone.Mediator.publish 'audio-player:play-sound', trigger: 'victory'
|
||||
gapi?.plusone?.go? @$el[0]
|
||||
FB?.XFBML?.parse? @$el[0]
|
||||
twttr?.widgets?.load?()
|
||||
|
||||
onHidden: ->
|
||||
Backbone.Mediator.publish 'level:victory-hidden'
|
||||
|
||||
destroy: ->
|
||||
@saveReview() if @$el.find('.review textarea').val()
|
||||
@feedback.off()
|
||||
|
|
|
@ -51,7 +51,7 @@ module.exports = class CastButtonView extends CocoView
|
|||
Backbone.Mediator.publish 'tome:manual-cast', {realTime: true}
|
||||
|
||||
onCastOptionsClick: (e) =>
|
||||
Backbone.Mediator.publish 'tome:focus-editor'
|
||||
Backbone.Mediator.publish 'tome:focus-editor', {}
|
||||
@castButtonGroup.removeClass 'open'
|
||||
@setAutocastDelay $(e.target).attr 'data-delay'
|
||||
false
|
||||
|
@ -63,7 +63,7 @@ module.exports = class CastButtonView extends CocoView
|
|||
return if e.preload
|
||||
@casting = true
|
||||
if @hasStartedCastingOnce # Don't play this sound the first time
|
||||
Backbone.Mediator.publish 'play-sound', trigger: 'cast', volume: 0.5
|
||||
Backbone.Mediator.publish 'audio-player:play-sound', trigger: 'cast', volume: 0.5
|
||||
@hasStartedCastingOnce = true
|
||||
@updateCastButton()
|
||||
@onWorldLoadProgressChanged progress: 0
|
||||
|
@ -76,7 +76,7 @@ module.exports = class CastButtonView extends CocoView
|
|||
onNewWorld: (e) ->
|
||||
@casting = false
|
||||
if @hasCastOnce # Don't play this sound the first time
|
||||
Backbone.Mediator.publish 'play-sound', trigger: 'cast-end', volume: 0.5
|
||||
Backbone.Mediator.publish 'audio-player:play-sound', trigger: 'cast-end', volume: 0.5
|
||||
@hasCastOnce = true
|
||||
@updateCastButton()
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@ module.exports = class ProblemAlertView extends CocoView
|
|||
super()
|
||||
@$el.addClass('alert').addClass("alert-#{@problem.aetherProblem.level}").hide().fadeIn('slow')
|
||||
@$el.addClass('no-hint') unless @problem.aetherProblem.hint
|
||||
Backbone.Mediator.publish 'play-sound', trigger: 'error_appear', volume: 1.0
|
||||
Backbone.Mediator.publish 'audio-player:play-sound', trigger: 'error_appear', volume: 1.0
|
||||
|
||||
onRemoveClicked: ->
|
||||
@$el.remove()
|
||||
|
|
|
@ -102,15 +102,15 @@ module.exports = class SpellDebugView extends CocoView
|
|||
@thang = thangAndSpellObject.thang
|
||||
@spell = thangAndSpellObject.spell
|
||||
|
||||
handleDebugValue: (returnObject) ->
|
||||
handleDebugValue: (e) ->
|
||||
{key, value} = e
|
||||
@workerIsSimulating = false
|
||||
{key, value} = returnObject
|
||||
@updateCache(@thang.id, @spell.name, key.split('.'), @lastFrameRequested, value)
|
||||
if @variableChain and not key is @variableChain.join('.') then return
|
||||
@setTooltipKeyAndValue(key, value)
|
||||
|
||||
handleWorldLoadProgressChanged: (data) ->
|
||||
@progress = data.progress
|
||||
handleWorldLoadProgressChanged: (e) ->
|
||||
@progress = e.progress
|
||||
|
||||
afterRender: ->
|
||||
super()
|
||||
|
|
|
@ -30,7 +30,7 @@ module.exports = class SpellListEntryThangsView extends CocoView
|
|||
avatar.render()
|
||||
avatar.setSelected thang is @thang
|
||||
avatar.$el.data('thang-id', thang.id).click (e) ->
|
||||
Backbone.Mediator.publish 'level-select-sprite', thangID: $(@).data('thang-id'), spellName: spellName
|
||||
Backbone.Mediator.publish 'level:select-sprite', thangID: $(@).data('thang-id'), spellName: spellName
|
||||
avatar.onProblemsUpdated spell: @spell
|
||||
@avatars.push avatar
|
||||
|
||||
|
|
|
@ -14,8 +14,8 @@ module.exports = class SpellListEntryView extends CocoView
|
|||
subscriptions:
|
||||
'tome:problems-updated': 'onProblemsUpdated'
|
||||
'tome:spell-changed-language': 'onSpellChangedLanguage'
|
||||
'level-disable-controls': 'onDisableControls'
|
||||
'level-enable-controls': 'onEnableControls'
|
||||
'level:disable-controls': 'onDisableControls'
|
||||
'level:enable-controls': 'onEnableControls'
|
||||
'god:new-world-created': 'onNewWorld'
|
||||
|
||||
events:
|
||||
|
@ -88,7 +88,7 @@ module.exports = class SpellListEntryView extends CocoView
|
|||
|
||||
onClick: (e) ->
|
||||
spellThang = @getPrimarySpellThang()
|
||||
Backbone.Mediator.publish 'level-select-sprite', thangID: spellThang.thang.id, spellName: @spell.name
|
||||
Backbone.Mediator.publish 'level:select-sprite', thangID: spellThang.thang.id, spellName: @spell.name
|
||||
|
||||
onMouseEnterAvatar: (e) ->
|
||||
return unless @controlsEnabled and _.size(@spell.thangs) > 1
|
||||
|
|
|
@ -10,8 +10,8 @@ module.exports = class SpellListTabEntryView extends SpellListEntryView
|
|||
id: 'spell-list-tab-entry-view'
|
||||
|
||||
subscriptions:
|
||||
'level-disable-controls': 'onDisableControls'
|
||||
'level-enable-controls': 'onEnableControls'
|
||||
'level:disable-controls': 'onDisableControls'
|
||||
'level:enable-controls': 'onEnableControls'
|
||||
'tome:spell-loaded': 'onSpellLoaded'
|
||||
'tome:spell-changed': 'onSpellChanged'
|
||||
'god:new-world-created': 'onNewWorld'
|
||||
|
@ -84,7 +84,7 @@ module.exports = class SpellListTabEntryView extends SpellListEntryView
|
|||
|
||||
onDropdownClick: (e) ->
|
||||
return unless @controlsEnabled
|
||||
Backbone.Mediator.publish 'tome:toggle-spell-list'
|
||||
Backbone.Mediator.publish 'tome:toggle-spell-list', {}
|
||||
|
||||
onCodeReload: ->
|
||||
return unless @controlsEnabled
|
||||
|
@ -92,7 +92,7 @@ module.exports = class SpellListTabEntryView extends SpellListEntryView
|
|||
|
||||
onBeautifyClick: ->
|
||||
return unless @controlsEnabled
|
||||
Backbone.Mediator.publish 'spell-beautify', spell: @spell
|
||||
Backbone.Mediator.publish 'tome:spell-beautify', spell: @spell
|
||||
|
||||
onFullscreenClick: ->
|
||||
$codearea = $('html')
|
||||
|
@ -140,7 +140,7 @@ module.exports = class SpellListTabEntryView extends SpellListEntryView
|
|||
attachTransitionEventListener: =>
|
||||
transitionListener = ''
|
||||
testEl = document.createElement 'fakeelement'
|
||||
transitions =
|
||||
transitions =
|
||||
'transition':'transitionend'
|
||||
'OTransition':'oTransitionEnd'
|
||||
'MozTransition':'transitionend'
|
||||
|
|
|
@ -14,8 +14,8 @@ module.exports = class SpellPaletteView extends CocoView
|
|||
controlsEnabled: true
|
||||
|
||||
subscriptions:
|
||||
'level-disable-controls': 'onDisableControls'
|
||||
'level-enable-controls': 'onEnableControls'
|
||||
'level:disable-controls': 'onDisableControls'
|
||||
'level:enable-controls': 'onEnableControls'
|
||||
'surface:frame-changed': 'onFrameChanged'
|
||||
'tome:change-language': 'onTomeChangedLanguage'
|
||||
|
||||
|
|
|
@ -7,8 +7,8 @@ module.exports = class SpellToolbarView extends CocoView
|
|||
progressHoverDelay: 500
|
||||
|
||||
subscriptions:
|
||||
'spell-step-backward': 'onStepBackward'
|
||||
'spell-step-forward': 'onStepForward'
|
||||
'tome:spell-step-backward': 'onStepBackward'
|
||||
'tome:spell-step-forward': 'onStepForward'
|
||||
|
||||
events:
|
||||
'mousemove .spell-progress': 'onProgressHover'
|
||||
|
@ -100,7 +100,7 @@ module.exports = class SpellToolbarView extends CocoView
|
|||
@maintainIndexScrub = true
|
||||
clearTimeout @maintainIndexScrubTimeout if @maintainIndexScrubTimeout
|
||||
@maintainIndexScrubTimeout = _.delay (=> @maintainIndexScrub = false), 500
|
||||
Backbone.Mediator.publish 'level-set-time', time: @statementTime, scrubDuration: 500
|
||||
Backbone.Mediator.publish 'level:set-time', time: @statementTime, scrubDuration: 500
|
||||
|
||||
updateScroll: ->
|
||||
return unless statementStart = @callState?.statements?[@statementIndex]?.range[0]
|
||||
|
|
|
@ -31,8 +31,8 @@ module.exports = class SpellView extends CocoView
|
|||
'emacs': 'ace/keyboard/emacs'
|
||||
|
||||
subscriptions:
|
||||
'level-disable-controls': 'onDisableControls'
|
||||
'level-enable-controls': 'onEnableControls'
|
||||
'level:disable-controls': 'onDisableControls'
|
||||
'level:enable-controls': 'onEnableControls'
|
||||
'surface:frame-changed': 'onFrameChanged'
|
||||
'surface:coordinate-selected': 'onCoordinateSelected'
|
||||
'god:new-world-created': 'onNewWorld'
|
||||
|
@ -42,14 +42,14 @@ module.exports = class SpellView extends CocoView
|
|||
'tome:reload-code': 'onCodeReload'
|
||||
'tome:spell-changed': 'onSpellChanged'
|
||||
'level:session-will-save': 'onSessionWillSave'
|
||||
'modal-closed': 'focus'
|
||||
'modal:closed': 'focus'
|
||||
'tome:focus-editor': 'focus'
|
||||
'tome:spell-statement-index-updated': 'onStatementIndexUpdated'
|
||||
'tome:change-language': 'onChangeLanguage'
|
||||
'tome:change-config': 'onChangeEditorConfig'
|
||||
'tome:update-snippets': 'addZatannaSnippets'
|
||||
'tome:insert-snippet': 'onInsertSnippet'
|
||||
'spell-beautify': 'onSpellBeautify'
|
||||
'tome:spell-beautify': 'onSpellBeautify'
|
||||
'script:state-changed': 'onScriptStateChange'
|
||||
|
||||
events:
|
||||
|
@ -125,7 +125,7 @@ module.exports = class SpellView extends CocoView
|
|||
addCommand
|
||||
name: 'toggle-playing'
|
||||
bindKey: {win: 'Ctrl-P', mac: 'Command-P|Ctrl-P'}
|
||||
exec: -> Backbone.Mediator.publish 'level-toggle-playing'
|
||||
exec: -> Backbone.Mediator.publish 'level:toggle-playing', {}
|
||||
addCommand
|
||||
name: 'end-current-script'
|
||||
bindKey: {win: 'Shift-Space', mac: 'Shift-Space'}
|
||||
|
@ -134,46 +134,46 @@ module.exports = class SpellView extends CocoView
|
|||
# Maybe we could temporarily set ourselves to read-only if we somehow know that a script is active?
|
||||
exec: =>
|
||||
if @scriptRunning
|
||||
Backbone.Mediator.publish 'level:shift-space-pressed'
|
||||
Backbone.Mediator.publish 'level:shift-space-pressed', {}
|
||||
else
|
||||
@ace.insert ' '
|
||||
|
||||
addCommand
|
||||
name: 'end-all-scripts'
|
||||
bindKey: {win: 'Escape', mac: 'Escape'}
|
||||
exec: -> Backbone.Mediator.publish 'level:escape-pressed'
|
||||
exec: -> Backbone.Mediator.publish 'level:escape-pressed', {}
|
||||
addCommand
|
||||
name: 'toggle-grid'
|
||||
bindKey: {win: 'Ctrl-G', mac: 'Command-G|Ctrl-G'}
|
||||
exec: -> Backbone.Mediator.publish 'level-toggle-grid'
|
||||
exec: -> Backbone.Mediator.publish 'level:toggle-grid', {}
|
||||
addCommand
|
||||
name: 'toggle-debug'
|
||||
bindKey: {win: 'Ctrl-\\', mac: 'Command-\\|Ctrl-\\'}
|
||||
exec: -> Backbone.Mediator.publish 'level-toggle-debug'
|
||||
exec: -> Backbone.Mediator.publish 'level:toggle-debug', {}
|
||||
addCommand
|
||||
name: 'toggle-pathfinding'
|
||||
bindKey: {win: 'Ctrl-O', mac: 'Command-O|Ctrl-O'}
|
||||
exec: -> Backbone.Mediator.publish 'level-toggle-pathfinding'
|
||||
exec: -> Backbone.Mediator.publish 'level:toggle-pathfinding', {}
|
||||
addCommand
|
||||
name: 'level-scrub-forward'
|
||||
bindKey: {win: 'Ctrl-]', mac: 'Command-]|Ctrl-]'}
|
||||
exec: -> Backbone.Mediator.publish 'level-scrub-forward'
|
||||
exec: -> Backbone.Mediator.publish 'level:scrub-forward', {}
|
||||
addCommand
|
||||
name: 'level-scrub-back'
|
||||
bindKey: {win: 'Ctrl-[', mac: 'Command-[|Ctrl-]'}
|
||||
exec: -> Backbone.Mediator.publish 'level-scrub-back'
|
||||
exec: -> Backbone.Mediator.publish 'level:scrub-back', {}
|
||||
addCommand
|
||||
name: 'spell-step-forward'
|
||||
bindKey: {win: 'Ctrl-Alt-]', mac: 'Command-Alt-]|Ctrl-Alt-]'}
|
||||
exec: -> Backbone.Mediator.publish 'spell-step-forward'
|
||||
exec: -> Backbone.Mediator.publish 'tome:spell-step-forward', {}
|
||||
addCommand
|
||||
name: 'spell-step-backward'
|
||||
bindKey: {win: 'Ctrl-Alt-[', mac: 'Command-Alt-[|Ctrl-Alt-]'}
|
||||
exec: -> Backbone.Mediator.publish 'spell-step-backward'
|
||||
exec: -> Backbone.Mediator.publish 'tome:spell-step-backward', {}
|
||||
addCommand
|
||||
name: 'spell-beautify'
|
||||
bindKey: {win: 'Ctrl-Shift-B', mac: 'Command-Shift-B|Ctrl-Shift-B'}
|
||||
exec: -> Backbone.Mediator.publish 'spell-beautify'
|
||||
exec: -> Backbone.Mediator.publish 'tome:spell-beautify', {}
|
||||
addCommand
|
||||
name: 'prevent-line-jump'
|
||||
bindKey: {win: 'Ctrl-L', mac: 'Command-L'}
|
||||
|
@ -182,7 +182,7 @@ module.exports = class SpellView extends CocoView
|
|||
addCommand
|
||||
name: 'open-fullscreen-editor'
|
||||
bindKey: {win: 'Alt-Shift-F', mac: 'Ctrl-Shift-F'}
|
||||
exec: -> Backbone.Mediator.publish 'tome:fullscreen-view'
|
||||
exec: -> Backbone.Mediator.publish 'tome:fullscreen-view', {}
|
||||
|
||||
fillACE: ->
|
||||
@ace.setValue @spell.source
|
||||
|
@ -281,11 +281,11 @@ module.exports = class SpellView extends CocoView
|
|||
|
||||
notifyEditingEnded: =>
|
||||
return if @aceDoc.undergoingFirepadOperation # from my Firepad ACE adapter
|
||||
Backbone.Mediator.publish('tome:editing-ended')
|
||||
Backbone.Mediator.publish 'tome:editing-ended', {}
|
||||
|
||||
notifyEditingBegan: =>
|
||||
return if @aceDoc.undergoingFirepadOperation # from my Firepad ACE adapter
|
||||
Backbone.Mediator.publish('tome:editing-began')
|
||||
Backbone.Mediator.publish 'tome:editing-began', {}
|
||||
|
||||
onManualCast: (e) ->
|
||||
cast = @$el.parent().length
|
||||
|
|
|
@ -16,10 +16,10 @@ module.exports = class ThangListEntryView extends CocoView
|
|||
|
||||
subscriptions:
|
||||
'tome:problems-updated': 'onProblemsUpdated'
|
||||
'level-disable-controls': 'onDisableControls'
|
||||
'level-enable-controls': 'onEnableControls'
|
||||
'level:disable-controls': 'onDisableControls'
|
||||
'level:enable-controls': 'onEnableControls'
|
||||
'surface:frame-changed': 'onFrameChanged'
|
||||
'level-set-letterbox': 'onSetLetterbox'
|
||||
'level:set-letterbox': 'onSetLetterbox'
|
||||
'tome:thang-list-entry-popover-shown': 'onThangListEntryPopoverShown'
|
||||
'surface:coordinates-shown': 'onSurfaceCoordinatesShown'
|
||||
|
||||
|
@ -83,7 +83,7 @@ module.exports = class ThangListEntryView extends CocoView
|
|||
onClick: (e) ->
|
||||
return unless @controlsEnabled
|
||||
@sortSpells()
|
||||
Backbone.Mediator.publish 'level-select-sprite', thangID: @thang.id, spellName: @spells[0]?.name
|
||||
Backbone.Mediator.publish 'level:select-sprite', thangID: @thang.id, spellName: @spells[0]?.name
|
||||
|
||||
onMouseEnter: (e) ->
|
||||
return unless @controlsEnabled and @spells.length
|
||||
|
@ -122,7 +122,7 @@ module.exports = class ThangListEntryView extends CocoView
|
|||
@popover.mouseleave (e) => @hideSpells()
|
||||
thangID = @thang.id
|
||||
@popover.find('code').click (e) ->
|
||||
Backbone.Mediator.publish 'level-select-sprite', thangID: thangID, spellName: $(@).data 'spell-name'
|
||||
Backbone.Mediator.publish 'level:select-sprite', thangID: thangID, spellName: $(@).data 'spell-name'
|
||||
Backbone.Mediator.publish 'tome:thang-list-entry-popover-shown', entry: @
|
||||
|
||||
hideSpells: =>
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue