2023-06-12 06:34:20 +02:00
|
|
|
import type { ScriptFilePath } from "../Paths/ScriptFilePath";
|
|
|
|
import type { TextFilePath } from "../Paths/TextFilePath";
|
|
|
|
|
2021-09-20 05:29:02 +02:00
|
|
|
import React, { useState, useEffect } from "react";
|
2023-06-12 06:34:20 +02:00
|
|
|
import { createStyles, makeStyles } from "@mui/styles";
|
|
|
|
import { Box, Typography } from "@mui/material";
|
|
|
|
import { Theme } from "@mui/material/styles";
|
2022-01-13 00:49:53 +01:00
|
|
|
|
2022-10-10 00:42:14 +02:00
|
|
|
import { Player } from "@player";
|
2021-09-17 08:04:44 +02:00
|
|
|
import { installAugmentations } from "../Augmentation/AugmentationHelpers";
|
2021-09-21 22:49:38 +02:00
|
|
|
import { saveObject } from "../SaveObject";
|
2021-09-17 08:04:44 +02:00
|
|
|
import { onExport } from "../ExportBonus";
|
2023-06-12 06:34:20 +02:00
|
|
|
import { LocationName } from "@enums";
|
2021-09-18 10:01:07 +02:00
|
|
|
import { Location } from "../Locations/Location";
|
2021-12-14 00:44:52 +01:00
|
|
|
import { ITutorial, iTutorialStart } from "../InteractiveTutorial";
|
2021-09-19 06:46:39 +02:00
|
|
|
import { InteractiveTutorialRoot } from "./InteractiveTutorial/InteractiveTutorialRoot";
|
|
|
|
import { ITutorialEvents } from "./InteractiveTutorial/ITutorialEvents";
|
2021-09-18 10:01:07 +02:00
|
|
|
|
2021-09-17 08:04:44 +02:00
|
|
|
import { Faction } from "../Faction/Faction";
|
|
|
|
import { prestigeAugmentation } from "../Prestige";
|
2021-09-25 20:42:57 +02:00
|
|
|
import { dialogBoxCreate } from "./React/DialogBox";
|
2021-10-07 22:04:04 +02:00
|
|
|
import { GetAllServers } from "../Server/AllServers";
|
2021-09-18 01:43:08 +02:00
|
|
|
import { Factions } from "../Faction/Factions";
|
2022-08-21 01:14:54 +02:00
|
|
|
import { StockMarket } from "../StockMarket/StockMarket";
|
2021-09-17 08:04:44 +02:00
|
|
|
|
FILES: Path rework & typesafety (#479)
* Added new types for various file paths, all in the Paths folder.
* TypeSafety and other helper functions related to these types
* Added basic globbing support with * and ?. Currently only implemented for Script/Text, on nano and download terminal commands
* Enforcing the new types throughout the codebase, plus whatever rewrites happened along the way
* Server.textFiles is now a map
* TextFile no longer uses a fn property, now it is filename
* Added a shared ContentFile interface for shared functionality between TextFile and Script.
* related to ContentFile change above, the player is now allowed to move a text file to a script file and vice versa.
* File paths no longer conditionally start with slashes, and all directory names other than root have ending slashes. The player is still able to provide paths starting with / but this now indicates that the player is specifying an absolute path instead of one relative to root.
* Singularized the MessageFilename and LiteratureName enums
* Because they now only accept correct types, server.writeToXFile functions now always succeed (the only reasons they could fail before were invalid filepath).
* Fix several issues with tab completion, which included pretty much a complete rewrite
* Changed the autocomplete display options so there's less chance it clips outside the display area.
* Turned CompletedProgramName into an enum.
* Got rid of programsMetadata, and programs and DarkWebItems are now initialized immediately instead of relying on initializers called from the engine.
* For any executable (program, cct, or script file) pathing can be used directly to execute without using the run command (previously the command had to start with ./ and it wasn't actually using pathing).
2023-04-24 16:26:57 +02:00
|
|
|
import { Page, SimplePage, IRouter } from "./Router";
|
2021-09-19 06:46:39 +02:00
|
|
|
import { Overview } from "./React/Overview";
|
2021-09-17 08:04:44 +02:00
|
|
|
import { SidebarRoot } from "../Sidebar/ui/SidebarRoot";
|
2021-09-18 01:43:08 +02:00
|
|
|
import { AugmentationsRoot } from "../Augmentation/ui/AugmentationsRoot";
|
2021-09-17 08:04:44 +02:00
|
|
|
import { DevMenuRoot } from "../DevMenu";
|
2021-09-18 01:43:08 +02:00
|
|
|
import { BladeburnerRoot } from "../Bladeburner/ui/BladeburnerRoot";
|
|
|
|
import { GangRoot } from "../Gang/ui/GangRoot";
|
2021-09-17 08:04:44 +02:00
|
|
|
import { CorporationRoot } from "../Corporation/ui/CorporationRoot";
|
2021-09-18 01:43:08 +02:00
|
|
|
import { InfiltrationRoot } from "../Infiltration/ui/InfiltrationRoot";
|
2022-03-19 05:22:21 +01:00
|
|
|
import { GraftingRoot } from "../PersonObjects/Grafting/ui/GraftingRoot";
|
2021-09-18 01:43:08 +02:00
|
|
|
import { WorkInProgressRoot } from "./WorkInProgressRoot";
|
2022-04-17 19:51:14 +02:00
|
|
|
import { GameOptionsRoot } from "../GameOptions/ui/GameOptionsRoot";
|
2021-09-17 08:04:44 +02:00
|
|
|
import { SleeveRoot } from "../PersonObjects/Sleeve/ui/SleeveRoot";
|
|
|
|
import { HacknetRoot } from "../Hacknet/ui/HacknetRoot";
|
2021-09-18 10:01:07 +02:00
|
|
|
import { GenericLocation } from "../Locations/ui/GenericLocation";
|
|
|
|
import { LocationCity } from "../Locations/ui/City";
|
2021-09-17 08:04:44 +02:00
|
|
|
import { ProgramsRoot } from "../Programs/ui/ProgramsRoot";
|
2023-06-03 19:55:25 +02:00
|
|
|
import { ScriptEditorRoot } from "../ScriptEditor/ui/ScriptEditorRoot";
|
2021-09-17 08:04:44 +02:00
|
|
|
import { MilestonesRoot } from "../Milestones/ui/MilestonesRoot";
|
|
|
|
import { TerminalRoot } from "../Terminal/ui/TerminalRoot";
|
|
|
|
import { TutorialRoot } from "../Tutorial/ui/TutorialRoot";
|
2022-03-06 05:05:55 +01:00
|
|
|
import { ActiveScriptsRoot } from "./ActiveScripts/ActiveScriptsRoot";
|
2021-09-17 08:04:44 +02:00
|
|
|
import { FactionsRoot } from "../Faction/ui/FactionsRoot";
|
|
|
|
import { FactionRoot } from "../Faction/ui/FactionRoot";
|
2021-09-18 18:13:20 +02:00
|
|
|
import { CharacterStats } from "./CharacterStats";
|
2021-09-17 08:04:44 +02:00
|
|
|
import { TravelAgencyRoot } from "../Locations/ui/TravelAgencyRoot";
|
2021-09-17 08:31:19 +02:00
|
|
|
import { StockMarketRoot } from "../StockMarket/ui/StockMarketRoot";
|
2021-09-18 01:43:08 +02:00
|
|
|
import { BitverseRoot } from "../BitNode/ui/BitverseRoot";
|
2021-09-25 23:21:50 +02:00
|
|
|
import { StaneksGiftRoot } from "../CotMG/ui/StaneksGiftRoot";
|
|
|
|
import { staneksGift } from "../CotMG/Helper";
|
2021-09-18 01:43:08 +02:00
|
|
|
import { CharacterOverview } from "./React/CharacterOverview";
|
|
|
|
import { BladeburnerCinematic } from "../Bladeburner/ui/BladeburnerCinematic";
|
2021-09-17 08:04:44 +02:00
|
|
|
import { workerScripts } from "../Netscript/WorkerScripts";
|
2021-09-25 20:00:38 +02:00
|
|
|
import { Unclickable } from "../Exploits/Unclickable";
|
2021-10-13 23:25:58 +02:00
|
|
|
import { Snackbar, SnackbarProvider } from "./React/Snackbar";
|
2021-10-01 07:00:50 +02:00
|
|
|
import { LogBoxManager } from "./React/LogBoxManager";
|
|
|
|
import { AlertManager } from "./React/AlertManager";
|
2021-10-02 04:53:23 +02:00
|
|
|
import { PromptManager } from "./React/PromptManager";
|
2021-10-01 19:08:37 +02:00
|
|
|
import { InvitationModal } from "../Faction/ui/InvitationModal";
|
2022-01-20 22:59:54 +01:00
|
|
|
import { calculateAchievements } from "../Achievements/Achievements";
|
2021-09-17 08:04:44 +02:00
|
|
|
|
2021-11-02 22:28:19 +01:00
|
|
|
import { RecoveryMode, RecoveryRoot } from "./React/RecoveryRoot";
|
2022-01-06 13:04:03 +01:00
|
|
|
import { AchievementsRoot } from "../Achievements/AchievementsRoot";
|
2022-01-11 07:50:41 +01:00
|
|
|
import { ErrorBoundary } from "./ErrorBoundary";
|
2022-01-19 15:49:08 +01:00
|
|
|
import { ThemeBrowser } from "../Themes/ui/ThemeBrowser";
|
2022-01-20 20:55:28 +01:00
|
|
|
import { ImportSaveRoot } from "./React/ImportSaveRoot";
|
|
|
|
import { BypassWrapper } from "./React/BypassWrapper";
|
2021-09-17 08:04:44 +02:00
|
|
|
|
2022-03-31 18:04:06 +02:00
|
|
|
import { Apr1 } from "./Apr1";
|
2022-07-12 07:54:19 +02:00
|
|
|
import { isFactionWork } from "../Work/FactionWork";
|
2022-07-26 21:09:11 +02:00
|
|
|
import { V2Modal } from "../utils/V2Modal";
|
2023-01-03 13:38:14 +01:00
|
|
|
import { MathJaxContext } from "better-react-mathjax";
|
2023-02-11 19:22:55 +01:00
|
|
|
import { useRerender } from "./React/hooks";
|
2022-01-22 16:53:16 +01:00
|
|
|
|
2021-10-26 21:50:55 +02:00
|
|
|
const htmlLocation = location;
|
|
|
|
|
2021-09-17 08:04:44 +02:00
|
|
|
const useStyles = makeStyles((theme: Theme) =>
|
|
|
|
createStyles({
|
|
|
|
root: {
|
|
|
|
"-ms-overflow-style": "none" /* for Internet Explorer, Edge */,
|
|
|
|
"scrollbar-width": "none" /* for Firefox */,
|
2021-09-18 01:43:08 +02:00
|
|
|
margin: theme.spacing(0),
|
2022-01-09 17:15:09 +01:00
|
|
|
flexGrow: 1,
|
|
|
|
padding: "8px",
|
|
|
|
minHeight: "100vh",
|
2022-01-16 00:13:35 +01:00
|
|
|
boxSizing: "border-box",
|
2022-08-16 08:32:25 +02:00
|
|
|
width: "1px",
|
2021-09-17 08:04:44 +02:00
|
|
|
},
|
|
|
|
}),
|
|
|
|
);
|
|
|
|
|
2022-07-15 07:51:30 +02:00
|
|
|
const uninitialized = (): void => {
|
2022-03-11 21:19:10 +01:00
|
|
|
throw new Error("Router called before initialization");
|
|
|
|
};
|
|
|
|
|
2021-09-18 01:43:08 +02:00
|
|
|
export let Router: IRouter = {
|
2022-03-09 21:44:19 +01:00
|
|
|
isInitialized: false,
|
2022-07-15 07:51:30 +02:00
|
|
|
page: () => {
|
|
|
|
throw new Error("Router called before initialization");
|
|
|
|
},
|
2022-03-11 21:19:10 +01:00
|
|
|
allowRouting: uninitialized,
|
2022-12-04 09:14:06 +01:00
|
|
|
toPage: () => {
|
|
|
|
throw new Error("Router called before initialization");
|
|
|
|
},
|
2022-03-11 21:19:10 +01:00
|
|
|
toBitVerse: uninitialized,
|
|
|
|
toFaction: uninitialized,
|
|
|
|
toInfiltration: uninitialized,
|
|
|
|
toJob: uninitialized,
|
|
|
|
toScriptEditor: uninitialized,
|
|
|
|
toLocation: uninitialized,
|
|
|
|
toImportSave: uninitialized,
|
2021-09-18 01:43:08 +02:00
|
|
|
};
|
|
|
|
|
2022-08-29 08:41:17 +02:00
|
|
|
function determineStartPage(): Page {
|
2021-11-02 22:28:19 +01:00
|
|
|
if (RecoveryMode) return Page.Recovery;
|
2022-08-29 08:41:17 +02:00
|
|
|
if (Player.currentWork !== null) return Page.Work;
|
2021-09-18 01:43:08 +02:00
|
|
|
return Page.Terminal;
|
|
|
|
}
|
|
|
|
|
2022-08-29 08:41:17 +02:00
|
|
|
export function GameRoot(): React.ReactElement {
|
2021-09-17 08:04:44 +02:00
|
|
|
const classes = useStyles();
|
FILES: Path rework & typesafety (#479)
* Added new types for various file paths, all in the Paths folder.
* TypeSafety and other helper functions related to these types
* Added basic globbing support with * and ?. Currently only implemented for Script/Text, on nano and download terminal commands
* Enforcing the new types throughout the codebase, plus whatever rewrites happened along the way
* Server.textFiles is now a map
* TextFile no longer uses a fn property, now it is filename
* Added a shared ContentFile interface for shared functionality between TextFile and Script.
* related to ContentFile change above, the player is now allowed to move a text file to a script file and vice versa.
* File paths no longer conditionally start with slashes, and all directory names other than root have ending slashes. The player is still able to provide paths starting with / but this now indicates that the player is specifying an absolute path instead of one relative to root.
* Singularized the MessageFilename and LiteratureName enums
* Because they now only accept correct types, server.writeToXFile functions now always succeed (the only reasons they could fail before were invalid filepath).
* Fix several issues with tab completion, which included pretty much a complete rewrite
* Changed the autocomplete display options so there's less chance it clips outside the display area.
* Turned CompletedProgramName into an enum.
* Got rid of programsMetadata, and programs and DarkWebItems are now initialized immediately instead of relying on initializers called from the engine.
* For any executable (program, cct, or script file) pathing can be used directly to execute without using the run command (previously the command had to start with ./ and it wasn't actually using pathing).
2023-04-24 16:26:57 +02:00
|
|
|
const [{ files, vim }, setEditorOptions] = useState<{
|
|
|
|
files: Map<ScriptFilePath | TextFilePath, string>;
|
|
|
|
vim: boolean;
|
|
|
|
}>({
|
|
|
|
files: new Map(),
|
|
|
|
vim: false,
|
|
|
|
});
|
2022-08-29 08:41:17 +02:00
|
|
|
const [page, setPage] = useState(determineStartPage());
|
2023-02-11 19:22:55 +01:00
|
|
|
const rerender = useRerender();
|
2022-03-11 01:37:57 +01:00
|
|
|
const [augPage, setAugPage] = useState<boolean>(false);
|
2021-09-18 10:01:07 +02:00
|
|
|
const [faction, setFaction] = useState<Faction>(
|
2022-08-29 08:41:17 +02:00
|
|
|
isFactionWork(Player.currentWork) ? Factions[Player.currentWork.factionName] : (undefined as unknown as Faction),
|
2021-09-18 01:43:08 +02:00
|
|
|
);
|
2021-09-18 10:01:07 +02:00
|
|
|
if (faction === undefined && page === Page.Faction)
|
|
|
|
throw new Error("Trying to go to a page without the proper setup");
|
2021-09-17 08:04:44 +02:00
|
|
|
|
2021-09-18 01:43:08 +02:00
|
|
|
const [flume, setFlume] = useState<boolean>(false);
|
|
|
|
const [quick, setQuick] = useState<boolean>(false);
|
2021-09-18 10:01:07 +02:00
|
|
|
const [location, setLocation] = useState<Location>(undefined as unknown as Location);
|
|
|
|
if (location === undefined && (page === Page.Infiltration || page === Page.Location || page === Page.Job))
|
|
|
|
throw new Error("Trying to go to a page without the proper setup");
|
2021-09-18 01:43:08 +02:00
|
|
|
|
|
|
|
const [cinematicText, setCinematicText] = useState("");
|
2022-01-11 07:50:41 +01:00
|
|
|
const [errorBoundaryKey, setErrorBoundaryKey] = useState<number>(0);
|
|
|
|
|
2022-01-20 20:55:28 +01:00
|
|
|
const [importString, setImportString] = useState<string>(undefined as unknown as string);
|
|
|
|
const [importAutomatic, setImportAutomatic] = useState<boolean>(false);
|
|
|
|
if (importString === undefined && page === Page.ImportSave)
|
|
|
|
throw new Error("Trying to go to a page without the proper setup");
|
|
|
|
|
2022-01-22 16:53:16 +01:00
|
|
|
const [allowRoutingCalls, setAllowRoutingCalls] = useState(true);
|
|
|
|
|
2022-01-11 07:50:41 +01:00
|
|
|
function resetErrorBoundary(): void {
|
2022-01-16 00:13:35 +01:00
|
|
|
setErrorBoundaryKey(errorBoundaryKey + 1);
|
2022-01-11 07:50:41 +01:00
|
|
|
}
|
2021-09-18 01:43:08 +02:00
|
|
|
|
2021-09-19 06:46:39 +02:00
|
|
|
useEffect(() => {
|
|
|
|
return ITutorialEvents.subscribe(rerender);
|
|
|
|
}, []);
|
|
|
|
|
2021-10-26 21:50:55 +02:00
|
|
|
function killAllScripts(): void {
|
|
|
|
for (const server of GetAllServers()) {
|
2023-04-28 00:21:06 +02:00
|
|
|
server.runningScriptMap.clear();
|
2021-10-26 21:50:55 +02:00
|
|
|
}
|
|
|
|
saveObject.saveGame();
|
|
|
|
setTimeout(() => htmlLocation.reload(), 2000);
|
|
|
|
}
|
|
|
|
|
2023-05-05 09:55:59 +02:00
|
|
|
function attemptedForbiddenRouting(name: string) {
|
|
|
|
console.error(`Routing is currently disabled - Attempted router.${name}()`);
|
|
|
|
}
|
|
|
|
|
2021-09-18 01:43:08 +02:00
|
|
|
Router = {
|
2022-03-09 21:44:19 +01:00
|
|
|
isInitialized: true,
|
2021-09-18 01:43:08 +02:00
|
|
|
page: () => page,
|
2022-01-22 16:53:16 +01:00
|
|
|
allowRouting: (value: boolean) => setAllowRoutingCalls(value),
|
2022-12-04 09:14:06 +01:00
|
|
|
toPage: (page: SimplePage) => {
|
2023-05-05 09:55:59 +02:00
|
|
|
if (!allowRoutingCalls) return attemptedForbiddenRouting("toPage");
|
2022-12-04 09:14:06 +01:00
|
|
|
switch (page) {
|
|
|
|
case Page.Travel:
|
|
|
|
Player.gotoLocation(LocationName.TravelAgency);
|
|
|
|
break;
|
|
|
|
case Page.BladeburnerCinematic:
|
|
|
|
setPage(page);
|
|
|
|
setCinematicText(cinematicText);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
setPage(page);
|
|
|
|
},
|
2022-03-11 01:37:57 +01:00
|
|
|
toFaction: (faction: Faction, augPage = false) => {
|
2023-05-05 09:55:59 +02:00
|
|
|
if (!allowRoutingCalls) return attemptedForbiddenRouting("toFaction");
|
2022-03-11 01:37:57 +01:00
|
|
|
setAugPage(augPage);
|
2022-01-13 00:49:53 +01:00
|
|
|
setPage(Page.Faction);
|
2021-09-18 01:43:08 +02:00
|
|
|
if (faction) setFaction(faction);
|
2021-09-17 08:04:44 +02:00
|
|
|
},
|
FILES: Path rework & typesafety (#479)
* Added new types for various file paths, all in the Paths folder.
* TypeSafety and other helper functions related to these types
* Added basic globbing support with * and ?. Currently only implemented for Script/Text, on nano and download terminal commands
* Enforcing the new types throughout the codebase, plus whatever rewrites happened along the way
* Server.textFiles is now a map
* TextFile no longer uses a fn property, now it is filename
* Added a shared ContentFile interface for shared functionality between TextFile and Script.
* related to ContentFile change above, the player is now allowed to move a text file to a script file and vice versa.
* File paths no longer conditionally start with slashes, and all directory names other than root have ending slashes. The player is still able to provide paths starting with / but this now indicates that the player is specifying an absolute path instead of one relative to root.
* Singularized the MessageFilename and LiteratureName enums
* Because they now only accept correct types, server.writeToXFile functions now always succeed (the only reasons they could fail before were invalid filepath).
* Fix several issues with tab completion, which included pretty much a complete rewrite
* Changed the autocomplete display options so there's less chance it clips outside the display area.
* Turned CompletedProgramName into an enum.
* Got rid of programsMetadata, and programs and DarkWebItems are now initialized immediately instead of relying on initializers called from the engine.
* For any executable (program, cct, or script file) pathing can be used directly to execute without using the run command (previously the command had to start with ./ and it wasn't actually using pathing).
2023-04-24 16:26:57 +02:00
|
|
|
toScriptEditor: (files = new Map(), options) => {
|
2023-05-05 09:55:59 +02:00
|
|
|
if (!allowRoutingCalls) return attemptedForbiddenRouting("toScriptEditor");
|
2021-12-20 18:42:47 +01:00
|
|
|
setEditorOptions({
|
|
|
|
files,
|
|
|
|
vim: !!options?.vim,
|
|
|
|
});
|
2022-01-13 00:49:53 +01:00
|
|
|
setPage(Page.ScriptEditor);
|
2021-09-17 08:58:02 +02:00
|
|
|
},
|
2022-07-19 20:21:12 +02:00
|
|
|
toJob: (location: Location) => {
|
2023-05-05 09:55:59 +02:00
|
|
|
if (!allowRoutingCalls) return attemptedForbiddenRouting("toJob");
|
2022-07-19 20:21:12 +02:00
|
|
|
setLocation(location);
|
2022-01-13 00:49:53 +01:00
|
|
|
setPage(Page.Job);
|
2021-09-17 08:31:19 +02:00
|
|
|
},
|
2021-09-18 01:43:08 +02:00
|
|
|
toBitVerse: (flume: boolean, quick: boolean) => {
|
2023-05-05 09:55:59 +02:00
|
|
|
if (!allowRoutingCalls) return attemptedForbiddenRouting("toBitVerse");
|
2021-09-18 01:43:08 +02:00
|
|
|
setFlume(flume);
|
|
|
|
setQuick(quick);
|
2022-01-20 22:59:54 +01:00
|
|
|
calculateAchievements();
|
2022-01-13 00:49:53 +01:00
|
|
|
setPage(Page.BitVerse);
|
2021-09-18 01:43:08 +02:00
|
|
|
},
|
2021-09-18 10:01:07 +02:00
|
|
|
toInfiltration: (location: Location) => {
|
2023-05-05 09:55:59 +02:00
|
|
|
if (!allowRoutingCalls) return attemptedForbiddenRouting("toInfiltration");
|
2021-09-18 01:43:08 +02:00
|
|
|
setLocation(location);
|
2022-01-13 00:49:53 +01:00
|
|
|
setPage(Page.Infiltration);
|
2021-09-18 01:43:08 +02:00
|
|
|
},
|
2021-09-18 10:01:07 +02:00
|
|
|
toLocation: (location: Location) => {
|
2023-05-05 09:55:59 +02:00
|
|
|
if (!allowRoutingCalls) return attemptedForbiddenRouting("toLocation");
|
2021-09-18 10:01:07 +02:00
|
|
|
setLocation(location);
|
2022-01-13 00:49:53 +01:00
|
|
|
setPage(Page.Location);
|
2021-09-18 10:01:07 +02:00
|
|
|
},
|
2022-01-20 20:55:28 +01:00
|
|
|
toImportSave: (base64save: string, automatic = false) => {
|
2023-05-05 09:55:59 +02:00
|
|
|
if (!allowRoutingCalls) return attemptedForbiddenRouting("toImportSave");
|
2022-01-20 20:55:28 +01:00
|
|
|
setImportString(base64save);
|
|
|
|
setImportAutomatic(automatic);
|
|
|
|
setPage(Page.ImportSave);
|
|
|
|
},
|
2021-09-17 08:04:44 +02:00
|
|
|
};
|
|
|
|
|
2021-09-17 08:58:02 +02:00
|
|
|
useEffect(() => {
|
2021-09-19 06:46:39 +02:00
|
|
|
if (page !== Page.Terminal) window.scrollTo(0, 0);
|
2021-09-17 08:58:02 +02:00
|
|
|
});
|
|
|
|
|
2022-01-11 07:50:41 +01:00
|
|
|
function softReset(): void {
|
|
|
|
dialogBoxCreate("Soft Reset!");
|
2022-04-08 06:28:37 +02:00
|
|
|
installAugmentations(true);
|
2022-01-11 07:50:41 +01:00
|
|
|
resetErrorBoundary();
|
2022-12-04 09:14:06 +01:00
|
|
|
Router.toPage(Page.Terminal);
|
2022-01-11 07:50:41 +01:00
|
|
|
}
|
|
|
|
|
2022-01-08 21:15:28 +01:00
|
|
|
let mainPage = <Typography>Cannot load</Typography>;
|
|
|
|
let withSidebar = true;
|
2022-01-08 21:25:41 +01:00
|
|
|
let withPopups = true;
|
2022-01-20 20:55:28 +01:00
|
|
|
let bypassGame = false;
|
2022-01-08 21:15:28 +01:00
|
|
|
switch (page) {
|
|
|
|
case Page.Recovery: {
|
2022-09-06 15:07:12 +02:00
|
|
|
mainPage = <RecoveryRoot softReset={softReset} />;
|
2022-01-08 21:15:28 +01:00
|
|
|
withSidebar = false;
|
2022-01-08 21:25:41 +01:00
|
|
|
withPopups = false;
|
2022-01-20 20:55:28 +01:00
|
|
|
bypassGame = true;
|
2022-01-08 21:15:28 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case Page.BitVerse: {
|
2022-09-13 00:00:09 +02:00
|
|
|
mainPage = <BitverseRoot flume={flume} quick={quick} />;
|
2022-01-08 21:15:28 +01:00
|
|
|
withSidebar = false;
|
2022-01-08 21:25:41 +01:00
|
|
|
withPopups = false;
|
2022-01-09 17:15:09 +01:00
|
|
|
break;
|
2022-01-08 21:15:28 +01:00
|
|
|
}
|
|
|
|
case Page.Infiltration: {
|
|
|
|
mainPage = <InfiltrationRoot location={location} />;
|
|
|
|
withSidebar = false;
|
2022-01-08 21:25:41 +01:00
|
|
|
withPopups = false;
|
2022-01-08 21:15:28 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case Page.BladeburnerCinematic: {
|
|
|
|
mainPage = <BladeburnerCinematic />;
|
|
|
|
withSidebar = false;
|
2022-01-08 21:25:41 +01:00
|
|
|
withPopups = false;
|
2022-01-08 21:15:28 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case Page.Work: {
|
|
|
|
mainPage = <WorkInProgressRoot />;
|
|
|
|
withSidebar = false;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case Page.Terminal: {
|
2022-09-06 15:07:12 +02:00
|
|
|
mainPage = <TerminalRoot />;
|
2022-01-08 21:15:28 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case Page.Sleeves: {
|
|
|
|
mainPage = <SleeveRoot />;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case Page.StaneksGift: {
|
|
|
|
mainPage = <StaneksGiftRoot staneksGift={staneksGift} />;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case Page.Stats: {
|
|
|
|
mainPage = <CharacterStats />;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case Page.ScriptEditor: {
|
2022-09-06 15:07:12 +02:00
|
|
|
mainPage = <ScriptEditorRoot files={files} hostname={Player.getCurrentServer().hostname} vim={vim} />;
|
2022-01-08 21:15:28 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case Page.ActiveScripts: {
|
|
|
|
mainPage = <ActiveScriptsRoot workerScripts={workerScripts} />;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case Page.Hacknet: {
|
2022-09-06 15:07:12 +02:00
|
|
|
mainPage = <HacknetRoot />;
|
2022-01-08 21:15:28 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case Page.CreateProgram: {
|
|
|
|
mainPage = <ProgramsRoot />;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case Page.Factions: {
|
2022-09-06 15:07:12 +02:00
|
|
|
mainPage = <FactionsRoot />;
|
2022-01-08 21:15:28 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case Page.Faction: {
|
2022-03-11 01:37:57 +01:00
|
|
|
mainPage = <FactionRoot faction={faction} augPage={augPage} />;
|
2022-01-08 21:15:28 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case Page.Milestones: {
|
2022-09-06 15:07:12 +02:00
|
|
|
mainPage = <MilestonesRoot />;
|
2022-01-08 21:15:28 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case Page.Tutorial: {
|
2022-01-09 17:15:09 +01:00
|
|
|
mainPage = (
|
|
|
|
<TutorialRoot
|
|
|
|
reactivateTutorial={() => {
|
|
|
|
prestigeAugmentation();
|
2022-12-04 09:14:06 +01:00
|
|
|
Router.toPage(Page.Terminal);
|
2022-01-09 17:15:09 +01:00
|
|
|
iTutorialStart();
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
);
|
2022-01-08 21:15:28 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case Page.DevMenu: {
|
2022-09-06 15:07:12 +02:00
|
|
|
mainPage = <DevMenuRoot />;
|
2022-01-08 21:15:28 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case Page.Gang: {
|
|
|
|
mainPage = <GangRoot />;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case Page.Corporation: {
|
|
|
|
mainPage = <CorporationRoot />;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case Page.Bladeburner: {
|
|
|
|
mainPage = <BladeburnerRoot />;
|
|
|
|
break;
|
|
|
|
}
|
2022-03-19 05:22:21 +01:00
|
|
|
case Page.Grafting: {
|
|
|
|
mainPage = <GraftingRoot />;
|
2022-01-08 21:15:28 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case Page.Travel: {
|
2022-09-06 15:07:12 +02:00
|
|
|
mainPage = <TravelAgencyRoot />;
|
2022-01-08 21:15:28 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case Page.StockMarket: {
|
2022-09-06 15:07:12 +02:00
|
|
|
mainPage = <StockMarketRoot stockMarket={StockMarket} />;
|
2022-01-08 21:15:28 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case Page.City: {
|
|
|
|
mainPage = <LocationCity />;
|
|
|
|
break;
|
|
|
|
}
|
2022-01-09 17:15:09 +01:00
|
|
|
case Page.Job:
|
2022-01-08 21:15:28 +01:00
|
|
|
case Page.Location: {
|
|
|
|
mainPage = <GenericLocation loc={location} />;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case Page.Options: {
|
2022-01-09 17:15:09 +01:00
|
|
|
mainPage = (
|
|
|
|
<GameOptionsRoot
|
|
|
|
save={() => saveObject.saveGame()}
|
|
|
|
export={() => {
|
|
|
|
// Apply the export bonus before saving the game
|
2022-09-06 15:07:12 +02:00
|
|
|
onExport();
|
2022-01-09 17:15:09 +01:00
|
|
|
saveObject.exportGame();
|
|
|
|
}}
|
|
|
|
forceKill={killAllScripts}
|
2022-01-11 07:50:41 +01:00
|
|
|
softReset={softReset}
|
2022-01-09 17:15:09 +01:00
|
|
|
/>
|
|
|
|
);
|
2022-01-08 21:15:28 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case Page.Augmentations: {
|
2022-01-09 17:15:09 +01:00
|
|
|
mainPage = (
|
|
|
|
<AugmentationsRoot
|
|
|
|
exportGameFn={() => {
|
|
|
|
// Apply the export bonus before saving the game
|
2022-09-06 15:07:12 +02:00
|
|
|
onExport();
|
2022-01-09 17:15:09 +01:00
|
|
|
saveObject.exportGame();
|
|
|
|
}}
|
|
|
|
installAugmentationsFn={() => {
|
|
|
|
installAugmentations();
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
);
|
2022-01-08 21:15:28 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case Page.Achievements: {
|
|
|
|
mainPage = <AchievementsRoot />;
|
|
|
|
break;
|
|
|
|
}
|
2022-01-19 15:49:08 +01:00
|
|
|
case Page.ThemeBrowser: {
|
2022-09-06 15:07:12 +02:00
|
|
|
mainPage = <ThemeBrowser />;
|
2022-01-19 15:49:08 +01:00
|
|
|
break;
|
|
|
|
}
|
2022-01-20 20:55:28 +01:00
|
|
|
case Page.ImportSave: {
|
2022-09-06 15:07:12 +02:00
|
|
|
mainPage = <ImportSaveRoot importString={importString} automatic={importAutomatic} />;
|
2022-01-20 20:55:28 +01:00
|
|
|
withSidebar = false;
|
|
|
|
withPopups = false;
|
|
|
|
bypassGame = true;
|
|
|
|
}
|
2022-01-08 21:15:28 +01:00
|
|
|
}
|
2022-01-09 17:15:09 +01:00
|
|
|
|
2021-09-17 08:04:44 +02:00
|
|
|
return (
|
2023-01-03 13:38:14 +01:00
|
|
|
<MathJaxContext version={3} src={"dist/ext/MathJax-3.2.2/es5/tex-chtml.js"}>
|
2022-09-13 00:05:48 +02:00
|
|
|
<ErrorBoundary key={errorBoundaryKey} softReset={softReset}>
|
|
|
|
<BypassWrapper content={bypassGame ? mainPage : null}>
|
|
|
|
<SnackbarProvider>
|
|
|
|
<Overview mode={ITutorial.isRunning ? "tutorial" : "overview"}>
|
2022-12-22 00:27:51 +01:00
|
|
|
{(parentOpen) =>
|
|
|
|
!ITutorial.isRunning ? (
|
|
|
|
<CharacterOverview
|
|
|
|
parentOpen={parentOpen}
|
|
|
|
save={() => saveObject.saveGame()}
|
|
|
|
killScripts={killAllScripts}
|
|
|
|
/>
|
|
|
|
) : (
|
|
|
|
<InteractiveTutorialRoot />
|
|
|
|
)
|
|
|
|
}
|
2022-09-13 00:05:48 +02:00
|
|
|
</Overview>
|
|
|
|
{withSidebar ? (
|
|
|
|
<Box display="flex" flexDirection="row" width="100%">
|
2022-12-04 09:14:06 +01:00
|
|
|
<SidebarRoot page={page} />
|
2022-09-13 00:05:48 +02:00
|
|
|
<Box className={classes.root}>{mainPage}</Box>
|
|
|
|
</Box>
|
|
|
|
) : (
|
|
|
|
<Box className={classes.root}>{mainPage}</Box>
|
|
|
|
)}
|
|
|
|
<Unclickable />
|
|
|
|
{withPopups && (
|
|
|
|
<>
|
|
|
|
<LogBoxManager />
|
|
|
|
<AlertManager />
|
|
|
|
<PromptManager />
|
|
|
|
<InvitationModal />
|
|
|
|
<Snackbar />
|
|
|
|
</>
|
|
|
|
)}
|
|
|
|
<Apr1 />
|
|
|
|
</SnackbarProvider>
|
|
|
|
</BypassWrapper>
|
|
|
|
</ErrorBoundary>
|
|
|
|
<V2Modal />
|
2023-01-03 13:38:14 +01:00
|
|
|
</MathJaxContext>
|
2021-09-17 08:04:44 +02:00
|
|
|
);
|
|
|
|
}
|