From 8d793ea27171e53371854b11330069f3a316c80c Mon Sep 17 00:00:00 2001 From: David Walker Date: Sun, 4 Dec 2022 00:14:06 -0800 Subject: [PATCH] Internal refactoring of Router (#241) --- src/Augmentation/AugmentationHelpers.tsx | 3 +- src/Bladeburner/ui/BladeburnerCinematic.tsx | 3 +- .../ui/modals/CreateCorporationModal.tsx | 5 +- src/Faction/FactionInfo.tsx | 5 +- src/Faction/ui/CreateGangModal.tsx | 3 +- src/Faction/ui/FactionRoot.tsx | 7 +- src/Faction/ui/GangButton.tsx | 3 +- src/GameOptions/ui/GameOptionsSidebar.tsx | 3 +- src/Infiltration/ui/Game.tsx | 5 +- src/Infiltration/ui/InfiltrationRoot.tsx | 3 +- src/Infiltration/ui/Victory.tsx | 3 +- src/Locations/ui/City.tsx | 5 +- src/Locations/ui/CompanyLocation.tsx | 3 +- src/Locations/ui/GenericLocation.tsx | 3 +- src/Locations/ui/GymLocation.tsx | 3 +- src/Locations/ui/SlumsLocation.tsx | 3 +- src/Locations/ui/SpecialLocation.tsx | 9 +- src/Locations/ui/TravelAgencyRoot.tsx | 3 +- src/Locations/ui/UniversityLocation.tsx | 3 +- src/NetscriptFunctions/Grafting.ts | 5 +- src/NetscriptFunctions/Singularity.ts | 40 +-- .../Grafting/ui/GraftingRoot.tsx | 3 +- src/Programs/ui/ProgramsRoot.tsx | 3 +- src/RedPill.tsx | 5 +- src/ScriptEditor/ui/ScriptEditorRoot.tsx | 17 +- src/Sidebar/ui/SidebarRoot.tsx | 282 ++++++++---------- src/Themes/ui/ThemeEditorModal.tsx | 3 +- src/engine.tsx | 2 +- src/ui/GameRoot.tsx | 94 ++---- src/ui/React/CharacterOverview.tsx | 3 +- src/ui/React/ImportSaveRoot.tsx | 3 +- src/ui/React/RecoveryRoot.tsx | 3 +- src/ui/Router.ts | 112 +++---- src/ui/WorkInProgressRoot.tsx | 21 +- src/utils/ErrorHelper.ts | 4 +- 35 files changed, 292 insertions(+), 383 deletions(-) diff --git a/src/Augmentation/AugmentationHelpers.tsx b/src/Augmentation/AugmentationHelpers.tsx index 6207716d7..96648f5f9 100644 --- a/src/Augmentation/AugmentationHelpers.tsx +++ b/src/Augmentation/AugmentationHelpers.tsx @@ -21,6 +21,7 @@ import { initUnstableCircadianModulator, } from "./data/AugmentationCreator"; import { Router } from "../ui/GameRoot"; +import { Page } from "../ui/Router"; import { mergeMultipliers } from "../PersonObjects/Multipliers"; export function AddToStaticAugmentations(aug: Augmentation): void { @@ -138,7 +139,7 @@ function installAugmentations(force?: boolean): boolean { ); } prestigeAugmentation(); - Router.toTerminal(); + Router.toPage(Page.Terminal); return true; } diff --git a/src/Bladeburner/ui/BladeburnerCinematic.tsx b/src/Bladeburner/ui/BladeburnerCinematic.tsx index 8ce17ea5c..e58cd31f1 100644 --- a/src/Bladeburner/ui/BladeburnerCinematic.tsx +++ b/src/Bladeburner/ui/BladeburnerCinematic.tsx @@ -1,6 +1,7 @@ import React from "react"; import { FactionNames } from "../../Faction/data/FactionNames"; import { Router } from "../../ui/GameRoot"; +import { Page } from "../../ui/Router"; import { CinematicText } from "../../ui/React/CinematicText"; import { dialogBoxCreate } from "../../ui/React/DialogBox"; @@ -31,7 +32,7 @@ export function BladeburnerCinematic(): React.ReactElement { "investigating and dealing with Synthoid threats.", ]} onDone={() => { - Router.toTerminal(); + Router.toPage(Page.Terminal); dialogBoxCreate( `Visit the National Security Agency (NSA) to apply for their ${FactionNames.Bladeburners} ` + "division! You will need 100 of each combat stat before doing this.", diff --git a/src/Corporation/ui/modals/CreateCorporationModal.tsx b/src/Corporation/ui/modals/CreateCorporationModal.tsx index 14082a716..c852e30f7 100644 --- a/src/Corporation/ui/modals/CreateCorporationModal.tsx +++ b/src/Corporation/ui/modals/CreateCorporationModal.tsx @@ -3,6 +3,7 @@ import React, { useState } from "react"; import { Money } from "../../../ui/React/Money"; import { Modal } from "../../../ui/React/Modal"; import { Router } from "../../../ui/GameRoot"; +import { Page } from "../../../ui/Router"; import { Player } from "@player"; import Typography from "@mui/material/Typography"; import Button from "@mui/material/Button"; @@ -33,7 +34,7 @@ export function CreateCorporationModal(props: IProps): React.ReactElement { Player.loseMoney(150e9, "corporation"); props.onClose(); - Router.toCorporation(); + Router.toPage(Page.Corporation); } function seed(): void { @@ -44,7 +45,7 @@ export function CreateCorporationModal(props: IProps): React.ReactElement { Player.startCorporation(name, 500e6); props.onClose(); - Router.toCorporation(); + Router.toPage(Page.Corporation); } return ( diff --git a/src/Faction/FactionInfo.tsx b/src/Faction/FactionInfo.tsx index 2599c8310..2227e1250 100644 --- a/src/Faction/FactionInfo.tsx +++ b/src/Faction/FactionInfo.tsx @@ -1,6 +1,7 @@ import React from "react"; import { FactionNames } from "./data/FactionNames"; import { Router } from "../ui/GameRoot"; +import { Page } from "../ui/Router"; import { Option } from "./ui/Option"; import { Typography } from "@mui/material"; @@ -432,7 +433,7 @@ export const FactionInfos: Record = {