mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-11-29 19:13:49 +01:00
Add confirmation to installing
This commit is contained in:
parent
02605090df
commit
555216a39b
@ -16,6 +16,8 @@ import Typography from "@mui/material/Typography";
|
|||||||
import Button from "@mui/material/Button";
|
import Button from "@mui/material/Button";
|
||||||
import Tooltip from "@mui/material/Tooltip";
|
import Tooltip from "@mui/material/Tooltip";
|
||||||
import Box from "@mui/material/Box";
|
import Box from "@mui/material/Box";
|
||||||
|
import { Settings } from "../../Settings/Settings";
|
||||||
|
import { ConfirmationModal } from "../../ui/React/ConfirmationModal";
|
||||||
|
|
||||||
interface IProps {
|
interface IProps {
|
||||||
exportGameFn: () => void;
|
exportGameFn: () => void;
|
||||||
@ -23,6 +25,7 @@ interface IProps {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function AugmentationsRoot(props: IProps): React.ReactElement {
|
export function AugmentationsRoot(props: IProps): React.ReactElement {
|
||||||
|
const [installOpen, setInstallOpen] = useState(false);
|
||||||
const player = use.Player();
|
const player = use.Player();
|
||||||
const setRerender = useState(false)[1];
|
const setRerender = useState(false)[1];
|
||||||
function rerender(): void {
|
function rerender(): void {
|
||||||
@ -43,6 +46,14 @@ export function AugmentationsRoot(props: IProps): React.ReactElement {
|
|||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function doInstall(): void {
|
||||||
|
if (!Settings.SuppressBuyAugmentationConfirmation) {
|
||||||
|
setInstallOpen(true);
|
||||||
|
} else {
|
||||||
|
props.installAugmentationsFn();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Typography variant="h4">Augmentations</Typography>
|
<Typography variant="h4">Augmentations</Typography>
|
||||||
@ -73,11 +84,36 @@ export function AugmentationsRoot(props: IProps): React.ReactElement {
|
|||||||
<Box mx={2}>
|
<Box mx={2}>
|
||||||
<Tooltip title={<Typography>'I never asked for this'</Typography>}>
|
<Tooltip title={<Typography>'I never asked for this'</Typography>}>
|
||||||
<span>
|
<span>
|
||||||
<Button disabled={player.queuedAugmentations.length === 0} onClick={props.installAugmentationsFn}>
|
<Button disabled={player.queuedAugmentations.length === 0} onClick={doInstall}>
|
||||||
Install Augmentations
|
Install Augmentations
|
||||||
</Button>
|
</Button>
|
||||||
</span>
|
</span>
|
||||||
</Tooltip>
|
</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>}>
|
<Tooltip title={<Typography>It's always a good idea to backup/export your save!</Typography>}>
|
||||||
<Button sx={{ mx: 2 }} onClick={doExport} color="error">
|
<Button sx={{ mx: 2 }} onClick={doExport} color="error">
|
||||||
Backup Save {exportBonusStr()}
|
Backup Save {exportBonusStr()}
|
||||||
|
@ -24,9 +24,9 @@ function timeCompression(): void {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
last = now;
|
last = now;
|
||||||
window.setTimeout(minute, 1000);
|
window.setTimeout(minute, 1000 * 60);
|
||||||
}
|
}
|
||||||
window.setTimeout(minute, 1000);
|
window.setTimeout(minute, 1000 * 60);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function startExploits(): void {
|
export function startExploits(): void {
|
||||||
|
@ -304,7 +304,10 @@ export function NetscriptFunctions(workerScript: WorkerScript): NS {
|
|||||||
const checkSingularityAccess = function (func: any, n: any): void {
|
const checkSingularityAccess = function (func: any, n: any): void {
|
||||||
if (Player.bitNodeN !== 4) {
|
if (Player.bitNodeN !== 4) {
|
||||||
if (SourceFileFlags[4] < n) {
|
if (SourceFileFlags[4] < n) {
|
||||||
throw makeRuntimeErrorMsg(func, `This singularity function requires Source-File 4-${n} to run.`);
|
throw makeRuntimeErrorMsg(
|
||||||
|
func,
|
||||||
|
`This singularity function requires Source-File 4-${n} to run. A power up you obtain later in the game. It will be very obvious when and how you can obtain it.`,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -1611,7 +1614,7 @@ export function NetscriptFunctions(workerScript: WorkerScript): NS {
|
|||||||
|
|
||||||
const cost = getPurchaseServerCost(ram);
|
const cost = getPurchaseServerCost(ram);
|
||||||
if (cost === Infinity) {
|
if (cost === Infinity) {
|
||||||
workerScript.log("purchaseServer", () => `Invalid argument: ram='${ram}'`);
|
workerScript.log("purchaseServer", () => `Invalid argument: ram='${ram}' must be power of 2`);
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@ interface IProps {
|
|||||||
open: boolean;
|
open: boolean;
|
||||||
onClose: () => void;
|
onClose: () => void;
|
||||||
onConfirm: () => void;
|
onConfirm: () => void;
|
||||||
confirmationText: string;
|
confirmationText: string | React.ReactNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function ConfirmationModal(props: IProps): React.ReactElement {
|
export function ConfirmationModal(props: IProps): React.ReactElement {
|
||||||
|
@ -83,6 +83,7 @@ export function GameOptionsRoot(props: IProps): React.ReactElement {
|
|||||||
const [diagnosticOpen, setDiagnosticOpen] = useState(false);
|
const [diagnosticOpen, setDiagnosticOpen] = useState(false);
|
||||||
const [deleteGameOpen, setDeleteOpen] = useState(false);
|
const [deleteGameOpen, setDeleteOpen] = useState(false);
|
||||||
const [themeEditorOpen, setThemeEditorOpen] = useState(false);
|
const [themeEditorOpen, setThemeEditorOpen] = useState(false);
|
||||||
|
const [softResetOpen, setSoftResetOpen] = useState(false);
|
||||||
|
|
||||||
function handleExecTimeChange(event: any, newValue: number | number[]): void {
|
function handleExecTimeChange(event: any, newValue: number | number[]): void {
|
||||||
setExecTime(newValue as number);
|
setExecTime(newValue as number);
|
||||||
@ -210,6 +211,14 @@ export function GameOptionsRoot(props: IProps): React.ReactElement {
|
|||||||
reader.readAsText(file);
|
reader.readAsText(file);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function doSoftReset(): void {
|
||||||
|
if (!Settings.SuppressBuyAugmentationConfirmation) {
|
||||||
|
setSoftResetOpen(true);
|
||||||
|
} else {
|
||||||
|
props.softReset();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={classes.root} style={{ width: "90%" }}>
|
<div className={classes.root} style={{ width: "90%" }}>
|
||||||
<Typography variant="h4" gutterBottom>
|
<Typography variant="h4" gutterBottom>
|
||||||
@ -388,7 +397,7 @@ export function GameOptionsRoot(props: IProps): React.ReactElement {
|
|||||||
</Typography>
|
</Typography>
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
<Typography>Suppress buy augmentation confirmation</Typography>
|
<Typography>Suppress augmentations confirmation</Typography>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
@ -428,15 +437,11 @@ export function GameOptionsRoot(props: IProps): React.ReactElement {
|
|||||||
)}
|
)}
|
||||||
<ListItem>
|
<ListItem>
|
||||||
<FormControlLabel
|
<FormControlLabel
|
||||||
control={
|
control={<Switch checked={suppressSavedGameToast} onChange={handleSuppressSavedGameToastChange} />}
|
||||||
<Switch checked={suppressSavedGameToast} onChange={handleSuppressSavedGameToastChange} />
|
|
||||||
}
|
|
||||||
label={
|
label={
|
||||||
<Tooltip
|
<Tooltip
|
||||||
title={
|
title={
|
||||||
<Typography>
|
<Typography>If this is set, there will be no "Saved Game" toast appearing after save.</Typography>
|
||||||
If this is set, there will be no "Saved Game" toast appearing after save.
|
|
||||||
</Typography>
|
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
<Typography>Suppress Saved Game Toast</Typography>
|
<Typography>Suppress Saved Game Toast</Typography>
|
||||||
@ -650,8 +655,14 @@ export function GameOptionsRoot(props: IProps): React.ReactElement {
|
|||||||
</Typography>
|
</Typography>
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
<Button onClick={() => props.softReset()}>Soft Reset</Button>
|
<Button onClick={doSoftReset}>Soft Reset</Button>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
|
<ConfirmationModal
|
||||||
|
open={softResetOpen}
|
||||||
|
onClose={() => setSoftResetOpen(false)}
|
||||||
|
onConfirm={props.softReset}
|
||||||
|
confirmationText={"This will perform the same action as installing Augmentations, are you sure?"}
|
||||||
|
/>
|
||||||
</Box>
|
</Box>
|
||||||
<Box>
|
<Box>
|
||||||
<Tooltip
|
<Tooltip
|
||||||
|
Loading…
Reference in New Issue
Block a user