From 1e1cebc3fcc2e07d3f9d147b64816442ec9aaa0a Mon Sep 17 00:00:00 2001 From: Simon Clark Date: Wed, 13 Jan 2021 12:11:53 +0000 Subject: [PATCH] Display a "No aircraft available" message. If in the create flight dialog, there are no suitable aircraft for a task, or no aircraft left at all, a suitable message is now shown that prevents the user from creating a flight. Also adds in a quick "remember what plane the user had selected last" feature. --- qt_ui/widgets/combos/QAircraftTypeSelector.py | 8 +++++++- qt_ui/windows/mission/flight/QFlightCreator.py | 2 ++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/qt_ui/widgets/combos/QAircraftTypeSelector.py b/qt_ui/widgets/combos/QAircraftTypeSelector.py index 33333b09..4093ce4b 100644 --- a/qt_ui/widgets/combos/QAircraftTypeSelector.py +++ b/qt_ui/widgets/combos/QAircraftTypeSelector.py @@ -23,6 +23,7 @@ class QAircraftTypeSelector(QComboBox): self.updateItems(mission_type, aircraft_types) def updateItems(self, mission_type: str, aircraft_types): + current_aircraft = self.currentData() self.clear() for aircraft in aircraft_types: if mission_type in [FlightType.BARCAP, FlightType.ESCORT, FlightType.INTERCEPTION, FlightType.SWEEP, FlightType.TARCAP]: @@ -42,4 +43,9 @@ class QAircraftTypeSelector(QComboBox): 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) \ No newline at end of file + self.addItem(f"{db.unit_pretty_name(self.country, aircraft)}", userData=aircraft) + current_aircraft_index = self.findData(current_aircraft) + if current_aircraft_index != -1: + self.setCurrentIndex(current_aircraft_index) + if self.count() == 0: + self.addItem("No capable aircraft available", userData=None) \ No newline at end of file diff --git a/qt_ui/windows/mission/flight/QFlightCreator.py b/qt_ui/windows/mission/flight/QFlightCreator.py index 11440c7a..629dfad7 100644 --- a/qt_ui/windows/mission/flight/QFlightCreator.py +++ b/qt_ui/windows/mission/flight/QFlightCreator.py @@ -117,6 +117,8 @@ class QFlightCreator(QDialog): arrival: ControlPoint = self.arrival.currentData() divert: ControlPoint = self.divert.currentData() size: int = self.flight_size_spinner.value() + if aircraft == None: + return "You must select an aircraft type." if not origin.captured: return f"{origin.name} is not owned by your coalition." if arrival is not None and not arrival.captured: