mirror of
https://github.com/dcs-liberation/dcs_liberation.git
synced 2025-11-10 14:22:26 +00:00
Add livery selection dropdown to air wing config.
Fixes https://github.com/dcs-liberation/dcs_liberation/issues/1861.
This commit is contained in:
parent
50d7a3e46f
commit
8158cc7112
@ -21,6 +21,7 @@ Saves from 6.x are not compatible with 7.0.
|
|||||||
* **[New Game Wizard]** Choices for some options will be remembered for the next new game. Not all settings will be preserved, as many are campaign dependent.
|
* **[New Game Wizard]** Choices for some options will be remembered for the next new game. Not all settings will be preserved, as many are campaign dependent.
|
||||||
* **[New Game Wizard]** Lua plugins can now be set while creating a new game.
|
* **[New Game Wizard]** Lua plugins can now be set while creating a new game.
|
||||||
* **[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.
|
* **[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.
|
||||||
|
* **[New Game Wizard]** Squadron liveries can now be selected during air wing configuration.
|
||||||
* **[Squadrons]** Squadron-specific mission capability lists no longer restrict players from assigning missions outside the squadron's preferences.
|
* **[Squadrons]** Squadron-specific mission capability lists no longer restrict players from assigning missions outside the squadron's preferences.
|
||||||
|
|
||||||
## Fixes
|
## Fixes
|
||||||
|
|||||||
31
qt_ui/widgets/combos/liveryselector.py
Normal file
31
qt_ui/widgets/combos/liveryselector.py
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
|
from PySide6.QtWidgets import QComboBox
|
||||||
|
from dcs.liveries.livery import Livery
|
||||||
|
|
||||||
|
from game.squadrons import Squadron
|
||||||
|
|
||||||
|
|
||||||
|
class LiverySelector(QComboBox):
|
||||||
|
def __init__(self, squadron: Squadron) -> None:
|
||||||
|
super().__init__()
|
||||||
|
self.setSizeAdjustPolicy(QComboBox.SizeAdjustPolicy.AdjustToContents)
|
||||||
|
self.set_squadron(squadron)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def selected_livery(self) -> Livery | None:
|
||||||
|
return self.currentData()
|
||||||
|
|
||||||
|
def set_squadron(self, squadron: Squadron) -> None:
|
||||||
|
selected_idx: int | None = None
|
||||||
|
self.clear()
|
||||||
|
self.addItem("Default", None)
|
||||||
|
for idx, livery in enumerate(
|
||||||
|
squadron.aircraft.dcs_unit_type.iter_liveries_for_country(squadron.country)
|
||||||
|
):
|
||||||
|
self.addItem(livery.name, livery)
|
||||||
|
if squadron.livery == livery.id:
|
||||||
|
selected_idx = idx
|
||||||
|
if selected_idx is not None:
|
||||||
|
self.setCurrentIndex(selected_idx)
|
||||||
|
self.update()
|
||||||
@ -39,6 +39,7 @@ from game.squadrons import AirWing, Pilot, Squadron
|
|||||||
from game.squadrons.squadrondef import SquadronDef
|
from game.squadrons.squadrondef import SquadronDef
|
||||||
from game.theater import ControlPoint
|
from game.theater import ControlPoint
|
||||||
from qt_ui.uiconstants import AIRCRAFT_ICONS, ICONS
|
from qt_ui.uiconstants import AIRCRAFT_ICONS, ICONS
|
||||||
|
from qt_ui.widgets.combos.liveryselector import LiverySelector
|
||||||
from qt_ui.widgets.combos.primarytaskselector import PrimaryTaskSelector
|
from qt_ui.widgets.combos.primarytaskselector import PrimaryTaskSelector
|
||||||
|
|
||||||
|
|
||||||
@ -188,6 +189,10 @@ class SquadronConfigurationBox(QGroupBox):
|
|||||||
reroll_nickname_button.clicked.connect(self.reroll_nickname)
|
reroll_nickname_button.clicked.connect(self.reroll_nickname)
|
||||||
nickname_edit_layout.addWidget(reroll_nickname_button, 1, 1, Qt.AlignTop)
|
nickname_edit_layout.addWidget(reroll_nickname_button, 1, 1, Qt.AlignTop)
|
||||||
|
|
||||||
|
left_column.addWidget(QLabel("Livery:"))
|
||||||
|
self.livery_selector = LiverySelector(self.squadron)
|
||||||
|
left_column.addWidget(self.livery_selector)
|
||||||
|
|
||||||
task_and_size_row = QHBoxLayout()
|
task_and_size_row = QHBoxLayout()
|
||||||
left_column.addLayout(task_and_size_row)
|
left_column.addLayout(task_and_size_row)
|
||||||
|
|
||||||
@ -254,6 +259,7 @@ class SquadronConfigurationBox(QGroupBox):
|
|||||||
try:
|
try:
|
||||||
self.name_edit.setText(self.squadron.name)
|
self.name_edit.setText(self.squadron.name)
|
||||||
self.nickname_edit.setText(self.squadron.nickname)
|
self.nickname_edit.setText(self.squadron.nickname)
|
||||||
|
self.livery_selector.set_squadron(self.squadron)
|
||||||
self.primary_task_selector.setCurrentText(self.squadron.primary_task.value)
|
self.primary_task_selector.setCurrentText(self.squadron.primary_task.value)
|
||||||
self.max_size_selector.setValue(self.squadron.max_size)
|
self.max_size_selector.setValue(self.squadron.max_size)
|
||||||
self.base_selector.setCurrentText(self.squadron.location.name)
|
self.base_selector.setCurrentText(self.squadron.location.name)
|
||||||
@ -327,6 +333,8 @@ class SquadronConfigurationBox(QGroupBox):
|
|||||||
def apply(self) -> Squadron:
|
def apply(self) -> Squadron:
|
||||||
self.squadron.name = self.name_edit.text()
|
self.squadron.name = self.name_edit.text()
|
||||||
self.squadron.nickname = self.nickname_edit.text()
|
self.squadron.nickname = self.nickname_edit.text()
|
||||||
|
if (livery := self.livery_selector.selected_livery) is not None:
|
||||||
|
self.squadron.livery = livery.id
|
||||||
self.squadron.max_size = self.max_size_selector.value()
|
self.squadron.max_size = self.max_size_selector.value()
|
||||||
if (primary_task := self.primary_task_selector.selected_task) is not None:
|
if (primary_task := self.primary_task_selector.selected_task) is not None:
|
||||||
self.squadron.primary_task = primary_task
|
self.squadron.primary_task = primary_task
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user