mirror of
https://github.com/dcs-retribution/dcs-retribution.git
synced 2025-11-10 15:41:24 +00:00
Allow custom mission types
Instead of giving an error when a mission type which was added to the squadron is not defined in the Ai autoplanner db for the aircraft the user should be able to task the aircraft accordingly.
This commit is contained in:
@@ -1,31 +1,24 @@
|
||||
"""Combo box for selecting aircraft types."""
|
||||
from typing import Iterable, Type
|
||||
|
||||
from typing import Iterable
|
||||
from PySide2.QtWidgets import QComboBox
|
||||
from dcs.unittype import FlyingType
|
||||
|
||||
from game.ato.ai_flight_planner_db import aircraft_for_task
|
||||
from game.ato.flighttype import FlightType
|
||||
from game.dcs.aircrafttype import AircraftType
|
||||
|
||||
|
||||
class QAircraftTypeSelector(QComboBox):
|
||||
"""Combo box for selecting among the given aircraft types."""
|
||||
|
||||
def __init__(
|
||||
self, aircraft_types: Iterable[Type[FlyingType]], mission_type: FlightType
|
||||
) -> None:
|
||||
def __init__(self, aircraft_types: Iterable[AircraftType]) -> None:
|
||||
super().__init__()
|
||||
|
||||
self.model().sort(0)
|
||||
self.setSizeAdjustPolicy(self.AdjustToContents)
|
||||
self.update_items(mission_type, aircraft_types)
|
||||
self.update_items(aircraft_types)
|
||||
|
||||
def update_items(self, mission_type: FlightType, aircraft_types):
|
||||
def update_items(self, aircraft_types: Iterable[AircraftType]):
|
||||
current_aircraft = self.currentData()
|
||||
self.clear()
|
||||
for aircraft in aircraft_types:
|
||||
if aircraft in aircraft_for_task(mission_type):
|
||||
self.addItem(f"{aircraft}", userData=aircraft)
|
||||
self.addItem(f"{aircraft}", userData=aircraft)
|
||||
current_aircraft_index = self.findData(current_aircraft)
|
||||
if current_aircraft_index != -1:
|
||||
self.setCurrentIndex(current_aircraft_index)
|
||||
|
||||
@@ -56,8 +56,9 @@ class QFlightCreator(QDialog):
|
||||
layout.addLayout(QLabeledWidget("Task:", self.task_selector))
|
||||
|
||||
self.aircraft_selector = QAircraftTypeSelector(
|
||||
self.game.blue.air_wing.available_aircraft_types,
|
||||
self.task_selector.currentData(),
|
||||
self.game.blue.air_wing.available_aircraft_for_task(
|
||||
self.task_selector.currentData()
|
||||
)
|
||||
)
|
||||
self.aircraft_selector.setCurrentIndex(0)
|
||||
self.aircraft_selector.currentIndexChanged.connect(self.on_aircraft_changed)
|
||||
@@ -216,7 +217,7 @@ class QFlightCreator(QDialog):
|
||||
def on_task_changed(self, index: int) -> None:
|
||||
task = self.task_selector.itemData(index)
|
||||
self.aircraft_selector.update_items(
|
||||
task, self.game.blue.air_wing.available_aircraft_types
|
||||
self.game.blue.air_wing.available_aircraft_for_task(task)
|
||||
)
|
||||
self.squadron_selector.update_items(task, self.aircraft_selector.currentData())
|
||||
|
||||
|
||||
Reference in New Issue
Block a user