mirror of
https://github.com/dcs-retribution/dcs-retribution.git
synced 2025-11-10 15:41:24 +00:00
Show active supply routes in the new UI.
This commit is contained in:
parent
752eb6235d
commit
7dd379c5c3
@ -20,6 +20,7 @@ from game.theater import (
|
|||||||
FrontLine,
|
FrontLine,
|
||||||
LatLon,
|
LatLon,
|
||||||
)
|
)
|
||||||
|
from game.transfers import MultiGroupTransport, TransportMap
|
||||||
from game.utils import meters, nautical_miles
|
from game.utils import meters, nautical_miles
|
||||||
from gen.ato import AirTaskingOrder
|
from gen.ato import AirTaskingOrder
|
||||||
from gen.flights.flight import Flight, FlightWaypoint, FlightWaypointType
|
from gen.flights.flight import Flight, FlightWaypoint, FlightWaypointType
|
||||||
@ -254,6 +255,7 @@ class SupplyRouteJs(QObject):
|
|||||||
frontActiveChanged = Signal()
|
frontActiveChanged = Signal()
|
||||||
isSeaChanged = Signal()
|
isSeaChanged = Signal()
|
||||||
blueChanged = Signal()
|
blueChanged = Signal()
|
||||||
|
activeTransportsChanged = Signal()
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
@ -261,12 +263,50 @@ class SupplyRouteJs(QObject):
|
|||||||
b: ControlPoint,
|
b: ControlPoint,
|
||||||
points: List[LeafletLatLon],
|
points: List[LeafletLatLon],
|
||||||
sea_route: bool,
|
sea_route: bool,
|
||||||
|
game: Game,
|
||||||
) -> None:
|
) -> None:
|
||||||
super().__init__()
|
super().__init__()
|
||||||
self.control_point_a = a
|
self.control_point_a = a
|
||||||
self.control_point_b = b
|
self.control_point_b = b
|
||||||
self._points = points
|
self._points = points
|
||||||
self.sea_route = sea_route
|
self.sea_route = sea_route
|
||||||
|
self.game = game
|
||||||
|
|
||||||
|
def find_in_transport_map(
|
||||||
|
self, transport_map: TransportMap
|
||||||
|
) -> List[MultiGroupTransport]:
|
||||||
|
transports = []
|
||||||
|
transport = transport_map.find_transport(
|
||||||
|
self.control_point_a, self.control_point_b
|
||||||
|
)
|
||||||
|
if transport is not None:
|
||||||
|
transports.append(transport)
|
||||||
|
transport = transport_map.find_transport(
|
||||||
|
self.control_point_b, self.control_point_a
|
||||||
|
)
|
||||||
|
if transport is not None:
|
||||||
|
transports.append(transport)
|
||||||
|
return transports
|
||||||
|
|
||||||
|
def find_transports(self) -> List[MultiGroupTransport]:
|
||||||
|
if self.sea_route:
|
||||||
|
return self.find_in_transport_map(self.game.transfers.cargo_ships)
|
||||||
|
return self.find_in_transport_map(self.game.transfers.convoys)
|
||||||
|
|
||||||
|
@Property(list, notify=activeTransportsChanged)
|
||||||
|
def activeTransports(self) -> List[str]:
|
||||||
|
transports = self.find_transports()
|
||||||
|
if not transports:
|
||||||
|
return []
|
||||||
|
|
||||||
|
descriptions = []
|
||||||
|
for transport in transports:
|
||||||
|
units = "units" if transport.size > 1 else "unit"
|
||||||
|
descriptions.append(
|
||||||
|
f"{transport.size} {units} transferring from {transport.origin} to "
|
||||||
|
f"{transport.destination}"
|
||||||
|
)
|
||||||
|
return descriptions
|
||||||
|
|
||||||
@Property(list, notify=pointsChanged)
|
@Property(list, notify=pointsChanged)
|
||||||
def points(self) -> List[LeafletLatLon]:
|
def points(self) -> List[LeafletLatLon]:
|
||||||
@ -638,6 +678,7 @@ class MapModel(QObject):
|
|||||||
for p in convoy_route
|
for p in convoy_route
|
||||||
],
|
],
|
||||||
sea_route=False,
|
sea_route=False,
|
||||||
|
game=self.game,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
for destination, shipping_lane in control_point.shipping_lanes.items():
|
for destination, shipping_lane in control_point.shipping_lanes.items():
|
||||||
@ -653,6 +694,7 @@ class MapModel(QObject):
|
|||||||
for p in shipping_lane
|
for p in shipping_lane
|
||||||
],
|
],
|
||||||
sea_route=True,
|
sea_route=True,
|
||||||
|
game=self.game,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
self.supplyRoutesChanged.emit()
|
self.supplyRoutesChanged.emit()
|
||||||
|
|||||||
@ -6,7 +6,6 @@
|
|||||||
* - Navmeshes
|
* - Navmeshes
|
||||||
* - Time of day/weather themeing
|
* - Time of day/weather themeing
|
||||||
* - Exclusion zones
|
* - Exclusion zones
|
||||||
* - Supply route status
|
|
||||||
* - "Actual" front line
|
* - "Actual" front line
|
||||||
* - Debug flight plan drawing
|
* - Debug flight plan drawing
|
||||||
* - Icon variety
|
* - Icon variety
|
||||||
@ -384,10 +383,20 @@ function drawSupplyRoutes() {
|
|||||||
} else {
|
} else {
|
||||||
color = "#8c1414";
|
color = "#8c1414";
|
||||||
}
|
}
|
||||||
L.polyline(route.points, {
|
const line = L.polyline(route.points, {
|
||||||
color: color,
|
color: color,
|
||||||
weight: route.isSea ? 4 : 6,
|
weight: route.isSea ? 4 : 6,
|
||||||
}).addTo(supplyRoutesLayer);
|
}).addTo(supplyRoutesLayer);
|
||||||
|
const activeTransports = route.activeTransports;
|
||||||
|
if (activeTransports.length > 0) {
|
||||||
|
line.bindTooltip(activeTransports.join("<br />"));
|
||||||
|
L.polyline(route.points, {
|
||||||
|
color: "#ffffff",
|
||||||
|
weight: 2,
|
||||||
|
}).addTo(supplyRoutesLayer);
|
||||||
|
} else {
|
||||||
|
line.bindTooltip("This supply route is inactive.");
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user