From 35fa6dcca116d89c538691349ce6c6805ce9ed59 Mon Sep 17 00:00:00 2001 From: nickofolas Date: Mon, 2 May 2022 16:34:17 -0500 Subject: [PATCH] Basic `WorkInfo` implementation --- src/ui/WorkInProgressRoot.tsx | 67 +++++++++++++++++++++++++++++++++-- 1 file changed, 65 insertions(+), 2 deletions(-) diff --git a/src/ui/WorkInProgressRoot.tsx b/src/ui/WorkInProgressRoot.tsx index cce3a056c..13fc2b919 100644 --- a/src/ui/WorkInProgressRoot.tsx +++ b/src/ui/WorkInProgressRoot.tsx @@ -21,6 +21,24 @@ import { createProgressBarText } from "../utils/helpers/createProgressBarText"; const CYCLES_PER_SEC = 1000 / CONSTANTS.MilliPerCycle; +interface IWorkInfo { + buttons: { + cancel: () => void; + unfocus?: () => void; + }; + title: string | React.ReactElement; + + description?: string | React.ReactElement; + gains?: (string | React.ReactElement)[]; + progress?: { + elapsed?: number; + percentage?: number; + }; + + stopText: string; + stopTooltip?: string | React.ReactElement; +} + export function WorkInProgressRoot(): React.ReactElement { const setRerender = useState(false)[1]; function rerender(): void { @@ -527,7 +545,52 @@ export function WorkInProgressRoot(): React.ReactElement { ); } - if (!player.workType) router.toTerminal(); + return ( + + + {workInfo.title} + {workInfo.description} + + + {workInfo.progress !== undefined && ( + + + {workInfo.progress.elapsed !== undefined && ( + {convertTimeMsToTimeElapsedString(workInfo.progress.elapsed)} elapsed + )} + {workInfo.progress.percentage !== undefined && ( + {workInfo.progress.percentage.toFixed(2)}% done + )} + + {workInfo.progress.percentage !== undefined && ( + + )} + + )} - return <>; + + {workInfo.stopTooltip ? ( + + + + ) : ( + + )} + {workInfo.buttons.unfocus && ( + + )} + + + + ); }