mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-12-18 12:15:44 +01:00
Added recovery mode
This commit is contained in:
parent
fa44b38506
commit
048ef0e69e
36
dist/vendor.bundle.js
vendored
36
dist/vendor.bundle.js
vendored
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -4,7 +4,6 @@ import { sanitizeExploits } from "./Exploits/Exploit";
|
||||
|
||||
import { Reviver } from "./utils/JSONReviver";
|
||||
import Decimal from "decimal.js";
|
||||
import { Programs } from "./Programs/Programs";
|
||||
|
||||
export let Player = new PlayerObject();
|
||||
|
||||
|
@ -73,6 +73,7 @@ import { InvitationModal } from "../Faction/ui/InvitationModal";
|
||||
|
||||
import { enterBitNode } from "../RedPill";
|
||||
import { Context } from "./Context";
|
||||
import { RecoveryMode, RecoveryRoot } from "./React/RecoveryRoot";
|
||||
|
||||
const htmlLocation = location;
|
||||
|
||||
@ -183,6 +184,7 @@ export let Router: IRouter = {
|
||||
};
|
||||
|
||||
function determineStartPage(player: IPlayer): Page {
|
||||
if (RecoveryMode) return Page.Recovery;
|
||||
if (player.isWorking) return Page.Work;
|
||||
return Page.Terminal;
|
||||
}
|
||||
@ -295,7 +297,9 @@ export function GameRoot({ player, engine, terminal }: IProps): React.ReactEleme
|
||||
<InteractiveTutorialRoot />
|
||||
)}
|
||||
</Overview>
|
||||
{page === Page.BitVerse ? (
|
||||
{page === Page.Recovery ? (
|
||||
<RecoveryRoot router={Router} />
|
||||
) : page === Page.BitVerse ? (
|
||||
<BitverseRoot flume={flume} enter={enterBitNode} quick={quick} />
|
||||
) : page === Page.Infiltration ? (
|
||||
<InfiltrationRoot location={location} />
|
||||
|
@ -14,6 +14,7 @@ import { Engine } from "../engine";
|
||||
import { GameRoot } from "./GameRoot";
|
||||
|
||||
import { CONSTANTS } from "../Constants";
|
||||
import { ActivateRecoveryMode } from "./React/RecoveryRoot";
|
||||
|
||||
const useStyles = makeStyles((theme: Theme) =>
|
||||
createStyles({
|
||||
@ -39,7 +40,14 @@ export function LoadingScreen(): React.ReactElement {
|
||||
async function doLoad(): Promise<void> {
|
||||
await load()
|
||||
.then((saveString) => {
|
||||
Engine.load(saveString);
|
||||
try {
|
||||
Engine.load(saveString);
|
||||
} catch (err: any) {
|
||||
ActivateRecoveryMode();
|
||||
setLoaded(true);
|
||||
throw err;
|
||||
}
|
||||
|
||||
setLoaded(true);
|
||||
})
|
||||
.catch((reason) => {
|
||||
|
@ -35,7 +35,8 @@ export function Overview({ children }: IProps): React.ReactElement {
|
||||
const [open, setOpen] = useState(true);
|
||||
const classes = useStyles();
|
||||
const router = use.Router();
|
||||
if (router.page() === Page.BitVerse || router.page() === Page.Loading) return <></>;
|
||||
if (router.page() === Page.BitVerse || router.page() === Page.Loading || router.page() === Page.Recovery)
|
||||
return <></>;
|
||||
let icon;
|
||||
if (open) {
|
||||
icon = <VisibilityOffIcon color="primary" />;
|
||||
@ -51,4 +52,4 @@ export function Overview({ children }: IProps): React.ReactElement {
|
||||
</Fab>
|
||||
</Paper>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
50
src/ui/React/RecoveryRoot.tsx
Normal file
50
src/ui/React/RecoveryRoot.tsx
Normal file
@ -0,0 +1,50 @@
|
||||
import React from "react";
|
||||
import Typography from "@mui/material/Typography";
|
||||
import Link from "@mui/material/Link";
|
||||
import Button from "@mui/material/Button";
|
||||
import { Settings } from "../../Settings/Settings";
|
||||
import { saveObject } from "../../SaveObject";
|
||||
import { IRouter } from "../Router";
|
||||
|
||||
export let RecoveryMode = false;
|
||||
|
||||
export function ActivateRecoveryMode(): void {
|
||||
RecoveryMode = true;
|
||||
}
|
||||
|
||||
interface IProps {
|
||||
router: IRouter;
|
||||
}
|
||||
|
||||
export function RecoveryRoot({ router }: IProps): React.ReactElement {
|
||||
function recover(): void {
|
||||
RecoveryMode = false;
|
||||
router.toTerminal();
|
||||
}
|
||||
Settings.AutosaveInterval = 0;
|
||||
saveObject.exportGame();
|
||||
return (
|
||||
<>
|
||||
<Typography variant="h3">RECOVERY MODE ACTIVATED</Typography>
|
||||
<Typography>
|
||||
There was an error loading your save file and the game went into recovery mode. In this mode saving is disabled
|
||||
and the game will automatically export your save file (to prevent corruption).
|
||||
</Typography>
|
||||
<Typography>At this point it is recommended to alert a developer.</Typography>
|
||||
<Link href="https://github.com/danielyxie/bitburner/issues/new" target="_blank">
|
||||
<Typography>File an issue on github</Typography>
|
||||
</Link>
|
||||
<Link href="https://www.reddit.com/r/Bitburner/" target="_blank">
|
||||
<Typography>Make a reddit post</Typography>
|
||||
</Link>
|
||||
<Link href="https://discord.gg/TFc3hKD" target="_blank">
|
||||
<Typography>Post in the #bug-report channel on Discord.</Typography>
|
||||
</Link>
|
||||
<Typography>Please include your save file.</Typography>
|
||||
<br />
|
||||
<br />
|
||||
<Typography>You can disable recovery mode now. But chances are the game will not work correctly.</Typography>
|
||||
<Button onClick={recover}>DISABLE RECOVERY MODE</Button>
|
||||
</>
|
||||
);
|
||||
}
|
@ -34,6 +34,7 @@ export enum Page {
|
||||
BladeburnerCinematic,
|
||||
Location,
|
||||
Loading,
|
||||
Recovery,
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user