MOHAWK: MYST: Use the shared save/load dialog code

This commit is contained in:
Bastien Bouclet 2020-04-16 07:14:37 +02:00
parent 17e5b91410
commit 8ad496fe52
3 changed files with 5 additions and 37 deletions

View File

@ -752,12 +752,12 @@ void MohawkEngine_Myst::doAction(MystEventAction action) {
break;
case kMystActionLoadGameState:
if (canLoadGameStateCurrently()) {
runLoadDialog();
loadGameDialog();
}
break;
case kMystActionSaveGameState:
if (canSaveGameStateCurrently()) {
runSaveDialog();
saveGameDialog();
}
break;
case kMystActionDropPage:
@ -1065,7 +1065,7 @@ bool MohawkEngine_Myst::isInteractive() const {
}
bool MohawkEngine_Myst::canLoadGameStateCurrently() {
bool isInMenu = (_stack->getStackId() == kMenuStack) && _prevStack;
bool isInMenu = _stack->getStackId() == kMenuStack;
if (!isInMenu) {
if (!isInteractive()) {
@ -1106,36 +1106,6 @@ bool MohawkEngine_Myst::canSaveGameStateCurrently() {
}
}
void MohawkEngine_Myst::runLoadDialog() {
GUI::SaveLoadChooser slc(_("Load game:"), _("Load"), false);
pauseEngine(true);
int slot = slc.runModalWithCurrentTarget();
pauseEngine(false);
if (slot >= 0) {
loadGameState(slot);
}
}
void MohawkEngine_Myst::runSaveDialog() {
GUI::SaveLoadChooser slc(_("Save game:"), _("Save"), true);
pauseEngine(true);
int slot = slc.runModalWithCurrentTarget();
pauseEngine(false);
if (slot >= 0) {
Common::String result(slc.getResultString());
if (result.empty()) {
// If the user was lazy and entered no save name, come up with a default name.
result = slc.createDefaultSaveDescription(slot);
}
saveGameState(slot, result);
}
}
void MohawkEngine_Myst::dropPage() {
HeldPage page = _gameState->_globals.heldPage;
bool whitePage = page == kWhitePage;

View File

@ -203,8 +203,6 @@ public:
void resumeFromMainMenu();
void runLoadDialog();
void runSaveDialog();
void runOptionsDialog();
void runCredits();

View File

@ -285,7 +285,7 @@ void Menu::o_menuLoad(uint16 var, const ArgumentsArray &args) {
return;
}
_vm->runLoadDialog();
_vm->loadGameDialog();
}
void Menu::o_menuSave(uint16 var, const ArgumentsArray &args) {
@ -293,7 +293,7 @@ void Menu::o_menuSave(uint16 var, const ArgumentsArray &args) {
return;
}
_vm->runSaveDialog();
_vm->saveGameDialog();
}
void Menu::o_menuNew(uint16 var, const ArgumentsArray &args) {