ISSUE-032 - Defined a great number of new state types for use with the race event's state, the broadcast director's controls, and the broadcast graphics states.
Taking a second to make a commit to save my progress so far.
This commit is contained in:
1 parent
ef0b58e98b
commit
5d009a3d70
12 files changed
+254
-21
No files matched your search
@@ -60,3 +60,7 @@ export function ChyronDriver() {
|
|||||||
</BaseBackground>
|
</BaseBackground>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// export function ChyronDriverStateContainer() {
|
||||||
|
|
||||||
|
// }
|
||||||
@@ -41,6 +41,7 @@ export const Workspace = () => {
|
|||||||
|
|
||||||
if (workspaceId == null) return null;
|
if (workspaceId == null) return null;
|
||||||
|
|
||||||
|
const [graphic, controls] = fetchBroadcastGraphic(workspaceId);
|
||||||
return (
|
return (
|
||||||
<Stack
|
<Stack
|
||||||
gutter="lg"
|
gutter="lg"
|
||||||
@@ -53,13 +54,14 @@ export const Workspace = () => {
|
|||||||
dimensions={workspaceProperties.previewWindowDimensions}
|
dimensions={workspaceProperties.previewWindowDimensions}
|
||||||
animatedBG={animatedBG}
|
animatedBG={animatedBG}
|
||||||
>
|
>
|
||||||
{fetchBroadcastGraphic(workspaceId)}
|
{graphic}
|
||||||
<OverlayDisplay
|
<OverlayDisplay
|
||||||
containerDimensions={workspaceProperties.previewWindowDimensions}
|
containerDimensions={workspaceProperties.previewWindowDimensions}
|
||||||
/>
|
/>
|
||||||
</PreviewWindow>
|
</PreviewWindow>
|
||||||
<ControlsContainer>
|
<ControlsContainer>
|
||||||
<WorkspaceControls />
|
<WorkspaceControls />
|
||||||
|
{controls}
|
||||||
</ControlsContainer>
|
</ControlsContainer>
|
||||||
</Stack>
|
</Stack>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ export const workspaces: WorkspaceObject = {
|
|||||||
],
|
],
|
||||||
previewWindowDimensions: {
|
previewWindowDimensions: {
|
||||||
width: 750,
|
width: 750,
|
||||||
height: 200,
|
height: 300,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
angledFlag: {
|
angledFlag: {
|
||||||
@@ -44,11 +44,11 @@ export const workspaces: WorkspaceObject = {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
export function fetchBroadcastGraphic(workspaceId: WorkspaceId): ReactNode {
|
export function fetchBroadcastGraphic(workspaceId: WorkspaceId): [ReactNode, ReactNode] {
|
||||||
switch(workspaceId) {
|
switch(workspaceId) {
|
||||||
case "chyronDriver": return ChyronDriver();
|
case "chyronDriver": return [ChyronDriver(), null];
|
||||||
case "angledFlag": return AngledFlagWorkSpace();
|
case "angledFlag": return [AngledFlagWorkSpace(), null];
|
||||||
default: return null;
|
default: return [null, null];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
import { RootState } from "../../../types/state";
|
||||||
|
|
||||||
|
export const broadcastDirectorSelector = (state: RootState) => state.broadcastDirector;
|
||||||
@@ -0,0 +1,46 @@
|
|||||||
|
import { createSlice, PayloadAction } from "@reduxjs/toolkit";
|
||||||
|
import { findIndex } from "lodash";
|
||||||
|
|
||||||
|
import { RootState, Car } from "../../../types/state";
|
||||||
|
|
||||||
|
const initialState: RootState["broadcastDirector"] = {
|
||||||
|
selectedCars: [],
|
||||||
|
};
|
||||||
|
|
||||||
|
const carMatch = (targetCar: Car) => (checkedCar: Car) =>
|
||||||
|
checkedCar.driver.id === targetCar.driver.id;
|
||||||
|
|
||||||
|
export const broadcastDirectorSlice = createSlice({
|
||||||
|
name: "broadcastDirector",
|
||||||
|
initialState,
|
||||||
|
reducers: {
|
||||||
|
selectedCarsAdd: (state, action: PayloadAction<Car>) => {
|
||||||
|
const index = findIndex(state.selectedCars, carMatch(action.payload));
|
||||||
|
if (index === -1) {
|
||||||
|
state.selectedCars = state.selectedCars.concat(action.payload);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
selectedCarsSet: (state, action: PayloadAction<Car>) => { // Might be removed.
|
||||||
|
state.selectedCars = [action.payload];
|
||||||
|
},
|
||||||
|
selectedCarsRemove: (state, action: PayloadAction<Car | number>) => {
|
||||||
|
const index = typeof action.payload === "number"
|
||||||
|
? action.payload
|
||||||
|
: findIndex(state.selectedCars, carMatch(action.payload));
|
||||||
|
state.selectedCars = state.selectedCars.slice(0, index).concat(
|
||||||
|
state.selectedCars.slice(index + 1),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
selectedCarsClear: (state) => {
|
||||||
|
state.selectedCars = [];
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
export const {
|
||||||
|
selectedCarsAdd,
|
||||||
|
selectedCarsSet,
|
||||||
|
selectedCarsRemove,
|
||||||
|
selectedCarsClear,
|
||||||
|
} = broadcastDirectorSlice.actions;
|
||||||
|
export default broadcastDirectorSlice.reducer;
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
import { RootState } from "../../../types/state";
|
||||||
|
|
||||||
|
export const broadcastGraphicsSelector = (state: RootState) => state.broadcastGraphics;
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
import { createSlice, PayloadAction } from "@reduxjs/toolkit";
|
||||||
|
|
||||||
|
import { BGChyrons, OpenState, RootState } from "../../../types/state";
|
||||||
|
|
||||||
|
const initialState: RootState["broadcastGraphics"] = {
|
||||||
|
chyrons: null,
|
||||||
|
};
|
||||||
|
|
||||||
|
export const broadcastGraphicsSlice = createSlice({
|
||||||
|
name: "broadcastGraphics",
|
||||||
|
initialState,
|
||||||
|
reducers: {
|
||||||
|
chyronsLaunch: (state, action: PayloadAction<BGChyrons>) => {
|
||||||
|
state.chyrons = action.payload;
|
||||||
|
},
|
||||||
|
chyronsSetOpenState: (state, action: PayloadAction<OpenState>) => {
|
||||||
|
if (state.chyrons == null) return;
|
||||||
|
state.chyrons.primary.openState = action.payload;
|
||||||
|
|
||||||
|
if (state.chyrons.secondary != null) {
|
||||||
|
state.chyrons.secondary.openState = action.payload;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
chyronsClear: (state) => {
|
||||||
|
state.chyrons = null;
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
export const {
|
||||||
|
chyronsLaunch,
|
||||||
|
chyronsClear,
|
||||||
|
} = broadcastGraphicsSlice.actions;
|
||||||
|
export default broadcastGraphicsSlice.reducer;
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
import { RootState } from "../../types/state";
|
||||||
|
|
||||||
|
export const eventSelector = (state: RootState) => state.event;
|
||||||
@@ -0,0 +1,58 @@
|
|||||||
|
import { createSlice, PayloadAction } from "@reduxjs/toolkit";
|
||||||
|
|
||||||
|
import { CourseFlag, RootState } from "../../types/state";
|
||||||
|
import { getDriver } from "../../utils/dataLookup";
|
||||||
|
|
||||||
|
const initialState: RootState["event"] = {
|
||||||
|
trackName: "Melbourne",
|
||||||
|
courseStatus: {
|
||||||
|
courseFlag: "green",
|
||||||
|
sectorFlags: ["green", "green", "green"],
|
||||||
|
safetyCar: "clear",
|
||||||
|
virtualSafetyCar: "clear",
|
||||||
|
},
|
||||||
|
mode: "race",
|
||||||
|
progress: {
|
||||||
|
startTime: Date.now(),
|
||||||
|
timeLimit: 60 * 60 * 2 * 1000,
|
||||||
|
currentLap: 1,
|
||||||
|
lapCount: 10,
|
||||||
|
},
|
||||||
|
grid: [
|
||||||
|
{ position: 1, driver: getDriver("verstappen") },
|
||||||
|
{ position: 3, driver: getDriver("hamilton") },
|
||||||
|
{ position: 2, driver: getDriver("bottas") },
|
||||||
|
{ position: 4, driver: getDriver("perez") },
|
||||||
|
{ position: 5, driver: getDriver("sainz") },
|
||||||
|
{ position: 6, driver: getDriver("norris") },
|
||||||
|
{ position: 7, driver: getDriver("leclerc") },
|
||||||
|
{ position: 8, driver: getDriver("ricciardo") },
|
||||||
|
{ position: 9, driver: getDriver("gasly") },
|
||||||
|
{ position: 10, driver: getDriver("alonso") },
|
||||||
|
{ position: 11, driver: getDriver("ocon") },
|
||||||
|
{ position: 12, driver: getDriver("vettel") },
|
||||||
|
{ position: 13, driver: getDriver("stroll") },
|
||||||
|
{ position: 14, driver: getDriver("tsunoda") },
|
||||||
|
{ position: 15, driver: getDriver("russell") },
|
||||||
|
{ position: 16, driver: getDriver("raikkonen") },
|
||||||
|
{ position: 17, driver: getDriver("latifi") },
|
||||||
|
{ position: 18, driver: getDriver("giovinazzi") },
|
||||||
|
{ position: 19, driver: getDriver("schumacher") },
|
||||||
|
{ position: 20, driver: getDriver("mazepin") },
|
||||||
|
],
|
||||||
|
};
|
||||||
|
|
||||||
|
export const eventSlice = createSlice({
|
||||||
|
name: "event",
|
||||||
|
initialState,
|
||||||
|
reducers: {
|
||||||
|
courseFlagSet: (state, action: PayloadAction<CourseFlag>) => {
|
||||||
|
state.courseStatus.courseFlag = action.payload;
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
export const {
|
||||||
|
courseFlagSet,
|
||||||
|
} = eventSlice.actions;
|
||||||
|
export default eventSlice.reducer;
|
||||||
@@ -3,11 +3,13 @@ import { configureStore, combineReducers } from "@reduxjs/toolkit";
|
|||||||
import pageDimensions from "./features/pageDimensions/pageDimensionsSlice";
|
import pageDimensions from "./features/pageDimensions/pageDimensionsSlice";
|
||||||
import workspace from "./features/workspace/workspaceSlice";
|
import workspace from "./features/workspace/workspaceSlice";
|
||||||
import overlayTool from "./features/overlayTool/overlayToolSlice";
|
import overlayTool from "./features/overlayTool/overlayToolSlice";
|
||||||
|
import broadcastGraphics from "./features/broadcast/graphics/broadcastGraphicsSlice";
|
||||||
|
|
||||||
export const store = configureStore({
|
export const store = configureStore({
|
||||||
reducer: combineReducers({
|
reducer: combineReducers({
|
||||||
pageDimensions,
|
pageDimensions,
|
||||||
workspace,
|
workspace,
|
||||||
overlayTool,
|
overlayTool,
|
||||||
|
broadcastGraphics,
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
Vendored
+90
-15
@@ -1,7 +1,12 @@
|
|||||||
|
import { Milliseconds, Optional } from "./util";
|
||||||
|
|
||||||
export interface RootState {
|
export interface RootState {
|
||||||
pageDimensions: PageDimensions;
|
pageDimensions: PageDimensions;
|
||||||
workspace: Workspace;
|
workspace: Workspace;
|
||||||
overlayTool: OverlayTool;
|
overlayTool: OverlayTool;
|
||||||
|
event: Event,
|
||||||
|
broadcastDirector: BroadcastDirector;
|
||||||
|
broadcastGraphics: BroadcastGraphics;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Page Dimensions
|
// Page Dimensions
|
||||||
@@ -42,14 +47,54 @@ export interface OverlayItem {
|
|||||||
opacity: number;
|
opacity: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Race State.
|
// Event State
|
||||||
|
export interface Event {
|
||||||
|
trackName: string;
|
||||||
|
courseStatus: CourseStatus;
|
||||||
|
mode: EventMode;
|
||||||
|
progress: EventProgress;
|
||||||
|
grid: Grid;
|
||||||
|
}
|
||||||
|
export interface EventProgress {
|
||||||
|
startTime: Milliseconds;
|
||||||
|
timeLimit: Milliseconds;
|
||||||
|
currentLap: number;
|
||||||
|
lapCount: number;
|
||||||
|
}
|
||||||
|
export type EventMode =
|
||||||
|
| "race"
|
||||||
|
| "sprint"
|
||||||
|
| "p1"
|
||||||
|
| "p2"
|
||||||
|
| "p3"
|
||||||
|
| "q1"
|
||||||
|
| "q2"
|
||||||
|
| "q3";
|
||||||
|
export interface CourseStatus {
|
||||||
|
courseFlag: CourseFlags;
|
||||||
|
sectorFlags: Array<CourseFlag>;
|
||||||
|
safetyCar: SafetyCarStatus;
|
||||||
|
virtualSafetyCar: VirtualSafetyCarStatus;
|
||||||
|
}
|
||||||
|
export type CourseFlag =
|
||||||
|
| "green"
|
||||||
|
| "yellow"
|
||||||
|
| "doubleYellow"
|
||||||
|
| "chequered"
|
||||||
|
| "red"
|
||||||
|
| "white"
|
||||||
|
| "redYellow";
|
||||||
|
export type SafetyCarStatus = "clear" | "starting" | "out" | "ending";
|
||||||
|
export type VirtualSafetyCarStatus = "clear" | "out" | "ending";
|
||||||
|
export type Grid = Array<Car>; // Grid order does not change.
|
||||||
export interface Car {
|
export interface Car {
|
||||||
position: number;
|
position: number;
|
||||||
driver: Driver;
|
driver: Driver;
|
||||||
// status: ???;
|
// status: ???; // retired
|
||||||
|
// flags: ???, // blue, red, meatball, black/white, black
|
||||||
|
// notices: ???; // Penalties, warnings, investigations, blue flags, etc
|
||||||
// distance: number;
|
// distance: number;
|
||||||
}
|
}
|
||||||
export type Grid = Array<Car>;
|
|
||||||
export interface Driver {
|
export interface Driver {
|
||||||
id: DriverId;
|
id: DriverId;
|
||||||
firstName: string;
|
firstName: string;
|
||||||
@@ -126,6 +171,11 @@ export type TeamFullName =
|
|||||||
| "Red Bull Racing"
|
| "Red Bull Racing"
|
||||||
| "Williams Racing";
|
| "Williams Racing";
|
||||||
|
|
||||||
|
// Broadcast Director
|
||||||
|
export interface BroadcastDirector {
|
||||||
|
selectedCars: Array<Car>;
|
||||||
|
}
|
||||||
|
|
||||||
// Broadcast Graphics
|
// Broadcast Graphics
|
||||||
export interface BGRelativePos {
|
export interface BGRelativePos {
|
||||||
top?: string;
|
top?: string;
|
||||||
@@ -133,34 +183,59 @@ export interface BGRelativePos {
|
|||||||
bottom?: string;
|
bottom?: string;
|
||||||
left?: string;
|
left?: string;
|
||||||
}
|
}
|
||||||
|
export interface BGBaseState {
|
||||||
|
relativePos: BGRelativePos;
|
||||||
|
openState: OpenState;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* -1 closing, 0 closed, 1 open, 2... different states
|
||||||
|
*/
|
||||||
|
export type OpenState = number;
|
||||||
|
|
||||||
export interface BroadcastGraphics {
|
export interface BroadcastGraphics {
|
||||||
// timingBoard: BGTimingBoard;
|
// timingBoard: BGTimingBoard;
|
||||||
// statusIndicator: BGStatusIndicator;
|
// statusIndicator: BGStatusIndicator;
|
||||||
// indicators: BGIndicators
|
// indicators: BGIndicators
|
||||||
chyrons: BGChyrons;
|
chyrons: Optional<BGChyrons>;
|
||||||
// gems: BGGems
|
// gems: BGGems
|
||||||
// toasts: BGToasts;
|
// toasts: BGToasts;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface BGChyrons {
|
// Chyrons
|
||||||
primary: BGChyron;
|
|
||||||
secondary: BGChyron;
|
|
||||||
// sponsorGem: BGSponsorGem;
|
|
||||||
}
|
|
||||||
|
|
||||||
export type FlagMode = "country" | "team";
|
export type FlagMode = "country" | "team";
|
||||||
export type BGChyronMode =
|
export type BGChyronMode =
|
||||||
| "driver-basic-small"
|
| "driver-basic-small"
|
||||||
| "driver-basic-medium"
|
| "driver-basic-medium"
|
||||||
| "driver-basic-large";
|
| "driver-basic-large";
|
||||||
export interface BGChyron extends BGRelativePos {
|
export interface BGChyron extends BGBaseState {
|
||||||
mode: BGChyronMode;
|
mode: BGChyronMode;
|
||||||
cars: Array<Car>;
|
car: Car;
|
||||||
|
flagMode: FlagMode;
|
||||||
|
showPosFlag: boolean;
|
||||||
|
showDriverNumber: boolean;
|
||||||
|
dimensions: Dimensions;
|
||||||
|
props?: unknown;
|
||||||
|
}
|
||||||
|
export interface BGChyrons {
|
||||||
|
primary: BGChyron;
|
||||||
|
secondary: Optional<BGChyron>;
|
||||||
|
// sponsorGem: BGSponsorGem;
|
||||||
}
|
}
|
||||||
export interface BGChyronMedium extends BGChyron {
|
export interface BGChyronMedium extends BGChyron {
|
||||||
mode: "driver-basic-medium";
|
mode: "driver-basic-medium";
|
||||||
flag: FlagMode;
|
dimensions: {
|
||||||
showPosFlag: boolean;
|
width: 582;
|
||||||
showDriverNumber: boolean;
|
height: 72;
|
||||||
|
}
|
||||||
|
props: {
|
||||||
|
showPortrait: boolean;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
export interface BGChyronLarge extends BGChyron {
|
||||||
|
mode: "driver-basic-large";
|
||||||
|
dimensions: {
|
||||||
|
width: 638;
|
||||||
|
height: 98;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Vendored
+3
@@ -0,0 +1,3 @@
|
|||||||
|
export type Optional<TEntity> = TEntity | null;
|
||||||
|
export type Milliseconds = number;
|
||||||
|
export type Seconds = number;
|
||||||
Reference in new issue
Block a user