// Variables to not even show in the list.
// step_* and bound_* are here because they literally break the game and do nothing else.
// parent_type is here because it's pointless to show in VV.
/var/list/view_variables_hide_vars = list("bound_x", "bound_y", "bound_height", "bound_width", "bounds", "parent_type", "step_x", "step_y", "step_size")
// Variables not to expand the lists of. Vars is pointless to expand, and overlays/underlays cannot be expanded.
/var/list/view_variables_dont_expand = list("overlays", "underlays", "vars")
/client/proc/debug_variables(datum/D in world)
set category = "Debug"
set name = "View Variables"
if(!check_rights(0))
return
if(!D)
return
var/icon/sprite
if(istype(D, /atom))
var/atom/A = D
if(A.icon && A.icon_state)
sprite = icon(A.icon, A.icon_state)
usr << browse_rsc(sprite, "view_vars_sprite.png")
usr << browse_rsc('code/js/view_variables.js', "view_variables.js")
var/html = {"
[D] (\ref[D] - [D.type])
[sprite ? " | " : ""]
[D.get_view_variables_header()] |
[replacetext("[D.type]", "/", "/")]
[holder.marked_datum == D ? " Marked Object" : ""]
|
|
E - Edit, tries to determine the variable type by itself.
C - Change, asks you for the var type first.
M - Mass modify: changes this variable for all objects of this type.
[make_view_variables_var_list(D)]
"}
usr << browse(html, "window=variables\ref[D];size=475x650")
/proc/make_view_variables_var_list(datum/D)
. = ""
var/list/variables = list()
for(var/x in D.vars)
if(x in view_variables_hide_vars)
continue
variables += x
variables = sortList(variables)
for(var/x in variables)
. += make_view_variables_var_entry(D, x, D.vars[x])
/proc/make_view_variables_var_entry(datum/D, varname, value, level=0)
var/ecm = null
var/vtext = null
var/extra = null
if(D)
ecm = {"
(E)
(C)
(M)
"}
if(isnull(value))
vtext = "null"
else if(istext(value))
vtext = "\"[value]\""
else if(isicon(value))
vtext = "[value]"
else if(isfile(value))
vtext = "'[value]'"
else if(istype(value, /datum))
var/datum/DA = value
if("[DA]" == "[DA.type]" || !"[DA]")
vtext = "\ref[DA] - [DA.type]"
else
vtext = "\ref[DA] - [DA] ([DA.type])"
else if(istype(value, /client))
var/client/C = value
vtext = "\ref[C] - [C] ([C.type])"
else if(islist(value))
var/list/L = value
vtext = "/list ([L.len])"
if(!(varname in view_variables_dont_expand) && L.len > 0 && L.len < 100)
extra = ""
var/index = 1
for (var/entry in L)
if(istext(entry))
extra += make_view_variables_var_entry(null, entry, L[entry], level+1)
else
extra += make_view_variables_var_entry(null, index, L[index], level+1)
index++
extra += "
"
else
vtext = "[value]"
return "[ecm][varname] = [vtext][extra]"