[Scummvm-git-logs] scummvm master -> b8094a39087abe23d53446a8eaac0832918d9411
bluegr
noreply at scummvm.org
Wed Dec 29 22:24:55 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:
b8094a3908 BURIED: Cleanup of the saving/loading dialog code
Commit: b8094a39087abe23d53446a8eaac0832918d9411
https://github.com/scummvm/scummvm/commit/b8094a39087abe23d53446a8eaac0832918d9411
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2021-12-30T00:24:35+02:00
Commit Message:
BURIED: Cleanup of the saving/loading dialog code
Changed paths:
engines/buried/buried.cpp
engines/buried/buried.h
engines/buried/death.cpp
engines/buried/main_menu.cpp
engines/buried/saveload.cpp
diff --git a/engines/buried/buried.cpp b/engines/buried/buried.cpp
index 675b5cd5271..f4411088d8d 100644
--- a/engines/buried/buried.cpp
+++ b/engines/buried/buried.cpp
@@ -598,9 +598,8 @@ void BuriedEngine::handleSaveDialog() {
if (isDemo())
return;
- PauseToken pt = pauseEngine();
- runSaveDialog();
- bioChipWindow->destroyBioChipViewWindow();
+ if (saveGameDialog())
+ bioChipWindow->destroyBioChipViewWindow();
}
void BuriedEngine::handleRestoreDialog() {
@@ -610,14 +609,8 @@ void BuriedEngine::handleRestoreDialog() {
if (isDemo())
return;
- PauseToken pt = pauseEngine();
- Common::Error result = runLoadDialog();
- bioChipWindow->destroyBioChipViewWindow();
-
- if (result.getCode() == Common::kUnknownError) {
- // Try to get us back to the main menu at this point
- frameWindow->showMainMenu();
- }
+ if (loadGameDialog())
+ bioChipWindow->destroyBioChipViewWindow();
}
} // End of namespace Buried
diff --git a/engines/buried/buried.h b/engines/buried/buried.h
index fd4eb445ba6..7216c79fb26 100644
--- a/engines/buried/buried.h
+++ b/engines/buried/buried.h
@@ -148,8 +148,6 @@ public:
static Common::StringArray listSaveFiles();
bool loadState(Common::SeekableReadStream *saveFile, Location &location, GlobalFlags &flags, Common::Array<int> &inventoryItems);
bool saveState(Common::WriteStream *saveFile, Location &location, GlobalFlags &flags, Common::Array<int> &inventoryItems);
- Common::Error runSaveDialog();
- Common::Error runLoadDialog();
void handleSaveDialog();
void handleRestoreDialog();
diff --git a/engines/buried/death.cpp b/engines/buried/death.cpp
index 5ab7366ac84..75bf25ce4d6 100644
--- a/engines/buried/death.cpp
+++ b/engines/buried/death.cpp
@@ -444,18 +444,8 @@ void DeathWindow::onLButtonUp(const Common::Point &point, uint flags) {
return;
}
} else {
- // Show restore game window
- FrameWindow *frameWindow = (FrameWindow *)_parent;
- 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
+ if (_vm->loadGameDialog())
return;
- }
}
}
break;
diff --git a/engines/buried/main_menu.cpp b/engines/buried/main_menu.cpp
index a514332b2dd..0d3f7dfa1a5 100644
--- a/engines/buried/main_menu.cpp
+++ b/engines/buried/main_menu.cpp
@@ -229,21 +229,9 @@ void MainMenuWindow::onLButtonUp(const Common::Point &point, uint flags) {
((FrameWindow *)_parent)->startNewGame(_walkthrough, _showIntro);
}
return;
- case BUTTON_RESTORE_GAME: {
- FrameWindow *frameWindow = (FrameWindow *)_parent;
- 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;
- }
-
- break;
- }
+ case BUTTON_RESTORE_GAME:
+ _vm->loadGameDialog();
+ return;
case BUTTON_CREDITS:
((FrameWindow *)_parent)->showCredits();
return;
diff --git a/engines/buried/saveload.cpp b/engines/buried/saveload.cpp
index e99e845e9b1..41fd3249544 100644
--- a/engines/buried/saveload.cpp
+++ b/engines/buried/saveload.cpp
@@ -510,42 +510,4 @@ bool BuriedEngine::syncGlobalFlags(Common::Serializer &s, GlobalFlags &flags) {
return s.bytesSynced() - startBytes == 1024;
}
-Common::Error BuriedEngine::runLoadDialog() {
- GUI::SaveLoadChooser slc(_("Load game:"), _("Load"), false);
-
- int slot = slc.runModalWithCurrentTarget();
-
- Common::Error result;
-
- if (slot >= 0) {
- if (loadGameState(slot).getCode() == Common::kNoError)
- result = Common::kNoError;
- else
- result = Common::kUnknownError;
- } else {
- result = Common::kUserCanceled;
- }
-
- return result;
-}
-
-Common::Error BuriedEngine::runSaveDialog() {
- GUI::SaveLoadChooser slc(_("Save game:"), _("Save"), true);
-
- int slot = slc.runModalWithCurrentTarget();
-
- Common::Error result;
-
- if (slot >= 0) {
- if (saveGameState(slot, slc.getResultString(), false).getCode() == Common::kNoError)
- result = Common::kNoError;
- else
- result = Common::kUnknownError;
- } else {
- result = Common::kUserCanceled;
- }
-
- return result;
-}
-
} // End of namespace Buried
More information about the Scummvm-git-logs
mailing list