Skip to content

Commit

Permalink
Makes sprite file viewable
Browse files Browse the repository at this point in the history
  • Loading branch information
EvilDragonfiend committed Apr 17, 2024
1 parent 2ff2749 commit 511794b
Showing 1 changed file with 26 additions and 8 deletions.
34 changes: 26 additions & 8 deletions code/modules/admin/view_variables/view_variables.dm
Original file line number Diff line number Diff line change
@@ -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"
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -296,3 +311,6 @@ datumrefresh=[refid];[HrefToken()]'>Refresh</a>

/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

0 comments on commit 511794b

Please sign in to comment.