From 6759346bb6a81d9dd71f75c2f96aaefd673981d0 Mon Sep 17 00:00:00 2001 From: Bastien Bouclet Date: Thu, 21 Jun 2018 21:28:22 +0200 Subject: MOHAWK: RIVEN: Show confirmation dialogs on the main menu --- engines/mohawk/riven_stacks/aspit.cpp | 25 +++++++++++++++++++++++++ engines/mohawk/riven_stacks/aspit.h | 1 + 2 files changed, 26 insertions(+) (limited to 'engines/mohawk') diff --git a/engines/mohawk/riven_stacks/aspit.cpp b/engines/mohawk/riven_stacks/aspit.cpp index eb03ac82f0..7ae1c47b24 100644 --- a/engines/mohawk/riven_stacks/aspit.cpp +++ b/engines/mohawk/riven_stacks/aspit.cpp @@ -379,6 +379,11 @@ void ASpit::xatrapbookopen(const ArgumentArray &args) { } void ASpit::xarestoregame(const ArgumentArray &args) { + if (!showConfirmationDialog(_("Are you sure you want to load a saved game? All unsaved progress will be lost."), + _("Load game"), _("Cancel"))) { + return; + } + // Launch the load game dialog _vm->runLoadDialog(); } @@ -396,6 +401,11 @@ void ASpit::xaOptions(const ArgumentArray &args) { } void ASpit::xaNewGame(const ArgumentArray &args) { + if (!showConfirmationDialog(_("Are you sure you want to start a new game? All unsaved progress will be lost."), + _("New game"), _("Cancel"))) { + return; + } + _vm->startNewGame(); RivenScriptPtr script = _vm->_scriptMan->createScriptFromData(2, @@ -410,6 +420,16 @@ void ASpit::xaNewGame(const ArgumentArray &args) { _vm->_scriptMan->runScript(script, false); } +bool ASpit::showConfirmationDialog(const char *message, const char *confirmButton, const char *cancelButton) { + if (!_vm->isGameStarted()) { + return true; + } + + GUI::MessageDialog dialog(message, confirmButton, cancelButton); + + return dialog.runModal() !=0; +} + void ASpit::xadisablemenureturn(const ArgumentArray &args) { // This function would normally enable the Windows menu item for // returning to the main menu. Ctrl+r will do this instead. @@ -465,6 +485,11 @@ void ASpit::xaenablemenuintro(const ArgumentArray &args) { } void ASpit::xademoquit(const ArgumentArray &args) { + if (!showConfirmationDialog(_("Are you sure you want to quit? All unsaved progress will be lost."), _("Quit"), + _("Cancel"))) { + return; + } + // Exactly as it says on the tin. In the demo, this function quits. _vm->setGameEnded(); } diff --git a/engines/mohawk/riven_stacks/aspit.h b/engines/mohawk/riven_stacks/aspit.h index 2a6d88f936..aa3c20f437 100644 --- a/engines/mohawk/riven_stacks/aspit.h +++ b/engines/mohawk/riven_stacks/aspit.h @@ -89,6 +89,7 @@ private: void cathBookDrawPage(uint32 page); + bool showConfirmationDialog(const char *message, const char *confirmButton, const char *cancelButton); }; } // End of namespace RivenStacks -- cgit v1.2.3