Files
test/src/features/broadcast/graphics/broadcastGraphicsSlice.ts
T
Kyle Geib 22ebab1101 ISSUE-054 - Initial work of building the Timing Board. Working so far only have work for the Timing Tower.
Timing Board is the combination of all elements on the left side of the screen, including the Status Indicator component (not written yet) that is visible whenever there are cars on track.
2022-02-16 14:36:27 -05:00

65 lines
1.5 KiB
TypeScript

import { createSlice, PayloadAction } from "@reduxjs/toolkit";
import {
BGChyrons,
BGStatusIndicatorModes,
BGTimingTowerFocusedCarsMode,
BGTimingTowerModes,
OpenState,
RootState,
} from "../../../types/state";
const initialState: RootState["broadcastGraphics"] = {
chyrons: null,
timingBoard: {
relativePos: {},
openState: 0,
statusIndicator: {
mode: BGStatusIndicatorModes.NormalNarrow,
},
timingTower: {
open: 1,
mode: BGTimingTowerModes.Leader,
focusedCars: [],
focusedCarsMode: BGTimingTowerFocusedCarsMode.None,
},
},
};
export const broadcastGraphicsSlice = createSlice({
name: "broadcastGraphics",
initialState,
reducers: {
setChyrons: (state, action: PayloadAction<BGChyrons>) => {
state.chyrons = action.payload;
},
setChyronsOpenState: (state, action: PayloadAction<OpenState>) => {
if (state.chyrons == null) return;
state.chyrons.openState = action.payload;
if (state.chyrons != null) {
state.chyrons.openState = action.payload;
}
},
incrementChyronsOpenState: (state) => {
if (state.chyrons == null) return;
++state.chyrons.openState;
if (state.chyrons != null) {
++state.chyrons.openState;
}
},
clearChyrons: (state) => {
state.chyrons = null;
},
},
});
export const {
setChyrons,
setChyronsOpenState,
incrementChyronsOpenState,
clearChyrons,
} = broadcastGraphicsSlice.actions;
export default broadcastGraphicsSlice.reducer;