Skip to content

Commit

Permalink
minimized tof for overlay
Browse files Browse the repository at this point in the history
  • Loading branch information
ari-party committed Jul 11, 2024
1 parent ed743c1 commit de9590c
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,22 @@ import useElevation from '@/hooks/data/useElevation';
import useProjectile from '@/hooks/data/useProjectile';
import { calculateTimeOfFlight } from '@/utils/math';

export default function TimeOfFlightValue() {
export default function TimeOfFlightValue({
minimized = false,
}: {
minimized?: boolean;
}) {
const t = useTranslations();

const { velocity } = useProjectile();
const [lowArc, highArc] = useElevation();
const distance = useDistanceWithHeight();

const lowArcTof = todec(
Math.max(0, calculateTimeOfFlight(lowArc, velocity, distance)),
);
const highArcTof = todec(calculateTimeOfFlight(highArc, velocity, distance));

return (
<DataContainer>
<Typography level="title-md">{t('typography.timeOfFlight')}</Typography>
Expand All @@ -31,24 +40,20 @@ export default function TimeOfFlightValue() {
>
{lowArc ? (
<>
<Typography>
{todec(
Math.max(0, calculateTimeOfFlight(lowArc, velocity, distance)),
)}
</Typography>
<Typography>{lowArcTof}</Typography>

{!!highArc && (
<>
<Typography component="b" level="body-sm">
{t('typography.or')}
{minimized ? '/' : t('typography.or')}
</Typography>

<Typography>
{t('units.second', {
value: todec(
calculateTimeOfFlight(highArc, velocity, distance),
),
})}
{minimized
? highArcTof
: t('units.second', {
value: highArcTof,
})}
</Typography>
</>
)}
Expand Down
2 changes: 2 additions & 0 deletions packages/mtc-artillery/src/views/Overlay.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import DistanceValue from '@/components/organisms/configuration/Distance';
import ElevationValue from '@/components/organisms/configuration/Elevation';
import MapSelection from '@/components/organisms/configuration/Map';
import ProjectileSelection from '@/components/organisms/configuration/Projectile';
import TimeOfFlightValue from '@/components/organisms/configuration/TimeOfFlight';
import Canvas from '@/components/templates/Canvas';
import RowContainer from '@tauri/atoms/RowContainer';
import Navigation from '@tauri/templates/Navigation';
Expand Down Expand Up @@ -110,6 +111,7 @@ export default function OverlayView() {

<RowContainer>
<DistanceValue />
<TimeOfFlightValue minimized />
</RowContainer>
</ColumnContainer>

Expand Down

0 comments on commit de9590c

Please sign in to comment.