Allow manual SAM orientation.

Fixes https://github.com/dcs-liberation/dcs_liberation/issues/2479.
This commit is contained in:
Dan Albert 2023-05-13 17:10:29 -07:00 committed by Raffson
parent 83916b9fb0
commit f9e9c2793a
No known key found for this signature in database
GPG Key ID: B0402B2C9B764D99
2 changed files with 22 additions and 11 deletions

View File

@ -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

View File

@ -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)