From f9e9c2793aa3e159c7e2d49503ec28b2d643dc7f Mon Sep 17 00:00:00 2001 From: Dan Albert Date: Sat, 13 May 2023 17:10:29 -0700 Subject: [PATCH] Allow manual SAM orientation. Fixes https://github.com/dcs-liberation/dcs_liberation/issues/2479. --- changelog.md | 1 + .../windows/groundobject/QGroundObjectMenu.py | 32 ++++++++++++------- 2 files changed, 22 insertions(+), 11 deletions(-) diff --git a/changelog.md b/changelog.md index b49bd5da..464af4eb 100644 --- a/changelog.md +++ b/changelog.md @@ -141,6 +141,7 @@ Saves from 6.x are not compatible with 7.0. * **[Modding]** The `mission_types` field in squadron files has been removed. Squadron task capability is now determined by airframe, and the auto-assignable list has always been overridden by the campaign settings. * **[Squadrons]** Squadron-specific mission capability lists no longer restrict players from assigning missions outside the squadron's preferences. * **[New Game Wizard]** Squadrons can be directly replaced with a preset during air wing configuration rather than needing to remove and create a new squadron. +* **[UI]** The orientation of objects like SAMs, EWRs, garrisons, and ships can now be manually adjusted. ## Fixes diff --git a/qt_ui/windows/groundobject/QGroundObjectMenu.py b/qt_ui/windows/groundobject/QGroundObjectMenu.py index d99c58b1..18cf14c6 100644 --- a/qt_ui/windows/groundobject/QGroundObjectMenu.py +++ b/qt_ui/windows/groundobject/QGroundObjectMenu.py @@ -10,6 +10,7 @@ from PySide2.QtWidgets import ( QPushButton, QVBoxLayout, QSpinBox, + QWidget, ) from dcs import Point @@ -30,6 +31,18 @@ from qt_ui.windows.groundobject.QBuildingInfo import QBuildingInfo from qt_ui.windows.groundobject.QGroundObjectBuyMenu import QGroundObjectBuyMenu +class HeadingIndicator(QLabel): + def __init__(self, initial_heading: Heading, parent: QWidget) -> None: + super().__init__(parent) + self.set_heading(initial_heading) + self.setFixedSize(32, 32) + + def set_heading(self, heading: Heading) -> None: + self.setPixmap( + ICONS["heading"].transformed(QTransform().rotate(heading.degrees)) + ) + + class QGroundObjectMenu(QDialog): def __init__( self, @@ -148,24 +161,21 @@ class QGroundObjectMenu(QDialog): self.orientationBox = QGroupBox("Orientation :") self.orientationBoxLayout = QHBoxLayout() - heading_image = QLabel() - heading_image.setPixmap( - ICONS["heading"].transformed( - QTransform().rotate(self.ground_object.heading.degrees) - ) - ) + heading_image = HeadingIndicator(self.ground_object.heading, self) self.orientationBoxLayout.addWidget(heading_image) self.headingLabel = QLabel("Heading:") self.orientationBoxLayout.addWidget(self.headingLabel) self.headingSelector = QSpinBox() - self.headingSelector.setEnabled(False) # Disable for now - self.headingSelector.setMinimum(0) - self.headingSelector.setMaximum(360) + self.headingSelector.setEnabled(self.cp.is_friendly(to_player=True)) + self.headingSelector.setRange(0, 359) + self.headingSelector.setWrapping(True) + self.headingSelector.setSingleStep(5) self.headingSelector.setValue(self.ground_object.heading.degrees) + self.headingSelector.valueChanged.connect( + lambda degrees: heading_image.set_heading(Heading(degrees)) + ) self.orientationBoxLayout.addWidget(self.headingSelector) if self.cp.captured: - # TODO Let the user choose the heading with the SpinBox - self.headingSelector.setEnabled(False) self.head_to_conflict_button = QPushButton("Head to conflict") heading = ( self.game.theater.heading_to_conflict_from(self.ground_object.position)