From 2c4e3ce19a665fb83e3bc6c7a258fab4deabb6d2 Mon Sep 17 00:00:00 2001 From: Bedshaped Date: Tue, 5 Jul 2016 19:23:09 +0100 Subject: [PATCH] Adds an option to use templates from the WI in command reports (#474) 90% of the work here was Skull's since I had no idea how to access and pull information from the DB. It's also a semi-fix for #433 --- code/__HELPERS/names.dm | 4 ++ code/global.dm | 1 + code/modules/admin/verbs/randomverbs.dm | 54 ++++++++++++++++++++----- html/changelogs/bedshaped-PR-474.yml | 9 +++++ 4 files changed, 58 insertions(+), 10 deletions(-) create mode 100644 html/changelogs/bedshaped-PR-474.yml diff --git a/code/__HELPERS/names.dm b/code/__HELPERS/names.dm index 0b26e51ac45..f06071b0045 100644 --- a/code/__HELPERS/names.dm +++ b/code/__HELPERS/names.dm @@ -46,6 +46,10 @@ var/religion_name = null /proc/system_name() return "Nyx" +/proc/commstation_name() + if (commstation_name) + return commstation_name + /proc/station_name() if (station_name) return station_name diff --git a/code/global.dm b/code/global.dm index a2948510017..471bfdb8507 100644 --- a/code/global.dm +++ b/code/global.dm @@ -94,6 +94,7 @@ var/blobevent = 0 var/diary = null var/href_logfile = null var/station_name = "NSS Exodus" +var/commstation_name = "NMSS Odin" var/game_version = "Baystation12" var/changelog_hash = "" var/game_year = (text2num(time2text(world.realtime, "YYYY")) + 544) diff --git a/code/modules/admin/verbs/randomverbs.dm b/code/modules/admin/verbs/randomverbs.dm index 7f7304569ff..1ee25e04111 100644 --- a/code/modules/admin/verbs/randomverbs.dm +++ b/code/modules/admin/verbs/randomverbs.dm @@ -510,30 +510,64 @@ Traitors and the like can also be revived with the previous role mostly intact. if(!holder) src << "Only administrators may use this command." return - var/input = sanitize(input(usr, "Please enter anything you want. Anything. Serious.", "What?", "") as message|null, extra = 0) - var/customname = sanitizeSafe(input(usr, "Pick a title for the report.", "Title") as text|null) - if(!input) - return - if(!customname) - customname = "NanoTrasen Update" + var/reporttitle + var/reportbody + var/reporter + var/reporttype = input(usr, "Choose whether to use a template or custom report.", "Create Command Report") in list("Template", "Custom", "Cancel") + switch(reporttype) + if("Template") + establish_db_connection(dbcon) + if (!dbcon.IsConnected()) + src << "Unable to connect to the database." + return + var/DBQuery/query = dbcon.NewQuery("SELECT title, message FROM ss13_ccia_general_notice_list WHERE deleted_at IS NULL") + query.Execute() + + var/list/template_names = list() + var/templates[] = list() + + while (query.NextRow()) + template_names += query.item[1] + templates[query.item[1]] = query.item[2] + + // Catch empty list + if (!templates.len) + src << "There are no templates in the database." + return + + reporttitle = input(usr, "Please select a command report template.", "Create Command Report") in list(template_names) + + reportbody = templates[reporttitle] + + if("Custom") + reporttitle = sanitizeSafe(input(usr, "Pick a title for the report.", "Title") as text|null) + if(!reporttitle) + reporttitle = "NanoTrasen Update" + reportbody = sanitize(input(usr, "Please enter anything you want. Anything. Serious.", "Body", "") as message|null, extra = 0) + if(!reportbody) + return + else + return for (var/obj/machinery/computer/communications/C in machines) if(! (C.stat & (BROKEN|NOPOWER) ) ) var/obj/item/weapon/paper/P = new /obj/item/weapon/paper( C.loc ) - P.name = "'[command_name()] Update.'" - P.info = replacetext(input, "\n", "
") + P.name = "[command_name()] Update" + P.info = replacetext(reportbody, "\n", "
") P.update_space(P.info) P.update_icon() C.messagetitle.Add("[command_name()] Update") C.messagetext.Add(P.info) + reporter = sanitizeSafe(input(usr, "Please enter your name.", "Name") as text|null) + switch(alert("Should this be announced to the general population?",,"Yes","No")) if("Yes") - command_announcement.Announce(input, customname, new_sound = 'sound/AI/commandreport.ogg', msg_sanitized = 1); + command_announcement.Announce("[reportbody]\n\n- [reporter], Central Command Internal Affairs Agent, [commstation_name()]", reporttitle, new_sound = 'sound/AI/commandreport.ogg', msg_sanitized = 1); if("No") world << "\red New NanoTrasen Update available at all communication consoles." world << sound('sound/AI/commandreport.ogg') - log_admin("[key_name(src)] has created a command report: [input]") + log_admin("[key_name(src)] has created a command report: [reportbody]") message_admins("[key_name_admin(src)] has created a command report", 1) feedback_add_details("admin_verb","CCR") //If you are copy-pasting this, ensure the 2nd parameter is unique to the new proc! diff --git a/html/changelogs/bedshaped-PR-474.yml b/html/changelogs/bedshaped-PR-474.yml new file mode 100644 index 00000000000..9e34705a569 --- /dev/null +++ b/html/changelogs/bedshaped-PR-474.yml @@ -0,0 +1,9 @@ +author: Bedshaped + +delete-after: True + +changes: + - rscadd: "Added the ability to pull template command reports from the WI" + - rscadd: "Added the ability to cancel sending a command report" + - tweak: "Changed command reports to ask for a name separately" + - rscadd: "Adding a helper in commstation_name() which returns NMSS Odin currently"