mirror of
https://github.com/CHOMPStation2/CHOMPStation2.git
synced 2025-12-10 10:12:45 +00:00
49 lines
1.0 KiB
TypeScript
49 lines
1.0 KiB
TypeScript
import { useDispatch } from 'tgui/backend';
|
|
import { Button } from 'tgui/components';
|
|
|
|
import { dismissWarning } from './game/actions';
|
|
|
|
let url: string | null = null;
|
|
|
|
setInterval(() => {
|
|
Byond.winget('', 'url').then((currentUrl) => {
|
|
// Sometimes, for whatever reason, BYOND will give an IP with a :0 port.
|
|
if (currentUrl && !currentUrl.match(/:0$/)) {
|
|
url = currentUrl;
|
|
}
|
|
});
|
|
}, 5000);
|
|
|
|
export const ReconnectButton = (props) => {
|
|
if (!url) {
|
|
return null;
|
|
}
|
|
const dispatch = useDispatch();
|
|
return (
|
|
<>
|
|
<Button
|
|
color="white"
|
|
onClick={() => {
|
|
Byond.command('.reconnect');
|
|
}}>
|
|
Reconnect
|
|
</Button>
|
|
<Button
|
|
color="white"
|
|
onClick={() => {
|
|
location.href = `byond://${url}`;
|
|
Byond.command('.quit');
|
|
}}>
|
|
Relaunch game
|
|
</Button>
|
|
<Button
|
|
color="white"
|
|
onClick={() => {
|
|
dispatch(dismissWarning());
|
|
}}>
|
|
Dismiss
|
|
</Button>
|
|
</>
|
|
);
|
|
};
|