Add warnings for invalid fast-forward settings.

Fixes https://github.com/dcs-liberation/dcs_liberation/issues/2739.
This commit is contained in:
Dan Albert 2023-07-13 20:54:26 -07:00
parent 2a29dd4886
commit 5b935db923
3 changed files with 55 additions and 4 deletions

View File

@ -6,6 +6,7 @@ Saves from 8.x are not compatible with 9.0.0.
* **[Flight Planning]** Improved IP selection for targets that are near the center of a threat zone.
* **[Modding]** Factions can now specify the ship type to be used for cargo shipping. The Handy Wind will be used by default, but WW2 factions can pick something more appropriate.
* **[UI]** An error will be displayed when invalid fast-forward options are selected rather than beginning a never ending simulation.
## Fixes

View File

@ -397,10 +397,12 @@ class Settings:
section=GAMEPLAY_SECTION,
default=False,
detail=(
"If enabled, aircraft entering combat during fast forward will have their "
"combat auto-resolved after a period of time. This allows the simulation "
"to advance further into the mission before requiring mission generation, "
"but simulation is currently very rudimentary so may result in huge losses."
'Requires a "Player missions interrupt fast forward" setting other than '
'"Never" If enabled, aircraft entering combat during fast forward will have'
"their combat auto-resolved after a period of time. This allows the "
"simulation to advance further into the mission before requiring mission "
"generation, but simulation is currently very rudimentary so may result in "
"huge losses."
),
)
supercarrier: bool = boolean_option(

View File

@ -1,3 +1,4 @@
import textwrap
from datetime import datetime
from typing import List, Optional, Callable
@ -246,6 +247,50 @@ class QTopPanel(QFrame):
mbox.exec_()
return True
def check_valid_autoresolve_settings(self) -> bool:
if not self.game.settings.fast_forward_to_first_contact:
return True
if not self.game.settings.auto_resolve_combat:
return True
has_clients = self.ato_has_clients()
if (
has_clients
and self.game.settings.player_mission_interrupts_sim_at is not None
):
return True
if has_clients:
message = textwrap.dedent(
"""\
You have enabled settings to fast forward and to auto-resolve combat,
but have not selected any interrupt condition. Fast forward will never
stop with your current settings. To use auto- resolve, you must choose a
"Player missions interrupt fast forward" setting other than "Never".
"""
)
else:
message = textwrap.dedent(
"""\
You have enabled settings to fast forward and to auto-resolve combat,
but have no players. Fast forward will never stop with your current
settings. Auto-resolve and fast forward cannot be used without player
flights and a "Player missions interrupt fast forward" setting other
than "Never".
"""
)
mbox = QMessageBox(
QMessageBox.Icon.Critical,
"Incompatible fast-forward settings",
message,
parent=self,
)
mbox.setEscapeButton(mbox.addButton(QMessageBox.StandardButton.Close))
mbox.exec()
return False
def launch_mission(self):
"""Finishes planning and waits for mission completion."""
if not self.ato_has_clients() and not self.confirm_no_client_launch():
@ -261,6 +306,9 @@ class QTopPanel(QFrame):
if not self.confirm_negative_start_time(negative_starts):
return
if not self.check_valid_autoresolve_settings():
return
if self.game.settings.fast_forward_to_first_contact:
with logged_duration("Simulating to first contact"):
self.sim_controller.run_to_first_contact()