diff --git a/tgui/packages/tgui/components/InfinitePlane.js b/tgui/packages/tgui/components/InfinitePlane.js index 55273137bbe..7d15a37e382 100644 --- a/tgui/packages/tgui/components/InfinitePlane.js +++ b/tgui/packages/tgui/components/InfinitePlane.js @@ -27,6 +27,8 @@ export class InfinitePlane extends Component { this.handleMouseDown = this.handleMouseDown.bind(this); this.handleMouseMove = this.handleMouseMove.bind(this); + this.handleZoomIncrease = this.handleZoomIncrease.bind(this); + this.handleZoomDecrease = this.handleZoomDecrease.bind(this); this.onMouseUp = this.onMouseUp.bind(this); this.doOffsetMouse = this.doOffsetMouse.bind(this); @@ -70,14 +72,46 @@ export class InfinitePlane extends Component { }); } + handleZoomIncrease(event) { + const { onZoomChange } = this.props; + const { zoom } = this.state; + const newZoomValue = Math.min(zoom+ZOOM_INCREMENT, ZOOM_MAX_VAL); + this.setState({ + zoom: newZoomValue, + }); + if (onZoomChange) { + onZoomChange(newZoomValue); + } + } + + handleZoomDecrease(event) { + const { onZoomChange } = this.props; + const { zoom } = this.state; + const newZoomValue = Math.max(zoom-ZOOM_INCREMENT, ZOOM_MIN_VAL); + this.setState({ + zoom: newZoomValue, + }); + + if (onZoomChange) { + onZoomChange(newZoomValue); + } + } + handleMouseMove(event) { + const { onBackgroundMoved } = this.props; if (this.state.mouseDown) { + let newX, newY; this.setState((state) => { + newX = event.clientX - state.lastLeft; + newY = event.clientY - state.lastTop; return { - left: event.clientX - state.lastLeft, - top: event.clientY - state.lastTop, + left: newX, + top: newY, }; }); + if (onBackgroundMoved) { + onBackgroundMoved(newX, newY); + } } } @@ -140,9 +174,7 @@ export class InfinitePlane extends Component { + )) + || port.name} + + + + {port.type || 'any'} + + + + + ); +}; diff --git a/tgui/packages/tgui/interfaces/IntegratedCircuit/FundamentalTypes.js b/tgui/packages/tgui/interfaces/IntegratedCircuit/FundamentalTypes.js new file mode 100644 index 00000000000..1374fea1e99 --- /dev/null +++ b/tgui/packages/tgui/interfaces/IntegratedCircuit/FundamentalTypes.js @@ -0,0 +1,84 @@ +import { BasicInput } from './BasicInput'; +import { NumberInput, Button, Stack, Input } from '../../components'; + +export const FUNDAMENTAL_DATA_TYPES = { + 'string': (props, context) => { + const { name, value, setValue, color } = props; + return ( + + setValue(val)} + /> + + ); + }, + 'number': (props, context) => { + const { name, value, setValue, color } = props; + return ( + + setValue(val)} + unit={name} + /> + + ); + }, + 'entity': (props, context) => { + const { name, setValue, color } = props; + return ( + - )) - || port.name} - - - - {port.type || 'any'} - - - - - ); -};