From f292d4047ccd69c313df4068bd02fe5b5a347527 Mon Sep 17 00:00:00 2001 From: kevinz000 <2003111+kevinz000@users.noreply.github.com> Date: Sun, 10 May 2020 16:35:48 -0700 Subject: [PATCH] Adds OOC notes (#12067) * ooc notes * fixes * repath * ok * This SHOULD compile, or else... Co-authored-by: Ghom <42542238+Ghommie@users.noreply.github.com> --- code/datums/elements/flavor_text.dm | 34 +++++++++++++------ code/modules/client/preferences.dm | 16 +++++++++ code/modules/client/preferences_savefile.dm | 5 +++ code/modules/mob/living/carbon/human/human.dm | 3 +- 4 files changed, 46 insertions(+), 12 deletions(-) diff --git a/code/datums/elements/flavor_text.dm b/code/datums/elements/flavor_text.dm index e9d8f278f4..f44215d9ac 100644 --- a/code/datums/elements/flavor_text.dm +++ b/code/datums/elements/flavor_text.dm @@ -5,12 +5,16 @@ GLOBAL_LIST_EMPTY(mobs_with_editable_flavor_text) //et tu, hacky code id_arg_index = 3 var/flavor_name = "Flavor Text" var/list/texts_by_atom = list() - var/addendum = "This can also be used for OOC notes and preferences!" + var/addendum = "" var/always_show = FALSE var/max_len = MAX_FLAVOR_LEN var/can_edit = TRUE + /// For preference/DNA saving/loading. Null to prevent. Prefs are only loaded from obviously if it exists in preferences.features. + var/save_key + /// Do not attempt to render a preview on examine. If this is on, it will display as \[flavor_name\] + var/examine_no_preview = FALSE -/datum/element/flavor_text/Attach(datum/target, text = "", _name = "Flavor Text", _addendum, _max_len = MAX_FLAVOR_LEN, _always_show = FALSE, _edit = TRUE) +/datum/element/flavor_text/Attach(datum/target, text = "", _name = "Flavor Text", _addendum, _max_len = MAX_FLAVOR_LEN, _always_show = FALSE, _edit = TRUE, _save_key, _examine_no_preview = FALSE) . = ..() if(. == ELEMENT_INCOMPATIBLE || !isatom(target)) //no reason why this shouldn't work on atoms too. @@ -25,6 +29,8 @@ GLOBAL_LIST_EMPTY(mobs_with_editable_flavor_text) //et tu, hacky code addendum = _addendum always_show = _always_show can_edit = _edit + save_key = _save_key + examine_no_preview = _examine_no_preview RegisterSignal(target, COMSIG_PARENT_EXAMINE, .proc/show_flavor) @@ -33,9 +39,12 @@ GLOBAL_LIST_EMPTY(mobs_with_editable_flavor_text) //et tu, hacky code LAZYOR(GLOB.mobs_with_editable_flavor_text[M], src) M.verbs |= /mob/proc/manage_flavor_tests + if(save_key && ishuman(target)) + RegisterSignal(target, COMSIG_HUMAN_PREFS_COPIED_TO, .proc/update_prefs_flavor_text) + /datum/element/flavor_text/Detach(atom/A) . = ..() - UnregisterSignal(A, COMSIG_PARENT_EXAMINE) + UnregisterSignal(A, list(COMSIG_PARENT_EXAMINE, COMSIG_HUMAN_PREFS_COPIED_TO)) texts_by_atom -= A if(can_edit && ismob(A)) var/mob/M = A @@ -58,6 +67,9 @@ GLOBAL_LIST_EMPTY(mobs_with_editable_flavor_text) //et tu, hacky code var/text = texts_by_atom[target] if(!text) return + if(examine_no_preview) + examine_list += "\[[flavor_name]\]" + return var/msg = replacetext(text, "\n", " ") if(length_char(msg) <= 40) examine_list += "[msg]" @@ -112,13 +124,17 @@ GLOBAL_LIST_EMPTY(mobs_with_editable_flavor_text) //et tu, hacky code return TRUE return FALSE +/datum/element/flavor_text/proc/update_prefs_flavor_text(mob/living/carbon/human/H, datum/preferences/P, icon_updates = TRUE, roundstart_checks = TRUE) + if(P.features.Find(save_key)) + texts_by_atom[H] = P.features[save_key] + //subtypes with additional hooks for DNA and preferences. /datum/element/flavor_text/carbon //list of antagonists etcetera that should have nothing to do with people's snowflakes. var/static/list/i_dont_even_know_who_you_are = typecacheof(list(/datum/antagonist/abductor, /datum/antagonist/ert, /datum/antagonist/nukeop, /datum/antagonist/wizard)) -/datum/element/flavor_text/carbon/Attach(datum/target, text = "", _name = "Flavor Text", _addendum, _max_len = MAX_FLAVOR_LEN, _always_show = FALSE, _edit = TRUE) +/datum/element/flavor_text/carbon/Attach(datum/target, text = "", _name = "Flavor Text", _addendum, _max_len = MAX_FLAVOR_LEN, _always_show = FALSE, _edit = TRUE, _save_key = "flavor_text", _examine_no_preview = FALSE) if(!iscarbon(target)) return ELEMENT_INCOMPATIBLE . = ..() @@ -127,7 +143,6 @@ GLOBAL_LIST_EMPTY(mobs_with_editable_flavor_text) //et tu, hacky code RegisterSignal(target, COMSIG_CARBON_IDENTITY_TRANSFERRED_TO, .proc/update_dna_flavor_text) RegisterSignal(target, COMSIG_MOB_ANTAG_ON_GAIN, .proc/on_antag_gain) if(ishuman(target)) - RegisterSignal(target, COMSIG_HUMAN_PREFS_COPIED_TO, .proc/update_prefs_flavor_text) RegisterSignal(target, COMSIG_HUMAN_HARDSET_DNA, .proc/update_dna_flavor_text) RegisterSignal(target, COMSIG_HUMAN_ON_RANDOMIZE, .proc/unset_flavor) @@ -136,15 +151,12 @@ GLOBAL_LIST_EMPTY(mobs_with_editable_flavor_text) //et tu, hacky code UnregisterSignal(C, list(COMSIG_CARBON_IDENTITY_TRANSFERRED_TO, COMSIG_MOB_ANTAG_ON_GAIN, COMSIG_HUMAN_PREFS_COPIED_TO, COMSIG_HUMAN_HARDSET_DNA, COMSIG_HUMAN_ON_RANDOMIZE)) /datum/element/flavor_text/carbon/proc/update_dna_flavor_text(mob/living/carbon/C) - texts_by_atom[C] = C.dna.features["flavor_text"] - -/datum/element/flavor_text/carbon/proc/update_prefs_flavor_text(mob/living/carbon/human/H, datum/preferences/P, icon_updates = TRUE, roundstart_checks = TRUE) - texts_by_atom[H] = P.features["flavor_text"] + texts_by_atom[C] = C.dna.features[save_key] /datum/element/flavor_text/carbon/set_flavor(mob/living/carbon/user) . = ..() if(. && user.dna) - user.dna.features["flavor_text"] = texts_by_atom[user] + user.dna.features[save_key] = texts_by_atom[user] /datum/element/flavor_text/carbon/proc/unset_flavor(mob/living/carbon/user) texts_by_atom[user] = "" @@ -153,4 +165,4 @@ GLOBAL_LIST_EMPTY(mobs_with_editable_flavor_text) //et tu, hacky code if(is_type_in_typecache(antag, i_dont_even_know_who_you_are)) texts_by_atom[user] = "" if(user.dna) - user.dna.features["flavor_text"] = "" \ No newline at end of file + user.dna.features[save_key] = "" diff --git a/code/modules/client/preferences.dm b/code/modules/client/preferences.dm index bb3a435258..a0c0832c2e 100644 --- a/code/modules/client/preferences.dm +++ b/code/modules/client/preferences.dm @@ -153,6 +153,7 @@ GLOBAL_LIST_EMPTY(preferences_datums) "ipc_screen" = "Sunburst", "ipc_antenna" = "None", "flavor_text" = "", + "ooc_notes" = "", "meat_type" = "Mammalian", "body_model" = MALE, "body_size" = RESIZE_DEFAULT_SIZE @@ -348,6 +349,16 @@ GLOBAL_LIST_EMPTY(preferences_datums) dat += "[features["flavor_text"]]" else dat += "[TextPreview(features["flavor_text"])]...
" + dat += "

OOC notes

" + dat += "Set OOC notes
" + var/ooc_notes_len = length(features["ooc_notes"]) + if(ooc_notes_len <= 40) + if(!ooc_notes_len) + dat += "\[...\]" + else + dat += "[features["ooc_notes"]]" + else + dat += "[TextPreview(features["ooc_notes"])]...
" dat += "

Body

" dat += "Gender:[gender == MALE ? "Male" : (gender == FEMALE ? "Female" : (gender == PLURAL ? "Non-binary" : "Object"))]
" if(gender != NEUTER && pref_species.sexes) @@ -1510,6 +1521,11 @@ GLOBAL_LIST_EMPTY(preferences_datums) if(!isnull(msg)) features["flavor_text"] = html_decode(msg) + if("ooc_notes") + var/msg = stripped_multiline_input(usr, "Set always-visible OOC notes related to content preferences. THIS IS NOT FOR CHARACTE DESCRIPTIONS!!", "OOC notes", features["ooc_notes"], MAX_FLAVOR_LEN, TRUE) + if(!isnull(msg)) + features["ooc_notes"] = html_decode(msg) + if("hair") var/new_hair = input(user, "Choose your character's hair colour:", "Character Preference","#"+hair_color) as color|null if(new_hair) diff --git a/code/modules/client/preferences_savefile.dm b/code/modules/client/preferences_savefile.dm index 6872def704..3f0381463a 100644 --- a/code/modules/client/preferences_savefile.dm +++ b/code/modules/client/preferences_savefile.dm @@ -535,6 +535,8 @@ SAVEFILE UPDATING/VERSIONING - 'Simplified', or rather, more coder-friendly ~Car else //We have no old flavortext, default to new S["feature_flavor_text"] >> features["flavor_text"] + S["feature_ooc_notes"] >> features["ooc_notes"] + S["vore_flags"] >> vore_flags S["vore_taste"] >> vore_taste S["belly_prefs"] >> belly_prefs @@ -643,6 +645,7 @@ SAVEFILE UPDATING/VERSIONING - 'Simplified', or rather, more coder-friendly ~Car features["flavor_text"] = copytext(features["flavor_text"], 1, MAX_FLAVOR_LEN) + features["ooc_notes"] = copytext(features["ooc_notes"], 1, MAX_FLAVOR_LEN) joblessrole = sanitize_integer(joblessrole, 1, 3, initial(joblessrole)) //Validate job prefs @@ -746,6 +749,8 @@ SAVEFILE UPDATING/VERSIONING - 'Simplified', or rather, more coder-friendly ~Car WRITE_FILE(S["feature_has_womb"], features["has_womb"]) + WRITE_FILE(S["feature_ooc_notes"], features["ooc_notes"]) + //Custom names for(var/custom_name_id in GLOB.preferences_custom_names) var/savefile_slot_name = custom_name_id + "_name" //TODO remove this diff --git a/code/modules/mob/living/carbon/human/human.dm b/code/modules/mob/living/carbon/human/human.dm index 2623574a73..ea91a90ee9 100644 --- a/code/modules/mob/living/carbon/human/human.dm +++ b/code/modules/mob/living/carbon/human/human.dm @@ -38,8 +38,9 @@ . = ..() if(!CONFIG_GET(flag/disable_human_mood)) AddComponent(/datum/component/mood) - AddElement(/datum/element/flavor_text/carbon) + AddElement(/datum/element/flavor_text/carbon, _name = "Flavor Text", _save_key = "flavor_text") AddElement(/datum/element/flavor_text, "", "Temporary Flavor Text", "This should be used only for things pertaining to the current round!") + AddElement(/datum/element/flavor_text, _name = "OOC Notes", _addendum = "Put information on ERP/vore/lewd-related preferences here. THIS SHOULD NOT CONTAIN REGULAR FLAVORTEXT!!", _always_show = TRUE, _save_key = "ooc_notes", _examine_no_preview = TRUE) /mob/living/carbon/human/Destroy() QDEL_NULL(physiology)