Skip to content

Commit

Permalink
requests manager
Browse files Browse the repository at this point in the history
  • Loading branch information
meemofcourse committed Jan 21, 2024
1 parent 3693e63 commit bfa2300
Show file tree
Hide file tree
Showing 21 changed files with 965 additions and 660 deletions.
2 changes: 2 additions & 0 deletions code/__DEFINES/admin.dm
Expand Up @@ -67,6 +67,8 @@
#define ADMIN_COORDJMP(src) "[src ? "[COORD(src)] [ADMIN_JMP(src)]" : "nonexistent location"]"
#define ADMIN_VERBOSEJMP(src) "[src ? "[AREACOORD(src)] [ADMIN_JMP(src)]" : "nonexistent location"]"
#define ADMIN_INDIVIDUALLOG(user) "(<a href='?_src_=holder;[HrefToken(TRUE)];individuallog=[REF(user)]'>LOGS</a>)"
/// Displays "(SHOW)" in the chat, when clicked it tries to show atom(paper). First you need to set the request_state variable to TRUE for the paper.
#define ADMIN_SHOW_PAPER(atom) "(<A href='?_src_=holder;[HrefToken(forceGlobal = TRUE)];show_paper=[REF(atom)]'>SHOW</a>)"

#define ADMIN_PUNISHMENT_BREAK_BONES "Break all bones"
#define ADMIN_PUNISHMENT_LIGHTNING "Lightning bolt"
Expand Down
26 changes: 0 additions & 26 deletions code/_globalvars/lists/faxes.dm

This file was deleted.

1 change: 1 addition & 0 deletions code/_globalvars/lists/objects.dm
Expand Up @@ -11,6 +11,7 @@ GLOBAL_LIST_EMPTY(wayfindingbeacons) //list of all navigation beacons used
GLOBAL_LIST_EMPTY(nuke_list)
GLOBAL_LIST_EMPTY(alarmdisplay) //list of all machines or programs that can display station alerts
GLOBAL_LIST_EMPTY(singularities) //list of all singularities on the station (actually technically all engines)
GLOBAL_LIST_EMPTY(fax_machines) //list of all fax machines

GLOBAL_LIST(chemical_reactions_list) //list of all /datum/chemical_reaction datums. Used during chemical reactions
GLOBAL_LIST(chemical_reagents_list) //list of all /datum/reagent datums indexed by reagent id. Used by chemistry stuff
Expand Down
Expand Up @@ -687,7 +687,6 @@
name = "Fax Machine"
build_path = /obj/machinery/fax
req_components = list(
/obj/item/stock_parts/subspace/crystal = 1,
/obj/item/stock_parts/scanning_module = 1,
/obj/item/stock_parts/micro_laser = 1,
/obj/item/stock_parts/manipulator = 1,)
Expand Down
145 changes: 145 additions & 0 deletions code/modules/admin/admin_fax_panel.dm
@@ -0,0 +1,145 @@
/**
* If client have R_ADMIN flag, opens an admin fax panel.
*/
/client/proc/fax_panel()
set name = "Send Fax Message"
set category = "Admin"

if(!check_rights(R_ADMIN))
return

var/datum/fax_panel_interface/ui = new(usr)
ui.ui_interact(usr)

/// Admin Fax Panel. Tool for sending fax messages faster.
/datum/fax_panel_interface
/// All faxes in from machinery list()
var/available_faxes = list()
/// List with available stamps
var/stamp_list = list()

/// Paper which admin edit and send.
var/obj/item/paper/fax_paper = new /obj/item/paper(null)

/// Default name of fax. Used when field with fax name not edited.
var/sending_fax_name = "Secret"
/// Default name of paper. paper - bluh-bluh. Used when field with paper name not edited.
var/default_paper_name = "Standard Report"

/datum/fax_panel_interface/New()
//Get all faxes, and save them to our list.
for(var/obj/machinery/fax/fax as anything in GLOB.fax_machines)
available_faxes += WEAKREF(fax)

//Get all stamps
for(var/stamp in subtypesof(/obj/item/stamp))
var/obj/item/stamp/real_stamp = new stamp()
if(!istype(real_stamp, /obj/item/stamp/chameleon))
var/stamp_detail = real_stamp.get_writing_implement_details()
stamp_list += list(list(real_stamp.name, real_stamp.icon_state, stamp_detail["stamp_class"]))

//Give our paper special status, to read everywhere.
fax_paper.request_state = TRUE

/**
* Return fax if name exists
* Arguments:
* * name - Name of fax what we try to find.
*/
/datum/fax_panel_interface/proc/get_fax_by_name(name)
if(!length(available_faxes))
return null

for(var/datum/weakref/weakrefed_fax as anything in available_faxes)
var/obj/machinery/fax/potential_fax = weakrefed_fax.resolve()
if(potential_fax && istype(potential_fax))
if(potential_fax.fax_name == name)
return potential_fax
return null

/datum/fax_panel_interface/ui_interact(mob/user, datum/tgui/ui)
ui = SStgui.try_update_ui(user, src, ui)
if(!ui)
ui = new(user, src, "AdminFax")
ui.open()

/datum/fax_panel_interface/ui_state(mob/user)
return GLOB.admin_state

/datum/fax_panel_interface/ui_static_data(mob/user)
var/list/data = list()

data["faxes"] = list()
data["stamps"] = list()

for(var/stamp in stamp_list)
data["stamps"] += list(stamp[1]) // send only names.

for(var/datum/weakref/weakrefed_fax as anything in available_faxes)
var/obj/machinery/fax/another_fax = weakrefed_fax.resolve()
if(another_fax && istype(another_fax))
data["faxes"] += list(another_fax.fax_name)

return data

/datum/fax_panel_interface/ui_act(action, list/params, datum/tgui/ui, datum/ui_state/state)
if(..())
return

if(!check_rights(R_ADMIN))
return

var/obj/machinery/fax/action_fax

if(params["faxName"])
action_fax = get_fax_by_name(params["faxName"])

switch(action)

if("follow")
if(!isobserver(usr))
usr.client?.admin_ghost()

usr.client?.holder?.admin_follow(action_fax)

if("preview") // see saved variant
if(!fax_paper)
return
fax_paper.ui_interact(usr)

if("save") // save paper
if(params["paperName"])
default_paper_name = params["paperName"]
if(params["fromWho"])
sending_fax_name = params["fromWho"]

fax_paper.clear_paper()
var/stamp
var/stamp_class

for(var/needed_stamp in stamp_list)
if(needed_stamp[1] == params["stamp"])
stamp = needed_stamp[2]
stamp_class = needed_stamp[3]
break

fax_paper.name = "paper — [default_paper_name]"
fax_paper.add_raw_text(params["rawText"])

if(stamp)
fax_paper.add_stamp(stamp_class, params["stampX"], params["stampY"], params["stampAngle"], stamp)

fax_paper.update_static_data(usr) // OK, it's work, and update UI.

if("send")
//copy
var/obj/item/paper/our_fax = fax_paper.copy(/obj/item/paper)
our_fax.name = fax_paper.name
//send
action_fax.receive(our_fax, sending_fax_name, important = TRUE)
message_admins("[key_name_admin(usr)] has sent a custom fax message to [action_fax.name][ADMIN_FLW(action_fax)][ADMIN_SHOW_PAPER(fax_paper)].")
log_admin("[key_name(usr)] has sent a custom fax message to [action_fax.name]")

if("createPaper")
var/obj/item/paper/our_paper = fax_paper.copy(/obj/item/paper, usr.loc)
our_paper.name = fax_paper.name
6 changes: 3 additions & 3 deletions code/modules/admin/admin_verbs.dm
Expand Up @@ -26,7 +26,9 @@ GLOBAL_PROTECT(admin_verbs_default)
/client/proc/resetasaycolor,
/client/proc/fix_air, /*resets air in designated radius to its default atmos composition*/
/client/proc/addbunkerbypass,
/client/proc/revokebunkerbypass
/client/proc/revokebunkerbypass,
/client/proc/requests,
/client/proc/fax_panel, /*send a paper to fax*/
)
GLOBAL_LIST_INIT(admin_verbs_admin, world.AVerbsAdmin())
GLOBAL_PROTECT(admin_verbs_admin)
Expand Down Expand Up @@ -119,7 +121,6 @@ GLOBAL_LIST_INIT(admin_verbs_fun, list(
/client/proc/polymorph_all,
/client/proc/show_tip,
/client/proc/smite,
/client/proc/fax_manager,
/client/proc/spawn_ruin,
))
GLOBAL_PROTECT(admin_verbs_fun)
Expand Down Expand Up @@ -283,7 +284,6 @@ GLOBAL_LIST_INIT(admin_verbs_hideable, list(
/client/proc/cmd_display_del_log,
/client/proc/toggle_combo_hud,
/client/proc/debug_huds,
/client/proc/fax_manager
))
GLOBAL_PROTECT(admin_verbs_hideable)

Expand Down
8 changes: 6 additions & 2 deletions code/modules/admin/topic.dm
Expand Up @@ -2218,10 +2218,14 @@
return
GLOB.interviews.ui_interact(usr)

else if(href_list["open_fax_manager"])
else if(href_list["show_paper"])
if(!check_rights(R_ADMIN))
return
usr.client.fax_manager()

var/obj/item/paper/paper_to_show = locate(href_list["show_paper"])
if(!istype(paper_to_show))
return
paper_to_show.ui_interact(usr)

/datum/admins/proc/HandleCMode()
if(!check_rights(R_ADMIN))
Expand Down
9 changes: 0 additions & 9 deletions code/modules/admin/verbs/fax_manager.dm

This file was deleted.

8 changes: 4 additions & 4 deletions code/modules/admin/verbs/pray.dm
Expand Up @@ -44,23 +44,21 @@
deity = "Ashen Hunter"

var/msg_tmp = msg
GLOB.requests.pray(usr.client, msg, usr.job == "Chaplain")
msg = "<span class='adminnotice'>[icon2html(cross, GLOB.admins)]<b><font color=[font_color]>[prayer_type][deity ? " (to [deity])" : ""]: </font>[ADMIN_FULLMONTY(src)] [ADMIN_SC(src)]:</b> <span class='linkify'>[msg]</span></span>"

for(var/client/C in GLOB.admins)
if(C.prefs.chat_toggles & CHAT_PRAYER)
to_chat(C, msg, confidential = TRUE)
if(C.prefs.toggles & SOUND_PRAYERS)
if(usr.job == "Chaplain")
SEND_SOUND(C, sound('sound/effects/pray.ogg'))
to_chat(usr, "<span class='info'>You pray to the gods: \"[msg_tmp]\"</span>", confidential = TRUE)
SSredbot.send_discord_message("admin", "Prayer from [src.key]/([src.name]): [msg]")

SSblackbox.record_feedback("tally", "admin_verb", 1, "Prayer") //If you are copy-pasting this, ensure the 2nd parameter is unique to the new proc!
//log_admin("HELP: [key_name(src)]: [msg]")

/// Used by communications consoles to message CentCom
/proc/message_centcom(text, mob/sender)
var/msg = copytext_char(sanitize(text), 1, MAX_MESSAGE_LEN)
GLOB.requests.message_centcom(sender.client, msg)
msg = "<span class='adminnotice'><b><font color=orange>CENTCOM:</font>[ADMIN_FULLMONTY(sender)] [ADMIN_CENTCOM_REPLY(sender)]:</b> [msg]</span>"
to_chat(GLOB.admins, msg, confidential = TRUE)
for(var/obj/machinery/computer/communications/console in GLOB.machines)
Expand All @@ -69,6 +67,7 @@
/// Used by communications consoles to message the Syndicate
/proc/message_syndicate(text, mob/sender)
var/msg = copytext_char(sanitize(text), 1, MAX_MESSAGE_LEN)
GLOB.requests.message_syndicate(sender.client, msg)
msg = "<span class='adminnotice'><b><font color=crimson>SYNDICATE:</font>[ADMIN_FULLMONTY(sender)] [ADMIN_SYNDICATE_REPLY(sender)]:</b> [msg]</span>"
to_chat(GLOB.admins, msg, confidential = TRUE)
for(var/obj/machinery/computer/communications/console in GLOB.machines)
Expand All @@ -77,6 +76,7 @@
/// Used by communications consoles to request the nuclear launch codes
/proc/nuke_request(text, mob/sender)
var/msg = copytext_char(sanitize(text), 1, MAX_MESSAGE_LEN)
GLOB.requests.nuke_request(sender.client, msg)
msg = "<span class='adminnotice'><b><font color=orange>NUKE CODE REQUEST:</font>[ADMIN_FULLMONTY(sender)] [ADMIN_CENTCOM_REPLY(sender)] [ADMIN_SET_SD_CODE]:</b> [msg]</span>"
to_chat(GLOB.admins, msg, confidential = TRUE)
for(var/obj/machinery/computer/communications/console in GLOB.machines)
Expand Down
7 changes: 7 additions & 0 deletions code/modules/admin/verbs/requests.dm
@@ -0,0 +1,7 @@
/// Verb for opening the requests manager panel
/client/proc/requests()
set name = "Requests Manager"
set desc = "Open the request manager panel to view all requests during this round"
set category = "Admin"
SSblackbox.record_feedback("tally", "admin_verb", 1, "Request Manager") //If you are copy-pasting this, ensure the 2nd parameter is unique to the new proc!
GLOB.requests.ui_interact(usr)
2 changes: 2 additions & 0 deletions code/modules/client/client_procs.dm
Expand Up @@ -231,6 +231,7 @@ GLOBAL_LIST_INIT(blacklisted_builds, list(

GLOB.ahelp_tickets.client_login(src)
GLOB.interviews.client_login(src)
GLOB.requests.client_login(src)
var/connecting_admin = FALSE //because de-admined admins connecting should be treated like admins.
//Admin Authorisation
holder = GLOB.admin_datums[ckey]
Expand Down Expand Up @@ -501,6 +502,7 @@ GLOBAL_LIST_INIT(blacklisted_builds, list(
log_access("Logout: [key_name(src)]")
GLOB.ahelp_tickets.client_logout(src)
GLOB.interviews.client_logout(src)
GLOB.requests.client_logout(src)
SSserver_maint.UpdateHubStatus()
if(credits)
QDEL_LIST(credits)
Expand Down

0 comments on commit bfa2300

Please sign in to comment.