mirror of
https://github.com/dcs-retribution/dcs-retribution.git
synced 2025-11-10 15:41:24 +00:00
Prevent saving packages with Escorts only (#509)
Fixes a bug that would later pop up when trying to calculate start-times... Co-authored-by: Raffson <Raffson@users.noreply.github.com>
This commit is contained in:
parent
0e7ea0050f
commit
7b16967641
@ -5,7 +5,7 @@
|
||||
* **[Config]** New preference setting to trigger the first-start window on every start (could help in scenarios multiple Retribution instances need to run concurrently)
|
||||
|
||||
## Fixes
|
||||
|
||||
* **[Flight Plans]** Fixed a bug when a package was created with only escort flights
|
||||
|
||||
# Retribution v1.4.0
|
||||
|
||||
|
||||
@ -177,6 +177,9 @@ class QPackageDialog(QDialog):
|
||||
)
|
||||
|
||||
def on_save(self) -> None:
|
||||
# TODO: Cache package start state and only update if valid
|
||||
if not self.package_valid():
|
||||
return
|
||||
self.save_tot()
|
||||
|
||||
def save_tot(self) -> None:
|
||||
@ -280,6 +283,29 @@ class QPackageDialog(QDialog):
|
||||
self.package_model.package.frequency = None
|
||||
self.package_freq_text.setText("AUTO")
|
||||
|
||||
def package_valid(self) -> bool:
|
||||
"""Validates the package before saving.
|
||||
|
||||
Returns:
|
||||
True if the package is valid, False otherwise.
|
||||
"""
|
||||
# Validate the package has more than just escort flights but allow empty packages
|
||||
if len(self.package_model.package.flights) == 0:
|
||||
return True
|
||||
if any(
|
||||
flight.flight_type.name not in {"ESCORT", "SEAD_ESCORT"}
|
||||
for flight in self.package_model.package.flights
|
||||
):
|
||||
return True
|
||||
else:
|
||||
QMessageBox.critical(
|
||||
self,
|
||||
"Invalid Package",
|
||||
"Package cannot contain only escort flights.",
|
||||
QMessageBox.StandardButton.Ok,
|
||||
)
|
||||
return False
|
||||
|
||||
|
||||
class QNewPackageDialog(QPackageDialog):
|
||||
"""Dialog window for creating a new package.
|
||||
@ -325,6 +351,8 @@ class QNewPackageDialog(QPackageDialog):
|
||||
Empty packages may be created. They can be modified later, and will have
|
||||
no effect if empty when the mission is generated.
|
||||
"""
|
||||
if not super().package_valid():
|
||||
return
|
||||
super().on_save()
|
||||
self.ato_model.add_package(self.package_model.package)
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user