diff --git a/code/controllers/subsystem/ticker.dm b/code/controllers/subsystem/ticker.dm index 27ca37714f9..055164a8f11 100644 --- a/code/controllers/subsystem/ticker.dm +++ b/code/controllers/subsystem/ticker.dm @@ -127,6 +127,7 @@ SUBSYSTEM_DEF(ticker) start_at = world.time + (CONFIG_GET(number/lobby_countdown) * 10) apply_scheduled_pregame_delay() // modular_solaris/code/modules/admin/delay_pregame_on_reboot.dm + apply_persistent_admin_notice() // modular_solaris/code/modules/admin/persistent_admin_notice.dm // Offset time drift but start right in the morning of Monday. gametime_offset = 288001 return ..() diff --git a/code/modules/admin/admin_verbs.dm b/code/modules/admin/admin_verbs.dm index 4d986355b20..21a9e2c389f 100644 --- a/code/modules/admin/admin_verbs.dm +++ b/code/modules/admin/admin_verbs.dm @@ -78,6 +78,7 @@ GLOBAL_PROTECT(admin_verbs_admin) /datum/admins/proc/toggleguests, /*toggles whether guests can join the current game*/ /datum/admins/proc/announce, /*priority announce something to all clients.*/ /datum/admins/proc/set_admin_notice, /*announcement all clients see when joining the server.*/ + /datum/admins/proc/set_persistent_admin_notice, /*same as above, but survives a reboot until cleared. modular_solaris/code/modules/admin/persistent_admin_notice.dm*/ /client/proc/toggle_game_master, /*opens the game master panel*/ /client/proc/toggle_aghost_invis, /* lets us choose whether our in-game mob goes visible when we aghost (off by default) */ /client/proc/admin_ghost, /*allows us to ghost/reenter body at will*/ @@ -253,6 +254,7 @@ GLOBAL_LIST_INIT(admin_verbs_hideable, list( /datum/admins/proc/toggleguests, /datum/admins/proc/announce, /datum/admins/proc/set_admin_notice, + /datum/admins/proc/set_persistent_admin_notice, /client/proc/toggle_aghost_invis, /client/proc/admin_ghost, /client/proc/toggle_view_range, diff --git a/modular_solaris/code/modules/admin/persistent_admin_notice.dm b/modular_solaris/code/modules/admin/persistent_admin_notice.dm new file mode 100644 index 00000000000..7b8097734c2 --- /dev/null +++ b/modular_solaris/code/modules/admin/persistent_admin_notice.dm @@ -0,0 +1,48 @@ +/// Text of the persistent admin notice, if one has been set. Stored separately from GLOB.admin_notice so it +/// survives a world restart (GLOB.admin_notice itself is not saved anywhere and always starts blank on boot). +GLOBAL_VAR_INIT(persistent_admin_notice, load_persistent_admin_notice()) + +/proc/load_persistent_admin_notice() + var/savefile = file("data/persistent_admin_notice.txt") + if(!fexists(savefile)) + return "" + return file2text(savefile) + +/proc/save_persistent_admin_notice(text) + var/savefile = file("data/persistent_admin_notice.txt") + fdel(savefile) + if(text) + WRITE_FILE(savefile, text) + +/// Re-applies the persisted notice (if any) into GLOB.admin_notice at round start, reusing the existing +/// admin_notice display pipeline (new player login message, the Adminnotice check verb, etc.) as-is. +/// Called once from ticker Initialize() so it's in place before anyone can join. +/datum/controller/subsystem/ticker/proc/apply_persistent_admin_notice() + if(GLOB.persistent_admin_notice) + GLOB.admin_notice = GLOB.persistent_admin_notice + +/datum/admins/proc/set_persistent_admin_notice() + set category = "Server" + set name = "Set Persistent Admin Notice" + set desc = "Set an announcement that appears to everyone who joins the server, every round, until cleared. Unlike Set Admin Notice, this survives a server reboot." + if(!check_rights(0)) + return + + var/new_notice = input(src, "Set a public notice that persists across round reboots.\nEveryone who joins the server will see it, every round, until this is cleared.\n(Leaving it blank will delete the current persistent notice):", "Set Persistent Notice", GLOB.persistent_admin_notice) as message|null + if(new_notice == null) + return + if(new_notice == GLOB.persistent_admin_notice) + return + + GLOB.persistent_admin_notice = new_notice + save_persistent_admin_notice(new_notice) + GLOB.admin_notice = new_notice // shares the same display pipeline as the round-only notice, so setting/clearing this also updates what's currently shown + + if(new_notice == "") + message_admins("[key_name(usr)] removed the persistent admin notice.") + log_admin("[key_name(usr)] removed the persistent admin notice.") + else + message_admins("[key_name(usr)] set the persistent admin notice.") + log_admin("[key_name(usr)] set the persistent admin notice:\n[new_notice]") + to_world(span_adminnotice("Admin Notice:\n \t [new_notice]")) + SSblackbox.record_feedback("tally", "admin_verb", 1, "Set Persistent Admin Notice") //If you are copy-pasting this, ensure the 2nd parameter is unique to the new proc! diff --git a/roguetown.dme b/roguetown.dme index 5f08545c7a9..bdde4378c63 100644 --- a/roguetown.dme +++ b/roguetown.dme @@ -3726,6 +3726,7 @@ #include "modular_solaris\code\game\objects\items\rogueweapons\ranged\handgonne.dm" #include "modular_solaris\code\modules\admin\delay_pregame_on_reboot.dm" #include "modular_solaris\code\modules\admin\loud_asay.dm" +#include "modular_solaris\code\modules\admin\persistent_admin_notice.dm" #include "modular_solaris\code\modules\clothing\rogueclothes\ammopouch.dm" #include "modular_solaris\code\modules\jobs\job_types\roguetown\adventurer\types\antag\smokerat.dm" #include "modular_solaris\code\modules\jobs\job_types\roguetown\adventurer\types\combat\ranger.dm"