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,
|
||||
LatLon,
|
||||
)
|
||||
from game.transfers import MultiGroupTransport, TransportMap
|
||||
from game.utils import meters, nautical_miles
|
||||
from gen.ato import AirTaskingOrder
|
||||
from gen.flights.flight import Flight, FlightWaypoint, FlightWaypointType
|
||||
@ -254,6 +255,7 @@ class SupplyRouteJs(QObject):
|
||||
frontActiveChanged = Signal()
|
||||
isSeaChanged = Signal()
|
||||
blueChanged = Signal()
|
||||
activeTransportsChanged = Signal()
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
@ -261,12 +263,50 @@ class SupplyRouteJs(QObject):
|
||||
b: ControlPoint,
|
||||
points: List[LeafletLatLon],
|
||||
sea_route: bool,
|
||||
game: Game,
|
||||
) -> None:
|
||||
super().__init__()
|
||||
self.control_point_a = a
|
||||
self.control_point_b = b
|
||||
self._points = points
|
||||
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)
|
||||
def points(self) -> List[LeafletLatLon]:
|
||||
@ -638,6 +678,7 @@ class MapModel(QObject):
|
||||
for p in convoy_route
|
||||
],
|
||||
sea_route=False,
|
||||
game=self.game,
|
||||
)
|
||||
)
|
||||
for destination, shipping_lane in control_point.shipping_lanes.items():
|
||||
@ -653,6 +694,7 @@ class MapModel(QObject):
|
||||
for p in shipping_lane
|
||||
],
|
||||
sea_route=True,
|
||||
game=self.game,
|
||||
)
|
||||
)
|
||||
self.supplyRoutesChanged.emit()
|
||||
|
||||
@ -6,7 +6,6 @@
|
||||
* - Navmeshes
|
||||
* - Time of day/weather themeing
|
||||
* - Exclusion zones
|
||||
* - Supply route status
|
||||
* - "Actual" front line
|
||||
* - Debug flight plan drawing
|
||||
* - Icon variety
|
||||
@ -384,10 +383,20 @@ function drawSupplyRoutes() {
|
||||
} else {
|
||||
color = "#8c1414";
|
||||
}
|
||||
L.polyline(route.points, {
|
||||
const line = L.polyline(route.points, {
|
||||
color: color,
|
||||
weight: route.isSea ? 4 : 6,
|
||||
}).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