Fix incorrect start types for off-map squadrons.

This commit is contained in:
Raffson 2022-06-30 06:21:18 +02:00 committed by GitHub
parent 13546d77e7
commit cc4237d076
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 1 deletions

View File

@ -115,6 +115,11 @@ class QFlightCreator(QDialog):
tooltip="Selects the start type for this flight.", tooltip="Selects the start type for this flight.",
) )
) )
squadron: Squadron = self.squadron_selector.currentData()
home_base: ControlPoint = squadron.location
if isinstance(home_base, OffMapSpawn):
self.start_type.setCurrentText(StartType.IN_FLIGHT.value)
self.start_type.setEnabled(False)
layout.addWidget( layout.addWidget(
QLabel( QLabel(
"Any option other than Cold will make this flight " "Any option other than Cold will make this flight "
@ -213,7 +218,7 @@ class QFlightCreator(QDialog):
else: else:
self.start_type.setEnabled(True) self.start_type.setEnabled(True)
if self.restore_start_type is not None: if self.restore_start_type is not None:
self.start_type.setCurrentText(self.restore_start_type) self.start_type.setCurrentText(self.restore_start_type.value)
self.restore_start_type = None self.restore_start_type = None
def on_task_changed(self, index: int) -> None: def on_task_changed(self, index: int) -> None:

View File

@ -8,6 +8,7 @@ from PySide2.QtWidgets import (
from game.ato.flight import Flight from game.ato.flight import Flight
from game.ato.starttype import StartType from game.ato.starttype import StartType
from game.theater import OffMapSpawn
from qt_ui.models import PackageModel from qt_ui.models import PackageModel
@ -26,6 +27,9 @@ class QFlightStartType(QGroupBox):
self.start_type.addItem(start_type.value, start_type) self.start_type.addItem(start_type.value, start_type)
self.start_type.setCurrentText(flight.start_type.value) self.start_type.setCurrentText(flight.start_type.value)
if isinstance(self.flight.departure, OffMapSpawn):
self.start_type.setEnabled(False)
self.start_type.currentTextChanged.connect(self._on_start_type_selected) self.start_type.currentTextChanged.connect(self._on_start_type_selected)
self.main_row.addWidget(self.start_type_label) self.main_row.addWidget(self.start_type_label)
self.main_row.addWidget(self.start_type) self.main_row.addWidget(self.start_type)