WAGE: Make menu items show Save/Load dialog

Default ScummVM Save/Load dialog shows up on click.
This commit is contained in:
Alexander Tkachev 2016-07-29 17:48:23 +06:00
parent b9198d37f7
commit f50d9feee1
5 changed files with 55 additions and 10 deletions

View File

@ -142,11 +142,11 @@ void WageMetaEngine::removeSaveState(const char *target, int slot) const {
namespace Wage {
bool WageEngine::canLoadGameStateCurrently() {
return false;
return true;
}
bool WageEngine::canSaveGameStateCurrently() {
return false;
return true;
}
} // End of namespace Wage

View File

@ -65,9 +65,9 @@ static const MenuData menuSubItems[] = {
{ kMenuHighLevel, "File", 0, 0, false },
{ kMenuHighLevel, "Edit", 0, 0, false },
{ kMenuFile, "New", kMenuActionNew, 0, false },
{ kMenuFile, "Open...", kMenuActionOpen, 0, false },
{ kMenuFile, "Open...", kMenuActionOpen, 0, true },
{ kMenuFile, "Close", kMenuActionClose, 0, true },
{ kMenuFile, "Save", kMenuActionSave, 0, false },
{ kMenuFile, "Save", kMenuActionSave, 0, true },
{ kMenuFile, "Save as...", kMenuActionSaveAs, 0, true },
{ kMenuFile, "Revert", kMenuActionRevert, 0, false },
{ kMenuFile, "Quit", kMenuActionQuit, 0, true },
@ -323,12 +323,19 @@ void Gui::executeMenuCommand(int action, Common::String &text) {
switch(action) {
case kMenuActionAbout:
case kMenuActionNew:
case kMenuActionOpen:
case kMenuActionClose:
case kMenuActionSave:
case kMenuActionSaveAs:
case kMenuActionRevert:
case kMenuActionQuit:
break;
case kMenuActionOpen:
_engine->scummVMSaveLoadDialog(false);
break;
case kMenuActionSave:
case kMenuActionSaveAs:
_engine->scummVMSaveLoadDialog(true);
break;
case kMenuActionUndo:
actionUndo();

View File

@ -721,6 +721,13 @@ Common::String WageEngine::getSavegameFilename(int16 slotId) const {
return saveLoadSlot;
}
Common::Error WageEngine::loadGameState(int slot) {
if (loadGame(slot) == 0)
return Common::kNoError;
else
return Common::kUnknownError;
}
Common::Error WageEngine::saveGameState(int slot, const Common::String &description) {
Common::String saveLoadSlot = getSavegameFilename(slot);
if (saveGame(saveLoadSlot, description) == 0)
@ -729,4 +736,35 @@ Common::Error WageEngine::saveGameState(int slot, const Common::String &descript
return Common::kUnknownError;
}
bool WageEngine::scummVMSaveLoadDialog(bool isSave) {
if (!isSave) {
// do loading
GUI::SaveLoadChooser dialog = GUI::SaveLoadChooser(_("Load game:"), _("Load"), false);
int slot = dialog.runModalWithCurrentTarget();
if (slot < 0)
return true;
return loadGameState(slot).getCode() == Common::kNoError;
}
// do saving
GUI::SaveLoadChooser dialog = GUI::SaveLoadChooser(_("Save game:"), _("Save"), true);
int slot = dialog.runModalWithCurrentTarget();
Common::String desc = dialog.getResultString();
if (desc.empty()) {
// create our own description for the saved game, the user didnt enter it
desc = dialog.createDefaultSaveDescription(slot);
}
if (desc.size() > 28)
desc = Common::String(desc.c_str(), 28);
if (slot < 0)
return true;
return saveGameState(slot, desc).getCode() == Common::kNoError;
}
} // End of namespace Agi

View File

@ -253,8 +253,6 @@ bool WageEngine::saveDialog() {
void WageEngine::saveGame() {
warning("STUB: saveGame()");
Common::String fileName = getSavegameFilename(1), desc = "test save #1";
saveGame(fileName, desc);
}
void WageEngine::performInitialSetup() {

View File

@ -208,7 +208,9 @@ public:
void redrawScene();
void saveGame();
Common::Error saveGameState(int slot, const Common::String &description);
virtual Common::Error loadGameState(int slot);
virtual Common::Error saveGameState(int slot, const Common::String &description);
bool scummVMSaveLoadDialog(bool isSave);
private:
int getSceneIndex(Scene *scene) const;