From 78e6b2696cd95ddc93699103c55a28412cd6a331 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tr=C3=A8sAbhi?= <43380238+tresabhi@users.noreply.github.com> Date: Tue, 2 Apr 2024 10:04:54 -0500 Subject: [PATCH] fix: word tolerant pitch and yaw --- .../[id]/components/QuickInputs/index.tsx | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/app/tools/tankopedia/[id]/components/QuickInputs/index.tsx b/src/app/tools/tankopedia/[id]/components/QuickInputs/index.tsx index d0adb06ed..0ce8e87f4 100644 --- a/src/app/tools/tankopedia/[id]/components/QuickInputs/index.tsx +++ b/src/app/tools/tankopedia/[id]/components/QuickInputs/index.tsx @@ -57,9 +57,16 @@ export function RotationInputs({ isFullScreen }: RotationInputsProps) { textAlign: 'right', }} onBlur={() => { + const value = Number(turretYawInput.current!.value); + if (isNaN(value)) { + turretYawInput.current!.value = radToDeg(protagonist.yaw).toFixed( + 1, + ); + return; + } const [pitch, yaw] = applyPitchYawLimits( protagonist.pitch, - degToRad(Number(turretYawInput.current!.value)), + degToRad(value), gunModelDefinition.pitch, turretModelDefinition.yaw, hasImprovedVerticalStabilizer, @@ -97,8 +104,15 @@ export function RotationInputs({ isFullScreen }: RotationInputsProps) { textAlign: 'right', }} onBlur={() => { + const value = Number(gunPitchInput.current!.value); + if (isNaN(value)) { + gunPitchInput.current!.value = ( + -radToDeg(protagonist.pitch) + initialGunPitch + ).toFixed(1); + return; + } const [pitch, yaw] = applyPitchYawLimits( - degToRad(-Number(gunPitchInput.current!.value) + initialGunPitch), + degToRad(-value + initialGunPitch), protagonist.yaw, gunModelDefinition.pitch, turretModelDefinition.yaw,