import { Settings, Guitar, Music, Gauge } from 'lucide-react'; import { TUNINGS, INSTRUMENT_TUNINGS } from '../music/Tunings'; import { INSTRUMENT_DEFINITIONS } from '../music/InstrumentConfigs'; export type Difficulty = string; export interface RhythmSettings { mode: 'bpm' | 'seconds'; bpm: number; seconds: number; active: boolean; autoAdvance: boolean; sound: boolean; volume: number; } export interface AppSettings { difficulty: Difficulty; showHint: boolean; tuningId: string; keySignature: string; instrument: string; showTuningMeter: boolean; rhythm: RhythmSettings; zenMode: boolean; gameMode: 'sight_reading' | 'ear_training'; } interface ControlsProps { settings: AppSettings; onUpdateSettings: (s: AppSettings) => void; } export const Controls: React.FC = ({ settings, onUpdateSettings }) => { const handleDifficultyChange = (e: React.ChangeEvent) => { onUpdateSettings({ ...settings, difficulty: e.target.value as Difficulty }); }; const handleTuningChange = (e: React.ChangeEvent) => { onUpdateSettings({ ...settings, tuningId: e.target.value }); }; const handleInstrumentChange = (e: React.ChangeEvent) => { const newInstrumentId = e.target.value; const instDef = INSTRUMENT_DEFINITIONS[newInstrumentId]; const defaultRange = instDef.ranges[0].id; // Reset tuning if applicable, or just keep as is (it won't be shown/used) let newTuningId = settings.tuningId; if (instDef.showTuning && INSTRUMENT_TUNINGS[newInstrumentId as 'guitar' | 'bass']) { newTuningId = INSTRUMENT_TUNINGS[newInstrumentId as 'guitar' | 'bass'][0]; } onUpdateSettings({ ...settings, instrument: newInstrumentId, difficulty: defaultRange as Difficulty, tuningId: newTuningId }); }; const updateRhythm = (updates: Partial) => { onUpdateSettings({ ...settings, rhythm: { ...settings.rhythm, ...updates } }); }; // Cast instrument to specific key if needed, or use generic record access const availableTunings = INSTRUMENT_TUNINGS[settings.instrument as 'guitar' | 'bass'] || []; const currentInstrumentDef = INSTRUMENT_DEFINITIONS[settings.instrument]; return (
{currentInstrumentDef.showTuning && (
)}
{/* Rhythm Controls */}
{settings.rhythm.active && (
{settings.rhythm.mode === 'bpm' ? (
{settings.rhythm.bpm} BPM updateRhythm({ bpm: Number(e.target.value) })} style={{ flex: 1 }} />
) : (
{settings.rhythm.seconds}s updateRhythm({ seconds: Number(e.target.value) })} style={{ flex: 1 }} />
)}
)}
); };