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
This commit is contained in:
Mothblocks
2021-09-15 10:11:11 +12:00
committed by GitHub
parent a3dfa16a98
commit 5a4c87a9fc
423 changed files with 12860 additions and 3995 deletions
+2
View File
@@ -75,7 +75,9 @@
#include "outfit_sanity.dm"
#include "pills.dm"
#include "plantgrowth_tests.dm"
#include "preferences.dm"
#include "projectiles.dm"
#include "quirks.dm"
#include "rcd.dm"
#include "reagent_id_typos.dm"
#include "reagent_mod_expose.dm"
@@ -12,3 +12,25 @@
Fail("[ruleset] has a scaling_cost, but is also a lone/highlander ruleset.")
else if (!has_scaling_cost && !is_lone)
Fail("[ruleset] has no scaling cost, but is also not a lone/highlander ruleset.")
/// Verifies that dynamic rulesets have unique antag_flag.
/datum/unit_test/dynamic_unique_antag_flags
/datum/unit_test/dynamic_unique_antag_flags/Run()
var/list/known_antag_flags = list()
for (var/datum/dynamic_ruleset/ruleset as anything in subtypesof(/datum/dynamic_ruleset))
if (isnull(initial(ruleset.antag_datum)))
continue
var/antag_flag = initial(ruleset.antag_flag)
if (isnull(antag_flag))
Fail("[ruleset] has a null antag_flag!")
continue
if (antag_flag in known_antag_flags)
Fail("[ruleset] has a non-unique antag_flag [antag_flag] (used by [known_antag_flags[antag_flag]])!")
continue
known_antag_flags[antag_flag] = ruleset
+51
View File
@@ -0,0 +1,51 @@
/// Requires all preferences to implement required methods.
/datum/unit_test/preferences_implement_everything
/datum/unit_test/preferences_implement_everything/Run()
var/datum/preferences/preferences = new
var/mob/living/carbon/human/human = allocate(/mob/living/carbon/human)
for (var/preference_type in GLOB.preference_entries)
var/datum/preference/preference = GLOB.preference_entries[preference_type]
if (preference.savefile_identifier == PREFERENCE_CHARACTER)
preference.apply_to_human(human, preference.create_informed_default_value(preferences))
if (istype(preference, /datum/preference/choiced))
var/datum/preference/choiced/choiced_preference = preference
choiced_preference.init_possible_values()
// Smoke-test is_valid
preference.is_valid(TRUE)
preference.is_valid("string")
preference.is_valid(100)
preference.is_valid(list(1, 2, 3))
/// Requires all preferences to have a valid, unique savefile_identifier.
/datum/unit_test/preferences_valid_savefile_key
/datum/unit_test/preferences_valid_savefile_key/Run()
var/list/known_savefile_keys = list()
for (var/preference_type in GLOB.preference_entries)
var/datum/preference/preference = GLOB.preference_entries[preference_type]
if (!istext(preference.savefile_key))
Fail("[preference_type] has an invalid savefile_key.")
if (preference.savefile_key in known_savefile_keys)
Fail("[preference_type] has a non-unique savefile_key `[preference.savefile_key]`!")
known_savefile_keys += preference.savefile_key
/// Requires all main features have a main_feature_name
/datum/unit_test/preferences_valid_main_feature_name
/datum/unit_test/preferences_valid_main_feature_name/Run()
for (var/preference_type in GLOB.preference_entries)
var/datum/preference/choiced/preference = GLOB.preference_entries[preference_type]
if (!istype(preference))
continue
if (preference.category != PREFERENCE_CATEGORY_FEATURES && preference.category != PREFERENCE_CATEGORY_CLOTHING)
continue
TEST_ASSERT(!isnull(preference.main_feature_name), "Preference [preference_type] does not have a main_feature_name set!")
+21
View File
@@ -0,0 +1,21 @@
/// Ensure every quirk has a unique icon
/datum/unit_test/quirk_icons
/datum/unit_test/quirk_icons/Run()
var/list/used_icons = list()
for (var/datum/quirk/quirk_type as anything in subtypesof(/datum/quirk))
if (initial(quirk_type.abstract_parent_type) == quirk_type)
continue
var/icon = initial(quirk_type.icon)
if (isnull(icon))
Fail("[quirk_type] has no icon!")
continue
if (icon in used_icons)
Fail("[icon] used in both [quirk_type] and [used_icons[icon]]!")
continue
used_icons[icon] = quirk_type
@@ -4,7 +4,6 @@
/datum/unit_test/reagent_id_typos/Run()
build_chemical_reactions_lists()
build_chemical_reagent_list()
for(var/I in GLOB.chemical_reactions_list_reactant_index)
for(var/V in GLOB.chemical_reactions_list_reactant_index[I])
@@ -1,4 +1,10 @@
#define SECURITY_OFFICER_DEPARTMENTS list("a", "b", "c", "d")
#define SECURITY_OFFICER_DEPARTMENTS_TO_NAMES (list( \
"a" = SEC_DEPT_ENGINEERING, \
"b" = SEC_DEPT_MEDICAL, \
"c" = SEC_DEPT_SCIENCE, \
"d" = SEC_DEPT_SUPPLY, \
))
/// Test that security officers with specific distributions get their departments.
/datum/unit_test/security_officer_roundstart_distribution
@@ -45,17 +51,22 @@
SECURITY_OFFICER_DEPARTMENTS,
)
TEST_ASSERT_EQUAL(outcome[REF(officer_a.new_character)], "a", "Officer A's department outcome was incorrect.")
TEST_ASSERT_EQUAL(outcome[REF(officer_b.new_character)], "b", "Officer B's department outcome was incorrect.")
TEST_ASSERT_EQUAL(outcome[REF(officer_c.new_character)], "b", "Officer C's department outcome was incorrect.")
TEST_ASSERT_EQUAL(outcome[REF(officer_d.new_character)], "a", "Officer D's department outcome was incorrect.")
TEST_ASSERT_EQUAL(outcome[REF(officer_a.new_character)], SECURITY_OFFICER_DEPARTMENTS_TO_NAMES["a"], "Officer A's department outcome was incorrect.")
TEST_ASSERT_EQUAL(outcome[REF(officer_b.new_character)], SECURITY_OFFICER_DEPARTMENTS_TO_NAMES["b"], "Officer B's department outcome was incorrect.")
TEST_ASSERT_EQUAL(outcome[REF(officer_c.new_character)], SECURITY_OFFICER_DEPARTMENTS_TO_NAMES["b"], "Officer C's department outcome was incorrect.")
TEST_ASSERT_EQUAL(outcome[REF(officer_d.new_character)], SECURITY_OFFICER_DEPARTMENTS_TO_NAMES["a"], "Officer D's department outcome was incorrect.")
/datum/unit_test/security_officer_roundstart_distribution/proc/create_officer(preference)
var/mob/dead/new_player/new_player = allocate(/mob/dead/new_player)
var/datum/client_interface/mock_client = new
mock_client.prefs = new
mock_client.prefs.prefered_security_department = preference
var/write_success = mock_client.prefs.write_preference(
GLOB.preference_entries[/datum/preference/choiced/security_department],
SECURITY_OFFICER_DEPARTMENTS_TO_NAMES[preference],
)
TEST_ASSERT(write_success, "Couldn't write department [SECURITY_OFFICER_DEPARTMENTS_TO_NAMES[preference]]")
var/mob/living/carbon/human/new_character = allocate(/mob/living/carbon/human)
new_character.mind_initialize()