From b8bfefde693bfc3d6b8e8faf635981b48bf0267f Mon Sep 17 00:00:00 2001 From: Francisco Salgueiro Date: Thu, 5 Dec 2024 18:39:39 +0000 Subject: [PATCH] add warning about enabling WDL (closes #443) --- src/components/common/EvalChart.tsx | 87 +++++++++++++++++------------ src/translation/en_US.ts | 2 + 2 files changed, 52 insertions(+), 37 deletions(-) diff --git a/src/components/common/EvalChart.tsx b/src/components/common/EvalChart.tsx index 6f2be14b..3daf020a 100644 --- a/src/components/common/EvalChart.tsx +++ b/src/components/common/EvalChart.tsx @@ -10,6 +10,7 @@ import { } from "@/utils/treeReducer"; import { AreaChart } from "@mantine/charts"; import { + Alert, Box, LoadingOverlay, Paper, @@ -20,12 +21,13 @@ import { } from "@mantine/core"; import equal from "fast-deep-equal"; import { useAtom } from "jotai"; -import { useContext } from "react"; +import { useContext, useMemo } from "react"; import { useTranslation } from "react-i18next"; import type { CategoricalChartFunc } from "recharts/types/chart/generateCategoricalChart"; import { useStore } from "zustand"; import * as classes from "./EvalChart.css"; import { TreeStateContext } from "./TreeStateContext"; +import { IconInfoCircle } from "@tabler/icons-react"; interface EvalChartProps { isAnalysing: boolean; @@ -168,6 +170,12 @@ function EvalChart(props: EvalChartProps) { const [chartType, setChartType] = useAtom(reportTypeAtom); + const isWDLDisabled = useMemo(() => { + return !data.some( + (point) => point.White !== 0 || point.Black !== 0 || point.Draw !== 0, + ); + }, [data]); + return ( @@ -215,42 +223,47 @@ function EvalChart(props: EvalChartProps) { }} /> )} - {chartType === "WDL" && ( - ( - - ), - }} - /> - )} + {chartType === "WDL" && + (isWDLDisabled ? ( + + {t("Board.Analysis.EnableWDL")} + + ) : ( + ( + + ), + }} + /> + ))} ); diff --git a/src/translation/en_US.ts b/src/translation/en_US.ts index fb6ebc77..f9a32517 100644 --- a/src/translation/en_US.ts +++ b/src/translation/en_US.ts @@ -189,6 +189,8 @@ export const en_US = { "Board.Analysis.Analyze": "Analyze", "Board.Analysis.Advantage": "Advantage", "Board.Analysis.Accuracy": "Accuracy", + "Board.Analysis.EnableWDL": + "You have to enable UCI_ShowWDL in the engine settings to use this feature.", "Board.Database.Local": "Local", "Board.Database.LichessAll": "Lichess All", "Board.Database.LichessMaster": "Lichess Masters",