From bc861380f032f7e2020c2a3213c67b983f11ca93 Mon Sep 17 00:00:00 2001 From: Raffson Date: Sun, 22 Oct 2023 00:21:46 +0200 Subject: [PATCH] Allow hiding IADS TGOs on MFD --- changelog.md | 1 + game/migrator.py | 1 + game/missiongenerator/tgogenerator.py | 6 +++-- game/theater/theatergroundobject.py | 2 ++ qt_ui/uiconstants.py | 1 + .../windows/groundobject/QGroundObjectMenu.py | 24 +++++++++++++++++++ 6 files changed, 33 insertions(+), 2 deletions(-) diff --git a/changelog.md b/changelog.md index 29b10116..df63e942 100644 --- a/changelog.md +++ b/changelog.md @@ -21,6 +21,7 @@ * **[UI]** Improved frequency selector to support all modeled bands for every aircraft's intra-flight radio * **[Options]** New options in Settings: Helicopter waypoint altitude (feet AGL) for combat & cruise waypoints * **[Options]** New options in Settings: Spawn ground power trucks at ground starts in airbases/roadbases +* **[Options]** Option for hiding TGOs (with IADS roles) on MFD ## Fixes * **[Mission Generation]** Anti-ship strikes should use "group attack" in their attack-task diff --git a/game/migrator.py b/game/migrator.py index c4fe7998..4a0cf75f 100644 --- a/game/migrator.py +++ b/game/migrator.py @@ -223,3 +223,4 @@ class Migrator: def _update_tgos(self) -> None: for go in self.game.theater.ground_objects: try_set_attr(go, "task", None) + try_set_attr(go, "hide_on_mfd", False) diff --git a/game/missiongenerator/tgogenerator.py b/game/missiongenerator/tgogenerator.py index 7de93bec..8a1f61b8 100644 --- a/game/missiongenerator/tgogenerator.py +++ b/game/missiongenerator/tgogenerator.py @@ -290,9 +290,11 @@ class GroundObjectGenerator: # All alive Ships ship_units.append(unit) if vehicle_units: - self.create_vehicle_group(group.group_name, vehicle_units) + vg = self.create_vehicle_group(group.group_name, vehicle_units) + vg.hidden_on_mfd = self.ground_object.hide_on_mfd if ship_units: - self.create_ship_group(group.group_name, ship_units) + sg = self.create_ship_group(group.group_name, ship_units) + sg.hidden_on_mfd = self.ground_object.hide_on_mfd def create_vehicle_group( self, group_name: str, units: list[TheaterUnit] diff --git a/game/theater/theatergroundobject.py b/game/theater/theatergroundobject.py index 275dee75..70467c34 100644 --- a/game/theater/theatergroundobject.py +++ b/game/theater/theatergroundobject.py @@ -64,6 +64,7 @@ class TheaterGroundObject(MissionTarget, SidcDescribable, ABC): control_point: ControlPoint, sea_object: bool, task: Optional[GroupTask], + hide_on_mfd: bool = False, ) -> None: super().__init__(name, location) self.id = uuid.uuid4() @@ -75,6 +76,7 @@ class TheaterGroundObject(MissionTarget, SidcDescribable, ABC): self.original_name = location.original_name self._threat_poly: ThreatPoly | None = None self.task = task + self.hide_on_mfd = hide_on_mfd def __getstate__(self) -> dict[str, Any]: state = self.__dict__.copy() diff --git a/qt_ui/uiconstants.py b/qt_ui/uiconstants.py index efeb4277..3c501db9 100644 --- a/qt_ui/uiconstants.py +++ b/qt_ui/uiconstants.py @@ -183,6 +183,7 @@ def load_icons(): ) ICONS["heading"] = QPixmap("./resources/ui/misc/heading.png") + ICONS["blue-sam"] = QPixmap("./resources/ui/misc/blue-sam.png") EVENT_ICONS: Dict[str, QPixmap] = {} diff --git a/qt_ui/windows/groundobject/QGroundObjectMenu.py b/qt_ui/windows/groundobject/QGroundObjectMenu.py index 09cc9251..6ce4e8df 100644 --- a/qt_ui/windows/groundobject/QGroundObjectMenu.py +++ b/qt_ui/windows/groundobject/QGroundObjectMenu.py @@ -11,6 +11,7 @@ from PySide6.QtWidgets import ( QVBoxLayout, QSpinBox, QWidget, + QCheckBox, ) from dcs import Point @@ -43,6 +44,13 @@ class HeadingIndicator(QLabel): ) +class SamIndicator(QLabel): + def __init__(self, parent: QWidget) -> None: + super().__init__(parent) + self.setFixedSize(32, 32) + self.setPixmap(ICONS["blue-sam"]) + + class QGroundObjectMenu(QDialog): def __init__( self, @@ -83,6 +91,8 @@ class QGroundObjectMenu(QDialog): else: self.mainLayout.addWidget(self.intelBox) self.mainLayout.addWidget(self.orientationBox) + if self.ground_object.is_iads and self.cp.is_friendly(to_player=False): + self.mainLayout.addWidget(self.hiddenBox) self.actionLayout = QHBoxLayout() @@ -188,11 +198,25 @@ class QGroundObjectMenu(QDialog): else: self.headingSelector.setEnabled(False) + # Hidden Box + self.hiddenBox = QGroupBox() + self.hiddenBoxLayout = QHBoxLayout() + self.hiddenBoxLayout.addWidget(SamIndicator(self)) + self.hiddenBoxLayout.addWidget(QLabel("Hidden on MFD:")) + self.hiddenCheckBox = QCheckBox() + self.hiddenCheckBox.setChecked(self.ground_object.hide_on_mfd) + self.hiddenCheckBox.stateChanged.connect(self.update_hidden_on_mfd) + self.hiddenBoxLayout.addWidget(self.hiddenCheckBox) + # Set the layouts self.financesBox.setLayout(self.financesBoxLayout) self.buildingBox.setLayout(self.buildingsLayout) self.intelBox.setLayout(self.intelLayout) self.orientationBox.setLayout(self.orientationBoxLayout) + self.hiddenBox.setLayout(self.hiddenBoxLayout) + + def update_hidden_on_mfd(self, state: bool) -> None: + self.ground_object.hide_on_mfd = bool(state) def do_refresh_layout(self): try: