Skip to content

Custom Command Report Updates! #5353

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Mar 27, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions code/__DEFINES/~monkestation/admin.dm
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,8 @@
#define AHELP_CLOSEREASON_MENTOR 2

#define ADMIN_SUSINFO(user) "[ADMIN_LOOKUP(user)] [ADMIN_PP(user)] [ADMIN_INDIVIDUALLOG(user)] [ADMIN_SMITE(user)]"

// Command reports
#define DEFAULT_COMMANDREPORT_SOUND "default_commandreport"
#define DEFAULT_ALERT_SOUND "default_alert"
#define CUSTOM_ALERT_SOUND "custom_alert"
14 changes: 7 additions & 7 deletions code/__HELPERS/priority_announce.dm
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
* * encode_title - if TRUE, the title will be HTML encoded
* * encode_text - if TRUE, the text will be HTML encoded
*/
/proc/priority_announce(text, title = "", sound, type, sender_override, has_important_message = FALSE, list/mob/players = GLOB.player_list, encode_title = TRUE, encode_text = TRUE, color_override)
/proc/priority_announce(text, title = "", sound, type, sender_override, has_important_message = FALSE, list/mob/players = GLOB.player_list, encode_title = TRUE, encode_text = TRUE, color_override, append_update = TRUE)
if(!text)
return

Expand Down Expand Up @@ -74,7 +74,7 @@
header = MAJOR_ANNOUNCEMENT_TITLE("Station Announcement by [sender.name] (AI)")
// MONKESTATION ADDITION END
else
header += generate_unique_announcement_header(title, sender_override)
header += generate_unique_announcement_header(title, sender_override, append_update) // Monkestation edit - update append

announcement_strings += ANNOUNCEMENT_HEADER(header)

Expand All @@ -96,9 +96,9 @@
if(length(title) > 0)
GLOB.news_network.submit_article(title + "<br><br>" + text, "[command_name()]", "Station Announcements", null)
else
GLOB.news_network.submit_article(text, "[command_name()] Update", "Station Announcements", null)
GLOB.news_network.submit_article(text, "[command_name()][append_update ? " Update" : ""]", "Station Announcements", null)

/proc/print_command_report(text = "", title = null, announce=TRUE)
/proc/print_command_report(text = "", title = null, announce = TRUE, sanitize = TRUE) // monkestation edit - sanitization
if(!title)
title = "Classified [command_name()] Update"

Expand All @@ -114,7 +114,7 @@
message.title = title
message.content = text

SScommunications.send_message(message)
SScommunications.send_message(message, sanitize)// monkestation edit - sanitization

/**
* Sends a minor annoucement to players.
Expand Down Expand Up @@ -179,10 +179,10 @@

/// Proc that just generates a custom header based on variables fed into `priority_announce()`
/// Will return a string.
/proc/generate_unique_announcement_header(title, sender_override)
/proc/generate_unique_announcement_header(title, sender_override, append_update = TRUE)
var/list/returnable_strings = list()
if(isnull(sender_override))
returnable_strings += MAJOR_ANNOUNCEMENT_TITLE("[command_name()] Update")
returnable_strings += MAJOR_ANNOUNCEMENT_TITLE("[command_name()][append_update ? " Update" : ""]")
else
returnable_strings += MAJOR_ANNOUNCEMENT_TITLE(sender_override)

Expand Down
4 changes: 2 additions & 2 deletions code/controllers/subsystem/communications.dm
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ SUBSYSTEM_DEF(communications)
user.log_talk(input, LOG_SAY, tag="priority announcement")
message_admins("[ADMIN_LOOKUPFLW(user)] has made a priority announcement.")

/datum/controller/subsystem/communications/proc/send_message(datum/comm_message/sending,print = TRUE,unique = FALSE)
/datum/controller/subsystem/communications/proc/send_message(datum/comm_message/sending, print = TRUE, unique = FALSE, sanitize = TRUE) // monkestation edit - sanitization
for(var/obj/machinery/computer/communications/C in GLOB.shuttle_caller_list)
if(!(C.machine_stat & (BROKEN|NOPOWER)) && is_station_level(C.z))
if(unique)
Expand All @@ -58,7 +58,7 @@ SUBSYSTEM_DEF(communications)
if(print)
var/obj/item/paper/printed_paper = new /obj/item/paper(C.loc)
printed_paper.name = "paper - '[sending.title]'"
printed_paper.add_raw_text(sending.content)
printed_paper.add_raw_text(sending.content, advanced_html = !sanitize) // monkestation edit - sanitization
printed_paper.update_appearance()

#undef COMMUNICATION_COOLDOWN
Expand Down
62 changes: 45 additions & 17 deletions code/modules/admin/verbs/commandreport.dm
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
/// The default command report announcement sound.
#define DEFAULT_ANNOUNCEMENT_SOUND "default_announcement"

/// Preset central command names to chose from for centcom reports.
#define CENTCOM_PRESET "Central Command"
#define SYNDICATE_PRESET "The Syndicate"
Expand Down Expand Up @@ -49,7 +46,7 @@
/// Whether a copy of the report is printed at every console.
var/print_report = TRUE
/// The sound that's going to accompany our message.
var/played_sound = DEFAULT_ANNOUNCEMENT_SOUND
var/played_sound = DEFAULT_COMMANDREPORT_SOUND
/// The colour of the announcement when sent
var/announcement_color = "default"
/// The subheader to include when sending the announcement. Keep blank to not include a subheader
Expand Down Expand Up @@ -91,7 +88,7 @@
/datum/command_report_menu/ui_static_data(mob/user)
var/list/data = list()
data["command_name_presets"] = preset_names
data["announcer_sounds"] = list(DEFAULT_ANNOUNCEMENT_SOUND) + GLOB.announcer_keys
data["announcer_sounds"] = list(DEFAULT_COMMANDREPORT_SOUND, DEFAULT_ALERT_SOUND, CUSTOM_ALERT_SOUND) + GLOB.announcer_keys // Monkestation edit - custom alert sounds
data["announcement_colors"] = ANNOUNCEMENT_COLORS

return data
Expand All @@ -110,7 +107,19 @@

command_name = params["updated_name"]
if("set_report_sound")
played_sound = params["picked_sound"]
// monkestation start
if (params["picked_sound"] == CUSTOM_ALERT_SOUND)
var/soundInput = input(ui_user, "Please pick a sound file to play when you create the command report.", "Pick a Sound File") as null|sound
if (isnull(soundInput))
to_chat(ui_user, span_danger("No file was selected."))
custom_played_sound = null
played_sound = DEFAULT_ALERT_SOUND
else
custom_played_sound = soundInput
played_sound = CUSTOM_ALERT_SOUND
else
played_sound = params["picked_sound"]
//monkestation end
if("toggle_announce")
announce_contents = !announce_contents
if("toggle_printing")
Expand All @@ -130,7 +139,8 @@
to_chat(ui_user, span_danger("You can't send a report with no contents."))
return
command_report_content = params["report"]
send_announcement()
var/is_preview = params["preview"] //monkestation edit - report previewing
send_announcement(is_preview) //monkestation edit - report previewing

return TRUE

Expand All @@ -139,15 +149,28 @@
*
* Uses the variables set by the user on our datum as the arguments for the report.
*/
/datum/command_report_menu/proc/send_announcement()
/datum/command_report_menu/proc/send_announcement(preview = FALSE)
/// Our current command name to swap back to after sending the report.
var/original_command_name = command_name()
change_command_name(command_name)

/// The sound we're going to play on report.
var/report_sound = played_sound
if(played_sound == DEFAULT_ANNOUNCEMENT_SOUND)
report_sound = SSstation.announcer.get_rand_report_sound()
// monkestation edit start - Custom alert sounds
switch(played_sound)
if (DEFAULT_COMMANDREPORT_SOUND)
report_sound = SSstation.announcer.get_rand_report_sound()
if (DEFAULT_ALERT_SOUND)
report_sound = SSstation.announcer.get_rand_alert_sound()
if (CUSTOM_ALERT_SOUND)
if (!isnull(custom_played_sound))
report_sound = custom_played_sound
else
to_chat(ui_user, span_danger("The custom sound you selected was not able to be played. Aborting..."))
played_sound = DEFAULT_ALERT_SOUND
change_command_name(original_command_name)
return
// monkestation end

if(announce_contents)
var/chosen_color = announcement_color
Expand All @@ -156,18 +179,23 @@
chosen_color = "red"
else if(command_name == WIZARD_PRESET)
chosen_color = "purple"
priority_announce(command_report_content, subheader == ""? null : subheader, report_sound, has_important_message = TRUE, color_override = chosen_color)
// monkestation edit start - preview reports, togglable update append
if (preview)
to_chat(ui_user, "The following is a preview of what the command report will look like for other players.")
priority_announce(command_report_content, subheader == ""? null : subheader, report_sound, has_important_message = TRUE, color_override = chosen_color, append_update = append_update_name, encode_title = sanitize_content, encode_text = sanitize_content, players = list(ui_user))
else
priority_announce(command_report_content, subheader == ""? null : subheader, report_sound, has_important_message = TRUE, color_override = chosen_color, append_update = append_update_name, encode_title = sanitize_content, encode_text = sanitize_content)
// monkestation edit end

if(!announce_contents || print_report)
print_command_report(command_report_content, "[announce_contents ? "" : "Classified "][command_name] Update", !announce_contents)
if(!preview && (!announce_contents || print_report))
print_command_report(command_report_content, "[announce_contents ? "" : "Classified "][command_name] Update", !announce_contents, sanitize = sanitize_content)

change_command_name(original_command_name)

log_admin("[key_name(ui_user)] has created a command report: \"[command_report_content]\", sent from \"[command_name]\" with the sound \"[played_sound]\".")
message_admins("[key_name_admin(ui_user)] has created a command report, sent from \"[command_name]\" with the sound \"[played_sound]\"")

if (!preview) // monkestation edit - preview reports
log_admin("[key_name(ui_user)] has created a command report: \"[command_report_content]\", sent from \"[command_name]\" with the sound \"[played_sound]\".")
message_admins("[key_name_admin(ui_user)] has created a command report, sent from \"[command_name]\" with the sound \"[played_sound]\"")

#undef DEFAULT_ANNOUNCEMENT_SOUND

#undef CENTCOM_PRESET
#undef SYNDICATE_PRESET
Expand Down
46 changes: 46 additions & 0 deletions monkestation/code/modules/admin/verbs/commandreport.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/datum/command_report_menu
var/append_update_name = TRUE
var/sanitize_content = TRUE
var/custom_played_sound

/datum/command_report_menu/ui_data(mob/user)
. = ..()
.["append_update_name"] = append_update_name
.["sanitize_content"] = sanitize_content

/datum/command_report_menu/ui_act(action, list/params, datum/tgui/ui, datum/ui_state/state)
switch(action)
if("toggle_update_append")
append_update_name = !append_update_name
if("toggle_sanitization")
sanitize_content = !sanitize_content
if("preview_sound")
preview_sound()
if("preview_paper_report")
preview_paper_report(params["report"])

. = ..()

/datum/command_report_menu/proc/preview_paper_report(report)
var/obj/item/paper/report_paper = new /obj/item/paper(null)
report_paper.name = "paper - '[announce_contents ? "" : "Classified "][command_name] Update'"
report_paper.add_raw_text(report, advanced_html = !sanitize_content)
report_paper.ui_interact(ui_user)

/datum/command_report_menu/proc/preview_sound()
var/volume_pref = ui_user.client.prefs.channel_volume["[CHANNEL_VOX]"]
switch(played_sound)
if(DEFAULT_COMMANDREPORT_SOUND)
SEND_SOUND(ui_user, sound(SSstation.announcer.get_rand_report_sound(), volume = volume_pref))
if(DEFAULT_ALERT_SOUND)
SEND_SOUND(ui_user, sound(SSstation.announcer.get_rand_alert_sound(), volume = volume_pref))
if(CUSTOM_ALERT_SOUND)
if (isnull(custom_played_sound))
to_chat(ui_user, span_danger("There's no custom alert loaded! Cannot preview."))
return
SEND_SOUND(ui_user, sound(custom_played_sound, volume = volume_pref))
else
if(SSstation.announcer.event_sounds[played_sound])
SEND_SOUND(ui_user, sound(SSstation.announcer.event_sounds[played_sound], volume = volume_pref))
else
to_chat(ui_user, span_danger("No announcer sound available for [played_sound]"))
1 change: 1 addition & 0 deletions tgstation.dme
Original file line number Diff line number Diff line change
Expand Up @@ -6254,6 +6254,7 @@
#include "monkestation\code\modules\admin\smites\smite.dm"
#include "monkestation\code\modules\admin\smites\swisscheese.dm"
#include "monkestation\code\modules\admin\smites\where_are_your_fingers.dm"
#include "monkestation\code\modules\admin\verbs\commandreport.dm"
#include "monkestation\code\modules\admin\verbs\diagnostics.dm"
#include "monkestation\code\modules\admin\verbs\getlogs.dm"
#include "monkestation\code\modules\admin\verbs\glowshrooms.dm"
Expand Down
Loading
Loading