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:
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()
|
||||
Reference in New Issue
Block a user