bitburner-src/src/ui/Router.ts

74 lines
2.2 KiB
TypeScript
Raw Normal View History

2021-09-17 08:04:44 +02:00
import { Faction } from "../Faction/Faction";
2021-09-18 10:01:07 +02:00
import { Location } from "../Locations/Location";
2021-09-17 08:04:44 +02:00
/**
* The full-screen page the player is currently be on.
2022-12-04 09:14:06 +01:00
* These are "simple" pages that don't require any extra parameters to
* transition to. You can use setPage() with these.
2021-09-17 08:04:44 +02:00
*/
2022-12-04 09:14:06 +01:00
export enum SimplePage {
ActiveScripts = "Active Scripts",
Augmentations = "Augmentations",
Bladeburner = "Bladeburner",
City = "City",
Corporation = "Corporation",
CreateProgram = "Create Program",
DevMenu = "Dev",
Factions = "Factions",
Gang = "Gang",
Hacknet = "Hacknet",
Milestones = "Milestones",
Options = "Options",
Grafting = "Grafting",
Sleeves = "Sleeves",
Stats = "Stats",
StockMarket = "Stock Market",
Terminal = "Terminal",
Travel = "Travel",
Tutorial = "Tutorial",
Work = "Work",
BladeburnerCinematic = "Bladeburner Cinematic",
Loading = "Loading",
StaneksGift = "Staneks Gift",
Recovery = "Recovery",
Achievements = "Achievements",
ThemeBrowser = "Theme Browser",
2021-09-17 08:04:44 +02:00
}
2022-12-04 09:14:06 +01:00
/**
* "Complex" pages that need a custom transition function.
*/
export enum ComplexPage {
BitVerse = "BitVerse",
Faction = "Faction",
Infiltration = "Infiltration",
Job = "Job",
ScriptEditor = "Script Editor",
Location = "Location",
ImportSave = "Import Save",
}
// Using the same name as both type and object to mimic enum-like behavior.
// See https://stackoverflow.com/a/71255520/202091
export type Page = SimplePage | ComplexPage;
export const Page = { ...SimplePage, ...ComplexPage };
2021-12-17 18:48:34 +01:00
export interface ScriptEditorRouteOptions {
vim: boolean;
}
/** The router keeps track of player navigation/routing within the game. */
2021-09-17 08:04:44 +02:00
export interface IRouter {
isInitialized: boolean;
2021-09-18 01:43:08 +02:00
page(): Page;
allowRouting(value: boolean): void;
2022-12-04 09:14:06 +01:00
toPage(page: SimplePage): void;
2021-09-18 01:43:08 +02:00
toBitVerse(flume: boolean, quick: boolean): void;
toFaction(faction: Faction, augPage?: boolean): void; // faction name
2021-09-18 10:01:07 +02:00
toInfiltration(location: Location): void;
2022-07-19 20:21:12 +02:00
toJob(location: Location): void;
toScriptEditor(files?: Record<string, string>, options?: ScriptEditorRouteOptions): void;
2021-09-18 10:01:07 +02:00
toLocation(location: Location): void;
toImportSave(base64Save: string, automatic?: boolean): void;
2021-09-17 08:04:44 +02:00
}