From bc739e9bf0e222346154cf21c23884d73d62fbcf Mon Sep 17 00:00:00 2001 From: Victor Giers Date: Mon, 27 Apr 2026 15:58:57 +0200 Subject: [PATCH] Refactor player start logic: Update default state values and simplify keyboard binding handlers --- src/app/App.tsx | 35 +++++++++++++---------------------- 1 file changed, 13 insertions(+), 22 deletions(-) diff --git a/src/app/App.tsx b/src/app/App.tsx index 3bc388c8..4503e7ea 100644 --- a/src/app/App.tsx +++ b/src/app/App.tsx @@ -2762,11 +2762,11 @@ export function App({ store, initialStatusMessage }: AppProps) { const [ playerStartAllowLookInputTargetSwitchDraft, setPlayerStartAllowLookInputTargetSwitchDraft - ] = useState(DEFAULT_PLAYER_START_ALLOW_LOOK_INPUT_TARGET_SWITCH); + ] = useState(DEFAULT_PLAYER_START_ALLOW_LOOK_INPUT_TARGET_SWITCH_VALUE); const [ playerStartTargetButtonCyclesActiveTargetDraft, setPlayerStartTargetButtonCyclesActiveTargetDraft - ] = useState(DEFAULT_PLAYER_START_TARGET_BUTTON_CYCLES_ACTIVE_TARGET); + ] = useState(DEFAULT_PLAYER_START_TARGET_BUTTON_CYCLES_ACTIVE_TARGET_VALUE); const [ playerStartMovementTemplateDraft, setPlayerStartMovementTemplateDraft @@ -3717,10 +3717,10 @@ export function App({ store, initialStatusMessage }: AppProps) { String(DEFAULT_PLAYER_START_INTERACTION_ANGLE_DEGREES) ); setPlayerStartAllowLookInputTargetSwitchDraft( - DEFAULT_PLAYER_START_ALLOW_LOOK_INPUT_TARGET_SWITCH + DEFAULT_PLAYER_START_ALLOW_LOOK_INPUT_TARGET_SWITCH_VALUE ); setPlayerStartTargetButtonCyclesActiveTargetDraft( - DEFAULT_PLAYER_START_TARGET_BUTTON_CYCLES_ACTIVE_TARGET + DEFAULT_PLAYER_START_TARGET_BUTTON_CYCLES_ACTIVE_TARGET_VALUE ); setPlayerStartMovementTemplateDraft(createPlayerStartMovementTemplate()); setPlayerStartMovementTemplateNumberDraft( @@ -21786,12 +21786,9 @@ export function App({ store, initialStatusMessage }: AppProps) { type="button" data-testid={`player-start-keyboard-binding-${action}`} className="toolbar__button" - onClick={() => { - setPlayerStartKeyboardCaptureAction(action); - setStatusMessage( - `Press any key or mouse button for ${getPlayerStartInputActionLabel(action)}. Press Escape to cancel.` - ); - }} + onClick={() => + beginPlayerStartKeyboardCapture(action) + } > {playerStartKeyboardCaptureAction === action ? "Press Any Key..." @@ -21848,12 +21845,9 @@ export function App({ store, initialStatusMessage }: AppProps) { type="button" data-testid={`player-start-keyboard-binding-${action}`} className="toolbar__button" - onClick={() => { - setPlayerStartKeyboardCaptureAction(action); - setStatusMessage( - `Press any key or mouse button for ${getPlayerStartInputActionLabel(action)}. Press Escape to cancel.` - ); - }} + onClick={() => + beginPlayerStartKeyboardCapture(action) + } > {playerStartKeyboardCaptureAction === action ? "Press Any Key..." @@ -21910,12 +21904,9 @@ export function App({ store, initialStatusMessage }: AppProps) { type="button" data-testid={`player-start-keyboard-binding-${action}`} className="toolbar__button" - onClick={() => { - setPlayerStartKeyboardCaptureAction(action); - setStatusMessage( - `Press any key or mouse button for ${getPlayerStartInputActionLabel(action)}. Press Escape to cancel.` - ); - }} + onClick={() => + beginPlayerStartKeyboardCapture(action) + } > {playerStartKeyboardCaptureAction === action ? "Press Any Key..."