mirror of
https://github.com/Citadel-Station-13/Citadel-Station-13.git
synced 2026-08-30 20:36:48 +01:00
update
This commit is contained in:
@@ -1,59 +0,0 @@
|
||||
|
||||
/**
|
||||
* /datum/tgui_module stuff
|
||||
* Citadel in house
|
||||
* Suffer.
|
||||
*
|
||||
* Basically, how this works, is we inject the module's
|
||||
* id, ref, data, and act into context, fetched with useModule().
|
||||
*
|
||||
* id: The tgui's module id from props; obviously must be unique
|
||||
* module: The tgui module's interface name
|
||||
* ref: The tgui_module's datum ref
|
||||
* data: The module's data passed into data.modules
|
||||
* act: A pre-built act function that automatically routes to the right datum procs.
|
||||
*
|
||||
* You should use the provided act instead of the one from useBackend().
|
||||
* useBackend() still works fine to grab the overall non-module context.
|
||||
*
|
||||
* @file
|
||||
* @license MIT
|
||||
*/
|
||||
|
||||
import React, { Component, createContext } from "react";
|
||||
|
||||
import { useBackend } from "../backend";
|
||||
import { getComponentForRoute } from "../routes";
|
||||
import { SectionProps } from ".";
|
||||
|
||||
export const LegacyModuleContext = createContext<{
|
||||
isModule: boolean;
|
||||
moduleId: string | null;
|
||||
moduleSection: SectionProps | null;
|
||||
}>({
|
||||
isModule: false,
|
||||
moduleId: null,
|
||||
moduleSection: null,
|
||||
});
|
||||
|
||||
export interface ModuleProps {
|
||||
id: string;
|
||||
section?: SectionProps;
|
||||
}
|
||||
|
||||
// eslint-disable-next-line react/prefer-stateless-function
|
||||
export class LegacyModule<T extends ModuleProps, S = {}> extends Component<T, S> {
|
||||
render() {
|
||||
const moduleData = useBackend().nestedData[this.props.id as string];
|
||||
const RoutedComponent = getComponentForRoute(moduleData["$tgui"]);
|
||||
return (
|
||||
<LegacyModuleContext value={{
|
||||
isModule: true,
|
||||
moduleId: this.props.id,
|
||||
moduleSection: this.props.section || null,
|
||||
}}>
|
||||
<RoutedComponent />
|
||||
</LegacyModuleContext>
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
import { toFixed } from 'common/math';
|
||||
import { toFixed } from 'tgui-core/math';
|
||||
import { Fragment } from 'react';
|
||||
import { useBackend, useLocalState } from '../backend';
|
||||
import { Box, Button, LabeledList, Section } from 'tgui-core/components';
|
||||
@@ -73,12 +73,12 @@ const AirAlarmStatus = (props) => {
|
||||
</LabeledList.Item>
|
||||
</>
|
||||
) || (
|
||||
<LabeledList.Item
|
||||
label="Warning"
|
||||
color="bad">
|
||||
Cannot obtain air sample for analysis.
|
||||
</LabeledList.Item>
|
||||
)}
|
||||
<LabeledList.Item
|
||||
label="Warning"
|
||||
color="bad">
|
||||
Cannot obtain air sample for analysis.
|
||||
</LabeledList.Item>
|
||||
)}
|
||||
{!!data.emagged && (
|
||||
<LabeledList.Item
|
||||
label="Warning"
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
* @license MIT
|
||||
*/
|
||||
|
||||
import { clamp01 } from 'common/math';
|
||||
import { clamp01 } from 'tgui-core/math';
|
||||
import { useBackend } from '../backend';
|
||||
import { Component, createRef } from 'react';
|
||||
import { Box, Flex, Section } from 'tgui-core/components';
|
||||
@@ -26,7 +26,7 @@ export class AlertModal extends Component {
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
const { data } = useBackend(this.context);
|
||||
const { data } = useBackend<any>();
|
||||
const { buttons, autofocus } = data;
|
||||
const { current } = this.state;
|
||||
const button = this.buttonRefs[current].current;
|
||||
@@ -42,7 +42,7 @@ export class AlertModal extends Component {
|
||||
}
|
||||
|
||||
setCurrent(current, isArrowKey) {
|
||||
const { data } = useBackend(this.context);
|
||||
const { data } = useBackend<any>();
|
||||
const { buttons } = data;
|
||||
|
||||
// Mimic alert() behavior for tabs and arrow keys
|
||||
@@ -62,7 +62,7 @@ export class AlertModal extends Component {
|
||||
}
|
||||
|
||||
render() {
|
||||
const { act, data } = useBackend(this.context);
|
||||
const { act, data } = useBackend<any>();
|
||||
const { title, message, buttons, timeout } = data;
|
||||
const { current } = this.state;
|
||||
const focusCurrentButton = () => this.setCurrent(current, false);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { map } from 'common/collections';
|
||||
import { toFixed } from 'common/math';
|
||||
import { toFixed } from 'tgui-core/math';
|
||||
import { useBackend } from '../backend';
|
||||
import { Button, LabeledList, NumberInput, Section } from 'tgui-core/components';
|
||||
import { Window } from '../layouts';
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { filter, sortBy } from 'common/collections';
|
||||
import { flow } from 'common/fp';
|
||||
import { toFixed } from 'common/math';
|
||||
import { toFixed } from 'tgui-core/math';
|
||||
import { useBackend } from '../backend';
|
||||
import { Button, Divider, LabeledList, NumberInput, ProgressBar, Section, Stack, Box, AnimatedNumber } from 'tgui-core/components';
|
||||
import { getGasColor, getGasLabel } from '../constants';
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { filter, sortBy } from 'common/collections';
|
||||
import { flow } from 'common/fp';
|
||||
import { toFixed } from 'common/math';
|
||||
import { toFixed } from 'tgui-core/math';
|
||||
import { multiline } from 'tgui-core/string';
|
||||
import { useBackend } from '../backend';
|
||||
import { Button, Divider, LabeledList, NumberInput, ProgressBar, Section, Stack, Box } from 'tgui-core/components';
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { toFixed } from 'common/math';
|
||||
import { toFixed } from 'tgui-core/math';
|
||||
import { useBackend } from '../backend';
|
||||
import { Box, Button, Flex, Icon, Knob, LabeledControls, LabeledList, RoundGauge, Section, Tooltip } from 'tgui-core/components';
|
||||
import { formatSiUnit } from 'tgui-core/format';
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { toFixed } from 'common/math';
|
||||
import { toFixed } from 'tgui-core/math';
|
||||
import { classes } from 'common/react';
|
||||
import { storage } from 'common/storage';
|
||||
import { multiline } from 'tgui-core/string';
|
||||
@@ -757,7 +757,7 @@ class PresetsPage extends Component {
|
||||
}
|
||||
|
||||
async loadDataFromPreset(id, context) {
|
||||
const { act } = useBackend(this.context);
|
||||
const { act } = useBackend<any>();
|
||||
act("loadDataFromPreset", {
|
||||
payload: await storage.get("podlauncher_preset_" + id),
|
||||
});
|
||||
@@ -795,7 +795,7 @@ class PresetsPage extends Component {
|
||||
}
|
||||
render() {
|
||||
const { presets } = this.state;
|
||||
const { act, data } = useBackend(this.context);
|
||||
const { act, data } = useBackend<any>();
|
||||
const [
|
||||
presetIndex,
|
||||
setSelectedPreset,
|
||||
|
||||
@@ -63,7 +63,7 @@ export class Changelog extends Component {
|
||||
}
|
||||
|
||||
getData = (date, attemptNumber = 1) => {
|
||||
const { act } = useBackend(this.context);
|
||||
const { act } = useBackend<any>();
|
||||
const self = this;
|
||||
const maxAttempts = 6;
|
||||
|
||||
@@ -94,7 +94,7 @@ export class Changelog extends Component {
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
const { data: { dates = [] } } = useBackend(this.context);
|
||||
const { data: { dates = [] } } = useBackend<any>();
|
||||
|
||||
if (dates) {
|
||||
dates.forEach(
|
||||
@@ -107,7 +107,7 @@ export class Changelog extends Component {
|
||||
|
||||
render() {
|
||||
const { data, selectedDate, selectedIndex } = this.state;
|
||||
const { data: { dates } } = useBackend(this.context);
|
||||
const { data: { dates } } = useBackend<any>();
|
||||
const { dateChoices } = this;
|
||||
|
||||
const dateDropdown = dateChoices.length > 0 && (
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { toFixed } from 'common/math';
|
||||
import { toFixed } from 'tgui-core/math';
|
||||
import { toTitleCase } from 'tgui-core/string';
|
||||
import { Fragment } from 'react';
|
||||
import { useBackend, useLocalState } from '../backend';
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { round, toFixed } from 'common/math';
|
||||
import { round, toFixed } from 'tgui-core/math';
|
||||
import { Fragment } from 'react';
|
||||
import { useBackend } from '../backend';
|
||||
import { AnimatedNumber, Box, Button, LabeledList, NumberInput, Section } from 'tgui-core/components';
|
||||
@@ -20,7 +20,7 @@ export const ChemHeater = (props) => {
|
||||
<Window
|
||||
width={300}
|
||||
height={320}
|
||||
>
|
||||
>
|
||||
<Window.Content scrollable>
|
||||
<Section
|
||||
title="Thermostat"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { round } from 'common/math';
|
||||
import { round } from 'tgui-core/math';
|
||||
import { useBackend } from '../backend';
|
||||
import { AnimatedNumber, Box, Button, Flex, LabeledList, NumberInput, ProgressBar, RoundGauge, Section, Table } from 'tgui-core/components';
|
||||
import { Window } from '../layouts';
|
||||
@@ -60,14 +60,14 @@ export const ChemRecipeDebug = (props) => {
|
||||
{processAll && (
|
||||
<Box>All</Box>
|
||||
) || (
|
||||
<Box>
|
||||
{queuedReactions.length && (
|
||||
queuedReactions.map(entry => (
|
||||
entry.name+", "
|
||||
))
|
||||
)}
|
||||
</Box>
|
||||
)}
|
||||
<Box>
|
||||
{queuedReactions.length && (
|
||||
queuedReactions.map(entry => (
|
||||
entry.name + ", "
|
||||
))
|
||||
)}
|
||||
</Box>
|
||||
)}
|
||||
</LabeledList.Item>
|
||||
<LabeledList.Item label="Temp">
|
||||
{currentTemp}K
|
||||
@@ -231,61 +231,61 @@ export const ChemRecipeDebug = (props) => {
|
||||
No active reactions.
|
||||
</Box>
|
||||
) || (
|
||||
<Table>
|
||||
<Table.Row>
|
||||
<Table.Cell bold color="label">
|
||||
Reaction
|
||||
</Table.Cell>
|
||||
<Table.Cell bold color="label">
|
||||
{"Reaction quality"}
|
||||
</Table.Cell>
|
||||
<Table.Cell bold color="label">
|
||||
Target
|
||||
</Table.Cell>
|
||||
</Table.Row>
|
||||
{activeReactions && activeReactions.map(reaction => (
|
||||
<Table.Row key="reactions">
|
||||
<Table.Cell width={'60px'} color={reaction.danger && "red"}>
|
||||
{reaction.name}
|
||||
<Table>
|
||||
<Table.Row>
|
||||
<Table.Cell bold color="label">
|
||||
Reaction
|
||||
</Table.Cell>
|
||||
<Table.Cell width={'100px'} pr={'10px'}>
|
||||
<AnimatedNumber value={reaction.quality}>
|
||||
{(_, value) => (
|
||||
<RoundGauge
|
||||
size={1.30}
|
||||
value={value}
|
||||
minValue={0}
|
||||
maxValue={1}
|
||||
alertAfter={reaction.purityAlert}
|
||||
content={"test"}
|
||||
format={value => null}
|
||||
ml={5}
|
||||
ranges={{
|
||||
"red": [0, reaction.minPure],
|
||||
"orange": [reaction.minPure, reaction.inverse],
|
||||
"yellow": [reaction.inverse, 0.8],
|
||||
"green": [0.8, 1],
|
||||
}} />
|
||||
)}
|
||||
</AnimatedNumber>
|
||||
<Table.Cell bold color="label">
|
||||
{"Reaction quality"}
|
||||
</Table.Cell>
|
||||
<Table.Cell width={'70px'}>
|
||||
<ProgressBar
|
||||
value={reaction.reactedVol}
|
||||
minValue={0}
|
||||
maxValue={reaction.targetVol}
|
||||
textAlign={'center'}
|
||||
icon={reaction.overheat && "thermometer-full"}
|
||||
width={7}
|
||||
color={reaction.overheat ? "red" : "label"}>
|
||||
{reaction.targetVol}u
|
||||
</ProgressBar>
|
||||
<Table.Cell bold color="label">
|
||||
Target
|
||||
</Table.Cell>
|
||||
</Table.Row>
|
||||
))}
|
||||
<Table.Row />
|
||||
</Table>
|
||||
)}
|
||||
{activeReactions && activeReactions.map(reaction => (
|
||||
<Table.Row key="reactions">
|
||||
<Table.Cell width={'60px'} color={reaction.danger && "red"}>
|
||||
{reaction.name}
|
||||
</Table.Cell>
|
||||
<Table.Cell width={'100px'} pr={'10px'}>
|
||||
<AnimatedNumber value={reaction.quality}>
|
||||
{(_, value) => (
|
||||
<RoundGauge
|
||||
size={1.30}
|
||||
value={value}
|
||||
minValue={0}
|
||||
maxValue={1}
|
||||
alertAfter={reaction.purityAlert}
|
||||
content={"test"}
|
||||
format={value => null}
|
||||
ml={5}
|
||||
ranges={{
|
||||
"red": [0, reaction.minPure],
|
||||
"orange": [reaction.minPure, reaction.inverse],
|
||||
"yellow": [reaction.inverse, 0.8],
|
||||
"green": [0.8, 1],
|
||||
}} />
|
||||
)}
|
||||
</AnimatedNumber>
|
||||
</Table.Cell>
|
||||
<Table.Cell width={'70px'}>
|
||||
<ProgressBar
|
||||
value={reaction.reactedVol}
|
||||
minValue={0}
|
||||
maxValue={reaction.targetVol}
|
||||
textAlign={'center'}
|
||||
icon={reaction.overheat && "thermometer-full"}
|
||||
width={7}
|
||||
color={reaction.overheat ? "red" : "label"}>
|
||||
{reaction.targetVol}u
|
||||
</ProgressBar>
|
||||
</Table.Cell>
|
||||
</Table.Row>
|
||||
))}
|
||||
<Table.Row />
|
||||
</Table>
|
||||
)}
|
||||
</Section>
|
||||
<Section
|
||||
title="Chamber"
|
||||
@@ -294,15 +294,15 @@ export const ChemRecipeDebug = (props) => {
|
||||
{isActive ? "Reacting" : "Waiting"}
|
||||
</Box>
|
||||
)} >
|
||||
{chamberContents.length &&(
|
||||
{chamberContents.length && (
|
||||
<BeakerContents
|
||||
beakerLoaded
|
||||
beakerContents={chamberContents} />
|
||||
) || (
|
||||
<Box>
|
||||
Nothing
|
||||
</Box>
|
||||
)}
|
||||
<Box>
|
||||
Nothing
|
||||
</Box>
|
||||
)}
|
||||
</Section>
|
||||
</Window.Content>
|
||||
</Window>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { toFixed } from 'common/math';
|
||||
import { toFixed } from 'tgui-core/math';
|
||||
import { useBackend } from '../backend';
|
||||
import { LabeledList, NumberInput, Section } from 'tgui-core/components';
|
||||
import { Window } from '../layouts';
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { toFixed } from 'common/math';
|
||||
import { toFixed } from 'tgui-core/math';
|
||||
import { useBackend } from '../backend';
|
||||
import { Box, Button, Section } from 'tgui-core/components';
|
||||
import { Window } from '../layouts';
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { useBackend } from '../backend';
|
||||
import { AnimatedNumber, Button, Flex, Input, LabeledList, ProgressBar, Section, Table, NumberInput, Box } from 'tgui-core/components';
|
||||
import { getGasColor, getGasLabel } from '../constants';
|
||||
import { toFixed } from 'common/math';
|
||||
import { toFixed } from 'tgui-core/math';
|
||||
import { Window } from '../layouts';
|
||||
|
||||
const logScale = value => Math.log2(16 + Math.max(0, value)) - 4;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { toFixed } from 'common/math';
|
||||
import { toFixed } from 'tgui-core/math';
|
||||
import { useBackend } from '../backend';
|
||||
import { AnimatedNumber, Box, Button, LabeledList, NoticeBox, Section } from 'tgui-core/components';
|
||||
import { Window } from '../layouts';
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import { map } from 'common/collections';
|
||||
import { toFixed } from 'common/math';
|
||||
import { numberOfDecimalDigits } from '../../common/math';
|
||||
import { numberOfDecimalDigits, toFixed, } from 'tgui-core/math';
|
||||
import { useBackend, useLocalState } from '../backend';
|
||||
import { Box, Button, Collapsible, ColorBox, Dropdown, Input, LabeledList, NoticeBox, NumberInput, Section } from 'tgui-core/components';
|
||||
import { Window } from '../layouts';
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { map, sortBy } from 'common/collections';
|
||||
import { flow } from 'common/fp';
|
||||
import { clamp } from 'common/math';
|
||||
import { clamp } from 'tgui-core/math';
|
||||
import { vecLength, vecSubtract } from 'common/vector';
|
||||
import { useBackend } from '../backend';
|
||||
import { Box, Button, Icon, LabeledList, Section, Table } from 'tgui-core/components';
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { filter, sortBy } from 'common/collections';
|
||||
import { flow } from 'common/fp';
|
||||
import { toFixed } from 'common/math';
|
||||
import { toFixed } from 'tgui-core/math';
|
||||
import { useBackend } from '../backend';
|
||||
import { Button, LabeledList, NumberInput, ProgressBar, Section, Stack, Box } from 'tgui-core/components';
|
||||
import { getGasColor, getGasLabel } from '../constants';
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
import { classes } from 'tgui-core/react';
|
||||
import { CSS_COLORS } from '../../constants';
|
||||
import { SVG_CURVE_INTENSITY } from './constants';
|
||||
import { classes } from '../../../common/react';
|
||||
|
||||
export const Connections = (props) => {
|
||||
const { connections } = props;
|
||||
|
||||
const isColorClass = (str) => {
|
||||
if (typeof str === 'string') {
|
||||
return CSS_COLORS.includes(str);
|
||||
return CSS_COLORS.includes(str as any);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -17,7 +17,6 @@ export const Connections = (props) => {
|
||||
height="100%"
|
||||
style={{
|
||||
'position': 'absolute',
|
||||
'pointer-events': 'none',
|
||||
'z-index': -1,
|
||||
}}>
|
||||
{connections.map((val, index) => {
|
||||
|
||||
@@ -4,14 +4,14 @@ import {
|
||||
Stack, Button, Dropdown,
|
||||
} from 'tgui-core/components';
|
||||
import { Component } from 'react';
|
||||
import { shallowDiffers } from '../../../common/react';
|
||||
import { ABSOLUTE_Y_OFFSET } from './constants';
|
||||
import { Port } from "./Port";
|
||||
import { shallowDiffers } from 'tgui-core/react';
|
||||
|
||||
|
||||
export class ObjectComponent extends Component {
|
||||
constructor() {
|
||||
super();
|
||||
export class ObjectComponent extends Component<any, any> {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
this.state = {
|
||||
isDragging: false,
|
||||
dragPos: null,
|
||||
@@ -38,7 +38,7 @@ export class ObjectComponent extends Component {
|
||||
}
|
||||
|
||||
handleStopDrag(e) {
|
||||
const { act } = useBackend(this.context);
|
||||
const { act } = useBackend<any>();
|
||||
const { dragPos } = this.state;
|
||||
const { index } = this.props;
|
||||
if (dragPos) {
|
||||
@@ -104,7 +104,7 @@ export class ObjectComponent extends Component {
|
||||
onPortMouseUp,
|
||||
...rest
|
||||
} = this.props;
|
||||
const { act } = useBackend(this.context);
|
||||
const { act } = useBackend<any>();
|
||||
const { startPos, dragPos } = this.state;
|
||||
|
||||
let [x_pos, y_pos] = [x, y];
|
||||
|
||||
@@ -6,9 +6,11 @@ import { Component, createRef } from 'react';
|
||||
import { DisplayName } from "./DisplayName";
|
||||
|
||||
|
||||
export class Port extends Component {
|
||||
constructor() {
|
||||
super();
|
||||
export class Port extends Component<any, any> {
|
||||
iconRef: any;
|
||||
|
||||
constructor(props) {
|
||||
super(props);
|
||||
this.iconRef = createRef();
|
||||
this.componentDidUpdate = this.componentDidUpdate.bind(this);
|
||||
this.componentDidMount = this.componentDidMount.bind(this);
|
||||
|
||||
@@ -16,9 +16,9 @@ import { Connections } from './Connections';
|
||||
import { ObjectComponent } from './ObjectComponent';
|
||||
import { VariableMenu } from './VariableMenu';
|
||||
|
||||
export class IntegratedCircuit extends Component {
|
||||
constructor() {
|
||||
super();
|
||||
export class IntegratedCircuit extends Component<any, any> {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
this.state = {
|
||||
locations: {},
|
||||
selectedPort: null,
|
||||
@@ -106,7 +106,7 @@ export class IntegratedCircuit extends Component {
|
||||
// mouse up called whilst over a port. This means we can check if selectedPort
|
||||
// exists and do perform some actions if it does.
|
||||
handlePortUp(portIndex, componentId, port, isOutput, event) {
|
||||
const { act } = useBackend(this.context);
|
||||
const { act } = useBackend<any>();
|
||||
const {
|
||||
selectedPort,
|
||||
} = this.state;
|
||||
@@ -136,7 +136,7 @@ export class IntegratedCircuit extends Component {
|
||||
}
|
||||
|
||||
handlePortDrag(event) {
|
||||
const { data } = useBackend(this.context);
|
||||
const { data } = useBackend<any>();
|
||||
const { screen_x, screen_y } = data;
|
||||
this.setState((state) => ({
|
||||
mouseX: event.clientX - (state.backgroundX || screen_x),
|
||||
@@ -154,7 +154,7 @@ export class IntegratedCircuit extends Component {
|
||||
}
|
||||
|
||||
handlePortRightClick(portIndex, componentId, port, isOutput, event) {
|
||||
const { act } = useBackend(this.context);
|
||||
const { act } = useBackend<any>();
|
||||
|
||||
event.preventDefault();
|
||||
act('remove_connection', {
|
||||
@@ -193,7 +193,7 @@ export class IntegratedCircuit extends Component {
|
||||
}
|
||||
|
||||
handleMouseDown(event) {
|
||||
const { act, data } = useBackend(this.context);
|
||||
const { act, data } = useBackend<any>();
|
||||
const { examined_name } = data;
|
||||
if (examined_name) {
|
||||
act('remove_examined_component');
|
||||
@@ -201,7 +201,7 @@ export class IntegratedCircuit extends Component {
|
||||
}
|
||||
|
||||
handleMouseUp(event) {
|
||||
const { act } = useBackend(this.context);
|
||||
const { act } = useBackend<any>();
|
||||
const { backgroundX, backgroundY } = this.state;
|
||||
if (backgroundX && backgroundY) {
|
||||
act("move_screen", {
|
||||
@@ -212,7 +212,7 @@ export class IntegratedCircuit extends Component {
|
||||
}
|
||||
|
||||
render() {
|
||||
const { act, data } = useBackend(this.context);
|
||||
const { act, data } = useBackend<any>();
|
||||
const {
|
||||
components,
|
||||
display_name,
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
* @license MIT
|
||||
*/
|
||||
|
||||
import { clamp01 } from 'common/math';
|
||||
import { clamp01 } from 'tgui-core/math';
|
||||
import { useBackend, useLocalState } from '../backend';
|
||||
import { Box, Button, Section, Input, Stack } from 'tgui-core/components';
|
||||
import { KEY_DOWN, KEY_UP, KEY_ENTER, KEY_SPACE } from 'common/keycodes';
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { round } from 'common/math';
|
||||
import { round } from 'tgui-core/math';
|
||||
import { useBackend } from '../backend';
|
||||
import { Box, Button, Dimmer, Icon, Section, Slider, Table } from 'tgui-core/components';
|
||||
import { Window } from '../layouts';
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { filter, sortBy } from 'common/collections';
|
||||
import { flow } from 'common/fp';
|
||||
import { toFixed } from 'common/math';
|
||||
import { toFixed } from 'tgui-core/math';
|
||||
import { useBackend } from '../backend';
|
||||
import { LabeledList, ProgressBar, Section } from 'tgui-core/components';
|
||||
import { getGasColor, getGasLabel } from '../constants';
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { scale, toFixed } from 'common/math';
|
||||
import { scale, toFixed } from 'tgui-core/math';
|
||||
import { useBackend, useLocalState } from '../backend';
|
||||
import { Box, Button, Stack, Icon, LabeledList, NoticeBox, ProgressBar, Section, Tabs } from 'tgui-core/components';
|
||||
import { flow } from 'common/fp';
|
||||
@@ -147,35 +147,35 @@ const Program = (props) => {
|
||||
maxValue={program.size}
|
||||
value={downloadcompletion} />
|
||||
) || (
|
||||
(!program.installed
|
||||
&& program.compatible
|
||||
&& program.access
|
||||
&& program.size < disk_free) && (
|
||||
<Button
|
||||
bold
|
||||
icon="download"
|
||||
content="Download"
|
||||
disabled={downloading}
|
||||
tooltipPosition="left"
|
||||
tooltip={!!downloading && ('Awaiting download completion...')}
|
||||
onClick={() => act('PRG_downloadfile', {
|
||||
filename: program.filename,
|
||||
})} />
|
||||
) || (
|
||||
<Button
|
||||
bold
|
||||
icon={program.installed ? 'check' : 'times'}
|
||||
color={
|
||||
program.installed ? 'good'
|
||||
: !program.compatible ? 'bad' : 'grey'
|
||||
}
|
||||
content={
|
||||
program.installed ? 'Installed'
|
||||
: !program.compatible ? 'Incompatible'
|
||||
: !program.access ? 'No Access' : 'No Space'
|
||||
} />
|
||||
)
|
||||
)}
|
||||
(!program.installed
|
||||
&& program.compatible
|
||||
&& program.access
|
||||
&& program.size < disk_free) && (
|
||||
<Button
|
||||
bold
|
||||
icon="download"
|
||||
content="Download"
|
||||
disabled={downloading}
|
||||
tooltipPosition="left"
|
||||
tooltip={!!downloading && ('Awaiting download completion...')}
|
||||
onClick={() => act('PRG_downloadfile', {
|
||||
filename: program.filename,
|
||||
})} />
|
||||
) || (
|
||||
<Button
|
||||
bold
|
||||
icon={program.installed ? 'check' : 'times'}
|
||||
color={
|
||||
program.installed ? 'good'
|
||||
: !program.compatible ? 'bad' : 'grey'
|
||||
}
|
||||
content={
|
||||
program.installed ? 'Installed'
|
||||
: !program.compatible ? 'Incompatible'
|
||||
: !program.access ? 'No Access' : 'No Space'
|
||||
} />
|
||||
)
|
||||
)}
|
||||
</Stack.Item>
|
||||
</Stack>
|
||||
<Box mt={1} italic color="label">
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { map, sortBy } from 'common/collections';
|
||||
import { flow } from 'common/fp';
|
||||
import { toFixed } from 'common/math';
|
||||
import { toFixed } from 'tgui-core/math';
|
||||
import { pureComponentHooks } from 'common/react';
|
||||
import { Component, Fragment } from 'react';
|
||||
import { Box, Button, Chart, ColorBox, Flex, Icon, LabeledList, ProgressBar, Section, Table } from 'tgui-core/components';
|
||||
|
||||
@@ -15,7 +15,7 @@ import { marked } from 'marked';
|
||||
import { useBackend } from '../backend';
|
||||
import { Box, Flex, Tabs, TextArea } from 'tgui-core/components';
|
||||
import { Window } from '../layouts';
|
||||
import { clamp } from 'common/math';
|
||||
import { clamp } from 'tgui-core/math';
|
||||
import { sanitizeText } from '../sanitize';
|
||||
import katex from 'katex';
|
||||
|
||||
@@ -49,7 +49,7 @@ const textWidth = (text, font, fontsize) => {
|
||||
return width;
|
||||
};
|
||||
|
||||
const setFontinText = (text, font, color, bold=false) => {
|
||||
const setFontinText = (text, font, color, bold = false) => {
|
||||
return "<span style=\""
|
||||
+ "color:" + color + ";"
|
||||
+ "font-family:'" + font + "';"
|
||||
@@ -72,17 +72,17 @@ const sign_regex = /%s(?:ign)?(?=\\s|$)?/igm;
|
||||
const createInputField = (length, width, font,
|
||||
fontsize, color, id) => {
|
||||
return "[<input "
|
||||
+ "type=\"text\" "
|
||||
+ "style=\""
|
||||
+ "font:'" + fontsize + "x " + font + "';"
|
||||
+ "color:" + color + ";"
|
||||
+ "min-width:" + width + ";"
|
||||
+ "max-width:" + width + ";"
|
||||
+ "\" "
|
||||
+ "id=\"" + id + "\" "
|
||||
+ "maxlength=" + length +" "
|
||||
+ "size=" + length + " "
|
||||
+ "/>]";
|
||||
+ "type=\"text\" "
|
||||
+ "style=\""
|
||||
+ "font:'" + fontsize + "x " + font + "';"
|
||||
+ "color:" + color + ";"
|
||||
+ "min-width:" + width + ";"
|
||||
+ "max-width:" + width + ";"
|
||||
+ "\" "
|
||||
+ "id=\"" + id + "\" "
|
||||
+ "maxlength=" + length + " "
|
||||
+ "size=" + length + " "
|
||||
+ "/>]";
|
||||
};
|
||||
|
||||
const createFields = (txt, font, fontsize, color, counter) => {
|
||||
@@ -141,7 +141,7 @@ const run_marked_default = value => {
|
||||
** It returns any values that were saved and a corrected
|
||||
** html code or null if nothing was updated
|
||||
*/
|
||||
const checkAllFields = (txt, font, color, user_name, bold=false) => {
|
||||
const checkAllFields = (txt, font, color, user_name, bold = false) => {
|
||||
let matches;
|
||||
let values = {};
|
||||
let replace = [];
|
||||
@@ -199,8 +199,8 @@ const checkAllFields = (txt, font, color, user_name, bold=false) => {
|
||||
const pauseEvent = e => {
|
||||
if (e.stopPropagation) { e.stopPropagation(); }
|
||||
if (e.preventDefault) { e.preventDefault(); }
|
||||
e.cancelBubble=true;
|
||||
e.returnValue=false;
|
||||
e.cancelBubble = true;
|
||||
e.returnValue = false;
|
||||
return false;
|
||||
};
|
||||
|
||||
@@ -288,7 +288,7 @@ class PaperSheetStamper extends Component {
|
||||
};
|
||||
this.handleMouseClick = e => {
|
||||
if (e.pageY <= 30) { return; }
|
||||
const { act, data } = useBackend(this.context);
|
||||
const { act, data } = useBackend<any>();
|
||||
const stamp_obj = {
|
||||
x: this.state.x, y: this.state.y, r: this.state.rotate,
|
||||
stamp_class: this.props.stamp_class,
|
||||
@@ -305,14 +305,13 @@ class PaperSheetStamper extends Component {
|
||||
rotating = true;
|
||||
}
|
||||
|
||||
if (document.getElementById("stamp"))
|
||||
{
|
||||
if (document.getElementById("stamp")) {
|
||||
const stamp = document.getElementById("stamp");
|
||||
const stampHeight = stamp.clientHeight;
|
||||
const stampWidth = stamp.clientWidth;
|
||||
|
||||
const currentHeight = rotating ? this.state.y : e.pageY
|
||||
- windowRef.scrollTop - stampHeight;
|
||||
- windowRef.scrollTop - stampHeight;
|
||||
const currentWidth = rotating ? this.state.x : e.pageX - (stampWidth / 2);
|
||||
|
||||
const widthMin = 0;
|
||||
@@ -440,7 +439,7 @@ class PaperSheetEdit extends Component {
|
||||
}
|
||||
|
||||
createPreviewFromData(value, do_fields = false) {
|
||||
const { data } = useBackend(this.context);
|
||||
const { data } = useBackend<any>();
|
||||
return createPreview(value,
|
||||
this.state.old_text,
|
||||
do_fields,
|
||||
@@ -477,16 +476,18 @@ class PaperSheetEdit extends Component {
|
||||
}
|
||||
// the final update send to byond, final upkeep
|
||||
finalUpdate(new_text) {
|
||||
const { act } = useBackend(this.context);
|
||||
const { act } = useBackend<any>();
|
||||
const final_processing = this.createPreviewFromData(new_text, true);
|
||||
act('save', final_processing);
|
||||
this.setState(() => { return {
|
||||
textarea_text: "",
|
||||
previewSelected: "save",
|
||||
combined_text: final_processing.text,
|
||||
old_text: final_processing.text,
|
||||
counter: final_processing.field_counter,
|
||||
}; });
|
||||
this.setState(() => {
|
||||
return {
|
||||
textarea_text: "",
|
||||
previewSelected: "save",
|
||||
combined_text: final_processing.text,
|
||||
old_text: final_processing.text,
|
||||
counter: final_processing.field_counter,
|
||||
};
|
||||
});
|
||||
// byond should switch us to readonly mode from here
|
||||
}
|
||||
|
||||
@@ -576,12 +577,12 @@ class PaperSheetEdit extends Component {
|
||||
backgroundColor={backgroundColor}
|
||||
onInput={this.onInputHandler.bind(this)} />
|
||||
) || (
|
||||
<PaperSheetView
|
||||
value={this.state.combined_text}
|
||||
stamps={stamps}
|
||||
fontFamily={fontFamily}
|
||||
textColor={textColor} />
|
||||
)}
|
||||
<PaperSheetView
|
||||
value={this.state.combined_text}
|
||||
stamps={stamps}
|
||||
fontFamily={fontFamily}
|
||||
textColor={textColor} />
|
||||
)}
|
||||
</Flex.Item>
|
||||
</Flex>
|
||||
);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { map, sortBy } from 'common/collections';
|
||||
import { flow } from 'common/fp';
|
||||
import { toFixed } from 'common/math';
|
||||
import { toFixed } from 'tgui-core/math';
|
||||
import { pureComponentHooks } from 'common/react';
|
||||
import { useBackend, useLocalState } from '../backend';
|
||||
import { Box, Button, Chart, ColorBox, Flex, Icon, LabeledList, ProgressBar, Section, Table } from 'tgui-core/components';
|
||||
@@ -40,7 +40,7 @@ export const PowerMonitorContent = (props) => {
|
||||
PEAK_DRAW,
|
||||
...history.supply,
|
||||
...history.demand);
|
||||
// Process area data
|
||||
// Process area data
|
||||
const areas = flow([
|
||||
map((area, i) => ({
|
||||
...area,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { map } from 'common/collections';
|
||||
import { toFixed } from 'common/math';
|
||||
import { toFixed } from 'tgui-core/math';
|
||||
import { useBackend } from '../backend';
|
||||
import { Box, Button, LabeledList, NumberInput, Section } from 'tgui-core/components';
|
||||
import { RADIO_CHANNELS } from '../constants';
|
||||
@@ -48,19 +48,19 @@ export const Radio = (props) => {
|
||||
{toFixed(frequency / 10, 1) + ' kHz'}
|
||||
</Box>
|
||||
) || (
|
||||
<NumberInput
|
||||
animate
|
||||
unit="kHz"
|
||||
step={0.2}
|
||||
stepPixelSize={10}
|
||||
minValue={minFrequency / 10}
|
||||
maxValue={maxFrequency / 10}
|
||||
value={frequency / 10}
|
||||
format={value => toFixed(value, 1)}
|
||||
onChange={(value) => act('frequency', {
|
||||
adjust: (value - frequency / 10),
|
||||
})} />
|
||||
)}
|
||||
<NumberInput
|
||||
animate
|
||||
unit="kHz"
|
||||
step={0.2}
|
||||
stepPixelSize={10}
|
||||
minValue={minFrequency / 10}
|
||||
maxValue={maxFrequency / 10}
|
||||
value={frequency / 10}
|
||||
format={value => toFixed(value, 1)}
|
||||
onChange={(value) => act('frequency', {
|
||||
adjust: (value - frequency / 10),
|
||||
})} />
|
||||
)}
|
||||
{tunedChannel && (
|
||||
<Box inline color={tunedChannel.color} ml={2}>
|
||||
[{tunedChannel.name}]
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { map, sortBy } from 'common/collections';
|
||||
import { flow } from 'common/fp';
|
||||
import { toFixed } from 'common/math';
|
||||
import { toFixed } from 'tgui-core/math';
|
||||
import { pureComponentHooks } from 'common/react';
|
||||
import { Component, Fragment } from 'react';
|
||||
import { Box, Button, Chart, ColorBox, Flex, Icon, LabeledList, ProgressBar, Section, Table } from 'tgui-core/components';
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { toFixed } from 'common/math';
|
||||
import { toFixed } from 'tgui-core/math';
|
||||
import { useBackend, useLocalState } from '../backend';
|
||||
import { Button, Flex, LabeledControls, NoticeBox, RoundGauge, Section, Stack } from 'tgui-core/components';
|
||||
import { Window } from '../layouts';
|
||||
@@ -551,7 +551,7 @@ export const Secrets = (props) => {
|
||||
tabIndex,
|
||||
setTabIndex,
|
||||
] = useLocalState('tab-index', 2);
|
||||
const TabComponent = TAB2NAME[tabIndex-1].component();
|
||||
const TabComponent = TAB2NAME[tabIndex - 1].component();
|
||||
return (
|
||||
<Window
|
||||
title="Secrets Panel"
|
||||
@@ -632,7 +632,7 @@ export const Secrets = (props) => {
|
||||
label="Chances of admin complaint">
|
||||
<RoundGauge
|
||||
size={2}
|
||||
value={TAB2NAME[tabIndex-1].gauge}
|
||||
value={TAB2NAME[tabIndex - 1].gauge}
|
||||
minValue={0}
|
||||
maxValue={100}
|
||||
alertAfter={100 * 0.70}
|
||||
@@ -659,8 +659,8 @@ export const Secrets = (props) => {
|
||||
<Flex.Item grow={1}>
|
||||
<Section
|
||||
fill={false}
|
||||
title={TAB2NAME[tabIndex-1].title
|
||||
+ " Or: " + TAB2NAME[tabIndex-1].blurb}>
|
||||
title={TAB2NAME[tabIndex - 1].title
|
||||
+ " Or: " + TAB2NAME[tabIndex - 1].blurb}>
|
||||
<TabComponent />
|
||||
</Section>
|
||||
</Flex.Item>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { toFixed } from 'common/math';
|
||||
import { toFixed } from 'tgui-core/math';
|
||||
import { useBackend } from '../backend';
|
||||
import { Button, NumberInput, Section } from 'tgui-core/components';
|
||||
import { Window } from '../layouts';
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { toFixed } from 'common/math';
|
||||
import { toFixed } from 'tgui-core/math';
|
||||
import { useBackend } from '../backend';
|
||||
import { Box, Button, Flex, Icon, LabeledList, NoticeBox, Section, Stack, Table } from 'tgui-core/components';
|
||||
import { Window } from '../layouts';
|
||||
@@ -184,10 +184,10 @@ export const ImplantedSkillchips = (props) => {
|
||||
bold
|
||||
color={(!!skill.active && "good"
|
||||
) || (
|
||||
(skill.complexity + complexity_used > complexity_max) && "bad"
|
||||
) || (
|
||||
"grey"
|
||||
)}
|
||||
(skill.complexity + complexity_used > complexity_max) && "bad"
|
||||
) || (
|
||||
"grey"
|
||||
)}
|
||||
textAlign="center">
|
||||
{skill.complexity}
|
||||
</Table.Cell>
|
||||
@@ -225,9 +225,9 @@ export const ImplantedSkillchips = (props) => {
|
||||
tooltip={(!!skill.active_error
|
||||
&& !skill.active
|
||||
&& skill.active_error) || (
|
||||
skill.active && "Deactivate") || (
|
||||
"Activate"
|
||||
)}
|
||||
skill.active && "Deactivate") || (
|
||||
"Activate"
|
||||
)}
|
||||
tooltipPosition="left"
|
||||
disabled={
|
||||
skill.cooldown
|
||||
@@ -246,9 +246,9 @@ export const ImplantedSkillchips = (props) => {
|
||||
export const TimeFormat = (props) => {
|
||||
const { value } = props;
|
||||
|
||||
const seconds = toFixed(Math.floor((value/10) % 60)).padStart(2, "0");
|
||||
const minutes = toFixed(Math.floor((value/(10*60)) % 60)).padStart(2, "0");
|
||||
const hours = toFixed(Math.floor((value/(10*60*60)) % 24)).padStart(2, "0");
|
||||
const seconds = toFixed(Math.floor((value / 10) % 60)).padStart(2, "0");
|
||||
const minutes = toFixed(Math.floor((value / (10 * 60)) % 60)).padStart(2, "0");
|
||||
const hours = toFixed(Math.floor((value / (10 * 60 * 60)) % 24)).padStart(2, "0");
|
||||
const formattedValue = `${hours}:${minutes}:${seconds}`;
|
||||
return formattedValue;
|
||||
};
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { sortBy } from 'common/collections';
|
||||
import { flow } from 'common/fp';
|
||||
import { toFixed } from 'common/math';
|
||||
import { toFixed } from 'tgui-core/math';
|
||||
import { useBackend } from '../backend';
|
||||
import { Button, LabeledList, ProgressBar, Section, Stack, Table } from 'tgui-core/components';
|
||||
import { getGasColor, getGasLabel } from '../constants';
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { toFixed } from 'common/math';
|
||||
import { toFixed } from 'tgui-core/math';
|
||||
import { useBackend } from '../backend';
|
||||
import { Button, LabeledControls, NumberInput, RoundGauge, Section } from 'tgui-core/components';
|
||||
import { formatSiUnit } from 'tgui-core/format';
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
*/
|
||||
import { Window } from '../layouts';
|
||||
import { useBackend } from '../backend';
|
||||
import { toFixed } from 'common/math';
|
||||
import { toFixed } from 'tgui-core/math';
|
||||
import { RADIO_CHANNELS } from '../constants';
|
||||
import { Button, LabeledList, NumberInput, NoticeBox, Section, Input } from 'tgui-core/components';
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ export class Thermometer extends Component {
|
||||
}
|
||||
|
||||
render() {
|
||||
const { act, data } = useBackend(this.context);
|
||||
const { act, data } = useBackend<any>();
|
||||
return (
|
||||
<Window
|
||||
width={70}
|
||||
@@ -67,7 +67,7 @@ const ThermometerIcon = props => {
|
||||
'right': 0,
|
||||
'transition': 'height 2s ease-out',
|
||||
// Temp in %
|
||||
'height': `${((temperature / maxTemperature)*100)}%`,
|
||||
'height': `${((temperature / maxTemperature) * 100)}%`,
|
||||
'background-color': '#bd2020',
|
||||
'border-radius': '8px',
|
||||
'border-bottom': 'none',
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { toFixed } from 'common/math';
|
||||
import { toFixed } from 'tgui-core/math';
|
||||
import { useBackend } from '../backend';
|
||||
import { Button, LabeledList, ProgressBar, Section } from 'tgui-core/components';
|
||||
import { Window } from '../layouts';
|
||||
|
||||
Reference in New Issue
Block a user