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

53 lines
1.7 KiB
Plaintext

/// Preference middleware is code that helps to decentralize complicated preference features.
/datum/preference_middleware
/// The preferences datum
var/datum/preferences/preferences
/// The key that will be used for get_constant_data().
/// If null, will use the typepath minus /datum/preference_middleware.
var/key = null
/// Map of ui_act actions -> proc paths to call.
/// Signature is `(list/params, mob/user) -> TRUE/FALSE.
/// Return output is the same as ui_act--TRUE if it should update, FALSE if it should not
var/list/action_delegations = list()
/datum/preference_middleware/New(datum/preferences)
src.preferences = preferences
if (isnull(key))
// + 2 coming from the off-by-one of copytext, and then another from the slash
key = copytext("[type]", length("[parent_type]") + 2)
/datum/preference_middleware/Destroy()
preferences = null
return ..()
/// Append all of these into ui_data
/datum/preference_middleware/proc/get_ui_data(mob/user)
return list()
/// Append all of these into ui_static_data
/datum/preference_middleware/proc/get_ui_static_data(mob/user)
return list()
/// Append all of these into ui_assets
/datum/preference_middleware/proc/get_ui_assets()
return list()
/// Append all of these into /datum/asset/json/preferences.
/datum/preference_middleware/proc/get_constant_data()
return null
/// Merge this into the result of compile_character_preferences.
/datum/preference_middleware/proc/get_character_preferences(mob/user)
return null
/// Called every set_preference, returns TRUE if this handled it.
/datum/preference_middleware/proc/pre_set_preference(mob/user, preference, value)
return FALSE
/// Called when a character is changed.
/datum/preference_middleware/proc/on_new_character(mob/user)
return