mirror of
https://github.com/CHOMPStation2/CHOMPStation2.git
synced 2025-12-10 18:22:39 +00:00
Change crew monitoring computer to use NanoUI
This commit is contained in:
@@ -297,6 +297,31 @@ proc/listclearnulls(list/list)
|
|||||||
return (result + R.Copy(Ri, 0))
|
return (result + R.Copy(Ri, 0))
|
||||||
|
|
||||||
|
|
||||||
|
// List of lists, sorts by element[key] - for things like crew monitoring computer sorting records by name.
|
||||||
|
/proc/sortByKey(var/list/L, var/key)
|
||||||
|
if(L.len < 2)
|
||||||
|
return L
|
||||||
|
var/middle = L.len / 2 + 1
|
||||||
|
return mergeKeyedLists(sortByKey(L.Copy(0, middle), key), sortByKey(L.Copy(middle), key), key)
|
||||||
|
|
||||||
|
/proc/mergeKeyedLists(var/list/L, var/list/R, var/key)
|
||||||
|
var/Li=1
|
||||||
|
var/Ri=1
|
||||||
|
var/list/result = new()
|
||||||
|
while(Li <= L.len && Ri <= R.len)
|
||||||
|
if(sorttext(L[Li][key], R[Ri][key]) < 1)
|
||||||
|
// Works around list += list2 merging lists; it's not pretty but it works
|
||||||
|
result += "temp item"
|
||||||
|
result[result.len] = R[Ri++]
|
||||||
|
else
|
||||||
|
result += "temp item"
|
||||||
|
result[result.len] = L[Li++]
|
||||||
|
|
||||||
|
if(Li <= L.len)
|
||||||
|
return (result + L.Copy(Li, 0))
|
||||||
|
return (result + R.Copy(Ri, 0))
|
||||||
|
|
||||||
|
|
||||||
//Mergesort: any value in a list, preserves key=value structure
|
//Mergesort: any value in a list, preserves key=value structure
|
||||||
/proc/sortAssoc(var/list/L)
|
/proc/sortAssoc(var/list/L)
|
||||||
if(L.len < 2)
|
if(L.len < 2)
|
||||||
|
|||||||
@@ -43,67 +43,65 @@
|
|||||||
if(..()) return
|
if(..()) return
|
||||||
if (src.z > 6)
|
if (src.z > 6)
|
||||||
usr << "\red <b>Unable to establish a connection</b>: \black You're too far away from the station!"
|
usr << "\red <b>Unable to establish a connection</b>: \black You're too far away from the station!"
|
||||||
return
|
return 0
|
||||||
if( href_list["close"] )
|
if( href_list["close"] )
|
||||||
usr << browse(null, "window=crewcomp")
|
var/mob/user = usr
|
||||||
|
var/datum/nanoui/ui = nanomanager.get_open_ui(user, src, "main")
|
||||||
usr.unset_machine()
|
usr.unset_machine()
|
||||||
return
|
ui.close()
|
||||||
|
return 0
|
||||||
if(href_list["update"])
|
if(href_list["update"])
|
||||||
src.updateDialog()
|
src.updateDialog()
|
||||||
return
|
return 1
|
||||||
|
|
||||||
|
/obj/machinery/computer/crew/interact(mob/user, ui_key = "main", var/datum/nanoui/ui = null)
|
||||||
/obj/machinery/computer/crew/interact(mob/user)
|
|
||||||
if(stat & (BROKEN|NOPOWER))
|
if(stat & (BROKEN|NOPOWER))
|
||||||
return
|
return
|
||||||
if(!istype(user, /mob/living/silicon) && get_dist(src, user) > 1)
|
|
||||||
user.unset_machine()
|
|
||||||
user << browse(null, "window=powcomp")
|
|
||||||
return
|
|
||||||
user.set_machine(src)
|
user.set_machine(src)
|
||||||
src.scan()
|
src.scan()
|
||||||
var/t = "<TT><B>Crew Monitoring</B><HR>"
|
|
||||||
t += "<BR><A href='?src=\ref[src];update=1'>Refresh</A> "
|
var/data[0]
|
||||||
t += "<A href='?src=\ref[src];close=1'>Close</A><BR>"
|
var/list/crewmembers = list()
|
||||||
t += "<table><tr><td width='40%'>Name</td><td width='20%'>Vitals</td><td width='40%'>Position</td></tr>"
|
|
||||||
var/list/logs = list()
|
|
||||||
for(var/obj/item/clothing/under/C in src.tracked)
|
for(var/obj/item/clothing/under/C in src.tracked)
|
||||||
var/log = ""
|
|
||||||
|
|
||||||
var/turf/pos = get_turf(C)
|
var/turf/pos = get_turf(C)
|
||||||
|
|
||||||
if((C) && (C.has_sensor) && (pos) && (pos.z == src.z) && C.sensor_mode)
|
if((C) && (C.has_sensor) && (pos) && (pos.z == src.z) && C.sensor_mode)
|
||||||
if(istype(C.loc, /mob/living/carbon/human))
|
if(istype(C.loc, /mob/living/carbon/human))
|
||||||
|
|
||||||
var/mob/living/carbon/human/H = C.loc
|
var/mob/living/carbon/human/H = C.loc
|
||||||
|
|
||||||
var/dam1 = round(H.getOxyLoss(),1)
|
var/list/crewmemberData = list()
|
||||||
var/dam2 = round(H.getToxLoss(),1)
|
|
||||||
var/dam3 = round(H.getFireLoss(),1)
|
|
||||||
var/dam4 = round(H.getBruteLoss(),1)
|
|
||||||
|
|
||||||
var/life_status = "[H.stat > 1 ? "<font color=red>Deceased</font>" : "Living"]"
|
crewmemberData["sensor_type"] = C.sensor_mode
|
||||||
var/damage_report = "(<font color='blue'>[dam1]</font>/<font color='green'>[dam2]</font>/<font color='orange'>[dam3]</font>/<font color='red'>[dam4]</font>)"
|
crewmemberData["dead"] = H.stat > 1
|
||||||
|
crewmemberData["oxy"] = round(H.getOxyLoss(), 1)
|
||||||
|
crewmemberData["tox"] = round(H.getToxLoss(), 1)
|
||||||
|
crewmemberData["fire"] = round(H.getFireLoss(), 1)
|
||||||
|
crewmemberData["brute"] = round(H.getBruteLoss(), 1)
|
||||||
|
crewmemberData["name"] = (H.wear_id ? H.wear_id.name : "Unknown")
|
||||||
|
crewmemberData["area"] = get_area(H)
|
||||||
|
crewmemberData["x"] = pos.x
|
||||||
|
crewmemberData["y"] = pos.y
|
||||||
|
|
||||||
if(H.wear_id)
|
// Works around list += list2 merging lists; it's not pretty but it works
|
||||||
log += "<tr><td width='40%'>[H.wear_id.name]</td>"
|
crewmembers += "temporary item"
|
||||||
else
|
crewmembers[crewmembers.len] = crewmemberData
|
||||||
log += "<tr><td width='40%'>Unknown</td>"
|
|
||||||
|
|
||||||
switch(C.sensor_mode)
|
crewmembers = sortByKey(crewmembers, "name")
|
||||||
if(1)
|
|
||||||
log += "<td width='15%'>[life_status]</td><td width='40%'>Not Available</td></tr>"
|
data["crewmembers"] = crewmembers
|
||||||
if(2)
|
|
||||||
log += "<td width='20%'>[life_status] [damage_report]</td><td width='40%'>Not Available</td></tr>"
|
ui = nanomanager.try_update_ui(user, src, ui_key, ui, data)
|
||||||
if(3)
|
if(!ui)
|
||||||
var/area/player_area = get_area(H)
|
ui = new(user, src, ui_key, "crew_monitor.tmpl", "Crew Monitoring Computer", 900, 600)
|
||||||
log += "<td width='20%'>[life_status] [damage_report]</td><td width='40%'>[player_area.name] ([pos.x], [pos.y])</td></tr>"
|
ui.set_initial_data(data)
|
||||||
logs += log
|
ui.open()
|
||||||
logs = sortList(logs)
|
|
||||||
for(var/log in logs)
|
// should make the UI auto-update; doesn't seem to?
|
||||||
t += log
|
ui.set_auto_update(1)
|
||||||
t += "</table>"
|
|
||||||
t += "</FONT></PRE></TT>"
|
|
||||||
user << browse(t, "window=crewcomp;size=900x600")
|
|
||||||
onclose(user, "crewcomp")
|
|
||||||
|
|
||||||
|
|
||||||
/obj/machinery/computer/crew/proc/scan()
|
/obj/machinery/computer/crew/proc/scan()
|
||||||
|
|||||||
@@ -519,5 +519,24 @@ th.misc
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Damage colors for crew monitoring computer */
|
||||||
|
|
||||||
|
.burn
|
||||||
|
{
|
||||||
|
color: orange;
|
||||||
|
}
|
||||||
|
|
||||||
|
.brute
|
||||||
|
{
|
||||||
|
color: red;
|
||||||
|
}
|
||||||
|
|
||||||
|
.toxin
|
||||||
|
{
|
||||||
|
color: green;
|
||||||
|
}
|
||||||
|
|
||||||
|
.oxyloss
|
||||||
|
{
|
||||||
|
color: blue;
|
||||||
|
}
|
||||||
|
|||||||
23
nano/templates/crew_monitor.tmpl
Normal file
23
nano/templates/crew_monitor.tmpl
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
<!--
|
||||||
|
Crew Monitoring Computer interface
|
||||||
|
-->
|
||||||
|
<div class="item">
|
||||||
|
<div class="itemLabel">
|
||||||
|
Functions:
|
||||||
|
</div>
|
||||||
|
<div class="itemContent">
|
||||||
|
{{:~link('Refresh', 'refresh', {'update' : 1}, null)}}
|
||||||
|
{{:~link('Close', 'close', {'close' : 1}, null)}}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<table width="100%"><tbody>
|
||||||
|
{{for crewmembers}}
|
||||||
|
{{if sensor_type == 1}}
|
||||||
|
<tr><td>{{:name}}</td><td>{{:dead ? "<span class='bad'>Deceased</span>" : "<span class='good'>Living</span>"}}</td><td><span class="neutral">Not Available</span></td></tr>
|
||||||
|
{{else sensor_type == 2}}
|
||||||
|
<tr><td>{{:name}}</td><td>{{:dead ? "<span class='bad'>Deceased</span>" : "<span class='good'>Living</span>"}} (<span class="oxyloss">{{:oxy}}</span>/<span class="toxin">{{:tox}}</span>/<span class="burn">{{:fire}}</span>/<span class="brute">{{:brute}}</span>)</td><td><span class="neutral">Not Available</td></td></tr>
|
||||||
|
{{else sensor_type == 3}}
|
||||||
|
<tr><td>{{:name}}</td><td>{{:dead ? "<span class='bad'>Deceased</span>" : "<span class='good'>Living</span>"}} (<span class="oxyloss">{{:oxy}}</span>/<span class="toxin">{{:tox}}</span>/<span class="burn">{{:fire}}</span>/<span class="brute">{{:brute}}</span>)</td><td>{{:area}}({{:x}}, {{:y}})</td></tr>
|
||||||
|
{{/if}}
|
||||||
|
{{/for}}
|
||||||
|
</tbody></table>
|
||||||
Reference in New Issue
Block a user