import type { ReplayShip, CollisionEvent } from '@common/types/backtrack' interface BacktrackReplayBarProps { isPlaying: boolean replayFrame: number totalFrames: number replaySpeed: number onTogglePlay: () => void onSeek: (frame: number) => void onSpeedChange: (speed: number) => void onClose: () => void replayShips: ReplayShip[] collisionEvent: CollisionEvent | null replayTimeRange?: { start: string; end: string } } export function BacktrackReplayBar({ isPlaying, replayFrame, totalFrames, replaySpeed, onTogglePlay, onSeek, onSpeedChange, onClose, replayShips, collisionEvent, replayTimeRange, }: BacktrackReplayBarProps) { const progress = (replayFrame / totalFrames) * 100 // 타임 계산 let startLabel: string let endLabel: string let currentTimeLabel: string if (replayTimeRange) { const startMs = new Date(replayTimeRange.start).getTime() const endMs = new Date(replayTimeRange.end).getTime() const currentMs = startMs + (replayFrame / totalFrames) * (endMs - startMs) const fmt = (ms: number) => { const d = new Date(ms + 9 * 3600000) // KST const mo = String(d.getUTCMonth() + 1).padStart(2, '0') const day = String(d.getUTCDate()).padStart(2, '0') const hh = String(d.getUTCHours()).padStart(2, '0') const mm = String(d.getUTCMinutes()).padStart(2, '0') return { date: `${mo}-${day}`, time: `${hh}:${mm}` } } const startFmt = fmt(startMs) const endFmt = fmt(endMs) const curFmt = fmt(currentMs) startLabel = `${startFmt.date} ${startFmt.time}` endLabel = `${endFmt.date} ${endFmt.time}` currentTimeLabel = `${curFmt.date} ${curFmt.time} KST` } else { // 기존 하드코딩 폴백 const hours = 18.5 + (replayFrame / totalFrames) * 12 const displayHours = hours >= 24 ? hours - 24 : hours const h = Math.floor(displayHours) const m = Math.round((displayHours - h) * 60) const dayLabel = hours >= 24 ? '02-10' : '02-09' startLabel = '18:30' endLabel = '06:30' currentTimeLabel = `${dayLabel} ${String(h).padStart(2, '0')}:${String(m).padStart(2, '0')} KST` } const handleSeekClick = (e: React.MouseEvent) => { const rect = e.currentTarget.getBoundingClientRect() const pct = Math.max(0, Math.min(1, (e.clientX - rect.left) / rect.width)) onSeek(Math.round(pct * totalFrames)) } return (
{/* Header row */}
역추적 리플레이
{/* Speed buttons */} {[1, 2, 4].map((spd) => ( ))}
{/* Close button */}
{/* Controls row */}
{/* Play/Pause */} {/* Timeline */}
{/* Progress bar */}
{/* Fill */}
{/* Collision marker */} {collisionEvent && (
💥
)}
{/* Thumb */}
{/* Time labels */}
{startLabel} {currentTimeLabel} {endLabel}
{/* Legend row */}
{replayShips.map((ship) => (
{ship.vesselName}
))}
) }