PDA Ringtone Preference (#70485)

* Creates some new defines for constant values in the Messenger app
* Created a new type of preference, text preferences, with a FeatureShortTextInput TGUI component
* Uses said new preference to re-add a PDA ringtone preference.
This commit is contained in:
GoldenAlpharex
2022-10-16 17:33:40 -04:00
committed by GitHub
parent 6ce946a056
commit e613c875b7
9 changed files with 139 additions and 25 deletions
+25 -1
View File
@@ -527,7 +527,7 @@ GLOBAL_LIST_INIT(preference_entries_by_key, init_preference_entries_by_key())
"step" = step,
)
/// A prefernece whose value is always TRUE or FALSE
/// A preference whose value is always TRUE or FALSE
/datum/preference/toggle
abstract_type = /datum/preference/toggle
@@ -542,3 +542,27 @@ GLOBAL_LIST_INIT(preference_entries_by_key, init_preference_entries_by_key())
/datum/preference/toggle/is_valid(value)
return value == TRUE || value == FALSE
/// A string-based preference accepting arbitrary string values entered by the user, with a maximum length.
/datum/preference/text
abstract_type = /datum/preference/text
/// What is the maximum length of the value allowed in this field?
var/maximum_value_length = 256
/// Should we strip HTML the input or simply restrict it to the maximum_value_length?
var/should_strip_html = TRUE
/datum/preference/text/deserialize(input, datum/preferences/preferences)
return should_strip_html ? STRIP_HTML_SIMPLE(input, maximum_value_length) : copytext(input, 1, maximum_value_length)
/datum/preference/text/create_default_value()
return ""
/datum/preference/text/is_valid(value)
return istext(value) && length(value) < maximum_value_length
/datum/preference/text/compile_constant_data()
return list("maximum_length" = maximum_value_length)
@@ -0,0 +1,19 @@
/**
* This is the preference for the player's SpaceMessenger ringtone.
* Currently only applies to humans spawned in with a job, as it's hooked
* into `/datum/job/proc/after_spawn()`.
*/
/datum/preference/text/pda_ringtone
savefile_key = "pda_ringtone"
category = PREFERENCE_CATEGORY_NON_CONTEXTUAL
savefile_identifier = PREFERENCE_CHARACTER
maximum_value_length = MESSENGER_RINGTONE_MAX_LENGTH
/datum/preference/text/pda_ringtone/create_default_value()
return MESSENGER_RINGTONE_DEFAULT
// Returning false here because this pref is handled a little differently, due to its dependency on the existence of a PDA.
/datum/preference/text/pda_ringtone/apply_to_human(mob/living/carbon/human/target, value, datum/preferences/preferences)
return FALSE