Fix multiple bugs and add debug features
All checks were successful
Build and Publish Mana Loop Docker Image / build-and-publish (push) Successful in 1m56s

- Add debug option to show component names at top of each component
- Fix mana lists to hide empty elemental mana types in ManaDisplay and LabTab
- Fix enchantment designing getting stuck at 99% by auto-saving design on completion
- Add resetFloorHP function and debug button to fix stuck floor HP issues
- Store design data in DesignProgress for proper completion handling
This commit is contained in:
Z User
2026-03-29 13:14:26 +00:00
parent 6dc301bd7b
commit 300e43f8be
13 changed files with 321 additions and 153 deletions

View File

@@ -0,0 +1,67 @@
'use client';
import { createContext, useContext, useState, useEffect, type ReactNode } from 'react';
interface DebugContextType {
showComponentNames: boolean;
toggleComponentNames: () => void;
}
const DebugContext = createContext<DebugContextType | null>(null);
export function DebugProvider({ children }: { children: ReactNode }) {
// Initialize from localStorage if available
const [showComponentNames, setShowComponentNames] = useState(() => {
if (typeof window !== 'undefined') {
const saved = localStorage.getItem('debug-show-component-names');
return saved === 'true';
}
return false;
});
const toggleComponentNames = () => {
setShowComponentNames(prev => {
const newValue = !prev;
localStorage.setItem('debug-show-component-names', String(newValue));
return newValue;
});
};
return (
<DebugContext.Provider value={{ showComponentNames, toggleComponentNames }}>
{children}
</DebugContext.Provider>
);
}
export function useDebug() {
const context = useContext(DebugContext);
if (!context) {
// Return default values if used outside provider
return { showComponentNames: false, toggleComponentNames: () => {} };
}
return context;
}
// Wrapper component to show component name in debug mode
interface DebugNameProps {
name: string;
children: ReactNode;
}
export function DebugName({ name, children }: DebugNameProps) {
const { showComponentNames } = useDebug();
if (!showComponentNames) {
return <>{children}</>;
}
return (
<div className="relative">
<div className="absolute -top-5 left-0 text-[10px] font-mono text-yellow-400 bg-yellow-900/50 px-1 rounded z-50">
{name}
</div>
{children}
</div>
);
}