bitburner-src/src/ui/React/StatsProgressBar.tsx

68 lines
1.9 KiB
TypeScript
Raw Normal View History

2021-12-18 22:26:50 +01:00
import * as React from "react";
import LinearProgress from "@mui/material/LinearProgress";
2021-12-19 11:45:35 +01:00
import { TableCell, Tooltip, Typography } from "@mui/material";
2021-12-18 22:26:50 +01:00
import { characterOverviewStyles } from "./CharacterOverview";
import { ISkillProgress } from "src/PersonObjects/formulas/skill";
import { numeralWrapper } from "../numeralFormat";
interface IProgressProps {
min: number;
max: number;
current: number;
2021-12-19 11:45:35 +01:00
progress: number;
color?: React.CSSProperties["color"];
}
interface IStatsOverviewCellProps {
progress: ISkillProgress;
color?: React.CSSProperties["color"];
}
2021-12-19 11:45:35 +01:00
export function StatsProgressBar({ min, max, current, progress, color }: IProgressProps): React.ReactElement {
const tooltip = (
<Typography sx={{ textAlign: 'right' }}>
<strong>Progress:</strong>&nbsp;
{numeralWrapper.formatExp(current - min)} / {numeralWrapper.formatExp(max - min)}
2021-12-18 22:26:50 +01:00
<br />
2021-12-19 11:45:35 +01:00
<strong>Remaining:</strong>&nbsp;
{numeralWrapper.formatExp(max - current)} ({progress.toFixed(2)}%)
</Typography>
2021-12-18 22:26:50 +01:00
);
return (
2021-12-19 11:45:35 +01:00
<Tooltip title={tooltip}>
<LinearProgress
variant="determinate"
2021-12-19 11:45:35 +01:00
value={progress}
sx={{
2021-12-18 22:26:50 +01:00
backgroundColor: "#111111",
"& .MuiLinearProgress-bar1Determinate": {
backgroundColor: color,
},
}}
/>
</Tooltip>
);
}
2021-12-19 11:45:35 +01:00
export function StatsProgressOverviewCell({ progress: skill, color }: IStatsOverviewCellProps): React.ReactElement {
const classes = characterOverviewStyles();
return (
2021-12-18 22:26:50 +01:00
<TableCell
component="th"
scope="row"
colSpan={2}
classes={{ root: classes.cellNone }}
2021-12-18 22:26:50 +01:00
style={{ paddingBottom: "2px", position: "relative", top: "-3px" }}
>
<StatsProgressBar
2021-12-19 11:45:35 +01:00
min={skill.baseExperience}
max={skill.nextExperience}
current={skill.experience}
progress={skill.progress}
color={color}
/>
</TableCell>
2021-12-18 22:26:50 +01:00
);
}