mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2025-04-26 05:53:39 -04:00
Improvements to SpellDebugView hover.
This commit is contained in:
parent
c3f5c1c334
commit
01efb2f92b
4 changed files with 39 additions and 8 deletions
app
|
@ -8,7 +8,7 @@ class Vector
|
|||
a.copy()[name](b, useZ)
|
||||
|
||||
isVector: true
|
||||
apiProperties: ['x', 'y', 'z', 'magnitude', 'heading', 'distance', 'dot', 'equals', 'copy']
|
||||
apiProperties: ['x', 'y', 'magnitude', 'heading', 'distance', 'dot', 'equals', 'copy']
|
||||
|
||||
constructor: (@x=0, @y=0, @z=0) ->
|
||||
|
||||
|
|
|
@ -270,8 +270,8 @@ module.exports = class HUDView extends View
|
|||
if val.id
|
||||
return val.id
|
||||
else if val.x and val.y
|
||||
#return "x: #{val.x.toFixed(0)} y: #{val.y.toFixed(0)}"
|
||||
return "x: #{val.x.toFixed(0)} y: #{val.y.toFixed(0)}, z: #{val.z.toFixed(0)}" # Debugging: include z
|
||||
return "x: #{val.x.toFixed(0)} y: #{val.y.toFixed(0)}"
|
||||
#return "x: #{val.x.toFixed(0)} y: #{val.y.toFixed(0)}, z: #{val.z.toFixed(0)}" # Debugging: include z
|
||||
else if not val?
|
||||
return "No " + prop
|
||||
return val
|
||||
|
|
|
@ -70,6 +70,7 @@ module.exports = class Spell
|
|||
functionParameters: @parameters
|
||||
yieldConditionally: thang.plan?
|
||||
requiresThis: thang.requiresThis
|
||||
# TODO: Gridmancer doesn't currently work with protectAPI, so hack it off
|
||||
protectAPI: not (@skipProtectAPI or window.currentView?.level.get('name').match("Gridmancer"))
|
||||
includeFlow: not @skipFlow
|
||||
#callIndex: 0
|
||||
|
|
|
@ -83,6 +83,40 @@ module.exports = class DebugView extends View
|
|||
if @markerRange
|
||||
@marker = @ace.getSession().addMarker @markerRange, "ace_bracket", "text"
|
||||
|
||||
stringifyValue: (value, depth) ->
|
||||
return value if not value or _.isString value
|
||||
if _.isFunction value
|
||||
return if depth is 2 then undefined else "<Function>"
|
||||
return "<this #{value.id}>" if value is @thang and depth
|
||||
if depth is 2
|
||||
if value.constructor?.className is "Thang"
|
||||
value = "<#{value.spriteName} - #{value.id}, #{if value.pos then value.pos.toString() else 'non-physical'}>"
|
||||
else
|
||||
value = value.toString()
|
||||
return value
|
||||
|
||||
isArray = _.isArray value
|
||||
isObject = _.isObject value
|
||||
return value.toString() unless isArray or isObject
|
||||
brackets = if isArray then ["[", "]"] else ["{", "}"]
|
||||
size = _.size value
|
||||
return brackets.join "" unless size
|
||||
values = []
|
||||
if isArray
|
||||
for v in value
|
||||
s = @stringifyValue(v, depth + 1)
|
||||
values.push "" + s unless s is undefined
|
||||
else
|
||||
for key in value.apiProperties ? _.keys value
|
||||
s = @stringifyValue(value[key], depth + 1)
|
||||
values.push key + ": " + s unless s is undefined
|
||||
sep = '\n' + (" " for i in [0 ... depth]).join('')
|
||||
prefix = value.constructor?.className
|
||||
prefix ?= "Array" if isArray
|
||||
prefix ?= "Object" if isObject
|
||||
prefix = if prefix then prefix + " " else ""
|
||||
return "#{prefix}#{brackets[0]}#{sep} #{values.join(sep + ' ')}#{sep}#{brackets[1]}"
|
||||
|
||||
deserializeVariableChain: (chain) ->
|
||||
keys = []
|
||||
for prop, i in chain
|
||||
|
@ -98,11 +132,7 @@ module.exports = class DebugView extends View
|
|||
value = thang or "<Thang #{value.id} (non-existent)>"
|
||||
else
|
||||
value = theClass.deserializeFromAether(value)
|
||||
if value and not _.isString value
|
||||
if value.constructor?.className is "Thang"
|
||||
value = "<#{value.spriteName} - #{value.id}, #{if value.pos then value.pos.toString() else 'non-physical'}>"
|
||||
else
|
||||
value = value.toString()
|
||||
value = @stringifyValue value, 0
|
||||
key: keys.join("."), value: value
|
||||
|
||||
destroy: ->
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue