Implements sending faxes to admins

This commit is contained in:
mwerezak
2014-10-31 00:27:00 -04:00
parent e53bd0e237
commit d38787697a
5 changed files with 168 additions and 118 deletions
+47 -26
View File
@@ -1,5 +1,8 @@
var/list/obj/machinery/photocopier/faxmachine/allfaxes = list()
var/list/alldepartments = list("Central Command", "Sol Government")
var/list/admin_departments = list("Central Command", "Sol Government")
var/list/alldepartments = list()
var/list/adminfaxes = list() //cache for faxes that have been sent to admins
/obj/machinery/photocopier/faxmachine
name = "fax machine"
@@ -24,7 +27,7 @@ var/list/alldepartments = list("Central Command", "Sol Government")
..()
allfaxes += src
if( !("[department]" in alldepartments) )
if( !(("[department]" in alldepartments) || ("[department]" in admin_departments)) )
alldepartments |= department
/obj/machinery/photocopier/faxmachine/attack_hand(mob/user as mob)
@@ -82,17 +85,11 @@ var/list/alldepartments = list("Central Command", "Sol Government")
/obj/machinery/photocopier/faxmachine/Topic(href, href_list)
if(href_list["send"])
if(copyitem)
if(destination == "Central Command")
//Centcomm_fax(src, tofax.info, tofax.name, usr)
sendcooldown = 1800
else if(destination == "Sol Government")
//Solgov_fax(src, tofax.info, tofax.name, usr)
sendcooldown = 1800
if (destination in admin_departments)
send_admin_fax(usr, destination)
else
sendfax(destination)
if (sendcooldown)
spawn(sendcooldown) // cooldown time
sendcooldown = 0
@@ -125,7 +122,7 @@ var/list/alldepartments = list("Central Command", "Sol Government")
if(href_list["dept"])
var/lastdestination = destination
destination = input(usr, "Which department?", "Choose a department", "") as null|anything in alldepartments
destination = input(usr, "Which department?", "Choose a department", "") as null|anything in (alldepartments + admin_departments)
if(!destination) destination = lastdestination
if(href_list["auth"])
@@ -138,21 +135,18 @@ var/list/alldepartments = list("Central Command", "Sol Government")
updateUsrDialog()
/obj/machinery/photocopier/faxmachine/proc/admin_fax()
//TODO
/obj/machinery/photocopier/faxmachine/proc/sendfax(var/destination)
if(stat & (BROKEN|NOPOWER))
return
var/sent = 0
use_power(200)
var/success = 0
for(var/obj/machinery/photocopier/faxmachine/F in allfaxes)
if( F.department == destination )
sent = F.recievefax(copyitem)
success = F.recievefax(copyitem)
if (sent)
if (success)
visible_message("[src] beeps, \"Message transmitted successfully.\"")
sendcooldown = 600
else
@@ -180,13 +174,40 @@ var/list/alldepartments = list("Central Command", "Sol Government")
use_power(active_power_usage)
return 1
/proc/Centcomm_fax(var/originfax, var/sent, var/sentname, var/mob/Sender)
/obj/machinery/photocopier/faxmachine/proc/send_admin_fax(var/mob/sender, var/destination)
if(stat & (BROKEN|NOPOWER))
return
use_power(200)
var/msg = "\blue <b><font color='#006100'>CENTCOMM FAX: </font>[key_name(Sender, 1)] (<A HREF='?_src_=holder;adminplayeropts=\ref[Sender]'>PP</A>) (<A HREF='?_src_=vars;Vars=\ref[Sender]'>VV</A>) (<A HREF='?_src_=holder;subtlemessage=\ref[Sender]'>SM</A>) (<A HREF='?_src_=holder;adminplayerobservejump=\ref[Sender]'>JMP</A>) (<A HREF='?_src_=holder;secretsadmin=check_antagonist'>CA</A>) (<a href='?_src_=holder;CentcommFaxReply=\ref[Sender];originfax=\ref[originfax]'>REPLY</a>)</b>: Receiving '[sentname]' via secure connection ... <a href='?_src_=holder;CentcommFaxView=\ref[sent]'>view message</a>"
admins << msg
/proc/Solgov_fax(var/originfax, var/sent, var/sentname, var/mob/Sender)
var/msg = "\blue <b><font color='#1F66A0'>SOL GOVERNMENT FAX: </font>[key_name(Sender, 1)] (<A HREF='?_src_=holder;adminplayeropts=\ref[Sender]'>PP</A>) (<A HREF='?_src_=vars;Vars=\ref[Sender]'>VV</A>) (<A HREF='?_src_=holder;subtlemessage=\ref[Sender]'>SM</A>) (<A HREF='?_src_=holder;adminplayerobservejump=\ref[Sender]'>JMP</A>) (<A HREF='?_src_=holder;secretsadmin=check_antagonist'>CA</A>) (<a href='?_src_=holder;SolGovFaxReply=\ref[Sender];originfax=\ref[originfax]'>REPLY</a>)</b>: Receiving '[sentname]' via secure connection ... <a href='?_src_=holder;CentcommFaxView=\ref[sent]'>view message</a>"
var/obj/item/rcvdcopy
if (istype(copyitem, /obj/item/weapon/paper))
rcvdcopy = copy(copyitem)
else if (istype(copyitem, /obj/item/weapon/photo))
rcvdcopy = photocopy(copyitem)
else if (istype(copyitem, /obj/item/weapon/paper_bundle))
rcvdcopy = bundlecopy(copyitem)
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
switch(destination)
if ("Central Command")
message_admins(sender, "CENTCOMM FAX", rcvdcopy, "CentcommFaxReply", "#006100")
if ("Sol Government")
message_admins(sender, "SOL GOVERNMENT FAX", rcvdcopy, "CentcommFaxReply", "#1F66A0")
//message_admins(sender, "SOL GOVERNMENT FAX", rcvdcopy, "SolGovFaxReply", "#1F66A0")
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 = "\blue <b><font color='[font_colour]'>[faxname]: </font>[key_name(sender, 1)] (<A HREF='?_src_=holder;adminplayeropts=\ref[sender]'>PP</A>) (<A HREF='?_src_=vars;Vars=\ref[sender]'>VV</A>) (<A HREF='?_src_=holder;subtlemessage=\ref[sender]'>SM</A>) (<A HREF='?_src_=holder;adminplayerobservejump=\ref[sender]'>JMP</A>) (<A HREF='?_src_=holder;secretsadmin=check_antagonist'>CA</A>) (<a href='?_src_=holder;[reply_type]=\ref[sender];originfax=\ref[src]'>REPLY</a>)</b>: Receiving '[sent.name]' via secure connection ... <a href='?_src_=holder;AdminFaxView=\ref[sent]'>view message</a>"
admins << msg
+9 -9
View File
@@ -62,20 +62,20 @@
/obj/item/weapon/paper/examine()
set src in oview(1)
// ..() //We don't want them to see the dumb "this is a paper" thing every time.
// I didn't like the idea that people can read tiny pieces of paper from across the room.
// Now you need to be next to the paper in order to read it.
if(in_range(usr, src))
if(!(istype(usr, /mob/living/carbon/human) || istype(usr, /mob/dead/observer) || istype(usr, /mob/living/silicon)))
usr << browse("<HTML><HEAD><TITLE>[name]</TITLE></HEAD><BODY>[stars(info)][stamps]</BODY></HTML>", "window=[name]")
onclose(usr, "[name]")
else
usr << browse("<HTML><HEAD><TITLE>[name]</TITLE></HEAD><BODY>[info][stamps]</BODY></HTML>", "window=[name]")
onclose(usr, "[name]")
show_content(usr)
else
usr << "<span class='notice'>It is too far away.</span>"
return
/obj/item/weapon/paper/proc/show_content(var/mob/user, var/forceshow=0)
if(!(istype(user, /mob/living/carbon/human) || istype(user, /mob/dead/observer) || istype(user, /mob/living/silicon)) && !forceshow)
user << browse("<HTML><HEAD><TITLE>[name]</TITLE></HEAD><BODY>[stars(info)][stamps]</BODY></HTML>", "window=[name]")
onclose(user, "[name]")
else
user << browse("<HTML><HEAD><TITLE>[name]</TITLE></HEAD><BODY>[info][stamps]</BODY></HTML>", "window=[name]")
onclose(user, "[name]")
/obj/item/weapon/paper/verb/rename()
set name = "Rename paper"
set category = "Object"
+35 -38
View File
@@ -99,52 +99,49 @@
usr << desc
if(in_range(usr, src))
src.attack_self(usr)
src.show_content(usr)
else
usr << "<span class='notice'>It is too far away.</span>"
return
/obj/item/weapon/paper_bundle/proc/show_content(mob/user as mob)
var/dat
var/obj/item/weapon/W = src[page]
switch(screen)
if(0)
dat+= "<DIV STYLE='float:left; text-align:left; width:33.33333%'></DIV>"
dat+= "<DIV STYLE='float:left; text-align:center; width:33.33333%'><A href='?src=\ref[src];remove=1'>Remove [(istype(W, /obj/item/weapon/paper)) ? "paper" : "photo"]</A></DIV>"
dat+= "<DIV STYLE='float:left; text-align:right; width:33.33333%'><A href='?src=\ref[src];next_page=1'>Next Page</A></DIV><BR><HR>"
if(1)
dat+= "<DIV STYLE='float:left; text-align:left; width:33.33333%'><A href='?src=\ref[src];prev_page=1'>Previous Page</A></DIV>"
dat+= "<DIV STYLE='float:left; text-align:center; width:33.33333%'><A href='?src=\ref[src];remove=1'>Remove [(istype(W, /obj/item/weapon/paper)) ? "paper" : "photo"]</A></DIV>"
dat+= "<DIV STYLE='float:left; text-align:right; width:33.33333%'><A href='?src=\ref[src];next_page=1'>Next Page</A></DIV><BR><HR>"
if(2)
dat+= "<DIV STYLE='float:left; text-align:left; width:33.33333%'><A href='?src=\ref[src];prev_page=1'>Previous Page</A></DIV>"
dat+= "<DIV STYLE='float:left; text-align:center; width:33.33333%'><A href='?src=\ref[src];remove=1'>Remove [(istype(W, /obj/item/weapon/paper)) ? "paper" : "photo"]</A></DIV><BR><HR>"
dat+= "<DIV STYLE='float;left; text-align:right; with:33.33333%'></DIV>"
if(istype(src[page], /obj/item/weapon/paper))
var/obj/item/weapon/paper/P = W
if(!(istype(usr, /mob/living/carbon/human) || istype(usr, /mob/dead/observer) || istype(usr, /mob/living/silicon)))
dat+= "<HTML><HEAD><TITLE>[P.name]</TITLE></HEAD><BODY>[stars(P.info)][P.stamps]</BODY></HTML>"
else
dat+= "<HTML><HEAD><TITLE>[P.name]</TITLE></HEAD><BODY>[P.info][P.stamps]</BODY></HTML>"
user << browse(dat, "window=[name]")
else if(istype(src[page], /obj/item/weapon/photo))
var/obj/item/weapon/photo/P = W
user << browse_rsc(P.img, "tmp_photo.png")
user << browse(dat + "<html><head><title>[P.name]</title></head>" \
+ "<body style='overflow:hidden'>" \
+ "<div> <img src='tmp_photo.png' width = '180'" \
+ "[P.scribble ? "<div> Written on the back:<br><i>[P.scribble]</i>" : ]"\
+ "</body></html>", "window=[name]")
/obj/item/weapon/paper_bundle/attack_self(mob/user as mob)
if(ishuman(user))
var/mob/living/carbon/human/human_user = user
var/dat
var/obj/item/weapon/W = src[page]
switch(screen)
if(0)
dat+= "<DIV STYLE='float:left; text-align:left; width:33.33333%'></DIV>"
dat+= "<DIV STYLE='float:left; text-align:center; width:33.33333%'><A href='?src=\ref[src];remove=1'>Remove [(istype(W, /obj/item/weapon/paper)) ? "paper" : "photo"]</A></DIV>"
dat+= "<DIV STYLE='float:left; text-align:right; width:33.33333%'><A href='?src=\ref[src];next_page=1'>Next Page</A></DIV><BR><HR>"
if(1)
dat+= "<DIV STYLE='float:left; text-align:left; width:33.33333%'><A href='?src=\ref[src];prev_page=1'>Previous Page</A></DIV>"
dat+= "<DIV STYLE='float:left; text-align:center; width:33.33333%'><A href='?src=\ref[src];remove=1'>Remove [(istype(W, /obj/item/weapon/paper)) ? "paper" : "photo"]</A></DIV>"
dat+= "<DIV STYLE='float:left; text-align:right; width:33.33333%'><A href='?src=\ref[src];next_page=1'>Next Page</A></DIV><BR><HR>"
if(2)
dat+= "<DIV STYLE='float:left; text-align:left; width:33.33333%'><A href='?src=\ref[src];prev_page=1'>Previous Page</A></DIV>"
dat+= "<DIV STYLE='float:left; text-align:center; width:33.33333%'><A href='?src=\ref[src];remove=1'>Remove [(istype(W, /obj/item/weapon/paper)) ? "paper" : "photo"]</A></DIV><BR><HR>"
dat+= "<DIV STYLE='float;left; text-align:right; with:33.33333%'></DIV>"
if(istype(src[page], /obj/item/weapon/paper))
var/obj/item/weapon/paper/P = W
if(!(istype(usr, /mob/living/carbon/human) || istype(usr, /mob/dead/observer) || istype(usr, /mob/living/silicon)))
dat+= "<HTML><HEAD><TITLE>[P.name]</TITLE></HEAD><BODY>[stars(P.info)][P.stamps]</BODY></HTML>"
else
dat+= "<HTML><HEAD><TITLE>[P.name]</TITLE></HEAD><BODY>[P.info][P.stamps]</BODY></HTML>"
human_user << browse(dat, "window=[name]")
P.add_fingerprint(usr)
else if(istype(src[page], /obj/item/weapon/photo))
var/obj/item/weapon/photo/P = W
human_user << browse_rsc(P.img, "tmp_photo.png")
human_user << browse(dat + "<html><head><title>[P.name]</title></head>" \
+ "<body style='overflow:hidden'>" \
+ "<div> <img src='tmp_photo.png' width = '180'" \
+ "[P.scribble ? "<div> Written on the back:<br><i>[P.scribble]</i>" : ]"\
+ "</body></html>", "window=[name]")
P.add_fingerprint(usr)
add_fingerprint(usr)
update_icon()
src.show_content(user)
add_fingerprint(usr)
update_icon()
return
/obj/item/weapon/paper_bundle/Topic(href, href_list)
..()
if((src in usr.contents) || (istype(src.loc, /obj/item/weapon/folder) && (src.loc in usr.contents)))