Skip to content

Commit 54dc6a4

Browse files
committed
And fax machine receves first vueui interface
1 parent 567b1d9 commit 54dc6a4

File tree

10 files changed

+183
-106
lines changed

10 files changed

+183
-106
lines changed

code/modules/paperwork/faxmachine.dm

+51-81
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#define VUEUI_SET_CHECK(a, b, c, d) if (a != b) { a = b; c = d; }
2+
13
var/list/obj/machinery/photocopier/faxmachine/allfaxes = list()
24
var/list/arrived_faxes = list() //cache for faxes that have been sent to the admins
35
var/list/sent_faxes = list() //cache for faxes that have been sent by the admins
@@ -21,105 +23,77 @@ var/list/admin_departments
2123

2224
var/static/const/broadcast_departments = "Stationwide broadcast (WARNING)"
2325
var/obj/item/weapon/card/id/scan = null // identification
24-
var/authenticated = 0
2526
var/sendtime = 0 // Time when fax was sent
2627
var/sendcooldown = 0 // Delay, before another fax can be sent (in 1/10 second). Used by set_cooldown() and get_remaining_cooldown()
2728

2829
var/department = "Unknown" // our department
29-
var/destination = null // the department we're sending to
3030

3131
var/list/obj/item/device/pda/alert_pdas = list() //A list of PDAs to alert upon arrival of the fax.
3232

3333
/obj/machinery/photocopier/faxmachine/Initialize()
3434
. = ..()
3535
allfaxes += src
36-
if(!destination) destination = "[current_map.boss_name]"
3736
if( !(("[department]" in alldepartments) || ("[department]" in admin_departments)) )
3837
alldepartments |= department
3938

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)
4748
if(scan)
48-
scan_name = scan.name
49+
VUEUI_SET_CHECK(newdata["idname"], scan.name, isChanged, TRUE)
4950
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)
9053

54+
if(newdata["alertpdas"] && alert_pdas && newdata["alertpdas"].len != alert_pdas.len)
55+
isChanged = TRUE
56+
newdata["alertpdas"] = list()
9157
if (alert_pdas && alert_pdas.len)
9258
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]"
9463

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
9669

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()
10475

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)
10679

10780
/obj/machinery/photocopier/faxmachine/Topic(href, href_list)
10881
if(href_list["send"])
10982
if (get_remaining_cooldown() > 0)
11083
// Rate-limit sending faxes
11184
usr << "<span class='warning'>The fax machine isn't ready, yet!</span>"
112-
updateUsrDialog()
85+
SSvueui.check_uis_for_change(src)
11386
return
11487

115-
if(copyitem)
88+
var/destination = href_list["vueui"].data["destination"]
89+
if(copyitem && is_authenticated())
11690
if (destination in admin_departments)
11791
send_admin_fax(usr, destination)
11892
else if (destination == broadcast_departments)
11993
send_broadcast_fax()
12094
else
12195
sendfax(destination)
122-
updateUsrDialog()
96+
SSvueui.check_uis_for_change(src)
12397

12498
else if(href_list["remove"])
12599
if(copyitem)
@@ -130,7 +104,7 @@ var/list/admin_departments
130104
else
131105
usr << "<span class='notice'>You eject \the [copyitem] from \the [src].</span>"
132106
copyitem = null
133-
updateUsrDialog()
107+
SSvueui.check_uis_for_change(src)
134108

135109
if(href_list["scan"])
136110
if (scan)
@@ -147,20 +121,7 @@ var/list/admin_departments
147121
if (istype(I, /obj/item/weapon/card/id) && usr.unEquip(I))
148122
I.loc = src
149123
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)
164125

165126
if(href_list["linkpda"])
166127
var/obj/item/device/pda/pda = usr.get_active_hand()
@@ -170,19 +131,20 @@ var/list/admin_departments
170131
usr << "<span class='notice'>\The [pda] appears to be already linked.</span>"
171132
//Update the name real quick.
172133
alert_pdas[pda] = pda.name
134+
SSvueui.check_uis_for_change(src)
173135
else
174136
alert_pdas += pda
175137
alert_pdas[pda] = pda.name
176138
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)
177140

178141
if(href_list["unlink"])
179142
var/obj/item/device/pda/pda = locate(href_list["unlink"])
180143
if (pda && istype(pda))
181144
if (pda in alert_pdas)
182145
usr << "<span class='notice'>You unlink [alert_pdas[pda]] from \the [src]. It will no longer be notified of new faxes.</span>"
183146
alert_pdas -= pda
184-
185-
updateUsrDialog()
147+
SSvueui.check_uis_for_change(src)
186148

187149
/obj/machinery/photocopier/faxmachine/machinery_process()
188150
.=..()
@@ -191,6 +153,12 @@ var/list/admin_departments
191153
if ((sendtime + sendcooldown) < world.time)
192154
sendcooldown = 0
193155

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+
194162
/*
195163
* Set the send cooldown
196164
* cooldown: duration in ~1/10s
@@ -348,3 +316,5 @@ var/list/admin_departments
348316

349317
var/message = "New fax has arrived at [src.department] fax machine."
350318
pda.new_info(pda.message_silent, pda.ttone, "\icon[pda] <b>[message]</b>")
319+
320+
#undef VUEUI_SET_CHECK

code/modules/vueui/test.dm

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
/datum/vueuiuitest/proc/open_ui()
1212
var/datum/vueuiui/ui = SSvueui.get_open_ui(usr, src)
1313
if (!ui)
14-
ui = new(usr, src, "test", 300, 300, null, interactive_state)
14+
ui = new(usr, src, "test", 400, 400, "Test ui title", null, interactive_state)
1515
ui.open()
1616

1717
/datum/vueuiuitest/vueui_data_change(var/list/newdata, var/mob/user, var/datum/vueuiui/ui)

code/modules/vueui/ui.dm

+5-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ main ui datum.
4343
*
4444
* @return nothing
4545
*/
46-
/datum/vueuiui/New(var/nuser, var/nobject, var/nactiveui = 0, var/nwidth = 0, var/nheight = 0, var/list/ndata, var/datum/topic_state/nstate = default_state)
46+
/datum/vueuiui/New(var/nuser, var/nobject, var/nactiveui = 0, var/nwidth = 0, var/nheight = 0, var/ntitle, var/list/ndata, var/datum/topic_state/nstate = default_state)
4747
user = nuser
4848
object = nobject
4949
data = ndata
@@ -55,6 +55,8 @@ main ui datum.
5555
width = nwidth
5656
if (nheight)
5757
height = nheight
58+
if (ntitle)
59+
title = ntitle
5860

5961
SSvueui.ui_opened(src)
6062
windowid = "vueui\ref[src]"
@@ -148,6 +150,7 @@ main ui datum.
148150
sdata["active"] = activeui
149151
sdata["uiref"] = "\ref[src]"
150152
sdata["status"] = status
153+
sdata["title"] = title
151154
sdata["wtime"] = world.time
152155
for(var/list/asset in assets)
153156
sdata["assets"][asset["name"]] = list("ref" = "\ref[asset["img"]]")
@@ -214,6 +217,7 @@ main ui datum.
214217
push_change(ret)
215218
src.data = ndata
216219
return // Object shal not get state update calls
220+
href_list["vueui"] = src // Let's pass our UI object to object for it to do things.
217221
object.Topic(href, href_list)
218222

219223
/**

vueui/components/header/default.vue

+26-13
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
<template>
22
<div id='uiTitleWrapper' unselectable="on">
3-
<div id='uiStatusIcon' class='icon24 uiStatusAverage' unselectable="on"></div>
4-
<div id='uiTitleText' unselectable="on">TITLE</div>
3+
<slot></slot>
4+
<div id='uiStatusIcon' class='icon24' :class="statusClass" unselectable="on"></div>
5+
<div id='uiTitleText' unselectable="on">{{ title }}</div>
56
<div id='uiTitleFluff' unselectable="on"></div>
67
</div>
78
</template>
@@ -11,27 +12,38 @@ export default {
1112
name: "header-default",
1213
data () {
1314
return this.$root.$data
15+
},
16+
computed: {
17+
statusClass() {
18+
if (this.status == 2) return 'uiStatusGood'
19+
if (this.status == 1) return 'uiStatusAverage'
20+
return 'uiStatusBad'
21+
}
1422
}
1523
}
1624
</script>
1725

1826
<style lang="scss" scoped>
1927
#uiTitleWrapper {
20-
box-shadow: 0px 0px 10px 5px rgba(0,0,0,0.75);
28+
box-shadow: 0px 0px 8px 4px rgba(0,0,0,0.5);
2129
margin: -8px -8px 10px;
2230
position: relative;
23-
height: 32px;
31+
padding-bottom: 8px;
32+
float: none;
2433
background: url(../../resources/uiTitleBackground.png) repeat center;
2534
}
2635
2736
#uiTitleText {
28-
position: absolute;
29-
top: 6px;
30-
left: 44px;
37+
position: relative;
38+
display: inline-block;
39+
top: 4px;
40+
left: 18px;
3141
width: 66%;
32-
overflow: hidden;
42+
width: calc(100% - 36px - 42px - 18px);
3343
color: #E9C183;
3444
font-size: 16px;
45+
line-height: 20px;
46+
vertical-align: middle;
3547
}
3648
3749
#uiTitle.icon {
@@ -41,20 +53,21 @@ export default {
4153
}
4254
4355
#uiTitleFluff {
44-
position: absolute;
56+
position: relative;
57+
float: right;
4558
top: 4px;
46-
right: 12px;
59+
right: 10px;
4760
width: 42px;
4861
height: 24px;
4962
background: url(../../resources/uiTitleFluff.png) 50% 50% no-repeat;
5063
}
5164
5265
#uiStatusIcon {
53-
position: absolute;
66+
position: relative;
67+
display: inline-block;
5468
top: 4px;
5569
left: 12px;
56-
width: 24px;
57-
height: 24px;
70+
vertical-align: middle;
5871
}
5972
</style>
6073

0 commit comments

Comments
 (0)