mirror of
https://github.com/dcs-liberation/dcs_liberation.git
synced 2025-11-10 14:22:26 +00:00
Filter mission types by aircraft.
First stab at implementing #392. You can now only select aircraft types that can do the selected task.
This commit is contained in:
parent
9ebad734a9
commit
727ec6bc28
@ -155,6 +155,9 @@ CAP_CAPABLE = [
|
|||||||
CAS_CAPABLE = [
|
CAS_CAPABLE = [
|
||||||
A_10C_2,
|
A_10C_2,
|
||||||
A_10C,
|
A_10C,
|
||||||
|
B_1B,
|
||||||
|
F_14B,
|
||||||
|
F_14A_135_GR,
|
||||||
Su_25TM,
|
Su_25TM,
|
||||||
Su_25T,
|
Su_25T,
|
||||||
Su_25,
|
Su_25,
|
||||||
@ -234,6 +237,19 @@ SEAD_CAPABLE = [
|
|||||||
Su_30,
|
Su_30,
|
||||||
MiG_27K,
|
MiG_27K,
|
||||||
Tornado_GR4,
|
Tornado_GR4,
|
||||||
|
F_117A,
|
||||||
|
B_17G,
|
||||||
|
A_20G,
|
||||||
|
P_47D_40,
|
||||||
|
P_47D_30bl1,
|
||||||
|
P_47D_30,
|
||||||
|
P_51D_30_NA,
|
||||||
|
P_51D,
|
||||||
|
SpitfireLFMkIXCW,
|
||||||
|
SpitfireLFMkIX,
|
||||||
|
Bf_109K_4,
|
||||||
|
FW_190D9,
|
||||||
|
FW_190A8,
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -5,14 +5,41 @@ from PySide2.QtWidgets import QComboBox
|
|||||||
|
|
||||||
from dcs.unittype import FlyingType
|
from dcs.unittype import FlyingType
|
||||||
|
|
||||||
|
from gen.flights.flight import FlightType
|
||||||
|
|
||||||
|
import gen.flights.ai_flight_planner_db
|
||||||
|
|
||||||
from game import Game, db
|
from game import Game, db
|
||||||
|
|
||||||
class QAircraftTypeSelector(QComboBox):
|
class QAircraftTypeSelector(QComboBox):
|
||||||
"""Combo box for selecting among the given aircraft types."""
|
"""Combo box for selecting among the given aircraft types."""
|
||||||
|
|
||||||
def __init__(self, aircraft_types: Iterable[Type[FlyingType]], country: str) -> None:
|
def __init__(self, aircraft_types: Iterable[Type[FlyingType]], country: str, mission_type: str) -> None:
|
||||||
super().__init__()
|
super().__init__()
|
||||||
for aircraft in aircraft_types:
|
|
||||||
self.addItem(f"{db.unit_pretty_name(country, aircraft)}", userData=aircraft)
|
|
||||||
self.model().sort(0)
|
self.model().sort(0)
|
||||||
self.setSizeAdjustPolicy(self.AdjustToContents)
|
self.setSizeAdjustPolicy(self.AdjustToContents)
|
||||||
|
self.country = country
|
||||||
|
self.updateItems(mission_type, aircraft_types)
|
||||||
|
|
||||||
|
def updateItems(self, mission_type: str, aircraft_types):
|
||||||
|
self.clear()
|
||||||
|
for aircraft in aircraft_types:
|
||||||
|
if mission_type in [FlightType.BARCAP, FlightType.ESCORT, FlightType.INTERCEPTION, FlightType.SWEEP, FlightType.TARCAP]:
|
||||||
|
if aircraft in gen.flights.ai_flight_planner_db.CAP_CAPABLE:
|
||||||
|
self.addItem(f"{db.unit_pretty_name(self.country, aircraft)}", userData=aircraft)
|
||||||
|
elif mission_type in [FlightType.CAS, FlightType.BAI, FlightType.OCA_AIRCRAFT]:
|
||||||
|
if aircraft in gen.flights.ai_flight_planner_db.CAS_CAPABLE:
|
||||||
|
self.addItem(f"{db.unit_pretty_name(self.country, aircraft)}", userData=aircraft)
|
||||||
|
elif mission_type in [FlightType.SEAD]:
|
||||||
|
if aircraft in gen.flights.ai_flight_planner_db.SEAD_CAPABLE:
|
||||||
|
self.addItem(f"{db.unit_pretty_name(self.country, aircraft)}", userData=aircraft)
|
||||||
|
elif mission_type in [FlightType.STRIKE]:
|
||||||
|
if aircraft in gen.flights.ai_flight_planner_db.STRIKE_CAPABLE:
|
||||||
|
self.addItem(f"{db.unit_pretty_name(self.country, aircraft)}", userData=aircraft)
|
||||||
|
elif mission_type in [FlightType.ANTISHIP]:
|
||||||
|
if aircraft in gen.flights.ai_flight_planner_db.ANTISHIP_CAPABLE:
|
||||||
|
self.addItem(f"{db.unit_pretty_name(self.country, aircraft)}", userData=aircraft)
|
||||||
|
elif mission_type in [FlightType.OCA_RUNWAY]:
|
||||||
|
if aircraft in gen.flights.ai_flight_planner_db.RUNWAY_ATTACK_CAPABLE:
|
||||||
|
self.addItem(f"{db.unit_pretty_name(self.country, aircraft)}", userData=aircraft)
|
||||||
@ -45,10 +45,12 @@ class QFlightCreator(QDialog):
|
|||||||
self.game.theater, package.target
|
self.game.theater, package.target
|
||||||
)
|
)
|
||||||
self.task_selector.setCurrentIndex(0)
|
self.task_selector.setCurrentIndex(0)
|
||||||
|
self.task_selector.currentTextChanged.connect(
|
||||||
|
self.on_task_changed)
|
||||||
layout.addLayout(QLabeledWidget("Task:", self.task_selector))
|
layout.addLayout(QLabeledWidget("Task:", self.task_selector))
|
||||||
|
|
||||||
self.aircraft_selector = QAircraftTypeSelector(
|
self.aircraft_selector = QAircraftTypeSelector(
|
||||||
self.game.aircraft_inventory.available_types_for_player, self.game.player_country
|
self.game.aircraft_inventory.available_types_for_player, self.game.player_country, self.task_selector.currentData()
|
||||||
)
|
)
|
||||||
self.aircraft_selector.setCurrentIndex(0)
|
self.aircraft_selector.setCurrentIndex(0)
|
||||||
self.aircraft_selector.currentIndexChanged.connect(
|
self.aircraft_selector.currentIndexChanged.connect(
|
||||||
@ -169,6 +171,9 @@ class QFlightCreator(QDialog):
|
|||||||
self.arrival.change_aircraft(new_aircraft)
|
self.arrival.change_aircraft(new_aircraft)
|
||||||
self.divert.change_aircraft(new_aircraft)
|
self.divert.change_aircraft(new_aircraft)
|
||||||
|
|
||||||
|
def on_task_changed(self) -> None:
|
||||||
|
self.aircraft_selector.updateItems(self.task_selector.currentData(), self.game.aircraft_inventory.available_types_for_player)
|
||||||
|
|
||||||
def update_max_size(self, available: int) -> None:
|
def update_max_size(self, available: int) -> None:
|
||||||
self.flight_size_spinner.setMaximum(min(available, 4))
|
self.flight_size_spinner.setMaximum(min(available, 4))
|
||||||
if self.flight_size_spinner.maximum() >= 2:
|
if self.flight_size_spinner.maximum() >= 2:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user