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