From 6e90a6d5585a8b55a54968aceb28378b07600048 Mon Sep 17 00:00:00 2001 From: Daniel Karbach Date: Thu, 29 May 2025 17:58:45 +0200 Subject: [PATCH] store tracker prefs --- .../js/components/zootr/MixedPoolsTracker.js | 144 ++++++++++-------- resources/sass/zootr.scss | 5 + 2 files changed, 88 insertions(+), 61 deletions(-) diff --git a/resources/js/components/zootr/MixedPoolsTracker.js b/resources/js/components/zootr/MixedPoolsTracker.js index fd4432b..808ccdf 100644 --- a/resources/js/components/zootr/MixedPoolsTracker.js +++ b/resources/js/components/zootr/MixedPoolsTracker.js @@ -2828,17 +2828,26 @@ MapAnnotation.propTypes = { }), }; +const initPrefs = () => { + const dump = localStorage.getItem('zootr.mixed-pools-tracker-prefs'); + if (dump) { + return JSON.parse(dump); + } + return { + showConnectors: true, + showEntrances: true, + showLabels: true, + showMaps: false, + showWarps: true, + }; +}; + const MixedPoolsTracker = () => { const { t } = useTranslation(); const [connections, setConnections] = React.useState({}); const [dragging, setDragging] = React.useState(null); - - const [showConnectors, setShowConnectors] = React.useState(true); - const [showEntrances, setShowEntrances] = React.useState(true); - const [showLabels, setShowLabels] = React.useState(true); - const [showMaps, setShowMaps] = React.useState(true); - const [showWarps, setShowWarps] = React.useState(true); + const [prefs, setPrefs] = React.useState(initPrefs()); const setConnection = React.useCallback((src, dst) => { setConnections((c) => { @@ -3034,34 +3043,19 @@ const MixedPoolsTracker = () => { } }, [setConnections, t]); + const togglePref = React.useCallback((which) => { + setPrefs((oldPrefs) => { + const newPrefs = { + ...oldPrefs, + [which]: !oldPrefs[which], + }; + localStorage.setItem('zootr.mixed-pools-tracker-prefs', JSON.stringify(newPrefs)); + return newPrefs; + }); + }, []); + return
-
- - - -
{superGroups.map((sg) =>
@@ -3131,9 +3125,9 @@ const MixedPoolsTracker = () => { pointerEvents="none" x={map.bg.pos.x} y={map.bg.pos.y} width={map.bg.size.x} - style={{ opacity: showMaps ? 1 : 0.25 }} + style={{ opacity: prefs.showMaps ? 1 : 0.25 }} /> - {map.labelPos && showLabels ? + {map.labelPos && prefs.showLabels ? { {map.short} : null} - {showEntrances ? map.entrances.map((entrance) => + {prefs.showEntrances ? map.entrances.map((entrance) => ) : null} )} - {showConnectors ? + {prefs.showConnectors ? {connectors.map((c) => { )} : null} - {showWarps ? + {prefs.showWarps ? {annotations.map((a) => { : null}
-
- - +
+
+ + + + + +
+
+
; }; diff --git a/resources/sass/zootr.scss b/resources/sass/zootr.scss index 3d0261e..1af50bf 100644 --- a/resources/sass/zootr.scss +++ b/resources/sass/zootr.scss @@ -137,4 +137,9 @@ } } } + .menu-bar { + max-width: 104em; + display: flex; + justify-content: space-between; + } } -- 2.39.5