mirror of
https://github.com/dcs-retribution/dcs-retribution.git
synced 2025-11-10 15:41:24 +00:00
We're still using mostly the same aircraft selection as we have before we added squadrons: the closest aircraft is the best choice. This adds an option to obey the primary task set by the campaign designer (can be overridden by players), even if the squadron is farther away than one that is capable of it as a secondary task. I don't expect this option to live very long. I'm making it optional for now to give people a chance to test it, but it'll either replace the old selection strategy or will be removed. Fixes https://github.com/dcs-liberation/dcs_liberation/issues/1892.
40 lines
1.2 KiB
Python
40 lines
1.2 KiB
Python
from __future__ import annotations
|
|
|
|
from PySide6.QtWidgets import QComboBox
|
|
|
|
from game.ato import FlightType
|
|
from game.dcs.aircrafttype import AircraftType
|
|
from game.squadrons import Squadron
|
|
|
|
|
|
class PrimaryTaskSelector(QComboBox):
|
|
def __init__(self, aircraft: AircraftType | None) -> None:
|
|
super().__init__()
|
|
self.setSizeAdjustPolicy(QComboBox.SizeAdjustPolicy.AdjustToContents)
|
|
self.set_aircraft(aircraft)
|
|
|
|
@staticmethod
|
|
def for_squadron(squadron: Squadron) -> PrimaryTaskSelector:
|
|
selector = PrimaryTaskSelector(squadron.aircraft)
|
|
selector.setCurrentText(squadron.primary_task.value)
|
|
return selector
|
|
|
|
def set_aircraft(self, aircraft: AircraftType | None) -> None:
|
|
self.clear()
|
|
if aircraft is None:
|
|
self.addItem("Select aircraft type first", None)
|
|
self.setEnabled(False)
|
|
self.update()
|
|
return
|
|
|
|
self.setEnabled(True)
|
|
for task in aircraft.iter_task_capabilities():
|
|
self.addItem(task.value, task)
|
|
self.model().sort(0)
|
|
self.setEnabled(True)
|
|
self.update()
|
|
|
|
@property
|
|
def selected_task(self) -> FlightType | None:
|
|
return self.currentData()
|