mirror of
https://github.com/ParadiseSS13/Paradise.git
synced 2026-07-18 18:44:48 +01:00
Merge pull request #13955 from AffectedArc07/sm-monitoring-console
[TGUI] Supermatter Monitoring Console
This commit is contained in:
@@ -233,7 +233,10 @@
|
||||
/obj/item/circuitboard/brigcells
|
||||
name = "Circuit board (Brig Cell Control)"
|
||||
build_path = /obj/machinery/computer/brigcells
|
||||
|
||||
/obj/item/circuitboard/sm_monitor
|
||||
name = "Circuit board (Supermatter Monitoring Console)"
|
||||
build_path = /obj/machinery/computer/sm_monitor
|
||||
origin_tech = "programming=2;powerstorage=2"
|
||||
|
||||
// RD console circuits, so that {de,re}constructing one of the special consoles doesn't ruin everything forever
|
||||
/obj/item/circuitboard/rdconsole
|
||||
|
||||
@@ -0,0 +1,147 @@
|
||||
/obj/machinery/computer/sm_monitor
|
||||
name = "supermatter monitoring console"
|
||||
desc = "Used to monitor supermatter shards."
|
||||
icon_keyboard = "power_key"
|
||||
icon_screen = "smmon_0"
|
||||
circuit = /obj/item/circuitboard/sm_monitor
|
||||
light_color = LIGHT_COLOR_YELLOW
|
||||
/// Cache-list of all supermatter shards
|
||||
var/list/supermatters
|
||||
/// Last status of the active supermatter for caching purposes
|
||||
var/last_status
|
||||
/// Reference to the active shard
|
||||
var/obj/machinery/power/supermatter_shard/active
|
||||
|
||||
/obj/machinery/computer/sm_monitor/Destroy()
|
||||
active = null
|
||||
return ..()
|
||||
|
||||
/obj/machinery/computer/sm_monitor/attack_ai(mob/user)
|
||||
attack_hand(user)
|
||||
|
||||
/obj/machinery/computer/sm_monitor/attack_hand(mob/user)
|
||||
add_fingerprint(user)
|
||||
if(stat & (BROKEN|NOPOWER))
|
||||
return
|
||||
tgui_interact(user)
|
||||
|
||||
/obj/machinery/computer/sm_monitor/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_default_state)
|
||||
ui = SStgui.try_update_ui(user, src, ui_key, ui, force_open)
|
||||
if(!ui)
|
||||
ui = new(user, src, ui_key, "SupermatterMonitor", name, 600, 325, master_ui, state)
|
||||
ui.open()
|
||||
|
||||
/obj/machinery/computer/sm_monitor/tgui_data(mob/user)
|
||||
var/list/data = list()
|
||||
|
||||
if(istype(active))
|
||||
var/turf/T = get_turf(active)
|
||||
// If we somehow delam during this proc, handle it somewhat
|
||||
if(!T)
|
||||
active = null
|
||||
refresh()
|
||||
return
|
||||
var/datum/gas_mixture/air = T.return_air()
|
||||
if(!air)
|
||||
active = null
|
||||
return
|
||||
|
||||
data["active"] = TRUE
|
||||
data["SM_integrity"] = active.get_integrity()
|
||||
data["SM_power"] = active.power
|
||||
data["SM_ambienttemp"] = air.temperature
|
||||
data["SM_ambientpressure"] = air.return_pressure()
|
||||
//data["SM_EPR"] = round((air.total_moles / air.group_multiplier) / 23.1, 0.01)
|
||||
var/other_moles = air.total_trace_moles()
|
||||
var/TM = air.total_moles()
|
||||
if(TM)
|
||||
data["SM_gas_O2"] = round(100*air.oxygen/TM, 0.01)
|
||||
data["SM_gas_CO2"] = round(100*air.carbon_dioxide/TM, 0.01)
|
||||
data["SM_gas_N2"] = round(100*air.nitrogen/TM, 0.01)
|
||||
data["SM_gas_PL"] = round(100*air.toxins/TM, 0.01)
|
||||
if(other_moles)
|
||||
data["SM_gas_OTHER"] = round(100 * other_moles / TM, 0.01)
|
||||
else
|
||||
data["SM_gas_OTHER"] = 0
|
||||
else
|
||||
data["SM_gas_O2"] = 0
|
||||
data["SM_gas_CO2"] = 0
|
||||
data["SM_gas_N2"] = 0
|
||||
data["SM_gas_PH"] = 0
|
||||
data["SM_gas_OTHER"] = 0
|
||||
else
|
||||
var/list/SMS = list()
|
||||
for(var/I in supermatters)
|
||||
var/obj/machinery/power/supermatter_shard/S = I
|
||||
var/area/A = get_area(S)
|
||||
if(!A)
|
||||
continue
|
||||
|
||||
SMS.Add(list(list(
|
||||
"area_name" = A.name,
|
||||
"integrity" = S.get_integrity(),
|
||||
"uid" = S.UID()
|
||||
)))
|
||||
|
||||
data["active"] = FALSE
|
||||
data["supermatters"] = SMS
|
||||
|
||||
return data
|
||||
|
||||
/**
|
||||
* Supermatter List Refresher
|
||||
*
|
||||
* This proc loops through the list of supermatters in the atmos SS and adds them to this console's cache list
|
||||
*/
|
||||
/obj/machinery/computer/sm_monitor/proc/refresh()
|
||||
supermatters = list()
|
||||
var/turf/T = get_turf(tgui_host()) // Get the TGUI host incase this ever turned into a supermatter monitoring module for AIs to use or something
|
||||
if(!T)
|
||||
return
|
||||
for(var/obj/machinery/power/supermatter_shard/S in SSair.atmos_machinery)
|
||||
// Delaminating, not within coverage, not on a tile.
|
||||
if(!(is_station_level(S.z) || is_mining_level(S.z) || atoms_share_level(S, T) || !istype(S.loc, /turf/simulated/)))
|
||||
continue
|
||||
supermatters.Add(S)
|
||||
|
||||
if(!(active in supermatters))
|
||||
active = null
|
||||
|
||||
/obj/machinery/computer/sm_monitor/process()
|
||||
if(stat & (NOPOWER|BROKEN))
|
||||
return FALSE
|
||||
|
||||
if(active)
|
||||
var/new_status = active.get_status()
|
||||
if(last_status != new_status)
|
||||
last_status = new_status
|
||||
if(last_status == SUPERMATTER_ERROR)
|
||||
last_status = SUPERMATTER_INACTIVE
|
||||
icon_screen = "smmon_[last_status]"
|
||||
update_icon()
|
||||
|
||||
return TRUE
|
||||
|
||||
/obj/machinery/computer/sm_monitor/tgui_act(action, params)
|
||||
if(..())
|
||||
return
|
||||
|
||||
if(stat & (BROKEN|NOPOWER))
|
||||
return
|
||||
|
||||
. = TRUE
|
||||
|
||||
switch(action)
|
||||
if("refresh")
|
||||
refresh()
|
||||
|
||||
if("view")
|
||||
var/newuid = params["view"]
|
||||
for(var/obj/machinery/power/supermatter_shard/S in supermatters)
|
||||
if(S.UID() == newuid)
|
||||
active = S
|
||||
break
|
||||
|
||||
if("back")
|
||||
active = null
|
||||
|
||||
@@ -272,6 +272,16 @@
|
||||
build_path = /obj/item/circuitboard/solar_control
|
||||
category = list("Computer Boards")
|
||||
|
||||
/datum/design/sm_monitor
|
||||
name = "Console Board (Supermatter Monitoring)"
|
||||
desc = "Allows for the construction of circuit boards used to build a supermatter monitoring console"
|
||||
id = "sm_monitor"
|
||||
req_tech = list("programming" = 2, "powerstorage" = 2)
|
||||
build_type = IMPRINTER
|
||||
materials = list(MAT_GLASS = 1000)
|
||||
build_path = /obj/item/circuitboard/sm_monitor
|
||||
category = list("Computer Boards")
|
||||
|
||||
/datum/design/spacepodlocator
|
||||
name = "Console Board (Spacepod Locator)"
|
||||
desc = "Allows for the construction of circuit boards used to build a space-pod locating console"
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 51 KiB After Width: | Height: | Size: 51 KiB |
@@ -733,6 +733,7 @@
|
||||
#include "code\game\machinery\computer\salvage_ship.dm"
|
||||
#include "code\game\machinery\computer\security.dm"
|
||||
#include "code\game\machinery\computer\skills.dm"
|
||||
#include "code\game\machinery\computer\sm_monitor.dm"
|
||||
#include "code\game\machinery\computer\specops_shuttle.dm"
|
||||
#include "code\game\machinery\computer\station_alert.dm"
|
||||
#include "code\game\machinery\computer\store.dm"
|
||||
|
||||
@@ -0,0 +1,157 @@
|
||||
import { Fragment } from 'inferno';
|
||||
import { useBackend } from '../backend';
|
||||
import { Section, Box, Button, Table, LabeledList, ProgressBar } from '../components';
|
||||
import { Window } from '../layouts';
|
||||
import { TableRow, TableCell } from '../components/Table';
|
||||
|
||||
export const SupermatterMonitor = (props, context) => {
|
||||
const { act, data } = useBackend(context);
|
||||
if (data.active === 0) {
|
||||
return <SupermatterMonitorListView />;
|
||||
} else {
|
||||
return <SupermatterMonitorDataView />;
|
||||
}
|
||||
};
|
||||
|
||||
const powerToColor = power => {
|
||||
if (power > 300) {
|
||||
return 'bad';
|
||||
} else if (power > 150) {
|
||||
return 'average';
|
||||
} else {
|
||||
return 'good';
|
||||
}
|
||||
};
|
||||
|
||||
const temperatureToColor = temp => {
|
||||
if (temp > 5000) {
|
||||
return 'bad';
|
||||
} else if (temp > 4000) {
|
||||
return 'average';
|
||||
} else {
|
||||
return 'good';
|
||||
}
|
||||
};
|
||||
|
||||
const pressureToColor = pressure => {
|
||||
if (pressure > 10000) {
|
||||
return 'bad';
|
||||
} else if (pressure > 5000) {
|
||||
return 'average';
|
||||
} else {
|
||||
return 'good';
|
||||
}
|
||||
};
|
||||
|
||||
const SupermatterMonitorListView = (props, context) => {
|
||||
const { act, data } = useBackend(context);
|
||||
return (
|
||||
<Window>
|
||||
<Window.Content scrollable>
|
||||
<Section title="Detected Supermatter Shards" buttons={
|
||||
<Button
|
||||
icon="sync"
|
||||
content="Refresh"
|
||||
onClick={() => act("refresh")}
|
||||
/>
|
||||
}>
|
||||
<Box m={1}>
|
||||
{data.supermatters.length === 0 ? (
|
||||
<h3>No shards detected</h3>
|
||||
) : (
|
||||
<Table>
|
||||
<Table.Row header>
|
||||
<TableCell>Area</TableCell>
|
||||
<TableCell>Integrity</TableCell>
|
||||
<TableCell>Details</TableCell>
|
||||
</Table.Row>
|
||||
{data.supermatters.map(sm => (
|
||||
<TableRow key={sm}>
|
||||
<TableCell>{sm.area_name}</TableCell>
|
||||
<TableCell>{sm.integrity}%</TableCell>
|
||||
<TableCell>
|
||||
<Button
|
||||
icon="sign-in-alt"
|
||||
content="View"
|
||||
onClick={() => act('view', {
|
||||
view: sm.uid,
|
||||
})}
|
||||
/>
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
))}
|
||||
</Table>
|
||||
)}
|
||||
</Box>
|
||||
</Section>
|
||||
</Window.Content>
|
||||
</Window>
|
||||
);
|
||||
};
|
||||
|
||||
const SupermatterMonitorDataView = (props, context) => {
|
||||
const { act, data } = useBackend(context);
|
||||
return (
|
||||
<Window>
|
||||
<Window.Content>
|
||||
<Section title="Crystal Status" buttons={
|
||||
<Button
|
||||
icon="caret-square-left"
|
||||
content="Back"
|
||||
onClick={() => act("back")}
|
||||
/>
|
||||
}>
|
||||
<LabeledList>
|
||||
<LabeledList.Item label="Core Integrity">
|
||||
<ProgressBar
|
||||
ranges={{
|
||||
good: [95, Infinity],
|
||||
average: [80, 94],
|
||||
bad: [-Infinity, 79],
|
||||
}}
|
||||
minValue="0"
|
||||
maxValue="100"
|
||||
value={data.SM_integrity}>
|
||||
{data.SM_integrity}%
|
||||
</ProgressBar>
|
||||
</LabeledList.Item>
|
||||
<LabeledList.Item label="Relative EER">
|
||||
<Box color={powerToColor(data.SM_power)}>
|
||||
{data.SM_power} MeV/cm3
|
||||
</Box>
|
||||
</LabeledList.Item>
|
||||
<LabeledList.Item label="Temperature">
|
||||
<Box color={temperatureToColor(data.SM_ambienttemp)}>
|
||||
{data.SM_ambienttemp} K
|
||||
</Box>
|
||||
</LabeledList.Item>
|
||||
<LabeledList.Item label="Pressure">
|
||||
<Box color={pressureToColor(data.SM_ambientpressure)}>
|
||||
{data.SM_ambientpressure} kPa
|
||||
</Box>
|
||||
</LabeledList.Item>
|
||||
</LabeledList>
|
||||
</Section>
|
||||
<Section title="Gas Composition">
|
||||
<LabeledList>
|
||||
<LabeledList.Item label="Oxygen">
|
||||
{data.SM_gas_O2}%
|
||||
</LabeledList.Item>
|
||||
<LabeledList.Item label="Carbon Dioxide">
|
||||
{data.SM_gas_CO2}%
|
||||
</LabeledList.Item>
|
||||
<LabeledList.Item label="Nitrogen">
|
||||
{data.SM_gas_N2}%
|
||||
</LabeledList.Item>
|
||||
<LabeledList.Item label="Plasma">
|
||||
{data.SM_gas_PL}%
|
||||
</LabeledList.Item>
|
||||
<LabeledList.Item label="Other">
|
||||
{data.SM_gas_OTHER}%
|
||||
</LabeledList.Item>
|
||||
</LabeledList>
|
||||
</Section>
|
||||
</Window.Content>
|
||||
</Window>
|
||||
);
|
||||
};
|
||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user