Skip to content

Commit

Permalink
TSXify shuttle manipulator again
Browse files Browse the repository at this point in the history
  • Loading branch information
Drulikar committed May 16, 2024
1 parent 025762c commit 5c89310
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 10 deletions.
6 changes: 3 additions & 3 deletions code/controllers/subsystem/shuttles.dm
Original file line number Diff line number Diff line change
Expand Up @@ -569,14 +569,14 @@ SUBSYSTEM_DEF(shuttle)
// Templates panel
data["templates"] = list()
var/list/templates = data["templates"]
data["templates_tabs"] = list()
//data["templates_tabs"] = list()
data["selected"] = null

for(var/id in SSmapping.shuttle_templates)
var/datum/map_template/shuttle/S = SSmapping.shuttle_templates[id]

if(!templates[S.port_id])
data["templates_tabs"] += S.port_id
//data["templates_tabs"] += S.port_id
templates[S.port_id] = list(
"port_id" = S.port_id,
"templates" = list())
Expand All @@ -593,7 +593,7 @@ SUBSYSTEM_DEF(shuttle)

templates[S.port_id]["templates"] += list(L)

data["templates_tabs"] = sort_list(data["templates_tabs"])
//data["templates_tabs"] = sort_list(data["templates_tabs"])

data["existing_shuttle"] = null

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,39 @@ import { useBackend } from '../backend';
import { Button, Flex, LabeledList, Section, Table, Tabs } from '../components';
import { Window } from '../layouts';

interface ShuttleData {
name: string;
id: string;
timer: string;
timeleft: string;
can_fast_travel: 0 | 1;
can_fly: 0 | 1;
mode: string;
status: string;
is_disabled: 0 | 1;
has_disable: 0 | 1;
}

interface ShuttleTemplate {
name: string;
id: string;
port_id: string;
description: string;
admin_notes: string;
}

interface TemplateGroup {
port_id: string;
templates: Array<ShuttleTemplate>;
}

interface ShuttleManipulatorData {
shuttles: Array<ShuttleData>;
templates: Record<string, TemplateGroup>;
selected?: ShuttleTemplate;
existing_shuttle?: ShuttleData;
}

export const ShuttleManipulator = (props) => {
const [tab, setTab] = useState(1);

Expand All @@ -31,8 +64,8 @@ export const ShuttleManipulator = (props) => {
};

export const ShuttleManipulatorStatus = (props) => {
const { act, data } = useBackend();
const shuttles = data.shuttles || [];
const { act, data } = useBackend<ShuttleManipulatorData>();
const shuttles = data.shuttles ?? [];
return (
<Section>
<Table>
Expand Down Expand Up @@ -112,9 +145,9 @@ export const ShuttleManipulatorStatus = (props) => {
};

export const ShuttleManipulatorTemplates = (props) => {
const { act, data } = useBackend();
const templateObject = data.templates || {};
const selected = data.selected || {};
const { act, data } = useBackend<ShuttleManipulatorData>();
const templateObject = data.templates;
const selected = data.selected;
const [selectedTemplateId, setSelectedTemplateId] = useState(
Object.keys(templateObject)[0],
);
Expand All @@ -138,7 +171,7 @@ export const ShuttleManipulatorTemplates = (props) => {
</Flex.Item>
<Flex.Item grow basis={0} ml={2}>
{actualTemplates.map((actualTemplate) => {
const isSelected = actualTemplate.id === selected.id;
const isSelected = actualTemplate.id === selected?.id;
return (
<Section
title={actualTemplate.name}
Expand Down Expand Up @@ -182,7 +215,7 @@ export const ShuttleManipulatorTemplates = (props) => {
};

export const ShuttleManipulatorModification = (props) => {
const { act, data } = useBackend();
const { act, data } = useBackend<ShuttleManipulatorData>();
const selected = data.selected;
const existingShuttle = data.existing_shuttle;
return (
Expand Down

0 comments on commit 5c89310

Please sign in to comment.