diff --git a/code/modules/admin/view_variables/view_variables.dm b/code/modules/admin/view_variables/view_variables.dm index 7203c0ba7376f..a330c337b7fa1 100644 --- a/code/modules/admin/view_variables/view_variables.dm +++ b/code/modules/admin/view_variables/view_variables.dm @@ -1,3 +1,6 @@ +#define ICON_STATE_CHECKED 1 /// this dmi is checked. We don't check this one anymore. +#define ICON_STATE_NULL 2 /// this dmi has null-named icon_state, allowing it to show a sprite on vv editor. + /client/proc/debug_variables(datum/thing in world) set category = "Debug" set name = "View Variables" @@ -32,12 +35,26 @@ if(!sprite) no_icon = TRUE - else if(isimage(thing) || isappearance(thing)) - var/image/image_object = thing + else if(isimage(thing) || isappearance) // icon_state=null shows first image even if dmi has no icon_state for null name. - // Unless dmi has a single icon_state as null name, let's skip null-name because it's confusing - if(image_object.icon_state || length(icon_states(image_object.icon)) == 1) - sprite = icon(image_object.icon, image_object.icon_state) + // This list remembers which dmi has null icon_state, to determine if icon_state=null should display a sprite + // (NOTE: icon_state="" is correct, but saying null is obvious) + var/static/list/dmi_nullstate_checklist = list() + var/image/image_object = thing + var/icon_filename_text = "[image_object.icon]" // "icon(null)" type can exist. textifying filters it. + if(icon_filename_text) + if(image_object.icon_state) + sprite = icon(image_object.icon, image_object.icon_state) + + else // it means: icon_state="" + if(!dmi_nullstate_checklist[icon_filename_text]) + dmi_nullstate_checklist[icon_filename_text] = ICON_STATE_CHECKED + if("" in icon_states(image_object.icon)) + // this dmi has nullstate. We'll allow "icon_state=null" to show image. + dmi_nullstate_checklist[icon_filename_text] = ICON_STATE_NULL + + if(dmi_nullstate_checklist[icon_filename_text] == ICON_STATE_NULL) + sprite = icon(image_object.icon, image_object.icon_state) var/sprite_text if(sprite) @@ -89,9 +106,7 @@ var/list/names = list() if(isappearance) - var/static/list/virtual_appearance_vars - if(!virtual_appearance_vars) - virtual_appearance_vars = build_virtual_appearance_vars() + var/static/list/virtual_appearance_vars = build_virtual_appearance_vars() names = virtual_appearance_vars.Copy() else if(!islist) for(var/varname in thing.vars) @@ -296,3 +311,6 @@ datumrefresh=[refid];[HrefToken()]'>Refresh /client/proc/vv_update_display(datum/thing, span, content) src << output("[span]:[content]", "variables[REF(thing)].browser:replace_span") + +#undef ICON_STATE_CHECKED +#undef ICON_STATE_NULL