dev menu in react

This commit is contained in:
Olivier Gagnon 2021-09-10 16:57:05 -04:00
parent 339d9a8d96
commit 5f64187a0f
8 changed files with 1643 additions and 1675 deletions

File diff suppressed because it is too large Load Diff

1607
src/DevMenu.tsx Normal file

File diff suppressed because it is too large Load Diff

@ -3,6 +3,8 @@
* to TypeScript at the moment * to TypeScript at the moment
*/ */
export interface IEngine { export interface IEngine {
indexedDb: any;
_lastUpdate: number;
hideAllContent: () => void; hideAllContent: () => void;
loadBladeburnerContent: () => void; loadBladeburnerContent: () => void;
loadFactionContent: () => void; loadFactionContent: () => void;

@ -21,15 +21,18 @@ import { IPlayerOwnedSourceFile } from "../SourceFile/PlayerOwnedSourceFile";
import { MoneySourceTracker } from "../utils/MoneySourceTracker"; import { MoneySourceTracker } from "../utils/MoneySourceTracker";
import { Exploit } from "../Exploits/Exploit"; import { Exploit } from "../Exploits/Exploit";
import { ICorporation } from "../Corporation/ICorporation"; import { ICorporation } from "../Corporation/ICorporation";
import { IGang } from "../Gang/IGang";
import { IBladeburner } from "../Bladeburner/IBladeburner";
export interface IPlayer { export interface IPlayer {
// Class members // Class members
augmentations: IPlayerOwnedAugmentation[]; augmentations: IPlayerOwnedAugmentation[];
bladeburner: any;
bitNodeN: number; bitNodeN: number;
city: CityName; city: CityName;
companyName: string; companyName: string;
corporation: ICorporation; corporation: ICorporation;
gang: IGang;
bladeburner: IBladeburner;
currentServer: string; currentServer: string;
factions: string[]; factions: string[];
factionInvitations: string[]; factionInvitations: string[];
@ -63,6 +66,7 @@ export interface IPlayer {
sleevesFromCovenant: number; sleevesFromCovenant: number;
sourceFiles: IPlayerOwnedSourceFile[]; sourceFiles: IPlayerOwnedSourceFile[];
exploits: Exploit[]; exploits: Exploit[];
lastUpdate: number;
totalPlaytime: number; totalPlaytime: number;
// Stats // Stats
@ -81,6 +85,7 @@ export interface IPlayer {
dexterity_exp: number; dexterity_exp: number;
agility_exp: number; agility_exp: number;
charisma_exp: number; charisma_exp: number;
intelligence_exp: number;
// Multipliers // Multipliers
hacking_chance_mult: number; hacking_chance_mult: number;
@ -193,4 +198,7 @@ export interface IPlayer {
quitJob(company: string): void; quitJob(company: string): void;
createHacknetServer(): void; createHacknetServer(): void;
startCreateProgramWork(programName: string, time: number, reqLevel: number): void; startCreateProgramWork(programName: string, time: number, reqLevel: number): void;
queueAugmentation(augmentationName: string): void;
receiveInvite(factionName: string): void;
updateSkillLevels(): void;
} }

1
src/SaveObject.d.ts vendored Normal file

@ -0,0 +1 @@
export declare const saveObject: any;

@ -21,7 +21,7 @@ import { generateRandomContract } from "./CodingContractGenerator";
import { initCompanies } from "./Company/Companies"; import { initCompanies } from "./Company/Companies";
import { Corporation } from "./Corporation/Corporation"; import { Corporation } from "./Corporation/Corporation";
import { CONSTANTS } from "./Constants"; import { CONSTANTS } from "./Constants";
import { createDevMenu, closeDevMenu } from "./DevMenu"; import { DevMenuRoot } from "./DevMenu";
import { Factions, initFactions } from "./Faction/Factions"; import { Factions, initFactions } from "./Faction/Factions";
import { processPassiveFactionRepGain, inviteToFaction } from "./Faction/FactionHelpers"; import { processPassiveFactionRepGain, inviteToFaction } from "./Faction/FactionHelpers";
import { FactionList } from "./Faction/ui/FactionList"; import { FactionList } from "./Faction/ui/FactionList";
@ -188,6 +188,7 @@ const Engine = {
factionContent: null, factionContent: null,
augmentationsContent: null, augmentationsContent: null,
milestonesContent: null, milestonesContent: null,
devMenuContent: null,
tutorialContent: null, tutorialContent: null,
infiltrationContent: null, infiltrationContent: null,
stockMarketContent: null, stockMarketContent: null,
@ -313,7 +314,11 @@ const Engine = {
// TODO reactify // TODO reactify
loadDevMenuContent: function () { loadDevMenuContent: function () {
Engine.hideAllContent(); Engine.hideAllContent();
createDevMenu(); if (process.env.NODE_ENV !== "development") {
throw new Error("Cannot create Dev Menu because you are not in a dev build");
}
Engine.Display.devMenuContent.style.display = "block";
ReactDOM.render(<DevMenuRoot player={Player} engine={this} />, Engine.Display.devMenuContent);
routing.navigateTo(Page.DevMenu); routing.navigateTo(Page.DevMenu);
MainMenuLinks.DevMenu.classList.add("active"); MainMenuLinks.DevMenu.classList.add("active");
}, },
@ -472,6 +477,7 @@ const Engine = {
Engine.Display.activeScriptsContent.style.display = "none"; Engine.Display.activeScriptsContent.style.display = "none";
ReactDOM.unmountComponentAtNode(Engine.Display.activeScriptsContent); ReactDOM.unmountComponentAtNode(Engine.Display.activeScriptsContent);
Engine.Display.infiltrationContent.style.display = "none"; Engine.Display.infiltrationContent.style.display = "none";
ReactDOM.unmountComponentAtNode(Engine.Display.infiltrationContent); ReactDOM.unmountComponentAtNode(Engine.Display.infiltrationContent);
@ -479,6 +485,7 @@ const Engine = {
ReactDOM.unmountComponentAtNode(Engine.Display.hacknetNodesContent); ReactDOM.unmountComponentAtNode(Engine.Display.hacknetNodesContent);
Engine.Display.createProgramContent.style.display = "none"; Engine.Display.createProgramContent.style.display = "none";
ReactDOM.unmountComponentAtNode(Engine.Display.createProgramContent);
Engine.Display.factionsContent.style.display = "none"; Engine.Display.factionsContent.style.display = "none";
ReactDOM.unmountComponentAtNode(Engine.Display.factionsContent); ReactDOM.unmountComponentAtNode(Engine.Display.factionsContent);
@ -489,8 +496,14 @@ const Engine = {
Engine.Display.augmentationsContent.style.display = "none"; Engine.Display.augmentationsContent.style.display = "none";
ReactDOM.unmountComponentAtNode(Engine.Display.augmentationsContent); ReactDOM.unmountComponentAtNode(Engine.Display.augmentationsContent);
Engine.Display.milestonesContent.style.display = "none";
Engine.Display.tutorialContent.style.display = "none"; Engine.Display.tutorialContent.style.display = "none";
ReactDOM.unmountComponentAtNode(Engine.Display.tutorialContent);
Engine.Display.milestonesContent.style.display = "none";
ReactDOM.unmountComponentAtNode(Engine.Display.milestonesContent);
Engine.Display.devMenuContent.style.display = "none";
ReactDOM.unmountComponentAtNode(Engine.Display.devMenuContent);
Engine.Display.locationContent.style.display = "none"; Engine.Display.locationContent.style.display = "none";
ReactDOM.unmountComponentAtNode(Engine.Display.locationContent); ReactDOM.unmountComponentAtNode(Engine.Display.locationContent);
@ -518,34 +531,13 @@ const Engine = {
// Make nav menu tabs inactive // Make nav menu tabs inactive
Engine.inactivateMainMenuLinks(); Engine.inactivateMainMenuLinks();
// Close dev menu
closeDevMenu();
}, },
// Remove 'active' css class from all main menu links // Remove 'active' css class from all main menu links
inactivateMainMenuLinks: function () { inactivateMainMenuLinks: function () {
MainMenuLinks.Terminal.classList.remove("active"); for (const link of Object.keys(MainMenuLinks)) {
MainMenuLinks.ScriptEditor.classList.remove("active"); MainMenuLinks[link].classList.remove("active");
MainMenuLinks.ActiveScripts.classList.remove("active"); }
MainMenuLinks.CreateProgram.classList.remove("active");
MainMenuLinks.Stats.classList.remove("active");
MainMenuLinks.Factions.classList.remove("active");
MainMenuLinks.Augmentations.classList.remove("active");
MainMenuLinks.HacknetNodes.classList.remove("active");
MainMenuLinks.Sleeves.classList.remove("active");
MainMenuLinks.City.classList.remove("active");
MainMenuLinks.Travel.classList.remove("active");
MainMenuLinks.Job.classList.remove("active");
MainMenuLinks.StockMarket.classList.remove("active");
MainMenuLinks.Gang.classList.remove("active");
MainMenuLinks.Bladeburner.classList.remove("active");
MainMenuLinks.Corporation.classList.remove("active");
MainMenuLinks.Gang.classList.remove("active");
MainMenuLinks.Milestones.classList.remove("active");
MainMenuLinks.Tutorial.classList.remove("active");
MainMenuLinks.Options.classList.remove("active");
MainMenuLinks.DevMenu.classList.remove("active");
}, },
displayCharacterOverviewInfo: function () { displayCharacterOverviewInfo: function () {
@ -1225,6 +1217,9 @@ const Engine = {
Engine.Display.milestonesContent = document.getElementById("milestones-container"); Engine.Display.milestonesContent = document.getElementById("milestones-container");
Engine.Display.milestonesContent.style.display = "none"; Engine.Display.milestonesContent.style.display = "none";
Engine.Display.devMenuContent = document.getElementById("dev-menu-container");
Engine.Display.devMenuContent.style.display = "none";
Engine.Display.tutorialContent = document.getElementById("tutorial-container"); Engine.Display.tutorialContent = document.getElementById("tutorial-container");
Engine.Display.tutorialContent.style.display = "none"; Engine.Display.tutorialContent.style.display = "none";

@ -166,6 +166,7 @@
<div id="gang-container" class="generic-menupage-container"></div> <div id="gang-container" class="generic-menupage-container"></div>
<div id="corporation-container" class="generic-menupage-container"></div> <div id="corporation-container" class="generic-menupage-container"></div>
<div id="sleeves-container" class="generic-menupage-container"></div> <div id="sleeves-container" class="generic-menupage-container"></div>
<div id="dev-menu-container" class="generic-menupage-container"></div>
<!-- Generic Yes/No Pop Up box --> <!-- Generic Yes/No Pop Up box -->
<div id="yes-no-box-container" class="popup-box-container"> <div id="yes-no-box-container" class="popup-box-container">

@ -3,6 +3,7 @@
import { clearEventListeners } from "../../../utils/uiHelpers/clearEventListeners"; import { clearEventListeners } from "../../../utils/uiHelpers/clearEventListeners";
interface IMainMenuLinks { interface IMainMenuLinks {
[key: string]: HTMLElement | undefined;
Terminal: HTMLElement; Terminal: HTMLElement;
ScriptEditor: HTMLElement; ScriptEditor: HTMLElement;
ActiveScripts: HTMLElement; ActiveScripts: HTMLElement;