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;
}
if (event.code === "Escape") {
if (
event.code === "Escape" &&
playerStartKeyboardCaptureAction !== "clearTarget"
) {
setPlayerStartKeyboardCaptureAction(null);
setStatusMessage("Cancelled Player Start key capture.");
return;
@@ -8925,6 +8928,10 @@ export function App({ store, initialStatusMessage }: AppProps) {
navigationMode,
interactionReachMeters,
interactionAngleDegrees,
allowLookInputTargetSwitch:
playerStartAllowLookInputTargetSwitchDraft,
targetButtonCyclesActiveTarget:
playerStartTargetButtonCyclesActiveTargetDraft,
movementTemplate,
inputBindings,
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 = (
action: PlayerStartInputAction,
nextCode: PlayerStartKeyboardBindingCode