diff --git a/app/assets/javascripts/workers/worker_world.js b/app/assets/javascripts/workers/worker_world.js index a1c4baf0f..3dcae25d2 100644 --- a/app/assets/javascripts/workers/worker_world.js +++ b/app/assets/javascripts/workers/worker_world.js @@ -289,6 +289,7 @@ self.setupDebugWorldToRunUntilFrame = function (args) { return; } 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.currentDebugWorldFrame = args.frame; @@ -343,6 +344,7 @@ self.runWorld = function runWorld(args) { return; } Math.random = self.world.rand.randf; // so user code is predictable + Aether.replaceBuiltin("Math", Math); self.postMessage({type: 'start-load-frames'}); self.world.loadFrames(self.onWorldLoaded, self.onWorldError, self.onWorldLoadProgress); }; diff --git a/app/lib/Angel.coffee b/app/lib/Angel.coffee index fbdb252db..aae10c724 100644 --- a/app/lib/Angel.coffee +++ b/app/lib/Angel.coffee @@ -211,6 +211,7 @@ module.exports = class Angel extends CocoClass doSimulateWorld: (work) -> work.t1 = now() Math.random = work.testWorld.rand.randf # so user code is predictable + Aether.replaceBuiltin("Math", Math) i = 0 while i < work.testWorld.totalFrames frame = work.testWorld.getFrame i++ diff --git a/app/lib/surface/CocoSprite.coffee b/app/lib/surface/CocoSprite.coffee index 882383b97..183d6aa65 100644 --- a/app/lib/surface/CocoSprite.coffee +++ b/app/lib/surface/CocoSprite.coffee @@ -100,6 +100,7 @@ module.exports = CocoSprite = class CocoSprite extends CocoClass @actions = @thangType.getActions() @buildFromSpriteSheet result @createMarks() + @queueAction 'idle' finishSetup: -> @updateBaseScale() diff --git a/app/models/CocoModel.coffee b/app/models/CocoModel.coffee index 515bbfa57..3a8838b65 100644 --- a/app/models/CocoModel.coffee +++ b/app/models/CocoModel.coffee @@ -32,10 +32,12 @@ class CocoModel extends Backbone.Model onError: -> @loading = false + @jqxhr = null onLoaded: -> @loaded = true @loading = false + @jqxhr = null @markToRevert() @loadFromBackup() @@ -91,6 +93,7 @@ class CocoModel extends Backbone.Model @jqxhr markToRevert: -> + return unless @saveBackups if @type() is 'ThangType' @_revertAttributes = _.clone @attributes # No deep clones for these! else @@ -104,7 +107,7 @@ class CocoModel extends Backbone.Model storage.remove @id hasLocalChanges: -> - not _.isEqual @attributes, @_revertAttributes + @_revertAttributes and not _.isEqual @attributes, @_revertAttributes cloneNewMinorVersion: -> newData = _.clone @attributes diff --git a/app/models/SuperModel.coffee b/app/models/SuperModel.coffee index 90118faa5..c5a4eeb55 100644 --- a/app/models/SuperModel.coffee +++ b/app/models/SuperModel.coffee @@ -169,9 +169,9 @@ module.exports = class SuperModel extends Backbone.Model _.defer @updateProgress r.clean() - onResourceFailed: (source) -> + onResourceFailed: (r) -> return unless @resources[r.rid] - @trigger('failed', source) + @trigger('failed', resource: r) r.clean() updateProgress: => @@ -216,14 +216,14 @@ class Resource extends Backbone.Model markFailed: -> return if @isLoaded - @trigger('failed', {resource: @}) + @trigger('failed', @) @isLoaded = @isLoading = false @isFailed = true markLoading: -> @isLoaded = @isFailed = false @isLoading = true - + clean: -> # request objects get rather large. Clean them up after the request is finished. @jqxhr = null diff --git a/app/models/ThangType.coffee b/app/models/ThangType.coffee index e1ccf1054..84fd8e713 100644 --- a/app/models/ThangType.coffee +++ b/app/models/ThangType.coffee @@ -159,7 +159,7 @@ module.exports = class ThangType extends CocoModel spriteSheet = @builder.build() @logBuild @t0, false, @options.portraitOnly @spriteSheets[key] = spriteSheet - delete @building[key] + @building[key] = false @builder = null @options = null spriteSheet @@ -171,7 +171,7 @@ module.exports = class ThangType extends CocoModel buildQueue[0].t0 = new Date().getTime() if buildQueue[0] buildQueue[0]?.buildAsync() @spriteSheets[key] = e.target.spriteSheet - delete @building[key] + @building[key] = false @trigger 'build-complete', {key:key, thangType:@} @vectorParser = null diff --git a/app/schemas/models/user.coffee b/app/schemas/models/user.coffee index a6525bf91..5b4a93ca7 100644 --- a/app/schemas/models/user.coffee +++ b/app/schemas/models/user.coffee @@ -60,7 +60,7 @@ UserSchema = c.object {}, colorConfig: c.object {additionalProperties: c.colorConfig()} 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']} invisibles: {type: 'boolean', 'default': false} indentGuides: {type: 'boolean', 'default': false} diff --git a/app/views/editor/article/home.coffee b/app/views/editor/article/home.coffee index 41d7419f9..c34640d55 100644 --- a/app/views/editor/article/home.coffee +++ b/app/views/editor/article/home.coffee @@ -6,3 +6,12 @@ module.exports = class ThangTypeHomeView extends SearchView model: require 'models/Article' modelURL: '/db/article' 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 diff --git a/app/views/editor/level/home.coffee b/app/views/editor/level/home.coffee index 247c9d3ff..ae31fd6e8 100644 --- a/app/views/editor/level/home.coffee +++ b/app/views/editor/level/home.coffee @@ -6,3 +6,12 @@ module.exports = class EditorSearchView extends SearchView model: require 'models/Level' modelURL: '/db/level' 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 diff --git a/app/views/editor/level/thangs_tab_view.coffee b/app/views/editor/level/thangs_tab_view.coffee index 5d5cdd7b3..b675fd3bc 100644 --- a/app/views/editor/level/thangs_tab_view.coffee +++ b/app/views/editor/level/thangs_tab_view.coffee @@ -69,7 +69,7 @@ module.exports = class ThangsTabView extends View @level = options.level $(document).bind 'contextmenu', @preventDefaultContextMenu - + getRenderData: (context={}) -> context = super(context) return context unless @supermodel.finished() @@ -102,7 +102,7 @@ module.exports = class ThangsTabView extends View $('#thangs-list').height(oldHeight - thangsHeaderHeight - 40) else $('#thangs-list').height(oldHeight - thangsHeaderHeight - 80) - + afterRender: -> super() @@ -440,18 +440,15 @@ module.exports = class ThangsTabView extends View onDuplicateClicked: (e) -> $('#contextmenu').hide() - if !@addThangType - thang = @selectedExtantThang.spriteName - e.target = $(".add-thang-palette-icon[data-thang-type='" + thang + "']").get 0 - @selectAddThang e - + @selectAddThangType @selectedExtantThang.spriteName, @selectedExtantThang + toggleThangsContainer: (e) -> $('#all-thangs').toggle() - + toggleThangsPalette: (e) -> $('#add-thangs-column').toggle() @onWindowResize e - + class ThangsNode extends TreemaNode.nodeMap.array valueClass: 'treema-array-replacement' diff --git a/app/views/editor/patches_view.coffee b/app/views/editor/patches_view.coffee index 17aef667b..a75e1e36d 100644 --- a/app/views/editor/patches_view.coffee +++ b/app/views/editor/patches_view.coffee @@ -46,6 +46,7 @@ module.exports = class PatchesView extends CocoView @reloadPatches() reloadPatches: -> + @supermodel.resetProgress() @load() @render() diff --git a/app/views/editor/thang/home.coffee b/app/views/editor/thang/home.coffee index 2fb208723..1f585b2ab 100644 --- a/app/views/editor/thang/home.coffee +++ b/app/views/editor/thang/home.coffee @@ -5,10 +5,19 @@ module.exports = class ThangTypeHomeView extends SearchView modelLabel: 'Thang Type' model: require 'models/ThangType' 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: => super() @$el.find("img").error(-> $(this).hide()) - # TODO: do the new thing on click, not just enter \ No newline at end of file + # TODO: do the new thing on click, not just enter diff --git a/app/views/kinds/SearchView.coffee b/app/views/kinds/SearchView.coffee index 209abdd8e..6619a71c3 100644 --- a/app/views/kinds/SearchView.coffee +++ b/app/views/kinds/SearchView.coffee @@ -26,27 +26,6 @@ module.exports = class SearchView extends View 'shown.bs.modal #new-model-modal': 'focusOnName' '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) -> @runSearch = _.debounce(@runSearch, 500) super options diff --git a/app/views/play/level/tome/spell_view.coffee b/app/views/play/level/tome/spell_view.coffee index 04851959e..9933033d0 100644 --- a/app/views/play/level/tome/spell_view.coffee +++ b/app/views/play/level/tome/spell_view.coffee @@ -18,9 +18,9 @@ module.exports = class SpellView extends View editModes: 'javascript': 'ace/mode/javascript' 'coffeescript': 'ace/mode/coffee' + 'python': 'ace/mode/python' 'clojure': 'ace/mode/clojure' 'lua': 'ace/mode/lua' - 'python': 'ace/mode/python' 'io': 'ace/mode/text' keyBindings: diff --git a/headless_client/worker_world.coffee b/headless_client/worker_world.coffee index e40317bfe..667481858 100644 --- a/headless_client/worker_world.coffee +++ b/headless_client/worker_world.coffee @@ -91,6 +91,7 @@ work = () -> self.onWorldError error return Math.random = self.world.rand.randf # so user code is predictable + Aether.replaceBuiltin("Math", Math) console.log "Loading frames." self.postMessage type: "start-load-frames"