[MIRROR] Convert preferences to /tg/ preferences (#9797)

Co-authored-by: ShadowLarkens <shadowlarkens@gmail.com>
Co-authored-by: Kashargul <144968721+Kashargul@users.noreply.github.com>
This commit is contained in:
CHOMPStation2StaffMirrorBot
2025-01-09 02:08:43 +01:00
committed by GitHub
co-authored by ShadowLarkens Kashargul
parent 689b354903
commit 039ee85382
82 changed files with 1753 additions and 1048 deletions
+308 -5
View File
@@ -170,7 +170,7 @@ GLOBAL_LIST_INIT(preference_entries_by_key, init_preference_entries_by_key())
/// Produce a random value for the purposes of character randomization.
/// Will just create a default value by default.
/datum/preference/proc/create_random_value(datum/preferences/preferences)
/datum/preference/proc/create_random_value(datum/preferences/preferences, datum/species/current_species)
return create_informed_default_value(preferences)
/// Returns whether or not a preference can be randomized.
@@ -220,6 +220,17 @@ GLOBAL_LIST_INIT(preference_entries_by_key, init_preference_entries_by_key())
SHOULD_NOT_SLEEP(TRUE)
apply_to_client(client, value)
/// Apply this preference onto the given liivng mob.
/// Calls the according procs depending on type.
/datum/preference/proc/apply_pref_to(mob/living, value)
apply_to_living(living, value)
if(isanimal(living))
apply_to_animal(living, value)
else if(ishuman(living))
apply_to_human(living, value)
else if(issilicon(living))
apply_to_silicon(living, value)
/// Apply this preference onto the given human.
/// Must be overriden by subtypes.
/// Called when the savefile_identifier == PREFERENCE_CHARACTER.
@@ -228,6 +239,30 @@ GLOBAL_LIST_INIT(preference_entries_by_key, init_preference_entries_by_key())
SHOULD_CALL_PARENT(FALSE)
CRASH("`apply_to_human()` was not implemented for [type]!")
/// Apply this preference onto the given silicon.
/// Must be overriden by subtypes.
/// Called when the savefile_identifier == PREFERENCE_CHARACTER.
/datum/preference/proc/apply_to_silicon(mob/living/silicon/target, value)
SHOULD_NOT_SLEEP(TRUE)
SHOULD_CALL_PARENT(FALSE)
CRASH("`apply_to_human()` was not implemented for [type]!")
/// Apply this preference onto the given animal.
/// Must be overriden by subtypes.
/// Called when the savefile_identifier == PREFERENCE_CHARACTER.
/datum/preference/proc/apply_to_animal(mob/living/simple_mob/target, value)
SHOULD_NOT_SLEEP(TRUE)
SHOULD_CALL_PARENT(FALSE)
CRASH("`apply_to_human()` was not implemented for [type]!")
/// Apply this preference onto the given living.
/// Must be overriden by subtypes.
/// Called when the savefile_identifier == PREFERENCE_CHARACTER.
/datum/preference/proc/apply_to_living(mob/living/target, value)
SHOULD_NOT_SLEEP(TRUE)
SHOULD_CALL_PARENT(FALSE)
CRASH("`apply_to_human()` was not implemented for [type]!")
/// Returns which savefile to use for a given savefile identifier
/datum/preferences/proc/get_save_data_for_savefile_identifier(savefile_identifier)
RETURN_TYPE(/list)
@@ -281,6 +316,10 @@ GLOBAL_LIST_INIT(preference_entries_by_key, init_preference_entries_by_key())
/mob/proc/read_preference(preference_type)
return client?.prefs?.read_preference(preference_type)
/// Write a /datum/preference type and return its value directly to the json.
/mob/proc/write_preference_directly(preference_type, preference_value)
return client?.prefs?.write_preference_by_type(preference_type, preference_value)
/// Set a /datum/preference entry.
/// Returns TRUE for a successful preference application.
/// Returns FALSE if it is invalid.
@@ -292,6 +331,23 @@ GLOBAL_LIST_INIT(preference_entries_by_key, init_preference_entries_by_key())
value_cache[preference.type] = new_value
return success
/// Writes a value and saves to disk immediately
/// Used by things that need to directly write to the player savefile things that aren't "really" prefs
/datum/preferences/proc/write_preference_by_type(preference_type, preference_value)
var/datum/preference/preference_entry = GLOB.preference_entries[preference_type]
if(isnull(preference_entry))
CRASH("Preference type `[preference_type]` is invalid!")
if(!write_preference(preference_entry, preference_entry.pref_serialize(preference_value)))
return
if(preference_entry.savefile_identifier == PREFERENCE_CHARACTER)
var/save_data = get_save_data_for_savefile_identifier(preference_entry.savefile_identifier)
player_setup.save_character(save_data)
else
savefile.save()
return TRUE
/// Will perform an update on the preference, but not write to the savefile.
/// This will, for instance, update the character preference view.
/// Performs sanity checks.
@@ -315,6 +371,13 @@ GLOBAL_LIST_INIT(preference_entries_by_key, init_preference_entries_by_key())
return TRUE
/datum/preferences/proc/update_preference_by_type(preference_type, preference_value)
var/datum/preference/preference_entry = GLOB.preference_entries[preference_type]
if(isnull(preference_entry))
CRASH("Preference type `[preference_type]` is invalid!")
return update_preference(preference_entry, preference_value)
/// Checks that a given value is valid.
/// Must be overriden by subtypes.
/// Any type can be passed through.
@@ -354,8 +417,9 @@ GLOBAL_LIST_INIT(preference_entries_by_key, init_preference_entries_by_key())
// if(!(savefile_key in species.get_features()))
// return FALSE
if(!should_show_on_page(preferences.current_window))
return FALSE
// TODO: Restore when tgui
// if(!should_show_on_page(preferences.current_window))
// return FALSE
return TRUE
@@ -444,8 +508,8 @@ GLOBAL_LIST_INIT(preference_entries_by_key, init_preference_entries_by_key())
if(should_generate_icons)
var/list/icons = list()
// for(var/choice in choices) // TODO: Pref spritesheet asset
// icons[choice] = get_spritesheet_key(choice)
for(var/choice in choices)
icons[choice] = get_spritesheet_key(choice)
data["icons"] = icons
@@ -454,6 +518,54 @@ GLOBAL_LIST_INIT(preference_entries_by_key, init_preference_entries_by_key())
return data
/datum/preference/choiced/human
abstract_type = /datum/preference/choiced/human
/datum/preference/choiced/human/apply_to_living(mob/living/target, value)
return
/datum/preference/choiced/human/apply_to_silicon(mob/living/silicon/target, value)
return
/datum/preference/choiced/human/apply_to_animal(mob/living/simple_mob, value)
return
/datum/preference/choiced/living
abstract_type = /datum/preference/choiced/living
/datum/preference/choiced/living/apply_to_human(mob/living/carbon/human/target, value)
return
/datum/preference/choiced/living/apply_to_silicon(mob/living/silicon/target, value)
return
/datum/preference/choiced/living/apply_to_animal(mob/living/simple_mob, value)
return
/datum/preference/choiced/silicon
abstract_type = /datum/preference/choiced/silicon
/datum/preference/choiced/silicon/apply_to_human(mob/living/carbon/human/target, value)
return
/datum/preference/choiced/silicon/apply_to_living(mob/living/target, value)
return
/datum/preference/choiced/silicon/apply_to_animal(mob/living/simple_mob, value)
return
/datum/preference/choiced/animal
abstract_type = /datum/preference/choiced/animal
/datum/preference/choiced/animal/apply_to_human(mob/living/carbon/human/target, value)
return
/datum/preference/choiced/animal/apply_to_living(mob/living/target, value)
return
/datum/preference/choiced/animal/apply_to_silicon(mob/living/silicon/target, value)
return
/// A preference that represents an RGB color of something.
/// Will give the value as 6 hex digits, without a hash.
/datum/preference/color
@@ -471,6 +583,54 @@ GLOBAL_LIST_INIT(preference_entries_by_key, init_preference_entries_by_key())
/datum/preference/color/is_valid(value)
return findtext(value, GLOB.is_color)
/datum/preference/color/human
abstract_type = /datum/preference/color/human
/datum/preference/color/human/apply_to_living(mob/living/target, value)
return
/datum/preference/color/human/apply_to_silicon(mob/living/silicon/target, value)
return
/datum/preference/color/human/apply_to_animal(mob/living/simple_mob, value)
return
/datum/preference/color/living
abstract_type = /datum/preference/color/living
/datum/preference/color/living/apply_to_human(mob/living/carbon/human/target, value)
return
/datum/preference/color/living/apply_to_silicon(mob/living/silicon/target, value)
return
/datum/preference/color/living/apply_to_animal(mob/living/simple_mob, value)
return
/datum/preference/color/silicon
abstract_type = /datum/preference/color/silicon
/datum/preference/color/silicon/apply_to_human(mob/living/carbon/human/target, value)
return
/datum/preference/color/silicon/apply_to_living(mob/living/target, value)
return
/datum/preference/color/silicon/apply_to_animal(mob/living/simple_mob, value)
return
/datum/preference/color/animal
abstract_type = /datum/preference/color/animal
/datum/preference/color/animal/apply_to_human(mob/living/carbon/human/target, value)
return
/datum/preference/color/animal/apply_to_living(mob/living/target, value)
return
/datum/preference/color/animal/apply_to_silicon(mob/living/silicon/target, value)
return
/// A numeric preference with a minimum and maximum value
/datum/preference/numeric
/// The minimum value
@@ -505,6 +665,54 @@ GLOBAL_LIST_INIT(preference_entries_by_key, init_preference_entries_by_key())
"step" = step,
)
/datum/preference/numeric/human
abstract_type = /datum/preference/numeric/human
/datum/preference/numeric/human/apply_to_living(mob/living/target, value)
return
/datum/preference/numeric/human/apply_to_silicon(mob/living/silicon/target, value)
return
/datum/preference/numeric/human/apply_to_animal(mob/living/simple_mob, value)
return
/datum/preference/numeric/living
abstract_type = /datum/preference/numeric/living
/datum/preference/numeric/living/apply_to_human(mob/living/carbon/human/target, value)
return
/datum/preference/numeric/living/apply_to_silicon(mob/living/silicon/target, value)
return
/datum/preference/numeric/living/apply_to_animal(mob/living/simple_mob, value)
return
/datum/preference/numeric/silicon
abstract_type = /datum/preference/numeric/silicon
/datum/preference/numeric/silicon/apply_to_human(mob/living/carbon/human/target, value)
return
/datum/preference/numeric/silicon/apply_to_living(mob/living/target, value)
return
/datum/preference/numeric/silicon/apply_to_animal(mob/living/simple_mob, value)
return
/datum/preference/numeric/animal
abstract_type = /datum/preference/numeric/animal
/datum/preference/numeric/animal/apply_to_human(mob/living/carbon/human/target, value)
return
/datum/preference/numeric/animal/apply_to_living(mob/living/target, value)
return
/datum/preference/numeric/animal/apply_to_silicon(mob/living/silicon/target, value)
return
/// A preference whose value is always TRUE or FALSE
/datum/preference/toggle
abstract_type = /datum/preference/toggle
@@ -521,6 +729,53 @@ GLOBAL_LIST_INIT(preference_entries_by_key, init_preference_entries_by_key())
/datum/preference/toggle/is_valid(value)
return value == TRUE || value == FALSE
/datum/preference/toggle/human
abstract_type = /datum/preference/toggle/human
/datum/preference/toggle/human/apply_to_living(mob/living/target, value)
return
/datum/preference/toggle/human/apply_to_silicon(mob/living/silicon/target, value)
return
/datum/preference/toggle/human/apply_to_animal(mob/living/simple_mob, value)
return
/datum/preference/toggle/living
abstract_type = /datum/preference/toggle/living
/datum/preference/toggle/living/apply_to_human(mob/living/carbon/human/target, value)
return
/datum/preference/toggle/living/apply_to_silicon(mob/living/silicon/target, value)
return
/datum/preference/toggle/living/apply_to_animal(mob/living/simple_mob, value)
return
/datum/preference/toggle/silicon
abstract_type = /datum/preference/toggle/silicon
/datum/preference/toggle/silicon/apply_to_human(mob/living/carbon/human/target, value)
return
/datum/preference/toggle/silicon/apply_to_living(mob/living/target, value)
return
/datum/preference/toggle/silicon/apply_to_animal(mob/living/simple_mob, value)
return
/datum/preference/toggle/animal
abstract_type = /datum/preference/toggle/animal
/datum/preference/toggle/animal/apply_to_human(mob/living/carbon/human/target, value)
return
/datum/preference/toggle/animal/apply_to_living(mob/living/target, value)
return
/datum/preference/toggle/animal/apply_to_silicon(mob/living/silicon/target, value)
return
/// A string-based preference accepting arbitrary string values entered by the user, with a maximum length.
/datum/preference/text
@@ -544,3 +799,51 @@ GLOBAL_LIST_INIT(preference_entries_by_key, init_preference_entries_by_key())
/datum/preference/text/compile_constant_data()
return list("maximum_length" = maximum_value_length)
/datum/preference/text/human
abstract_type = /datum/preference/text/human
/datum/preference/text/human/apply_to_living(mob/living/target, value)
return
/datum/preference/text/human/apply_to_silicon(mob/living/silicon/target, value)
return
/datum/preference/text/human/apply_to_animal(mob/living/simple_mob, value)
return
/datum/preference/text/living
abstract_type = /datum/preference/text/living
/datum/preference/text/living/apply_to_human(mob/living/carbon/human/target, value)
return
/datum/preference/text/living/apply_to_silicon(mob/living/silicon/target, value)
return
/datum/preference/text/living/apply_to_animal(mob/living/simple_mob, value)
return
/datum/preference/text/silicon
abstract_type = /datum/preference/text/silicon
/datum/preference/text/silicon/apply_to_human(mob/living/carbon/human/target, value)
return
/datum/preference/text/silicon/apply_to_living(mob/living/target, value)
return
/datum/preference/text/silicon/apply_to_animal(mob/living/simple_mob, value)
return
/datum/preference/text/animal
abstract_type = /datum/preference/text/animal
/datum/preference/text/animal/apply_to_human(mob/living/carbon/human/target, value)
return
/datum/preference/text/animal/apply_to_living(mob/living/target, value)
return
/datum/preference/text/animal/apply_to_silicon(mob/living/silicon/target, value)
return
@@ -0,0 +1,84 @@
/// Middleware for handling randomization preferences
/datum/preference_middleware/random
action_delegations = list(
"randomize_character" = PROC_REF(randomize_character),
"set_random_preference" = PROC_REF(set_random_preference),
)
/datum/preference_middleware/random/get_character_preferences(mob/user)
return list(
"randomization" = preferences.randomise,
)
/datum/preference_middleware/random/get_constant_data()
var/list/randomizable = list()
for (var/preference_type in GLOB.preference_entries)
var/datum/preference/preference = GLOB.preference_entries[preference_type]
if (!preference.is_randomizable())
continue
randomizable += preference.savefile_key
return list(
"randomizable" = randomizable,
)
/datum/preference_middleware/random/proc/randomize_character()
for (var/datum/preference/preference as anything in get_preferences_in_priority_order())
if (preferences.should_randomize(preference))
preferences.write_preference(preference, preference.create_random_value(preferences))
// preferences.character_preview_view.update_body()
return TRUE
/datum/preference_middleware/random/proc/set_random_preference(list/params, mob/user)
var/requested_preference_key = params["preference"]
var/value = params["value"]
var/datum/preference/requested_preference = GLOB.preference_entries_by_key[requested_preference_key]
if (isnull(requested_preference))
return FALSE
if (!requested_preference.is_randomizable())
return FALSE
if (value == RANDOM_ANTAG_ONLY)
preferences.randomise[requested_preference_key] = RANDOM_ANTAG_ONLY
else if (value == RANDOM_ENABLED)
preferences.randomise[requested_preference_key] = RANDOM_ENABLED
else if (value == RANDOM_DISABLED)
preferences.randomise -= requested_preference_key
else
return FALSE
return TRUE
/// Returns if a preference should be randomized.
/datum/preferences/proc/should_randomize(datum/preference/preference, is_antag)
if (!preference.is_randomizable())
return FALSE
var/requested_randomization = randomise[preference.savefile_key]
//if (istype(preference, /datum/preference/name))
// requested_randomization = read_preference(/datum/preference/choiced/random_name)
switch (requested_randomization)
if (RANDOM_ENABLED)
return TRUE
if (RANDOM_ANTAG_ONLY)
return is_antag
else
return FALSE
/// Given randomization flags, will return whether or not this preference should be randomized.
/datum/preference/proc/included_in_randomization_flags(randomize_flags)
return TRUE
// /datum/preference/name/included_in_randomization_flags(randomize_flags)
// return !!(randomize_flags & RANDOMIZE_NAME)
// /datum/preference/choiced/species/included_in_randomization_flags(randomize_flags)
// return !!(randomize_flags & RANDOMIZE_SPECIES)
@@ -0,0 +1,25 @@
/// Moves r_g_b_ affixes to single hex colors
/datum/preferences/proc/migration_16_colors(datum/json_savefile/S)
for(var/slot in 1 to CONFIG_GET(number/character_slots))
var/list/prefs = S.get_entry("character[slot]", null)
if(!islist(prefs))
continue
prefs["hair_color"] = rgb(prefs["hair_red"], prefs["hair_green"], prefs["hair_blue"])
prefs["facial_color"] = rgb(prefs["facial_red"], prefs["facial_green"], prefs["facial_blue"])
prefs["grad_color"] = rgb(prefs["grad_red"], prefs["grad_green"], prefs["grad_blue"])
prefs["skin_color"] = rgb(prefs["skin_red"], prefs["skin_green"], prefs["skin_blue"])
prefs["eyes_color"] = rgb(prefs["eyes_red"], prefs["eyes_green"], prefs["eyes_blue"])
prefs["synth_color_rgb"] = rgb(prefs["synth_red"], prefs["synth_green"], prefs["synth_blue"])
prefs["ears_color1"] = rgb(prefs["r_ears"], prefs["g_ears"], prefs["b_ears"])
prefs["ears_color2"] = rgb(prefs["r_ears2"], prefs["g_ears2"], prefs["b_ears2"])
prefs["ears_color3"] = rgb(prefs["r_ears3"], prefs["g_ears3"], prefs["b_ears3"])
prefs["tail_color1"] = rgb(prefs["r_tail"], prefs["g_tail"], prefs["b_tail"])
prefs["tail_color2"] = rgb(prefs["r_tail2"], prefs["g_tail2"], prefs["b_tail2"])
prefs["tail_color3"] = rgb(prefs["r_tail3"], prefs["g_tail3"], prefs["b_tail3"])
prefs["wing_color1"] = rgb(prefs["r_wing"], prefs["g_wing"], prefs["b_wing"])
prefs["wing_color2"] = rgb(prefs["r_wing2"], prefs["g_wing2"], prefs["b_wing2"])
prefs["wing_color3"] = rgb(prefs["r_wing3"], prefs["g_wing3"], prefs["b_wing3"])
@@ -0,0 +1,18 @@
/datum/preference/choiced/uplinklocation
category = PREFERENCE_CATEGORY_NON_CONTEXTUAL
savefile_key = "uplinklocation"
savefile_identifier = PREFERENCE_CHARACTER
can_randomize = FALSE
/datum/preference/choiced/uplinklocation/init_possible_values()
return GLOB.uplink_locations
// No application
/datum/preference/choiced/uplinklocation/apply_to_living(mob/living/target, value)
return
/datum/preference/choiced/uplinklocation/apply_to_animal(mob/living/simple_mob/target, value)
return
/datum/preference/choiced/uplinklocation/apply_to_human(mob/living/carbon/human/target, value)
return
/datum/preference/choiced/uplinklocation/apply_to_silicon(mob/living/silicon/target, value)
return
@@ -0,0 +1,175 @@
// Toggles
/datum/preference/toggle/human/bday_announce
category = PREFERENCE_CATEGORY_NON_CONTEXTUAL
savefile_key = "bday_announce"
default_value = FALSE
savefile_identifier = PREFERENCE_CHARACTER
can_randomize = FALSE
/datum/preference/toggle/human/bday_announce/apply_to_human(mob/living/carbon/human/target, value)
return
// Numerics
/datum/preference/numeric/human/age
category = PREFERENCE_CATEGORY_MANUALLY_RENDERED
savefile_key = "age"
savefile_identifier = PREFERENCE_CHARACTER
step = 1
minimum = 18
maximum = 250
/datum/preference/numeric/human/age/apply_to_human(mob/living/carbon/human/target, value)
target.age = value
return
/datum/preference/numeric/human/age/create_default_value()
return 18
/datum/preference/numeric/human/age/create_random_value(datum/preferences/preferences, datum/species/current_species)
return rand(current_species.min_age, current_species.max_age)
/datum/preference/numeric/human/bday_month
category = PREFERENCE_CATEGORY_MANUALLY_RENDERED
savefile_key = "bday_month"
savefile_identifier = PREFERENCE_CHARACTER
can_randomize = FALSE
step = 1
minimum = 0
maximum = 12
/datum/preference/numeric/human/bday_month/apply_to_human(mob/living/carbon/human/target, value)
return
/datum/preference/numeric/human/bday_month/create_default_value()
return 0
/datum/preference/numeric/human/bday_day
category = PREFERENCE_CATEGORY_MANUALLY_RENDERED
savefile_key = "bday_day"
savefile_identifier = PREFERENCE_CHARACTER
can_randomize = FALSE
step = 1
minimum = 0
maximum = 31
/datum/preference/numeric/human/bday_day/apply_to_human(mob/living/carbon/human/target, value)
return
/datum/preference/numeric/human/bday_day/create_default_value()
return 0
/datum/preference/numeric/human/last_bday_note
category = PREFERENCE_CATEGORY_MANUALLY_RENDERED
savefile_key = "last_bday_note"
savefile_identifier = PREFERENCE_CHARACTER
can_randomize = FALSE
step = 1
minimum = 0
maximum = 9999
/datum/preference/numeric/human/last_bday_note/apply_to_human(mob/living/carbon/human/target, value)
return
/datum/preference/numeric/human/last_bday_note/create_default_value()
return 0
/datum/preference/numeric/human/last_bday_note/is_accessible(datum/preferences/preferences)
..()
return FALSE
/datum/preference/text/living/ooc_notes
category = PREFERENCE_CATEGORY_MANUALLY_RENDERED
savefile_identifier = PREFERENCE_CHARACTER
savefile_key = "OOC_Notes"
maximum_value_length = MAX_MESSAGE_LEN * 4
can_randomize = FALSE
/datum/preference/text/living/ooc_notes/apply_to_living(mob/living/target, value)
target.ooc_notes = value
return
/datum/preference/text/living/ooc_notes_likes
category = PREFERENCE_CATEGORY_MANUALLY_RENDERED
savefile_identifier = PREFERENCE_CHARACTER
savefile_key = "OOC_Notes_Likes"
maximum_value_length = MAX_MESSAGE_LEN * 2
can_randomize = FALSE
/datum/preference/text/living/ooc_notes_likes/apply_to_living(mob/living/target, value)
target.ooc_notes_likes = value
return
/datum/preference/text/living/ooc_notes_dislikes
category = PREFERENCE_CATEGORY_MANUALLY_RENDERED
savefile_identifier = PREFERENCE_CHARACTER
savefile_key = "OOC_Notes_Disikes"
maximum_value_length = MAX_MESSAGE_LEN * 2
can_randomize = FALSE
/datum/preference/text/living/ooc_notes_dislikes/apply_to_living(mob/living/target, value)
target.ooc_notes_dislikes = value
return
// CHOMP specific, but added here not to forget
/datum/preference/toggle/living/ooc_notes_style
category = PREFERENCE_CATEGORY_MANUALLY_RENDERED
savefile_key = "OOC_Notes_System"
default_value = FALSE
savefile_identifier = PREFERENCE_CHARACTER
can_randomize = FALSE
/datum/preference/toggle/living/ooc_notes_style/apply_to_living(mob/living/target, value)
target.ooc_notes_style = value // CHOMPEnable
return
/datum/preference/text/living/ooc_notes_maybes
category = PREFERENCE_CATEGORY_MANUALLY_RENDERED
savefile_identifier = PREFERENCE_CHARACTER
savefile_key = "OOC_Notes_Maybes"
maximum_value_length = MAX_MESSAGE_LEN * 2
can_randomize = FALSE
/datum/preference/text/living/ooc_notes_maybes/apply_to_living(mob/living/target, value)
target.ooc_notes_maybes = value // CHOMPEnable
return
/datum/preference/text/living/ooc_notes_favs
category = PREFERENCE_CATEGORY_MANUALLY_RENDERED
savefile_identifier = PREFERENCE_CHARACTER
savefile_key = "OOC_Notes_Favs"
maximum_value_length = MAX_MESSAGE_LEN * 2
can_randomize = FALSE
/datum/preference/text/living/ooc_notes_favs/apply_to_living(mob/living/target, value)
target.ooc_notes_favs = value // CHOMPEnable
return
/datum/preference/toggle/human/name_is_always_random
category = PREFERENCE_CATEGORY_MANUALLY_RENDERED
savefile_key = "name_is_always_random"
default_value = FALSE
savefile_identifier = PREFERENCE_CHARACTER
can_randomize = FALSE
/datum/preference/toggle/human/name_is_always_random/apply_to_human(mob/living/carbon/human/target, value)
return // handled in copy_to
/datum/preference/choiced/living/spawnpoint
category = PREFERENCE_CATEGORY_MANUALLY_RENDERED
savefile_key = "spawnpoint"
savefile_identifier = PREFERENCE_CHARACTER
can_randomize = FALSE
/datum/preference/choiced/living/spawnpoint/init_possible_values()
var/list/spawnkeys = list()
for(var/spawntype in get_spawn_points())
spawnkeys += spawntype
return spawnkeys
/datum/preference/choiced/living/spawnpoint/apply_to_living(mob/living/target, value)
return // handled in job_controller
@@ -0,0 +1,166 @@
/datum/preference/color/human/hair_color
category = PREFERENCE_CATEGORY_MANUALLY_RENDERED
savefile_identifier = PREFERENCE_CHARACTER
savefile_key = "hair_color"
can_randomize = FALSE
/datum/preference/color/human/hair_color/apply_to_human(mob/living/carbon/human/target, value)
target.r_hair = hex2num(copytext(value, 2, 4))
target.g_hair = hex2num(copytext(value, 4, 6))
target.b_hair = hex2num(copytext(value, 6, 8))
/datum/preference/color/human/grad_color
category = PREFERENCE_CATEGORY_MANUALLY_RENDERED
savefile_identifier = PREFERENCE_CHARACTER
savefile_key = "grad_color"
can_randomize = FALSE
/datum/preference/color/human/grad_color/apply_to_human(mob/living/carbon/human/target, value)
target.r_grad = hex2num(copytext(value, 2, 4))
target.g_grad = hex2num(copytext(value, 4, 6))
target.b_grad = hex2num(copytext(value, 6, 8))
/datum/preference/color/human/facial_color
category = PREFERENCE_CATEGORY_MANUALLY_RENDERED
savefile_identifier = PREFERENCE_CHARACTER
savefile_key = "facial_color"
can_randomize = FALSE
/datum/preference/color/human/facial_color/apply_to_human(mob/living/carbon/human/target, value)
target.r_facial = hex2num(copytext(value, 2, 4))
target.g_facial = hex2num(copytext(value, 4, 6))
target.b_facial = hex2num(copytext(value, 6, 8))
/datum/preference/color/human/eyes_color
category = PREFERENCE_CATEGORY_MANUALLY_RENDERED
savefile_identifier = PREFERENCE_CHARACTER
savefile_key = "eyes_color"
can_randomize = FALSE
/datum/preference/color/human/eyes_color/apply_to_human(mob/living/carbon/human/target, value)
target.r_eyes = hex2num(copytext(value, 2, 4))
target.g_eyes = hex2num(copytext(value, 4, 6))
target.b_eyes = hex2num(copytext(value, 6, 8))
/datum/preference/color/human/skin_color
category = PREFERENCE_CATEGORY_MANUALLY_RENDERED
savefile_identifier = PREFERENCE_CHARACTER
savefile_key = "skin_color"
can_randomize = FALSE
/datum/preference/color/human/skin_color/apply_to_human(mob/living/carbon/human/target, value)
target.r_skin = hex2num(copytext(value, 2, 4))
target.g_skin = hex2num(copytext(value, 4, 6))
target.b_skin = hex2num(copytext(value, 6, 8))
/datum/preference/color/human/synth_color
category = PREFERENCE_CATEGORY_MANUALLY_RENDERED
savefile_identifier = PREFERENCE_CHARACTER
savefile_key = "synth_color_rgb"
can_randomize = FALSE
/datum/preference/color/human/synth_color/apply_to_human(mob/living/carbon/human/target, value)
target.r_synth = hex2num(copytext(value, 2, 4))
target.g_synth = hex2num(copytext(value, 4, 6))
target.b_synth = hex2num(copytext(value, 6, 8))
/datum/preference/color/human/tail_color1
category = PREFERENCE_CATEGORY_MANUALLY_RENDERED
savefile_identifier = PREFERENCE_CHARACTER
savefile_key = "tail_color1"
can_randomize = FALSE
/datum/preference/color/human/tail_color1/apply_to_human(mob/living/carbon/human/target, value)
target.r_tail = hex2num(copytext(value, 2, 4))
target.g_tail = hex2num(copytext(value, 4, 6))
target.b_tail = hex2num(copytext(value, 6, 8))
/datum/preference/color/human/tail_color2
category = PREFERENCE_CATEGORY_MANUALLY_RENDERED
savefile_identifier = PREFERENCE_CHARACTER
savefile_key = "tail_color2"
can_randomize = FALSE
/datum/preference/color/human/tail_color2/apply_to_human(mob/living/carbon/human/target, value)
target.r_tail2 = hex2num(copytext(value, 2, 4))
target.g_tail2 = hex2num(copytext(value, 4, 6))
target.b_tail2 = hex2num(copytext(value, 6, 8))
/datum/preference/color/human/tail_color3
category = PREFERENCE_CATEGORY_MANUALLY_RENDERED
savefile_identifier = PREFERENCE_CHARACTER
savefile_key = "tail_color3"
can_randomize = FALSE
/datum/preference/color/human/tail_color3/apply_to_human(mob/living/carbon/human/target, value)
target.r_tail3 = hex2num(copytext(value, 2, 4))
target.g_tail3 = hex2num(copytext(value, 4, 6))
target.b_tail3 = hex2num(copytext(value, 6, 8))
/datum/preference/color/human/wing_color1
category = PREFERENCE_CATEGORY_MANUALLY_RENDERED
savefile_identifier = PREFERENCE_CHARACTER
savefile_key = "wing_color1"
can_randomize = FALSE
/datum/preference/color/human/wing_color1/apply_to_human(mob/living/carbon/human/target, value)
target.r_wing = hex2num(copytext(value, 2, 4))
target.g_wing = hex2num(copytext(value, 4, 6))
target.b_wing = hex2num(copytext(value, 6, 8))
/datum/preference/color/human/wing_color2
category = PREFERENCE_CATEGORY_MANUALLY_RENDERED
savefile_identifier = PREFERENCE_CHARACTER
savefile_key = "wing_color2"
can_randomize = FALSE
/datum/preference/color/human/wing_color2/apply_to_human(mob/living/carbon/human/target, value)
target.r_wing2 = hex2num(copytext(value, 2, 4))
target.g_wing2 = hex2num(copytext(value, 4, 6))
target.b_wing2 = hex2num(copytext(value, 6, 8))
/datum/preference/color/human/wing_color3
category = PREFERENCE_CATEGORY_MANUALLY_RENDERED
savefile_identifier = PREFERENCE_CHARACTER
savefile_key = "wing_color3"
can_randomize = FALSE
/datum/preference/color/human/wing_color3/apply_to_human(mob/living/carbon/human/target, value)
target.r_wing3 = hex2num(copytext(value, 2, 4))
target.g_wing3 = hex2num(copytext(value, 4, 6))
target.b_wing3 = hex2num(copytext(value, 6, 8))
/datum/preference/color/human/ears_color1
category = PREFERENCE_CATEGORY_MANUALLY_RENDERED
savefile_identifier = PREFERENCE_CHARACTER
savefile_key = "ears_color1"
can_randomize = FALSE
/datum/preference/color/human/ears_color1/apply_to_human(mob/living/carbon/human/target, value)
target.r_ears = hex2num(copytext(value, 2, 4))
target.g_ears = hex2num(copytext(value, 4, 6))
target.b_ears = hex2num(copytext(value, 6, 8))
/datum/preference/color/human/ears_color2
category = PREFERENCE_CATEGORY_MANUALLY_RENDERED
savefile_identifier = PREFERENCE_CHARACTER
savefile_key = "ears_color2"
can_randomize = FALSE
/datum/preference/color/human/ears_color2/apply_to_human(mob/living/carbon/human/target, value)
target.r_ears2 = hex2num(copytext(value, 2, 4))
target.g_ears2 = hex2num(copytext(value, 4, 6))
target.b_ears2 = hex2num(copytext(value, 6, 8))
/datum/preference/color/human/ears_color3
category = PREFERENCE_CATEGORY_MANUALLY_RENDERED
savefile_identifier = PREFERENCE_CHARACTER
savefile_key = "ears_color3"
can_randomize = FALSE
/datum/preference/color/human/ears_color3/apply_to_human(mob/living/carbon/human/target, value)
target.r_ears3 = hex2num(copytext(value, 2, 4))
target.g_ears3 = hex2num(copytext(value, 4, 6))
target.b_ears3 = hex2num(copytext(value, 6, 8))
@@ -71,3 +71,18 @@
savefile_key = "CHAT_ADSAY"
default_value = TRUE
savefile_identifier = PREFERENCE_PLAYER
/// The color admins will speak in for OOC.
/datum/preference/color/ooc_color
category = PREFERENCE_CATEGORY_GAME_PREFERENCES
savefile_key = "ooccolor"
savefile_identifier = PREFERENCE_PLAYER
/datum/preference/color/ooc_color/create_default_value()
return "#010000"
/datum/preference/color/ooc_color/is_accessible(datum/preferences/preferences)
if(!..(preferences))
return FALSE
return CONFIG_GET(flag/allow_admin_ooccolor) && check_rights(R_ADMIN|R_EVENT|R_FUN, 0, preferences.client)
@@ -0,0 +1,20 @@
/datum/preference/numeric/fps
category = PREFERENCE_CATEGORY_GAME_PREFERENCES
savefile_key = "client_fps"
savefile_identifier = PREFERENCE_PLAYER
minimum = -1
maximum = MAX_CLIENT_FPS
/datum/preference/numeric/fps/create_default_value()
return -1
/datum/preference/numeric/fps/apply_to_client(client/client, value)
client.fps = (value < 0) ? RECOMMENDED_FPS : value
/datum/preference/numeric/fps/compile_constant_data()
var/list/data = ..()
data["recommended_fps"] = RECOMMENDED_FPS
return data
@@ -0,0 +1,17 @@
/datum/preference/ignored_players
category = PREFERENCE_CATEGORY_GAME_PREFERENCES
savefile_key = "ignored_players"
savefile_identifier = PREFERENCE_PLAYER
/datum/preference/ignored_players/is_valid(value)
return TRUE
/datum/preference/ignored_players/pref_deserialize(input, datum/preferences/preferences)
return SANITIZE_LIST(input)
/datum/preference/ignored_players/create_default_value()
return list()
/datum/preference/ignored_players/is_accessible(datum/preferences/preferences)
. = ..()
return FALSE
@@ -11,18 +11,6 @@
PH.set_ao(VIS_OBJS, value)
PH.set_ao(VIS_MOBS, value)
/datum/preference/toggle/mob_tooltips
category = PREFERENCE_CATEGORY_GAME_PREFERENCES
savefile_key = "MOB_TOOLTIPS"
default_value = TRUE
savefile_identifier = PREFERENCE_PLAYER
/datum/preference/toggle/inv_tooltips
category = PREFERENCE_CATEGORY_GAME_PREFERENCES
savefile_key = "INV_TOOLTIPS"
default_value = TRUE
savefile_identifier = PREFERENCE_PLAYER
/datum/preference/toggle/attack_icons
category = PREFERENCE_CATEGORY_GAME_PREFERENCES
savefile_key = "ATTACK_ICONS"
@@ -93,3 +81,15 @@
winset(client, null, "browser-options=[DEFAULT_CLIENT_BROWSER_OPTIONS],devtools")
else
winset(client, null, "browser-options=[DEFAULT_CLIENT_BROWSER_OPTIONS]")
/datum/preference/toggle/obfuscate_key
category = PREFERENCE_CATEGORY_GAME_PREFERENCES
savefile_key = "obfuscate_key"
default_value = FALSE
savefile_identifier = PREFERENCE_PLAYER
/datum/preference/toggle/obfuscate_job
category = PREFERENCE_CATEGORY_GAME_PREFERENCES
savefile_key = "obfuscate_job"
default_value = FALSE
savefile_identifier = PREFERENCE_PLAYER
@@ -147,3 +147,23 @@
savefile_key = "DIGEST_NOISES"
default_value = TRUE
savefile_identifier = PREFERENCE_PLAYER
/datum/preference/numeric/ambience_freq
category = PREFERENCE_CATEGORY_GAME_PREFERENCES
savefile_key = "ambience_freq"
savefile_identifier = PREFERENCE_PLAYER
minimum = 0
maximum = 60
/datum/preference/numeric/ambience_freq/create_default_value()
return 5
/datum/preference/numeric/ambience_chance
category = PREFERENCE_CATEGORY_GAME_PREFERENCES
savefile_key = "ambience_chance"
savefile_identifier = PREFERENCE_PLAYER
minimum = 0
maximum = 100
/datum/preference/numeric/ambience_chance/create_default_value()
return 35
@@ -0,0 +1,22 @@
/datum/preference/toggle/mob_tooltips
category = PREFERENCE_CATEGORY_GAME_PREFERENCES
savefile_key = "MOB_TOOLTIPS"
default_value = TRUE
savefile_identifier = PREFERENCE_PLAYER
/datum/preference/toggle/inv_tooltips
category = PREFERENCE_CATEGORY_GAME_PREFERENCES
savefile_key = "INV_TOOLTIPS"
default_value = TRUE
savefile_identifier = PREFERENCE_PLAYER
/datum/preference/choiced/tooltip_style
category = PREFERENCE_CATEGORY_GAME_PREFERENCES
savefile_key = "tooltipstyle"
savefile_identifier = PREFERENCE_PLAYER
/datum/preference/choiced/tooltip_style/init_possible_values()
return all_tooltip_styles
/datum/preference/choiced/tooltip_style/create_default_value()
return all_tooltip_styles[1]
@@ -21,6 +21,36 @@
if(before != client.tgui_panel.oldchat)
client.nuke_chat()
/datum/preference/toggle/tgui_fancy
category = PREFERENCE_CATEGORY_GAME_PREFERENCES
savefile_key = "tgui_fancy"
default_value = TRUE
savefile_identifier = PREFERENCE_PLAYER
/datum/preference/toggle/tgui_lock
category = PREFERENCE_CATEGORY_GAME_PREFERENCES
savefile_key = "tgui_lock"
default_value = FALSE
savefile_identifier = PREFERENCE_PLAYER
/datum/preference/toggle/tgui_input_mode
category = PREFERENCE_CATEGORY_GAME_PREFERENCES
savefile_key = "tgui_input_mode"
default_value = FALSE
savefile_identifier = PREFERENCE_PLAYER
/datum/preference/toggle/tgui_large_buttons
category = PREFERENCE_CATEGORY_GAME_PREFERENCES
savefile_key = "tgui_large_buttons"
default_value = TRUE
savefile_identifier = PREFERENCE_PLAYER
/datum/preference/toggle/tgui_swapped_buttons
category = PREFERENCE_CATEGORY_GAME_PREFERENCES
savefile_key = "tgui_swapped_buttons"
default_value = FALSE
savefile_identifier = PREFERENCE_PLAYER
/datum/preference/toggle/tgui_say
category = PREFERENCE_CATEGORY_GAME_PREFERENCES
savefile_key = "TGUI_SAY"
@@ -0,0 +1,49 @@
/datum/preference/choiced/ui_style
category = PREFERENCE_CATEGORY_GAME_PREFERENCES
savefile_key = "UI_style"
savefile_identifier = PREFERENCE_PLAYER
should_generate_icons = TRUE
/datum/preference/choiced/ui_style/init_possible_values()
return assoc_to_keys(all_ui_styles)
/datum/preference/choiced/ui_style/icon_for(value)
var/icon/icon_file = all_ui_styles[value]
var/icon/icon = icon(icon_file, "r_hand_inactive")
icon.Crop(1, 1, ICON_SIZE_X * 2, ICON_SIZE_Y)
icon.Blend(icon(icon_file, "l_hand_inactive"), ICON_OVERLAY, ICON_SIZE_X)
return icon
/datum/preference/choiced/ui_style/create_default_value()
return all_ui_styles[1]
/datum/preference/choiced/ui_style/apply_to_client_updated(client/client, value)
client.mob?.update_ui_style(UI_style_new = value)
/datum/preference/numeric/ui_style_alpha
category = PREFERENCE_CATEGORY_GAME_PREFERENCES
savefile_key = "UI_style_alpha"
savefile_identifier = PREFERENCE_PLAYER
minimum = 50
maximum = 255
step = 1
/datum/preference/numeric/ui_style_alpha/create_default_value()
return 255
/datum/preference/numeric/ui_style_alpha/apply_to_client_updated(client/client, value)
client.mob?.update_ui_style(UI_style_alpha_new = value)
/datum/preference/color/ui_style_color
category = PREFERENCE_CATEGORY_GAME_PREFERENCES
savefile_key = "UI_style_color"
savefile_identifier = PREFERENCE_PLAYER
/datum/preference/color/ui_style_color/create_default_value()
return COLOR_WHITE
/datum/preference/color/ui_style_color/apply_to_client_updated(client/client, value)
client.mob?.update_ui_style(UI_style_color_new = value)