Add confirmation to installing

This commit is contained in:
Olivier Gagnon
2021-12-18 18:13:49 -05:00
parent 02605090df
commit 555216a39b
5 changed files with 64 additions and 14 deletions
+37 -1
View File
@@ -16,6 +16,8 @@ import Typography from "@mui/material/Typography";
import Button from "@mui/material/Button";
import Tooltip from "@mui/material/Tooltip";
import Box from "@mui/material/Box";
import { Settings } from "../../Settings/Settings";
import { ConfirmationModal } from "../../ui/React/ConfirmationModal";
interface IProps {
exportGameFn: () => void;
@@ -23,6 +25,7 @@ interface IProps {
}
export function AugmentationsRoot(props: IProps): React.ReactElement {
const [installOpen, setInstallOpen] = useState(false);
const player = use.Player();
const setRerender = useState(false)[1];
function rerender(): void {
@@ -43,6 +46,14 @@ export function AugmentationsRoot(props: IProps): React.ReactElement {
return "";
}
function doInstall(): void {
if (!Settings.SuppressBuyAugmentationConfirmation) {
setInstallOpen(true);
} else {
props.installAugmentationsFn();
}
}
return (
<>
<Typography variant="h4">Augmentations</Typography>
@@ -73,11 +84,36 @@ export function AugmentationsRoot(props: IProps): React.ReactElement {
<Box mx={2}>
<Tooltip title={<Typography>'I never asked for this'</Typography>}>
<span>
<Button disabled={player.queuedAugmentations.length === 0} onClick={props.installAugmentationsFn}>
<Button disabled={player.queuedAugmentations.length === 0} onClick={doInstall}>
Install Augmentations
</Button>
</span>
</Tooltip>
<ConfirmationModal
open={installOpen}
onClose={() => setInstallOpen(false)}
onConfirm={props.installAugmentationsFn}
confirmationText={
<>
Installing will reset
<br />
<br />- money
<br />- skill / experience
<br />- every server except home
<br />- factions and reputation
<br />
<br />
You will keep:
<br />
<br />- All scripts on home
<br />- home ram and cores
<br />
<br />
It is recommended to install several Augmentations at once. Preferably everything from any faction of your
chosing.
</>
}
/>
<Tooltip title={<Typography>It's always a good idea to backup/export your save!</Typography>}>
<Button sx={{ mx: 2 }} onClick={doExport} color="error">
Backup Save {exportBonusStr()}