mirror of
https://github.com/dcs-retribution/dcs-retribution.git
synced 2025-11-10 15:41:24 +00:00
Move threat zones out of MapModel.
This commit is contained in:
@@ -21,8 +21,6 @@ from .flightjs import FlightJs
|
||||
from .frontlinejs import FrontLineJs
|
||||
from .groundobjectjs import GroundObjectJs
|
||||
from .supplyroutejs import SupplyRouteJs
|
||||
from .threatzonecontainerjs import ThreatZoneContainerJs
|
||||
from .threatzonesjs import ThreatZonesJs
|
||||
|
||||
|
||||
# **EVERY PROPERTY NEEDS A NOTIFY SIGNAL**
|
||||
@@ -51,7 +49,6 @@ class MapModel(QObject):
|
||||
supplyRoutesChanged = Signal()
|
||||
flightsChanged = Signal()
|
||||
frontLinesChanged = Signal()
|
||||
threatZonesChanged = Signal()
|
||||
selectedFlightChanged = Signal(str)
|
||||
|
||||
def __init__(self, game_model: GameModel) -> None:
|
||||
@@ -63,9 +60,7 @@ class MapModel(QObject):
|
||||
self._supply_routes = []
|
||||
self._flights: dict[tuple[bool, int, int], FlightJs] = {}
|
||||
self._front_lines = []
|
||||
self._threat_zones = ThreatZoneContainerJs(
|
||||
ThreatZonesJs.empty(), ThreatZonesJs.empty()
|
||||
)
|
||||
|
||||
self._selected_flight_index: Optional[Tuple[int, int]] = None
|
||||
|
||||
GameUpdateSignal.get_instance().game_loaded.connect(self.on_game_load)
|
||||
@@ -84,9 +79,6 @@ class MapModel(QObject):
|
||||
self._ground_objects = []
|
||||
self._flights = {}
|
||||
self._front_lines = []
|
||||
self._threat_zones = ThreatZoneContainerJs(
|
||||
ThreatZonesJs.empty(), ThreatZonesJs.empty()
|
||||
)
|
||||
self.cleared.emit()
|
||||
|
||||
def set_package_selection(self, index: int) -> None:
|
||||
@@ -149,7 +141,6 @@ class MapModel(QObject):
|
||||
self.reset_routes()
|
||||
self.reset_atos()
|
||||
self.reset_front_lines()
|
||||
self.reset_threat_zones()
|
||||
|
||||
def on_game_load(self, game: Optional[Game]) -> None:
|
||||
if game is not None:
|
||||
@@ -266,21 +257,6 @@ class MapModel(QObject):
|
||||
def frontLines(self) -> List[FrontLineJs]:
|
||||
return self._front_lines
|
||||
|
||||
def reset_threat_zones(self) -> None:
|
||||
self._threat_zones = ThreatZoneContainerJs(
|
||||
ThreatZonesJs.from_zones(
|
||||
self.game.threat_zone_for(player=True), self.game.theater
|
||||
),
|
||||
ThreatZonesJs.from_zones(
|
||||
self.game.threat_zone_for(player=False), self.game.theater
|
||||
),
|
||||
)
|
||||
self.threatZonesChanged.emit()
|
||||
|
||||
@Property(ThreatZoneContainerJs, notify=threatZonesChanged)
|
||||
def threatZones(self) -> ThreatZoneContainerJs:
|
||||
return self._threat_zones
|
||||
|
||||
@property
|
||||
def game(self) -> Game:
|
||||
if self.game_model.game is None:
|
||||
|
||||
@@ -1,23 +0,0 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from PySide2.QtCore import Property, QObject, Signal
|
||||
|
||||
from .threatzonesjs import ThreatZonesJs
|
||||
|
||||
|
||||
class ThreatZoneContainerJs(QObject):
|
||||
blueChanged = Signal()
|
||||
redChanged = Signal()
|
||||
|
||||
def __init__(self, blue: ThreatZonesJs, red: ThreatZonesJs) -> None:
|
||||
super().__init__()
|
||||
self._blue = blue
|
||||
self._red = red
|
||||
|
||||
@Property(ThreatZonesJs, notify=blueChanged)
|
||||
def blue(self) -> ThreatZonesJs:
|
||||
return self._blue
|
||||
|
||||
@Property(ThreatZonesJs, notify=redChanged)
|
||||
def red(self) -> ThreatZonesJs:
|
||||
return self._red
|
||||
@@ -1,56 +0,0 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from PySide2.QtCore import Property, QObject, Signal
|
||||
|
||||
from game.server.leaflet import LeafletPoly, ShapelyUtil
|
||||
from game.theater import ConflictTheater
|
||||
from game.threatzones import ThreatZones
|
||||
|
||||
|
||||
class ThreatZonesJs(QObject):
|
||||
fullChanged = Signal()
|
||||
aircraftChanged = Signal()
|
||||
airDefensesChanged = Signal()
|
||||
radarSamsChanged = Signal()
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
full: list[LeafletPoly],
|
||||
aircraft: list[LeafletPoly],
|
||||
air_defenses: list[LeafletPoly],
|
||||
radar_sams: list[LeafletPoly],
|
||||
) -> None:
|
||||
super().__init__()
|
||||
self._full = full
|
||||
self._aircraft = aircraft
|
||||
self._air_defenses = air_defenses
|
||||
self._radar_sams = radar_sams
|
||||
|
||||
@Property(list, notify=fullChanged)
|
||||
def full(self) -> list[LeafletPoly]:
|
||||
return self._full
|
||||
|
||||
@Property(list, notify=aircraftChanged)
|
||||
def aircraft(self) -> list[LeafletPoly]:
|
||||
return self._aircraft
|
||||
|
||||
@Property(list, notify=airDefensesChanged)
|
||||
def airDefenses(self) -> list[LeafletPoly]:
|
||||
return self._air_defenses
|
||||
|
||||
@Property(list, notify=radarSamsChanged)
|
||||
def radarSams(self) -> list[LeafletPoly]:
|
||||
return self._radar_sams
|
||||
|
||||
@classmethod
|
||||
def from_zones(cls, zones: ThreatZones, theater: ConflictTheater) -> ThreatZonesJs:
|
||||
return ThreatZonesJs(
|
||||
ShapelyUtil.polys_to_leaflet(zones.all, theater),
|
||||
ShapelyUtil.polys_to_leaflet(zones.airbases, theater),
|
||||
ShapelyUtil.polys_to_leaflet(zones.air_defenses, theater),
|
||||
ShapelyUtil.polys_to_leaflet(zones.radar_sam_threats, theater),
|
||||
)
|
||||
|
||||
@classmethod
|
||||
def empty(cls) -> ThreatZonesJs:
|
||||
return ThreatZonesJs([], [], [], [])
|
||||
Reference in New Issue
Block a user