Recording flow only for frame of interest.

This commit is contained in:
Nick Winter 2014-05-16 16:52:55 -07:00
parent 891471b80a
commit f64e50f85b
4 changed files with 26 additions and 21 deletions

View file

@ -238,13 +238,13 @@ self.retrieveValueFromFrame = function retrieveValueFromFrame(args) {
self.enableFlowOnThangSpell = function (thangID, spellID, userCodeMap) { self.enableFlowOnThangSpell = function (thangID, spellID, userCodeMap) {
try { try {
if (userCodeMap[thangID][spellID].originalOptions.includeFlow === true && var options = userCodeMap[thangID][spellID].originalOptions;
userCodeMap[thangID][spellID].originalOptions.noSerializationInFlow === true) if (options.includeFlow === true && options.noSerializationInFlow === true)
return; return;
else else
{ {
userCodeMap[thangID][spellID].originalOptions.includeFlow = true; options.includeFlow = true;
userCodeMap[thangID][spellID].originalOptions.noSerializationInFlow = true; options.noSerializationInFlow = true;
var temporaryAether = Aether.deserialize(userCodeMap[thangID][spellID]); var temporaryAether = Aether.deserialize(userCodeMap[thangID][spellID]);
temporaryAether.transpile(temporaryAether.raw); temporaryAether.transpile(temporaryAether.raw);
userCodeMap[thangID][spellID] = temporaryAether.serialize(); userCodeMap[thangID][spellID] = temporaryAether.serialize();

View file

@ -20,6 +20,7 @@ module.exports = class Mark extends CocoClass
@build() @build()
destroy: -> destroy: ->
createjs.Tween.removeTweens @mark
@mark?.parent?.removeChild @mark @mark?.parent?.removeChild @mark
@markSprite?.destroy() @markSprite?.destroy()
@sprite = null @sprite = null

View file

@ -85,6 +85,12 @@ module.exports = class World
frameToLoadUntil = @totalFrames frameToLoadUntil = @totalFrames
i = @frames.length i = @frames.length
while i < frameToLoadUntil 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 try
@getFrame(i) @getFrame(i)
++i # increment this after we have succeeded in getting the frame, otherwise we'll have to do that frame again ++i # increment this after we have succeeded in getting the frame, otherwise we'll have to do that frame again

View file

@ -34,40 +34,38 @@ module.exports = class DebugView extends View
@cache = {} @cache = {}
@lastFrameRequested = -1 @lastFrameRequested = -1
@workerIsSimulating = false @workerIsSimulating = false
pad2: (num) -> pad2: (num) ->
if not num? or num is 0 then "00" else ((if num < 10 then "0" else "") + num) if not num? or num is 0 then "00" else ((if num < 10 then "0" else "") + num)
calculateCurrentTimeString: => calculateCurrentTimeString: =>
time = @currentFrame / @frameRate time = @currentFrame / @frameRate
console.log "Current frame is",@currentFrame
console.log "Current framerate is",@frameRate
mins = Math.floor(time / 60) mins = Math.floor(time / 60)
secs = (time - mins * 60).toFixed(1) secs = (time - mins * 60).toFixed(1)
"#{mins}:#{@pad2 secs}" "#{mins}:#{@pad2 secs}"
setTooltipKeyAndValue: (key, value) => setTooltipKeyAndValue: (key, value) =>
message = "Time: #{@calculateCurrentTimeString()}\n#{key}: #{value}" message = "Time: #{@calculateCurrentTimeString()}\n#{key}: #{value}"
@$el.find("code").text message @$el.find("code").text message
@$el.show().css(@pos) @$el.show().css(@pos)
setTooltipText: (text) => setTooltipText: (text) =>
#perhaps changing styling here in the future #perhaps changing styling here in the future
@$el.find("code").text text @$el.find("code").text text
@$el.show().css(@pos) @$el.show().css(@pos)
onTomeCast: -> onTomeCast: ->
@invalidateCache() @invalidateCache()
invalidateCache: -> @cache = {} invalidateCache: -> @cache = {}
retrieveValueFromCache: (thangID,spellID,variableChain,frame) -> retrieveValueFromCache: (thangID,spellID,variableChain,frame) ->
joinedVariableChain = variableChain.join() joinedVariableChain = variableChain.join()
value = @cache[frame]?[thangID]?[spellID]?[joinedVariableChain] value = @cache[frame]?[thangID]?[spellID]?[joinedVariableChain]
return value ? undefined return value ? undefined
updateCache: (thangID, spellID, variableChain, frame, value) -> updateCache: (thangID, spellID, variableChain, frame, value) ->
currentObject = @cache currentObject = @cache
keys = [frame,thangID,spellID,variableChain.join()] keys = [frame,thangID,spellID,variableChain.join()]
@ -77,8 +75,8 @@ module.exports = class DebugView extends View
currentObject[key] = {} currentObject[key] = {}
currentObject = currentObject[key] currentObject = currentObject[key]
currentObject[keys[keys.length - 1]] = value currentObject[keys[keys.length - 1]] = value
changeCurrentThangAndSpell: (thangAndSpellObject) -> changeCurrentThangAndSpell: (thangAndSpellObject) ->
@thang = thangAndSpellObject.thang @thang = thangAndSpellObject.thang
@spell = thangAndSpellObject.spell @spell = thangAndSpellObject.spell
@ -143,11 +141,11 @@ module.exports = class DebugView extends View
onNewWorld: (e) -> onNewWorld: (e) ->
@thang = @options.thang = e.world.thangMap[@thang.id] if @thang @thang = @options.thang = e.world.thangMap[@thang.id] if @thang
@frameRate = e.world.frameRate @frameRate = e.world.frameRate
onFrameChanged: (data) -> onFrameChanged: (data) ->
@currentFrame = data.frame @currentFrame = data.frame
@frameRate = data.world.frameRate @frameRate = data.world.frameRate
update: -> update: ->
if @variableChain if @variableChain
if @variableChain.length is 2 and @variableChain[0] is "this" if @variableChain.length is 2 and @variableChain[0] is "this"
@ -173,7 +171,7 @@ module.exports = class DebugView extends View
else else
@notifyPropertyHovered() @notifyPropertyHovered()
@updateMarker() @updateMarker()
stringifyValue: (value, depth) -> stringifyValue: (value, depth) ->
return value if not value or _.isString value return value if not value or _.isString value
if _.isFunction 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 {} @hoveredProperty = if @variableChain?.length is 2 then owner: @variableChain[0], property: @variableChain[1] else {}
unless _.isEqual oldHoveredProperty, @hoveredProperty unless _.isEqual oldHoveredProperty, @hoveredProperty
Backbone.Mediator.publish 'tome:spell-debug-property-hovered', @hoveredProperty Backbone.Mediator.publish 'tome:spell-debug-property-hovered', @hoveredProperty
updateMarker: -> updateMarker: ->
if @marker if @marker
@ace.getSession().removeMarker @marker @ace.getSession().removeMarker @marker