Files
Bubberstation/code/modules/client/preferences/glasses.dm
Mothblocks 380ce9c300 Separate init_possible_values() from icon generation (#77660)
## About The Pull Request
`init_possible_values()` now only ever returns a list of values instead
of both values and icons. The responsibility of icon generation has
moved from this proc to a new `icon_for(value)` proc, which returns the
icon/typepath of an atom. A runtime is thrown if any value does not have
an icon.

This boosts production initialization times by 3+ seconds, but is
primarily done to allow for further optimizations of this process. As an
example, it is a mapping of value -> icon so that in the code that
executes this we can have more fine grained control over tick overrun.

As a bonus, fixes #67092.
2023-08-20 14:49:26 -07:00

24 lines
792 B
Plaintext

/datum/preference/choiced/glasses
category = PREFERENCE_CATEGORY_SECONDARY_FEATURES
savefile_key = "glasses"
savefile_identifier = PREFERENCE_CHARACTER
should_generate_icons = TRUE
/datum/preference/choiced/glasses/init_possible_values()
return assoc_to_keys(GLOB.nearsighted_glasses) + "Random"
/datum/preference/choiced/glasses/icon_for(value)
if (value == "Random")
return icon('icons/effects/random_spawners.dmi', "questionmark")
else
return icon('icons/obj/clothing/glasses.dmi', "glasses_[lowertext(value)]")
/datum/preference/choiced/glasses/is_accessible(datum/preferences/preferences)
if (!..(preferences))
return FALSE
return "Nearsighted" in preferences.all_quirks
/datum/preference/choiced/glasses/apply_to_human(mob/living/carbon/human/target, value)
return