mirror of
https://github.com/CHOMPStation2/CHOMPStation2.git
synced 2025-12-12 03:02:54 +00:00
[MIRROR] fix shuttle console & painting canvas (#7953)
Co-authored-by: Kashargul <144968721+Kashargul@users.noreply.github.com> Co-authored-by: Selis <selis@xynolabs.com>
This commit is contained in:
@@ -52,8 +52,8 @@ class PaintCanvas extends Component {
|
|||||||
const y_size = this.props.value[0].length;
|
const y_size = this.props.value[0].length;
|
||||||
const x_scale = this.canvasRef.current.width / x_size;
|
const x_scale = this.canvasRef.current.width / x_size;
|
||||||
const y_scale = this.canvasRef.current.height / y_size;
|
const y_scale = this.canvasRef.current.height / y_size;
|
||||||
const x = Math.floor(event.offsetX / x_scale) + 1;
|
const x = Math.floor(event.nativeEvent.offsetX / x_scale) + 1;
|
||||||
const y = Math.floor(event.offsetY / y_scale) + 1;
|
const y = Math.floor(event.nativeEvent.offsetY / y_scale) + 1;
|
||||||
this.onCVClick(x, y);
|
this.onCVClick(x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -144,7 +144,7 @@ const ShuttleControlConsoleDefault = (props) => {
|
|||||||
|
|
||||||
const ShuttleControlConsoleMulti = (props) => {
|
const ShuttleControlConsoleMulti = (props) => {
|
||||||
const { act, data } = useBackend();
|
const { act, data } = useBackend();
|
||||||
const { can_cloak, can_pick, legit, cloaked, destination_name } = data;
|
const { can_cloak, can_pick, legit, cloaked } = data;
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<ShuttleControlSharedShuttleStatus />
|
<ShuttleControlSharedShuttleStatus />
|
||||||
@@ -164,12 +164,11 @@ const ShuttleControlConsoleMulti = (props) => {
|
|||||||
null}
|
null}
|
||||||
<LabeledList.Item label="Current Destination">
|
<LabeledList.Item label="Current Destination">
|
||||||
<Button
|
<Button
|
||||||
|
content={props.destination_name}
|
||||||
icon="taxi"
|
icon="taxi"
|
||||||
disabled={!can_pick}
|
disabled={!can_pick}
|
||||||
onClick={() => act('pick')}
|
onClick={() => act('pick')}
|
||||||
>
|
/>
|
||||||
{destination_name}
|
|
||||||
</Button>
|
|
||||||
</LabeledList.Item>
|
</LabeledList.Item>
|
||||||
</LabeledList>
|
</LabeledList>
|
||||||
</Section>
|
</Section>
|
||||||
@@ -467,24 +466,28 @@ const ShuttleControlConsoleWeb = (props) => {
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
// This may look tempting to convert to require() or some kind of dynamic call
|
|
||||||
// Don't do it. XSS abound.
|
|
||||||
const SubtemplateList = {
|
|
||||||
ShuttleControlConsoleDefault: <ShuttleControlConsoleDefault />,
|
|
||||||
ShuttleControlConsoleMulti: <ShuttleControlConsoleMulti />,
|
|
||||||
ShuttleControlConsoleExploration: <ShuttleControlConsoleExploration />,
|
|
||||||
ShuttleControlConsoleWeb: <ShuttleControlConsoleWeb />,
|
|
||||||
};
|
|
||||||
|
|
||||||
export const ShuttleControl = (props) => {
|
export const ShuttleControl = (props) => {
|
||||||
const { act, data } = useBackend();
|
const { act, data } = useBackend();
|
||||||
const { subtemplate } = data;
|
const { subtemplate, destination_name } = data;
|
||||||
return (
|
return (
|
||||||
<Window
|
<Window
|
||||||
width={470}
|
width={470}
|
||||||
height={subtemplate === 'ShuttleControlConsoleWeb' ? 560 : 370}
|
height={subtemplate === 'ShuttleControlConsoleWeb' ? 560 : 370}
|
||||||
>
|
>
|
||||||
<Window.Content>{SubtemplateList[subtemplate]}</Window.Content>
|
<Window.Content>
|
||||||
|
{(subtemplate === 'ShuttleControlConsoleDefault' && (
|
||||||
|
<ShuttleControlConsoleDefault />
|
||||||
|
)) ||
|
||||||
|
(subtemplate === 'ShuttleControlConsoleMulti' && (
|
||||||
|
<ShuttleControlConsoleMulti destination_name={destination_name} />
|
||||||
|
)) ||
|
||||||
|
(subtemplate === 'ShuttleControlConsoleExploration' && (
|
||||||
|
<ShuttleControlConsoleExploration />
|
||||||
|
)) ||
|
||||||
|
(subtemplate === 'ShuttleControlConsoleWeb' && (
|
||||||
|
<ShuttleControlConsoleWeb />
|
||||||
|
))}
|
||||||
|
</Window.Content>
|
||||||
</Window>
|
</Window>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user