diff --git a/game/ato/starttype.py b/game/ato/starttype.py index 81171751..e42e6402 100644 --- a/game/ato/starttype.py +++ b/game/ato/starttype.py @@ -9,7 +9,7 @@ class StartType(Enum): IN_FLIGHT. """ - IN_FLIGHT = "In Flight" - RUNWAY = "Runway" COLD = "Cold" WARM = "Warm" + RUNWAY = "Runway" + IN_FLIGHT = "In Flight" diff --git a/game/commander/theatercommander.py b/game/commander/theatercommander.py index 3066ff54..a3c4a45b 100644 --- a/game/commander/theatercommander.py +++ b/game/commander/theatercommander.py @@ -56,6 +56,7 @@ from __future__ import annotations from typing import TYPE_CHECKING +from game.ato.starttype import StartType from game.commander.tasks.compound.nextaction import PlanNextAction from game.commander.tasks.theatercommandertask import TheaterCommanderTask from game.commander.theaterstate import TheaterState @@ -70,7 +71,7 @@ class TheaterCommander(Planner[TheaterState, TheaterCommanderTask]): def __init__(self, game: Game, player: bool) -> None: super().__init__( PlanNextAction( - aircraft_cold_start=game.settings.default_start_type == "Cold" + aircraft_cold_start=game.settings.default_start_type is StartType.COLD ) ) self.game = game diff --git a/qt_ui/windows/mission/flight/QFlightCreator.py b/qt_ui/windows/mission/flight/QFlightCreator.py index 3504a88a..40091fb5 100644 --- a/qt_ui/windows/mission/flight/QFlightCreator.py +++ b/qt_ui/windows/mission/flight/QFlightCreator.py @@ -14,6 +14,7 @@ from PySide2.QtWidgets import ( from dcs.unittype import FlyingType from game import Game +from game.ato.starttype import StartType from game.squadrons.squadron import Squadron from game.theater import ControlPoint, OffMapSpawn from game.ato.package import Package @@ -98,8 +99,9 @@ class QFlightCreator(QDialog): # we restore the previous choice. self.restore_start_type: Optional[str] = None self.start_type = QComboBox() - self.start_type.addItems(["Cold", "Warm", "Runway", "In Flight"]) - self.start_type.setCurrentText(self.game.settings.default_start_type) + for start_type in StartType: + self.start_type.addItem(start_type.value, start_type) + self.start_type.setCurrentText(self.game.settings.default_start_type.value) layout.addLayout( QLabeledWidget( "Start type:", @@ -178,7 +180,7 @@ class QFlightCreator(QDialog): # the roster is passed explicitly. Needs a refactor. roster.max_size, task, - self.start_type.currentText(), + self.start_type.currentData(), divert, custom_name=self.custom_name_text, roster=roster, @@ -197,10 +199,10 @@ class QFlightCreator(QDialog): def on_departure_changed(self, departure: ControlPoint) -> None: if isinstance(departure, OffMapSpawn): - previous_type = self.start_type.currentText() - if previous_type != "In Flight": + previous_type = self.start_type.currentData() + if previous_type != StartType.IN_FLIGHT: self.restore_start_type = previous_type - self.start_type.setCurrentText("In Flight") + self.start_type.setCurrentText(StartType.IN_FLIGHT.value) self.start_type.setEnabled(False) else: self.start_type.setEnabled(True) diff --git a/qt_ui/windows/mission/flight/settings/QFlightStartType.py b/qt_ui/windows/mission/flight/settings/QFlightStartType.py index ed96a6d6..59e870d2 100644 --- a/qt_ui/windows/mission/flight/settings/QFlightStartType.py +++ b/qt_ui/windows/mission/flight/settings/QFlightStartType.py @@ -7,6 +7,7 @@ from PySide2.QtWidgets import ( ) from game.ato.flight import Flight +from game.ato.starttype import StartType from qt_ui.models import PackageModel @@ -21,10 +22,9 @@ class QFlightStartType(QGroupBox): self.start_type_label = QLabel("Start type:") self.start_type = QComboBox() - for i, st in enumerate([b for b in ["Cold", "Warm", "Runway", "In Flight"]]): - self.start_type.addItem(st, st) - if flight.start_type == st: - self.start_type.setCurrentIndex(i) + for start_type in StartType: + self.start_type.addItem(start_type.value, start_type) + self.start_type.setCurrentText(flight.start_type.value) self.start_type.currentTextChanged.connect(self._on_start_type_selected) self.main_row.addWidget(self.start_type_label)