mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2025-02-17 02:22:23 +01:00
convert game saved to snackbar, index.html is nearly empty now
This commit is contained in:
@ -11,7 +11,7 @@ import { loadSpecialServerIps, SpecialServerIps } from "./Server/SpecialServerIp
|
||||
import { SourceFileFlags } from "./SourceFile/SourceFileFlags";
|
||||
import { loadStockMarket, StockMarket } from "./StockMarket/StockMarket";
|
||||
|
||||
import { createStatusText } from "./ui/createStatusText";
|
||||
import { GameSavedEvents } from "./ui/React/Snackbar";
|
||||
|
||||
import { setTimeoutRef } from "./utils/SetTimeoutRef";
|
||||
import * as ExportBonus from "./ExportBonus";
|
||||
@ -79,7 +79,7 @@ class BitburnerSaveObject {
|
||||
const saveString = this.getSaveString();
|
||||
|
||||
save(saveString)
|
||||
.then(() => createStatusText("Game saved!"))
|
||||
.then(() => GameSavedEvents.emit())
|
||||
.catch((err) => console.error(err));
|
||||
}
|
||||
|
||||
|
@ -40,11 +40,6 @@
|
||||
<body>
|
||||
<div id="entire-game-container">
|
||||
<div id="mainmenu-container" style="display: flex; flex-direction: row"></div>
|
||||
|
||||
<!-- Status text -->
|
||||
<div id="status-text-container">
|
||||
<p id="status-text"></p>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
|
||||
|
@ -66,6 +66,7 @@ import { CharacterOverview } from "./React/CharacterOverview";
|
||||
import { BladeburnerCinematic } from "../Bladeburner/ui/BladeburnerCinematic";
|
||||
import { workerScripts } from "../Netscript/WorkerScripts";
|
||||
import { Unclickable } from "../Exploits/Unclickable";
|
||||
import { Snackbar } from "./React/Snackbar";
|
||||
|
||||
import { enterBitNode } from "../RedPill";
|
||||
import { Context } from "./Context";
|
||||
@ -392,6 +393,7 @@ export function GameRoot({ player, engine, terminal }: IProps): React.ReactEleme
|
||||
</Box>
|
||||
)}
|
||||
<Unclickable />
|
||||
<Snackbar />
|
||||
</Context.Router.Provider>
|
||||
</Context.Player.Provider>
|
||||
);
|
||||
|
29
src/ui/React/Snackbar.tsx
Normal file
29
src/ui/React/Snackbar.tsx
Normal file
@ -0,0 +1,29 @@
|
||||
import React, { useState, useEffect } from "react";
|
||||
|
||||
import { Snackbar as S } from "@mui/material";
|
||||
import { EventEmitter } from "../../utils/EventEmitter";
|
||||
import Typography from "@mui/material/Typography";
|
||||
import Paper from "@mui/material/Paper";
|
||||
|
||||
export const GameSavedEvents = new EventEmitter<[]>();
|
||||
|
||||
export function Snackbar(): React.ReactElement {
|
||||
const [open, setOpen] = useState(false);
|
||||
|
||||
useEffect(() => GameSavedEvents.subscribe(() => setOpen(true)));
|
||||
return (
|
||||
<S
|
||||
open={open}
|
||||
anchorOrigin={{
|
||||
vertical: "top",
|
||||
horizontal: "center",
|
||||
}}
|
||||
autoHideDuration={2000}
|
||||
onClose={() => setOpen(false)}
|
||||
>
|
||||
<Paper sx={{ p: 2 }}>
|
||||
<Typography>Game Saved!</Typography>
|
||||
</Paper>
|
||||
</S>
|
||||
);
|
||||
}
|
Reference in New Issue
Block a user