Simplfy fast forward settings, introduce ability to skip combat instead of resolving. (#3448)

This PR simplifies fast forward settings and introduces the ability to
skip combat instead of resolving.
This commit is contained in:
zhexu14
2024-10-15 20:10:53 +11:00
committed by GitHub
parent 5d0ddea753
commit df43d2eed6
12 changed files with 108 additions and 92 deletions

View File

@@ -16,6 +16,7 @@ from game import Game, persistence
from game.ato.package import Package
from game.ato.traveltime import TotEstimator
from game.profiling import logged_duration
from game.settings.settings import FastForwardStopCondition
from game.utils import meters
from qt_ui.models import GameModel
from qt_ui.simcontroller import SimController
@@ -248,50 +249,6 @@ 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():
@@ -307,10 +264,10 @@ 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:
if self.game.settings.fast_forward_stop_condition not in [
FastForwardStopCondition.DISABLED,
FastForwardStopCondition.MANUAL,
]:
with logged_duration("Simulating to first contact"):
self.sim_controller.run_to_first_contact()
self.sim_controller.generate_miz(