diff --git a/gui/app/public/i18n/en/translation.ftl b/gui/app/public/i18n/en/translation.ftl index f14e564f0..5765662f0 100644 --- a/gui/app/public/i18n/en/translation.ftl +++ b/gui/app/public/i18n/en/translation.ftl @@ -626,28 +626,85 @@ settings-general-tracker_mechanics-trackers_over_usb-description = settings-general-tracker_mechanics-timeout_delay = Timeout delay settings-general-tracker_mechanics-timeout_delay-description = How long until a tracker is marked as '{ tracker-status-disconnected }' when the connection is lost. -settings-stay_aligned-description = Stay Aligned reduces drift by gradually adjusting your trackers to match your relaxed poses. -settings-stay_aligned-setup_group = Setup -settings-stay_aligned-setup-label = Setup Stay Aligned -settings-stay_aligned-setup-label-description = Record how your legs look when relaxed, so Stay Aligned has a reference to align to. -settings-stay_aligned-setup-open = Open setup -settings-stay_aligned-setup-description = You must complete "{ settings-stay_aligned-setup-label }" to enable Stay Aligned. +settings-stay_aligned-description = Stay Aligned reduces yaw drift while you play. Trackers that stay still are held where they are, with no setup. To also correct trackers while you move, turn it on and record the poses you play in. settings-stay_aligned-enabled-label = Enable Stay Aligned -settings-stay_aligned-enabled-label-description = Turn Stay Aligned on or off. Each relaxed pose below can also be turned on or off. -settings-stay_aligned-relaxed_poses-label = Relaxed Poses -settings-stay_aligned-relaxed_poses-description = Stay Aligned uses your relaxed poses to keep the trackers aligned. Use "{ settings-stay_aligned-setup-label }" to update these poses. -settings-stay_aligned-relaxed_poses-pose-description = Turn this on to let Stay Aligned use this pose. Use Save pose to record it. -settings-stay_aligned-relaxed_poses-standing = Adjust trackers while standing -settings-stay_aligned-relaxed_poses-sitting = Adjust trackers while sitting in a chair -settings-stay_aligned-relaxed_poses-flat = Adjust trackers while sitting on the floor, or lying on your back -settings-stay_aligned-relaxed_poses-save_pose = Save pose -settings-stay_aligned-relaxed_poses-reset_pose = Reset pose -settings-stay_aligned-relaxed_poses-close = Close +settings-stay_aligned-enabled-label-description = Turn Stay Aligned on or off for all your trackers. +settings-stay_aligned-status_group = Status +settings-stay_aligned-status-correction = Correction +settings-stay_aligned-status-position = Current detected position +settings-stay_aligned-position-unknown = Not recognised +settings-stay_aligned-position-standing = Standing +settings-stay_aligned-position-sitting = Sitting +settings-stay_aligned-position-flat = On the floor +settings-stay_aligned-position-kneeling = Kneeling +settings-stay_aligned-trackers-missing = No tracker for: { $parts }. +settings-stay_aligned-status-badge-disabled = Off +settings-stay_aligned-status-badge-correcting = Correcting +settings-stay_aligned-status-badge-not_correcting = Not correcting +settings-stay_aligned-status-text-disabled = Turn it on above to hold and correct your trackers. +settings-stay_aligned-status-text-correcting = Moving trackers are corrected using the pose you are in. +settings-stay_aligned-status-text-pose_unusable = Moving trackers are not corrected in this position. +settings-stay_aligned-status-pose-name = { $pose }. +settings-stay_aligned-status-badge-pose-ready = Ready +settings-stay_aligned-status-badge-pose-not_recorded = Not recorded +settings-stay_aligned-status-badge-pose-disabled = Turned off +settings-stay_aligned-status-badge-pose-unknown = Unrecognised +settings-stay_aligned-status-pose-ready = Moving trackers can be corrected with this pose. +settings-stay_aligned-status-pose-not_recorded = Record this pose so moving trackers can be corrected in it. +settings-stay_aligned-status-pose-disabled = This pose is turned off, so moving trackers are not corrected in it. +settings-stay_aligned-status-pose-unknown = Your position does not match any pose, so moving trackers are not corrected. +settings-stay_aligned-status-largest_correction = Largest correction +settings-stay_aligned-status-largest_correction-part = { $part }, since your last reset. +settings-stay_aligned-status-largest_correction-none = No tracker was turned since your last reset. +settings-stay_aligned-status-largest_correction-off = Nothing is corrected while Stay Aligned is off. +settings-stay_aligned-poses_group = Relaxed poses +settings-stay_aligned-poses_group-description = Stay Aligned needs to know how your legs sit when you are relaxed, for each position you play in. Record the ones you use. Only your legs and torso count, arms and hands can be anywhere. +settings-stay_aligned-pose-standing = Standing +settings-stay_aligned-pose-standing-description = Stand relaxed with your legs in your natural stance. +settings-stay_aligned-pose-sitting = Sitting in a chair +settings-stay_aligned-pose-sitting-description = Sit relaxed in a chair, feet on the floor. +settings-stay_aligned-pose-flat = Sitting on the floor or lying on your back +settings-stay_aligned-pose-flat-description = Sit on the floor with your legs in front of you, relaxed. +settings-stay_aligned-badge-recorded = Recorded +settings-stay_aligned-badge-not_recorded = Not recorded +settings-stay_aligned-badge-default = Default +settings-stay_aligned-record = Record +settings-stay_aligned-record_again = Record again +settings-stay_aligned-toggle-record_first = Record this pose first settings-stay_aligned-debug-label = Debugging settings-stay_aligned-debug-description = Please include your settings when reporting problems about Stay Aligned. settings-stay_aligned-debug-copy-label = Copy settings to clipboard settings-stay_aligned-debug-copy-short = Copy +## Stay Aligned pose recorder +settings-stay_aligned-recorder-close = Cancel +settings-stay_aligned-recorder-step-trackers = Trackers +settings-stay_aligned-recorder-step-full_reset = Full reset +settings-stay_aligned-recorder-step-mounting = Mounting calibration +settings-stay_aligned-recorder-step-feet_mounting = Feet calibration +settings-stay_aligned-recorder-step-record = Record pose +settings-stay_aligned-recorder-trackers-intro = Stay Aligned needs a chest, waist or hip tracker plus both thighs and both ankles. +settings-stay_aligned-recorder-trackers-assign = Assign trackers +settings-stay_aligned-recorder-full_reset-intro = Poses are measured from calibrated trackers, so your trackers need a full reset first. +settings-stay_aligned-recorder-mounting-intro = Your leg directions are measured from how the trackers are mounted, so they need calibrating first. +settings-stay_aligned-recorder-feet_mounting-intro = Your foot angles are measured from how the feet trackers are mounted, and your feet have a calibration of their own. +settings-stay_aligned-recorder-arms = Arms and hands can be anywhere. +settings-stay_aligned-recorder-record-step-0 = 1. Press "Start", then get into the pose. +settings-stay_aligned-recorder-record-step-1 = 2. Hold still. The pose is saved as soon as all your trackers are still. +settings-stay_aligned-recorder-start = Start +settings-stay_aligned-recorder-start_over = Start over +settings-stay_aligned-recorder-try_again = Try again +settings-stay_aligned-recorder-redo_preparation = Redo preparation +settings-stay_aligned-recorder-live-hold = Hold the pose and keep your trackers still. +settings-stay_aligned-recorder-live-wrong_pose = Wrong pose. +settings-stay_aligned-recorder-live-detected = Detected: { $position }. +settings-stay_aligned-recorder-live-not_still = Some trackers did not stay still. +settings-stay_aligned-recorder-live-missing = Some trackers are missing. +settings-stay_aligned-recorder-live-not_calibrated = Your trackers need a reset first. +settings-stay_aligned-recorder-part-upper_body = Upper body +settings-stay_aligned-recorder-state-still = Still +settings-stay_aligned-recorder-state-moving = Moving + ## Keybinds Page settings-keybinds-description = Change keybinds for various shortcuts keybind_config-keybind_name = Keybind @@ -1520,35 +1577,6 @@ onboarding-user_height-manual-tip = While adjusting your height, try different p onboarding-user_height-reset-warning = Warning: This will reset your proportions to be based on your height. Are you sure you want to do this? -## Stay Aligned setup -onboarding-stay_aligned-title = Stay Aligned -onboarding-stay_aligned-description = Configure Stay Aligned to keep your trackers aligned. -onboarding-stay_aligned-put_trackers_on-title = Put on your trackers -onboarding-stay_aligned-put_trackers_on-description = To save your resting poses, we'll use the trackers you just assigned. Put on all your trackers, you can see which are which in the figure to the right. -onboarding-stay_aligned-put_trackers_on-trackers_warning = You have fewer than 5 trackers currently connected and assigned! This is the minimum amount of trackers required for Stay Aligned to function properly. -onboarding-stay_aligned-put_trackers_on-next = I have all my trackers on -onboarding-stay_aligned-verify_mounting-title = Mounting Calibration -onboarding-stay_aligned-verify_mounting-change_method = Change method -onboarding-stay_aligned-preparation-title = Preparation -onboarding-stay_aligned-preparation-tip = Make sure to stand upright. Keep looking forward with your arms down at your sides. -onboarding-stay_aligned-relaxed_poses-standing-title = Relaxed Standing Pose -onboarding-stay_aligned-relaxed_poses-standing-step-0 = 1. Stand in a comfortable position. Relax! -onboarding-stay_aligned-relaxed_poses-standing-step-1-v2 = 2. Press the "Save pose" button. -onboarding-stay_aligned-relaxed_poses-sitting-title = Relaxed Sitting in Chair Pose -onboarding-stay_aligned-relaxed_poses-sitting-step-0 = 1. Sit in a comfortable position. Relax! -onboarding-stay_aligned-relaxed_poses-sitting-step-1-v2 = 2. Press the "Save pose" button. -onboarding-stay_aligned-relaxed_poses-flat-title = Relaxed Sitting on Floor Pose -onboarding-stay_aligned-relaxed_poses-flat-step-0 = 1. Sit on the floor with your legs in front. Relax! -onboarding-stay_aligned-relaxed_poses-flat-step-1-v2 = 2. Press the "Save pose" button. -onboarding-stay_aligned-relaxed_poses-skip_step = Skip -onboarding-stay_aligned-done-title = Stay Aligned enabled! -onboarding-stay_aligned-done-description = Your Stay Aligned setup is complete! -onboarding-stay_aligned-done-description-2 = Setup is complete! You may restart the process if you want to recalibrate the poses. -onboarding-stay_aligned-previous_step = Previous -onboarding-stay_aligned-next_step = Next -onboarding-stay_aligned-restart = Restart -onboarding-stay_aligned-done = Done - ## Home home-settings = Home Page Settings home-settings-close = Close @@ -1843,7 +1871,7 @@ tracking_checklist-NETWORK_PROFILE_PUBLIC-settings_desc = Shown when a network a tracking_checklist-STAY_ALIGNED_CONFIGURED = Configure Stay Aligned tracking_checklist-STAY_ALIGNED_CONFIGURED-desc = Record the Stay Aligned poses to reduce drift tracking_checklist-STAY_ALIGNED_CONFIGURED-settings_desc = Shown when Stay Aligned is not enabled. -tracking_checklist-STAY_ALIGNED_CONFIGURED-open = Open Stay Aligned Wizard +tracking_checklist-STAY_ALIGNED_CONFIGURED-open = Open Stay Aligned settings tracking_checklist-VRCHAT_OSC_TRACKING_DISABLED = Enable VRChat OSC tracking data tracking_checklist-VRCHAT_OSC_TRACKING_DISABLED-desc = VRChat is connected, but isn't sending back your head and hand tracking data. Turn on the OSC tracking-data toggle in VRChat's settings. See how to enable it. tracking_checklist-VRCHAT_OSC_TRACKING_DISABLED-settings_desc = Shown when VRChat is connected but does not send back your head and hand tracking data. diff --git a/gui/app/src/App.tsx b/gui/app/src/App.tsx index 2515d94c1..ff8908671 100644 --- a/gui/app/src/App.tsx +++ b/gui/app/src/App.tsx @@ -51,7 +51,6 @@ import { CrashScreen } from './components/CrashScreen'; import { ScaledProportionsPage } from './components/onboarding/pages/body-proportions/ScaledProportions'; import { FirmwareUpdate } from './components/firmware-update/FirmwareUpdate'; import { ConnectionLost } from './components/onboarding/pages/ConnectionLost'; -import { StayAlignedSetup } from './components/onboarding/pages/stay-aligned/StayAlignedSetup'; import { TrackingChecklistProvider } from './components/tracking-checklist/TrackingChecklistProvider'; import { ChecklistPage } from './components/tracking-checklist/TrackingChecklist'; import { QuizSlimeSetQuestion } from './components/onboarding/pages/quiz/SlimeSetQuestion'; @@ -211,7 +210,6 @@ function AppRoutes() { path="body-proportions/scaled" element={} /> - } /> } /> diff --git a/gui/app/src/components/commons/BaseModal.tsx b/gui/app/src/components/commons/BaseModal.tsx index 51ed9faba..0239af9fc 100644 --- a/gui/app/src/components/commons/BaseModal.tsx +++ b/gui/app/src/components/commons/BaseModal.tsx @@ -50,7 +50,8 @@ export function BaseModal({ classNames( 'fixed top-0 right-0 left-0 bottom-0 flex flex-col justify-center', 'items-center w-full h-full bg-background-90 bg-opacity-60', - important ? 'z-50' : 'z-40' + // Above the app chrome (top bar, settings page picker, floating buttons) at z-50 + important ? 'z-[70]' : 'z-[60]' ) } className={ diff --git a/gui/app/src/components/commons/icon/SimevrIcon.tsx b/gui/app/src/components/commons/icon/SimevrIcon.tsx index 2e5ae8a09..fe2644665 100644 --- a/gui/app/src/components/commons/icon/SimevrIcon.tsx +++ b/gui/app/src/components/commons/icon/SimevrIcon.tsx @@ -73,11 +73,7 @@ export function SlimeVRIcon({ drag }: { drag?: boolean }) { stroke="#CD5000" /> - + diff --git a/gui/app/src/components/commons/icon/SlimeVRIcon.tsx b/gui/app/src/components/commons/icon/SlimeVRIcon.tsx index 67bc2e7e3..90a5c4eee 100644 --- a/gui/app/src/components/commons/icon/SlimeVRIcon.tsx +++ b/gui/app/src/components/commons/icon/SlimeVRIcon.tsx @@ -59,11 +59,7 @@ export function SlimeVRIcon({ width = 28 }: { width?: number }) { stroke="#FFFFFF" /> - + diff --git a/gui/app/src/components/onboarding/pages/stay-aligned/StayAlignedSetup.tsx b/gui/app/src/components/onboarding/pages/stay-aligned/StayAlignedSetup.tsx deleted file mode 100644 index 3abaf5e0e..000000000 --- a/gui/app/src/components/onboarding/pages/stay-aligned/StayAlignedSetup.tsx +++ /dev/null @@ -1,239 +0,0 @@ -import { Typography } from '@/components/commons/Typography'; -import { DoneStep } from './stay-aligned-steps/Done'; -import { useLocalization } from '@fluent/react'; -import { - FlatRelaxedPoseStep, - SittingRelaxedPoseStep, - StandingRelaxedPoseStep, -} from './stay-aligned-steps/RelaxedPoseSteps'; -import { - ChangeStayAlignedEnabledRequestT, - MountingMethod, - RpcMessage, -} from 'solarxr-protocol'; -import { useResetsSettings } from '@/hooks/resets-settings'; -import { RPCPacketType, useWebsocketAPI } from '@/hooks/websocket-api'; -import { useEffect, useRef } from 'react'; -import VerticalStepper from '@/components/commons/VerticalStepper'; -import { useBreakpoint } from '@/hooks/breakpoint'; -import { - SkeletonPreviewView, - SkeletonVisualizerWidget, -} from '@/components/widgets/SkeletonVisualizerWidget'; -import { Vector3 } from 'three'; -import { Easing } from '@tweenjs/tween.js'; -import { VerifyMountingStep } from './stay-aligned-steps/VerifyMounting'; -import { PutTrackersOnStep } from './stay-aligned-steps/PutTrackersOnStep'; -import { PreparationStep } from './stay-aligned-steps/PreparationStep'; - -export function enableStayAligned( - enable: boolean, - sendRPCPacket: (type: RpcMessage, data: RPCPacketType) => void -) { - const req = new ChangeStayAlignedEnabledRequestT(); - req.enabled = enable; - sendRPCPacket(RpcMessage.ChangeStayAlignedEnabledRequest, req); -} - -export function StayAlignedSetup() { - const { l10n } = useLocalization(); - const { isMobile } = useBreakpoint('mobile'); - const { sendRPCPacket, useConnectedEffect } = useWebsocketAPI(); - const { resetsSettings } = useResetsSettings(); - - const viewsRef = useRef<{ - cam1?: SkeletonPreviewView; - cam2?: SkeletonPreviewView; - }>({}); - - useConnectedEffect(() => { - // Disable Stay Aligned as soon as we enter the setup flow so that we don't - // adjust the trackers while trying to set up the feature - enableStayAligned(false, sendRPCPacket); - }, []); - - const updateCamSizes = () => { - const views = viewsRef.current; - if (!views.cam1 || !views.cam2) return; - if (!views.cam2.hidden) { - if (isMobile) { - views.cam1.height = 1; - views.cam2.height = 1; - views.cam2.width = 0.5; - views.cam1.width = 0.5; - views.cam1.bottom = 0; - views.cam2.bottom = 0; - views.cam2.left = 0.5; - } else { - views.cam1.height = 0.5; - views.cam2.height = 0.5; - views.cam2.width = 1; - views.cam1.width = 1; - views.cam1.bottom = 0; - views.cam2.bottom = 0.5; - views.cam2.left = 0; - } - } else { - views.cam1.height = 1; - views.cam2.height = 1; - views.cam2.width = 1; - views.cam1.width = 1; - views.cam1.bottom = 0; - views.cam2.bottom = 0; - views.cam2.left = 0; - } - }; - - const onStepChange = (index: number, id?: string) => { - if (id === 'start') { - enableStayAligned(false, sendRPCPacket); - } - - const views = viewsRef.current; - if (!views.cam1 || !views.cam2) return; - switch (id) { - case 'standing': { - views.cam2.hidden = true; - views.cam1.tween - .stop() - .to(new Vector3(0, 1, -6), 500) - .easing(Easing.Quadratic.InOut) - .startFromCurrentValues(); - break; - } - case 'flat': - case 'sitting': { - views.cam2.hidden = false; - views.cam1.tween - .stop() - .to(new Vector3(-5, 1, -0), 500) - .easing(Easing.Quadratic.InOut) - .startFromCurrentValues(); - - views.cam2.tween - .stop() - .to(new Vector3(0, 4, -0.2), 500) - .easing(Easing.Quadratic.InOut) - .startFromCurrentValues(); - break; - } - default: { - views.cam2.hidden = true; - views.cam1.tween - .stop() - .to(new Vector3(3, 2.5, -3), 1000) - .easing(Easing.Quadratic.InOut) - .startFromCurrentValues(); - break; - } - } - - updateCamSizes(); - }; - - useEffect(() => { - updateCamSizes(); - }, [isMobile]); - - return ( -
-
-
- - {l10n.getString('onboarding-stay_aligned-title')} - - - {l10n.getString('onboarding-stay_aligned-description')} - -
-
- -
-
-
- { - viewsRef.current.cam1 = context.addView({ - left: 0, - bottom: 0, - width: 1, - height: 1, - position: new Vector3(3, 2.5, -3), - onHeightChange(v, newHeight) { - v.controls.target.set(0, newHeight / 2, 0); - const scale = Math.max(1, newHeight) / 1.5; - v.camera.zoom = 1 / scale; - }, - }); - - viewsRef.current.cam2 = context.addView({ - left: 0, - bottom: 0.5, - width: 1, - height: 0.5, - hidden: true, - position: new Vector3(3, 2.5, -3), - onHeightChange(v, newHeight) { - v.controls.target.set(0, newHeight / 2, 0); - const scale = Math.max(1, newHeight) / 1.5; - v.camera.zoom = 1 / scale; - }, - }); - }} - /> -
-
- ); -} diff --git a/gui/app/src/components/onboarding/pages/stay-aligned/stay-aligned-steps/Done.tsx b/gui/app/src/components/onboarding/pages/stay-aligned/stay-aligned-steps/Done.tsx deleted file mode 100644 index 90892ff2e..000000000 --- a/gui/app/src/components/onboarding/pages/stay-aligned/stay-aligned-steps/Done.tsx +++ /dev/null @@ -1,27 +0,0 @@ -import { Button } from '@/components/commons/Button'; -import { Typography } from '@/components/commons/Typography'; -import { VerticalStepComponentProps } from '@/components/commons/VerticalStepper'; -import { Localized } from '@fluent/react'; - -export function DoneStep({ goTo }: VerticalStepComponentProps) { - return ( -
-
- - - - - - -
-
- -
-
- ); -} diff --git a/gui/app/src/components/onboarding/pages/stay-aligned/stay-aligned-steps/PreparationStep.tsx b/gui/app/src/components/onboarding/pages/stay-aligned/stay-aligned-steps/PreparationStep.tsx deleted file mode 100644 index 338711801..000000000 --- a/gui/app/src/components/onboarding/pages/stay-aligned/stay-aligned-steps/PreparationStep.tsx +++ /dev/null @@ -1,71 +0,0 @@ -import { Button } from '@/components/commons/Button'; -import { FullResetExamples } from '@/components/commons/FullResetExamples'; -import { TipBox } from '@/components/commons/TipBox'; -import { Typography } from '@/components/commons/Typography'; -import { VerticalStepComponentProps } from '@/components/commons/VerticalStepper'; -import { ResetButton } from '@/components/home/ResetButton'; -import { Localized } from '@fluent/react'; -import { ResetAvailability, ResetType } from 'solarxr-protocol'; -import { useAtomValue } from 'jotai'; -import { serverGuardsAtom } from '@/store/app-store'; - -export function PreparationStep({ - nextStep, - prevStep, - isActive, -}: VerticalStepComponentProps) { - const serverGuards = useAtomValue(serverGuardsAtom); - return ( -
- {serverGuards?.mountingReset === ResetAvailability.NEEDS_FULL_RESET && ( - <> -
- - - -
- - TIP - - -
-
- - )} - {serverGuards && - serverGuards.mountingReset !== ResetAvailability.NEEDS_FULL_RESET && ( -
- -
-
-
- )} -
- ); -} diff --git a/gui/app/src/components/onboarding/pages/stay-aligned/stay-aligned-steps/PutTrackersOnStep.tsx b/gui/app/src/components/onboarding/pages/stay-aligned/stay-aligned-steps/PutTrackersOnStep.tsx deleted file mode 100644 index 5ab361139..000000000 --- a/gui/app/src/components/onboarding/pages/stay-aligned/stay-aligned-steps/PutTrackersOnStep.tsx +++ /dev/null @@ -1,61 +0,0 @@ -import { BodyDisplay } from '@/components/commons/BodyDisplay'; -import { Button } from '@/components/commons/Button'; -import { TipBox, WarningBox } from '@/components/commons/TipBox'; -import { Typography } from '@/components/commons/Typography'; -import { VerticalStepComponentProps } from '@/components/commons/VerticalStepper'; -import { assignedTrackersAtom } from '@/store/app-store'; -import { Localized } from '@fluent/react'; -import { useAtomValue } from 'jotai'; - -export function PutTrackersOnStep({ nextStep }: VerticalStepComponentProps) { - const assignedTrackers = useAtomValue(assignedTrackersAtom); - - // Keep the button while in dev - const canContinue = assignedTrackers.length >= 5 || import.meta.env.DEV; - - return ( -
-
-
-
- - - -
-
- - Tip - -
- {assignedTrackers.length < 5 && ( -
- - Warning - -
- )} -
-
-
- -
-
-
-
- -
-
-
-
- ); -} diff --git a/gui/app/src/components/onboarding/pages/stay-aligned/stay-aligned-steps/RelaxedPoseSteps.tsx b/gui/app/src/components/onboarding/pages/stay-aligned/stay-aligned-steps/RelaxedPoseSteps.tsx deleted file mode 100644 index b8c33b982..000000000 --- a/gui/app/src/components/onboarding/pages/stay-aligned/stay-aligned-steps/RelaxedPoseSteps.tsx +++ /dev/null @@ -1,127 +0,0 @@ -import { Button } from '@/components/commons/Button'; -import { Typography } from '@/components/commons/Typography'; -import { - DetectRelaxedPoseButton, - ResetRelaxedPoseButton, -} from '@/components/stay-aligned/RelaxedPose'; -import { useLocalization } from '@fluent/react'; -import { StayAlignedRelaxedPose } from 'solarxr-protocol'; -import { enableStayAligned } from '@/components/onboarding/pages/stay-aligned/StayAlignedSetup'; -import { useWebsocketAPI } from '@/hooks/websocket-api'; -import { VerticalStepComponentProps } from '@/components/commons/VerticalStepper'; -import { ReactNode } from 'react'; - -function PosePage({ - nextStep, - prevStep, - descriptionKeys, - children, - relaxedPose, - lastStep = false, -}: VerticalStepComponentProps & { - descriptionKeys: string[]; - children: ReactNode; - relaxedPose: StayAlignedRelaxedPose; - lastStep?: boolean; -}) { - const { l10n } = useLocalization(); - const { sendRPCPacket } = useWebsocketAPI(); - return ( -
-
- {descriptionKeys.map((descriptionKey, i) => ( - {l10n.getString(descriptionKey)} - ))} -
-
- {children} -
-
- -
- { - if (lastStep) { - enableStayAligned(true, sendRPCPacket); - } - nextStep(); - }} - pose={relaxedPose} - > - {l10n.getString('onboarding-stay_aligned-relaxed_poses-skip_step')} - - { - if (lastStep) { - enableStayAligned(true, sendRPCPacket); - } - nextStep(); - }} - pose={relaxedPose} - /> -
-
-
- ); -} - -export const StandingRelaxedPoseStep = ( - verticalStepProps: VerticalStepComponentProps -) => ( - - Reset position - -); - -export const SittingRelaxedPoseStep = ( - verticalStepProps: VerticalStepComponentProps -) => ( - - Reset position - -); - -export const FlatRelaxedPoseStep = ( - verticalStepProps: VerticalStepComponentProps -) => ( - - Reset position - -); diff --git a/gui/app/src/components/onboarding/pages/stay-aligned/stay-aligned-steps/VerifyMounting.tsx b/gui/app/src/components/onboarding/pages/stay-aligned/stay-aligned-steps/VerifyMounting.tsx deleted file mode 100644 index ea1e80cfb..000000000 --- a/gui/app/src/components/onboarding/pages/stay-aligned/stay-aligned-steps/VerifyMounting.tsx +++ /dev/null @@ -1,145 +0,0 @@ -import { ReactNode, useState } from 'react'; -import { Button } from '@/components/commons/Button'; -import { Typography } from '@/components/commons/Typography'; -import { - PoseMountingInstructions, - PoseMountingVideo, -} from '@/components/mounting/PoseMountingVideo'; -import { MountingMethod, ResetType } from 'solarxr-protocol'; -import { ResetButton } from '@/components/home/ResetButton'; -import { VerticalStepComponentProps } from '@/components/commons/VerticalStepper'; -import { useCancelMountingOnLeave } from '@/components/onboarding/pages/mounting/MountingFlow'; -import { MountingMethodModal } from '@/components/mounting/MountingMethodModal'; -import { MountingMethodRadio } from '@/components/mounting/MountingMethodRadio'; -import { StepMedia } from '@/components/mounting/StepMountingStatus'; -import { useResetsSettings } from '@/hooks/resets-settings'; - -function MountingLayout({ - instructions, - media, - actions, -}: { - instructions: ReactNode; - media: ReactNode; - actions: ReactNode; -}) { - return ( -
-
-
-
- {instructions} -
-
- {media} -
-
-
{actions}
-
-
- ); -} - -function ChangeMethodButton() { - const [isOpen, setOpen] = useState(false); - - return ( - <> - -
- { - open[1](false); - }} - pose={relaxedPose} - > - {l10n.getString('settings-stay_aligned-relaxed_poses-reset_pose')} - - { - open[1](false); - }} - pose={relaxedPose} - /> -
- - - - ); -} - -export const StandingRelaxedPoseModal = ({ - open, -}: { - open: [boolean, Dispatch>]; -}) => ( - - Reset position - -); - -export const SittingRelaxedPoseModal = ({ - open, -}: { - open: [boolean, Dispatch>]; -}) => ( - - Reset position - -); - -export const FlatRelaxedPoseModal = ({ - open, -}: { - open: [boolean, Dispatch>]; -}) => ( - - Reset position - -); diff --git a/gui/app/src/components/settings/search-destinations.ts b/gui/app/src/components/settings/search-destinations.ts index 606a58b86..4f5c38504 100644 --- a/gui/app/src/components/settings/search-destinations.ts +++ b/gui/app/src/components/settings/search-destinations.ts @@ -43,11 +43,5 @@ export const searchDestinations: SearchDestination[] = [ title: 'navbar-connect_trackers', state: { alonePage: true }, }, - { - section: 'page', - path: '/onboarding/stay-aligned', - title: 'onboarding-stay_aligned-title', - state: { alonePage: true }, - }, { section: 'page', path: '/onboarding/home', title: 'navbar-onboarding' }, ]; diff --git a/gui/app/src/components/stay-aligned/PoseRecorderModal.tsx b/gui/app/src/components/stay-aligned/PoseRecorderModal.tsx new file mode 100644 index 000000000..76dddd9cd --- /dev/null +++ b/gui/app/src/components/stay-aligned/PoseRecorderModal.tsx @@ -0,0 +1,551 @@ +import classNames from 'classnames'; +import { Localized, useLocalization } from '@fluent/react'; +import { ReactNode, useEffect, useMemo } from 'react'; +import { useAtomValue } from 'jotai'; +import { + MountingMethod, + ResetLifecycle, + ResetType, + StayAlignedPart, + StayAlignedPoseCountdownT, + StayAlignedPoseRecordingDetail, + StayAlignedPoseRecordingLifecycle, + StayAlignedPoseRecordingStatusResponseT, + StayAlignedStatusResponseT, +} from 'solarxr-protocol'; +import { BaseModal } from '@/components/commons/BaseModal'; +import { Button } from '@/components/commons/Button'; +import { FullResetExamples } from '@/components/commons/FullResetExamples'; +import { IconButton } from '@/components/commons/IconButton'; +import { Timeline, TimelineItem } from '@/components/commons/Timeline'; +import { Typography } from '@/components/commons/Typography'; +import { CloseIcon } from '@/components/commons/icon/CloseIcon'; +import { ResetButton } from '@/components/home/ResetButton'; +import { + PoseMountingInstructions, + PoseMountingVideo, +} from '@/components/mounting/PoseMountingVideo'; +import { StepMedia } from '@/components/mounting/StepMountingStatus'; +import { useCancelReset } from '@/hooks/reset'; +import { useLocaleConfig } from '@/i18n/config'; +import { + PART_LABEL, + POSE_DESCRIPTION, + POSE_IMAGE, + POSE_TITLE, + RecordablePose, + RecorderStep, + useRecorderSteps, + useStayAlignedRecording, +} from '@/hooks/stay-aligned'; +import { resetStatusAtom } from '@/store/app-store'; +import { RecordingLive } from './RecordingLive'; + +const MODAL_CLASSES = classNames( + 'focus:ring-transparent focus:ring-offset-transparent focus:outline-transparent outline-none', + 'relative flex flex-col gap-4 bg-background-70 border border-background-60 p-6 rounded-lg m-2', + 'text-background-10 text-standard w-[min(920px,100%)]', + 'mobile:w-full mobile:p-4 mobile:h-[min(40rem,calc(100dvh-1rem))]' +); + +const STEP_TITLE: Record = { + trackers: 'settings-stay_aligned-recorder-step-trackers', + 'full-reset': 'settings-stay_aligned-recorder-step-full_reset', + mounting: 'settings-stay_aligned-recorder-step-mounting', + 'feet-mounting': 'settings-stay_aligned-recorder-step-feet_mounting', + record: 'settings-stay_aligned-recorder-step-record', +}; + +interface RecorderFrame { + pose: RecordablePose; + timeline: RecorderStep[]; + current: RecorderStep; + onClose: () => void; +} + +function RecorderTimeline({ + timeline, + current, + body, +}: { + timeline: RecorderStep[]; + current: RecorderStep; + body: ReactNode; +}) { + if (timeline.length === 1) return <>{body}; + + const currentIndex = timeline.indexOf(current); + const stateOf = (index: number) => { + if (index < currentIndex) return 'done'; + if (index === currentIndex) return 'current'; + return 'todo'; + }; + + return ( + + {timeline.map((step, index) => ( + } + > + {step === current && ( +
{body}
+ )} +
+ ))} +
+ ); +} + +function RecorderLayout({ + frame, + body, + media, + actions, +}: { + frame: RecorderFrame; + body: ReactNode; + media: ReactNode; + actions: ReactNode; +}) { + return ( + <> + + + + +
+
+ +
+
+ {media} +
+
+
+
+ + ); +} + +function TrackersStep({ + frame, + missingParts, +}: { + frame: RecorderFrame; + missingParts: StayAlignedPart[]; +}) { + const { l10n } = useLocalization(); + const { currentLocales } = useLocaleConfig(); + const partList = useMemo( + () => new Intl.ListFormat(currentLocales, { type: 'conjunction' }), + [currentLocales] + ); + + return ( + + + l10n.getString(PART_LABEL[part])) + ), + }} + /> + + } + media={ + + } + actions={ + + ); + } + if (phase === 'waiting') { + return ( + - ); -} - -/** - * Tells the server to reset the angles in a relaxed pose. - */ -export function ResetRelaxedPoseButton({ - pose, - variant = 'primary', - onClick, - children, -}: { - variant: ButtonProps['variant']; - pose: StayAlignedRelaxedPose; - onClick?: MouseEventHandler; -} & React.PropsWithChildren) { - const { sendRPCPacket } = useWebsocketAPI(); - const { l10n } = useLocalization(); - - return ( - - ); -} diff --git a/gui/app/src/components/stay-aligned/StayAlignedStatusRow.tsx b/gui/app/src/components/stay-aligned/StayAlignedStatusRow.tsx new file mode 100644 index 000000000..85829454d --- /dev/null +++ b/gui/app/src/components/stay-aligned/StayAlignedStatusRow.tsx @@ -0,0 +1,220 @@ +import { useLocalization } from '@fluent/react'; +import { useMemo } from 'react'; +import { + BodyPart, + StayAlignedPoseState, + StayAlignedStatusResponseT, +} from 'solarxr-protocol'; +import { + StatusBadge, + StatusRow, + StatusVariant, +} from '@/components/commons/StatusBadge'; +import { Typography } from '@/components/commons/Typography'; +import { useLocaleConfig } from '@/i18n/config'; +import { PART_LABEL, POSITION_LABEL } from '@/hooks/stay-aligned'; + +interface StatusLine { + variant: StatusVariant; + badge: string; + text: string; +} + +const POSE_STATUS: Record = { + [StayAlignedPoseState.ENABLED]: { + variant: 'success', + badge: 'settings-stay_aligned-status-badge-pose-ready', + text: 'settings-stay_aligned-status-pose-ready', + }, + [StayAlignedPoseState.NOT_RECORDED]: { + variant: 'warning', + badge: 'settings-stay_aligned-status-badge-pose-not_recorded', + text: 'settings-stay_aligned-status-pose-not_recorded', + }, + [StayAlignedPoseState.DISABLED]: { + variant: 'neutral', + badge: 'settings-stay_aligned-status-badge-pose-disabled', + text: 'settings-stay_aligned-status-pose-disabled', + }, +}; + +const POSE_UNKNOWN: StatusLine = { + variant: 'warning', + badge: 'settings-stay_aligned-status-badge-pose-unknown', + text: 'settings-stay_aligned-status-pose-unknown', +}; + +function correction(status: StayAlignedStatusResponseT): StatusLine { + if (!status.enabled) { + return { + variant: 'neutral', + badge: 'settings-stay_aligned-status-badge-disabled', + text: 'settings-stay_aligned-status-text-disabled', + }; + } + if (status.missingParts.length > 0) { + return { + variant: 'warning', + badge: 'settings-stay_aligned-status-badge-not_correcting', + text: 'settings-stay_aligned-trackers-missing', + }; + } + if (status.detectedPose?.state !== StayAlignedPoseState.ENABLED) { + return { + variant: 'neutral', + badge: 'settings-stay_aligned-status-badge-not_correcting', + text: 'settings-stay_aligned-status-text-pose_unusable', + }; + } + return { + variant: 'success', + badge: 'settings-stay_aligned-status-badge-correcting', + text: 'settings-stay_aligned-status-text-correcting', + }; +} + +function position(status: StayAlignedStatusResponseT): StatusLine { + const line = status.detectedPose + ? POSE_STATUS[status.detectedPose.state] + : POSE_UNKNOWN; + // Nothing is corrected while Stay Aligned is off, so no pose is good or bad + if (!status.enabled) return { ...line, variant: 'neutral' }; + return line; +} + +function PositionText({ + status, + text, +}: { + status: StayAlignedStatusResponseT; + text: string; +}) { + const { l10n } = useLocalization(); + if (!status.detectedPose) return ; + return ( +

+ {' '} + +

+ ); +} + +function CorrectionValue({ status }: { status: StayAlignedStatusResponseT }) { + const { currentLocales } = useLocaleConfig(); + const degreeFormat = useMemo( + () => + new Intl.NumberFormat(currentLocales, { + style: 'unit', + unit: 'degree', + unitDisplay: 'narrow', + minimumFractionDigits: 1, + maximumFractionDigits: 1, + }), + [currentLocales] + ); + + return ( + + + {degreeFormat.format(status.largestCorrection?.degrees ?? 0)} + + + ); +} + +function CorrectionText({ status }: { status: StayAlignedStatusResponseT }) { + const { l10n } = useLocalization(); + if (!status.enabled) { + return ( + + ); + } + if (!status.largestCorrection) { + return ( + + ); + } + return ( + + ); +} + +export function StayAlignedStatusRow({ + status, +}: { + status: StayAlignedStatusResponseT | null; +}) { + const { l10n } = useLocalization(); + const { currentLocales } = useLocaleConfig(); + const partList = useMemo( + () => new Intl.ListFormat(currentLocales, { type: 'conjunction' }), + [currentLocales] + ); + const shown = status && correction(status); + const pose = status && position(status); + + return ( +
+ + } + badge={ + shown && + } + > + {status && shown && ( + + l10n.getString(PART_LABEL[part]) + ) + ), + }} + /> + )} + + + } + badge={pose && } + > + {status && pose && } + + + } + badge={status && } + > + {status && } + +
+ ); +} diff --git a/gui/app/src/components/tracking-checklist/TrackingChecklist.tsx b/gui/app/src/components/tracking-checklist/TrackingChecklist.tsx index a45f1a012..7d8bcebdf 100644 --- a/gui/app/src/components/tracking-checklist/TrackingChecklist.tsx +++ b/gui/app/src/components/tracking-checklist/TrackingChecklist.tsx @@ -454,8 +454,7 @@ const stepContentLookup: Record<