diff --git a/src/InteractiveTutorial.js b/src/InteractiveTutorial.js index 2ecd78882..9925b6e77 100644 --- a/src/InteractiveTutorial.js +++ b/src/InteractiveTutorial.js @@ -63,8 +63,6 @@ function iTutorialStart() { ITutorial.stepIsDone[i] = false; } - Engine.loadTerminalContent(); - // Don't autosave during this interactive tutorial Engine.Counters.autoSaveCounter = Infinity; ITutorial.currStep = 0; @@ -120,7 +118,6 @@ function iTutorialEvaluateStep() { switch (ITutorial.currStep) { case iTutorialSteps.Start: - Engine.loadTerminalContent(); iTutorialSetText( "Welcome to Bitburner, a cyberpunk-themed incremental RPG! " + "The game takes place in a dark, dystopian future... The year is 2077...

" + @@ -130,7 +127,6 @@ function iTutorialEvaluateStep() { nextBtn.style.display = "inline-block"; break; case iTutorialSteps.GoToCharacterPage: - Engine.loadTerminalContent(); iTutorialSetText( "Let's start by heading to the Stats page. Click the Stats tab on " + "the main navigation menu (left-hand side of the screen)", @@ -138,7 +134,6 @@ function iTutorialEvaluateStep() { nextBtn.style.display = "none"; break; case iTutorialSteps.CharacterPage: - Engine.loadCharacterContent(); iTutorialSetText( "The Stats page shows a lot of important information about your progress, " + "such as your skills, money, and bonuses. ", @@ -146,7 +141,6 @@ function iTutorialEvaluateStep() { nextBtn.style.display = "inline-block"; break; case iTutorialSteps.CharacterGoToTerminalPage: - Engine.loadCharacterContent(); iTutorialSetText( "Let's head to your computer's terminal by clicking the Terminal tab on the " + "main navigation menu.", @@ -154,7 +148,6 @@ function iTutorialEvaluateStep() { nextBtn.style.display = "none"; break; case iTutorialSteps.TerminalIntro: - Engine.loadTerminalContent(); iTutorialSetText( "The Terminal is used to interface with your home computer as well as " + "all of the other machines around the world.", @@ -162,7 +155,6 @@ function iTutorialEvaluateStep() { nextBtn.style.display = "inline-block"; break; case iTutorialSteps.TerminalHelp: - Engine.loadTerminalContent(); iTutorialSetText( "Let's try it out. Start by entering the help command into the Terminal " + "(Don't forget to press Enter after typing the command)", @@ -170,7 +162,6 @@ function iTutorialEvaluateStep() { nextBtn.style.display = "none"; // next step triggered by terminal command break; case iTutorialSteps.TerminalLs: - Engine.loadTerminalContent(); iTutorialSetText( "The help command displays a list of all available Terminal commands, how to use them, " + "and a description of what they do.

Let's try another command. Enter the ls command.", @@ -178,7 +169,6 @@ function iTutorialEvaluateStep() { nextBtn.style.display = "none"; // next step triggered by terminal command break; case iTutorialSteps.TerminalScan: - Engine.loadTerminalContent(); iTutorialSetText( " ls is a basic command that shows files " + "on the computer. Right now, it shows that you have a program called NUKE.exe on your computer. " + @@ -189,7 +179,6 @@ function iTutorialEvaluateStep() { nextBtn.style.display = "none"; // next step triggered by terminal command break; case iTutorialSteps.TerminalScanAnalyze1: - Engine.loadTerminalContent(); iTutorialSetText( "The scan command shows all available network connections. In other words, " + "it displays a list of all servers that can be connected to from your " + @@ -201,7 +190,6 @@ function iTutorialEvaluateStep() { nextBtn.style.display = "none"; // next step triggered by terminal command break; case iTutorialSteps.TerminalScanAnalyze2: - Engine.loadTerminalContent(); iTutorialSetText( "You just ran scan-analyze with a depth of one. This command shows more detailed " + "information about each server that you can connect to (servers that are a distance of " + @@ -211,7 +199,6 @@ function iTutorialEvaluateStep() { nextBtn.style.display = "none"; // next step triggered by terminal command break; case iTutorialSteps.TerminalConnect: - Engine.loadTerminalContent(); iTutorialSetText( "Now you can see information about all servers that are up to two nodes away, as well " + "as figure out how to navigate to those servers through the network. You can only connect to " + @@ -222,7 +209,6 @@ function iTutorialEvaluateStep() { nextBtn.style.display = "none"; // next step triggered by terminal command break; case iTutorialSteps.TerminalAnalyze: - Engine.loadTerminalContent(); iTutorialSetText( "You are now connected to another machine! What can you do now? You can hack it!

In the year 2077, currency has " + "become digital and decentralized. People and corporations store their money " + @@ -233,7 +219,6 @@ function iTutorialEvaluateStep() { nextBtn.style.display = "none"; // next step triggered by terminal command break; case iTutorialSteps.TerminalNuke: - Engine.loadTerminalContent(); iTutorialSetText( "When the analyze command finishes running it will show useful information " + "about hacking the server.

For this server, the required hacking skill is only 1, " + @@ -247,7 +232,6 @@ function iTutorialEvaluateStep() { nextBtn.style.display = "none"; // next step triggered by terminal command break; case iTutorialSteps.TerminalManualHack: - Engine.loadTerminalContent(); iTutorialSetText( "You now have root access! You can hack the server using the hack command. " + "Try doing that now.", @@ -255,7 +239,6 @@ function iTutorialEvaluateStep() { nextBtn.style.display = "none"; // next step triggered by terminal command break; case iTutorialSteps.TerminalHackingMechanics: - Engine.loadTerminalContent(); iTutorialSetText( "You are now attempting to hack the server. Performing a hack takes time and " + "only has a certain percentage chance " + @@ -270,7 +253,6 @@ function iTutorialEvaluateStep() { nextBtn.style.display = "inline-block"; break; case iTutorialSteps.TerminalCreateScript: - Engine.loadTerminalContent(); iTutorialSetText( "Hacking is the core mechanic of the game and is necessary for progressing. However, " + "you don't want to be hacking manually the entire time. You can automate your hacking " + @@ -282,7 +264,6 @@ function iTutorialEvaluateStep() { nextBtn.style.display = "none"; // next step triggered by terminal command break; case iTutorialSteps.TerminalTypeScript: - Engine.loadScriptEditorContent("n00dles.script", ""); iTutorialSetText( "This is the script editor. You can use it to program your scripts. Scripts are " + "written in a simplified version of javascript. Copy and paste the following code into the script editor:

" + @@ -297,7 +278,6 @@ function iTutorialEvaluateStep() { nextBtn.style.display = "none"; // next step triggered in saveAndCloseScriptEditor() (Script.js) break; case iTutorialSteps.TerminalFree: - Engine.loadTerminalContent(); iTutorialSetText( "Now we'll run the script. Scripts require a certain amount of RAM to run, and can be " + "run on any machine which you have root access to. Different servers have different " + @@ -307,7 +287,6 @@ function iTutorialEvaluateStep() { nextBtn.style.display = "none"; // next step triggered by terminal commmand break; case iTutorialSteps.TerminalRunScript: - Engine.loadTerminalContent(); iTutorialSetText( "We have 4GB of free RAM on this machine, which is enough to run our " + "script. Let's run our script using run n00dles.script.", @@ -315,7 +294,6 @@ function iTutorialEvaluateStep() { nextBtn.style.display = "none"; // next step triggered by terminal commmand break; case iTutorialSteps.TerminalGoToActiveScriptsPage: - Engine.loadTerminalContent(); iTutorialSetText( "Your script is now running! " + "It will continuously run in the background and will automatically stop if " + @@ -329,7 +307,6 @@ function iTutorialEvaluateStep() { nextBtn.style.display = "none"; break; case iTutorialSteps.ActiveScriptsPage: - Engine.loadActiveScriptsContent(); iTutorialSetText( "This page displays information about all of your scripts that are " + "running across every server. You can use this to gauge how well " + @@ -338,7 +315,6 @@ function iTutorialEvaluateStep() { nextBtn.style.display = "none"; break; case iTutorialSteps.ActiveScriptsToTerminal: - Engine.loadTerminalContent(); iTutorialSetText( "One last thing about scripts, each active script contains logs that detail " + "what it's doing. We can check these logs using the tail command. Do that " + @@ -347,7 +323,6 @@ function iTutorialEvaluateStep() { nextBtn.style.display = "none"; // next step triggered by terminal command break; case iTutorialSteps.TerminalTailScript: - Engine.loadTerminalContent(); iTutorialSetText( "The log for this script won't show much right now (it might show nothing at all) because it " + "just started running...but check back again in a few minutes!

" + @@ -361,7 +336,6 @@ function iTutorialEvaluateStep() { nextBtn.style.display = "inline-block"; break; case iTutorialSteps.GoToHacknetNodesPage: - Engine.loadTerminalContent(); iTutorialSetText( "Hacking is not the only way to earn money. One other way to passively " + "earn money is by purchasing and upgrading Hacknet Nodes. Let's go to " + @@ -370,14 +344,12 @@ function iTutorialEvaluateStep() { nextBtn.style.display = "none"; break; case iTutorialSteps.HacknetNodesIntroduction: - Engine.loadHacknetNodesContent(); iTutorialSetText( "here you can purchase new Hacknet Nodes and upgrade your " + "existing ones. Let's purchase a new one now.", ); nextBtn.style.display = "none"; // Next step triggered by purchaseHacknet() (HacknetNode.js) break; case iTutorialSteps.HacknetNodesGoToWorldPage: - Engine.loadHacknetNodesContent(); iTutorialSetText( "You just purchased a Hacknet Node! This Hacknet Node will passively " + "earn you money over time, both online and offline. When you get enough " + @@ -388,7 +360,6 @@ function iTutorialEvaluateStep() { nextBtn.style.display = "none"; break; case iTutorialSteps.WorldDescription: - Engine.loadLocationContent(); iTutorialSetText( "This page lists all of the different locations you can currently " + "travel to. Each location has something that you can do. " + @@ -399,7 +370,6 @@ function iTutorialEvaluateStep() { nextBtn.style.display = "none"; break; case iTutorialSteps.TutorialPageInfo: - Engine.loadTutorialContent(); iTutorialSetText( "This page contains a lot of different documentation about the game's " + "content and mechanics. I know it's a lot, but I highly suggest you read " + diff --git a/src/Script/Script.ts b/src/Script/Script.ts index 233627a32..88295ed12 100644 --- a/src/Script/Script.ts +++ b/src/Script/Script.ts @@ -93,22 +93,18 @@ export class Script { * @param {Script[]} otherScripts - Other scripts on the server. Used to process imports */ saveScript(code: string, serverIp: string, otherScripts: Script[]): void { - if (routing.isOn(Page.ScriptEditor)) { - // Update code and filename - this.code = code.replace(/^\s+|\s+$/g, ""); + // Update code and filename + this.code = code.replace(/^\s+|\s+$/g, ""); - const filenameElem: HTMLInputElement | null = document.getElementById( - "script-editor-filename", - ) as HTMLInputElement; - if (filenameElem == null) { - console.error(`Failed to get Script filename DOM element`); - return; - } - this.filename = filenameElem.value; - this.server = serverIp; - this.updateRamUsage(otherScripts); - this.markUpdated(); + const filenameElem: HTMLInputElement | null = document.getElementById("script-editor-filename") as HTMLInputElement; + if (filenameElem == null) { + console.error(`Failed to get Script filename DOM element`); + return; } + this.filename = filenameElem.value; + this.server = serverIp; + this.updateRamUsage(otherScripts); + this.markUpdated(); } /** diff --git a/src/ScriptEditor/ui/Root.tsx b/src/ScriptEditor/ui/Root.tsx index b1eb01bef..6fafaef07 100644 --- a/src/ScriptEditor/ui/Root.tsx +++ b/src/ScriptEditor/ui/Root.tsx @@ -9,7 +9,7 @@ import { Options } from "./Options"; import { js_beautify as beautifyCode } from "js-beautify"; import { isValidFilePath } from "../../Terminal/DirectoryHelpers"; import { IPlayer } from "../../PersonObjects/IPlayer"; -import { IEngine } from "../../IEngine"; +import { IRouter } from "../../ui/Router"; import { dialogBoxCreate } from "../../../utils/DialogBox"; import { parseFconfSettings } from "../../Fconf/Fconf"; import { isScriptFilename } from "../../Script/ScriptHelpersTS"; @@ -53,7 +53,7 @@ interface IProps { filename: string; code: string; player: IPlayer; - engine: IEngine; + router: IRouter; } /* @@ -103,7 +103,6 @@ export function Root(props: IProps): React.ReactElement { } lastPosition = null; - // TODO(hydroflame): re-enable the tutorial. if (ITutorial.isRunning && ITutorial.currStep === iTutorialSteps.TerminalTypeScript) { //Make sure filename + code properly follow tutorial if (filename !== "n00dles.script") { @@ -121,7 +120,7 @@ export function Root(props: IProps): React.ReactElement { for (let i = 0; i < server.scripts.length; i++) { if (filename == server.scripts[i].filename) { server.scripts[i].saveScript(code, props.player.currentServer, server.scripts); - props.engine.loadTerminalContent(); + props.router.toTerminal(); return iTutorialNextStep(); } } @@ -160,7 +159,7 @@ export function Root(props: IProps): React.ReactElement { for (let i = 0; i < server.scripts.length; i++) { if (filename == server.scripts[i].filename) { server.scripts[i].saveScript(code, props.player.currentServer, server.scripts); - props.engine.loadTerminalContent(); + props.router.toTerminal(); return; } } @@ -173,7 +172,7 @@ export function Root(props: IProps): React.ReactElement { for (let i = 0; i < server.textFiles.length; ++i) { if (server.textFiles[i].fn === filename) { server.textFiles[i].write(code); - props.engine.loadTerminalContent(); + props.router.toTerminal(); return; } } @@ -183,7 +182,7 @@ export function Root(props: IProps): React.ReactElement { dialogBoxCreate("Invalid filename. Must be either a script (.script, .js, or .ns) or " + " or text file (.txt)"); return; } - props.engine.loadTerminalContent(); + props.router.toTerminal(); } function beautify(): void { diff --git a/src/Terminal/ITerminal.ts b/src/Terminal/ITerminal.ts index 278f66fb8..0985d10f3 100644 --- a/src/Terminal/ITerminal.ts +++ b/src/Terminal/ITerminal.ts @@ -1,7 +1,7 @@ import { TextFile } from "../TextFile"; import { Script } from "../Script/Script"; import { IPlayer } from "../PersonObjects/IPlayer"; -import { IEngine } from "../IEngine"; +import { IRouter } from "../ui/Router"; export class Output { text: string; @@ -70,8 +70,8 @@ export interface ITerminal { runContract(player: IPlayer, name: string): void; executeScanAnalyzeCommand(player: IPlayer, depth?: number, all?: boolean): void; connectToServer(player: IPlayer, server: string): void; - executeCommand(engine: IEngine, player: IPlayer, command: string): void; - executeCommands(engine: IEngine, player: IPlayer, commands: string): void; + executeCommand(router: IRouter, player: IPlayer, command: string): void; + executeCommands(router: IRouter, player: IPlayer, commands: string): void; // If there was any changes, will return true, once. pollChanges(): boolean; process(player: IPlayer, cycles: number): void; diff --git a/src/Terminal/Terminal.ts b/src/Terminal/Terminal.ts index c9f0e022a..5d50d6894 100644 --- a/src/Terminal/Terminal.ts +++ b/src/Terminal/Terminal.ts @@ -1,5 +1,5 @@ import { ITerminal, Output, Link, TTimer } from "./ITerminal"; -import { IEngine } from "../IEngine"; +import { IRouter } from "../ui/Router"; import { IPlayer } from "../PersonObjects/IPlayer"; import { HacknetServer } from "../Hacknet/HacknetServer"; import { BaseServer } from "../Server/BaseServer"; @@ -468,7 +468,7 @@ export class Terminal implements ITerminal { } } - executeCommands(engine: IEngine, player: IPlayer, commands: string): void { + executeCommands(router: IRouter, player: IPlayer, commands: string): void { // Sanitize input commands = commands.trim(); commands = commands.replace(/\s\s+/g, " "); // Replace all extra whitespace in command with a single space @@ -484,7 +484,7 @@ export class Terminal implements ITerminal { const allCommands = ParseCommands(commands); for (let i = 0; i < allCommands.length; i++) { - this.executeCommand(engine, player, allCommands[i]); + this.executeCommand(router, player, allCommands[i]); } } @@ -499,7 +499,7 @@ export class Terminal implements ITerminal { this.clear(); } - executeCommand(engine: IEngine, player: IPlayer, command: string): void { + executeCommand(router: IRouter, player: IPlayer, command: string): void { if (this.action !== null) { this.error(`Cannot execute command (${command}) while an action is in progress`); return; @@ -532,7 +532,7 @@ export class Terminal implements ITerminal { break; case iTutorialSteps.TerminalLs: if (commandArray.length === 1 && commandArray[0] == "ls") { - ls(this, engine, player, s, commandArray.slice(1)); + ls(this, router, player, s, commandArray.slice(1)); iTutorialNextStep(); } else { this.print("Bad command. Please follow the tutorial"); @@ -540,7 +540,7 @@ export class Terminal implements ITerminal { break; case iTutorialSteps.TerminalScan: if (commandArray.length === 1 && commandArray[0] == "scan") { - scan(this, engine, player, s, commandArray.slice(1)); + scan(this, router, player, s, commandArray.slice(1)); iTutorialNextStep(); } else { this.print("Bad command. Please follow the tutorial"); @@ -609,7 +609,7 @@ export class Terminal implements ITerminal { break; case iTutorialSteps.TerminalCreateScript: if (commandArray.length == 2 && commandArray[0] == "nano" && commandArray[1] == "n00dles.script") { - engine.loadScriptEditorContent("n00dles.script", ""); + router.toScriptEditor("n00dles.script", ""); iTutorialNextStep(); } else { this.print("Bad command. Please follow the tutorial"); @@ -617,7 +617,7 @@ export class Terminal implements ITerminal { break; case iTutorialSteps.TerminalFree: if (commandArray.length == 1 && commandArray[0] == "free") { - free(this, engine, player, s, commandArray.slice(1)); + free(this, router, player, s, commandArray.slice(1)); iTutorialNextStep(); } else { this.print("Bad command. Please follow the tutorial"); @@ -625,7 +625,7 @@ export class Terminal implements ITerminal { break; case iTutorialSteps.TerminalRunScript: if (commandArray.length == 2 && commandArray[0] == "run" && commandArray[1] == "n00dles.script") { - run(this, engine, player, s, commandArray.slice(1)); + run(this, router, player, s, commandArray.slice(1)); iTutorialNextStep(); } else { this.print("Bad command. Please follow the tutorial"); @@ -662,7 +662,7 @@ export class Terminal implements ITerminal { const commands: { [key: string]: ( terminal: ITerminal, - engine: IEngine, + router: IRouter, player: IPlayer, server: BaseServer, args: (string | number)[], @@ -713,7 +713,7 @@ export class Terminal implements ITerminal { return; } - f(this, engine, player, s, commandArray.slice(1)); + f(this, router, player, s, commandArray.slice(1)); } getProgressText(): string { diff --git a/src/Terminal/commands/alias.ts b/src/Terminal/commands/alias.ts index 9fbf59c3e..da06efaab 100644 --- a/src/Terminal/commands/alias.ts +++ b/src/Terminal/commands/alias.ts @@ -1,12 +1,12 @@ import { ITerminal } from "../ITerminal"; -import { IEngine } from "../../IEngine"; +import { IRouter } from "../../ui/Router"; import { IPlayer } from "../../PersonObjects/IPlayer"; import { BaseServer } from "../../Server/BaseServer"; import { parseAliasDeclaration, printAliases } from "../../Alias"; export function alias( terminal: ITerminal, - engine: IEngine, + router: IRouter, player: IPlayer, server: BaseServer, args: (string | number)[], diff --git a/src/Terminal/commands/analyze.ts b/src/Terminal/commands/analyze.ts index e3d3b3c88..bd1004a40 100644 --- a/src/Terminal/commands/analyze.ts +++ b/src/Terminal/commands/analyze.ts @@ -1,11 +1,11 @@ import { ITerminal } from "../ITerminal"; -import { IEngine } from "../../IEngine"; +import { IRouter } from "../../ui/Router"; import { IPlayer } from "../../PersonObjects/IPlayer"; import { BaseServer } from "../../Server/BaseServer"; export function analyze( terminal: ITerminal, - engine: IEngine, + router: IRouter, player: IPlayer, server: BaseServer, args: (string | number)[], diff --git a/src/Terminal/commands/backdoor.ts b/src/Terminal/commands/backdoor.ts index ea33e2438..72247327f 100644 --- a/src/Terminal/commands/backdoor.ts +++ b/src/Terminal/commands/backdoor.ts @@ -1,5 +1,5 @@ import { ITerminal } from "../ITerminal"; -import { IEngine } from "../../IEngine"; +import { IRouter } from "../../ui/Router"; import { IPlayer } from "../../PersonObjects/IPlayer"; import { BaseServer } from "../../Server/BaseServer"; import { Server } from "../../Server/Server"; @@ -7,7 +7,7 @@ import { HacknetServer } from "../../Hacknet/HacknetServer"; export function backdoor( terminal: ITerminal, - engine: IEngine, + router: IRouter, player: IPlayer, server: BaseServer, args: (string | number)[], diff --git a/src/Terminal/commands/buy.ts b/src/Terminal/commands/buy.ts index 8f2f3dab4..d81195abe 100644 --- a/src/Terminal/commands/buy.ts +++ b/src/Terminal/commands/buy.ts @@ -1,5 +1,5 @@ import { ITerminal } from "../ITerminal"; -import { IEngine } from "../../IEngine"; +import { IRouter } from "../../ui/Router"; import { IPlayer } from "../../PersonObjects/IPlayer"; import { BaseServer } from "../../Server/BaseServer"; import { listAllDarkwebItems, buyDarkwebItem } from "../../DarkWeb/DarkWeb"; @@ -7,7 +7,7 @@ import { SpecialServerIps } from "../../Server/SpecialServerIps"; export function buy( terminal: ITerminal, - engine: IEngine, + router: IRouter, player: IPlayer, server: BaseServer, args: (string | number)[], diff --git a/src/Terminal/commands/cat.ts b/src/Terminal/commands/cat.ts index 98bfa7e8f..c10a025fe 100644 --- a/src/Terminal/commands/cat.ts +++ b/src/Terminal/commands/cat.ts @@ -1,5 +1,5 @@ import { ITerminal } from "../ITerminal"; -import { IEngine } from "../../IEngine"; +import { IRouter } from "../../ui/Router"; import { IPlayer } from "../../PersonObjects/IPlayer"; import { BaseServer } from "../../Server/BaseServer"; import { showMessage } from "../../Message/MessageHelpers"; @@ -8,7 +8,7 @@ import { showLiterature } from "../../Literature/LiteratureHelpers"; export function cat( terminal: ITerminal, - engine: IEngine, + router: IRouter, player: IPlayer, server: BaseServer, args: (string | number)[], diff --git a/src/Terminal/commands/cd.ts b/src/Terminal/commands/cd.ts index fe9b66e50..ab5576d7a 100644 --- a/src/Terminal/commands/cd.ts +++ b/src/Terminal/commands/cd.ts @@ -1,5 +1,5 @@ import { ITerminal } from "../ITerminal"; -import { IEngine } from "../../IEngine"; +import { IRouter } from "../../ui/Router"; import { IPlayer } from "../../PersonObjects/IPlayer"; import { BaseServer } from "../../Server/BaseServer"; @@ -7,7 +7,7 @@ import { evaluateDirectoryPath, removeTrailingSlash } from "../DirectoryHelpers" export function cd( terminal: ITerminal, - engine: IEngine, + router: IRouter, player: IPlayer, server: BaseServer, args: (string | number)[], diff --git a/src/Terminal/commands/check.ts b/src/Terminal/commands/check.ts index c93f8d973..ad4d155a9 100644 --- a/src/Terminal/commands/check.ts +++ b/src/Terminal/commands/check.ts @@ -1,5 +1,5 @@ import { ITerminal } from "../ITerminal"; -import { IEngine } from "../../IEngine"; +import { IRouter } from "../../ui/Router"; import { IPlayer } from "../../PersonObjects/IPlayer"; import { BaseServer } from "../../Server/BaseServer"; import { findRunningScript } from "../../Script/ScriptHelpers"; @@ -7,7 +7,7 @@ import { isScriptFilename } from "../../Script/ScriptHelpersTS"; export function check( terminal: ITerminal, - engine: IEngine, + router: IRouter, player: IPlayer, server: BaseServer, args: (string | number)[], diff --git a/src/Terminal/commands/connect.ts b/src/Terminal/commands/connect.ts index 5f868dc8c..f66d6f765 100644 --- a/src/Terminal/commands/connect.ts +++ b/src/Terminal/commands/connect.ts @@ -1,12 +1,12 @@ import { ITerminal } from "../ITerminal"; -import { IEngine } from "../../IEngine"; +import { IRouter } from "../../ui/Router"; import { IPlayer } from "../../PersonObjects/IPlayer"; import { BaseServer } from "../../Server/BaseServer"; import { getServerOnNetwork } from "../../Server/ServerHelpers"; export function connect( terminal: ITerminal, - engine: IEngine, + router: IRouter, player: IPlayer, server: BaseServer, args: (string | number)[], diff --git a/src/Terminal/commands/download.ts b/src/Terminal/commands/download.ts index eb58d9e57..cad18d762 100644 --- a/src/Terminal/commands/download.ts +++ b/src/Terminal/commands/download.ts @@ -1,5 +1,5 @@ import { ITerminal } from "../ITerminal"; -import { IEngine } from "../../IEngine"; +import { IRouter } from "../../ui/Router"; import { IPlayer } from "../../PersonObjects/IPlayer"; import { BaseServer } from "../../Server/BaseServer"; import { isScriptFilename } from "../../Script/ScriptHelpersTS"; @@ -8,7 +8,7 @@ import JSZip from "jszip"; export function download( terminal: ITerminal, - engine: IEngine, + router: IRouter, player: IPlayer, server: BaseServer, args: (string | number)[], diff --git a/src/Terminal/commands/expr.ts b/src/Terminal/commands/expr.ts index 8a8bab5b4..060971e29 100644 --- a/src/Terminal/commands/expr.ts +++ b/src/Terminal/commands/expr.ts @@ -1,11 +1,11 @@ import { ITerminal } from "../ITerminal"; -import { IEngine } from "../../IEngine"; +import { IRouter } from "../../ui/Router"; import { IPlayer } from "../../PersonObjects/IPlayer"; import { BaseServer } from "../../Server/BaseServer"; export function expr( terminal: ITerminal, - engine: IEngine, + router: IRouter, player: IPlayer, server: BaseServer, args: (string | number)[], diff --git a/src/Terminal/commands/free.ts b/src/Terminal/commands/free.ts index b6372bbfa..68a668efc 100644 --- a/src/Terminal/commands/free.ts +++ b/src/Terminal/commands/free.ts @@ -1,12 +1,12 @@ import { ITerminal } from "../ITerminal"; -import { IEngine } from "../../IEngine"; +import { IRouter } from "../../ui/Router"; import { IPlayer } from "../../PersonObjects/IPlayer"; import { BaseServer } from "../../Server/BaseServer"; import { numeralWrapper } from "../../ui/numeralFormat"; export function free( terminal: ITerminal, - engine: IEngine, + router: IRouter, player: IPlayer, server: BaseServer, args: (string | number)[], diff --git a/src/Terminal/commands/hack.ts b/src/Terminal/commands/hack.ts index a2f587b4b..4fb0a6c6f 100644 --- a/src/Terminal/commands/hack.ts +++ b/src/Terminal/commands/hack.ts @@ -1,12 +1,12 @@ import { ITerminal } from "../ITerminal"; -import { IEngine } from "../../IEngine"; +import { IRouter } from "../../ui/Router"; import { IPlayer } from "../../PersonObjects/IPlayer"; import { BaseServer } from "../../Server/BaseServer"; import { Server } from "../../Server/Server"; export function hack( terminal: ITerminal, - engine: IEngine, + router: IRouter, player: IPlayer, server: BaseServer, args: (string | number)[], diff --git a/src/Terminal/commands/help.ts b/src/Terminal/commands/help.ts index 33b11a204..af818ee38 100644 --- a/src/Terminal/commands/help.ts +++ b/src/Terminal/commands/help.ts @@ -1,12 +1,12 @@ import { ITerminal } from "../ITerminal"; -import { IEngine } from "../../IEngine"; +import { IRouter } from "../../ui/Router"; import { IPlayer } from "../../PersonObjects/IPlayer"; import { BaseServer } from "../../Server/BaseServer"; import { TerminalHelpText, HelpTexts } from "../HelpText"; export function help( terminal: ITerminal, - engine: IEngine, + router: IRouter, player: IPlayer, server: BaseServer, args: (string | number)[], diff --git a/src/Terminal/commands/home.ts b/src/Terminal/commands/home.ts index 12f120d60..09bd81765 100644 --- a/src/Terminal/commands/home.ts +++ b/src/Terminal/commands/home.ts @@ -1,11 +1,11 @@ import { ITerminal } from "../ITerminal"; -import { IEngine } from "../../IEngine"; +import { IRouter } from "../../ui/Router"; import { IPlayer } from "../../PersonObjects/IPlayer"; import { BaseServer } from "../../Server/BaseServer"; export function home( terminal: ITerminal, - engine: IEngine, + router: IRouter, player: IPlayer, server: BaseServer, args: (string | number)[], diff --git a/src/Terminal/commands/hostname.ts b/src/Terminal/commands/hostname.ts index d1dcae62a..13340e9a7 100644 --- a/src/Terminal/commands/hostname.ts +++ b/src/Terminal/commands/hostname.ts @@ -1,11 +1,11 @@ import { ITerminal } from "../ITerminal"; -import { IEngine } from "../../IEngine"; +import { IRouter } from "../../ui/Router"; import { IPlayer } from "../../PersonObjects/IPlayer"; import { BaseServer } from "../../Server/BaseServer"; export function hostname( terminal: ITerminal, - engine: IEngine, + router: IRouter, player: IPlayer, server: BaseServer, args: (string | number)[], diff --git a/src/Terminal/commands/ifconfig.ts b/src/Terminal/commands/ifconfig.ts index 68cf00852..d5bfa3ac0 100644 --- a/src/Terminal/commands/ifconfig.ts +++ b/src/Terminal/commands/ifconfig.ts @@ -1,11 +1,11 @@ import { ITerminal } from "../ITerminal"; -import { IEngine } from "../../IEngine"; +import { IRouter } from "../../ui/Router"; import { IPlayer } from "../../PersonObjects/IPlayer"; import { BaseServer } from "../../Server/BaseServer"; export function ifconfig( terminal: ITerminal, - engine: IEngine, + router: IRouter, player: IPlayer, server: BaseServer, args: (string | number)[], diff --git a/src/Terminal/commands/kill.ts b/src/Terminal/commands/kill.ts index 61ebcbf1c..08ba7efd2 100644 --- a/src/Terminal/commands/kill.ts +++ b/src/Terminal/commands/kill.ts @@ -1,12 +1,12 @@ import { ITerminal } from "../ITerminal"; -import { IEngine } from "../../IEngine"; +import { IRouter } from "../../ui/Router"; import { IPlayer } from "../../PersonObjects/IPlayer"; import { BaseServer } from "../../Server/BaseServer"; import { killWorkerScript } from "../../Netscript/killWorkerScript"; export function kill( terminal: ITerminal, - engine: IEngine, + router: IRouter, player: IPlayer, server: BaseServer, args: (string | number)[], diff --git a/src/Terminal/commands/killall.ts b/src/Terminal/commands/killall.ts index a5a237617..72326c2bb 100644 --- a/src/Terminal/commands/killall.ts +++ b/src/Terminal/commands/killall.ts @@ -1,11 +1,11 @@ import { ITerminal } from "../ITerminal"; -import { IEngine } from "../../IEngine"; +import { IRouter } from "../../ui/Router"; import { IPlayer } from "../../PersonObjects/IPlayer"; import { BaseServer } from "../../Server/BaseServer"; import { killWorkerScript } from "../../Netscript/killWorkerScript"; import { WorkerScriptStartStopEventEmitter } from "../../Netscript/WorkerScriptStartStopEventEmitter"; -export function killall(terminal: ITerminal, engine: IEngine, player: IPlayer, server: BaseServer): void { +export function killall(terminal: ITerminal, router: IRouter, player: IPlayer, server: BaseServer): void { for (let i = server.runningScripts.length - 1; i >= 0; --i) { killWorkerScript(server.runningScripts[i], server.ip, false); } diff --git a/src/Terminal/commands/ls.tsx b/src/Terminal/commands/ls.tsx index 8d6c346c9..24d3a1420 100644 --- a/src/Terminal/commands/ls.tsx +++ b/src/Terminal/commands/ls.tsx @@ -1,5 +1,5 @@ import { ITerminal } from "../ITerminal"; -import { IEngine } from "../../IEngine"; +import { IRouter } from "../../ui/Router"; import { IPlayer } from "../../PersonObjects/IPlayer"; import { BaseServer } from "../../Server/BaseServer"; import { Message } from "../../Message/Message"; @@ -7,7 +7,7 @@ import { getFirstParentDirectory, isValidDirectoryPath, evaluateDirectoryPath } export function ls( terminal: ITerminal, - engine: IEngine, + router: IRouter, player: IPlayer, server: BaseServer, args: (string | number)[], diff --git a/src/Terminal/commands/lscpu.ts b/src/Terminal/commands/lscpu.ts index c26d17427..8eba1239e 100644 --- a/src/Terminal/commands/lscpu.ts +++ b/src/Terminal/commands/lscpu.ts @@ -1,7 +1,7 @@ import { ITerminal } from "../ITerminal"; -import { IEngine } from "../../IEngine"; +import { IRouter } from "../../ui/Router"; import { IPlayer } from "../../PersonObjects/IPlayer"; -export function lscpu(terminal: ITerminal, engine: IEngine, player: IPlayer): void { +export function lscpu(terminal: ITerminal, router: IRouter, player: IPlayer): void { terminal.print(player.getCurrentServer().cpuCores + " Core(s)"); } diff --git a/src/Terminal/commands/mem.ts b/src/Terminal/commands/mem.ts index 0d0fd12a6..a08b11c75 100644 --- a/src/Terminal/commands/mem.ts +++ b/src/Terminal/commands/mem.ts @@ -1,12 +1,12 @@ import { ITerminal } from "../ITerminal"; -import { IEngine } from "../../IEngine"; +import { IRouter } from "../../ui/Router"; import { IPlayer } from "../../PersonObjects/IPlayer"; import { BaseServer } from "../../Server/BaseServer"; import { numeralWrapper } from "../../ui/numeralFormat"; export function mem( terminal: ITerminal, - engine: IEngine, + router: IRouter, player: IPlayer, server: BaseServer, args: (string | number)[], diff --git a/src/Terminal/commands/mv.ts b/src/Terminal/commands/mv.ts index 94014932a..f62f5579f 100644 --- a/src/Terminal/commands/mv.ts +++ b/src/Terminal/commands/mv.ts @@ -1,5 +1,5 @@ import { ITerminal } from "../ITerminal"; -import { IEngine } from "../../IEngine"; +import { IRouter } from "../../ui/Router"; import { IPlayer } from "../../PersonObjects/IPlayer"; import { BaseServer } from "../../Server/BaseServer"; import { isScriptFilename } from "../../Script/ScriptHelpersTS"; @@ -8,7 +8,7 @@ import { Script } from "../../Script/Script"; export function mv( terminal: ITerminal, - engine: IEngine, + router: IRouter, player: IPlayer, server: BaseServer, args: (string | number)[], diff --git a/src/Terminal/commands/nano.ts b/src/Terminal/commands/nano.ts index 0195d85fd..ad93cf2f9 100644 --- a/src/Terminal/commands/nano.ts +++ b/src/Terminal/commands/nano.ts @@ -1,5 +1,5 @@ import { ITerminal } from "../ITerminal"; -import { IEngine } from "../../IEngine"; +import { IRouter } from "../../ui/Router"; import { IPlayer } from "../../PersonObjects/IPlayer"; import { BaseServer } from "../../Server/BaseServer"; import { isScriptFilename } from "../../Script/ScriptHelpersTS"; @@ -7,7 +7,7 @@ import { createFconf } from "../../Fconf/Fconf"; export function nano( terminal: ITerminal, - engine: IEngine, + router: IRouter, player: IPlayer, server: BaseServer, args: (string | number)[], @@ -21,7 +21,7 @@ export function nano( const filename = args[0] + ""; if (filename === ".fconf") { const text = createFconf(); - engine.loadScriptEditorContent(filename, text); + router.toScriptEditor(filename, text); return; } else if (isScriptFilename(filename)) { const filepath = terminal.getFilepath(filename); @@ -33,17 +33,17 @@ export function nano( }`; } - engine.loadScriptEditorContent(filepath, code); + router.toScriptEditor(filepath, code); } else { - engine.loadScriptEditorContent(filepath, script.code); + router.toScriptEditor(filepath, script.code); } } else if (filename.endsWith(".txt")) { const filepath = terminal.getFilepath(filename); const txt = terminal.getTextFile(player, filename); if (txt == null) { - engine.loadScriptEditorContent(filepath); + router.toScriptEditor(filepath); } else { - engine.loadScriptEditorContent(filepath, txt.text); + router.toScriptEditor(filepath, txt.text); } } else { terminal.error( diff --git a/src/Terminal/commands/ps.ts b/src/Terminal/commands/ps.ts index 23bf2185d..c18254bbb 100644 --- a/src/Terminal/commands/ps.ts +++ b/src/Terminal/commands/ps.ts @@ -1,11 +1,11 @@ import { ITerminal } from "../ITerminal"; -import { IEngine } from "../../IEngine"; +import { IRouter } from "../../ui/Router"; import { IPlayer } from "../../PersonObjects/IPlayer"; import { BaseServer } from "../../Server/BaseServer"; export function ps( terminal: ITerminal, - engine: IEngine, + router: IRouter, player: IPlayer, server: BaseServer, args: (string | number)[], diff --git a/src/Terminal/commands/rm.ts b/src/Terminal/commands/rm.ts index 0244f2d98..0e91bc496 100644 --- a/src/Terminal/commands/rm.ts +++ b/src/Terminal/commands/rm.ts @@ -1,12 +1,12 @@ import { ITerminal } from "../ITerminal"; -import { IEngine } from "../../IEngine"; +import { IRouter } from "../../ui/Router"; import { IPlayer } from "../../PersonObjects/IPlayer"; import { BaseServer } from "../../Server/BaseServer"; import { IReturnStatus } from "../../types"; export function rm( terminal: ITerminal, - engine: IEngine, + router: IRouter, player: IPlayer, server: BaseServer, args: (string | number)[], diff --git a/src/Terminal/commands/run.ts b/src/Terminal/commands/run.ts index 1335cc40f..cacc9b864 100644 --- a/src/Terminal/commands/run.ts +++ b/src/Terminal/commands/run.ts @@ -1,5 +1,5 @@ import { ITerminal } from "../ITerminal"; -import { IEngine } from "../../IEngine"; +import { IRouter } from "../../ui/Router"; import { IPlayer } from "../../PersonObjects/IPlayer"; import { BaseServer } from "../../Server/BaseServer"; import { isScriptFilename } from "../../Script/ScriptHelpersTS"; @@ -8,7 +8,7 @@ import { runProgram } from "./runProgram"; export function run( terminal: ITerminal, - engine: IEngine, + router: IRouter, player: IPlayer, server: BaseServer, args: (string | number)[], @@ -30,11 +30,11 @@ export function run( // Check if its a script or just a program/executable if (isScriptFilename(executableName)) { - runScript(terminal, engine, player, server, args); + runScript(terminal, router, player, server, args); } else if (executableName.endsWith(".cct")) { terminal.runContract(player, executableName); } else { - runProgram(terminal, engine, player, server, args); + runProgram(terminal, router, player, server, args); } } } diff --git a/src/Terminal/commands/runProgram.ts b/src/Terminal/commands/runProgram.ts index 65ac4979d..868b95813 100644 --- a/src/Terminal/commands/runProgram.ts +++ b/src/Terminal/commands/runProgram.ts @@ -1,12 +1,12 @@ import { ITerminal } from "../ITerminal"; -import { IEngine } from "../../IEngine"; +import { IRouter } from "../../ui/Router"; import { IPlayer } from "../../PersonObjects/IPlayer"; import { BaseServer } from "../../Server/BaseServer"; import { Programs } from "../../Programs/Programs"; export function runProgram( terminal: ITerminal, - engine: IEngine, + router: IRouter, player: IPlayer, server: BaseServer, args: (string | number)[], diff --git a/src/Terminal/commands/runScript.ts b/src/Terminal/commands/runScript.ts index b905c8b45..10b5896ed 100644 --- a/src/Terminal/commands/runScript.ts +++ b/src/Terminal/commands/runScript.ts @@ -1,5 +1,5 @@ import { ITerminal } from "../ITerminal"; -import { IEngine } from "../../IEngine"; +import { IRouter } from "../../ui/Router"; import { IPlayer } from "../../PersonObjects/IPlayer"; import { BaseServer } from "../../Server/BaseServer"; import { logBoxCreate } from "../../../utils/LogBox"; @@ -10,7 +10,7 @@ import * as libarg from "arg"; export function runScript( terminal: ITerminal, - engine: IEngine, + router: IRouter, player: IPlayer, server: BaseServer, commandArgs: (string | number)[], diff --git a/src/Terminal/commands/scan.ts b/src/Terminal/commands/scan.ts index 8fd5246fd..d14d0dbdc 100644 --- a/src/Terminal/commands/scan.ts +++ b/src/Terminal/commands/scan.ts @@ -1,12 +1,12 @@ import { ITerminal } from "../ITerminal"; -import { IEngine } from "../../IEngine"; +import { IRouter } from "../../ui/Router"; import { IPlayer } from "../../PersonObjects/IPlayer"; import { BaseServer } from "../../Server/BaseServer"; import { getServerOnNetwork } from "../../Server/ServerHelpers"; export function scan( terminal: ITerminal, - engine: IEngine, + router: IRouter, player: IPlayer, server: BaseServer, args: (string | number)[], diff --git a/src/Terminal/commands/scananalyze.ts b/src/Terminal/commands/scananalyze.ts index ec5bcf924..3f997a4ea 100644 --- a/src/Terminal/commands/scananalyze.ts +++ b/src/Terminal/commands/scananalyze.ts @@ -1,12 +1,12 @@ import { ITerminal } from "../ITerminal"; -import { IEngine } from "../../IEngine"; +import { IRouter } from "../../ui/Router"; import { IPlayer } from "../../PersonObjects/IPlayer"; import { BaseServer } from "../../Server/BaseServer"; import { Programs } from "../../Programs/Programs"; export function scananalyze( terminal: ITerminal, - engine: IEngine, + router: IRouter, player: IPlayer, server: BaseServer, args: (string | number)[], diff --git a/src/Terminal/commands/scp.ts b/src/Terminal/commands/scp.ts index ec2052153..78d5a559b 100644 --- a/src/Terminal/commands/scp.ts +++ b/src/Terminal/commands/scp.ts @@ -1,5 +1,5 @@ import { ITerminal } from "../ITerminal"; -import { IEngine } from "../../IEngine"; +import { IRouter } from "../../ui/Router"; import { IPlayer } from "../../PersonObjects/IPlayer"; import { BaseServer } from "../../Server/BaseServer"; import { Message } from "../../Message/Message"; @@ -8,7 +8,7 @@ import { isScriptFilename } from "../../Script/ScriptHelpersTS"; export function scp( terminal: ITerminal, - engine: IEngine, + router: IRouter, player: IPlayer, server: BaseServer, args: (string | number)[], diff --git a/src/Terminal/commands/sudov.ts b/src/Terminal/commands/sudov.ts index 609fb1c2c..4457d1da0 100644 --- a/src/Terminal/commands/sudov.ts +++ b/src/Terminal/commands/sudov.ts @@ -1,11 +1,11 @@ import { ITerminal } from "../ITerminal"; -import { IEngine } from "../../IEngine"; +import { IRouter } from "../../ui/Router"; import { IPlayer } from "../../PersonObjects/IPlayer"; import { BaseServer } from "../../Server/BaseServer"; export function sudov( terminal: ITerminal, - engine: IEngine, + router: IRouter, player: IPlayer, server: BaseServer, args: (string | number)[], diff --git a/src/Terminal/commands/tail.ts b/src/Terminal/commands/tail.ts index 5d9de3aca..ef17463cf 100644 --- a/src/Terminal/commands/tail.ts +++ b/src/Terminal/commands/tail.ts @@ -1,5 +1,5 @@ import { ITerminal } from "../ITerminal"; -import { IEngine } from "../../IEngine"; +import { IRouter } from "../../ui/Router"; import { IPlayer } from "../../PersonObjects/IPlayer"; import { BaseServer } from "../../Server/BaseServer"; import { logBoxCreate } from "../../../utils/LogBox"; @@ -9,7 +9,7 @@ import { isScriptFilename } from "../../Script/ScriptHelpersTS"; export function tail( terminal: ITerminal, - engine: IEngine, + router: IRouter, player: IPlayer, server: BaseServer, commandArray: (string | number)[], diff --git a/src/Terminal/commands/theme.ts b/src/Terminal/commands/theme.ts index e8e779db2..62e468132 100644 --- a/src/Terminal/commands/theme.ts +++ b/src/Terminal/commands/theme.ts @@ -1,12 +1,12 @@ import { ITerminal } from "../ITerminal"; -import { IEngine } from "../../IEngine"; +import { IRouter } from "../../ui/Router"; import { IPlayer } from "../../PersonObjects/IPlayer"; import { BaseServer } from "../../Server/BaseServer"; import { FconfSettings } from "../../Fconf/FconfSettings"; export function theme( terminal: ITerminal, - engine: IEngine, + router: IRouter, player: IPlayer, server: BaseServer, args: (string | number)[], diff --git a/src/Terminal/commands/top.ts b/src/Terminal/commands/top.ts index c542d81e9..e3cf72f97 100644 --- a/src/Terminal/commands/top.ts +++ b/src/Terminal/commands/top.ts @@ -1,5 +1,5 @@ import { ITerminal } from "../ITerminal"; -import { IEngine } from "../../IEngine"; +import { IRouter } from "../../ui/Router"; import { IPlayer } from "../../PersonObjects/IPlayer"; import { BaseServer } from "../../Server/BaseServer"; import { getRamUsageFromRunningScript } from "../../Script/RunningScriptHelpers"; @@ -7,7 +7,7 @@ import { numeralWrapper } from "../../ui/numeralFormat"; export function top( terminal: ITerminal, - engine: IEngine, + router: IRouter, player: IPlayer, server: BaseServer, args: (string | number)[], diff --git a/src/Terminal/commands/unalias.ts b/src/Terminal/commands/unalias.ts index 392aad99b..10c274bfb 100644 --- a/src/Terminal/commands/unalias.ts +++ b/src/Terminal/commands/unalias.ts @@ -1,12 +1,12 @@ import { ITerminal } from "../ITerminal"; -import { IEngine } from "../../IEngine"; +import { IRouter } from "../../ui/Router"; import { IPlayer } from "../../PersonObjects/IPlayer"; import { BaseServer } from "../../Server/BaseServer"; import { removeAlias } from "../../Alias"; export function unalias( terminal: ITerminal, - engine: IEngine, + router: IRouter, player: IPlayer, server: BaseServer, args: (string | number)[], diff --git a/src/Terminal/commands/wget.ts b/src/Terminal/commands/wget.ts index eaf08b3eb..066416bee 100644 --- a/src/Terminal/commands/wget.ts +++ b/src/Terminal/commands/wget.ts @@ -1,12 +1,12 @@ import { ITerminal } from "../ITerminal"; -import { IEngine } from "../../IEngine"; +import { IRouter } from "../../ui/Router"; import { IPlayer } from "../../PersonObjects/IPlayer"; import { BaseServer } from "../../Server/BaseServer"; import { isScriptFilename } from "../../Script/ScriptHelpersTS"; export function wget( terminal: ITerminal, - engine: IEngine, + router: IRouter, player: IPlayer, server: BaseServer, args: (string | number)[], diff --git a/src/Terminal/ui/TerminalInput.tsx b/src/Terminal/ui/TerminalInput.tsx index 3934a08d9..e94f4ea4a 100644 --- a/src/Terminal/ui/TerminalInput.tsx +++ b/src/Terminal/ui/TerminalInput.tsx @@ -6,7 +6,7 @@ import createStyles from "@mui/styles/createStyles"; import TextField from "@mui/material/TextField"; import { KEY } from "../../../utils/helpers/keyCodes"; import { ITerminal } from "../ITerminal"; -import { IEngine } from "../../IEngine"; +import { IRouter } from "../../ui/Router"; import { IPlayer } from "../../PersonObjects/IPlayer"; import { determineAllPossibilitiesForTabCompletion } from "../determineAllPossibilitiesForTabCompletion"; import { tabCompletion } from "../tabCompletion"; @@ -37,11 +37,11 @@ const useStyles = makeStyles((theme: Theme) => interface IProps { terminal: ITerminal; - engine: IEngine; + router: IRouter; player: IPlayer; } -export function TerminalInput({ terminal, engine, player }: IProps): React.ReactElement { +export function TerminalInput({ terminal, router, player }: IProps): React.ReactElement { const terminalInput = useRef(null); const [value, setValue] = useState(""); @@ -157,7 +157,7 @@ export function TerminalInput({ terminal, engine, player }: IProps): React.React if (event.keyCode === KEY.ENTER && value !== "") { event.preventDefault(); terminal.print(`[${player.getCurrentServer().hostname} ~${terminal.cwd()}]> ${value}`); - terminal.executeCommands(engine, player, value); + terminal.executeCommands(router, player, value); setValue(""); return; } diff --git a/src/Terminal/ui/TerminalRoot.tsx b/src/Terminal/ui/TerminalRoot.tsx index cc4de1e29..dca127138 100644 --- a/src/Terminal/ui/TerminalRoot.tsx +++ b/src/Terminal/ui/TerminalRoot.tsx @@ -8,7 +8,7 @@ import makeStyles from "@mui/styles/makeStyles"; import createStyles from "@mui/styles/createStyles"; import Box from "@mui/material/Box"; import { ITerminal, Output, Link } from "../ITerminal"; -import { IEngine } from "../../IEngine"; +import { IRouter } from "../../ui/Router"; import { IPlayer } from "../../PersonObjects/IPlayer"; import { TerminalInput } from "./TerminalInput"; @@ -42,11 +42,11 @@ const useStyles = makeStyles((theme: Theme) => interface IProps { terminal: ITerminal; - engine: IEngine; + router: IRouter; player: IPlayer; } -export function TerminalRoot({ terminal, engine, player }: IProps): React.ReactElement { +export function TerminalRoot({ terminal, router, player }: IProps): React.ReactElement { const scrollHook = useRef(null); const setRerender = useState(false)[1]; function rerender(): void { @@ -106,7 +106,7 @@ export function TerminalRoot({ terminal, engine, player }: IProps): React.ReactE
- + ); diff --git a/src/engine.jsx b/src/engine.jsx index d68172824..8d623c752 100644 --- a/src/engine.jsx +++ b/src/engine.jsx @@ -207,25 +207,6 @@ const Engine = { ReactDOM.render(, Engine.Display.content); }, - loadTutorialContent: function () { - Engine.hideAllContent(); - Engine.Display.content.style.display = "block"; - routing.navigateTo(Page.Tutorial); - MainMenuLinks.Tutorial.classList.add("active"); - ReactDOM.render(, Engine.Display.content); - }, - - loadDevMenuContent: function () { - Engine.hideAllContent(); - if (process.env.NODE_ENV !== "development") { - throw new Error("Cannot create Dev Menu because you are not in a dev build"); - } - Engine.Display.content.style.display = "block"; - ReactDOM.render(, Engine.Display.content); - routing.navigateTo(Page.DevMenu); - MainMenuLinks.DevMenu.classList.add("active"); - }, - loadLocationContent: function (initiallyInCity = true) { Engine.hideAllContent(); Engine.Display.content.style.display = "block"; diff --git a/src/ui/GameRoot.tsx b/src/ui/GameRoot.tsx index 5fa9cb350..906535fda 100644 --- a/src/ui/GameRoot.tsx +++ b/src/ui/GameRoot.tsx @@ -69,6 +69,9 @@ const useStyles = makeStyles((theme: Theme) => }), ); +let filename = ""; +let code = ""; + export function GameRoot({ player, engine, terminal }: IProps): React.ReactElement { const contentRef = useRef(null); const [faction, setFaction] = useState(null); @@ -93,7 +96,11 @@ export function GameRoot({ player, engine, terminal }: IProps): React.ReactEleme toHacknetNodes: () => setPage(Page.Hacknet), toMilestones: () => setPage(Page.Milestones), toResleeves: () => setPage(Page.Resleeves), - toScriptEditor: () => setPage(Page.CreateScript), + toScriptEditor: (fn: string, c: string) => { + filename = fn; + code = c; + setPage(Page.CreateScript); + }, toSleeves: () => setPage(Page.Sleeves), toStockMarket: () => setPage(Page.StockMarket), toTerminal: () => setPage(Page.Terminal), @@ -113,19 +120,24 @@ export function GameRoot({ player, engine, terminal }: IProps): React.ReactEleme }, }; + useEffect(() => { + filename = ""; + code = ""; + }); + return ( <> {page === Page.Terminal ? ( - + ) : page === Page.Sleeves ? ( ) : page === Page.Stats ? ( ) : page === Page.CreateScript ? ( - + ) : page === Page.ActiveScripts ? ( ) : page === Page.Hacknet ? (