UI: Add a stop button to bladeburner (#1312)

This commit is contained in:
Kelenius 2024-05-28 01:02:56 +03:00 committed by GitHub
parent 30cdaa1a7a
commit bf5c43daa2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 22 additions and 1 deletions

@ -8,6 +8,7 @@ import { convertTimeMsToTimeElapsedString } from "../../utils/StringHelperFuncti
import { Player } from "@player"; import { Player } from "@player";
import { CopyableText } from "../../ui/React/CopyableText"; import { CopyableText } from "../../ui/React/CopyableText";
import { StartButton } from "./StartButton"; import { StartButton } from "./StartButton";
import { StopButton } from "./StopButton";
import { Box, Paper, Typography } from "@mui/material"; import { Box, Paper, Typography } from "@mui/material";
import { useRerender } from "../../ui/React/hooks"; import { useRerender } from "../../ui/React/hooks";
@ -31,7 +32,10 @@ export function GeneralActionElem({ bladeburner, action }: GeneralActionElemProp
<Paper sx={{ my: 1, p: 1 }}> <Paper sx={{ my: 1, p: 1 }}>
{isActive ? ( {isActive ? (
<> <>
<CopyableText value={action.name} /> <Box display="flex" flexDirection="row" alignItems="center">
<CopyableText value={action.name} />
<StopButton bladeburner={bladeburner} rerender={rerender} />
</Box>
<Typography> <Typography>
(IN PROGRESS - {formatNumberNoSuffix(computedActionTimeCurrent, 0)} /{" "} (IN PROGRESS - {formatNumberNoSuffix(computedActionTimeCurrent, 0)} /{" "}
{formatNumberNoSuffix(bladeburner.actionTimeToComplete, 0)}) {formatNumberNoSuffix(bladeburner.actionTimeToComplete, 0)})

@ -0,0 +1,17 @@
import type { Bladeburner } from "../Bladeburner";
import React from "react";
import { Button } from "@mui/material";
interface StopButtonProps {
bladeburner: Bladeburner;
rerender: () => void;
}
export function StopButton({ bladeburner, rerender }: StopButtonProps): React.ReactElement {
function onClick(): void {
bladeburner.resetAction();
rerender();
}
return <Button onClick={onClick}>Stop</Button>;
}