mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-11-26 17:43:48 +01:00
UI: General devmenu followup changes (#885)
This commit is contained in:
parent
ff0118f2f4
commit
daa7a22786
@ -8,14 +8,16 @@ import {
|
|||||||
Select,
|
Select,
|
||||||
SelectChangeEvent,
|
SelectChangeEvent,
|
||||||
TextField,
|
TextField,
|
||||||
Tooltip,
|
|
||||||
Typography,
|
Typography,
|
||||||
} from "@mui/material";
|
} from "@mui/material";
|
||||||
import ExpandMoreIcon from "@mui/icons-material/ExpandMore";
|
import ExpandMoreIcon from "@mui/icons-material/ExpandMore";
|
||||||
|
|
||||||
import { Player } from "@player";
|
import { Player } from "@player";
|
||||||
import { FactionName } from "@enums";
|
import { FactionName } from "@enums";
|
||||||
|
import { useRerender } from "../../ui/React/hooks";
|
||||||
import { Money } from "../../ui/React/Money";
|
import { Money } from "../../ui/React/Money";
|
||||||
|
import { NumberInput } from "../../ui/React/NumberInput";
|
||||||
|
import { Hashes } from "../../ui/React/Hashes";
|
||||||
import { Router } from "../../ui/GameRoot";
|
import { Router } from "../../ui/GameRoot";
|
||||||
import { Page } from "../../ui/Router";
|
import { Page } from "../../ui/Router";
|
||||||
import { Bladeburner } from "../../Bladeburner/Bladeburner";
|
import { Bladeburner } from "../../Bladeburner/Bladeburner";
|
||||||
@ -23,30 +25,34 @@ import { GangConstants } from "../../Gang/data/Constants";
|
|||||||
import { checkForMessagesToSend } from "../../Message/MessageHelpers";
|
import { checkForMessagesToSend } from "../../Message/MessageHelpers";
|
||||||
import { ThemeEvents } from "../../Themes/ui/Theme";
|
import { ThemeEvents } from "../../Themes/ui/Theme";
|
||||||
import { getEnumHelper } from "../../utils/EnumHelper";
|
import { getEnumHelper } from "../../utils/EnumHelper";
|
||||||
|
import { formatRam } from "../../ui/formatNumber";
|
||||||
|
|
||||||
export function General(): React.ReactElement {
|
export function General(): React.ReactElement {
|
||||||
|
const rerender = useRerender(400);
|
||||||
const [error, setError] = useState(false);
|
const [error, setError] = useState(false);
|
||||||
const [corporationName, setCorporationName] = useState("");
|
const [corporationName, setCorporationName] = useState("");
|
||||||
const [gangFaction, setGangFaction] = useState(FactionName.SlumSnakes);
|
const [gangFaction, setGangFaction] = useState(FactionName.SlumSnakes);
|
||||||
const [devMoney, setDevMoney] = useState(0);
|
const [devMoney, setDevMoney] = useState(0);
|
||||||
const [hash, setHash] = useState(Player.hashManager.hashes);
|
const [hash, setHash] = useState(Player.hashManager.hashes);
|
||||||
const [homeRam, setHomeRam] = useState(Player.getHomeComputer().maxRam);
|
|
||||||
|
|
||||||
// Money functions
|
// Money functions
|
||||||
const moneyValues = [1e6, 1e9, 1e12, 1e15, Infinity];
|
|
||||||
const addCustomMoney = () => !Number.isNaN(devMoney) && Player.gainMoney(devMoney, "other");
|
const addCustomMoney = () => !Number.isNaN(devMoney) && Player.gainMoney(devMoney, "other");
|
||||||
const addMoney = (n: number) => () => Player.gainMoney(n, "other");
|
const addMoney = (n: number) => () => n && Player.gainMoney(n, "other");
|
||||||
const setMoney = (n: number) => () => (Player.money = Number(n));
|
const setMoney = (n: number) => () => {
|
||||||
const addHashes = () => (Player.hashManager.hashes += hash);
|
if (!isNaN(n)) Player.money = n;
|
||||||
|
};
|
||||||
|
const addHashes = () => hash && Player.hashManager.storeHashes(hash);
|
||||||
|
|
||||||
|
const homeComputer = Player.getHomeComputer();
|
||||||
|
|
||||||
// Ram functions
|
// Ram functions
|
||||||
const doubleRam = () => {
|
const doubleRam = () => {
|
||||||
Player.getHomeComputer().maxRam *= 2;
|
homeComputer.maxRam *= 2;
|
||||||
setHomeRam(homeRam * 2);
|
rerender();
|
||||||
};
|
};
|
||||||
const setRam = (gb: number) => () => {
|
const ramSetter = (gb: number) => () => {
|
||||||
Player.getHomeComputer().maxRam = gb;
|
homeComputer.maxRam = gb;
|
||||||
setHomeRam(gb);
|
rerender();
|
||||||
};
|
};
|
||||||
|
|
||||||
// Node-clearing functions
|
// Node-clearing functions
|
||||||
@ -103,17 +109,8 @@ export function General(): React.ReactElement {
|
|||||||
if (error) throw new ReferenceError("Manually thrown error");
|
if (error) throw new ReferenceError("Manually thrown error");
|
||||||
}, [error]);
|
}, [error]);
|
||||||
|
|
||||||
// Component css
|
const moneyValues = [1e6, 1e9, 1e12, 1e15, Infinity];
|
||||||
const smallButtonStyle = { width: "12rem" };
|
const ramValues = [8, 64, 1024, 1048576, 1073741824];
|
||||||
const largeButtonStyle = { width: "20rem" };
|
|
||||||
const noArrowsNumberField = {
|
|
||||||
"& input::-webkit-outer-spin-button, & input::-webkit-inner-spin-button": {
|
|
||||||
display: "none",
|
|
||||||
},
|
|
||||||
"& input[type=number]": {
|
|
||||||
MozAppearance: "textfield",
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Accordion TransitionProps={{ unmountOnExit: true }}>
|
<Accordion TransitionProps={{ unmountOnExit: true }}>
|
||||||
@ -121,67 +118,50 @@ export function General(): React.ReactElement {
|
|||||||
<Typography>General</Typography>
|
<Typography>General</Typography>
|
||||||
</AccordionSummary>
|
</AccordionSummary>
|
||||||
<AccordionDetails>
|
<AccordionDetails>
|
||||||
|
<Typography>
|
||||||
|
Money (current: <Money money={Player.money} />)
|
||||||
|
</Typography>
|
||||||
{moneyValues.map((value) => (
|
{moneyValues.map((value) => (
|
||||||
<Button key={`add money ${value}`} onClick={addMoney(value)}>
|
<Button key={`add money ${value}`} onClick={addMoney(value)}>
|
||||||
<pre>
|
+
|
||||||
+ <Money money={value} />
|
<Money money={value} />
|
||||||
</pre>
|
|
||||||
</Button>
|
</Button>
|
||||||
))}
|
))}
|
||||||
<br />
|
<br />
|
||||||
<Typography>Add Money</Typography>
|
<NumberInput placeholder={"$$$"} onChange={setDevMoney} />
|
||||||
<TextField
|
<Button onClick={addCustomMoney}>Give Money</Button>
|
||||||
placeholder={"$$$"}
|
<Button onClick={setMoney(0)}>Clear Money</Button>
|
||||||
type="number"
|
{Player.hashManager.capacity > 0 && (
|
||||||
onChange={(x) => setDevMoney(parseFloat(x.target.value))}
|
<>
|
||||||
sx={noArrowsNumberField}
|
|
||||||
/>
|
|
||||||
<Button style={smallButtonStyle} onClick={addCustomMoney}>
|
|
||||||
Give Money
|
|
||||||
</Button>
|
|
||||||
<Button
|
|
||||||
style={smallButtonStyle}
|
|
||||||
onClick={setMoney(0)}
|
|
||||||
title="This sets your money to $0, this means the money you had will just vanish without being accounted for where it went and may offset some metrics."
|
|
||||||
>
|
|
||||||
Clear Money
|
|
||||||
</Button>
|
|
||||||
<br />
|
<br />
|
||||||
<TextField
|
<br />
|
||||||
disabled={!Player.hashManager}
|
<Typography>
|
||||||
type="number"
|
Hashes (current: <Hashes hashes={Player.hashManager.hashes} /> /
|
||||||
placeholder={"add Hacknet hashes"}
|
<Hashes hashes={Player.hashManager.capacity} />)
|
||||||
onChange={(x) => setHash(parseFloat(x.target.value))}
|
</Typography>
|
||||||
sx={noArrowsNumberField}
|
<NumberInput disabled={!Player.hashManager} placeholder={"hashes"} onChange={setHash} />
|
||||||
/>
|
<Button disabled={!Player.hashManager} onClick={addHashes}>
|
||||||
<Button disabled={!Player.hashManager} style={smallButtonStyle} onClick={addHashes}>
|
|
||||||
Give Hashes
|
Give Hashes
|
||||||
</Button>
|
</Button>
|
||||||
<Button disabled={!Player.hashManager} style={smallButtonStyle} onClick={() => (Player.hashManager.hashes = 0)}>
|
<Button disabled={!Player.hashManager} onClick={() => (Player.hashManager.hashes = 0)}>
|
||||||
Clear Hashes
|
Clear Hashes
|
||||||
</Button>
|
</Button>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
<br />
|
<br />
|
||||||
<Tooltip placement="top-start" title={`Current RAM: ${Player.getHomeComputer().maxRam} GB`}>
|
<br />
|
||||||
<Typography>Set Home Server RAM</Typography>
|
<Typography>Max Home RAM (current: {formatRam(homeComputer.maxRam)})</Typography>
|
||||||
</Tooltip>
|
{ramValues.map((gb) => (
|
||||||
<Tooltip placement="top" title="Starting RAM">
|
<Button key={gb} onClick={ramSetter(gb)}>
|
||||||
<Button onClick={setRam(8)}>8 GB</Button>
|
{formatRam(gb)}
|
||||||
</Tooltip>
|
</Button>
|
||||||
<Button onClick={setRam(64)}>64 GB</Button>
|
))}
|
||||||
<Button onClick={setRam(1024)}>1 TB</Button>
|
|
||||||
<Button onClick={setRam(1048576)}>1.05 PB</Button>
|
|
||||||
<Tooltip placement="top" title="Max RAM sold by Alpha Ent.">
|
|
||||||
<Button onClick={setRam(1073741824)}>1.07 EB</Button>
|
|
||||||
</Tooltip>
|
|
||||||
<Tooltip placement="top" title="Double Home server's current RAM">
|
|
||||||
<Button onClick={doubleRam}>RAM *= 2</Button>
|
<Button onClick={doubleRam}>RAM *= 2</Button>
|
||||||
</Tooltip>
|
<br />
|
||||||
<br />
|
<br />
|
||||||
<Typography>Corporation:</Typography>
|
<Typography>Corporation:</Typography>
|
||||||
{Player.corporation ? (
|
{Player.corporation ? (
|
||||||
<Button style={smallButtonStyle} onClick={destroyCorporation}>
|
<Button onClick={destroyCorporation}>Destroy Corporation</Button>
|
||||||
Destroy Corporation
|
|
||||||
</Button>
|
|
||||||
) : (
|
) : (
|
||||||
<>
|
<>
|
||||||
<TextField
|
<TextField
|
||||||
@ -189,18 +169,14 @@ export function General(): React.ReactElement {
|
|||||||
value={corporationName}
|
value={corporationName}
|
||||||
onChange={(x) => setCorporationName(x.target.value)}
|
onChange={(x) => setCorporationName(x.target.value)}
|
||||||
/>
|
/>
|
||||||
<br />
|
<Button onClick={createCorporation}>Create Corporation</Button>
|
||||||
<Button style={smallButtonStyle} onClick={createCorporation}>
|
|
||||||
Create Corporation
|
|
||||||
</Button>
|
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
<br />
|
<br />
|
||||||
<Typography>Gang Faction:</Typography>
|
<br />
|
||||||
|
<Typography>Gang:</Typography>
|
||||||
{Player.gang ? (
|
{Player.gang ? (
|
||||||
<Button style={smallButtonStyle} onClick={stopGang}>
|
<Button onClick={stopGang}>Leave Gang</Button>
|
||||||
Leave Gang
|
|
||||||
</Button>
|
|
||||||
) : (
|
) : (
|
||||||
<>
|
<>
|
||||||
<Select value={gangFaction} onChange={setGangFactionDropdown}>
|
<Select value={gangFaction} onChange={setGangFactionDropdown}>
|
||||||
@ -210,45 +186,28 @@ export function General(): React.ReactElement {
|
|||||||
</MenuItem>
|
</MenuItem>
|
||||||
))}
|
))}
|
||||||
</Select>
|
</Select>
|
||||||
<br />
|
<Button onClick={startGang}>Create Gang</Button>
|
||||||
<Button style={smallButtonStyle} onClick={startGang}>
|
|
||||||
Create Gang
|
|
||||||
</Button>
|
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
<br />
|
<br />
|
||||||
|
<br />
|
||||||
<Typography>Bladeburner:</Typography>
|
<Typography>Bladeburner:</Typography>
|
||||||
{Player.bladeburner ? (
|
{Player.bladeburner ? (
|
||||||
<Button style={smallButtonStyle} onClick={leaveBladeburner}>
|
<Button onClick={leaveBladeburner}>Leave BladeBurner</Button>
|
||||||
Leave BladeBurner
|
|
||||||
</Button>
|
|
||||||
) : (
|
) : (
|
||||||
<Button style={smallButtonStyle} onClick={joinBladeburner}>
|
<Button onClick={joinBladeburner}>Join BladeBurner</Button>
|
||||||
Join BladeBurner
|
|
||||||
</Button>
|
|
||||||
)}
|
)}
|
||||||
<br />
|
<br />
|
||||||
<Typography>General:</Typography>
|
|
||||||
<Button style={largeButtonStyle} onClick={quickB1tFlum3}>
|
|
||||||
Quick b1t_flum3.exe
|
|
||||||
</Button>
|
|
||||||
<Button style={largeButtonStyle} onClick={b1tflum3}>
|
|
||||||
Run b1t_flum3.exe
|
|
||||||
</Button>
|
|
||||||
<br />
|
<br />
|
||||||
<Button style={largeButtonStyle} onClick={quickHackW0r1dD43m0n}>
|
<Typography>Misc:</Typography>
|
||||||
Quick w0rld_d34m0n
|
<Button onClick={quickB1tFlum3}>Quick b1t_flum3.exe</Button>
|
||||||
</Button>
|
<Button onClick={b1tflum3}>Run b1t_flum3.exe</Button>
|
||||||
<Button style={largeButtonStyle} onClick={hackW0r1dD43m0n}>
|
|
||||||
Hack w0rld_d34m0n
|
|
||||||
</Button>
|
|
||||||
<br />
|
<br />
|
||||||
<Button style={largeButtonStyle} onClick={() => setError(true)}>
|
<Button onClick={quickHackW0r1dD43m0n}>Quick w0rld_d34m0n</Button>
|
||||||
Throw Error
|
<Button onClick={hackW0r1dD43m0n}>Hack w0rld_d34m0n</Button>
|
||||||
</Button>
|
<br />
|
||||||
<Button style={largeButtonStyle} onClick={checkMessages}>
|
<Button onClick={() => setError(true)}>Throw Error</Button>
|
||||||
Check Messages
|
<Button onClick={checkMessages}>Check Messages</Button>
|
||||||
</Button>
|
|
||||||
</AccordionDetails>
|
</AccordionDetails>
|
||||||
</Accordion>
|
</Accordion>
|
||||||
);
|
);
|
||||||
|
Loading…
Reference in New Issue
Block a user