From a481af08d3f259d326d4b7e3820207ba18d7a727 Mon Sep 17 00:00:00 2001 From: Nick Winter Date: Mon, 26 May 2014 20:51:05 -0700 Subject: [PATCH 1/8] Fixed a couple typos with failed resource loading handling. --- app/models/SuperModel.coffee | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) 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 From 3b87c9c36068e0b949b6e44986387cbd93859edd Mon Sep 17 00:00:00 2001 From: Scott Erickson Date: Tue, 27 May 2014 16:33:57 -0700 Subject: [PATCH 2/8] Fixed some remaining jqxhr objects hanging around. --- app/models/CocoModel.coffee | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/models/CocoModel.coffee b/app/models/CocoModel.coffee index 515bbfa57..add8b5600 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 From 93f7d8c0a41e16d8efc948154e51a3977295cf36 Mon Sep 17 00:00:00 2001 From: Scott Erickson Date: Tue, 27 May 2014 16:41:56 -0700 Subject: [PATCH 3/8] Made sure sprites are idle and properly positioned when they load. --- app/lib/surface/CocoSprite.coffee | 1 + 1 file changed, 1 insertion(+) 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() From 5909f156788354a4cbefab51828ce378f497186b Mon Sep 17 00:00:00 2001 From: Ruben Vereecken Date: Wed, 28 May 2014 17:29:36 +0200 Subject: [PATCH 4/8] Refactored getRenderData from SearchView to children --- app/views/editor/article/home.coffee | 9 +++++++++ app/views/editor/level/home.coffee | 9 +++++++++ app/views/editor/thang/home.coffee | 13 +++++++++++-- app/views/kinds/SearchView.coffee | 21 --------------------- 4 files changed, 29 insertions(+), 23 deletions(-) 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/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 From bd444fa547c8d927562b8d9fac44ec4c6f155824 Mon Sep 17 00:00:00 2001 From: dpen2000 Date: Thu, 29 May 2014 02:13:20 +0100 Subject: [PATCH 5/8] Fixes #1096 by ensuring progress is reset back to zero so render gets called correctly after ajax call to load patches completes --- app/views/editor/patches_view.coffee | 1 + 1 file changed, 1 insertion(+) 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() From afc14e593d753f2bf7b0e95c02a1906e4c9caaa5 Mon Sep 17 00:00:00 2001 From: Scott Erickson Date: Thu, 29 May 2014 10:48:48 -0700 Subject: [PATCH 6/8] Fixed models thinking they've got changes when they don't. --- app/models/CocoModel.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/CocoModel.coffee b/app/models/CocoModel.coffee index add8b5600..3a8838b65 100644 --- a/app/models/CocoModel.coffee +++ b/app/models/CocoModel.coffee @@ -107,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 From f3adc216edd2a55028b9e431b129f10dedc36aec Mon Sep 17 00:00:00 2001 From: Nick Winter Date: Thu, 29 May 2014 12:26:01 -0700 Subject: [PATCH 7/8] Protecting our replacement of Math.random via Aether. --- app/assets/javascripts/workers/worker_world.js | 2 ++ app/lib/Angel.coffee | 1 + app/models/ThangType.coffee | 4 ++-- app/schemas/models/user.coffee | 2 +- app/views/play/level/tome/spell_view.coffee | 2 +- headless_client/worker_world.coffee | 1 + 6 files changed, 8 insertions(+), 4 deletions(-) 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/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/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" From df13bbfaa681347dbe3c835edd4bf6c8105dd708 Mon Sep 17 00:00:00 2001 From: Nick Winter Date: Thu, 29 May 2014 12:33:21 -0700 Subject: [PATCH 8/8] Made right-click duplicate Thang menu actually clone modified Thang. --- app/views/editor/level/thangs_tab_view.coffee | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) 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'