diff --git a/tgui/packages/tgui/components/NanoMap.js b/tgui/packages/tgui/components/NanoMap.js deleted file mode 100644 index f06141047238b..0000000000000 --- a/tgui/packages/tgui/components/NanoMap.js +++ /dev/null @@ -1,224 +0,0 @@ -// BANDASTATION ADDITION - -import { resolveAsset } from '../assets'; -import { useBackend } from '../backend'; -import { Box, Button, Icon, Tooltip } from '.'; -import { LabeledList } from './LabeledList'; -import { Slider } from './Slider'; - -const pauseEvent = (e) => { - if (e.stopPropagation) { - e.stopPropagation(); - } - if (e.preventDefault) { - e.preventDefault(); - } - e.cancelBubble = true; - e.returnValue = false; - return false; -}; - -export class NanoMap extends Component { - constructor(props) { - super(props); - - // Auto center based on window size - const Xcenter = window.innerWidth / 2 - 256; - const Ycenter = window.innerHeight / 2 - 256; - - this.state = { - offsetX: 128, - offsetY: 48, - transform: 'none', - dragging: false, - originX: null, - originY: null, - zoom: 1, - }; - - // Dragging - this.handleDragStart = (e) => { - this.ref = e.target; - this.setState({ - dragging: false, - originX: e.screenX, - originY: e.screenY, - }); - document.addEventListener('mousemove', this.handleDragMove); - document.addEventListener('mouseup', this.handleDragEnd); - pauseEvent(e); - }; - - this.handleDragMove = (e) => { - this.setState((prevState) => { - const state = { ...prevState }; - const newOffsetX = e.screenX - state.originX; - const newOffsetY = e.screenY - state.originY; - if (prevState.dragging) { - state.offsetX += newOffsetX; - state.offsetY += newOffsetY; - state.originX = e.screenX; - state.originY = e.screenY; - } else { - state.dragging = true; - } - return state; - }); - pauseEvent(e); - }; - - this.handleDragEnd = (e) => { - this.setState({ - dragging: false, - originX: null, - originY: null, - }); - document.removeEventListener('mousemove', this.handleDragMove); - document.removeEventListener('mouseup', this.handleDragEnd); - pauseEvent(e); - }; - - this.handleZoom = (_e, value) => { - this.setState((state) => { - const newZoom = Math.min(Math.max(value, 1), 8); - let zoomDiff = (newZoom - state.zoom) * 1.5; - state.zoom = newZoom; - state.offsetX = state.offsetX - 262 * zoomDiff; - state.offsetY = state.offsetY - 256 * zoomDiff; - if (props.onZoom) { - props.onZoom(state.zoom); - } - return state; - }); - }; - } - - render() { - const { config } = useBackend(this.context); - const { dragging, offsetX, offsetY, zoom = 1 } = this.state; - const { children } = this.props; - - const mapUrl = config.map + '_nanomap_z1.png'; - const mapSize = 510 * zoom + 'px'; - const newStyle = { - width: mapSize, - height: mapSize, - 'margin-top': offsetY + 'px', - 'margin-left': offsetX + 'px', - overflow: 'hidden', - position: 'relative', - 'background-size': 'cover', - 'background-repeat': 'no-repeat', - 'text-align': 'center', - cursor: dragging ? 'move' : 'auto', - }; - const mapStyle = { - width: '100%', - height: '100%', - position: 'absolute', - top: '50%', - left: '50%', - transform: 'translate(-50%, -50%)', - '-ms-interpolation-mode': 'nearest-neighbor', - }; - - return ( - - - - {children} - - - - ); - } -} - -const NanoMapMarker = (props, context) => { - const { x, y, zoom = 1, icon, tooltip, color } = props; - const rx = x * 2 * zoom - zoom - 3; - const ry = y * 2 * zoom - zoom - 3; - return ( -
- - - - - -
- ); -}; - -NanoMap.Marker = NanoMapMarker; - -const NanoMapZoomer = (props, context) => { - return ( - - - - v + 'x'} - value={props.zoom} - onDrag={(e, v) => props.onZoom(e, v)} - /> - - - - ); -}; - -NanoMap.Zoomer = NanoMapZoomer; - -let ActiveButton; -class NanoButton extends Component { - constructor(props) { - super(props); - const { act } = useBackend(this.props.context); - this.state = { - color: this.props.color, - }; - this.handleClick = (e) => { - if (ActiveButton !== undefined) { - ActiveButton.setState({ - color: 'blue', - }); - } - act('switch_camera', { - name: this.props.name, - }); - ActiveButton = this; - this.setState({ - color: 'green', - }); - }; - } - render() { - let rx = this.props.x * 2 * this.props.zoom - this.props.zoom - 3; - let ry = this.props.y * 2 * this.props.zoom - this.props.zoom - 3; - return ( - - ); - } -} -NanoMap.NanoButton = NanoButton; diff --git a/tgui/packages/tgui/components/index.ts b/tgui/packages/tgui/components/index.ts index e591dc4cc9238..1a5f477d256b5 100644 --- a/tgui/packages/tgui/components/index.ts +++ b/tgui/packages/tgui/components/index.ts @@ -49,6 +49,3 @@ export { TimeDisplay } from './TimeDisplay'; export { Tooltip } from './Tooltip'; export { TrackOutsideClicks } from './TrackOutsideClicks'; export { VirtualList } from './VirtualList'; - -// BANDASTATION EDIT ADDITION -export { NanoMap } from './NanoMap'; diff --git a/tgui/packages/tgui/styles/components/NanoMap.scss b/tgui/packages/tgui/styles/components/NanoMap.scss deleted file mode 100644 index acdb43ffb03a6..0000000000000 --- a/tgui/packages/tgui/styles/components/NanoMap.scss +++ /dev/null @@ -1,35 +0,0 @@ -// BANDASTATION ADDITION - -$background-color: rgba(0, 0, 0, 0.33) !default; - -.NanoMap__container { - overflow: hidden; - width: 100%; - z-index: 1; -} - -.NanoMap__marker { - z-index: 10; - padding: 0px; - margin: 0px; -} - -.NanoMap__button { - padding: 3px 3px; - font-size: 12px; - border: 2px solid black; -} - -.NanoMap__button:hover { - background-color: greenyellow; -} - -.NanoMap__zoomer { - z-index: 20; - background-color: $background-color; - position: absolute; - top: 30px; - left: 0; - padding: 0.5rem; - width: 20%; -} diff --git a/tgui/packages/tgui/styles/main.scss b/tgui/packages/tgui/styles/main.scss index c3bad8883a0e1..91712be44d0da 100644 --- a/tgui/packages/tgui/styles/main.scss +++ b/tgui/packages/tgui/styles/main.scss @@ -93,6 +93,3 @@ background-position: center; background-repeat: no-repeat; } - -// BANDASTATION EDIT ADDITION -@include meta.load-css('./components/NanoMap.scss');