From 5b935db923ee52160421ab6492a95a5b3668f092 Mon Sep 17 00:00:00 2001 From: Dan Albert Date: Thu, 13 Jul 2023 20:54:26 -0700 Subject: [PATCH] Add warnings for invalid fast-forward settings. Fixes https://github.com/dcs-liberation/dcs_liberation/issues/2739. --- changelog.md | 1 + game/settings/settings.py | 10 ++++---- qt_ui/widgets/QTopPanel.py | 48 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 55 insertions(+), 4 deletions(-) diff --git a/changelog.md b/changelog.md index 1ae61dbe..1102557d 100644 --- a/changelog.md +++ b/changelog.md @@ -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 diff --git a/game/settings/settings.py b/game/settings/settings.py index 14d7c3a8..d2f278e1 100644 --- a/game/settings/settings.py +++ b/game/settings/settings.py @@ -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( diff --git a/qt_ui/widgets/QTopPanel.py b/qt_ui/widgets/QTopPanel.py index 595d03bc..fcd3c636 100644 --- a/qt_ui/widgets/QTopPanel.py +++ b/qt_ui/widgets/QTopPanel.py @@ -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()