Files
Bubberstation/code/modules/client/preferences/assets.dm
Mothblocks 5a4c87a9fc tgui Preferences Menu + total rewrite of the preferences backend (#61313)
About The Pull Request

Rewrites the entire preferences menu in tgui. Rewrites the entire backend to be built upon datumized preferences, rather than constant additions to the preferences base datum.

Splits game preferences into its own window.

Antagonists are now split into their individual rulesets. You can now be a roundstart heretic without signing up for latejoin heretic, as an example.

This iteration matches parity, and provides very little new functionality, but adding anything new will be much easier.

Fixes #60823
Fixes #28907
Fixes #44887
Fixes #59912
Fixes #58458
Fixes #59181
Major TODOs

Quirk icons, from @Fikou (with some slight adjustments from me)
Lore text, from @EOBGames (4/6, need moths and then ethereal lore from @AMonkeyThatCodes)
Heavy documentation on how one would add new preferences, species, jobs, etc

    A lot of specialized testing so that people's real data don't get corrupted

Changelog

cl Mothblocks, Floyd on lots of the design
refactor: The preferences menu has been completely rewritten in tgui.
refactor: The "Stop Sounds" verb has been moved to OOC.
/cl
2021-09-15 10:11:11 +12:00

67 lines
2.1 KiB
Plaintext

/// Assets generated from `/datum/preference` icons
/datum/asset/spritesheet/preferences
name = "preferences"
early = TRUE
/datum/asset/spritesheet/preferences/register()
var/list/to_insert = list()
for (var/preference_key in GLOB.preference_entries_by_key)
var/datum/preference/choiced/preference = GLOB.preference_entries_by_key[preference_key]
if (!istype(preference))
continue
if (!preference.should_generate_icons)
continue
var/list/choices = preference.get_choices_serialized()
for (var/preference_value in choices)
var/create_icon_of = choices[preference_value]
var/icon/icon
var/icon_state
if (ispath(create_icon_of, /atom))
var/atom/atom_icon_source = create_icon_of
icon = initial(atom_icon_source.icon)
icon_state = initial(atom_icon_source.icon_state)
else if (isicon(create_icon_of))
icon = create_icon_of
else
CRASH("[create_icon_of] is an invalid preference value (from [preference_key]:[preference_value]).")
to_insert[preference.get_spritesheet_key(preference_value)] = list(icon, icon_state)
for (var/spritesheet_key in to_insert)
var/list/inserting = to_insert[spritesheet_key]
Insert(spritesheet_key, inserting[1], inserting[2])
return ..()
/// Returns the key that will be used in the spritesheet for a given value.
/datum/preference/proc/get_spritesheet_key(value)
return "[savefile_key]___[sanitize_css_class_name(value)]"
/// Sends information needed for shared details on individual preferences
/datum/asset/json/preferences
name = "preferences"
/datum/asset/json/preferences/generate()
var/list/preference_data = list()
for (var/middleware_type in subtypesof(/datum/preference_middleware))
var/datum/preference_middleware/middleware = new middleware_type
var/data = middleware.get_constant_data()
if (!isnull(data))
preference_data[middleware.key] = data
qdel(middleware)
for (var/preference_type in GLOB.preference_entries)
var/datum/preference/preference_entry = GLOB.preference_entries[preference_type]
var/data = preference_entry.compile_constant_data()
if (!isnull(data))
preference_data[preference_entry.savefile_key] = data
return preference_data