Skip to content
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

Fax Machine Requests Redo #9408

Merged
merged 7 commits into from Aug 25, 2023
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 1 addition & 3 deletions beestation.dme
Expand Up @@ -299,7 +299,6 @@
#include "code\_globalvars\lists\admin.dm"
#include "code\_globalvars\lists\ambience.dm"
#include "code\_globalvars\lists\client.dm"
#include "code\_globalvars\lists\faxes.dm"
#include "code\_globalvars\lists\flavor_misc.dm"
#include "code\_globalvars\lists\maintenance_loot.dm"
#include "code\_globalvars\lists\mapping.dm"
Expand Down Expand Up @@ -1609,6 +1608,7 @@
#include "code\modules\actionspeed\modifiers\race.dm"
#include "code\modules\actionspeed\modifiers\status_effects.dm"
#include "code\modules\admin\admin.dm"
#include "code\modules\admin\admin_fax_panel.dm"
#include "code\modules\admin\admin_follow.dm"
#include "code\modules\admin\admin_investigate.dm"
#include "code\modules\admin\admin_more_info.dm"
Expand Down Expand Up @@ -1685,7 +1685,6 @@
#include "code\modules\admin\verbs\deadsay.dm"
#include "code\modules\admin\verbs\debug.dm"
#include "code\modules\admin\verbs\diagnostics.dm"
#include "code\modules\admin\verbs\fax_manager.dm"
#include "code\modules\admin\verbs\forcecryo.dm"
#include "code\modules\admin\verbs\fps.dm"
#include "code\modules\admin\verbs\getlogs.dm"
Expand Down Expand Up @@ -3219,7 +3218,6 @@
#include "code\modules\paperwork\contract.dm"
#include "code\modules\paperwork\desk_bell.dm"
#include "code\modules\paperwork\fax.dm"
#include "code\modules\paperwork\fax_manager.dm"
#include "code\modules\paperwork\filingcabinet.dm"
#include "code\modules\paperwork\folder_premade.dm"
#include "code\modules\paperwork\folders.dm"
Expand Down
2 changes: 2 additions & 0 deletions code/__DEFINES/admin.dm
Expand Up @@ -54,6 +54,8 @@
#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>)"
#define ADMIN_RETRIEVE_BOH_ITEMS(boh) "(<a href='?_src_=holder;[HrefToken(TRUE)];retrieveboh=[REF(boh)]'>RETRIEVE CONSUMED ITEMS</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 TICKET_UNCLAIMED 1
#define TICKET_ACTIVE 2
Expand Down
21 changes: 0 additions & 21 deletions code/_globalvars/lists/faxes.dm

This file was deleted.

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 = "Standart 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
2 changes: 1 addition & 1 deletion code/modules/admin/admin_verbs.dm
Expand Up @@ -19,7 +19,6 @@ GLOBAL_PROTECT(admin_verbs_default)
/client/proc/stop_sounds,
/client/proc/mark_datum_mapview,
/client/proc/requests,
/client/proc/fax_manager
)
GLOBAL_LIST_INIT(admin_verbs_admin, world.AVerbsAdmin())
GLOBAL_PROTECT(admin_verbs_admin)
Expand Down Expand Up @@ -76,6 +75,7 @@ GLOBAL_PROTECT(admin_verbs_admin)
/client/proc/battle_royale,
/client/proc/delete_book,
/client/proc/cmd_admin_send_pda_msg,
/client/proc/fax_panel, /*send a paper to fax*/
)
GLOBAL_LIST_INIT(admin_verbs_ban, list(/client/proc/unban_panel, /client/proc/ban_panel, /client/proc/stickybanpanel))
GLOBAL_PROTECT(admin_verbs_ban)
Expand Down
9 changes: 9 additions & 0 deletions code/modules/admin/topic.dm
Expand Up @@ -1917,6 +1917,15 @@
message_admins("[key_name_admin(usr)] selected backstory: [choice]")
log_admin("[key_name(usr)] selected backstory: [choice]")

else if(href_list["show_paper"])
if(!check_rights(R_ADMIN))
return

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))
return
Expand Down
6 changes: 0 additions & 6 deletions code/modules/admin/verbs/fax_manager.dm

This file was deleted.