Implement player start key binding capture and refine key handling logic

This commit is contained in:
2026-04-27 15:58:10 +02:00
parent a533800451
commit 807e1a543f

View File

@@ -3447,7 +3447,10 @@ export function App({ store, initialStatusMessage }: AppProps) {
return; return;
} }
if (event.code === "Escape") { if (
event.code === "Escape" &&
playerStartKeyboardCaptureAction !== "clearTarget"
) {
setPlayerStartKeyboardCaptureAction(null); setPlayerStartKeyboardCaptureAction(null);
setStatusMessage("Cancelled Player Start key capture."); setStatusMessage("Cancelled Player Start key capture.");
return; return;
@@ -8925,6 +8928,10 @@ export function App({ store, initialStatusMessage }: AppProps) {
navigationMode, navigationMode,
interactionReachMeters, interactionReachMeters,
interactionAngleDegrees, interactionAngleDegrees,
allowLookInputTargetSwitch:
playerStartAllowLookInputTargetSwitchDraft,
targetButtonCyclesActiveTarget:
playerStartTargetButtonCyclesActiveTargetDraft,
movementTemplate, movementTemplate,
inputBindings, inputBindings,
collider: { collider: {
@@ -8958,6 +8965,21 @@ export function App({ store, initialStatusMessage }: AppProps) {
} }
}; };
const beginPlayerStartKeyboardCapture = (action: PlayerStartInputAction) => {
if (playerStartKeyboardCaptureAction === action) {
setPlayerStartKeyboardCaptureAction(null);
setStatusMessage("Cancelled Player Start key capture.");
return;
}
setPlayerStartKeyboardCaptureAction(action);
setStatusMessage(
action === "clearTarget"
? `Press any key or mouse button for ${getPlayerStartInputActionLabel(action)}. Click the binding button again to cancel.`
: `Press any key or mouse button for ${getPlayerStartInputActionLabel(action)}. Press Escape to cancel.`
);
};
const handlePlayerStartKeyboardBindingChange = ( const handlePlayerStartKeyboardBindingChange = (
action: PlayerStartInputAction, action: PlayerStartInputAction,
nextCode: PlayerStartKeyboardBindingCode nextCode: PlayerStartKeyboardBindingCode