1
+ #define VUEUI_SET_CHECK (a, b, c, d ) if (a != b) { a = b; c = d; }
2
+
1
3
var /list /obj/machinery/photocopier/faxmachine/allfaxes = list ()
2
4
var /list /arrived_faxes = list () // cache for faxes that have been sent to the admins
3
5
var /list /sent_faxes = list () // cache for faxes that have been sent by the admins
@@ -21,105 +23,77 @@ var/list/admin_departments
21
23
22
24
var /static /const/broadcast_departments = " Stationwide broadcast (WARNING)"
23
25
var /obj /item/weapon/card/id/scan = null // identification
24
- var /authenticated = 0
25
26
var /sendtime = 0 // Time when fax was sent
26
27
var /sendcooldown = 0 // Delay, before another fax can be sent (in 1/10 second). Used by set_cooldown() and get_remaining_cooldown()
27
28
28
29
var /department = " Unknown" // our department
29
- var /destination = null // the department we're sending to
30
30
31
31
var /list /obj/item/device/pda/alert_pdas = list () // A list of PDAs to alert upon arrival of the fax.
32
32
33
33
/ obj / machinery/ photocopier/ faxmachine/ Initialize()
34
34
. = .. ()
35
35
allfaxes += src
36
- if (! destination) destination = " [ current_map. boss_name] "
37
36
if ( ! ((" [ department] " in alldepartments) || (" [ department] " in admin_departments)) )
38
37
alldepartments |= department
39
38
40
- / obj / machinery/ photocopier/ faxmachine/ attack_hand( mob / user as mob)
41
- user. set_machine(src )
42
-
43
- var /remaining_cooldown = get_remaining_cooldown()
44
- var /dat = " Fax Machine<BR>"
45
-
46
- var /scan_name
39
+ / obj / machinery/ photocopier/ faxmachine/ vueui_data_change(var /list /newdata , var /mob /user , var /datum /vueuiui/ui )
40
+ var /isChanged = FALSE
41
+ // Build baseline data, that's read-only
42
+ if (! newdata)
43
+ isChanged = TRUE
44
+ newdata = list (" destination" = " [ current_map. boss_name] " , " idname" = " " , " paper" = " " )
45
+ newdata[" bossname" ] = current_map. boss_name
46
+ VUEUI_SET_CHECK (newdata[" auth" ], is_authenticated(), isChanged, TRUE )
47
+ VUEUI_SET_CHECK (newdata[" cooldownend" ], sendtime + sendcooldown, isChanged, TRUE )
47
48
if (scan)
48
- scan_name = scan. name
49
+ VUEUI_SET_CHECK (newdata[ " idname " ], scan. name, isChanged, TRUE )
49
50
else
50
- scan_name = " --------"
51
-
52
- dat += " Confirm Identity: <a href='byond://?src=\ref [ src ] ;scan=1'> [ scan_name] </a><br>"
53
-
54
- if (authenticated)
55
- dat += " <a href='byond://?src=\ref [ src ] ;logout=1'>{Log Out}</a>"
56
- else
57
- dat += " <a href='byond://?src=\ref [ src ] ;auth=1'>{Log In}</a>"
58
-
59
- dat += " <hr>"
60
-
61
- if (authenticated)
62
- dat += " <b>Logged in to:</b> [ current_map. boss_name] Quantum Entanglement Network<br><br>"
63
-
64
- if (copyitem)
65
- dat += " <a href='byond://?src=\ref [ src ] ;remove=1'>Remove Item</a><br><br>"
66
-
67
- if (remaining_cooldown > 0 )
68
- dat += " <b>Transmitter arrays realigning. Please stand by. [ round(remaining_cooldown / 10 )] seconds remaining.</b><br>"
69
-
70
- else
71
-
72
- dat += " <a href='byond://?src=\ref [ src ] ;send=1'>Send</a><br>"
73
- dat += " <b>Currently sending:</b> [ copyitem. name] <br>"
74
- dat += " <b>Sending to:</b> <a href='byond://?src=\ref [ src ] ;dept=1'> [ destination] </a><br>"
75
-
76
- else
77
- if (remaining_cooldown > 0 )
78
- dat += " Please insert paper to send via secure connection.<br><br>"
79
- dat += " <b>Transmitter arrays realigning. Please stand by. [ round(remaining_cooldown / 10 )] seconds remaining.</b><br>"
80
- else
81
- dat += " Please insert paper to send via secure connection.<br><br>"
82
-
83
- else
84
- dat += " Proper authentication is required to use this device.<br><br>"
85
-
86
- if (copyitem)
87
- dat += " <a href ='byond://?src=\ref [ src ] ;remove=1'>Remove Item</a><br>"
88
-
89
- dat += " <br>PDAs to notify:<br>"
51
+ VUEUI_SET_CHECK (newdata[" idname" ], " " , isChanged, TRUE )
52
+ VUEUI_SET_CHECK (newdata[" paper" ], (copyitem ? copyitem. name : " " ), isChanged, TRUE )
90
53
54
+ if (newdata[" alertpdas" ] && alert_pdas && newdata[" alertpdas" ]. len != alert_pdas. len)
55
+ isChanged = TRUE
56
+ newdata[" alertpdas" ] = list ()
91
57
if (alert_pdas && alert_pdas. len)
92
58
for (var /obj /item/device/pda/pda in alert_pdas)
93
- dat += " [ alert_pdas[pda]] - <a href='byond://?src= \ref [ src ] ;unlink= \ref [ pda] '>Unlink</a><br>"
59
+ newdata[" alertpdas" ] += list (list (" name" = " [ alert_pdas[pda]] " , " ref" = " \ref [ pda] " ))
60
+ newdata[" departiments" ] = list ()
61
+ for (var /dept in (alldepartments + admin_departments + broadcast_departments))
62
+ newdata[" departiments" ] += " [ dept] "
94
63
95
- dat += " <br><a href='byond://?src=\ref [ src ] ;linkpda=1'>Add PDA to Notify</a>"
64
+ // Get destination from UI
65
+ if (! (newdata[" destination" ] in (alldepartments + admin_departments + broadcast_departments)))
66
+ newdata[" destination" ] = " [ current_map. boss_name] "
67
+ if (isChanged)
68
+ return newdata
96
69
97
- user << browse(dat, " window=copier" )
98
- onclose (user, " copier" )
99
-
100
- if (remaining_cooldown > 0 )
101
- spawn (50 )
102
- // Auto-refresh every 5 seconds, if cooldown is active
103
- updateUsrDialog ()
70
+ / obj / machinery/ photocopier/ faxmachine/ attack_hand( mob / user as mob)
71
+ var /datum /vueuiui/ui = SSvueui. get_open_ui(user, src )
72
+ if (! ui)
73
+ ui = new (usr , src , " fax" , 450 , 350 , capitalize(src . name))
74
+ ui. open()
104
75
105
- return
76
+ / obj / machinery/ photocopier/ faxmachine/ attackby( obj / item/ O as obj, mob / user as mob)
77
+ . = .. ()
78
+ SSvueui. check_uis_for_change(src )
106
79
107
80
/ obj / machinery/ photocopier/ faxmachine/ Topic(href, href_list)
108
81
if (href_list[" send" ])
109
82
if (get_remaining_cooldown() > 0 )
110
83
// Rate-limit sending faxes
111
84
usr << " <span class='warning'>The fax machine isn't ready, yet!</span>"
112
- updateUsrDialog ( )
85
+ SSvueui . check_uis_for_change( src )
113
86
return
114
87
115
- if (copyitem)
88
+ var /destination = href_list[" vueui" ]. data[" destination" ]
89
+ if (copyitem && is_authenticated())
116
90
if (destination in admin_departments)
117
91
send_admin_fax (usr , destination)
118
92
else if (destination == broadcast_departments)
119
93
send_broadcast_fax ()
120
94
else
121
95
sendfax (destination)
122
- updateUsrDialog ( )
96
+ SSvueui . check_uis_for_change( src )
123
97
124
98
else if (href_list[" remove" ])
125
99
if (copyitem)
@@ -130,7 +104,7 @@ var/list/admin_departments
130
104
else
131
105
usr << " <span class='notice'>You eject \the [ copyitem] from \the [ src ] .</span>"
132
106
copyitem = null
133
- updateUsrDialog ( )
107
+ SSvueui . check_uis_for_change( src )
134
108
135
109
if (href_list[" scan" ])
136
110
if (scan)
@@ -147,20 +121,7 @@ var/list/admin_departments
147
121
if (istype(I, / obj / item/ weapon/ card/ id) && usr . unEquip(I))
148
122
I. loc = src
149
123
scan = I
150
- authenticated = 0
151
-
152
- if (href_list[" dept" ])
153
- var /lastdestination = destination
154
- destination = input (usr , " Which department?" , " Choose a department" , " " ) as null | anything in (alldepartments + admin_departments + broadcast_departments)
155
- if (! destination) destination = lastdestination
156
-
157
- if (href_list[" auth" ])
158
- if ( (! ( authenticated ) && (scan)) )
159
- if (check_access(scan))
160
- authenticated = 1
161
-
162
- if (href_list[" logout" ])
163
- authenticated = 0
124
+ SSvueui. check_uis_for_change(src )
164
125
165
126
if (href_list[" linkpda" ])
166
127
var /obj /item/device/pda/pda = usr . get_active_hand()
@@ -170,19 +131,20 @@ var/list/admin_departments
170
131
usr << " <span class='notice'>\The [ pda] appears to be already linked.</span>"
171
132
// Update the name real quick.
172
133
alert_pdas[pda] = pda. name
134
+ SSvueui. check_uis_for_change(src )
173
135
else
174
136
alert_pdas += pda
175
137
alert_pdas[pda] = pda. name
176
138
usr << " <span class='notice'>You link \the [ pda] to \the [ src ] . It will now ping upon the arrival of a fax to this machine.</span>"
139
+ SSvueui. check_uis_for_change(src )
177
140
178
141
if (href_list[" unlink" ])
179
142
var /obj /item/device/pda/pda = locate (href_list[" unlink" ])
180
143
if (pda && istype(pda))
181
144
if (pda in alert_pdas)
182
145
usr << " <span class='notice'>You unlink [ alert_pdas[pda]] from \the [ src ] . It will no longer be notified of new faxes.</span>"
183
146
alert_pdas -= pda
184
-
185
- updateUsrDialog ()
147
+ SSvueui. check_uis_for_change(src )
186
148
187
149
/ obj / machinery/ photocopier/ faxmachine/ machinery_process()
188
150
.=.. ()
@@ -191,6 +153,12 @@ var/list/admin_departments
191
153
if ((sendtime + sendcooldown) < world . time)
192
154
sendcooldown = 0
193
155
156
+ /*
157
+ * Check if current id in machine is autenthicated
158
+ */
159
+ / obj / machinery/ photocopier/ faxmachine/ proc / is_authenticated()
160
+ return scan ? check_access(scan) : FALSE
161
+
194
162
/*
195
163
* Set the send cooldown
196
164
* cooldown: duration in ~1/10s
@@ -348,3 +316,5 @@ var/list/admin_departments
348
316
349
317
var /message = " New fax has arrived at [ src . department] fax machine."
350
318
pda. new_info(pda. message_silent, pda. ttone, " \icon [ pda] <b> [ message] </b>" )
319
+
320
+ #undef VUEUI_SET_CHECK
0 commit comments