mirror of
https://github.com/dcs-retribution/dcs-retribution.git
synced 2025-11-10 15:41:24 +00:00
Add back the "selected only" flight plans layer.
Fixes https://github.com/dcs-liberation/dcs_liberation/issues/2058
This commit is contained in:
parent
ca640ebabe
commit
cf7c7d853f
@ -11,10 +11,11 @@ const SELECTED_PATH = "#ffff00";
|
|||||||
interface FlightPlanProps {
|
interface FlightPlanProps {
|
||||||
flight: Flight;
|
flight: Flight;
|
||||||
selected: boolean;
|
selected: boolean;
|
||||||
|
highlight?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
const pathColor = (props: FlightPlanProps) => {
|
const pathColor = (props: FlightPlanProps) => {
|
||||||
if (props.selected) {
|
if (props.selected && props.highlight) {
|
||||||
return SELECTED_PATH;
|
return SELECTED_PATH;
|
||||||
} else if (props.flight.blue) {
|
} else if (props.flight.blue) {
|
||||||
return BLUE_PATH;
|
return BLUE_PATH;
|
||||||
|
|||||||
@ -6,6 +6,7 @@ import { LayerGroup } from "react-leaflet";
|
|||||||
|
|
||||||
interface FlightPlansLayerProps {
|
interface FlightPlansLayerProps {
|
||||||
blue: boolean;
|
blue: boolean;
|
||||||
|
selectedOnly?: true;
|
||||||
}
|
}
|
||||||
|
|
||||||
function SelectedFlightPlan(props: FlightPlansLayerProps) {
|
function SelectedFlightPlan(props: FlightPlansLayerProps) {
|
||||||
@ -19,10 +20,17 @@ function SelectedFlightPlan(props: FlightPlansLayerProps) {
|
|||||||
return <></>;
|
return <></>;
|
||||||
}
|
}
|
||||||
|
|
||||||
return <FlightPlan key={flight.id} flight={flight} selected={true} />;
|
return (
|
||||||
|
<FlightPlan
|
||||||
|
key={flight.id}
|
||||||
|
flight={flight}
|
||||||
|
selected={true}
|
||||||
|
highlight={!props.selectedOnly}
|
||||||
|
/>
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function FlightPlansLayer(props: FlightPlansLayerProps) {
|
function UnselectedFlightPlans(props: FlightPlansLayerProps) {
|
||||||
const flightData = useAppSelector(selectFlights);
|
const flightData = useAppSelector(selectFlights);
|
||||||
const isNotSelected = (flight: Flight) => {
|
const isNotSelected = (flight: Flight) => {
|
||||||
if (flightData.selected == null) {
|
if (flightData.selected == null) {
|
||||||
@ -31,8 +39,12 @@ export default function FlightPlansLayer(props: FlightPlansLayerProps) {
|
|||||||
return flightData.selected !== flight.id;
|
return flightData.selected !== flight.id;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (props.selectedOnly) {
|
||||||
|
return <></>;
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<LayerGroup>
|
<>
|
||||||
{Object.values(flightData.flights)
|
{Object.values(flightData.flights)
|
||||||
.filter(isNotSelected)
|
.filter(isNotSelected)
|
||||||
.filter((flight) => props.blue === flight.blue)
|
.filter((flight) => props.blue === flight.blue)
|
||||||
@ -41,6 +53,14 @@ export default function FlightPlansLayer(props: FlightPlansLayerProps) {
|
|||||||
<FlightPlan key={flight.id} flight={flight} selected={false} />
|
<FlightPlan key={flight.id} flight={flight} selected={false} />
|
||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export default function FlightPlansLayer(props: FlightPlansLayerProps) {
|
||||||
|
return (
|
||||||
|
<LayerGroup>
|
||||||
|
<UnselectedFlightPlans {...props} />
|
||||||
<SelectedFlightPlan {...props} />
|
<SelectedFlightPlan {...props} />
|
||||||
</LayerGroup>
|
</LayerGroup>
|
||||||
);
|
);
|
||||||
|
|||||||
@ -80,6 +80,9 @@ export default function LiberationMap() {
|
|||||||
<LayersControl.Overlay name="Allied SAM detection range">
|
<LayersControl.Overlay name="Allied SAM detection range">
|
||||||
<AirDefenseRangeLayer blue={true} detection />
|
<AirDefenseRangeLayer blue={true} detection />
|
||||||
</LayersControl.Overlay>
|
</LayersControl.Overlay>
|
||||||
|
<LayersControl.Overlay name="Selected blue flight plan">
|
||||||
|
<FlightPlansLayer blue={true} selectedOnly />
|
||||||
|
</LayersControl.Overlay>
|
||||||
<LayersControl.Overlay name="All blue flight plans" checked>
|
<LayersControl.Overlay name="All blue flight plans" checked>
|
||||||
<FlightPlansLayer blue={true} />
|
<FlightPlansLayer blue={true} />
|
||||||
</LayersControl.Overlay>
|
</LayersControl.Overlay>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user