"use client"; import { useEffect, useState } from "react"; import { useRouter } from "next/navigation"; import type { PinballInstance } from "@valknar/vpinball-wasm"; import { useIdleTimer } from "./useIdleTimer"; import GameInfoPanel from "@/components/GameInfoPanel"; import type { TableInfo } from "@/lib/pinball/types"; export interface CoinDoorHudProps { instanceRef: React.RefObject; tableInfo: TableInfo; loadTimeMs: number | null; } function HudButton({ label, shortLabel, active, onClick, }: { label: string; shortLabel?: string; active?: boolean; onClick: () => void; }) { return ( ); } export default function CoinDoorHud({ instanceRef, tableInfo, loadTimeMs }: CoinDoorHudProps) { const router = useRouter(); const isIdle = useIdleTimer(3000); const [showInfo, setShowInfo] = useState(false); const [isFullscreen, setIsFullscreen] = useState(false); useEffect(() => { const onChange = () => setIsFullscreen(Boolean(document.fullscreenElement)); document.addEventListener("fullscreenchange", onChange); return () => document.removeEventListener("fullscreenchange", onChange); }, []); const handleFullscreen = () => { instanceRef.current?.requestFullscreen(); }; const handleEject = () => { // usePinballInstance's unmount cleanup (triggered by this navigation) // handles stop()+dispose() itself, sequenced to avoid hanging the tab. router.push("/"); }; return ( <>
VPINBALL {tableInfo.name}
setShowInfo((v) => !v)} />
{showInfo && (
)} ); }