mirror of
https://github.com/dcs-liberation/dcs_liberation.git
synced 2025-11-10 14:22:26 +00:00
Checkpoint game before sim, auto-revert on abort.
An alternative to https://github.com/dcs-liberation/dcs_liberation/pull/2891 that I ended up liking much better (I had assumed some part of the UI would fail or at least look terrible with this approach, but it seems to work quite well). On by default now since it's far less frightening than the previous thing. Fixes https://github.com/dcs-liberation/dcs_liberation/issues/2735.
This commit is contained in:
@@ -133,7 +133,14 @@ class QLiberationWindow(QMainWindow):
|
||||
|
||||
vbox = QVBoxLayout()
|
||||
vbox.setContentsMargins(0, 0, 0, 0)
|
||||
vbox.addWidget(QTopPanel(self.game_model, self.sim_controller, ui_flags))
|
||||
vbox.addWidget(
|
||||
QTopPanel(
|
||||
self.game_model,
|
||||
self.sim_controller,
|
||||
ui_flags,
|
||||
self.reset_to_pre_sim_checkpoint,
|
||||
)
|
||||
)
|
||||
vbox.addWidget(hbox)
|
||||
|
||||
central_widget = QWidget()
|
||||
@@ -340,6 +347,23 @@ class QLiberationWindow(QMainWindow):
|
||||
except Exception:
|
||||
logging.exception("Error loading save game %s", file[0])
|
||||
|
||||
def reset_to_pre_sim_checkpoint(self) -> None:
|
||||
"""Loads the game that was saved before pressing the take-off button.
|
||||
|
||||
A checkpoint will be saved when the player presses take-off to save their state
|
||||
before the mission simulation begins. If the mission is aborted, we usually want
|
||||
to reset to the pre-simulation state to allow players to effectively "rewind",
|
||||
since they probably aborted so that they could make changes. Implementing rewind
|
||||
for real is impractical, but checkpoints are easy.
|
||||
"""
|
||||
if self.game is None:
|
||||
raise RuntimeError(
|
||||
"Cannot reset to pre-sim checkpoint when no game is loaded"
|
||||
)
|
||||
GameUpdateSignal.get_instance().game_loaded.emit(
|
||||
self.game.save_manager.load_pre_sim_checkpoint()
|
||||
)
|
||||
|
||||
def saveGame(self):
|
||||
logging.info("Saving game")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user