mirror of
https://github.com/dcs-retribution/dcs-retribution.git
synced 2025-11-10 15:41:24 +00:00
- The SA-8 LD unit hat the SA-13 unit name as variant. The Layout tried to create a SA-13 SHORAD Site but actually used an SA-8 LD unit instead with zero threat range. This resulted in a yellow marked GroundObject on the map - Cleaned up the treat and radar range functions a bit
86 lines
2.6 KiB
Python
86 lines
2.6 KiB
Python
from __future__ import annotations
|
|
|
|
from typing import List, Optional
|
|
|
|
from PySide2.QtCore import Property, QObject, Signal, Slot
|
|
|
|
from game import Game
|
|
from game.server.leaflet import LeafletLatLon
|
|
from game.theater import TheaterGroundObject
|
|
from qt_ui.dialogs import Dialog
|
|
from qt_ui.windows.groundobject.QGroundObjectMenu import QGroundObjectMenu
|
|
|
|
|
|
class GroundObjectJs(QObject):
|
|
nameChanged = Signal()
|
|
controlPointNameChanged = Signal()
|
|
unitsChanged = Signal()
|
|
blueChanged = Signal()
|
|
positionChanged = Signal()
|
|
samThreatRangesChanged = Signal()
|
|
samDetectionRangesChanged = Signal()
|
|
categoryChanged = Signal()
|
|
deadChanged = Signal()
|
|
|
|
def __init__(self, tgo: TheaterGroundObject, game: Game) -> None:
|
|
super().__init__()
|
|
self.tgo = tgo
|
|
self.game = game
|
|
self.theater = game.theater
|
|
self.dialog: Optional[QGroundObjectMenu] = None
|
|
|
|
@Slot()
|
|
def showInfoDialog(self) -> None:
|
|
if self.dialog is None:
|
|
self.dialog = QGroundObjectMenu(
|
|
None,
|
|
self.tgo,
|
|
self.tgo.control_point,
|
|
self.game,
|
|
)
|
|
self.dialog.show()
|
|
|
|
@Slot()
|
|
def showPackageDialog(self) -> None:
|
|
Dialog.open_new_package_dialog(self.tgo)
|
|
|
|
@Property(str, notify=nameChanged)
|
|
def name(self) -> str:
|
|
return self.tgo.name
|
|
|
|
@Property(str, notify=controlPointNameChanged)
|
|
def controlPointName(self) -> str:
|
|
return self.tgo.control_point.name
|
|
|
|
@Property(str, notify=categoryChanged)
|
|
def category(self) -> str:
|
|
return self.tgo.category
|
|
|
|
@Property(list, notify=unitsChanged)
|
|
def units(self) -> List[str]:
|
|
return [unit.display_name for unit in self.tgo.units]
|
|
|
|
@Property(bool, notify=blueChanged)
|
|
def blue(self) -> bool:
|
|
return self.tgo.control_point.captured
|
|
|
|
@Property(list, notify=positionChanged)
|
|
def position(self) -> LeafletLatLon:
|
|
return self.tgo.position.latlng().as_list()
|
|
|
|
@Property(bool, notify=deadChanged)
|
|
def dead(self) -> bool:
|
|
return not any(g.alive_units > 0 for g in self.tgo.groups)
|
|
|
|
@Property(list, notify=samThreatRangesChanged)
|
|
def samThreatRanges(self) -> List[float]:
|
|
if not self.tgo.might_have_aa:
|
|
return []
|
|
return [self.tgo.threat_range(group).meters for group in self.tgo.groups]
|
|
|
|
@Property(list, notify=samDetectionRangesChanged)
|
|
def samDetectionRanges(self) -> List[float]:
|
|
if not self.tgo.might_have_aa:
|
|
return []
|
|
return [self.tgo.detection_range(group).meters for group in self.tgo.groups]
|