Internal refactoring of Router (#241)

This commit is contained in:
David Walker
2022-12-04 00:14:06 -08:00
committed by GitHub
parent 897a1fbc8e
commit 8d793ea271
35 changed files with 292 additions and 383 deletions
+3 -2
View File
@@ -14,6 +14,7 @@ import { Settings } from "../../Settings/Settings";
import { Player } from "@player";
import { Router } from "../../ui/GameRoot";
import { Page } from "../../ui/Router";
import Typography from "@mui/material/Typography";
import Button from "@mui/material/Button";
import { LocationType } from "../LocationTypeEnum";
@@ -39,9 +40,9 @@ const useStyles = makeStyles((theme: Theme) =>
function toLocation(location: Location): void {
if (location.name === LocationName.TravelAgency) {
Router.toTravel();
Router.toPage(Page.Travel);
} else if (location.name === LocationName.WorldStockExchange) {
Router.toStockMarket();
Router.toPage(Page.StockMarket);
} else {
Router.toLocation(location);
}
+2 -1
View File
@@ -21,6 +21,7 @@ import * as posNames from "../../Company/data/companypositionnames";
import { Reputation } from "../../ui/React/Reputation";
import { Favor } from "../../ui/React/Favor";
import { Router } from "../../ui/GameRoot";
import { Page } from "../../ui/Router";
import { Player } from "@player";
import { QuitJobModal } from "../../Company/ui/QuitJobModal";
import { CompanyWork } from "../../Work/CompanyWork";
@@ -177,7 +178,7 @@ export function CompanyLocation(props: IProps): React.ReactElement {
}),
);
Player.startFocusing();
Router.toWork();
Router.toPage(Page.Work);
}
}
+2 -1
View File
@@ -28,6 +28,7 @@ import { GetServer } from "../../Server/AllServers";
import { CorruptableText } from "../../ui/React/CorruptableText";
import { Router } from "../../ui/GameRoot";
import { Page } from "../../ui/Router";
import { serverMetadata } from "../../Server/data/servers";
import { Tooltip } from "@mui/material";
@@ -90,7 +91,7 @@ export function GenericLocation({ loc }: IProps): React.ReactElement {
return (
<>
<Button onClick={() => Router.toCity()}>Return to World</Button>
<Button onClick={() => Router.toPage(Page.City)}>Return to World</Button>
<Typography variant="h4" sx={{ mt: 1 }}>
{backdoorInstalled && !Settings.DisableTextEffects ? (
<Tooltip title={`Backdoor installed on ${loc.name}.`}>
+2 -1
View File
@@ -12,6 +12,7 @@ import { Player } from "@player";
import { Money } from "../../ui/React/Money";
import { Router } from "../../ui/GameRoot";
import { Page } from "../../ui/Router";
import { Box } from "@mui/material";
import { ClassWork, Classes } from "../../Work/ClassWork";
import { calculateCost } from "../../Work/Formulas";
@@ -31,7 +32,7 @@ export function GymLocation(props: IProps): React.ReactElement {
}),
);
Player.startFocusing();
Router.toWork();
Router.toPage(Page.Work);
}
const cost = calculateCost(Classes[GymType.strength], props.loc);
+2 -1
View File
@@ -11,6 +11,7 @@ import { Crimes } from "../../Crime/Crimes";
import { numeralWrapper } from "../../ui/numeralFormat";
import { Router } from "../../ui/GameRoot";
import { Page } from "../../ui/Router";
import { Player } from "@player";
import { Box } from "@mui/material";
import { Crime } from "../../Crime/Crime";
@@ -27,7 +28,7 @@ export function SlumsLocation(): React.ReactElement {
function doCrime(e: React.MouseEvent<HTMLElement>, crime: Crime) {
if (!e.isTrusted) return;
crime.commit();
Router.toWork();
Router.toPage(Page.Work);
Player.focus = true;
}
+5 -4
View File
@@ -22,6 +22,7 @@ import { Factions } from "../../Faction/Factions";
import { joinFaction } from "../../Faction/FactionHelpers";
import { Router } from "../../ui/GameRoot";
import { Page } from "../../ui/Router";
import { Player } from "@player";
import { dialogBoxCreate } from "../../ui/React/DialogBox";
@@ -48,7 +49,7 @@ export function SpecialLocation(props: IProps): React.ReactElement {
function handleBladeburner(): void {
if (Player.bladeburner) {
// Enter Bladeburner division
Router.toBladeburner();
Router.toPage(Page.Bladeburner);
} else if (
Player.skills.strength >= 100 &&
Player.skills.defense >= 100 &&
@@ -72,7 +73,7 @@ export function SpecialLocation(props: IProps): React.ReactElement {
/** Click handler for Resleeving button at New Tokyo VitaLife */
function handleGrafting(): void {
Router.toGrafting();
Router.toPage(Page.Grafting);
}
function renderBladeburner(): React.ReactElement {
@@ -173,11 +174,11 @@ export function SpecialLocation(props: IProps): React.ReactElement {
applyAugmentation({ name: AugmentationNames.StaneksGift1, level: 1 });
}
Router.toStaneksGift();
Router.toPage(Page.StaneksGift);
}
function renderCotMG(): React.ReactElement {
const toStanek = <Button onClick={() => Router.toStaneksGift()}>Open Stanek's Gift</Button>;
const toStanek = <Button onClick={() => Router.toPage(Page.StaneksGift)}>Open Stanek's Gift</Button>;
// prettier-ignore
const symbol = <Typography sx={{ lineHeight: '1em', whiteSpace: 'pre' }}>
{" `` "}<br />
+2 -1
View File
@@ -11,6 +11,7 @@ import { TravelConfirmationModal } from "./TravelConfirmationModal";
import { CONSTANTS } from "../../Constants";
import { Player } from "@player";
import { Router } from "../../ui/GameRoot";
import { Page } from "../../ui/Router";
import { Settings } from "../../Settings/Settings";
import { Money } from "../../ui/React/Money";
@@ -30,7 +31,7 @@ function travel(to: CityName): void {
Player.loseMoney(cost, "other");
Player.travel(to);
dialogBoxCreate(`You are now in ${to}!`);
Router.toCity();
Router.toPage(Page.City);
}
export function TravelAgencyRoot(): React.ReactElement {
+2 -1
View File
@@ -11,6 +11,7 @@ import { Location } from "../Location";
import { Money } from "../../ui/React/Money";
import { Router } from "../../ui/GameRoot";
import { Page } from "../../ui/Router";
import { Player } from "@player";
import { Box } from "@mui/material";
@@ -32,7 +33,7 @@ export function UniversityLocation(props: IProps): React.ReactElement {
}),
);
Player.startFocusing();
Router.toWork();
Router.toPage(Page.Work);
}
const dataStructuresCost = calculateCost(Classes[UniversityClassType.dataStructures], props.loc);