From 4f25b33d3b675629b188b4e4f1b7271ba4df698c Mon Sep 17 00:00:00 2001 From: tom-boullay Date: Thu, 21 May 2026 12:09:12 +0200 Subject: [PATCH] feat(debug): persist and reset debug game state --- src/components/ui/GameSettingsMenu.tsx | 23 ++- src/index.css | 11 ++ src/managers/stores/useGameStore.ts | 183 +++++++++++++++++++++++- src/utils/debug/debugGameStateCookie.ts | 39 +++++ 4 files changed, 251 insertions(+), 5 deletions(-) create mode 100644 src/utils/debug/debugGameStateCookie.ts diff --git a/src/components/ui/GameSettingsMenu.tsx b/src/components/ui/GameSettingsMenu.tsx index e737bb6..8151d39 100644 --- a/src/components/ui/GameSettingsMenu.tsx +++ b/src/components/ui/GameSettingsMenu.tsx @@ -1,10 +1,12 @@ import { useEffect } from "react"; -import { X } from "lucide-react"; +import { RotateCcw, X } from "lucide-react"; +import { useGameStore } from "@/managers/stores/useGameStore"; import { useSettingsStore } from "@/managers/stores/useSettingsStore"; import type { RepairRuntime, SubtitleLanguage, } from "@/managers/stores/useSettingsStore"; +import { isDebugEnabled } from "@/utils/debug/isDebugEnabled"; function formatPercent(value: number): string { return `${Math.round(value * 100)}%`; @@ -52,6 +54,7 @@ function VolumeSlider({ } export function GameSettingsMenu(): React.JSX.Element | null { + const resetGame = useGameStore((state) => state.resetGame); const { isSettingsMenuOpen, musicVolume, @@ -93,6 +96,13 @@ export function GameSettingsMenu(): React.JSX.Element | null { window.location.assign("/"); }; + const handleRestart = (): void => { + resetGame(); + window.location.reload(); + }; + + const showDebugRestart = isDebugEnabled(); + return (
@@ -190,6 +200,17 @@ export function GameSettingsMenu(): React.JSX.Element | null {
+ {showDebugRestart ? ( + + ) : null} +