mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2024-11-24 08:08:15 -05:00
Recording flow only for frame of interest.
This commit is contained in:
parent
891471b80a
commit
f64e50f85b
4 changed files with 26 additions and 21 deletions
|
@ -238,13 +238,13 @@ self.retrieveValueFromFrame = function retrieveValueFromFrame(args) {
|
|||
|
||||
self.enableFlowOnThangSpell = function (thangID, spellID, userCodeMap) {
|
||||
try {
|
||||
if (userCodeMap[thangID][spellID].originalOptions.includeFlow === true &&
|
||||
userCodeMap[thangID][spellID].originalOptions.noSerializationInFlow === true)
|
||||
var options = userCodeMap[thangID][spellID].originalOptions;
|
||||
if (options.includeFlow === true && options.noSerializationInFlow === true)
|
||||
return;
|
||||
else
|
||||
{
|
||||
userCodeMap[thangID][spellID].originalOptions.includeFlow = true;
|
||||
userCodeMap[thangID][spellID].originalOptions.noSerializationInFlow = true;
|
||||
options.includeFlow = true;
|
||||
options.noSerializationInFlow = true;
|
||||
var temporaryAether = Aether.deserialize(userCodeMap[thangID][spellID]);
|
||||
temporaryAether.transpile(temporaryAether.raw);
|
||||
userCodeMap[thangID][spellID] = temporaryAether.serialize();
|
||||
|
|
|
@ -20,6 +20,7 @@ module.exports = class Mark extends CocoClass
|
|||
@build()
|
||||
|
||||
destroy: ->
|
||||
createjs.Tween.removeTweens @mark
|
||||
@mark?.parent?.removeChild @mark
|
||||
@markSprite?.destroy()
|
||||
@sprite = null
|
||||
|
|
|
@ -85,6 +85,12 @@ module.exports = class World
|
|||
frameToLoadUntil = @totalFrames
|
||||
i = @frames.length
|
||||
while i < frameToLoadUntil
|
||||
if @debugging
|
||||
for thang in @thangs when thang.isProgrammable
|
||||
userCode = @userCodeMap[thang.id] ? {}
|
||||
for methodName, aether of userCode
|
||||
framesToLoadFlowBefore = if methodName is 'plan' then 200 else 1 # Adjust if plan() is taking even longer
|
||||
aether._shouldSkipFlow = i < loadUntilFrame - framesToLoadFlowBefore
|
||||
try
|
||||
@getFrame(i)
|
||||
++i # increment this after we have succeeded in getting the frame, otherwise we'll have to do that frame again
|
||||
|
|
|
@ -34,40 +34,38 @@ module.exports = class DebugView extends View
|
|||
@cache = {}
|
||||
@lastFrameRequested = -1
|
||||
@workerIsSimulating = false
|
||||
|
||||
|
||||
|
||||
pad2: (num) ->
|
||||
if not num? or num is 0 then "00" else ((if num < 10 then "0" else "") + num)
|
||||
|
||||
|
||||
calculateCurrentTimeString: =>
|
||||
time = @currentFrame / @frameRate
|
||||
console.log "Current frame is",@currentFrame
|
||||
console.log "Current framerate is",@frameRate
|
||||
mins = Math.floor(time / 60)
|
||||
secs = (time - mins * 60).toFixed(1)
|
||||
"#{mins}:#{@pad2 secs}"
|
||||
|
||||
|
||||
|
||||
|
||||
setTooltipKeyAndValue: (key, value) =>
|
||||
message = "Time: #{@calculateCurrentTimeString()}\n#{key}: #{value}"
|
||||
@$el.find("code").text message
|
||||
@$el.show().css(@pos)
|
||||
|
||||
|
||||
setTooltipText: (text) =>
|
||||
#perhaps changing styling here in the future
|
||||
@$el.find("code").text text
|
||||
@$el.show().css(@pos)
|
||||
|
||||
|
||||
onTomeCast: ->
|
||||
@invalidateCache()
|
||||
|
||||
|
||||
invalidateCache: -> @cache = {}
|
||||
|
||||
|
||||
retrieveValueFromCache: (thangID,spellID,variableChain,frame) ->
|
||||
joinedVariableChain = variableChain.join()
|
||||
value = @cache[frame]?[thangID]?[spellID]?[joinedVariableChain]
|
||||
return value ? undefined
|
||||
|
||||
|
||||
updateCache: (thangID, spellID, variableChain, frame, value) ->
|
||||
currentObject = @cache
|
||||
keys = [frame,thangID,spellID,variableChain.join()]
|
||||
|
@ -77,8 +75,8 @@ module.exports = class DebugView extends View
|
|||
currentObject[key] = {}
|
||||
currentObject = currentObject[key]
|
||||
currentObject[keys[keys.length - 1]] = value
|
||||
|
||||
|
||||
|
||||
|
||||
changeCurrentThangAndSpell: (thangAndSpellObject) ->
|
||||
@thang = thangAndSpellObject.thang
|
||||
@spell = thangAndSpellObject.spell
|
||||
|
@ -143,11 +141,11 @@ module.exports = class DebugView extends View
|
|||
onNewWorld: (e) ->
|
||||
@thang = @options.thang = e.world.thangMap[@thang.id] if @thang
|
||||
@frameRate = e.world.frameRate
|
||||
|
||||
|
||||
onFrameChanged: (data) ->
|
||||
@currentFrame = data.frame
|
||||
@frameRate = data.world.frameRate
|
||||
|
||||
|
||||
update: ->
|
||||
if @variableChain
|
||||
if @variableChain.length is 2 and @variableChain[0] is "this"
|
||||
|
@ -173,7 +171,7 @@ module.exports = class DebugView extends View
|
|||
else
|
||||
@notifyPropertyHovered()
|
||||
@updateMarker()
|
||||
|
||||
|
||||
stringifyValue: (value, depth) ->
|
||||
return value if not value or _.isString value
|
||||
if _.isFunction value
|
||||
|
@ -214,7 +212,7 @@ module.exports = class DebugView extends View
|
|||
@hoveredProperty = if @variableChain?.length is 2 then owner: @variableChain[0], property: @variableChain[1] else {}
|
||||
unless _.isEqual oldHoveredProperty, @hoveredProperty
|
||||
Backbone.Mediator.publish 'tome:spell-debug-property-hovered', @hoveredProperty
|
||||
|
||||
|
||||
updateMarker: ->
|
||||
if @marker
|
||||
@ace.getSession().removeMarker @marker
|
||||
|
|
Loading…
Reference in a new issue