Skip to content

Commit

Permalink
[MIRROR] New views for mc controller ui (#2142)
Browse files Browse the repository at this point in the history
* New views for mc controller ui (#82769)

## About The Pull Request
Lots of qol improvements for controller tgui

- Auto sort order based on type
- Bar view for items in deciseconds

<details>
<summary>vids</summary>

in a live round

![image](https://github.com/tgstation/tgstation/assets/42397676/52fd4677-763a-4ea9-965a-386ab59cd353)

modals

![Tzp0i9yfwP](https://github.com/tgstation/tgstation/assets/42397676/06ca6d9e-c528-4f02-8dbb-d302d2380396)

bar view with defaults for decisecond sorts

![2X6IqQIE7c](https://github.com/tgstation/tgstation/assets/42397676/88b80fd4-1116-4ba1-aa0b-6bac56827e6b)

</details>

## Why It's Good For The Game
Better admin tools
## Changelog
:cl:
add: Admin tools buffed, check the Controller Overview
add: Controller Overview moved to debug tab
/:cl:

* New views for mc controller ui

---------

Co-authored-by: Jeremiah <[email protected]>
  • Loading branch information
2 people authored and StealsThePRs committed Apr 23, 2024
1 parent df3285b commit 8cb5f8c
Show file tree
Hide file tree
Showing 10 changed files with 621 additions and 246 deletions.
2 changes: 1 addition & 1 deletion code/controllers/master.dm
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ GLOBAL_REAL(Master, /datum/controller/master)
ss.Shutdown()
log_world("Shutdown complete")

ADMIN_VERB(cmd_controller_view_ui, R_SERVER|R_DEBUG, "Controller Overview", "View the current states of the Subsystem Controllers.", ADMIN_CATEGORY_SERVER)
ADMIN_VERB(cmd_controller_view_ui, R_SERVER|R_DEBUG, "Controller Overview", "View the current states of the Subsystem Controllers.", ADMIN_CATEGORY_DEBUG)
Master.ui_interact(user.mob)

/datum/controller/master/ui_status(mob/user, datum/ui_state/state)
Expand Down
245 changes: 0 additions & 245 deletions tgui/packages/tgui/interfaces/ControllerOverview.tsx

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import { useBackend } from '../../backend';
import { Button, LabeledList, Section, Stack } from '../../components';
import { ControllerData } from './types';

export function OverviewSection(props) {
const { act, data } = useBackend<ControllerData>();
const { fast_update, map_cpu, subsystems = [], world_time } = data;

let overallUsage = 0;
let overallOverrun = 0;
for (let i = 0; i < subsystems.length; i++) {
overallUsage += subsystems[i].tick_usage;
overallOverrun += subsystems[i].tick_overrun;
}

return (
<Section
fill
title="Master Overview"
buttons={
<Button
tooltip="Fast Update"
icon={fast_update ? 'check-square-o' : 'square-o'}
color={fast_update && 'average'}
onClick={() => {
act('toggle_fast_update');
}}
>
Fast
</Button>
}
>
<Stack fill>
<Stack.Item grow>
<LabeledList>
<LabeledList.Item label="World Time">
{world_time.toFixed(1)}
</LabeledList.Item>
<LabeledList.Item label="Map CPU">
{map_cpu.toFixed(2)}%
</LabeledList.Item>
</LabeledList>
</Stack.Item>
<Stack.Item grow>
<LabeledList>
<LabeledList.Item label="Overall Usage">
{(overallUsage * 0.01).toFixed(2)}%
</LabeledList.Item>
<LabeledList.Item label="Overall Overrun">
{(overallOverrun * 0.01).toFixed(2)}%
</LabeledList.Item>
</LabeledList>
</Stack.Item>
</Stack>
</Section>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
import {
Box,
Button,
Divider,
LabeledList,
Modal,
Stack,
} from '../../components';
import { SubsystemData } from './types';

type Props = {
subsystem: SubsystemData;
onClose: () => void;
};

export function SubsystemDialog(props: Props) {
const { subsystem, onClose } = props;
const {
cost_ms,
init_order,
initialization_failure_message,
last_fire,
name,
next_fire,
tick_overrun,
tick_usage,
} = subsystem;

return (
<Modal width="85%" ml={7}>
<Stack fill>
<Stack.Item grow fontSize="22px">
{name}
</Stack.Item>
<Stack.Item>
<Button color="bad" icon="times" onClick={onClose} />
</Stack.Item>
</Stack>
<Divider />
<Box p={1}>
<LabeledList>
<LabeledList.Item label="Init Order">{init_order}</LabeledList.Item>
<LabeledList.Item label="Last Fire">{last_fire}</LabeledList.Item>
<LabeledList.Item label="Next Fire">{next_fire}</LabeledList.Item>
<LabeledList.Item label="Cost">{cost_ms}ms</LabeledList.Item>
<LabeledList.Item label="Tick Usage">
{(tick_usage * 0.01).toFixed(2)}%
</LabeledList.Item>
<LabeledList.Item label="Tick Overrun">
{(tick_overrun * 0.01).toFixed(2)}%
</LabeledList.Item>
{initialization_failure_message && (
<LabeledList.Item color="bad">
{initialization_failure_message}
</LabeledList.Item>
)}
</LabeledList>
</Box>
<Stack fill justify="space-between">
<Stack.Item />
<Stack.Item>
<Button color="good" onClick={onClose} px={3} py={1}>
Close
</Button>
</Stack.Item>
</Stack>
</Modal>
);
}
Loading

0 comments on commit 8cb5f8c

Please sign in to comment.