Skip to content

Commit

Permalink
Optimizes height filters for preference menu
Browse files Browse the repository at this point in the history
  • Loading branch information
MrMelbert committed Nov 14, 2023
1 parent eaabe55 commit e82f91d
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 2 deletions.
3 changes: 3 additions & 0 deletions code/__DEFINES/is_helpers.dm
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@

#define isweakref(D) (istype(D, /datum/weakref))

GLOBAL_VAR_INIT(magic_appearance_detecting_image, new /image) // appearances are awful to detect safely, but this seems to be the best way ~ninjanomnom
#define isappearance(thing) (!istype(thing, /image) && !ispath(thing) && istype(GLOB.magic_appearance_detecting_image, thing))

#define isgenerator(A) (istype(A, /generator))

//Turfs
Expand Down
4 changes: 4 additions & 0 deletions code/modules/admin/view_variables/debug_variables.dm
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@
item = "[name_part] = /icon (<span class='value'>[value]</span>)"
#endif

else if(isappearance(value))
var/image/actually_an_appearance = value
item = "[name_part] = /appearance (<span class='value'>[actually_an_appearance.icon]</span>)"

else if (isfile(value))
item = "[name_part] = <span class='value'>'[value]'</span>"

Expand Down
2 changes: 1 addition & 1 deletion code/modules/client/preferences.dm
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ GLOBAL_LIST_EMPTY(preferences_datums)
body = new

// Without this, it doesn't show up in the menu
body.appearance_flags &= ~KEEP_TOGETHER
// body.appearance_flags &= ~KEEP_TOGETHER // NON-MODULE CHANGE

/datum/preferences/proc/create_character_profiles()
var/list/profiles = list()
Expand Down
15 changes: 14 additions & 1 deletion maplestation_modules/code/modules/client/preferences/height.dm
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
return

// Snowflake, but otherwise the dummy in the prefs menu will be resized and you can't see anything
if(istype(target, /mob/living/carbon/human/dummy))
if(isdummy(target))
return
// Just in case
if(!ishuman(target))
Expand Down Expand Up @@ -143,6 +143,19 @@
#undef SIZE_PREF_PRIORITY
#undef HEIGHT_PREF_PRIORITY

// To speed up the preference menu, we apply 1 filter to the entire mob
/mob/living/carbon/human/dummy/regenerate_icons()
. = ..()
apply_height_filters(src, TRUE)

/mob/living/carbon/human/dummy/apply_height_filters(mutable_appearance/appearance, only_apply_in_prefs = FALSE)
if(only_apply_in_prefs)
return ..()

// Not necessary with above
/mob/living/carbon/human/dummy/apply_height_offsets(mutable_appearance/appearance, upper_torso)
return

/mob/living/carbon/human/get_mob_height()
// If you have roundstart dwarfism (IE: resized), it'll just return normal mob height, so no filters are applied
if(HAS_TRAIT_FROM_ONLY(src, TRAIT_DWARF, ROUNDSTART_TRAIT))
Expand Down

0 comments on commit e82f91d

Please sign in to comment.