Merge branch 'master' into production

This commit is contained in:
Nick Winter 2014-05-29 12:34:52 -07:00
commit 0793066e43
15 changed files with 53 additions and 41 deletions

View file

@ -289,6 +289,7 @@ self.setupDebugWorldToRunUntilFrame = function (args) {
return; return;
} }
Math.random = self.debugWorld.rand.randf; // so user code is predictable Math.random = self.debugWorld.rand.randf; // so user code is predictable
Aether.replaceBuiltin("Math", Math);
} }
self.debugWorld.totalFrames = args.frame; //hack to work around error checking self.debugWorld.totalFrames = args.frame; //hack to work around error checking
self.currentDebugWorldFrame = args.frame; self.currentDebugWorldFrame = args.frame;
@ -343,6 +344,7 @@ self.runWorld = function runWorld(args) {
return; return;
} }
Math.random = self.world.rand.randf; // so user code is predictable Math.random = self.world.rand.randf; // so user code is predictable
Aether.replaceBuiltin("Math", Math);
self.postMessage({type: 'start-load-frames'}); self.postMessage({type: 'start-load-frames'});
self.world.loadFrames(self.onWorldLoaded, self.onWorldError, self.onWorldLoadProgress); self.world.loadFrames(self.onWorldLoaded, self.onWorldError, self.onWorldLoadProgress);
}; };

View file

@ -211,6 +211,7 @@ module.exports = class Angel extends CocoClass
doSimulateWorld: (work) -> doSimulateWorld: (work) ->
work.t1 = now() work.t1 = now()
Math.random = work.testWorld.rand.randf # so user code is predictable Math.random = work.testWorld.rand.randf # so user code is predictable
Aether.replaceBuiltin("Math", Math)
i = 0 i = 0
while i < work.testWorld.totalFrames while i < work.testWorld.totalFrames
frame = work.testWorld.getFrame i++ frame = work.testWorld.getFrame i++

View file

@ -100,6 +100,7 @@ module.exports = CocoSprite = class CocoSprite extends CocoClass
@actions = @thangType.getActions() @actions = @thangType.getActions()
@buildFromSpriteSheet result @buildFromSpriteSheet result
@createMarks() @createMarks()
@queueAction 'idle'
finishSetup: -> finishSetup: ->
@updateBaseScale() @updateBaseScale()

View file

@ -32,10 +32,12 @@ class CocoModel extends Backbone.Model
onError: -> onError: ->
@loading = false @loading = false
@jqxhr = null
onLoaded: -> onLoaded: ->
@loaded = true @loaded = true
@loading = false @loading = false
@jqxhr = null
@markToRevert() @markToRevert()
@loadFromBackup() @loadFromBackup()
@ -91,6 +93,7 @@ class CocoModel extends Backbone.Model
@jqxhr @jqxhr
markToRevert: -> markToRevert: ->
return unless @saveBackups
if @type() is 'ThangType' if @type() is 'ThangType'
@_revertAttributes = _.clone @attributes # No deep clones for these! @_revertAttributes = _.clone @attributes # No deep clones for these!
else else
@ -104,7 +107,7 @@ class CocoModel extends Backbone.Model
storage.remove @id storage.remove @id
hasLocalChanges: -> hasLocalChanges: ->
not _.isEqual @attributes, @_revertAttributes @_revertAttributes and not _.isEqual @attributes, @_revertAttributes
cloneNewMinorVersion: -> cloneNewMinorVersion: ->
newData = _.clone @attributes newData = _.clone @attributes

View file

@ -169,9 +169,9 @@ module.exports = class SuperModel extends Backbone.Model
_.defer @updateProgress _.defer @updateProgress
r.clean() r.clean()
onResourceFailed: (source) -> onResourceFailed: (r) ->
return unless @resources[r.rid] return unless @resources[r.rid]
@trigger('failed', source) @trigger('failed', resource: r)
r.clean() r.clean()
updateProgress: => updateProgress: =>
@ -216,7 +216,7 @@ class Resource extends Backbone.Model
markFailed: -> markFailed: ->
return if @isLoaded return if @isLoaded
@trigger('failed', {resource: @}) @trigger('failed', @)
@isLoaded = @isLoading = false @isLoaded = @isLoading = false
@isFailed = true @isFailed = true

View file

@ -159,7 +159,7 @@ module.exports = class ThangType extends CocoModel
spriteSheet = @builder.build() spriteSheet = @builder.build()
@logBuild @t0, false, @options.portraitOnly @logBuild @t0, false, @options.portraitOnly
@spriteSheets[key] = spriteSheet @spriteSheets[key] = spriteSheet
delete @building[key] @building[key] = false
@builder = null @builder = null
@options = null @options = null
spriteSheet spriteSheet
@ -171,7 +171,7 @@ module.exports = class ThangType extends CocoModel
buildQueue[0].t0 = new Date().getTime() if buildQueue[0] buildQueue[0].t0 = new Date().getTime() if buildQueue[0]
buildQueue[0]?.buildAsync() buildQueue[0]?.buildAsync()
@spriteSheets[key] = e.target.spriteSheet @spriteSheets[key] = e.target.spriteSheet
delete @building[key] @building[key] = false
@trigger 'build-complete', {key:key, thangType:@} @trigger 'build-complete', {key:key, thangType:@}
@vectorParser = null @vectorParser = null

View file

@ -60,7 +60,7 @@ UserSchema = c.object {},
colorConfig: c.object {additionalProperties: c.colorConfig()} colorConfig: c.object {additionalProperties: c.colorConfig()}
aceConfig: c.object {}, aceConfig: c.object {},
language: {type: 'string', 'default': 'javascript', 'enum': ['javascript', 'coffeescript', 'clojure', 'lua', 'python', 'io']} language: {type: 'string', 'default': 'javascript', 'enum': ['javascript', 'coffeescript', 'python', 'clojure', 'lua', 'io']}
keyBindings: {type: 'string', 'default': 'default', 'enum': ['default', 'vim', 'emacs']} keyBindings: {type: 'string', 'default': 'default', 'enum': ['default', 'vim', 'emacs']}
invisibles: {type: 'boolean', 'default': false} invisibles: {type: 'boolean', 'default': false}
indentGuides: {type: 'boolean', 'default': false} indentGuides: {type: 'boolean', 'default': false}

View file

@ -6,3 +6,12 @@ module.exports = class ThangTypeHomeView extends SearchView
model: require 'models/Article' model: require 'models/Article'
modelURL: '/db/article' modelURL: '/db/article'
tableTemplate: require 'templates/editor/article/table' tableTemplate: require 'templates/editor/article/table'
getRenderData: ->
context = super()
context.currentEditor = 'editor.article_title'
context.currentNew = 'editor.new_article_title'
context.currentNewSignup = 'editor.new_article_title_login'
context.currentSearch = 'editor.article_search_title'
@$el.i18n()
context

View file

@ -6,3 +6,12 @@ module.exports = class EditorSearchView extends SearchView
model: require 'models/Level' model: require 'models/Level'
modelURL: '/db/level' modelURL: '/db/level'
tableTemplate: require 'templates/editor/level/table' tableTemplate: require 'templates/editor/level/table'
getRenderData: ->
context = super()
context.currentEditor = 'editor.level_title'
context.currentNew = 'editor.new_level_title'
context.currentNewSignup = 'editor.new_level_title_login'
context.currentSearch = 'editor.level_search_title'
@$el.i18n()
context

View file

@ -440,10 +440,7 @@ module.exports = class ThangsTabView extends View
onDuplicateClicked: (e) -> onDuplicateClicked: (e) ->
$('#contextmenu').hide() $('#contextmenu').hide()
if !@addThangType @selectAddThangType @selectedExtantThang.spriteName, @selectedExtantThang
thang = @selectedExtantThang.spriteName
e.target = $(".add-thang-palette-icon[data-thang-type='" + thang + "']").get 0
@selectAddThang e
toggleThangsContainer: (e) -> toggleThangsContainer: (e) ->
$('#all-thangs').toggle() $('#all-thangs').toggle()

View file

@ -46,6 +46,7 @@ module.exports = class PatchesView extends CocoView
@reloadPatches() @reloadPatches()
reloadPatches: -> reloadPatches: ->
@supermodel.resetProgress()
@load() @load()
@render() @render()

View file

@ -7,6 +7,15 @@ module.exports = class ThangTypeHomeView extends SearchView
modelURL: '/db/thang.type' modelURL: '/db/thang.type'
tableTemplate: require 'templates/editor/thang/table' tableTemplate: require 'templates/editor/thang/table'
getRenderData: ->
context = super()
context.currentEditor = 'editor.thang_title'
context.currentNew = 'editor.new_thang_title'
context.currentNewSignup = 'editor.new_thang_title_login'
context.currentSearch = 'editor.thang_search_title'
@$el.i18n()
context
onSearchChange: => onSearchChange: =>
super() super()
@$el.find("img").error(-> $(this).hide()) @$el.find("img").error(-> $(this).hide())

View file

@ -26,27 +26,6 @@ module.exports = class SearchView extends View
'shown.bs.modal #new-model-modal': 'focusOnName' 'shown.bs.modal #new-model-modal': 'focusOnName'
'hidden.bs.modal #new-model-modal': 'onModalHidden' 'hidden.bs.modal #new-model-modal': 'onModalHidden'
getRenderData: ->
context = super()
switch @modelLabel
when 'Level'
context.currentEditor = 'editor.level_title'
context.currentNew = 'editor.new_level_title'
context.currentNewSignup = 'editor.new_level_title_login'
context.currentSearch = 'editor.level_search_title'
when 'Thang Type'
context.currentEditor = 'editor.thang_title'
context.currentNew = 'editor.new_thang_title'
context.currentNewSignup = 'editor.new_thang_title_login'
context.currentSearch = 'editor.thang_search_title'
when 'Article'
context.currentEditor = 'editor.article_title'
context.currentNew = 'editor.new_article_title'
context.currentNewSignup = 'editor.new_article_title_login'
context.currentSearch = 'editor.article_search_title'
@$el.i18n()
context
constructor: (options) -> constructor: (options) ->
@runSearch = _.debounce(@runSearch, 500) @runSearch = _.debounce(@runSearch, 500)
super options super options

View file

@ -18,9 +18,9 @@ module.exports = class SpellView extends View
editModes: editModes:
'javascript': 'ace/mode/javascript' 'javascript': 'ace/mode/javascript'
'coffeescript': 'ace/mode/coffee' 'coffeescript': 'ace/mode/coffee'
'python': 'ace/mode/python'
'clojure': 'ace/mode/clojure' 'clojure': 'ace/mode/clojure'
'lua': 'ace/mode/lua' 'lua': 'ace/mode/lua'
'python': 'ace/mode/python'
'io': 'ace/mode/text' 'io': 'ace/mode/text'
keyBindings: keyBindings:

View file

@ -91,6 +91,7 @@ work = () ->
self.onWorldError error self.onWorldError error
return return
Math.random = self.world.rand.randf # so user code is predictable Math.random = self.world.rand.randf # so user code is predictable
Aether.replaceBuiltin("Math", Math)
console.log "Loading frames." console.log "Loading frames."
self.postMessage type: "start-load-frames" self.postMessage type: "start-load-frames"