Files
VOREStation/code/modules/paperwork/faxmachine.dm
Arokha Sieyes b099ac6e4c Merge branch 'master' of https://github.com/VOREStation/Polaris into sync-09272018
# Conflicts:
#	code/__defines/holomap.dm
#	code/__defines/mobs.dm
#	code/_helpers/icons.dm
#	code/_helpers/unsorted.dm
#	code/_onclick/hud/hud.dm
#	code/_onclick/item_attack.dm
#	code/controllers/Processes/supply.dm
#	code/controllers/subsystems/planets.dm
#	code/datums/supplypacks/munitions.dm
#	code/datums/supplypacks/science.dm
#	code/datums/supplypacks/security.dm
#	code/datums/supplypacks/supply.dm
#	code/game/area/Space Station 13 areas.dm
#	code/game/atoms_movable.dm
#	code/game/machinery/autolathe.dm
#	code/game/machinery/doors/door.dm
#	code/game/machinery/jukebox.dm
#	code/game/machinery/recharger.dm
#	code/game/machinery/vending.dm
#	code/game/mecha/equipment/tools/medical_tools.dm
#	code/game/mecha/equipment/weapons/weapons.dm
#	code/game/objects/items/devices/PDA/PDA.dm
#	code/game/objects/items/devices/megaphone.dm
#	code/game/objects/items/poi_items.dm
#	code/game/objects/items/weapons/implants/implantlanguage.dm
#	code/game/objects/items/weapons/storage/firstaid.dm
#	code/game/objects/items/weapons/tools/weldingtool.dm
#	code/game/objects/structures/flora/trees.dm
#	code/game/objects/structures/plasticflaps.dm
#	code/game/supplyshuttle.dm
#	code/game/turfs/simulated/wall_attacks.dm
#	code/modules/admin/admin_verbs.dm
#	code/modules/assembly/infrared.dm
#	code/modules/client/client procs.dm
#	code/modules/client/preference_setup/loadout/loadout_utility.dm
#	code/modules/client/preferences.dm
#	code/modules/clothing/suits/miscellaneous.dm
#	code/modules/holomap/holomap_datum.dm
#	code/modules/holomap/station_holomap.dm
#	code/modules/integrated_electronics/core/printer.dm
#	code/modules/mining/machine_processing.dm
#	code/modules/mob/living/carbon/human/human_defense.dm
#	code/modules/mob/living/carbon/human/species/virtual_reality/avatar.dm
#	code/modules/mob/living/death.dm
#	code/modules/mob/living/silicon/ai/ai.dm
#	code/modules/mob/living/silicon/pai/pai.dm
#	code/modules/mob/living/silicon/robot/robot.dm
#	code/modules/mob/living/simple_animal/animals/parrot.dm
#	code/modules/mob/mob_movement.dm
#	code/modules/organs/organ_external.dm
#	code/modules/organs/organ_icon.dm
#	code/modules/organs/subtypes/standard.dm
#	code/modules/planet/weather.dm
#	code/modules/power/cable.dm
#	code/modules/power/fusion/core/core_control.dm
#	code/modules/power/fusion/fuel_assembly/fuel_control.dm
#	code/modules/power/fusion/gyrotron/gyrotron_control.dm
#	code/modules/projectiles/gun.dm
#	code/modules/reagents/Chemistry-Reagents/Chemistry-Reagents-Food-Drinks.dm
#	config/names/first_name_skrell.txt
#	config/names/last_name_skrell.txt
#	icons/mob/head.dmi
#	icons/mob/robots.dmi
#	icons/mob/species/tajaran/helmet.dmi
#	icons/obj/ammo.dmi
#	icons/obj/gun.dmi
#	icons/obj/mining.dmi
#	icons/obj/projectiles.dmi
#	icons/obj/rig_modules.dmi
#	icons/obj/surgery.dmi
#	icons/turf/walls.dmi
#	maps/southern_cross/southern_cross-1.dmm
#	maps/southern_cross/southern_cross-3.dmm
#	maps/southern_cross/southern_cross-6.dmm
#	maps/southern_cross/southern_cross-8.dmm
#	maps/submaps/surface_submaps/mountains/backup/IceCave1.dmm
#	maps/submaps/surface_submaps/mountains/backup/IceCave1A.dmm
#	maps/submaps/surface_submaps/mountains/backup/IceCave1B.dmm
#	maps/submaps/surface_submaps/mountains/backup/IceCave1C.dmm
#	maps/submaps/surface_submaps/mountains/crashedcontainmentshuttle.dmm
#	maps/submaps/surface_submaps/mountains/deadspy.dmm
#	maps/submaps/surface_submaps/mountains/mountains_areas.dm
#	maps/submaps/surface_submaps/plains/Thiefc.dmm
#	maps/~map_system/maps.dm
#	vorestation.dme
2018-09-27 18:01:09 -04:00

212 lines
6.5 KiB
Plaintext

var/list/obj/machinery/photocopier/faxmachine/allfaxes = list()
var/list/admin_departments = list("[using_map.boss_name]", "Virgo-Prime Governmental Authority", "Supply") // Vorestation Edit
var/list/alldepartments = list()
var/list/adminfaxes = list() //cache for faxes that have been sent to admins
/obj/machinery/photocopier/faxmachine
name = "fax machine"
icon = 'icons/obj/library.dmi'
icon_state = "fax"
insert_anim = "faxsend"
req_one_access = list(access_lawyer, access_heads, access_armory, access_qm)
use_power = 1
idle_power_usage = 30
active_power_usage = 200
circuit = /obj/item/weapon/circuitboard/fax
var/obj/item/weapon/card/id/scan = null // identification
var/authenticated = 0
var/sendcooldown = 0 // to avoid spamming fax messages
var/department = "Unknown" // our department
var/destination = null // the department we're sending to
/obj/machinery/photocopier/faxmachine/New()
allfaxes += src
if(!destination) destination = "[using_map.boss_name]"
if( !(("[department]" in alldepartments) || ("[department]" in admin_departments)) )
alldepartments |= department
..()
/obj/machinery/photocopier/faxmachine/attack_hand(mob/user as mob)
user.set_machine(src)
ui_interact(user)
/**
* Display the NanoUI window for the fax machine.
*
* See NanoUI documentation for details.
*/
/obj/machinery/photocopier/faxmachine/ui_interact(mob/user, ui_key = "main", var/datum/nanoui/ui = null, var/force_open = 1)
user.set_machine(src)
var/list/data = list()
if(scan)
data["scanName"] = scan.name
else
data["scanName"] = null
data["bossName"] = using_map.boss_name
data["authenticated"] = authenticated
data["copyItem"] = copyitem
if(copyitem)
data["copyItemName"] = copyitem.name
else
data["copyItemName"] = null
data["cooldown"] = sendcooldown
data["destination"] = destination
ui = GLOB.nanomanager.try_update_ui(user, src, ui_key, ui, data, force_open)
if (!ui)
ui = new(user, src, ui_key, "fax.tmpl", src.name, 500, 500)
ui.set_initial_data(data)
ui.open()
ui.set_auto_update(10) //this machine is so unimportant let's not have it update that often.
/obj/machinery/photocopier/faxmachine/Topic(href, href_list)
if(href_list["send"])
if(copyitem)
if (destination in admin_departments)
send_admin_fax(usr, destination)
else
sendfax(destination)
if (sendcooldown)
spawn(sendcooldown) // cooldown time
sendcooldown = 0
else if(href_list["remove"])
if(copyitem)
copyitem.loc = usr.loc
usr.put_in_hands(copyitem)
to_chat(usr, "<span class='notice'>You take \the [copyitem] out of \the [src].</span>")
copyitem = null
if(href_list["scan"])
if (scan)
if(ishuman(usr))
scan.loc = usr.loc
if(!usr.get_active_hand())
usr.put_in_hands(scan)
scan = null
else
scan.loc = src.loc
scan = null
else
var/obj/item/I = usr.get_active_hand()
if (istype(I, /obj/item/weapon/card/id) && usr.unEquip(I))
I.loc = src
scan = I
authenticated = 0
if(href_list["dept"])
var/lastdestination = destination
destination = input(usr, "Which department?", "Choose a department", "") as null|anything in (alldepartments + admin_departments)
if(!destination) destination = lastdestination
if(href_list["auth"])
if ( (!( authenticated ) && (scan)) )
if (check_access(scan))
authenticated = 1
if(href_list["logout"])
authenticated = 0
GLOB.nanomanager.update_uis(src)
/obj/machinery/photocopier/faxmachine/proc/sendfax(var/destination)
if(stat & (BROKEN|NOPOWER))
return
use_power(200)
var/success = 0
for(var/obj/machinery/photocopier/faxmachine/F in allfaxes)
if( F.department == destination )
success = F.receivefax(copyitem)
if (success)
visible_message("[src] beeps, \"Message transmitted successfully.\"")
//sendcooldown = 600
else
visible_message("[src] beeps, \"Error transmitting message.\"")
/obj/machinery/photocopier/faxmachine/proc/receivefax(var/obj/item/incoming)
if(stat & (BROKEN|NOPOWER))
return 0
if(department == "Unknown")
return 0 //You can't send faxes to "Unknown"
flick("faxreceive", src)
playsound(loc, "sound/effects/printer.ogg", 50, 1)
// give the sprite some time to flick
sleep(20)
if (istype(incoming, /obj/item/weapon/paper))
copy(incoming)
else if (istype(incoming, /obj/item/weapon/photo))
photocopy(incoming)
else if (istype(incoming, /obj/item/weapon/paper_bundle))
bundlecopy(incoming)
else
return 0
use_power(active_power_usage)
return 1
/obj/machinery/photocopier/faxmachine/proc/send_admin_fax(var/mob/sender, var/destination)
if(stat & (BROKEN|NOPOWER))
return
use_power(200)
//received copies should not use toner since it's being used by admins only.
var/obj/item/rcvdcopy
if (istype(copyitem, /obj/item/weapon/paper))
rcvdcopy = copy(copyitem, 0)
else if (istype(copyitem, /obj/item/weapon/photo))
rcvdcopy = photocopy(copyitem, 0)
else if (istype(copyitem, /obj/item/weapon/paper_bundle))
rcvdcopy = bundlecopy(copyitem, 0)
else
visible_message("[src] beeps, \"Error transmitting message.\"")
return
rcvdcopy.loc = null //hopefully this shouldn't cause trouble
adminfaxes += rcvdcopy
//message badmins that a fax has arrived
if (destination == using_map.boss_name)
message_admins(sender, "[uppertext(using_map.boss_short)] FAX", rcvdcopy, "CentComFaxReply", "#006100")
else if (destination == "Virgo-Prime Governmental Authority") // Vorestation Edit
message_admins(sender, "VIRGO GOVERNMENT FAX", rcvdcopy, "CentComFaxReply", "#1F66A0")
else if (destination == "Supply")
message_admins(sender, "[uppertext(using_map.boss_short)] SUPPLY FAX", rcvdcopy, "CentComFaxReply", "#5F4519")
else
message_admins(sender, "[uppertext(destination)] FAX", rcvdcopy, "UNKNOWN")
sendcooldown = 1800
sleep(50)
visible_message("[src] beeps, \"Message transmitted successfully.\"")
/obj/machinery/photocopier/faxmachine/proc/message_admins(var/mob/sender, var/faxname, var/obj/item/sent, var/reply_type, font_colour="#006100")
var/msg = "<span class='notice'><b><font color='[font_colour]'>[faxname]: </font>[get_options_bar(sender, 2,1,1)]"
msg += "(<a href='?_src_=holder;FaxReply=\ref[sender];originfax=\ref[src];replyorigin=[reply_type]'>REPLY</a>)</b>: "
msg += "Receiving '[sent.name]' via secure connection ... <a href='?_src_=holder;AdminFaxView=\ref[sent]'>view message</a></span>"
for(var/client/C in admins)
if(check_rights((R_ADMIN|R_MOD),0,C))
C << msg
C << 'sound/effects/printer.ogg'
// VoreStation Edit Start
var/faxid = export_fax(sent)
message_chat_admins(sender, faxname, sent, faxid, font_colour)
// VoreStation Edit End