mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2024-12-02 03:47:09 -05:00
Merge branch 'master' into production
This commit is contained in:
commit
0793066e43
15 changed files with 53 additions and 41 deletions
|
@ -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);
|
||||
};
|
||||
|
|
|
@ -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++
|
||||
|
|
|
@ -100,6 +100,7 @@ module.exports = CocoSprite = class CocoSprite extends CocoClass
|
|||
@actions = @thangType.getActions()
|
||||
@buildFromSpriteSheet result
|
||||
@createMarks()
|
||||
@queueAction 'idle'
|
||||
|
||||
finishSetup: ->
|
||||
@updateBaseScale()
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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'
|
||||
|
|
|
@ -46,6 +46,7 @@ module.exports = class PatchesView extends CocoView
|
|||
@reloadPatches()
|
||||
|
||||
reloadPatches: ->
|
||||
@supermodel.resetProgress()
|
||||
@load()
|
||||
@render()
|
||||
|
||||
|
|
|
@ -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
|
||||
# TODO: do the new thing on click, not just enter
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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"
|
||||
|
|
Loading…
Reference in a new issue