Skip to content

Commit

Permalink
prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
DOOM committed Jul 2, 2023
1 parent 13037ba commit 5ef3526
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 25 deletions.
6 changes: 3 additions & 3 deletions tgui/packages/tgui/interfaces/CanvasLayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ export class CanvasLayer extends Component {
super(props);
this.canvasRef = createRef();


// color selection
// using this.state prevents unpredictable behavior
this.state = {
Expand Down Expand Up @@ -171,8 +170,9 @@ export class CanvasLayer extends Component {
}

if (selection === 'export') {

this.props.onImageExport(String(this.canvasRef.current.toDataURL("image/jpeg", 0.4)));
this.props.onImageExport(
String(this.canvasRef.current.toDataURL('image/jpeg', 0.4))
);

return;
}
Expand Down
55 changes: 33 additions & 22 deletions tgui/packages/tgui/interfaces/TacticalMap.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
import { useBackend } from '../backend';
import { Button, Dropdown, Section, Stack, ProgressBar, Box} from '../components';
import {
Button,
Dropdown,
Section,
Stack,
ProgressBar,
Box,
} from '../components';
import { Window } from '../layouts';
import { CanvasLayer } from './CanvasLayer';

Expand All @@ -18,9 +25,7 @@ export const TacticalMap = (props, context) => {
const { data, act } = useBackend<TacMapProps>(context);

const timeLeft = data.nextcanvastime - data.worldtime;

const timeLeftPct = timeLeft / data.canvas_cooldown;

const canUpdate = timeLeft < 0 && !data.updatedCanvas;

const handleTacMapExport = (image: any) => {
Expand All @@ -34,7 +39,7 @@ export const TacticalMap = (props, context) => {
'blue',
'purple',
'green',
'brown'
'brown',
];

const colors: Record<string, string> = {
Expand All @@ -44,16 +49,19 @@ export const TacticalMap = (props, context) => {
'blue': '#0561F5',
'purple': '#C002FA',
'green': '#02c245',
'brown': '#5C351E'
'brown': '#5C351E',
};

const handleColorSelection = () => {
if(colors[data.toolbarUpdatedSelection] != null && colors[data.toolbarUpdatedSelection] != undefined){
if (
colors[data.toolbarUpdatedSelection] != null &&
colors[data.toolbarUpdatedSelection] != undefined
) {
return colors[data.toolbarUpdatedSelection];
} else {
return data.toolbarUpdatedSelection;
}
}
};

return (
<Window title={'Tactical Map'} theme="usmc" width={650} height={750}>
Expand All @@ -65,10 +73,10 @@ export const TacticalMap = (props, context) => {
onImageExport={handleTacMapExport}
/>
</Section>
<Section title="Canvas Options" className={"canvas-options"}>
<Section title="Canvas Options" className={'canvas-options'}>
<Stack>
<Stack.Item grow>
{(!data.updatedCanvas && (
{(!data.updatedCanvas && (
<Button
fontSize="10px"
fluid={1}
Expand All @@ -88,9 +96,11 @@ export const TacticalMap = (props, context) => {
content="Announce"
className="text-center"
onClick={() =>
act('selectAnnouncement', { image: data.exportedTacMapImage })
}
/>
act('selectAnnouncement', {
image: data.exportedTacMapImage,
})
}
/>
)}
</Stack.Item>
<Stack.Item grow>
Expand Down Expand Up @@ -125,26 +135,27 @@ export const TacticalMap = (props, context) => {
/>
</Stack.Item>
</Stack>
<Stack className={"progress-stack"} >
<Stack.Item grow>
{timeLeft > 0 && (
<ProgressBar
<Stack className={'progress-stack'}>
<Stack.Item grow>
{timeLeft > 0 && (
<ProgressBar
value={timeLeftPct}
ranges={{
good: [-Infinity, 0.33],
average: [0.33, 0.67],
bad: [0.67, Infinity],
}}>
}}
>
<Box textAlign="center" fontSize="15px">
{Math.ceil(timeLeft / 10)} seconds until the canvas changes can be updated
{Math.ceil(timeLeft / 10)} seconds until the canvas changes
can be updated
</Box>
</ProgressBar>
)}
</Stack.Item>
</ProgressBar>
)}
</Stack.Item>
</Stack>
</Section>
</Window.Content>
</Window>
);
};

0 comments on commit 5ef3526

Please sign in to comment.