ISSUE-054 - Basic animating of the Timing Tower added.
Provided basic controls to switch between. Still need to properly round the bottom rows of both the running and retired cars.
This commit is contained in:
1 parent
00d2c671cb
commit
c9388b86fc
12 files changed
+202
-112
No files matched your search
@@ -1,11 +1,19 @@
|
|||||||
|
import { useEffect, useState } from "react";
|
||||||
import { useSelector } from "react-redux";
|
import { useSelector } from "react-redux";
|
||||||
|
|
||||||
import { broadcastGraphicsSelector } from "../../../../features/broadcast/graphics/broadcastGraphicsSelector";
|
import { broadcastGraphicsSelector } from "../../../../features/broadcast/graphics/broadcastGraphicsSelector";
|
||||||
import { eventSelector } from "../../../../features/event/eventSelector";
|
import { eventSelector } from "../../../../features/event/eventSelector";
|
||||||
import { BGTimingTowerModes, Car, CarNotice, CarStatus } from "../../../../types/state";
|
import { theme } from "../../../../shared/theme";
|
||||||
|
import {
|
||||||
|
BGTimingTowerDisplayModes,
|
||||||
|
BGTimingTowerSplitsMode,
|
||||||
|
Car,
|
||||||
|
CarNotice,
|
||||||
|
CarStatus,
|
||||||
|
} from "../../../../types/state";
|
||||||
import { Fraction } from "../../../../types/style";
|
import { Fraction } from "../../../../types/style";
|
||||||
import { orMatch } from "../../../../utils/common";
|
import { orMatch } from "../../../../utils/common";
|
||||||
import { timeDiff } from "../../../../utils/event";
|
import { getCarAtPos, timeDiff } from "../../../../utils/event";
|
||||||
import { formatTime } from "../../../../utils/styling";
|
import { formatTime } from "../../../../utils/styling";
|
||||||
|
|
||||||
import { PositionFlag } from "../../Common/PositionFlag";
|
import { PositionFlag } from "../../Common/PositionFlag";
|
||||||
@@ -14,7 +22,7 @@ import { TeamGem } from "../../Common/TeamGem";
|
|||||||
import {
|
import {
|
||||||
DriverName,
|
DriverName,
|
||||||
FastestLapGem,
|
FastestLapGem,
|
||||||
RowContainer,
|
AnimatedRowContainer,
|
||||||
RowLeftHalf,
|
RowLeftHalf,
|
||||||
RowLeftHalfGemContainer,
|
RowLeftHalfGemContainer,
|
||||||
RowLeftHalfLayout,
|
RowLeftHalfLayout,
|
||||||
@@ -24,72 +32,72 @@ import {
|
|||||||
TimeDiff,
|
TimeDiff,
|
||||||
} from "./styles";
|
} from "./styles";
|
||||||
|
|
||||||
type TimingTowerProps = {
|
|
||||||
carsToDisplay?: number,
|
|
||||||
}
|
|
||||||
export function TimingTower({
|
|
||||||
carsToDisplay = 20,
|
|
||||||
}: TimingTowerProps) {
|
|
||||||
|
|
||||||
const { grid, trackLength, leaderGridSpot } = useSelector(eventSelector);
|
export function TimingTower() {
|
||||||
const { timingBoard } = useSelector(broadcastGraphicsSelector);
|
|
||||||
|
|
||||||
const runningCars: Car[] = [];
|
const { lastUpdate, grid, trackLength, leaderGridSpot } = useSelector(eventSelector);
|
||||||
const retiredCars: Car[] = [];
|
const { timingBoard: { timingTower }, timingBoard: { timingTower: { splitsMode } } } = useSelector(
|
||||||
|
broadcastGraphicsSelector,
|
||||||
|
);
|
||||||
|
|
||||||
grid.forEach((car, index) => {
|
const [retiredCarsPresent, setRetiredCarsPresent] = useState(0);
|
||||||
if (index >= carsToDisplay || car.status === CarStatus.DidNotStart) return;
|
const [rows, setRows] = useState<JSX.Element[]>([]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
let anyRetired = 0;
|
||||||
|
|
||||||
|
setRows(grid.map((car, index, cars) => {
|
||||||
if (car.status === CarStatus.Retired) {
|
if (car.status === CarStatus.Retired) {
|
||||||
retiredCars.push(car);
|
++anyRetired;
|
||||||
} else {
|
|
||||||
runningCars.push(car);
|
|
||||||
}
|
}
|
||||||
});
|
return buildRow(car, index, cars.length);
|
||||||
|
}));
|
||||||
|
setRetiredCarsPresent(anyRetired);
|
||||||
|
}, [lastUpdate, splitsMode]);
|
||||||
|
|
||||||
let forwardCarDistance = -1;
|
|
||||||
|
|
||||||
const buildRow = (
|
const buildRow = (
|
||||||
car: Car,
|
car: Car,
|
||||||
index: number,
|
index: number,
|
||||||
count: number,
|
count: number,
|
||||||
) => {
|
) => {
|
||||||
const firstRow = index === 0;
|
|
||||||
const lastRow = index + 1 === count;
|
const lastRow = index + 1 === count;
|
||||||
let rightHalfContent = "";
|
let rightHalfContent = "";
|
||||||
let xScale: Fraction = 1.0;
|
let xScale: Fraction = 1.0;
|
||||||
let yScale: Fraction = 1.0;
|
let yScale: Fraction = 1.0;
|
||||||
|
|
||||||
let isLeader = false;
|
if (index === leaderGridSpot) {
|
||||||
if (forwardCarDistance === -1) {
|
// Leading car shows "Leader" or "Interval".
|
||||||
isLeader = true;
|
rightHalfContent = splitsMode === BGTimingTowerSplitsMode.Leader
|
||||||
forwardCarDistance = car.distance;
|
? "Leader" : splitsMode === BGTimingTowerSplitsMode.Interval
|
||||||
}
|
|
||||||
if (isLeader) {
|
|
||||||
rightHalfContent = timingBoard.timingTower.mode === BGTimingTowerModes.Leader
|
|
||||||
? "Leader" : timingBoard.timingTower.mode === BGTimingTowerModes.Interval
|
|
||||||
? "Interval" : "";
|
? "Interval" : "";
|
||||||
} else if (car.status === CarStatus.Retired) {
|
} else if (car.status === CarStatus.Retired) {
|
||||||
|
// Retired car shows "OUT".
|
||||||
rightHalfContent = "OUT";
|
rightHalfContent = "OUT";
|
||||||
} else {
|
} else {
|
||||||
const plusLaps = Math.floor((grid[leaderGridSpot].distance - car.distance) / trackLength);
|
// Other cars show gaps.
|
||||||
|
const deltaCar = getCarAtPos(
|
||||||
|
grid,
|
||||||
|
splitsMode === BGTimingTowerSplitsMode.Leader ? 1 : car.position - 1,
|
||||||
|
);
|
||||||
|
|
||||||
|
const plusLaps = Math.floor((deltaCar.distance - car.distance) / trackLength);
|
||||||
|
|
||||||
rightHalfContent =
|
rightHalfContent =
|
||||||
timingBoard.timingTower.mode === BGTimingTowerModes.Leader && plusLaps > 0
|
splitsMode === BGTimingTowerSplitsMode.Leader && plusLaps > 0
|
||||||
? `+${plusLaps} LAP${plusLaps > 1 ? "S" : ""}`
|
? `+${plusLaps} LAP${plusLaps > 1 ? "S" : ""}`
|
||||||
: `+${formatTime(timeDiff(forwardCarDistance, car.distance), 60)}`;
|
: `+${formatTime(timeDiff(deltaCar.distance, car.distance), 60)}`;
|
||||||
|
|
||||||
xScale = rightHalfContent.includes(":") ? 0.75 : 0.9;
|
xScale = rightHalfContent.includes(":") ? 0.75 : 0.9;
|
||||||
yScale = rightHalfContent.includes("+") ? 1.1 : 1.0;
|
yScale = rightHalfContent.includes("+") ? 1.1 : 1.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (timingBoard.timingTower.mode === BGTimingTowerModes.Interval) {
|
|
||||||
forwardCarDistance = car.distance;
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<RowContainer
|
<AnimatedRowContainer
|
||||||
key={car.driver.id}
|
key={car.driver.id}
|
||||||
topGap={car.status === CarStatus.Retired && firstRow}
|
|
||||||
retired={car.status === CarStatus.Retired}
|
retired={car.status === CarStatus.Retired}
|
||||||
wide={timingBoard.timingTower.mode !== BGTimingTowerModes.Minimum}
|
wide={timingTower.displayMode !== BGTimingTowerDisplayModes.LeftOnly}
|
||||||
|
top={(car.position - 1) * theme.design.timingTower.rowHeightPx}
|
||||||
>
|
>
|
||||||
{car.notices.includes(CarNotice.FastestLap) && (
|
{car.notices.includes(CarNotice.FastestLap) && (
|
||||||
<FastestLapGem />
|
<FastestLapGem />
|
||||||
@@ -97,9 +105,9 @@ export function TimingTower({
|
|||||||
<RowLeftHalf
|
<RowLeftHalf
|
||||||
roundedCornerBottom={
|
roundedCornerBottom={
|
||||||
lastRow && orMatch(
|
lastRow && orMatch(
|
||||||
timingBoard.timingTower.mode,
|
timingTower.displayMode,
|
||||||
BGTimingTowerModes.Minimum,
|
BGTimingTowerDisplayModes.LeftOnly,
|
||||||
BGTimingTowerModes.FullName,
|
BGTimingTowerDisplayModes.FullLeft,
|
||||||
) ? 5 : undefined
|
) ? 5 : undefined
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
@@ -107,7 +115,7 @@ export function TimingTower({
|
|||||||
{car.status !== CarStatus.Retired && (
|
{car.status !== CarStatus.Retired && (
|
||||||
<PositionFlag
|
<PositionFlag
|
||||||
size={32}
|
size={32}
|
||||||
number={index + 1} // Not using car.position...
|
number={car.position}
|
||||||
numberSizeFraction={.6}
|
numberSizeFraction={.6}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
@@ -126,9 +134,9 @@ export function TimingTower({
|
|||||||
}
|
}
|
||||||
roundedCornerBottom={
|
roundedCornerBottom={
|
||||||
lastRow && orMatch(
|
lastRow && orMatch(
|
||||||
timingBoard.timingTower.mode,
|
timingTower.splitsMode,
|
||||||
BGTimingTowerModes.Leader,
|
BGTimingTowerSplitsMode.Leader,
|
||||||
BGTimingTowerModes.Interval,
|
BGTimingTowerSplitsMode.Interval,
|
||||||
) ? 5 : undefined
|
) ? 5 : undefined
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
@@ -138,16 +146,12 @@ export function TimingTower({
|
|||||||
</TimeDiff>
|
</TimeDiff>
|
||||||
</RowRightHalfLayout>
|
</RowRightHalfLayout>
|
||||||
</RowRightHalf>
|
</RowRightHalf>
|
||||||
</RowContainer>
|
</AnimatedRowContainer>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
const rows = runningCars.map((car, index, cars) => buildRow(car, index, cars.length));
|
|
||||||
rows.push(...retiredCars.map((car, index, cars) => buildRow(car, index, cars.length)));
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<RowsContainer>
|
<RowsContainer carsToDisplay={grid.length} retiredCarsPresent={!!retiredCarsPresent}>
|
||||||
{rows}
|
{rows}
|
||||||
</RowsContainer>
|
</RowsContainer>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,35 +1,51 @@
|
|||||||
import styled, { css } from "styled-components";
|
import styled, { css } from "styled-components";
|
||||||
|
import { animated } from "@react-spring/web";
|
||||||
|
|
||||||
import { Fraction, Px } from "../../../../types/style";
|
import { Fraction, Px } from "../../../../types/style";
|
||||||
|
|
||||||
export const RowsContainer = styled.div`
|
import fastestLapIcon from "../../../../public/images/icons/fastest-lap.svg";
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
|
|
||||||
flex-wrap: nowrap;
|
type RowsContainerProps = {
|
||||||
|
carsToDisplay: number,
|
||||||
|
retiredCarsPresent: boolean,
|
||||||
|
};
|
||||||
|
export const RowsContainer = styled.div<RowsContainerProps>`
|
||||||
|
position: relative;
|
||||||
|
|
||||||
justify-content: flex-start;
|
width: ${p =>
|
||||||
align-items: stretch;
|
p.theme.design.timingTower.rowLeftHalfWidthPx
|
||||||
|
+ p.theme.design.timingTower.rowRightHalfWidthPx}px;
|
||||||
|
height: ${({ theme, carsToDisplay, retiredCarsPresent }) =>
|
||||||
|
theme.design.timingTower.rowHeightPx * carsToDisplay + (retiredCarsPresent ? 3 : 0)}px;
|
||||||
|
|
||||||
|
overflow-y: clip; // hidden doesn't work for some reason.
|
||||||
`;
|
`;
|
||||||
RowsContainer.displayName = "RowsContainer";
|
RowsContainer.displayName = "RowsContainer";
|
||||||
|
|
||||||
type RowContainerProps = {
|
type AnimatedRowContainerProps = {
|
||||||
topGap?: boolean,
|
|
||||||
bottomGap?: boolean,
|
|
||||||
retired?: boolean,
|
retired?: boolean,
|
||||||
wide?: boolean,
|
wide?: boolean,
|
||||||
}
|
top: Px,
|
||||||
|
};
|
||||||
// All the elements in a row should go in here.
|
// All the elements in a row should go in here.
|
||||||
export const RowContainer = styled.div<RowContainerProps>`
|
export const AnimatedRowContainer = animated(styled.div.attrs<AnimatedRowContainerProps>(({
|
||||||
position: relative;
|
top,
|
||||||
|
retired,
|
||||||
|
}) => ({
|
||||||
|
style: {
|
||||||
|
top: `${top + (retired ? 3 : 0)}px`,
|
||||||
|
},
|
||||||
|
}))<AnimatedRowContainerProps>`
|
||||||
|
position: absolute;
|
||||||
|
left: 0;
|
||||||
|
transition: top 500ms;
|
||||||
|
|
||||||
width: ${({ wide }) => wide ? 255 : 147}px;
|
width: ${({ wide }) => wide ? 255 : 147}px;
|
||||||
height: ${p => p.theme.design.timingTower.rowHeightPx}px; // Future will be animated.
|
height: ${p => p.theme.design.timingTower.rowHeightPx}px; // Future will be animated.
|
||||||
|
|
||||||
${({ topGap }) => topGap && css`margin-top: 3px;`}
|
|
||||||
${({ bottomGap }) => bottomGap && css`margin-bottom: 3px;`}
|
|
||||||
${({ retired }) => retired && css`opacity: 0.7;`}
|
${({ retired }) => retired && css`opacity: 0.7;`}
|
||||||
`;
|
`);
|
||||||
RowContainer.displayName = "RowContainer";
|
AnimatedRowContainer.displayName = "AnimatedRowContainer";
|
||||||
|
|
||||||
type RoundedProp = {
|
type RoundedProp = {
|
||||||
roundedCornerTop?: Px,
|
roundedCornerTop?: Px,
|
||||||
@@ -47,7 +63,7 @@ export const RowLeftHalf = styled(Rounded)`
|
|||||||
left: 0;
|
left: 0;
|
||||||
top: 0;
|
top: 0;
|
||||||
|
|
||||||
width: 147px; // Future will be animated.
|
width: ${p => p.theme.design.timingTower.rowLeftHalfWidthPx}px; // Future will be animated.
|
||||||
height: ${p => p.theme.design.timingTower.rowHeightPx}px;
|
height: ${p => p.theme.design.timingTower.rowHeightPx}px;
|
||||||
|
|
||||||
background-color: #000000e5
|
background-color: #000000e5
|
||||||
@@ -80,7 +96,7 @@ export const RowRightHalf = styled(Rounded)`
|
|||||||
right: 0;
|
right: 0;
|
||||||
top: 0;
|
top: 0;
|
||||||
|
|
||||||
width: 108px; // Future will be animated.
|
width: ${p => p.theme.design.timingTower.rowRightHalfWidthPx}px; // Future will be animated.
|
||||||
height: ${p => p.theme.design.timingTower.rowHeightPx}px;
|
height: ${p => p.theme.design.timingTower.rowHeightPx}px;
|
||||||
|
|
||||||
overflow-x: hidden;
|
overflow-x: hidden;
|
||||||
@@ -126,7 +142,6 @@ export const TimeDiff = styled.span<TimeDiffProps>`
|
|||||||
`;
|
`;
|
||||||
TimeDiff.displayName = "TimeDiff";
|
TimeDiff.displayName = "TimeDiff";
|
||||||
|
|
||||||
import fastestLapIcon from "../../../../public/images/icons/fastest-lap.svg";
|
|
||||||
export const FastestLapGem = styled.div`
|
export const FastestLapGem = styled.div`
|
||||||
position: absolute;
|
position: absolute;
|
||||||
|
|
||||||
|
|||||||
+39
@@ -0,0 +1,39 @@
|
|||||||
|
import { InlineCluster } from "@bedrock-layout/inline-cluster";
|
||||||
|
import { useDispatch, useSelector } from "react-redux";
|
||||||
|
import { broadcastGraphicsSelector } from "../../../../features/broadcast/graphics/broadcastGraphicsSelector";
|
||||||
|
import { setTimingTowerSplitsMode } from "../../../../features/broadcast/graphics/broadcastGraphicsSlice";
|
||||||
|
|
||||||
|
import { refreshRunningOrder } from "../../../../features/event/eventSlice";
|
||||||
|
import { BGTimingTowerSplitsMode } from "../../../../types/state";
|
||||||
|
|
||||||
|
import { ClickSpan } from "./styles";
|
||||||
|
|
||||||
|
export function TimingTowerPrototypeControls() {
|
||||||
|
const dispatch = useDispatch();
|
||||||
|
const { timingBoard: { timingTower: { splitsMode } } } = useSelector(broadcastGraphicsSelector);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<InlineCluster gutter="md">
|
||||||
|
<ClickSpan
|
||||||
|
onClick={() => {
|
||||||
|
console.log("refreshRunningOrder");
|
||||||
|
dispatch(refreshRunningOrder());
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
Refresh Running Order
|
||||||
|
</ClickSpan>
|
||||||
|
<ClickSpan
|
||||||
|
onClick={() => {
|
||||||
|
console.log("Swap Interval");
|
||||||
|
if (splitsMode === BGTimingTowerSplitsMode.Interval) {
|
||||||
|
dispatch(setTimingTowerSplitsMode(BGTimingTowerSplitsMode.Leader));
|
||||||
|
} else {
|
||||||
|
dispatch(setTimingTowerSplitsMode(BGTimingTowerSplitsMode.Interval));
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
Splits Mode = {BGTimingTowerSplitsMode[splitsMode]}
|
||||||
|
</ClickSpan>
|
||||||
|
</InlineCluster>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
export * from "./TimingTowerPrototypeControls";
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
import styled from "styled-components";
|
||||||
|
|
||||||
|
export const ClickSpan = styled.span`
|
||||||
|
font-family: ${p => p.theme.fonts.f1Bold};
|
||||||
|
font-size: 0.9em;
|
||||||
|
cursor: pointer;
|
||||||
|
`;
|
||||||
@@ -19,6 +19,7 @@ import { ChyronContainer } from "../BroadcastGraphics/Chyrons/Container";
|
|||||||
import { VenetianBlindsWorkspace } from "./CustomWorkSpaces/VenetianBlindsWorkspace";
|
import { VenetianBlindsWorkspace } from "./CustomWorkSpaces/VenetianBlindsWorkspace";
|
||||||
import { VenetianBlindsPrototypeControls } from "./PrototypingControls/VenetianBlindsPrototype";
|
import { VenetianBlindsPrototypeControls } from "./PrototypingControls/VenetianBlindsPrototype";
|
||||||
import { TimingTower } from "../BroadcastGraphics/TimingBoard/TimingTower";
|
import { TimingTower } from "../BroadcastGraphics/TimingBoard/TimingTower";
|
||||||
|
import { TimingTowerPrototypeControls } from "./PrototypingControls/TimingTowerPrototype";
|
||||||
|
|
||||||
const WORKSPACE_LIST_WIDTH = 180;
|
const WORKSPACE_LIST_WIDTH = 180;
|
||||||
|
|
||||||
@@ -90,22 +91,14 @@ export default function Workspaces() {
|
|||||||
prototypeControls={<VenetianBlindsPrototypeControls />}
|
prototypeControls={<VenetianBlindsPrototypeControls />}
|
||||||
/>
|
/>
|
||||||
} />
|
} />
|
||||||
<Route path="timingBoardFull" element={
|
<Route path="timingBoard" element={
|
||||||
<Workspace
|
<Workspace
|
||||||
workspaceId="timingBoardFull"
|
workspaceId="timingBoard"
|
||||||
previewContent={<TimingTower />}
|
previewContent={<TimingTower />}
|
||||||
prototypeControls={<div>Timing Tower Full</div>}
|
prototypeControls={<TimingTowerPrototypeControls />}
|
||||||
bleedover={500}
|
bleedover={500}
|
||||||
/>
|
/>
|
||||||
} />
|
} />
|
||||||
<Route path="timingBoardShort" element={
|
|
||||||
<Workspace
|
|
||||||
workspaceId="timingBoardShort"
|
|
||||||
previewContent={<TimingTower carsToDisplay={6} />}
|
|
||||||
prototypeControls={<div>Timing Tower Short</div>}
|
|
||||||
bleedover={250}
|
|
||||||
/>
|
|
||||||
} />
|
|
||||||
<Route path="*" element={<IndexHeading>Unknown Workspace</IndexHeading>} />
|
<Route path="*" element={<IndexHeading>Unknown Workspace</IndexHeading>} />
|
||||||
</Routes>
|
</Routes>
|
||||||
</FullScreenContainer>
|
</FullScreenContainer>
|
||||||
|
|||||||
@@ -84,26 +84,17 @@ export const workspaces: WorkspaceObject = {
|
|||||||
height: 500,
|
height: 500,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
timingBoardFull: {
|
timingBoard: {
|
||||||
name: "Timing Board (Full)",
|
name: "Timing Board",
|
||||||
overlayIds: [
|
overlayIds: [
|
||||||
"timing-board-leader-19.png",
|
"timing-board-leader-19.png",
|
||||||
"timing-board-leader-20-out-1.png",
|
"timing-board-leader-20-out-1.png",
|
||||||
"timing-board-intervals-yellow-flag.png",
|
"timing-board-intervals-yellow-flag.png",
|
||||||
|
"timing-board-portrait-gap.png",
|
||||||
],
|
],
|
||||||
previewWindowDimensions: {
|
previewWindowDimensions: {
|
||||||
width: 700,
|
width: 700,
|
||||||
height: 900,
|
height: 900,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
timingBoardShort: {
|
|
||||||
name: "Timing Board (Short)",
|
|
||||||
overlayIds: [
|
|
||||||
"timing-board-portrait-gap.png",
|
|
||||||
],
|
|
||||||
previewWindowDimensions: {
|
|
||||||
width: 700,
|
|
||||||
height: 450,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
@@ -3,8 +3,9 @@ import { createSlice, PayloadAction } from "@reduxjs/toolkit";
|
|||||||
import {
|
import {
|
||||||
BGChyrons,
|
BGChyrons,
|
||||||
BGStatusIndicatorModes,
|
BGStatusIndicatorModes,
|
||||||
|
BGTimingTowerDisplayModes,
|
||||||
BGTimingTowerFocusedCarsMode,
|
BGTimingTowerFocusedCarsMode,
|
||||||
BGTimingTowerModes,
|
BGTimingTowerSplitsMode,
|
||||||
OpenState,
|
OpenState,
|
||||||
RootState,
|
RootState,
|
||||||
} from "../../../types/state";
|
} from "../../../types/state";
|
||||||
@@ -19,7 +20,8 @@ const initialState: RootState["broadcastGraphics"] = {
|
|||||||
},
|
},
|
||||||
timingTower: {
|
timingTower: {
|
||||||
open: 1,
|
open: 1,
|
||||||
mode: BGTimingTowerModes.Leader,
|
displayMode: BGTimingTowerDisplayModes.LeftAndRight,
|
||||||
|
splitsMode: BGTimingTowerSplitsMode.Leader,
|
||||||
focusedCars: [],
|
focusedCars: [],
|
||||||
focusedCarsMode: BGTimingTowerFocusedCarsMode.None,
|
focusedCarsMode: BGTimingTowerFocusedCarsMode.None,
|
||||||
},
|
},
|
||||||
@@ -52,6 +54,11 @@ export const broadcastGraphicsSlice = createSlice({
|
|||||||
clearChyrons: (state) => {
|
clearChyrons: (state) => {
|
||||||
state.chyrons = null;
|
state.chyrons = null;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
// Timing Board
|
||||||
|
setTimingTowerSplitsMode: (state, action: PayloadAction<BGTimingTowerSplitsMode>) => {
|
||||||
|
state.timingBoard.timingTower.splitsMode = action.payload;
|
||||||
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -60,5 +67,6 @@ export const {
|
|||||||
setChyronsOpenState,
|
setChyronsOpenState,
|
||||||
incrementChyronsOpenState,
|
incrementChyronsOpenState,
|
||||||
clearChyrons,
|
clearChyrons,
|
||||||
|
setTimingTowerSplitsMode,
|
||||||
} = broadcastGraphicsSlice.actions;
|
} = broadcastGraphicsSlice.actions;
|
||||||
export default broadcastGraphicsSlice.reducer;
|
export default broadcastGraphicsSlice.reducer;
|
||||||
@@ -188,6 +188,7 @@ const initialState: RootState["event"] = {
|
|||||||
driver: cloneDriver("mazepin"),
|
driver: cloneDriver("mazepin"),
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
lastUpdate: Date.now(),
|
||||||
};
|
};
|
||||||
|
|
||||||
export const eventSlice = createSlice({
|
export const eventSlice = createSlice({
|
||||||
@@ -196,23 +197,32 @@ export const eventSlice = createSlice({
|
|||||||
reducers: {
|
reducers: {
|
||||||
setCourseFlag: (state, action: PayloadAction<CourseFlag>) => {
|
setCourseFlag: (state, action: PayloadAction<CourseFlag>) => {
|
||||||
state.courseStatus.courseFlag = action.payload;
|
state.courseStatus.courseFlag = action.payload;
|
||||||
|
state.lastUpdate = Date.now();
|
||||||
},
|
},
|
||||||
calculateLeader: (state) => {
|
refreshRunningOrder: (state) => {
|
||||||
let leader = 0;
|
const sortingGrid = state.grid.map((car, index) => ({
|
||||||
let greatestDistance = Number.MIN_SAFE_INTEGER;
|
gridSpot: index,
|
||||||
for (let p = 0; p < state.grid.length; ++p) {
|
distance: car.distance,
|
||||||
if (state.grid[p].distance > greatestDistance) {
|
status: car.status,
|
||||||
leader = p;
|
}));
|
||||||
greatestDistance = state.grid[p].distance;
|
|
||||||
}
|
sortingGrid.sort((a, b) =>
|
||||||
}
|
// Retired cars go to the end but still maintain their own order.
|
||||||
state.leaderGridSpot = leader;
|
(b.distance - (b.status === CarStatus.Retired ? 1000000 : 0))
|
||||||
|
- (a.distance - (a.status === CarStatus.Retired ? 1000000 : 0)),
|
||||||
|
);
|
||||||
|
|
||||||
|
sortingGrid.forEach((entry, sortedPosition) => {
|
||||||
|
state.grid[entry.gridSpot].position = sortedPosition + 1;
|
||||||
|
});
|
||||||
|
state.leaderGridSpot = sortingGrid[0].gridSpot;
|
||||||
|
state.lastUpdate = Date.now();
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
export const {
|
export const {
|
||||||
setCourseFlag,
|
setCourseFlag,
|
||||||
calculateLeader,
|
refreshRunningOrder,
|
||||||
} = eventSlice.actions;
|
} = eventSlice.actions;
|
||||||
export default eventSlice.reducer;
|
export default eventSlice.reducer;
|
||||||
@@ -66,6 +66,9 @@ export const theme = {
|
|||||||
design: {
|
design: {
|
||||||
timingTower: {
|
timingTower: {
|
||||||
rowHeightPx: 36.5,
|
rowHeightPx: 36.5,
|
||||||
|
rowLeftHalfWidthPx: 147,
|
||||||
|
rowRightHalfWidthPx: 108,
|
||||||
|
retiredTopGapPx: 3,
|
||||||
},
|
},
|
||||||
button: {
|
button: {
|
||||||
borderRadius: "0.25rem",
|
borderRadius: "0.25rem",
|
||||||
|
|||||||
+11
-5
@@ -76,6 +76,8 @@ export interface Event {
|
|||||||
progress: EventProgress;
|
progress: EventProgress;
|
||||||
leaderGridSpot: GridSpot;
|
leaderGridSpot: GridSpot;
|
||||||
grid: Grid;
|
grid: Grid;
|
||||||
|
// gridPositions: GridSpot[];
|
||||||
|
lastUpdate: number;
|
||||||
}
|
}
|
||||||
export interface EventProgress {
|
export interface EventProgress {
|
||||||
startTime: Milliseconds;
|
startTime: Milliseconds;
|
||||||
@@ -280,16 +282,20 @@ export enum BGStatusIndicatorModes {
|
|||||||
// Timing Tower
|
// Timing Tower
|
||||||
export interface BGTimingTower {
|
export interface BGTimingTower {
|
||||||
open: OpenState;
|
open: OpenState;
|
||||||
mode: BGTimingTowerModes;
|
displayMode: BGTimingTowerDisplayModes;
|
||||||
|
splitsMode: BGTimingTowerSplitsMode,
|
||||||
focusedCars: Car[],
|
focusedCars: Car[],
|
||||||
focusedCarsMode: BGTimingTowerFocusedCarsMode,
|
focusedCarsMode: BGTimingTowerFocusedCarsMode,
|
||||||
}
|
}
|
||||||
export enum BGTimingTowerModes {
|
export enum BGTimingTowerDisplayModes {
|
||||||
Hidden, // Not on display.
|
Hidden,
|
||||||
Minimum, // Just the driver name abbrv.
|
LeftOnly,
|
||||||
|
LeftAndRight,
|
||||||
|
FullLeft,
|
||||||
|
}
|
||||||
|
export enum BGTimingTowerSplitsMode {
|
||||||
Leader, // Leader timing.
|
Leader, // Leader timing.
|
||||||
Interval, // Interval timing.
|
Interval, // Interval timing.
|
||||||
FullName, // Displays full name.
|
|
||||||
}
|
}
|
||||||
export enum BGTimingTowerFocusedCarsMode {
|
export enum BGTimingTowerFocusedCarsMode {
|
||||||
None, // When no special treatments are made.
|
None, // When no special treatments are made.
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import { random } from "lodash";
|
import { random } from "lodash";
|
||||||
|
import { Car, Grid } from "../types/state";
|
||||||
|
|
||||||
import { Meters } from "../types/util";
|
import { Meters } from "../types/util";
|
||||||
|
|
||||||
@@ -14,3 +15,15 @@ export function timeDiff(
|
|||||||
|
|
||||||
return random(0.95, 1.05) * ((front - back) / 61.015);
|
return random(0.95, 1.05) * ((front - back) / 61.015);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
export function getCarAtPos(
|
||||||
|
grid: Grid,
|
||||||
|
targetPosition: number,
|
||||||
|
): Car {
|
||||||
|
const foundCar = grid.find(car => car.position === targetPosition);
|
||||||
|
if (!foundCar) {
|
||||||
|
return grid[0];
|
||||||
|
}
|
||||||
|
return foundCar;
|
||||||
|
}
|
||||||
Reference in new issue
Block a user