ISSUE-075 - Switched to using GridSpots for the SelectedCars state.
Chyrons still show out-of-date information, though. Might need to do some refactoring to get this straightened.
This commit is contained in:
1 parent
bf89bc96dc
commit
d9b30f64f2
6 files changed
+44
-50
No files matched your search
@@ -7,6 +7,7 @@ import { FaCheck, FaStepForward, FaTimes } from "react-icons/fa";
|
||||
|
||||
import { broadcastGraphicsSelector } from "../../../../features/broadcast/graphics/broadcastGraphicsSelector";
|
||||
import { broadcastDirectorSelector } from "../../../../features/broadcast/director/broadcastDirectorSelector";
|
||||
import { eventSelector } from "../../../../features/event/eventSelector";
|
||||
import {
|
||||
incrementChyronsOpenState,
|
||||
setChyrons,
|
||||
@@ -36,6 +37,7 @@ export function ChyronsDirectorControls() {
|
||||
const dispatch = useDispatch();
|
||||
const { chyrons } = useSelector(broadcastGraphicsSelector);
|
||||
const { selectedCars } = useSelector(broadcastDirectorSelector);
|
||||
const { grid } = useSelector(eventSelector);
|
||||
|
||||
// Handle changes to the chyron mode so submodes can be changed accordingly.
|
||||
useEffect(() => {
|
||||
@@ -60,14 +62,14 @@ export function ChyronsDirectorControls() {
|
||||
|
||||
const buildDriver = () => {
|
||||
if (selectedCars.length === 0) return;
|
||||
let primaryCar = selectedCars[0];
|
||||
let secondaryCar = selectedCars.length > 1 ? selectedCars[1] : null;
|
||||
let primaryCar = grid[selectedCars[0]];
|
||||
let secondaryCar = selectedCars.length > 1 ? grid[selectedCars[1]] : null;
|
||||
|
||||
// Auto-sort drivers by position so trailing car always appears second.
|
||||
if (chyronSubMode === "medium" && secondaryCar != null
|
||||
&& secondaryCar.position < primaryCar.position) {
|
||||
secondaryCar = selectedCars[0];
|
||||
primaryCar = selectedCars[1];
|
||||
secondaryCar = grid[selectedCars[0]];
|
||||
primaryCar = grid[selectedCars[1]];
|
||||
}
|
||||
const newChyrons: BGChyrons = {
|
||||
openState: 0,
|
||||
|
||||
@@ -1,12 +1,10 @@
|
||||
import { InlineCluster } from "@bedrock-layout/inline-cluster";
|
||||
import { findIndex } from "lodash";
|
||||
import { useDispatch, useSelector } from "react-redux";
|
||||
|
||||
import { broadcastDirectorSelector } from "../../../../features/broadcast/director/broadcastDirectorSelector";
|
||||
import { pushSelectedCars, clearSelectedCars, removeSelectedCars } from "../../../../features/broadcast/director/broadcastDirectorSlice";
|
||||
import { eventSelector } from "../../../../features/event/eventSelector";
|
||||
import { Car } from "../../../../types/state";
|
||||
import { carMatch } from "../../../../utils/comparators";
|
||||
import { GridSpot } from "../../../../types/state";
|
||||
|
||||
import { DriverLabel, GridItem, SelectionLabel } from "./styles";
|
||||
|
||||
@@ -19,24 +17,24 @@ export function GridSelection() {
|
||||
selectedCars,
|
||||
} = useSelector(broadcastDirectorSelector);
|
||||
|
||||
const carClick = (car: Car, selected: boolean) => () => {
|
||||
const carClick = (gridSpot: GridSpot, selected: boolean) => () => {
|
||||
if (selected) {
|
||||
dispatch(removeSelectedCars(car));
|
||||
dispatch(removeSelectedCars(gridSpot));
|
||||
} else {
|
||||
dispatch(pushSelectedCars(car));
|
||||
dispatch(pushSelectedCars(gridSpot));
|
||||
}
|
||||
};
|
||||
const carDoubleClick = (car: Car) => () => {
|
||||
dispatch(clearSelectedCars(car));
|
||||
const carDoubleClick = (gridSpot: GridSpot) => () => {
|
||||
dispatch(clearSelectedCars(gridSpot));
|
||||
};
|
||||
|
||||
return (
|
||||
<InlineCluster gutter="xs">
|
||||
{grid.map(car => {
|
||||
const selectedIndex = findIndex(selectedCars, carMatch(car));
|
||||
{grid.map((car, gridSpot) => {
|
||||
const selectedIndex = selectedCars.findIndex(g => g === gridSpot);
|
||||
const selected = selectedIndex !== -1;
|
||||
const onClick = carClick(car, selected);
|
||||
const onDoubleClick = carDoubleClick(car);
|
||||
const onClick = carClick(gridSpot, selected);
|
||||
const onDoubleClick = carDoubleClick(gridSpot);
|
||||
return (
|
||||
<GridItem
|
||||
key={car.driver.id}
|
||||
|
||||
+5
-5
@@ -32,7 +32,7 @@ export function TimingTowerPrototypeControls() {
|
||||
<ClickSpan
|
||||
onClick={() => {
|
||||
dispatch(increaseDistance({
|
||||
cars: selectedCars,
|
||||
gridSpots: selectedCars,
|
||||
distance: 200,
|
||||
randomness: 0,
|
||||
usePerformance: false,
|
||||
@@ -45,7 +45,7 @@ export function TimingTowerPrototypeControls() {
|
||||
<ClickSpan
|
||||
onClick={() => {
|
||||
dispatch(increaseDistance({
|
||||
cars: grid,
|
||||
gridSpots: Array.from(Array(grid.length).keys()),
|
||||
distance: 100,
|
||||
randomness: 0.05,
|
||||
usePerformance: true,
|
||||
@@ -58,7 +58,7 @@ export function TimingTowerPrototypeControls() {
|
||||
<ClickSpan
|
||||
onClick={() => {
|
||||
dispatch(increaseDistance({
|
||||
cars: grid,
|
||||
gridSpots: Array.from(Array(grid.length).keys()),
|
||||
distance: 1000,
|
||||
randomness: 0.05,
|
||||
usePerformance: true,
|
||||
@@ -71,7 +71,7 @@ export function TimingTowerPrototypeControls() {
|
||||
<ClickSpan
|
||||
onClick={() => {
|
||||
dispatch(setCarStatus({
|
||||
cars: selectedCars,
|
||||
gridSpots: selectedCars,
|
||||
status: CarStatus.Retired,
|
||||
}));
|
||||
dispatch(refreshRunningOrder());
|
||||
@@ -82,7 +82,7 @@ export function TimingTowerPrototypeControls() {
|
||||
<ClickSpan
|
||||
onClick={() => {
|
||||
dispatch(setCarStatus({
|
||||
cars: selectedCars,
|
||||
gridSpots: selectedCars,
|
||||
status: CarStatus.Normal,
|
||||
}));
|
||||
dispatch(refreshRunningOrder());
|
||||
|
||||
Reference in new issue
Block a user