From 8496d99aeca9e36f6b638802ac458582604a44d1 Mon Sep 17 00:00:00 2001 From: Victor Giers Date: Mon, 27 Apr 2026 16:03:41 +0200 Subject: [PATCH] Refactor type handling in scripts and add player start look/target button controls --- scripts/list-authorable-fields.ts | 21 ++++++++------------- src/app/App.tsx | 28 ++++++++++++++++++++-------- 2 files changed, 28 insertions(+), 21 deletions(-) diff --git a/scripts/list-authorable-fields.ts b/scripts/list-authorable-fields.ts index ea8e514f..61434d74 100644 --- a/scripts/list-authorable-fields.ts +++ b/scripts/list-authorable-fields.ts @@ -324,14 +324,6 @@ function getTypeKey(type: ts.Type): string { ); } -function getTypeLabel(type: ts.Type): string { - try { - return checker.typeToString(type); - } catch { - return getTypeKey(type); - } -} - function isCallableType(type: ts.Type): boolean { const normalizedType = withoutNullish(type); return normalizedType.getCallSignatures().length > 0; @@ -389,10 +381,11 @@ function literalLabel(type: ts.Type): string | null { return String(type.value); } - const typeText = checker.typeToString(type); + const intrinsicName = (type as ts.Type & { intrinsicName?: string }) + .intrinsicName; - if (typeText === "true" || typeText === "false") { - return typeText; + if (intrinsicName === "true" || intrinsicName === "false") { + return intrinsicName; } return null; @@ -610,7 +603,9 @@ function collectUnionFields( const typeLabels = objectTypes.map((objectType) => { const propertyType = getPropertyType(objectType, name); - return propertyType === null ? "" : getTypeLabel(propertyType); + return propertyType === null + ? "" + : getTypeKey(withoutNullish(propertyType)); }); return new Set(typeLabels).size === 1; @@ -635,7 +630,7 @@ function collectUnionFields( ? "" : literalUnionLabels(discriminatorType)[0] ?? ""; const groupKey = - discriminator === null ? getTypeLabel(objectType) : discriminatorValue; + discriminator === null ? getTypeKey(objectType) : discriminatorValue; groupedTypes.set(groupKey, [...(groupedTypes.get(groupKey) ?? []), objectType]); } diff --git a/src/app/App.tsx b/src/app/App.tsx index a90700dd..ce1e3e8c 100644 --- a/src/app/App.tsx +++ b/src/app/App.tsx @@ -8887,10 +8887,12 @@ export function App({ store, initialStatusMessage }: AppProps) { const applyPlayerStartChange = ( overrides: { + allowLookInputTargetSwitch?: boolean; colliderMode?: PlayerStartColliderMode; movementTemplate?: PlayerStartMovementTemplate; navigationMode?: PlayerStartNavigationMode; inputBindings?: PlayerStartInputBindings; + targetButtonCyclesActiveTarget?: boolean; } = {} ) => { if (selectedPlayerStart === null) { @@ -8920,6 +8922,12 @@ export function App({ store, initialStatusMessage }: AppProps) { playerStartInteractionAngleDraft, "Player Start interaction angle" ); + const allowLookInputTargetSwitch = + overrides.allowLookInputTargetSwitch ?? + playerStartAllowLookInputTargetSwitchDraft; + const targetButtonCyclesActiveTarget = + overrides.targetButtonCyclesActiveTarget ?? + playerStartTargetButtonCyclesActiveTargetDraft; const nextEntity = createPlayerStartEntity({ id: selectedPlayerStart.id, name: selectedPlayerStart.name, @@ -8928,10 +8936,8 @@ export function App({ store, initialStatusMessage }: AppProps) { navigationMode, interactionReachMeters, interactionAngleDegrees, - allowLookInputTargetSwitch: - playerStartAllowLookInputTargetSwitchDraft, - targetButtonCyclesActiveTarget: - playerStartTargetButtonCyclesActiveTargetDraft, + allowLookInputTargetSwitch, + targetButtonCyclesActiveTarget, movementTemplate, inputBindings, collider: { @@ -20782,11 +20788,14 @@ export function App({ store, initialStatusMessage }: AppProps) { playerStartAllowLookInputTargetSwitchDraft } onChange={(event) => { + const nextValue = event.currentTarget.checked; setPlayerStartAllowLookInputTargetSwitchDraft( - event.currentTarget.checked + nextValue ); scheduleDraftCommit(() => - applyPlayerStartChange() + applyPlayerStartChange({ + allowLookInputTargetSwitch: nextValue + }) ); }} /> @@ -20802,11 +20811,14 @@ export function App({ store, initialStatusMessage }: AppProps) { playerStartTargetButtonCyclesActiveTargetDraft } onChange={(event) => { + const nextValue = event.currentTarget.checked; setPlayerStartTargetButtonCyclesActiveTargetDraft( - event.currentTarget.checked + nextValue ); scheduleDraftCommit(() => - applyPlayerStartChange() + applyPlayerStartChange({ + targetButtonCyclesActiveTarget: nextValue + }) ); }} />