mirror of
https://github.com/dcs-liberation/dcs_liberation.git
synced 2025-11-10 14:22:26 +00:00
This reverts commit bd2ec12e0f039c9500ea0dd94e7b2e4f7d168fef. Country is both the data (name, ID, etc) and the container for groups added to the miz, so it can't be used across multiple mission generations. See https://github.com/pydcs/dcs/issues/314 for potential follow up work that would let us do this. Fixes https://github.com/dcs-liberation/dcs_liberation/issues/2864.
35 lines
1.1 KiB
Python
35 lines
1.1 KiB
Python
from __future__ import annotations
|
|
|
|
import dcs.countries
|
|
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(
|
|
dcs.countries.get_by_name(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()
|