import { useState, useEffect, useRef } from "react"; import { motion } from "framer-motion"; import { useUI, useAudio, useConfig } from "../../context/LauncherContext"; interface DevTool { id: string; name: string; view: string; comingSoon: boolean; } const DEV_TOOLS: DevTool[] = [ { id: "pck", name: "PCK Editor", view: "pck-editor", comingSoon: false }, { id: "arc", name: "ARC Editor", view: "arc-editor", comingSoon: false }, { id: "loc", name: "LOC Editor", view: "loc-editor", comingSoon: false }, { id: "grf", name: "GRF Editor", view: "grf-editor", comingSoon: false }, { id: "col", name: "COL Editor", view: "col-editor", comingSoon: false }, { id: "options", name: "Options Editor", view: "options-editor", comingSoon: false } ]; export default function DevtoolsView() { const { setActiveView } = useUI(); const { playPressSound, playBackSound } = useAudio(); const { animationsEnabled } = useConfig(); const [focusIndex, setFocusIndex] = useState(0); const containerRef = useRef(null); const BACK_BUTTON_INDEX = DEV_TOOLS.length; useEffect(() => { const handleKeyDown = (e: KeyboardEvent) => { if (e.key === "Escape" || e.key === "Backspace") { playBackSound(); setActiveView("main"); return; } if (e.key === "ArrowRight") { setFocusIndex((prev) => (prev >= BACK_BUTTON_INDEX ? 0 : prev + 1)); } else if (e.key === "ArrowLeft") { setFocusIndex((prev) => (prev <= 0 ? BACK_BUTTON_INDEX : prev - 1)); } else if (e.key === "ArrowDown") { if (focusIndex < BACK_BUTTON_INDEX) { setFocusIndex(BACK_BUTTON_INDEX); } } else if (e.key === "ArrowUp") { if (focusIndex === BACK_BUTTON_INDEX) { setFocusIndex(0); } } else if (e.key === "Enter") { if (focusIndex === BACK_BUTTON_INDEX) { playBackSound(); setActiveView("main"); } else { playPressSound(); const tool = DEV_TOOLS[focusIndex]; setActiveView(tool.view); } } }; window.addEventListener("keydown", handleKeyDown); return () => window.removeEventListener("keydown", handleKeyDown); }, [focusIndex, playPressSound, playBackSound, setActiveView, BACK_BUTTON_INDEX]); useEffect(() => { if (focusIndex !== null) { const el = containerRef.current?.querySelector(`[data-index="${focusIndex}"]`) as HTMLElement; if (el) el.focus(); } }, [focusIndex]); return (

Developer Tools

{DEV_TOOLS.map((tool, i) => (
setFocusIndex(i)} onClick={() => { playPressSound(); setActiveView(tool.view); }} className={`group flex flex-col items-center gap-3 w-40 p-4 relative transition-all cursor-pointer outline-none border-2 ${focusIndex === i ? "border-[#FFFF55] bg-white/5" : "border-transparent" }`} >
{tool.name} {tool.comingSoon && (
Coming Soon
)}
{tool.name}
))}
); }