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
+204
-114
No files matched your search
@@ -3,8 +3,9 @@ import { createSlice, PayloadAction } from "@reduxjs/toolkit";
|
||||
import {
|
||||
BGChyrons,
|
||||
BGStatusIndicatorModes,
|
||||
BGTimingTowerDisplayModes,
|
||||
BGTimingTowerFocusedCarsMode,
|
||||
BGTimingTowerModes,
|
||||
BGTimingTowerSplitsMode,
|
||||
OpenState,
|
||||
RootState,
|
||||
} from "../../../types/state";
|
||||
@@ -19,7 +20,8 @@ const initialState: RootState["broadcastGraphics"] = {
|
||||
},
|
||||
timingTower: {
|
||||
open: 1,
|
||||
mode: BGTimingTowerModes.Leader,
|
||||
displayMode: BGTimingTowerDisplayModes.LeftAndRight,
|
||||
splitsMode: BGTimingTowerSplitsMode.Leader,
|
||||
focusedCars: [],
|
||||
focusedCarsMode: BGTimingTowerFocusedCarsMode.None,
|
||||
},
|
||||
@@ -52,6 +54,11 @@ export const broadcastGraphicsSlice = createSlice({
|
||||
clearChyrons: (state) => {
|
||||
state.chyrons = null;
|
||||
},
|
||||
|
||||
// Timing Board
|
||||
setTimingTowerSplitsMode: (state, action: PayloadAction<BGTimingTowerSplitsMode>) => {
|
||||
state.timingBoard.timingTower.splitsMode = action.payload;
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
@@ -60,5 +67,6 @@ export const {
|
||||
setChyronsOpenState,
|
||||
incrementChyronsOpenState,
|
||||
clearChyrons,
|
||||
setTimingTowerSplitsMode,
|
||||
} = broadcastGraphicsSlice.actions;
|
||||
export default broadcastGraphicsSlice.reducer;
|
||||
@@ -188,6 +188,7 @@ const initialState: RootState["event"] = {
|
||||
driver: cloneDriver("mazepin"),
|
||||
},
|
||||
],
|
||||
lastUpdate: Date.now(),
|
||||
};
|
||||
|
||||
export const eventSlice = createSlice({
|
||||
@@ -196,23 +197,32 @@ export const eventSlice = createSlice({
|
||||
reducers: {
|
||||
setCourseFlag: (state, action: PayloadAction<CourseFlag>) => {
|
||||
state.courseStatus.courseFlag = action.payload;
|
||||
state.lastUpdate = Date.now();
|
||||
},
|
||||
calculateLeader: (state) => {
|
||||
let leader = 0;
|
||||
let greatestDistance = Number.MIN_SAFE_INTEGER;
|
||||
for (let p = 0; p < state.grid.length; ++p) {
|
||||
if (state.grid[p].distance > greatestDistance) {
|
||||
leader = p;
|
||||
greatestDistance = state.grid[p].distance;
|
||||
}
|
||||
}
|
||||
state.leaderGridSpot = leader;
|
||||
refreshRunningOrder: (state) => {
|
||||
const sortingGrid = state.grid.map((car, index) => ({
|
||||
gridSpot: index,
|
||||
distance: car.distance,
|
||||
status: car.status,
|
||||
}));
|
||||
|
||||
sortingGrid.sort((a, b) =>
|
||||
// Retired cars go to the end but still maintain their own order.
|
||||
(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 {
|
||||
setCourseFlag,
|
||||
calculateLeader,
|
||||
refreshRunningOrder,
|
||||
} = eventSlice.actions;
|
||||
export default eventSlice.reducer;
|
||||
Reference in new issue
Block a user