bitburner-src/src/DevMenu/ui/Augmentations.tsx

90 lines
2.8 KiB
TypeScript
Raw Normal View History

2021-09-14 02:37:35 +02:00
import React, { useState } from "react";
2021-09-17 01:23:03 +02:00
import Accordion from "@mui/material/Accordion";
import AccordionSummary from "@mui/material/AccordionSummary";
import AccordionDetails from "@mui/material/AccordionDetails";
import ExpandMoreIcon from "@mui/icons-material/ExpandMore";
2021-09-14 02:37:35 +02:00
2021-09-17 01:23:03 +02:00
import Select, { SelectChangeEvent } from "@mui/material/Select";
2021-09-14 02:37:35 +02:00
import { IPlayer } from "../../PersonObjects/IPlayer";
import { AugmentationNames } from "../../Augmentation/data/AugmentationNames";
2021-09-17 01:23:03 +02:00
import MenuItem from "@mui/material/MenuItem";
import IconButton from "@mui/material/IconButton";
import ReplyAllIcon from "@mui/icons-material/ReplyAll";
import ReplyIcon from "@mui/icons-material/Reply";
import ClearIcon from "@mui/icons-material/Clear";
2021-09-14 02:37:35 +02:00
interface IProps {
player: IPlayer;
}
export function Augmentations(props: IProps): React.ReactElement {
const [augmentation, setAugmentation] = useState("Augmented Targeting I");
2021-09-17 01:23:03 +02:00
function setAugmentationDropdown(event: SelectChangeEvent<string>): void {
2021-09-14 02:37:35 +02:00
setAugmentation(event.target.value as string);
}
function queueAug(): void {
props.player.queueAugmentation(augmentation);
}
function queueAllAugs(): void {
for (const i in AugmentationNames) {
const augName = AugmentationNames[i];
props.player.queueAugmentation(augName);
}
}
2021-09-16 20:43:39 +02:00
function clearAugs(): void {
props.player.augmentations = [];
}
2021-09-14 02:37:35 +02:00
return (
2021-09-18 03:30:02 +02:00
<Accordion TransitionProps={{ unmountOnExit: true }}>
2021-09-14 02:37:35 +02:00
<AccordionSummary expandIcon={<ExpandMoreIcon />}>
<h2>Augmentations</h2>
</AccordionSummary>
<AccordionDetails>
<table>
<tbody>
<tr>
<td>
<span className="text">Aug:</span>
</td>
<td>
<Select
onChange={setAugmentationDropdown}
value={augmentation}
startAdornment={
<>
2021-09-18 06:16:02 +02:00
<IconButton onClick={queueAllAugs} size="large">
2021-09-14 02:37:35 +02:00
<ReplyAllIcon />
</IconButton>
2021-09-18 06:16:02 +02:00
<IconButton onClick={queueAug} size="large">
2021-09-14 02:37:35 +02:00
<ReplyIcon />
</IconButton>
</>
}
2021-09-16 20:43:39 +02:00
endAdornment={
<>
2021-09-18 06:16:02 +02:00
<IconButton onClick={clearAugs} size="large">
2021-09-16 20:43:39 +02:00
<ClearIcon />
</IconButton>
</>
}
2021-09-14 02:37:35 +02:00
>
{Object.values(AugmentationNames).map((aug) => (
<MenuItem key={aug} value={aug}>
{aug}
</MenuItem>
))}
</Select>
</td>
</tr>
</tbody>
</table>
</AccordionDetails>
</Accordion>
);
}