Added kill all scripts button

This commit is contained in:
Olivier Gagnon
2021-10-26 15:50:55 -04:00
parent f915ba61a9
commit ba72fd7fb5
6 changed files with 210 additions and 167 deletions
+12 -7
View File
@@ -74,6 +74,8 @@ import { InvitationModal } from "../Faction/ui/InvitationModal";
import { enterBitNode } from "../RedPill";
import { Context } from "./Context";
const htmlLocation = location;
interface IProps {
terminal: ITerminal;
player: IPlayer;
@@ -210,6 +212,14 @@ export function GameRoot({ player, engine, terminal }: IProps): React.ReactEleme
return ITutorialEvents.subscribe(rerender);
}, []);
function killAllScripts(): void {
for (const server of GetAllServers()) {
server.runningScripts = [];
}
saveObject.saveGame();
setTimeout(() => htmlLocation.reload(), 2000);
}
Router = {
page: () => page,
toActiveScripts: () => setPage(Page.ActiveScripts),
@@ -280,7 +290,7 @@ export function GameRoot({ player, engine, terminal }: IProps): React.ReactEleme
<Context.Router.Provider value={Router}>
<Overview>
{!ITutorial.isRunning ? (
<CharacterOverview save={() => saveObject.saveGame()} />
<CharacterOverview save={() => saveObject.saveGame()} killScripts={killAllScripts} />
) : (
<InteractiveTutorialRoot />
)}
@@ -362,12 +372,7 @@ export function GameRoot({ player, engine, terminal }: IProps): React.ReactEleme
player={player}
save={() => saveObject.saveGame()}
export={() => saveObject.exportGame()}
forceKill={() => {
for (const server of GetAllServers()) {
server.runningScripts = [];
}
dialogBoxCreate("Forcefully deleted all running scripts. Please save and refresh page.");
}}
forceKill={killAllScripts}
softReset={() => {
dialogBoxCreate("Soft Reset!");
prestigeAugmentation();