Files
Bubberstation/code/modules/client/preferences/ui_style.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

25 lines
820 B
Plaintext

/// UI style preference
/datum/preference/choiced/ui_style
category = PREFERENCE_CATEGORY_GAME_PREFERENCES
savefile_identifier = PREFERENCE_PLAYER
savefile_key = "UI_style"
should_generate_icons = TRUE
/datum/preference/choiced/ui_style/init_possible_values()
return assoc_to_keys(GLOB.available_ui_styles)
/datum/preference/choiced/ui_style/icon_for(value)
var/icon/icons = GLOB.available_ui_styles[value]
var/icon/icon = icon(icons, "hand_r")
icon.Crop(1, 1, world.icon_size * 2, world.icon_size)
icon.Blend(icon(icons, "hand_l"), ICON_OVERLAY, world.icon_size)
return icon
/datum/preference/choiced/ui_style/create_default_value()
return GLOB.available_ui_styles[1]
/datum/preference/choiced/ui_style/apply_to_client(client/client, value)
client.mob?.hud_used?.update_ui_style(ui_style2icon(value))