mirror of
https://github.com/dcs-liberation/dcs_liberation.git
synced 2025-11-10 14:22:26 +00:00
Add front lines to new map UI.
Only shows an approximate front line. Still need support for "actual".
This commit is contained in:
parent
3e01953a3a
commit
d73ceb374c
@ -4,8 +4,8 @@ from typing import List, Optional, Tuple
|
|||||||
|
|
||||||
from PySide2.QtCore import Property, QObject, Signal, Slot
|
from PySide2.QtCore import Property, QObject, Signal, Slot
|
||||||
from dcs import Point
|
from dcs import Point
|
||||||
from dcs.vehicles import vehicle_map
|
|
||||||
from dcs.unit import Unit
|
from dcs.unit import Unit
|
||||||
|
from dcs.vehicles import vehicle_map
|
||||||
|
|
||||||
from game import Game, db
|
from game import Game, db
|
||||||
from game.profiling import logged_duration
|
from game.profiling import logged_duration
|
||||||
@ -13,8 +13,9 @@ from game.theater import (
|
|||||||
ConflictTheater,
|
ConflictTheater,
|
||||||
ControlPoint,
|
ControlPoint,
|
||||||
TheaterGroundObject,
|
TheaterGroundObject,
|
||||||
|
FrontLine,
|
||||||
)
|
)
|
||||||
from game.utils import meters
|
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
|
||||||
from gen.flights.flightplan import FlightPlan
|
from gen.flights.flightplan import FlightPlan
|
||||||
@ -190,6 +191,31 @@ class SupplyRouteJs(QObject):
|
|||||||
return self.control_point_a.captured
|
return self.control_point_a.captured
|
||||||
|
|
||||||
|
|
||||||
|
class FrontLineJs(QObject):
|
||||||
|
def __init__(self, front_line: FrontLine, theater: ConflictTheater) -> None:
|
||||||
|
super().__init__()
|
||||||
|
self.front_line = front_line
|
||||||
|
self.theater = theater
|
||||||
|
|
||||||
|
@Property(list)
|
||||||
|
def extents(self) -> List[LeafletLatLon]:
|
||||||
|
a = self.theater.point_to_ll(
|
||||||
|
self.front_line.position.point_from_heading(
|
||||||
|
self.front_line.attack_heading + 90, nautical_miles(2).meters
|
||||||
|
)
|
||||||
|
)
|
||||||
|
b = self.theater.point_to_ll(
|
||||||
|
self.front_line.position.point_from_heading(
|
||||||
|
self.front_line.attack_heading + 270, nautical_miles(2).meters
|
||||||
|
)
|
||||||
|
)
|
||||||
|
return [[a.latitude, a.longitude], [b.latitude, b.longitude]]
|
||||||
|
|
||||||
|
@Slot()
|
||||||
|
def showPackageDialog(self) -> None:
|
||||||
|
Dialog.open_new_package_dialog(self.front_line)
|
||||||
|
|
||||||
|
|
||||||
class WaypointJs(QObject):
|
class WaypointJs(QObject):
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
@ -289,6 +315,7 @@ class MapModel(QObject):
|
|||||||
groundObjectsChanged = Signal()
|
groundObjectsChanged = Signal()
|
||||||
supplyRoutesChanged = Signal()
|
supplyRoutesChanged = Signal()
|
||||||
flightsChanged = Signal()
|
flightsChanged = Signal()
|
||||||
|
frontLinesChanged = Signal()
|
||||||
|
|
||||||
def __init__(self, game_model: GameModel) -> None:
|
def __init__(self, game_model: GameModel) -> None:
|
||||||
super().__init__()
|
super().__init__()
|
||||||
@ -298,6 +325,7 @@ class MapModel(QObject):
|
|||||||
self._ground_objects = []
|
self._ground_objects = []
|
||||||
self._supply_routes = []
|
self._supply_routes = []
|
||||||
self._flights = []
|
self._flights = []
|
||||||
|
self._front_lines = []
|
||||||
self._selected_flight_index: Optional[Tuple[int, int]] = None
|
self._selected_flight_index: Optional[Tuple[int, int]] = None
|
||||||
GameUpdateSignal.get_instance().game_loaded.connect(self.on_game_load)
|
GameUpdateSignal.get_instance().game_loaded.connect(self.on_game_load)
|
||||||
GameUpdateSignal.get_instance().flight_paths_changed.connect(self.reset_atos)
|
GameUpdateSignal.get_instance().flight_paths_changed.connect(self.reset_atos)
|
||||||
@ -309,6 +337,14 @@ class MapModel(QObject):
|
|||||||
)
|
)
|
||||||
self.reset()
|
self.reset()
|
||||||
|
|
||||||
|
def clear(self) -> None:
|
||||||
|
self._control_points = []
|
||||||
|
self._supply_routes = []
|
||||||
|
self._ground_objects = []
|
||||||
|
self._flights = []
|
||||||
|
self._front_lines = []
|
||||||
|
self.cleared.emit()
|
||||||
|
|
||||||
def set_package_selection(self, index: int) -> None:
|
def set_package_selection(self, index: int) -> None:
|
||||||
# Optional[int] isn't a valid type for a Qt signal. None will be converted to
|
# Optional[int] isn't a valid type for a Qt signal. None will be converted to
|
||||||
# zero automatically. We use -1 to indicate no selection.
|
# zero automatically. We use -1 to indicate no selection.
|
||||||
@ -349,6 +385,7 @@ class MapModel(QObject):
|
|||||||
self.reset_ground_objects()
|
self.reset_ground_objects()
|
||||||
self.reset_routes()
|
self.reset_routes()
|
||||||
self.reset_atos()
|
self.reset_atos()
|
||||||
|
self.reset_front_lines()
|
||||||
|
|
||||||
def on_game_load(self, game: Optional[Game]) -> None:
|
def on_game_load(self, game: Optional[Game]) -> None:
|
||||||
if game is not None:
|
if game is not None:
|
||||||
@ -453,12 +490,15 @@ class MapModel(QObject):
|
|||||||
def supplyRoutes(self) -> List[SupplyRouteJs]:
|
def supplyRoutes(self) -> List[SupplyRouteJs]:
|
||||||
return self._supply_routes
|
return self._supply_routes
|
||||||
|
|
||||||
def clear(self) -> None:
|
def reset_front_lines(self) -> None:
|
||||||
self._control_points = []
|
self._front_lines = [
|
||||||
self._supply_routes = []
|
FrontLineJs(f, self.game.theater) for f in self.game.theater.conflicts()
|
||||||
self._ground_objects = []
|
]
|
||||||
self._flights = []
|
self.frontLinesChanged.emit()
|
||||||
self.cleared.emit()
|
|
||||||
|
@Property(list, notify=frontLinesChanged)
|
||||||
|
def frontLines(self) -> List[FrontLineJs]:
|
||||||
|
return self._front_lines
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def game(self) -> Game:
|
def game(self) -> Game:
|
||||||
|
|||||||
@ -9,7 +9,7 @@
|
|||||||
* - Exclusion zones
|
* - Exclusion zones
|
||||||
* - Commit ranges
|
* - Commit ranges
|
||||||
* - Supply route status
|
* - Supply route status
|
||||||
* - Front line
|
* - "Actual" front line
|
||||||
* - Debug flight plan drawing
|
* - Debug flight plan drawing
|
||||||
* - Icon variety
|
* - Icon variety
|
||||||
*/
|
*/
|
||||||
@ -35,6 +35,7 @@ defaultBaseMap.addTo(map);
|
|||||||
var controlPointsLayer = L.layerGroup().addTo(map);
|
var controlPointsLayer = L.layerGroup().addTo(map);
|
||||||
var groundObjectsLayer = L.markerClusterGroup().addTo(map);
|
var groundObjectsLayer = L.markerClusterGroup().addTo(map);
|
||||||
var supplyRoutesLayer = L.layerGroup().addTo(map);
|
var supplyRoutesLayer = L.layerGroup().addTo(map);
|
||||||
|
var frontLinesLayer = L.layerGroup().addTo(map);
|
||||||
var redSamThreatLayer = L.layerGroup().addTo(map);
|
var redSamThreatLayer = L.layerGroup().addTo(map);
|
||||||
var blueFlightPlansLayer = L.layerGroup().addTo(map);
|
var blueFlightPlansLayer = L.layerGroup().addTo(map);
|
||||||
|
|
||||||
@ -53,6 +54,7 @@ L.control
|
|||||||
"Control points": controlPointsLayer,
|
"Control points": controlPointsLayer,
|
||||||
"Ground objects": groundObjectsLayer,
|
"Ground objects": groundObjectsLayer,
|
||||||
"Supply routes": supplyRoutesLayer,
|
"Supply routes": supplyRoutesLayer,
|
||||||
|
"Front lines": frontLinesLayer,
|
||||||
},
|
},
|
||||||
"Air Defenses": {
|
"Air Defenses": {
|
||||||
"Ally SAM threat range": blueSamThreatLayer,
|
"Ally SAM threat range": blueSamThreatLayer,
|
||||||
@ -102,6 +104,7 @@ new QWebChannel(qt.webChannelTransport, function (channel) {
|
|||||||
game.controlPointsChanged.connect(drawControlPoints);
|
game.controlPointsChanged.connect(drawControlPoints);
|
||||||
game.groundObjectsChanged.connect(drawGroundObjects);
|
game.groundObjectsChanged.connect(drawGroundObjects);
|
||||||
game.supplyRoutesChanged.connect(drawSupplyRoutes);
|
game.supplyRoutesChanged.connect(drawSupplyRoutes);
|
||||||
|
game.frontLinesChanged.connect(drawFrontLines);
|
||||||
game.flightsChanged.connect(drawFlightPlans);
|
game.flightsChanged.connect(drawFlightPlans);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -200,6 +203,17 @@ function drawSupplyRoutes() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function drawFrontLines() {
|
||||||
|
frontLinesLayer.clearLayers();
|
||||||
|
game.frontLines.forEach((front) => {
|
||||||
|
L.polyline(front.extents, { weight: 8, color: "#fe7d0a" })
|
||||||
|
.on("contextmenu", function () {
|
||||||
|
front.showPackageDialog();
|
||||||
|
})
|
||||||
|
.addTo(frontLinesLayer);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
const SHOW_WAYPOINT_INFO_AT_ZOOM = 9;
|
const SHOW_WAYPOINT_INFO_AT_ZOOM = 9;
|
||||||
|
|
||||||
function drawFlightPlan(flight) {
|
function drawFlightPlan(flight) {
|
||||||
@ -264,6 +278,7 @@ function drawInitialMap() {
|
|||||||
drawControlPoints();
|
drawControlPoints();
|
||||||
drawGroundObjects();
|
drawGroundObjects();
|
||||||
drawSupplyRoutes();
|
drawSupplyRoutes();
|
||||||
|
drawFrontLines();
|
||||||
drawFlightPlans();
|
drawFlightPlans();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user