From 6a5619f2724cd1ae6c78c4b242e867dcda65e773 Mon Sep 17 00:00:00 2001 From: SidVeld Date: Thu, 21 Mar 2024 22:24:57 +0300 Subject: [PATCH] OOC notes rewrite and examine boxes in HUD's output (#18688) * feat: add ability to view ooc notes in examine Allows you to view non-player notes when examining a character. Warning: It requires `ALLOW_METADATA` to be enabled in the config. * feat: wrap hud's information with examine block Wraps information from sec/med huds with new subtypes of examine boxes. * chore: add changelog for ooc-notes changes * Apply suggestions from code review Co-authored-by: SleepyGemmy <99297919+SleepyGemmy@users.noreply.github.com> Signed-off-by: SidVeld --------- Signed-off-by: SidVeld Co-authored-by: SleepyGemmy <99297919+SleepyGemmy@users.noreply.github.com> --- code/__DEFINES/_macros.dm | 3 + .../preference_setup/general/01_basic.dm | 33 ++++++++-- .../mob/living/carbon/human/examine.dm | 3 + code/modules/mob/living/carbon/human/human.dm | 60 ++++++++++++------- code/modules/mob/living/living.dm | 16 ----- .../sidveld-ooc-notes-changelog.yml | 42 +++++++++++++ .../tgui-panel/styles/tgchat/chat-dark.scss | 15 +++++ .../tgui-panel/styles/tgchat/chat-light.scss | 15 +++++ 8 files changed, 145 insertions(+), 42 deletions(-) create mode 100644 html/changelogs/sidveld-ooc-notes-changelog.yml diff --git a/code/__DEFINES/_macros.dm b/code/__DEFINES/_macros.dm index b8939d01c67..e367ca71e25 100644 --- a/code/__DEFINES/_macros.dm +++ b/code/__DEFINES/_macros.dm @@ -32,6 +32,9 @@ /// Adds a generic box around whatever message you're sending in chat. Really makes things stand out. #define EXAMINE_BLOCK(str) ("
" + str + "
") +#define EXAMINE_BLOCK_BLUE(str) ("
" + str + "
") +#define EXAMINE_BLOCK_RED(str) ("
" + str + "
") +#define EXAMINE_BLOCK_DEEP_CYAN(str) ("
" + str + "
") #define FONT_SIZE_SMALL "10px" #define FONT_SIZE_NORMAL "13px" diff --git a/code/modules/client/preference_setup/general/01_basic.dm b/code/modules/client/preference_setup/general/01_basic.dm index 71bb02ccb6a..35e6b2c46c1 100644 --- a/code/modules/client/preference_setup/general/01_basic.dm +++ b/code/modules/client/preference_setup/general/01_basic.dm @@ -198,7 +198,8 @@ dat += "Serial Number: [pref.machine_serial_number] (?)
" dat += "Ownership Status: [pref.machine_ownership_status] (?)
" if(GLOB.config.allow_Metadata) - dat += "OOC Notes: Edit
" + dat += "OOC Notes: Edit " \ + + "Clear" + "
" . = dat.Join() @@ -302,10 +303,18 @@ return TOPIC_REFRESH else if(href_list["metadata"]) - var/new_metadata = sanitize(input(user, "Enter any information you'd like others to see, such as Roleplay-preferences:", "Game Preference" , pref.metadata) as message|null) + var/new_metadata = sanitize( + input( + user, + "Enter any information you'd like others to see, such as roleplay preferences.", + "Game Preference", + html_decode(pref.metadata) + ) as message|null, + MAX_MESSAGE_LEN + ) if(new_metadata && CanUseTopic(user)) - pref.metadata = sanitize(new_metadata) - return TOPIC_REFRESH + pref.metadata = new_metadata + return TOPIC_REFRESH else if(href_list["ipc_tag"]) if(!pref.can_edit_ipc_tag) @@ -348,4 +357,20 @@ pref.machine_ownership_status = new_ownership_status return TOPIC_REFRESH + else if (href_list["clear_metadata"]) + if (CanUseTopic(user)) + var/user_choice = alert( + user, + "Are you sure you wish to clear this character's OOC notes?", + "Clear OOC Notes Confirmation", + "Yes", + "No" + ) + + if (user_choice == "No") + return TOPIC_NOACTION + + pref.metadata = "" + return TOPIC_REFRESH + return ..() diff --git a/code/modules/mob/living/carbon/human/examine.dm b/code/modules/mob/living/carbon/human/examine.dm index 43ae14af504..f213288d2eb 100644 --- a/code/modules/mob/living/carbon/human/examine.dm +++ b/code/modules/mob/living/carbon/human/examine.dm @@ -390,6 +390,9 @@ if(print_flavor_text()) msg += "[print_flavor_text()]\n" + if (GLOB.config.allow_Metadata && client.prefs.metadata) + msg += "OOC Notes: \[View\]\n" + msg += "" if(src in GLOB.intent_listener) diff --git a/code/modules/mob/living/carbon/human/human.dm b/code/modules/mob/living/carbon/human/human.dm index 50cd5c93c9e..4f26d2bb0c2 100644 --- a/code/modules/mob/living/carbon/human/human.dm +++ b/code/modules/mob/living/carbon/human/human.dm @@ -576,7 +576,7 @@ U.handle_regular_hud_updates() if(!modified) - to_chat(usr, SPAN_WARNING("Unable to locate a data core entry for this person.")) + to_chat(usr, EXAMINE_BLOCK_RED(SPAN_WARNING("Unable to locate a data core entry for this person."))) if (href_list["secrecord"]) if(hasHUD(usr,"security")) @@ -591,15 +591,16 @@ var/datum/record/general/R = SSrecords.find_record("name", perpname) if(istype(R) && istype(R.security)) if(hasHUD(usr,"security")) - to_chat(usr, "Name: [R.name]") - to_chat(usr, "Criminal Status: [R.security.criminal]") - to_chat(usr, "Crimes: [R.security.crimes]") - to_chat(usr, "Notes: [R.security.notes]") - to_chat(usr, "\[View Comment Log\]") + var/message = "Security Records: [R.name]\n\n" \ + + "Criminal Status: [R.security.criminal]\n" \ + + "Crimes: [R.security.crimes]\n" \ + + "Notes: [R.security.notes]\n" \ + + "\[View Comment Log\]" + to_chat(usr, EXAMINE_BLOCK_RED(message)) read = 1 if(!read) - to_chat(usr, SPAN_WARNING("Unable to locate a data core entry for this person.")) + to_chat(usr, EXAMINE_BLOCK_RED(SPAN_WARNING("Unable to locate a data core entry for this person."))) if (href_list["secrecordComment"]) if(hasHUD(usr,"security")) @@ -614,16 +615,18 @@ var/datum/record/general/R = SSrecords.find_record("name", perpname) if(istype(R) && istype(R.security)) if(hasHUD(usr, "security")) + var/message = "Security Record Comments: [name]\n\n" read = 1 if(R.security.comments.len > 0) for(var/comment in R.security.comments) - to_chat(usr, comment) + message += comment + "\n\n" else - to_chat(usr, "No comments found") - to_chat(usr, "\[Add comment\]") + message += "No comments found.\n" + message += "\[Add Comment\]" + to_chat(usr, EXAMINE_BLOCK_RED(message)) if(!read) - to_chat(usr, SPAN_WARNING("Unable to locate a data core entry for this person.")) + to_chat(usr, EXAMINE_BLOCK_RED(SPAN_WARNING("Unable to locate a data core entry for this person."))) if (href_list["secrecordadd"]) if(hasHUD(usr,"security")) @@ -675,7 +678,7 @@ U.handle_regular_hud_updates() if(!modified) - to_chat(usr, SPAN_WARNING("Unable to locate a data core entry for this person.")) + to_chat(usr, EXAMINE_BLOCK_DEEP_CYAN(SPAN_WARNING("Unable to locate a data core entry for this person."))) if (href_list["medrecord"]) if(hasHUD(usr,"medical")) @@ -690,15 +693,17 @@ var/datum/record/general/R = SSrecords.find_record("name", perpname) if(istype(R) && istype(R.medical)) if(hasHUD(usr, "medical")) - to_chat(usr, "Name: [R.name] Blood Type: [R.medical.blood_type]") - to_chat(usr, "DNA: [R.medical.blood_dna]") - to_chat(usr, "Disabilities: [R.medical.disabilities]") - to_chat(usr, "Notes: [R.medical.notes]") - to_chat(usr, "\[View Comment Log\]") + var/message = "Medical Records: [R.name]\n\n" \ + + "Name: [R.name] Blood Type: [R.medical.blood_type]\n" \ + + "DNA: [R.medical.blood_dna]\n" \ + + "Disabilities: [R.medical.disabilities]\n" \ + + "Notes: [R.medical.notes]\n" \ + + "\[View Comment Log\]" + to_chat(usr, EXAMINE_BLOCK_DEEP_CYAN(message)) read = 1 if(!read) - to_chat(usr, SPAN_WARNING("Unable to locate a data core entry for this person.")) + to_chat(usr, EXAMINE_BLOCK_DEEP_CYAN(SPAN_WARNING("Unable to locate a data core entry for this person."))) if (href_list["medrecordComment"]) if(hasHUD(usr,"medical")) @@ -713,16 +718,18 @@ var/datum/record/general/R = SSrecords.find_record("name", perpname) if(istype(R) && istype(R.medical)) if(hasHUD(usr, "medical")) + var/message = "Medical Record Comments: [name]\n\n" read = 1 if(R.medical.comments.len > 0) for(var/comment in R.medical.comments) - to_chat(usr, comment) + message += comment + "\n\n" else - to_chat(usr, "No comments found") - to_chat(usr, "\[Add comment\]") + message += "No comments found.\n" + message += "\[Add Comment\]" + to_chat(usr, EXAMINE_BLOCK_DEEP_CYAN(message)) if(!read) - to_chat(usr, SPAN_WARNING("Unable to locate a data core entry for this person.")) + to_chat(usr, EXAMINE_BLOCK_DEEP_CYAN(SPAN_WARNING("Unable to locate a data core entry for this person."))) if (href_list["medrecordadd"]) if(hasHUD(usr,"medical")) @@ -791,6 +798,15 @@ flavor_texts[href_list["flavor_change"]] = msg set_flavor() return + + if (href_list["metadata"]) + var/message = "OOC Notes: [name]" \ + + "\n\n" \ + + client.prefs.metadata \ + + "\n\n" \ + + SPAN_WARNING("Remember, this is OOC information.") + to_chat(usr, EXAMINE_BLOCK(message)) + ..() return diff --git a/code/modules/mob/living/living.dm b/code/modules/mob/living/living.dm index 0073505b0e4..163e182bdfc 100644 --- a/code/modules/mob/living/living.dm +++ b/code/modules/mob/living/living.dm @@ -569,22 +569,6 @@ default behaviour is: /mob/living/proc/UpdateDamageIcon() return - -/mob/living/proc/Examine_OOC() - set name = "Examine Meta-Info (OOC)" - set category = "OOC" - set src in view() - - if(GLOB.config.allow_Metadata) - if(client) - to_chat(usr, "[src]'s Metainfo:
[client.prefs.metadata]") - else - to_chat(usr, "[src] does not have any stored infomation!") - else - to_chat(usr, "OOC Metadata is not supported by this server!") - - return - /mob/living/Move(a, b, flag) if (buckled_to) return diff --git a/html/changelogs/sidveld-ooc-notes-changelog.yml b/html/changelogs/sidveld-ooc-notes-changelog.yml new file mode 100644 index 00000000000..d9988e7ff82 --- /dev/null +++ b/html/changelogs/sidveld-ooc-notes-changelog.yml @@ -0,0 +1,42 @@ +################################ +# Example Changelog File +# +# Note: This file, and files beginning with ".", and files that don't end in ".yml" will not be read. If you change this file, you will look really dumb. +# +# Your changelog will be merged with a master changelog. (New stuff added only, and only on the date entry for the day it was merged.) +# When it is, any changes listed below will disappear. +# +# Valid Prefixes: +# bugfix +# wip (For works in progress) +# tweak +# soundadd +# sounddel +# rscadd (general adding of nice things) +# rscdel (general deleting of nice things) +# imageadd +# imagedel +# maptweak +# spellcheck (typo fixes) +# experiment +# balance +# admin +# backend +# security +# refactor +################################# + +# Your name. +author: SidVeld + +# Optional: Remove this file after generating master changelog. Useful for PR changelogs that won't get used again. +delete-after: True + +# Any changes you've made. See valid prefix list above. +# INDENT WITH TWO SPACES. NOT TABS. SPACES. +# SCREW THIS UP AND IT WON'T WORK. +# Also, all entries are changed into a single [] after a master changelog generation. Just remove the brackets when you add new entries. +# Please surround your changes in double quotes ("), as certain characters otherwise screws up compiling. The quotes will not show up in the changelog. +changes: + - rscadd: "Added ability to view ooc notes in examine." + - tweak: "Medical and Security huds messages wrapped into boxes." diff --git a/tgui/packages/tgui-panel/styles/tgchat/chat-dark.scss b/tgui/packages/tgui-panel/styles/tgchat/chat-dark.scss index 32ef0bfb756..9edc50df511 100644 --- a/tgui/packages/tgui-panel/styles/tgchat/chat-dark.scss +++ b/tgui/packages/tgui-panel/styles/tgchat/chat-dark.scss @@ -614,6 +614,21 @@ em { border: 1px solid #a4bad6; margin: 0.5em; padding: 0.5em 0.75em; + + &--blue { + @extend .examine_block; + border-color: #3c5dc0; + } + + &--red { + @extend .examine_block; + border-color: #e21111; + } + + &--deep-cyan { + @extend .examine_block; + border-color: #0f7e62; + } } .examine_block .icon { diff --git a/tgui/packages/tgui-panel/styles/tgchat/chat-light.scss b/tgui/packages/tgui-panel/styles/tgchat/chat-light.scss index d02f6781623..6dc94111ea8 100644 --- a/tgui/packages/tgui-panel/styles/tgchat/chat-light.scss +++ b/tgui/packages/tgui-panel/styles/tgchat/chat-light.scss @@ -628,6 +628,21 @@ h2.alert { border: 1px solid #111a27; margin: 0.5em; padding: 0.5em 0.75em; + + &--blue { + @extend .examine_block; + border-color: #3c5dc0; + } + + &--red { + @extend .examine_block; + border-color: #a30000; + } + + &--deep-cyan { + @extend .examine_block; + border-color: #0a5c47; + } } .examine_block .icon {