mirror of
https://github.com/dcs-retribution/dcs-retribution.git
synced 2025-11-10 15:41:24 +00:00
Breaks save compat because it adds new fields to `Flight` that have no constant default. Removing all of our other save compat at the same time. Note that player flights with a divert point will have a nav point for their actual landing point. This is because we place the divert point last, and DCS won't let us have a land point anywhere but the final waypoint. It would allow a LandingReFuAr point, but they're only generated for player flights anyway so it doesn't really matter. Fixes https://github.com/Khopa/dcs_liberation/issues/342
48 lines
1.6 KiB
Python
48 lines
1.6 KiB
Python
"""Combo box for selecting a departure airfield."""
|
|
from typing import Iterable
|
|
|
|
from PySide2.QtWidgets import QComboBox
|
|
from dcs.planes import PlaneType
|
|
|
|
from game import db
|
|
from game.theater.controlpoint import ControlPoint
|
|
|
|
|
|
class QArrivalAirfieldSelector(QComboBox):
|
|
"""A combo box for selecting a flight's arrival or divert airfield.
|
|
|
|
The combo box will automatically be populated with all airfields the given
|
|
aircraft type is able to land at.
|
|
"""
|
|
|
|
def __init__(self, destinations: Iterable[ControlPoint],
|
|
aircraft: PlaneType, optional_text: str) -> None:
|
|
super().__init__()
|
|
self.destinations = list(destinations)
|
|
self.aircraft = aircraft
|
|
self.optional_text = optional_text
|
|
self.rebuild_selector()
|
|
self.setCurrentIndex(0)
|
|
|
|
def change_aircraft(self, aircraft: PlaneType) -> None:
|
|
if self.aircraft == aircraft:
|
|
return
|
|
self.aircraft = aircraft
|
|
self.rebuild_selector()
|
|
|
|
def valid_destination(self, destination: ControlPoint) -> bool:
|
|
if destination.is_carrier and self.aircraft not in db.CARRIER_CAPABLE:
|
|
return False
|
|
if destination.is_lha and self.aircraft not in db.LHA_CAPABLE:
|
|
return False
|
|
return True
|
|
|
|
def rebuild_selector(self) -> None:
|
|
self.clear()
|
|
for destination in self.destinations:
|
|
if self.valid_destination(destination):
|
|
self.addItem(destination.name, destination)
|
|
self.model().sort(0)
|
|
self.insertItem(0, self.optional_text, None)
|
|
self.update()
|