/
adminpaper.dm
168 lines (129 loc) · 5.26 KB
/
adminpaper.dm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
//Adminpaper - it's like paper, but more adminny!
/obj/item/paper/admin
name = "administrative paper"
desc = "If you see this, something has gone horribly wrong."
var/datum/admins/admindatum = null
var/interactions = null
var/isCrayon = 0
var/origin = null
var/mob/sender = null
/// List (`/obj/machinery/photocopier/faxmachine`). List of fax machines matching the paper's target department.
var/list/destinations = list()
/// String. The paper's target department.
var/department = null
var/header = null
var/headerOn = TRUE
var/footer = null
var/footerOn = FALSE
var/logo_list = list("sollogo.png","eclogo.png","fleetlogo.png","exologo.png","ntlogo.png","daislogo.png","xynlogo.png","terralogo.png", "sfplogo.png", "falogo.png", "zhlogo.png")
var/logo = ""
var/unformatedText = ""
/obj/item/paper/admin/New()
..()
generateInteractions()
/obj/item/paper/admin/proc/generateInteractions()
//clear first
interactions = null
//Snapshot is crazy and likes putting each topic hyperlink on a seperate line from any other tags so it's nice and clean.
interactions += "<HR><center><span style='font-size: 10px'>The fax will transmit everything above this line</span><br>"
interactions += "<A href='?src=\ref[src];confirm=1'>Send fax</A> "
interactions += "<A href='?src=\ref[src];penmode=1'>Pen mode: [isCrayon ? "Crayon" : "Pen"]</A> "
interactions += "<A href='?src=\ref[src];cancel=1'>Cancel fax</A> "
interactions += "<BR>"
interactions += "<A href='?src=\ref[src];changelogo=1'>Change logo</A> "
interactions += "<A href='?src=\ref[src];changelanguage=1'>Change language ([language])</A> "
interactions += "<A href='?src=\ref[src];toggleheader=1'>Toggle Header</A> "
interactions += "<A href='?src=\ref[src];togglefooter=1'>Toggle Footer</A> "
interactions += "<A href='?src=\ref[src];clear=1'>Clear page</A> "
interactions += "</center>"
/obj/item/paper/admin/proc/generateHeader()
var/originhash = md5("[origin]")
var/challengehash = copytext(md5("[game_id]"),1,10) // changed to a hash of the game ID so it's more consistant but changes every round.
var/text = null
//TODO change logo based on who you're contacting.
text = "<center><img src = [logo]></br>"
text += "<b>[origin] Quantum Uplink Signed Message</b><br>"
text += "<span style='font-size: 10px'>Encryption key: [originhash]<br>"
text += "Challenge: [challengehash]<br></span></center><hr>"
header = text
/obj/item/paper/admin/proc/generateFooter()
var/text = null
text = "<hr><span style='font-size: 10px'>"
text += "This transmission is intended only for the addressee and may contain confidential information. Any unauthorized disclosure is strictly prohibited. <br><br>"
text += "If this transmission is recieved in error, please notify both the sender and the office of [GLOB.using_map.boss_name] Internal Affairs immediately so that corrective action may be taken."
text += "Failure to comply is a breach of regulation and may be prosecuted to the fullest extent of the law, where applicable."
text += "</span>"
footer = text
/obj/item/paper/admin/proc/adminbrowse()
updateinfolinks()
generateHeader()
generateFooter()
updateDisplay()
/obj/item/paper/admin/proc/updateDisplay()
show_browser(usr, "<HTML><HEAD><TITLE>[name]</TITLE></HEAD><BODY>[headerOn ? header : ""][info_links][stamps][footerOn ? footer : ""][interactions]</BODY></HTML>", "window=[name];can_close=0")
/obj/item/paper/admin/Topic(href, href_list)
if(href_list["write"])
var/id = href_list["write"]
var/t = sanitize(input("Enter what you want to write:", "Write", unformatedText, null) as message, MAX_PAPER_MESSAGE_LEN, extra = 0)
if(!t)
return
var last_fields_value = fields
unformatedText = t
//t = html_encode(t)
t = replacetext(t, "\n", "<BR>")
t = parsepencode(t, null, null, isCrayon, null, TRUE) // Encode everything from pencode to html
if(fields > 50)//large amount of fields creates a heavy load on the server, see updateinfolinks() and addtofield()
to_chat(usr, SPAN_WARNING("Too many fields. Sorry, you can't do this."))
fields = last_fields_value
return
if(id!="end")
addtofield(text2num(id), t) // He wants to edit a field, let him.
else
info = t // set the file to the new text
updateinfolinks()
//manualy set freespace
free_space = MAX_PAPER_MESSAGE_LEN - length(strip_html_properly(t))
updateDisplay()
update_icon()
return
if(href_list["confirm"])
switch(alert("Are you sure you want to send the fax as is?",, "Yes", "No"))
if("Yes")
if(headerOn)
info = header + info
if(footerOn)
info += footer
updateinfolinks()
close_browser(usr, "window=[name]")
admindatum.faxCallback(src)
return
if(href_list["penmode"])
isCrayon = !isCrayon
generateInteractions()
updateDisplay()
return
if(href_list["cancel"])
close_browser(usr, "window=[name]")
qdel(src)
return
if(href_list["clear"])
clearpaper()
updateDisplay()
return
if(href_list["toggleheader"])
headerOn = !headerOn
updateDisplay()
return
if(href_list["togglefooter"])
footerOn = !footerOn
updateDisplay()
return
if(href_list["changelogo"])
logo = input(usr, "What logo?", "Choose a logo", "") as null|anything in (logo_list)
generateHeader()
updateDisplay()
return
if (href_list["changelanguage"])
choose_language(usr, TRUE)
updateDisplay()
return