From e82f91d62c7866022866f95d3d49ae0d23df6f71 Mon Sep 17 00:00:00 2001 From: MrMelbert Date: Tue, 14 Nov 2023 13:49:16 -0600 Subject: [PATCH] Optimizes height filters for preference menu --- code/__DEFINES/is_helpers.dm | 3 +++ .../admin/view_variables/debug_variables.dm | 4 ++++ code/modules/client/preferences.dm | 2 +- .../code/modules/client/preferences/height.dm | 15 ++++++++++++++- 4 files changed, 22 insertions(+), 2 deletions(-) diff --git a/code/__DEFINES/is_helpers.dm b/code/__DEFINES/is_helpers.dm index 3d08f8d70992..87462aa73691 100644 --- a/code/__DEFINES/is_helpers.dm +++ b/code/__DEFINES/is_helpers.dm @@ -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 diff --git a/code/modules/admin/view_variables/debug_variables.dm b/code/modules/admin/view_variables/debug_variables.dm index f92d5de53650..0cf2f84168e6 100644 --- a/code/modules/admin/view_variables/debug_variables.dm +++ b/code/modules/admin/view_variables/debug_variables.dm @@ -41,6 +41,10 @@ item = "[name_part] = /icon ([value])" #endif + else if(isappearance(value)) + var/image/actually_an_appearance = value + item = "[name_part] = /appearance ([actually_an_appearance.icon])" + else if (isfile(value)) item = "[name_part] = '[value]'" diff --git a/code/modules/client/preferences.dm b/code/modules/client/preferences.dm index 161931bb7b09..44d6e823132b 100644 --- a/code/modules/client/preferences.dm +++ b/code/modules/client/preferences.dm @@ -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() diff --git a/maplestation_modules/code/modules/client/preferences/height.dm b/maplestation_modules/code/modules/client/preferences/height.dm index 9331a75cca01..5a67a7cde9d3 100644 --- a/maplestation_modules/code/modules/client/preferences/height.dm +++ b/maplestation_modules/code/modules/client/preferences/height.dm @@ -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)) @@ -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))