From 0776b7d934d79ab2141a3a5ac5e905e31489b631 Mon Sep 17 00:00:00 2001 From: Runa Dacino Date: Mon, 23 Oct 2023 13:38:40 +0200 Subject: [PATCH 1/2] tweak(paper): Changes bundle naming logic to be general Used to be bundles would get renamed based on hardcoded default values of "paper" or "photo". Using the Initial() procedure, we now check for defaults at compile time to be able to adapt to changes in paper/photo names. This was done to enable checking if a bundle is using its default name or not. --- code/modules/paperwork/paper.dm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/code/modules/paperwork/paper.dm b/code/modules/paperwork/paper.dm index 6771e774318..f55a36cb81b 100644 --- a/code/modules/paperwork/paper.dm +++ b/code/modules/paperwork/paper.dm @@ -549,9 +549,9 @@ add_fingerprint(user) return var/obj/item/weapon/paper_bundle/B = new(src.loc) - if (name != "paper") + if (name != initial(name)) B.name = name - else if (P.name != "paper" && P.name != "photo") + else if (P.name != initial(P.name)) B.name = P.name user.drop_from_inventory(P) if (istype(user, /mob/living/carbon/human)) From e30f35df8e1124ff42337343c805481d4c0186d0 Mon Sep 17 00:00:00 2001 From: Runa Dacino Date: Mon, 23 Oct 2023 14:40:26 +0200 Subject: [PATCH 2/2] add(fax): check to prompt renaming when sending to admin Adds a check on sending fax to admin departments that prompts the user to either rename, cancel or continue as is when they try to send a fax using the initial() (compile time) value. Continuing works as it did, cancelling ceases the operation and renaming renames it. Also adds a check for when using bundles to check if the bundle title matches either page 1 or page 2. We only check page 1/2 due to bundle naming logic on creation. add(fax): Adds a buton to interface to rename fax message Renames the bundle/paper. Also includes a tooltip to explain what it does and why you should do it. --- code/modules/paperwork/faxmachine.dm | 43 ++++++++++++++++++++++++++++ tgui/packages/tgui/interfaces/Fax.js | 10 ++++++- tgui/public/tgui.bundle.js | 2 +- 3 files changed, 53 insertions(+), 2 deletions(-) diff --git a/code/modules/paperwork/faxmachine.dm b/code/modules/paperwork/faxmachine.dm index 26e2a45de3e..89ec66dd7a4 100644 --- a/code/modules/paperwork/faxmachine.dm +++ b/code/modules/paperwork/faxmachine.dm @@ -220,9 +220,18 @@ var/list/adminfaxes = list() //cache for faxes that have been sent to admins return switch(action) + if("rename") + if(copyitem) + var/new_name = tgui_input_text(usr, "Enter new paper title", "This will show up in the preview for staff chat on discord when sending \ + to central.", copyitem.name, MAX_NAME_LEN) + if(!new_name) + return + copyitem.name = new_name if("send") if(copyitem) if (destination in admin_departments) + if(check_if_default_title_and_rename()) + return send_admin_fax(usr, destination) else sendfax(destination) @@ -239,6 +248,40 @@ var/list/adminfaxes = list() //cache for faxes that have been sent to admins return TRUE + +/obj/machinery/photocopier/faxmachine/proc/check_if_default_title_and_rename() +/* +Returns TRUE only on "Cancel" or invalid newname, else returns null/false +Extracted to its own procedure for easier logic handling with paper bundles. +*/ + var/question_text = "Your fax is set to its default name. It's advisable to rename it to something self-explanatory to" + + if(istype(copyitem, /obj/item/weapon/paper_bundle)) + var/obj/item/weapon/paper_bundle/B = copyitem + if(B.name != initial(B.name)) + var/atom/page1 = B.pages[1] //atom is enough for us to ensure it has name var. would've used ?. opertor, but linter doesnt like. + var/atom/page2 = B.pages[2] + if((istype(page1) && B.name == page1.name) || (istype(page2) && B.name == page2.name) ) + question_text = "Your fax is set to use the title of its first or second page. It's advisable to rename it to something \ + summarizing the entire bundle succintly to" + else + return FALSE + else if(copyitem.name != initial(copyitem.name)) + return FALSE + + var/choice = tgui_alert(usr, "[question_text] improve response time from staff when sending to discord. \ + Renaming it changes its preview in staff chat.", \ + "Default name detected", list("Change Title","Continue", "Cancel")) + if(choice == "Cancel") + return TRUE + else if(choice == "Change Title") + var/new_name = tgui_input_text(usr, "Enter new fax title", "This will show up in the preview for staff chat on discord when sending \ + to central.", copyitem.name, MAX_NAME_LEN) + if(!new_name) + return TRUE + copyitem.name = new_name + + /obj/machinery/photocopier/faxmachine/attackby(obj/item/O as obj, mob/user as mob) if(istype(O, /obj/item/weapon/card/id) && !scan) user.drop_from_inventory(O) diff --git a/tgui/packages/tgui/interfaces/Fax.js b/tgui/packages/tgui/interfaces/Fax.js index 86d8ea29820..75f789d6b1b 100644 --- a/tgui/packages/tgui/interfaces/Fax.js +++ b/tgui/packages/tgui/interfaces/Fax.js @@ -59,7 +59,15 @@ export const FaxContent = (props, context) => { - {copyItem} + {copyItem}{' '} +