Merge branch 'master' into production
This commit is contained in:
commit
f4e30509e6
10 changed files with 59 additions and 32 deletions
|
@ -131,7 +131,9 @@ module.exports = class God extends CocoClass
|
||||||
Backbone.Mediator.publish 'god:debug-world-load-progress-changed', progress: event.data.progress
|
Backbone.Mediator.publish 'god:debug-world-load-progress-changed', progress: event.data.progress
|
||||||
|
|
||||||
onNewWorldCreated: (e) ->
|
onNewWorldCreated: (e) ->
|
||||||
|
console.log 'filtering', _.cloneDeep e.world.userCodeMap
|
||||||
@currentUserCodeMap = @filterUserCodeMapWhenFromWorld e.world.userCodeMap
|
@currentUserCodeMap = @filterUserCodeMapWhenFromWorld e.world.userCodeMap
|
||||||
|
console.log ' ... filtered into', _.cloneDeep e.world.userCodeMap
|
||||||
|
|
||||||
filterUserCodeMapWhenFromWorld: (worldUserCodeMap) ->
|
filterUserCodeMapWhenFromWorld: (worldUserCodeMap) ->
|
||||||
newUserCodeMap = {}
|
newUserCodeMap = {}
|
||||||
|
|
|
@ -46,9 +46,7 @@ module.exports = class LevelBus extends Bus
|
||||||
incrementSessionPlaytime: =>
|
incrementSessionPlaytime: =>
|
||||||
if @playerIsIdle then return
|
if @playerIsIdle then return
|
||||||
@changedSessionProperties.playtime = true
|
@changedSessionProperties.playtime = true
|
||||||
if _.isNaN @session.get('playtime')
|
@session.set('playtime', (@session.get('playtime') ? 0) + 1)
|
||||||
@session.set 'playtime', 0 # Oops, corrupted some playtimes when moving to new defaults system. Fixed on 2014-10-06, but lost playtime data in between.
|
|
||||||
@session.set('playtime', @session.get('playtime', true) + 1)
|
|
||||||
|
|
||||||
onPoint: ->
|
onPoint: ->
|
||||||
return true unless @session?.get('multiplayer')
|
return true unless @session?.get('multiplayer')
|
||||||
|
|
|
@ -8,7 +8,7 @@ module.exports.createAetherOptions = (options) ->
|
||||||
aetherOptions =
|
aetherOptions =
|
||||||
functionName: options.functionName
|
functionName: options.functionName
|
||||||
protectAPI: not options.skipProtectAPI
|
protectAPI: not options.skipProtectAPI
|
||||||
includeFlow: false
|
includeFlow: options.includeFlow
|
||||||
yieldConditionally: options.functionName is 'plan'
|
yieldConditionally: options.functionName is 'plan'
|
||||||
simpleLoops: true
|
simpleLoops: true
|
||||||
globals: ['Vector', '_']
|
globals: ['Vector', '_']
|
||||||
|
|
|
@ -442,7 +442,15 @@ module.exports = class World
|
||||||
perf = {}
|
perf = {}
|
||||||
perf.t0 = now()
|
perf.t0 = now()
|
||||||
nFrames = endFrame - startFrame
|
nFrames = endFrame - startFrame
|
||||||
w = streamingWorld ? new World o.userCodeMap, classMap
|
if streamingWorld
|
||||||
|
w = streamingWorld
|
||||||
|
# Make sure we get any Aether updates from the new frames into the already-deserialized streaming world Aethers.
|
||||||
|
for thangID, methods of o.userCodeMap
|
||||||
|
for methodName, serializedAether of methods
|
||||||
|
for aetherStateKey in ['flow', 'metrics', 'style', 'problems']
|
||||||
|
w.userCodeMap[thangID][methodName][aetherStateKey] = serializedAether[aetherStateKey]
|
||||||
|
else
|
||||||
|
w = new World o.userCodeMap, classMap
|
||||||
[w.totalFrames, w.maxTotalFrames, w.frameRate, w.dt, w.scriptNotes, w.victory] = [o.totalFrames, o.maxTotalFrames, o.frameRate, o.dt, o.scriptNotes ? [], o.victory]
|
[w.totalFrames, w.maxTotalFrames, w.frameRate, w.dt, w.scriptNotes, w.victory] = [o.totalFrames, o.maxTotalFrames, o.frameRate, o.dt, o.scriptNotes ? [], o.victory]
|
||||||
w[prop] = val for prop, val of o.trackedProperties
|
w[prop] = val for prop, val of o.trackedProperties
|
||||||
|
|
||||||
|
|
|
@ -58,7 +58,7 @@ module.exports =
|
||||||
entry: {type: 'object'}
|
entry: {type: 'object'}
|
||||||
|
|
||||||
'tome:spell-statement-index-updated': c.object {title: 'Spell Statement Index Updated', description: 'Published when the spell index is updated', required: ['statementIndex', 'ace']},
|
'tome:spell-statement-index-updated': c.object {title: 'Spell Statement Index Updated', description: 'Published when the spell index is updated', required: ['statementIndex', 'ace']},
|
||||||
statementIndex: {type: 'object'}
|
statementIndex: {type: 'integer'}
|
||||||
ace: {type: 'object'}
|
ace: {type: 'object'}
|
||||||
|
|
||||||
'tome:spell-beautify': c.object {title: 'Beautify', description: 'Published when you click the \'beautify\' button', required: []},
|
'tome:spell-beautify': c.object {title: 'Beautify', description: 'Published when you click the \'beautify\' button', required: []},
|
||||||
|
|
|
@ -17,8 +17,9 @@
|
||||||
.spell-progress
|
.spell-progress
|
||||||
position: absolute
|
position: absolute
|
||||||
height: 100%
|
height: 100%
|
||||||
width: 40%
|
top: -50px
|
||||||
left: 45%
|
width: 85%
|
||||||
|
left: 10%
|
||||||
display: inline-block
|
display: inline-block
|
||||||
cursor: pointer
|
cursor: pointer
|
||||||
box-sizing: border-box
|
box-sizing: border-box
|
||||||
|
|
|
@ -343,8 +343,8 @@ module.exports = class ThangsTabView extends CocoView
|
||||||
wasSelected = target.hasClass 'selected'
|
wasSelected = target.hasClass 'selected'
|
||||||
@$el.find('.add-thangs-palette .add-thang-palette-icon.selected').removeClass('selected')
|
@$el.find('.add-thangs-palette .add-thang-palette-icon.selected').removeClass('selected')
|
||||||
@selectAddThangType(if wasSelected then null else target.attr 'data-thang-type') unless key.alt or key.meta
|
@selectAddThangType(if wasSelected then null else target.attr 'data-thang-type') unless key.alt or key.meta
|
||||||
|
@addThangLank?.playSound? 'selected'
|
||||||
target.addClass('selected') if @addThangType
|
target.addClass('selected') if @addThangType
|
||||||
#false # was causing #1099, any reason to keep?
|
|
||||||
|
|
||||||
moveAddThangSelection: (direction) ->
|
moveAddThangSelection: (direction) ->
|
||||||
return unless @addThangType
|
return unless @addThangType
|
||||||
|
@ -366,7 +366,6 @@ module.exports = class ThangsTabView extends CocoView
|
||||||
@addThangLank = @surface.lankBoss.addThangToLanks thang, @surface.lankBoss.layerAdapters['Floating']
|
@addThangLank = @surface.lankBoss.addThangToLanks thang, @surface.lankBoss.layerAdapters['Floating']
|
||||||
@addThangLank.notOfThisWorld = true
|
@addThangLank.notOfThisWorld = true
|
||||||
@addThangLank.sprite.alpha = 0.75
|
@addThangLank.sprite.alpha = 0.75
|
||||||
@addThangLank.playSound? 'selected'
|
|
||||||
pos ?= x: Math.round(@world.width / 2), y: Math.round(@world.height / 2)
|
pos ?= x: Math.round(@world.width / 2), y: Math.round(@world.height / 2)
|
||||||
@adjustThangPos @addThangLank, thang, pos
|
@adjustThangPos @addThangLank, thang, pos
|
||||||
else
|
else
|
||||||
|
@ -399,9 +398,14 @@ module.exports = class ThangsTabView extends CocoView
|
||||||
thang
|
thang
|
||||||
|
|
||||||
adjustThangPos: (sprite, thang, pos) ->
|
adjustThangPos: (sprite, thang, pos) ->
|
||||||
snap = sprite?.data?.snap or sprite?.thangType?.get('snap') or {x: 0.01, y: 0.01} # Centimeter resolution by default
|
if key.shift
|
||||||
pos.x = Math.round((pos.x - (thang.width ? 1) / 2) / snap.x) * snap.x + (thang.width ? 1) / 2
|
# Meter resolution when holding shift, not caring about thang size.
|
||||||
pos.y = Math.round((pos.y - (thang.height ? 1) / 2) / snap.y) * snap.y + (thang.height ? 1) / 2
|
pos.x = Math.round pos.x
|
||||||
|
pos.y = Math.round pos.y
|
||||||
|
else
|
||||||
|
snap = sprite?.data?.snap or sprite?.thangType?.get('snap') or x: 0.01, y: 0.01 # Centimeter resolution by default
|
||||||
|
pos.x = Math.round((pos.x - (thang.width ? 1) / 2) / snap.x) * snap.x + (thang.width ? 1) / 2
|
||||||
|
pos.y = Math.round((pos.y - (thang.height ? 1) / 2) / snap.y) * snap.y + (thang.height ? 1) / 2
|
||||||
pos.z = thang.depth / 2
|
pos.z = thang.depth / 2
|
||||||
thang.pos = pos
|
thang.pos = pos
|
||||||
thang.stateChanged = true
|
thang.stateChanged = true
|
||||||
|
|
|
@ -19,6 +19,7 @@ module.exports = class Spell
|
||||||
@skipProtectAPI = options.skipProtectAPI
|
@skipProtectAPI = options.skipProtectAPI
|
||||||
@worker = options.worker
|
@worker = options.worker
|
||||||
@levelID = options.levelID
|
@levelID = options.levelID
|
||||||
|
@levelType = options.level.get('type', true)
|
||||||
|
|
||||||
p = options.programmableMethod
|
p = options.programmableMethod
|
||||||
@languages = p.languages ? {}
|
@languages = p.languages ? {}
|
||||||
|
@ -131,7 +132,7 @@ module.exports = class Spell
|
||||||
aceConfig = me.get('aceConfig') ? {}
|
aceConfig = me.get('aceConfig') ? {}
|
||||||
writable = @permissions.readwrite.length > 0
|
writable = @permissions.readwrite.length > 0
|
||||||
skipProtectAPI = @skipProtectAPI or not writable
|
skipProtectAPI = @skipProtectAPI or not writable
|
||||||
aetherOptions = createAetherOptions functionName: @name, codeLanguage: @language, functionParameters: @parameters, skipProtectAPI: skipProtectAPI
|
aetherOptions = createAetherOptions functionName: @name, codeLanguage: @language, functionParameters: @parameters, skipProtectAPI: skipProtectAPI, includeFlow: @levelType is 'hero'
|
||||||
aether = new Aether aetherOptions
|
aether = new Aether aetherOptions
|
||||||
if @worker
|
if @worker
|
||||||
workerMessage =
|
workerMessage =
|
||||||
|
|
|
@ -100,11 +100,7 @@ module.exports = class SpellView extends CocoView
|
||||||
@toggleControls null, @writable
|
@toggleControls null, @writable
|
||||||
@aceSession.selection.on 'changeCursor', @onCursorActivity
|
@aceSession.selection.on 'changeCursor', @onCursorActivity
|
||||||
$(@ace.container).find('.ace_gutter').on 'click', '.ace_error, .ace_warning, .ace_info', @onAnnotationClick
|
$(@ace.container).find('.ace_gutter').on 'click', '.ace_error, .ace_warning, .ace_info', @onAnnotationClick
|
||||||
# TODO: restore Zatanna when it totally stops the this.this.moveRight()(); problem
|
@initAutocomplete aceConfig.liveCompletion ? true
|
||||||
#@zatanna = new Zatanna @ace,
|
|
||||||
# liveCompletion: aceConfig.liveCompletion ? true
|
|
||||||
# completers:
|
|
||||||
# keywords: false
|
|
||||||
|
|
||||||
createACEShortcuts: ->
|
createACEShortcuts: ->
|
||||||
@aceCommands = aceCommands = []
|
@aceCommands = aceCommands = []
|
||||||
|
@ -191,8 +187,24 @@ module.exports = class SpellView extends CocoView
|
||||||
@aceSession.setUndoManager(new UndoManager())
|
@aceSession.setUndoManager(new UndoManager())
|
||||||
@ace.clearSelection()
|
@ace.clearSelection()
|
||||||
|
|
||||||
|
initAutocomplete: (@autocomplete) ->
|
||||||
|
# TODO: Turn on more autocompletion based on level sophistication
|
||||||
|
# TODO: E.g. using the language default snippets yields a bunch of crazy non-beginner suggestions
|
||||||
|
# TODO: Options logic shouldn't exist both here and in updateAutocomplete()
|
||||||
|
@zatanna = new Zatanna @ace,
|
||||||
|
basic: false
|
||||||
|
liveCompletion: false
|
||||||
|
snippets: @autocomplete
|
||||||
|
snippetsLangDefaults: false
|
||||||
|
completers:
|
||||||
|
keywords: false
|
||||||
|
text: false
|
||||||
|
|
||||||
|
updateAutocomplete: (@autocomplete) ->
|
||||||
|
@zatanna?.set 'snippets', @autocomplete
|
||||||
|
|
||||||
addZatannaSnippets: (e) ->
|
addZatannaSnippets: (e) ->
|
||||||
return unless @zatanna
|
return unless @zatanna and @autocomplete
|
||||||
snippetEntries = []
|
snippetEntries = []
|
||||||
for owner, props of e.propGroups
|
for owner, props of e.propGroups
|
||||||
for prop in props
|
for prop in props
|
||||||
|
@ -593,18 +605,20 @@ module.exports = class SpellView extends CocoView
|
||||||
@aceSession.removeGutterDecoration row, 'executing'
|
@aceSession.removeGutterDecoration row, 'executing'
|
||||||
@aceSession.removeGutterDecoration row, 'executed'
|
@aceSession.removeGutterDecoration row, 'executed'
|
||||||
@decoratedGutter[row] = ''
|
@decoratedGutter[row] = ''
|
||||||
if not executed.length or (@spell.name is 'plan' and @spellThang.castAether.metrics.statementsExecuted < 20)
|
lastExecuted = _.last executed
|
||||||
|
showToolbarView = executed.length and (@spell.name isnt 'plan' or @spellThang.castAether.metrics.statementsExecuted > 20)
|
||||||
|
|
||||||
|
if showToolbarView
|
||||||
|
statementIndex = Math.max 0, lastExecuted.length - 1
|
||||||
|
@toolbarView?.toggleFlow true
|
||||||
|
@toolbarView?.setCallState states[currentCallIndex], statementIndex, currentCallIndex, @spellThang.castAether.metrics
|
||||||
|
lastExecuted = lastExecuted[0 .. @toolbarView.statementIndex] if @toolbarView?.statementIndex?
|
||||||
|
else
|
||||||
@toolbarView?.toggleFlow false
|
@toolbarView?.toggleFlow false
|
||||||
@debugView?.setVariableStates {}
|
@debugView?.setVariableStates {}
|
||||||
return
|
|
||||||
lastExecuted = _.last executed
|
|
||||||
@toolbarView?.toggleFlow true
|
|
||||||
statementIndex = Math.max 0, lastExecuted.length - 1
|
|
||||||
@toolbarView?.setCallState states[currentCallIndex], statementIndex, currentCallIndex, @spellThang.castAether.metrics
|
|
||||||
marked = {}
|
marked = {}
|
||||||
lastExecuted = lastExecuted[0 .. @toolbarView.statementIndex] if @toolbarView?.statementIndex?
|
|
||||||
gotVariableStates = false
|
gotVariableStates = false
|
||||||
for state, i in lastExecuted
|
for state, i in lastExecuted ? []
|
||||||
[start, end] = state.range
|
[start, end] = state.range
|
||||||
clazz = if i is lastExecuted.length - 1 then 'executing' else 'executed'
|
clazz = if i is lastExecuted.length - 1 then 'executing' else 'executed'
|
||||||
if clazz is 'executed'
|
if clazz is 'executed'
|
||||||
|
@ -682,18 +696,17 @@ module.exports = class SpellView extends CocoView
|
||||||
@ace.setDisplayIndentGuides aceConfig.indentGuides # default false
|
@ace.setDisplayIndentGuides aceConfig.indentGuides # default false
|
||||||
@ace.setShowInvisibles aceConfig.invisibles # default false
|
@ace.setShowInvisibles aceConfig.invisibles # default false
|
||||||
@ace.setKeyboardHandler @keyBindings[aceConfig.keyBindings ? 'default']
|
@ace.setKeyboardHandler @keyBindings[aceConfig.keyBindings ? 'default']
|
||||||
@zatanna?.set 'liveCompletion', (aceConfig.liveCompletion ? false)
|
@updateAutocomplete(aceConfig.liveCompletion ? false)
|
||||||
|
|
||||||
onChangeLanguage: (e) ->
|
onChangeLanguage: (e) ->
|
||||||
return unless @spell.canWrite()
|
return unless @spell.canWrite()
|
||||||
@aceSession.setMode @editModes[e.language]
|
@aceSession.setMode @editModes[e.language]
|
||||||
# @zatanna?.set 'language', @editModes[e.language].substr('ace/mode/')
|
@zatanna?.set 'language', @editModes[e.language].substr('ace/mode/')
|
||||||
wasDefault = @getSource() is @spell.originalSource
|
wasDefault = @getSource() is @spell.originalSource
|
||||||
@spell.setLanguage e.language
|
@spell.setLanguage e.language
|
||||||
@reloadCode true if wasDefault
|
@reloadCode true if wasDefault
|
||||||
|
|
||||||
onInsertSnippet: (e) ->
|
onInsertSnippet: (e) ->
|
||||||
console.log 'doc', e.doc, e.formatted
|
|
||||||
snippetCode = null
|
snippetCode = null
|
||||||
if e.doc.snippets?[e.language]?.code
|
if e.doc.snippets?[e.language]?.code
|
||||||
snippetCode = e.doc.snippets[e.language].code
|
snippetCode = e.doc.snippets[e.language].code
|
||||||
|
|
|
@ -44,7 +44,7 @@
|
||||||
"bootstrap": "~3.2.0",
|
"bootstrap": "~3.2.0",
|
||||||
"validated-backbone-mediator": "~0.1.3",
|
"validated-backbone-mediator": "~0.1.3",
|
||||||
"jquery.browser": "~0.0.6",
|
"jquery.browser": "~0.0.6",
|
||||||
"zatanna": "~0.0.6",
|
"zatanna": "https://github.com/differentmatt/zatanna.git#master",
|
||||||
"modernizr": "~2.8.3",
|
"modernizr": "~2.8.3",
|
||||||
"backfire": "~0.3.0"
|
"backfire": "~0.3.0"
|
||||||
},
|
},
|
||||||
|
|
Reference in a new issue