[Scummvm-git-logs] scummvm master -> 479c2ba1f37b4ea59585182f2fcc91c197ea80a4

bluegr noreply at scummvm.org
Wed Dec 29 20:28:37 UTC 2021


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
479c2ba1f3 BURIED: Proper handling of engine pausing - bug #12886


Commit: 479c2ba1f37b4ea59585182f2fcc91c197ea80a4
    https://github.com/scummvm/scummvm/commit/479c2ba1f37b4ea59585182f2fcc91c197ea80a4
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2021-12-29T22:28:17+02:00

Commit Message:
BURIED: Proper handling of engine pausing - bug #12886

The game is now paused while the interface menu, the save dialog and the
restore dialog is shown. The interface menu always pauses the game when
shown, regardless of the pause option. Hotkeys for saving, loading and
pausing the game are disabled while these dialogs are open.

Changed paths:
    engines/buried/biochip_right.cpp
    engines/buried/biochip_right.h
    engines/buried/biochip_view.cpp
    engines/buried/buried.cpp
    engines/buried/buried.h
    engines/buried/gameui.cpp


diff --git a/engines/buried/biochip_right.cpp b/engines/buried/biochip_right.cpp
index c6c42dbf3f5..4057bd608fe 100644
--- a/engines/buried/biochip_right.cpp
+++ b/engines/buried/biochip_right.cpp
@@ -82,6 +82,9 @@ bool BioChipRightWindow::showBioChipMainView() {
 	if (_bioChipViewWindow)
 		return false;
 
+	if (_curBioChip == kItemBioChipInterface)
+		_vm->pauseEngineIntern(true);
+
 	((GameUIWindow *)_parent)->_sceneViewWindow->bioChipWindowDisplayed(true);
 	_vm->_sound->timerCallback();
 
@@ -100,6 +103,9 @@ bool BioChipRightWindow::destroyBioChipViewWindow() {
 	if (!_bioChipViewWindow)
 		return false;
 
+	if (_curBioChip == kItemBioChipInterface)
+		_vm->pauseEngineIntern(false);
+
 	_vm->_sound->timerCallback();
 	delete _bioChipViewWindow;
 	_bioChipViewWindow = nullptr;
@@ -235,6 +241,10 @@ void BioChipRightWindow::toggleBioChip() {
 	}
 }
 
+int BioChipRightWindow::getCurrentBioChip() const {
+	return _bioChipViewWindow ? _curBioChip : -1;
+}
+
 void BioChipRightWindow::onEnable(bool enable) {
 	if (enable)
 		_vm->removeMouseMessages(this);
diff --git a/engines/buried/biochip_right.h b/engines/buried/biochip_right.h
index 70e05a8597c..2d7bdb99a23 100644
--- a/engines/buried/biochip_right.h
+++ b/engines/buried/biochip_right.h
@@ -57,6 +57,7 @@ public:
 	void jumpInitiated(bool redraw);
 	void jumpEnded(bool redraw);
 	void toggleBioChip();
+	int getCurrentBioChip() const;
 
 	void onPaint();
 	void onEnable(bool enable);
diff --git a/engines/buried/biochip_view.cpp b/engines/buried/biochip_view.cpp
index f10050588a5..40fd303e9f1 100644
--- a/engines/buried/biochip_view.cpp
+++ b/engines/buried/biochip_view.cpp
@@ -43,7 +43,6 @@
 namespace Buried {
 
 BioChipMainViewWindow::BioChipMainViewWindow(BuriedEngine *vm, Window *parent, int currentBioChipID) : Window(vm, parent) {
-	_currentBioChipID = -1;
 	_rect = Common::Rect(0, 0, 432, 189);
 	_bioChipDisplayWindow = createBioChipSpecificViewWindow(currentBioChipID);
 	_currentBioChipID = currentBioChipID;
@@ -588,25 +587,10 @@ void InterfaceBioChipViewWindow::onLButtonDown(const Common::Point &point, uint
 void InterfaceBioChipViewWindow::onLButtonUp(const Common::Point &point, uint flags) {
 	switch (_curRegion) {
 	case REGION_SAVE:
-		if (!_vm->isDemo()) {
-			_vm->runSaveDialog();
-			((GameUIWindow *)getParent()->getParent()->getParent())->_bioChipRightWindow->destroyBioChipViewWindow();
-		}
+		_vm->handleSaveDialog();
 		break;
 	case REGION_RESTORE:
-		if (!_vm->isDemo()) {
-			FrameWindow *frameWindow = (FrameWindow *)_vm->_mainWindow;
-			Common::Error result = _vm->runLoadDialog();
-
-			if (result.getCode() == Common::kUnknownError) {
-				// Try to get us back to the main menu at this point
-				frameWindow->showMainMenu();
-				return;
-			} else if (result.getCode() == Common::kNoError) {
-				// Loaded successfully
-				return;
-			}
-		}
+		_vm->handleRestoreDialog();
 		break;
 	case REGION_QUIT:
 		if (_vm->runQuitDialog()) {
diff --git a/engines/buried/buried.cpp b/engines/buried/buried.cpp
index c3e7dee9c1f..069e1a9baa0 100644
--- a/engines/buried/buried.cpp
+++ b/engines/buried/buried.cpp
@@ -37,6 +37,7 @@
 #include "graphics/wincursor.h"
 #include "gui/message.h"
 
+#include "buried/biochip_right.h"
 #include "buried/buried.h"
 #include "buried/console.h"
 #include "buried/frame_window.h"
@@ -582,19 +583,51 @@ bool BuriedEngine::isControlDown() const {
 }
 
 void BuriedEngine::pauseGame() {
-	FrameWindow *frameWindow = (FrameWindow *)_mainWindow;
-	SceneViewWindow *sceneView = ((GameUIWindow *)frameWindow->getMainChildWindow())->_sceneViewWindow;
-
 	if (isDemo())
 		return;
 
-	sceneView->_paused = true;
+	pauseEngineIntern(true);
 
 	// TODO: Would be nice to load the translated text from IDS_APP_MESSAGE_PAUSED_TEXT (9023)
 	GUI::MessageDialog dialog(_("Your game is now Paused.  Click OK to continue."));
 	dialog.runModal();
 
-	sceneView->_paused = false;
+	pauseEngineIntern(false);
+}
+
+void BuriedEngine::handleSaveDialog() {
+	FrameWindow *frameWindow = (FrameWindow *)_mainWindow;
+	BioChipRightWindow *bioChipWindow = ((GameUIWindow *)frameWindow->getMainChildWindow())->_bioChipRightWindow;
+
+	if (isDemo())
+		return;
+
+	pauseEngineIntern(true);
+
+	runSaveDialog();
+	bioChipWindow->destroyBioChipViewWindow();
+
+	pauseEngineIntern(false);
+}
+
+void BuriedEngine::handleRestoreDialog() {
+	FrameWindow *frameWindow = (FrameWindow *)_mainWindow;
+	BioChipRightWindow *bioChipWindow = ((GameUIWindow *)frameWindow->getMainChildWindow())->_bioChipRightWindow;
+
+	if (isDemo())
+		return;
+
+	pauseEngineIntern(true);
+
+	Common::Error result = runLoadDialog();
+	bioChipWindow->destroyBioChipViewWindow();
+
+	pauseEngineIntern(false);
+
+	if (result.getCode() == Common::kUnknownError) {
+		// Try to get us back to the main menu at this point
+		frameWindow->showMainMenu();
+	}
 }
 
 } // End of namespace Buried
diff --git a/engines/buried/buried.h b/engines/buried/buried.h
index f4f8b1dceab..fd4eb445ba6 100644
--- a/engines/buried/buried.h
+++ b/engines/buried/buried.h
@@ -150,6 +150,8 @@ public:
 	bool saveState(Common::WriteStream *saveFile, Location &location, GlobalFlags &flags, Common::Array<int> &inventoryItems);
 	Common::Error runSaveDialog();
 	Common::Error runLoadDialog();
+	void handleSaveDialog();
+	void handleRestoreDialog();
 
 private:
 	Common::WinResources *_mainEXE, *_library;
diff --git a/engines/buried/gameui.cpp b/engines/buried/gameui.cpp
index 7166875d1e5..359493d5c86 100644
--- a/engines/buried/gameui.cpp
+++ b/engines/buried/gameui.cpp
@@ -292,6 +292,9 @@ void GameUIWindow::onEnable(bool enable) {
 }
 
 void GameUIWindow::onKeyUp(const Common::KeyState &key, uint flags) {
+	const bool cloakingDisabled = _sceneViewWindow->getGlobalFlags().bcCloakingEnabled != 1;
+	const bool interfaceMenuActive = (_bioChipRightWindow->getCurrentBioChip() == kItemBioChipInterface);
+
 	switch (key.keycode) {
 	case Common::KEYCODE_KP4:
 	case Common::KEYCODE_LEFT:
@@ -306,25 +309,20 @@ void GameUIWindow::onKeyUp(const Common::KeyState &key, uint flags) {
 			_navArrowWindow->sendMessage(new KeyUpMessage(key, flags));
 		break;
 	case Common::KEYCODE_s:
-		if ((key.flags & Common::KBD_CTRL) && _sceneViewWindow->getGlobalFlags().bcCloakingEnabled != 1) {
-			_vm->runSaveDialog();
+		if ((key.flags & Common::KBD_CTRL) && cloakingDisabled && !interfaceMenuActive) {
+			_vm->handleSaveDialog();
 		} else if (_sceneViewWindow)
 			_sceneViewWindow->sendMessage(new KeyUpMessage(key, flags));
 		break;
 	case Common::KEYCODE_o:
 	case Common::KEYCODE_l:
-		if ((key.flags & Common::KBD_CTRL) && _sceneViewWindow->getGlobalFlags().bcCloakingEnabled != 1) {
-			_bioChipRightWindow->changeCurrentBioChip(kItemBioChipInterface);
-			_bioChipRightWindow->invalidateWindow(false);
-			_bioChipRightWindow->sendMessage(new LButtonUpMessage(Common::Point(50, 130), 0));
-
-			if (_vm->runLoadDialog().getCode() == Common::kUnknownError)
-				((FrameWindow *)_vm->_mainWindow)->showMainMenu();
+		if ((key.flags & Common::KBD_CTRL) && cloakingDisabled && !interfaceMenuActive) {
+			_vm->handleRestoreDialog();
 		} else if (_sceneViewWindow)
 			_sceneViewWindow->sendMessage(new KeyUpMessage(key, flags));
 		break;
 	case Common::KEYCODE_p:
-		if ((key.flags & Common::KBD_CTRL) && _sceneViewWindow->getGlobalFlags().bcCloakingEnabled != 1)
+		if ((key.flags & Common::KBD_CTRL) && cloakingDisabled && !interfaceMenuActive)
 			_vm->pauseGame();
 		else if (_sceneViewWindow)
 			_sceneViewWindow->sendMessage(new KeyUpMessage(key, flags));




More information about the Scummvm-git-logs mailing list