[TGUI] ERT Manager

This commit is contained in:
Kyep
2020-08-29 17:34:01 -07:00
parent 6710bfef9e
commit e71f40f3c0
7 changed files with 243 additions and 186 deletions
-105
View File
@@ -1,105 +0,0 @@
/datum/nano_module/ert_manager
name = "ERT Manager"
var/ert_type = "Code Red"
var/commander_slots = 1
var/security_slots = 3
var/medical_slots = 3
var/engineering_slots = 3
var/janitor_slots = 0
var/paranormal_slots = 0
var/cyborg_slots = 0
var/autoclose = 0
/datum/nano_module/ert_manager/ui_interact(mob/user, ui_key = "main", var/datum/nanoui/ui = null, var/force_open = 1, var/datum/topic_state/state = GLOB.admin_state)
ui = SSnanoui.try_update_ui(user, src, ui_key, ui, force_open)
if(ui && autoclose)
ui.close()
return 0
if(!ui)
ui = new(user, src, ui_key, "ert_config.tmpl", "ERT Panel", 600, 600, state = state)
ui.open()
ui.set_auto_update(1)
/datum/nano_module/ert_manager/Topic(href, href_list)
if(..())
return 1
if(href_list["set_code"])
ert_type = href_list["set_code"]
if(href_list["set_com"])
commander_slots = text2num(href_list["set_com"])
if(href_list["set_sec"])
security_slots = text2num(href_list["set_sec"])
if(href_list["set_med"])
medical_slots = text2num(href_list["set_med"])
if(href_list["set_eng"])
engineering_slots = text2num(href_list["set_eng"])
if(href_list["set_jan"])
janitor_slots = text2num(href_list["set_jan"])
if(href_list["set_par"])
paranormal_slots = text2num(href_list["set_par"])
if(href_list["set_cyb"])
cyborg_slots = text2num(href_list["set_cyb"])
if(href_list["dispatch_ert"])
GLOB.ert_request_answered = TRUE
var/slots_list = list()
if(commander_slots > 0)
slots_list += "commander: [commander_slots]"
if(security_slots > 0)
slots_list += "security: [security_slots]"
if(medical_slots > 0)
slots_list += "medical: [medical_slots]"
if(engineering_slots > 0)
slots_list += "engineering: [engineering_slots]"
if(janitor_slots > 0)
slots_list += "janitor: [janitor_slots]"
if(paranormal_slots > 0)
slots_list += "paranormal: [paranormal_slots]"
if(cyborg_slots > 0)
slots_list += "cyborg: [cyborg_slots]"
var/slot_text = jointext(slots_list, ", ")
notify_ghosts("An ERT is being dispatched. Open positions: [slot_text]")
message_admins("[key_name_admin(usr)] dispatched a [ert_type] ERT. Slots: [slot_text]", 1)
log_admin("[key_name(usr)] dispatched a [ert_type] ERT. Slots: [slot_text]")
GLOB.event_announcement.Announce("Attention, [station_name()]. We are attempting to assemble an ERT. Standby.", "ERT Protocol Activated")
autoclose = 1
ui_interact(usr)
trigger_armed_response_team(convert_ert_string(ert_type), commander_slots, security_slots, medical_slots, engineering_slots, janitor_slots, paranormal_slots, cyborg_slots)
return 0
ui_interact(usr)
/proc/convert_ert_string(thestring)
switch(thestring)
if("Code Amber")
return new /datum/response_team/amber
if("Code Red")
return new /datum/response_team/red
if("Code Gamma")
return new /datum/response_team/gamma
/datum/nano_module/ert_manager/ui_data()
var/data[0]
data["alert_level"] = get_security_level()
data["ert_type"] = ert_type
data["com"] = commander_slots
data["sec"] = security_slots
data["med"] = medical_slots
data["eng"] = engineering_slots
data["jan"] = janitor_slots
data["par"] = paranormal_slots
data["cyb"] = cyborg_slots
return data
+2 -2
View File
@@ -33,8 +33,8 @@ GLOBAL_VAR_INIT(ert_request_answered, FALSE)
to_chat(usr, "<span class='warning'>Central Command has already dispatched an emergency response team!</span>")
return
var/datum/nano_module/ert_manager/E = new()
E.ui_interact(usr)
var/datum/tgui_module/ert_manager/E = new()
E.tgui_interact(usr)
/mob/dead/observer/proc/JoinResponseTeam()
+100
View File
@@ -0,0 +1,100 @@
/datum/tgui_module/ert_manager
name = "ERT Manager"
var/ert_type = "Red"
var/commander_slots = 1 // defaults for open slots
var/security_slots = 4
var/medical_slots = 0
var/engineering_slots = 0
var/janitor_slots = 0
var/paranormal_slots = 0
var/cyborg_slots = 0
/datum/tgui_module/ert_manager/tgui_interact(mob/user, ui_key = "main", datum/tgui/ui = null, force_open = FALSE, datum/tgui/master_ui = null, datum/tgui_state/state = GLOB.tgui_admin_state)
ui = SStgui.try_update_ui(user, src, ui_key, ui, force_open)
if(!ui)
ui = new(user, src, ui_key, "ERTmanager", name, 350, 430, master_ui, state)
ui.autoupdate = TRUE
ui.open()
/datum/tgui_module/ert_manager/tgui_data(mob/user)
var/list/data = list()
data["str_security_level"] = capitalize(get_security_level())
switch(GLOB.security_level)
if(SEC_LEVEL_GREEN)
data["security_level_color"] = "green";
if(SEC_LEVEL_BLUE)
data["security_level_color"] = "blue";
if(SEC_LEVEL_RED)
data["security_level_color"] = "red";
else
data["security_level_color"] = "purple";
data["ert_type"] = ert_type
data["com"] = commander_slots
data["sec"] = security_slots
data["med"] = medical_slots
data["eng"] = engineering_slots
data["jan"] = janitor_slots
data["par"] = paranormal_slots
data["cyb"] = cyborg_slots
data["total"] = commander_slots + security_slots + medical_slots + engineering_slots + janitor_slots + paranormal_slots + cyborg_slots
data["spawnpoints"] = GLOB.emergencyresponseteamspawn.len
return data
/datum/tgui_module/ert_manager/tgui_act(action, params)
if(..())
return
. = TRUE
switch(action)
if("ert_type")
ert_type = params["ert_type"]
if("toggle_com")
commander_slots = commander_slots ? 0 : 1
if("set_sec")
security_slots = text2num(params["set_sec"])
if("set_med")
medical_slots = text2num(params["set_med"])
if("set_eng")
engineering_slots = text2num(params["set_eng"])
if("set_jan")
janitor_slots = text2num(params["set_jan"])
if("set_par")
paranormal_slots = text2num(params["set_par"])
if("set_cyb")
cyborg_slots = text2num(params["set_cyb"])
if("dispatch_ert")
var/datum/response_team/D
switch(ert_type)
if("Amber")
D = new /datum/response_team/amber
if("Red")
D = new /datum/response_team/red
if("Gamma")
D = new /datum/response_team/gamma
else
to_chat(usr, "<span class='userdanger'>Invalid ERT type.</span>")
return
GLOB.ert_request_answered = TRUE
var/slots_list = list()
if(commander_slots > 0)
slots_list += "commander: [commander_slots]"
if(security_slots > 0)
slots_list += "security: [security_slots]"
if(medical_slots > 0)
slots_list += "medical: [medical_slots]"
if(engineering_slots > 0)
slots_list += "engineering: [engineering_slots]"
if(janitor_slots > 0)
slots_list += "janitor: [janitor_slots]"
if(paranormal_slots > 0)
slots_list += "paranormal: [paranormal_slots]"
if(cyborg_slots > 0)
slots_list += "cyborg: [cyborg_slots]"
var/slot_text = jointext(slots_list, ", ")
notify_ghosts("An ERT is being dispatched. Open positions: [slot_text]")
message_admins("[key_name_admin(usr)] dispatched a [ert_type] ERT. Slots: [slot_text]", 1)
log_admin("[key_name(usr)] dispatched a [ert_type] ERT. Slots: [slot_text]")
GLOB.event_announcement.Announce("Attention, [station_name()]. We are attempting to assemble an ERT. Standby.", "ERT Protocol Activated")
trigger_armed_response_team(D, commander_slots, security_slots, medical_slots, engineering_slots, janitor_slots, paranormal_slots, cyborg_slots)
else
return FALSE
-75
View File
@@ -1,75 +0,0 @@
<div class='item'>
<table style='width: 100%'>
<tr>
<td>Station Alert Level</td><td>{{:data.alert_level}}</td>
</tr><tr>
<td>ERT Type</td><TD>
{{if data.ert_type == 'Code Amber'}} <font color='#FF7E00'> AMBER </font> {{else}} {{:helper.link('Amber', null, {"set_code": 'Code Amber'})}} {{/if}}
{{if data.ert_type == 'Code Red'}} <font color='#DC143C'> RED </font> {{else}} {{:helper.link('Red', null, {"set_code": 'Code Red'})}} {{/if}}
{{if data.ert_type == 'Code Gamma'}} <font color='#DB7093'> GAMMA </font> {{else}} {{:helper.link('Gamma', null, {"set_code": 'Code Gamma'})}} {{/if}}
</td>
</tr>
</table>
</div>
<hr>
<div class='item'>
<table style='width: 100%'>
<tr><th>Department</th><th>Slots</th><th>Change Slots</th></tr>
<tr><td>Command</td><td>{{if data.com == 0}}-{{else}}{{:helper.smoothRound(data.com)}}{{/if}}</td><td>
{{:helper.link('0', null, {"set_com": 0})}}
{{:helper.link('1', null, {"set_com": 1})}}</td></tr>
<tr><td>Security</td><td>{{if data.sec == 0}}-{{else}}{{:helper.smoothRound(data.sec)}}{{/if}}</td><td>
{{:helper.link('0', null, {"set_sec": 0})}}
{{:helper.link('1', null, {"set_sec": 1})}}
{{:helper.link('2', null, {"set_sec": 2})}}
{{:helper.link('3', null, {"set_sec": 3})}}
{{:helper.link('4', null, {"set_sec": 4})}}
{{:helper.link('5', null, {"set_sec": 5})}}
</td>
<tr><td>Medical</td><td>{{if data.med == 0}}-{{else}}{{:helper.smoothRound(data.med)}}{{/if}}</td><td>
{{:helper.link('0', null, {"set_med": 0})}}
{{:helper.link('1', null, {"set_med": 1})}}
{{:helper.link('2', null, {"set_med": 2})}}
{{:helper.link('3', null, {"set_med": 3})}}
{{:helper.link('4', null, {"set_med": 4})}}
{{:helper.link('5', null, {"set_med": 5})}}
</td>
<tr><td>Engineering</td><td>{{if data.eng == 0}}-{{else}}{{:helper.smoothRound(data.eng)}}{{/if}}</td><td>
{{:helper.link('0', null, {"set_eng": 0})}}
{{:helper.link('1', null, {"set_eng": 1})}}
{{:helper.link('2', null, {"set_eng": 2})}}
{{:helper.link('3', null, {"set_eng": 3})}}
{{:helper.link('4', null, {"set_eng": 4})}}
{{:helper.link('5', null, {"set_eng": 5})}}
</td>
<tr><td>Paranormal</td><td>{{if data.par == 0}}-{{else}}{{:helper.smoothRound(data.par)}}{{/if}}</td><td>
{{:helper.link('0', null, {"set_par": 0})}}
{{:helper.link('1', null, {"set_par": 1})}}
{{:helper.link('2', null, {"set_par": 2})}}
{{:helper.link('3', null, {"set_par": 3})}}
{{:helper.link('4', null, {"set_par": 4})}}
{{:helper.link('5', null, {"set_par": 5})}}
</td>
<tr><td>Janitor</td><td>{{if data.jan == 0}}-{{else}}{{:helper.smoothRound(data.jan)}}{{/if}}</td><td>
{{:helper.link('0', null, {"set_jan": 0})}}
{{:helper.link('1', null, {"set_jan": 1})}}
{{:helper.link('2', null, {"set_jan": 2})}}
{{:helper.link('3', null, {"set_jan": 3})}}
{{:helper.link('4', null, {"set_jan": 4})}}
{{:helper.link('5', null, {"set_jan": 5})}}
</td>
<tr><td>{{if data.ert_type == 'Code Gamma'}}<font color='#DB7093'>GAMMA</font> {{/if}}Cyborg</td><td>{{if data.cyb == 0}}-{{else}}{{:helper.smoothRound(data.cyb)}}{{/if}}</td><td>
{{:helper.link('0', null, {"set_cyb": 0})}}
{{:helper.link('1', null, {"set_cyb": 1})}}
{{:helper.link('2', null, {"set_cyb": 2})}}
{{:helper.link('3', null, {"set_cyb": 3})}}
{{:helper.link('4', null, {"set_cyb": 4})}}
{{:helper.link('5', null, {"set_cyb": 5})}}
</td></tr>
</table>
<BR>
</div>
<div class='item'>
{{:helper.link('Dispatch', null, {"dispatch_ert": 1})}}
</div>
+1 -1
View File
@@ -2108,7 +2108,6 @@
#include "code\modules\nano\interaction\zlevel.dm"
#include "code\modules\nano\modules\alarm_monitor.dm"
#include "code\modules\nano\modules\atmos_control.dm"
#include "code\modules\nano\modules\ert_manager.dm"
#include "code\modules\nano\modules\human_appearance.dm"
#include "code\modules\nano\modules\law_manager.dm"
#include "code\modules\nano\modules\nano_module.dm"
@@ -2447,6 +2446,7 @@
#include "code\modules\tgui\tgui.dm"
#include "code\modules\tgui\modules\_base.dm"
#include "code\modules\tgui\modules\crew_monitor.dm"
#include "code\modules\tgui\modules\ert_manager.dm"
#include "code\modules\tgui\states\admin.dm"
#include "code\modules\tgui\states\always.dm"
#include "code\modules\tgui\states\conscious.dm"
+137
View File
@@ -0,0 +1,137 @@
import { useBackend } from '../backend';
import { Button, LabeledList, Box, Section } from '../components';
import { Window } from '../layouts';
export const ERTmanager = (props, context) => {
const { act, data } = useBackend(context);
let slotOptions = [0, 1, 2, 3, 4, 5];
return (
<Window>
<Window.Content>
<Section title="Overview">
<LabeledList>
<LabeledList.Item label="Current Alert"
color={data.security_level_color}>
{data.str_security_level}
</LabeledList.Item>
<LabeledList.Item label="ERT Type">
<Button
content="Amber"
color={data.ert_type === "Amber"
? "orange"
: ""}
onClick={() => act('ert_type', { ert_type: "Amber" })} />
<Button
content="Red"
color={data.ert_type === "Red"
? "red"
: ""}
onClick={() => act('ert_type', { ert_type: "Red" })} />
<Button
content="Gamma"
color={data.ert_type === "Gamma"
? "purple"
: ""}
onClick={() => act('ert_type', { ert_type: "Gamma" })} />
</LabeledList.Item>
</LabeledList>
</Section>
<Section title="Slots">
<LabeledList>
<LabeledList.Item label="Commander">
<Button
content={data.com > 0 ? "Yes" : "No"}
selected={data.com > 0}
onClick={() => act('toggle_com')} />
</LabeledList.Item>
<LabeledList.Item label="Security">
{slotOptions.map((a, i) => (
<Button
key={"sec" + a}
selected={data.sec === a}
content={a}
onClick={() => act('set_sec', {
set_sec: a,
})}
/>
))}
</LabeledList.Item>
<LabeledList.Item label="Medical">
{slotOptions.map((a, i) => (
<Button
key={"med" + a}
selected={data.med === a}
content={a}
onClick={() => act('set_med', {
set_med: a,
})}
/>
))}
</LabeledList.Item>
<LabeledList.Item label="Engineering">
{slotOptions.map((a, i) => (
<Button
key={"eng" + a}
selected={data.eng === a}
content={a}
onClick={() => act('set_eng', {
set_eng: a,
})}
/>
))}
</LabeledList.Item>
<LabeledList.Item label="Paranormal">
{slotOptions.map((a, i) => (
<Button
key={"par" + a}
selected={data.par === a}
content={a}
onClick={() => act('set_par', {
set_par: a,
})}
/>
))}
</LabeledList.Item>
<LabeledList.Item label="Janitor">
{slotOptions.map((a, i) => (
<Button
key={"jan" + a}
selected={data.jan === a}
content={a}
onClick={() => act('set_jan', {
set_jan: a,
})}
/>
))}
</LabeledList.Item>
<LabeledList.Item label="Cyborg">
{slotOptions.map((a, i) => (
<Button
key={"cyb" + a}
selected={data.cyb === a}
content={a}
onClick={() => act('set_cyb', {
set_cyb: a,
})}
/>
))}
</LabeledList.Item>
<LabeledList.Item label="Total Slots">
<Box color={data.total > data.spawnpoints
? "red"
: "green"}>
{data.total} total, versus {data.spawnpoints} spawnpoints
</Box>
</LabeledList.Item>
<LabeledList.Item label="Dispatch">
<Button
icon="ambulance"
content="Send ERT"
onClick={() => act('dispatch_ert')} />
</LabeledList.Item>
</LabeledList>
</Section>
</Window.Content>
</Window>
);
};
File diff suppressed because one or more lines are too long