mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-10-23 18:23:15 +02:00
855a4e622d
Adds a channel to communicate between the main process & the renderer process, so that the game can easily ship data back to the main process. It uses the Electron contextBridge & ipcRenderer/ipcMain. Connects those events to various save functions. Adds triggered events on game save, game load, and imported game. Adds way for the Electron app to ask for certain actions or data. Hook handlers to disable automatic restore Allows to temporarily disable restore when the game just did an import or deleted a save game. Prevents looping screens.
37 lines
1.2 KiB
TypeScript
37 lines
1.2 KiB
TypeScript
import React, { useState } from 'react';
|
|
import { deleteGame } from "../../db";
|
|
import { ConfirmationModal } from "./ConfirmationModal";
|
|
import Button from "@mui/material/Button";
|
|
import { Tooltip } from '@mui/material';
|
|
|
|
import DeleteIcon from '@mui/icons-material/Delete';
|
|
import { pushDisableRestore } from '../../Electron';
|
|
|
|
interface IProps {
|
|
color?: "primary" | "warning" | "error";
|
|
}
|
|
|
|
export function DeleteGameButton({ color = "primary" }: IProps): React.ReactElement {
|
|
const [modalOpened, setModalOpened] = useState(false);
|
|
|
|
return (<>
|
|
<Tooltip title="This will permanently delete your local save game. Did you export it before?">
|
|
<Button startIcon={<DeleteIcon />} color={color} onClick={() => setModalOpened(true)}>Delete Save</Button>
|
|
</Tooltip>
|
|
<ConfirmationModal
|
|
onConfirm={() => {
|
|
setModalOpened(false);
|
|
deleteGame()
|
|
.then(() => {
|
|
pushDisableRestore();
|
|
setTimeout(() => location.reload(), 1000);
|
|
})
|
|
.catch((r) => console.error(`Could not delete game: ${r}`));
|
|
}}
|
|
open={modalOpened}
|
|
onClose={() => setModalOpened(false)}
|
|
confirmationText={"Really delete your game? (It's permanent!)"}
|
|
/>
|
|
</>)
|
|
}
|