Files
Bubberstation/code/modules/admin/admin_fax_panel.dm
NamelessFairy 63614f31e0 Replaces the direct central command contact from fax machines with nanotrasen departmental contacts (#72009)
<!-- Write **BELOW** The Headers and **ABOVE** The comments else it may
not be viewable. -->
<!-- You can view Contributing.MD for a detailed description of the pull
request process. -->

## About The Pull Request

Does what it says on the tin, instead of being able to fax central
command fax machines are linked to a randomly selected Nanotrasen
department. Current options are as follows but more can be added if any
creative ideas are provided.

- NT HR Department
- NT Legal Department
- NT Complaint Department
- NT Customer Relations
- Nanotrasen Tech Support
- NT Internal Affairs Dept

<!-- Describe The Pull Request. Please be sure every change is
documented or this can delay review and even discourage maintainers from
merging your PR! -->

## Why It's Good For The Game

Re-restricts contacting the top dogs at central command to people with a
captain ID. Being able to contact central commands highest ranks from an
IC perspective makes sense to be restricted to the captain only through
the use of the communications console. The crew can instead contact what
is likely an intern working in a specialized department.

<!-- Argue for the merits of your changes and how they benefit the game,
especially if they are controversial and/or far reaching. If you can't
actually explain WHY what you are doing will improve the game, then it
probably isn't good for the game in the first place. -->

## Changelog

<!-- If your PR modifies aspects of the game that can be concretely
observed by players or admins you should add a changelog. If your change
does NOT meet this description, remove this section. Be sure to properly
mark your PRs to prevent unnecessary GBP loss. You can read up on GBP
and it's effects on PRs in the tgstation guides for contributors. Please
note that maintainers freely reserve the right to remove and add tags
should they deem it appropriate. You can attempt to finagle the system
all you want, but it's best to shoot for clear communication right off
the bat. -->

🆑
spellcheck: Admin fax report names now default to standard report rather
than standart.
del: Central Command can no longer be faxed directly from fax machines.
spellcheck: Replaced the ability to contact central command directly by
being able to contact a randomly selected nanotrasen department.
/🆑

<!-- Both 🆑's are required for the changelog to work! You can put
your name to the right of the first 🆑 if you want to overwrite your
GitHub username as author ingame. -->
<!-- You can use multiple of the same prefix (they're only used for the
icon ingame) and delete the unneeded ones. Despite some of the tags,
changelogs should generally represent how a player might be affected by
the changes rather than a summary of the PR's contents. -->
2022-12-16 10:34:23 +01:00

146 lines
4.2 KiB
Plaintext

/**
* If client have R_ADMIN flag, opens an admin fax panel.
*/
/client/proc/fax_panel()
set category = "Admin.Events"
set name = "Fax Panel"
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 in GLOB.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) && !istype(real_stamp, /obj/item/stamp/mod))
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?.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)
message_admins("[key_name_admin(usr)] has send custom fax message to [action_fax.name][ADMIN_FLW(action_fax)][ADMIN_SHOW_PAPER(fax_paper)].")
log_admin("[key_name(usr)] has send 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