BURIED: Cleanup of the saving/loading dialog code

This commit is contained in:
Filippos Karapetis 2021-12-30 00:24:13 +02:00
parent e22f1a6cc4
commit b8094a3908
5 changed files with 8 additions and 77 deletions

View File

@ -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

View File

@ -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();

View File

@ -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();
if (_vm->loadGameDialog())
return;
} else if (result.getCode() == Common::kNoError) {
// Loaded successfully
return;
}
}
}
break;

View File

@ -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;

View File

@ -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