Add "Show all" option for flight plans.

Fixes https://github.com/dcs-liberation/dcs_liberation/issues/1085
This commit is contained in:
Dan Albert 2021-05-16 13:15:51 -07:00
parent 7dd379c5c3
commit 2dfe1420bc

View File

@ -59,6 +59,7 @@ const blueSamDetectionLayer = L.layerGroup();
const redSamDetectionLayer = L.layerGroup(); const redSamDetectionLayer = L.layerGroup();
const redFlightPlansLayer = L.layerGroup(); const redFlightPlansLayer = L.layerGroup();
const selectedFlightPlansLayer = L.layerGroup(); const selectedFlightPlansLayer = L.layerGroup();
const allFlightPlansLayer = L.layerGroup();
L.control L.control
.groupedLayers( .groupedLayers(
@ -83,6 +84,7 @@ L.control
"Show selected blue": selectedFlightPlansLayer, "Show selected blue": selectedFlightPlansLayer,
"Show all blue": blueFlightPlansLayer, "Show all blue": blueFlightPlansLayer,
"Show all red": redFlightPlansLayer, "Show all red": redFlightPlansLayer,
"Show all": allFlightPlansLayer,
}, },
}, },
{ collapsed: false, exclusiveGroups: ["Flight Plans"] } { collapsed: false, exclusiveGroups: ["Flight Plans"] }
@ -514,18 +516,22 @@ class Flight {
const layer = this.flightPlanLayer(); const layer = this.flightPlanLayer();
if (this.flight.selected) { if (this.flight.selected) {
this.path = L.polyline(path, { color: Colors.Highlight }) this.path = L.polyline(path, { color: Colors.Highlight })
.addTo(selectedFlightPlansLayer)
.addTo(layer) .addTo(layer)
.addTo(selectedFlightPlansLayer); .addTo(allFlightPlansLayer);
} else { } else {
this.path = L.polyline(path, { color: color }).addTo(layer); this.path = L.polyline(path, { color: color })
.addTo(layer)
.addTo(allFlightPlansLayer);
} }
} }
drawCommitBoundary() { drawCommitBoundary() {
if (this.commitBoundary != null) { if (this.commitBoundary != null) {
this.commitBoundary this.commitBoundary
.removeFrom(selectedFlightPlansLayer)
.removeFrom(this.flightPlanLayer()) .removeFrom(this.flightPlanLayer())
.removeFrom(selectedFlightPlansLayer); .removeFrom(allFlightPlansLayer);
} }
if (this.flight.selected) { if (this.flight.selected) {
if (this.flight.commitBoundary) { if (this.flight.commitBoundary) {
@ -533,8 +539,9 @@ class Flight {
color: Colors.Highlight, color: Colors.Highlight,
weight: 1, weight: 1,
}) })
.addTo(selectedFlightPlansLayer)
.addTo(this.flightPlanLayer()) .addTo(this.flightPlanLayer())
.addTo(selectedFlightPlansLayer); .addTo(allFlightPlansLayer);
} }
} }
} }
@ -547,8 +554,9 @@ class Flight {
} }
if (this.shouldMark(waypoint)) { if (this.shouldMark(waypoint)) {
waypoint.marker waypoint.marker
.addTo(selectedFlightPlansLayer)
.addTo(this.flightPlanLayer()) .addTo(this.flightPlanLayer())
.addTo(selectedFlightPlansLayer); .addTo(allFlightPlansLayer);
} }
}); });
@ -561,6 +569,7 @@ function drawFlightPlans() {
blueFlightPlansLayer.clearLayers(); blueFlightPlansLayer.clearLayers();
redFlightPlansLayer.clearLayers(); redFlightPlansLayer.clearLayers();
selectedFlightPlansLayer.clearLayers(); selectedFlightPlansLayer.clearLayers();
allFlightPlansLayer.clearLayers();
let selected = null; let selected = null;
game.flights.forEach((flight) => { game.flights.forEach((flight) => {
// Draw the selected waypoint last so it's on top. bringToFront only brings // Draw the selected waypoint last so it's on top. bringToFront only brings