improvements on active scripts

This commit is contained in:
Olivier Gagnon 2021-09-18 01:01:51 -04:00
parent 6f20b0bc30
commit 244e669b2b

@ -6,6 +6,10 @@ import * as React from "react";
import { numeralWrapper } from "../numeralFormat"; import { numeralWrapper } from "../numeralFormat";
import Table from "@mui/material/Table";
import TableCell from "@mui/material/TableCell";
import TableRow from "@mui/material/TableRow";
import TableBody from "@mui/material/TableBody";
import Button from "@mui/material/Button"; import Button from "@mui/material/Button";
import Box from "@mui/material/Box"; import Box from "@mui/material/Box";
import Paper from "@mui/material/Paper"; import Paper from "@mui/material/Paper";
@ -19,6 +23,8 @@ import IconButton from "@mui/material/IconButton";
import DeleteIcon from "@mui/icons-material/Delete"; import DeleteIcon from "@mui/icons-material/Delete";
import ListItemButton from "@mui/material/ListItemButton"; import ListItemButton from "@mui/material/ListItemButton";
import ListItemText from "@mui/material/ListItemText"; import ListItemText from "@mui/material/ListItemText";
import makeStyles from "@mui/styles/makeStyles";
import createStyles from "@mui/styles/createStyles";
import Collapse from "@mui/material/Collapse"; import Collapse from "@mui/material/Collapse";
import ExpandMore from "@mui/icons-material/ExpandMore"; import ExpandMore from "@mui/icons-material/ExpandMore";
@ -32,12 +38,20 @@ import { logBoxCreate } from "../../../utils/LogBox";
import { convertTimeMsToTimeElapsedString } from "../../../utils/StringHelperFunctions"; import { convertTimeMsToTimeElapsedString } from "../../../utils/StringHelperFunctions";
import { arrayToString } from "../../../utils/helpers/arrayToString"; import { arrayToString } from "../../../utils/helpers/arrayToString";
import { Money } from "../React/Money"; import { Money } from "../React/Money";
import { MoneyRate } from "../React/MoneyRate";
const useStyles = makeStyles({
noborder: {
borderBottom: "none",
},
});
type IProps = { type IProps = {
workerScript: WorkerScript; workerScript: WorkerScript;
}; };
export function WorkerScriptAccordion(props: IProps): React.ReactElement { export function WorkerScriptAccordion(props: IProps): React.ReactElement {
const classes = useStyles();
const [open, setOpen] = React.useState(false); const [open, setOpen] = React.useState(false);
const workerScript = props.workerScript; const workerScript = props.workerScript;
const scriptRef = workerScript.scriptRef; const scriptRef = workerScript.scriptRef;
@ -59,33 +73,94 @@ export function WorkerScriptAccordion(props: IProps): React.ReactElement {
return ( return (
<> <>
<ListItemButton onClick={() => setOpen((old) => !old)} component={Paper}> <ListItemButton onClick={() => setOpen((old) => !old)} component={Paper}>
<ListItemText <ListItemText primary={<Typography> {props.workerScript.name}</Typography>} />
primary={<Typography style={{ whiteSpace: "pre-wrap" }}> {props.workerScript.name}</Typography>}
/>
{open ? <ExpandLess /> : <ExpandMore />} {open ? <ExpandLess /> : <ExpandMore />}
</ListItemButton> </ListItemButton>
<Collapse in={open} timeout={0} unmountOnExit> <Collapse in={open} timeout={0} unmountOnExit>
<Box mx={4}> <Box mx={6}>
<pre>Threads: {numeralWrapper.formatThreads(props.workerScript.scriptRef.threads)}</pre> <Table padding="none">
<pre>Args: {arrayToString(props.workerScript.args)}</pre> <TableBody>
<pre>Online Time: {convertTimeMsToTimeElapsedString(scriptRef.onlineRunningTime * 1e3)}</pre> <TableRow>
<pre>Offline Time: {convertTimeMsToTimeElapsedString(scriptRef.offlineRunningTime * 1e3)}</pre> <TableCell className={classes.noborder}>
<pre> <Typography>Threads:</Typography>
Total online production: <Money money={scriptRef.onlineMoneyMade} /> </TableCell>
</pre> <TableCell className={classes.noborder}>
<pre>{Array(26).join(" ") + numeralWrapper.formatExp(scriptRef.onlineExpGained) + " hacking exp"}</pre> <Typography>{numeralWrapper.formatThreads(props.workerScript.scriptRef.threads)}</Typography>
<pre> </TableCell>
Online production rate: <Money money={onlineMps} /> / second </TableRow>
</pre> <TableRow>
<pre>{Array(25).join(" ") + numeralWrapper.formatExp(onlineEps) + " hacking exp / second"}</pre> <TableCell className={classes.noborder} colSpan={2}>
<pre> <Typography>Args: {arrayToString(props.workerScript.args)}</Typography>
Total offline production: <Money money={scriptRef.offlineMoneyMade} /> </TableCell>
</pre> </TableRow>
<pre>{Array(27).join(" ") + numeralWrapper.formatExp(scriptRef.offlineExpGained) + " hacking exp"}</pre> <TableRow>
<pre> <TableCell className={classes.noborder}>
Offline production rate: <Money money={offlineMps} /> / second <Typography>Online Time:</Typography>
</pre> </TableCell>
<pre>{Array(26).join(" ") + numeralWrapper.formatExp(offlineEps) + " hacking exp / second"}</pre> <TableCell className={classes.noborder}>
<Typography>{convertTimeMsToTimeElapsedString(scriptRef.onlineRunningTime * 1e3)}</Typography>
</TableCell>
</TableRow>
<TableRow>
<TableCell className={classes.noborder}>
<Typography>Offline Time:</Typography>
</TableCell>
<TableCell className={classes.noborder}>
<Typography>{convertTimeMsToTimeElapsedString(scriptRef.offlineRunningTime * 1e3)}</Typography>
</TableCell>
</TableRow>
<TableRow>
<TableCell className={classes.noborder}>
<Typography>Total online production:</Typography>
</TableCell>
<TableCell className={classes.noborder} align="left">
<Typography>
<Money money={scriptRef.onlineMoneyMade} />
</Typography>
</TableCell>
</TableRow>
<TableRow>
<TableCell className={classes.noborder} colSpan={1} />
<TableCell className={classes.noborder} align="left">
<Typography>&nbsp;{numeralWrapper.formatExp(scriptRef.onlineExpGained) + " hacking exp"}</Typography>
</TableCell>
</TableRow>
<TableRow>
<TableCell className={classes.noborder}>
<Typography>Online production rate:</Typography>
</TableCell>
<TableCell className={classes.noborder} align="left">
<Typography>
<MoneyRate money={onlineMps} />
</Typography>
</TableCell>
</TableRow>
<TableRow>
<TableCell className={classes.noborder} colSpan={1} />
<TableCell className={classes.noborder} align="left">
<Typography>&nbsp;{numeralWrapper.formatExp(onlineEps) + " hacking exp / sec"}</Typography>
</TableCell>
</TableRow>
<TableRow>
<TableCell className={classes.noborder}>
<Typography>Total offline production:</Typography>
</TableCell>
<TableCell className={classes.noborder} align="left">
<Typography>
<Money money={scriptRef.offlineMoneyMade} />
</Typography>
</TableCell>
</TableRow>
<TableRow>
<TableCell className={classes.noborder} colSpan={1} />
<TableCell className={classes.noborder} align="left">
<Typography>&nbsp;{numeralWrapper.formatExp(scriptRef.offlineExpGained) + " hacking exp"}</Typography>
</TableCell>
</TableRow>
</TableBody>
</Table>
<Button onClick={logClickHandler}> <Button onClick={logClickHandler}>
<Typography>Log</Typography> <Typography>Log</Typography>