mirror of
https://github.com/scummvm/scummvm.git
synced 2026-11-18 21:34:48 +00:00
ULTIMA6: Improved handling of autosave checks
This commit is contained in:
1 parent
d76e1bd8b6
commit
77e91e613d
7 files changed
+61
-25
No files matched your search
@@ -73,7 +73,7 @@ void UltimaEngine::GUIError(const Common::String &msg) {
|
||||
}
|
||||
|
||||
bool UltimaEngine::autoSaveCheck(int lastSaveTime) {
|
||||
if (shouldPerformAutoSave(lastSaveTime) && canSaveGameStateCurrently()) {
|
||||
if (shouldPerformAutoSave(lastSaveTime) && canSaveGameState(true)) {
|
||||
saveGameState(0, _("Autosave"));
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -121,6 +121,32 @@ public:
|
||||
* Shows the ScummVM Restore dialog, allowing users to restore a game
|
||||
*/
|
||||
virtual bool loadGame();
|
||||
|
||||
/**
|
||||
* Indicates whether a game state can be loaded.
|
||||
* @param isAutosave Flags whether it's an autosave check
|
||||
*/
|
||||
virtual bool canLoadGameState(bool isAutosave = false) = 0;
|
||||
|
||||
/**
|
||||
* Indicates whether a game state can be loaded.
|
||||
*/
|
||||
virtual bool canLoadGameStateCurrently() override {
|
||||
return canLoadGameState(false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicates whether a game state can be saved.
|
||||
* @param isAutosave Flags whether it's an autosave check
|
||||
*/
|
||||
virtual bool canSaveGameState(bool isAutosave = false) = 0;
|
||||
|
||||
/**
|
||||
* Indicates whether a game state can be saved.
|
||||
*/
|
||||
virtual bool canSaveGameStateCurrently() override {
|
||||
return canSaveGameState(false);
|
||||
}
|
||||
};
|
||||
|
||||
extern UltimaEngine *g_ultima;
|
||||
|
||||
@@ -69,7 +69,7 @@ void NuvieIOFileRead::close() {
|
||||
}
|
||||
|
||||
void NuvieIOFileRead::seek(uint32 new_pos) {
|
||||
if (isOpen() && new_pos <= _file->size()) {
|
||||
if (isOpen() && (int)new_pos <= _file->size()) {
|
||||
_file->seek(new_pos);
|
||||
pos = new_pos;
|
||||
}
|
||||
|
||||
@@ -234,7 +234,7 @@ bool Ultima6Engine::checkDataDir() {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Ultima6Engine::canLoadGameStateCurrently() {
|
||||
bool Ultima6Engine::canLoadGameState(bool isAutosave) {
|
||||
if (_events == nullptr)
|
||||
return false;
|
||||
|
||||
@@ -242,24 +242,30 @@ bool Ultima6Engine::canLoadGameStateCurrently() {
|
||||
// the save dialog will result in active gumps being closed
|
||||
Events *events = static_cast<Events *>(_events);
|
||||
MapWindow *mapWindow = _game->get_map_window();
|
||||
events->close_gumps();
|
||||
|
||||
if (isAutosave) {
|
||||
return events->get_mode() == MOVE_MODE;
|
||||
|
||||
} else {
|
||||
events->close_gumps();
|
||||
|
||||
switch (events->get_mode()) {
|
||||
case EQUIP_MODE:
|
||||
events->cancelAction();
|
||||
return false;
|
||||
case MOVE_MODE:
|
||||
mapWindow->set_looking(false);
|
||||
mapWindow->set_walking(false);
|
||||
return true;
|
||||
default:
|
||||
// Saving/loading only available in standard move mode in-game
|
||||
return false;
|
||||
switch (events->get_mode()) {
|
||||
case EQUIP_MODE:
|
||||
events->cancelAction();
|
||||
return false;
|
||||
case MOVE_MODE:
|
||||
mapWindow->set_looking(false);
|
||||
mapWindow->set_walking(false);
|
||||
return true;
|
||||
default:
|
||||
// Saving/loading only available in standard move mode in-game
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool Ultima6Engine::canSaveGameStateCurrently() {
|
||||
if (!canLoadGameStateCurrently())
|
||||
bool Ultima6Engine::canSaveGameState(bool isAutosave) {
|
||||
if (!canLoadGameState(isAutosave))
|
||||
return false;
|
||||
|
||||
// Further checks against saving
|
||||
@@ -267,10 +273,12 @@ bool Ultima6Engine::canSaveGameStateCurrently() {
|
||||
MsgScroll *scroll = _game->get_scroll();
|
||||
|
||||
if (_game->is_armageddon()) {
|
||||
scroll->message("Can't save. You killed everyone!\n\n");
|
||||
if (!isAutosave)
|
||||
scroll->message("Can't save. You killed everyone!\n\n");
|
||||
return false;
|
||||
} else if (events->using_control_cheat()) {
|
||||
scroll->message(" Can't save while using control cheat\n\n");
|
||||
if (!isAutosave)
|
||||
scroll->message(" Can't save while using control cheat\n\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -71,13 +71,15 @@ public:
|
||||
|
||||
/**
|
||||
* Indicates whether a game state can be loaded.
|
||||
* @param isAutosave Flags whether it's an autosave check
|
||||
*/
|
||||
virtual bool canLoadGameStateCurrently() override;
|
||||
virtual bool canLoadGameState(bool isAutosave = false) override;
|
||||
|
||||
/**
|
||||
* Indicates whether a game state can be saved.
|
||||
* @param isAutosave Flags whether it's an autosave check
|
||||
*/
|
||||
virtual bool canSaveGameStateCurrently() override;
|
||||
virtual bool canSaveGameState(bool isAutosave = false) override;
|
||||
|
||||
/**
|
||||
* Load a game state.
|
||||
|
||||
@@ -1296,7 +1296,7 @@ void Ultima8Engine::writeSaveInfo(ODataSource *ods) {
|
||||
}
|
||||
|
||||
bool Ultima8Engine::saveGame() {
|
||||
if (!canSaveGameStateCurrently())
|
||||
if (!canSaveGameState())
|
||||
return false;
|
||||
|
||||
GUI::SaveLoadChooser *dialog = new GUI::SaveLoadChooser(_("Save game:"), _("Save"), true);
|
||||
@@ -1322,7 +1322,7 @@ bool Ultima8Engine::saveGame() {
|
||||
return result;
|
||||
}
|
||||
|
||||
bool Ultima8Engine::canSaveGameStateCurrently() {
|
||||
bool Ultima8Engine::canSaveGameState(bool isAutosave) {
|
||||
if (desktopGump->FindGump<ModalGump>())
|
||||
// Can't save when a modal gump is open
|
||||
return false;
|
||||
|
||||
@@ -311,12 +311,12 @@ public:
|
||||
/**
|
||||
* Returns true if a savegame can be loaded
|
||||
*/
|
||||
virtual bool canLoadGameStateCurrently() { return true; }
|
||||
virtual bool canLoadGameState(bool isAutosave = false) { return true; }
|
||||
|
||||
/**
|
||||
* Returns true if the game can be saved
|
||||
*/
|
||||
virtual bool canSaveGameStateCurrently();
|
||||
virtual bool canSaveGameState(bool isAutosave = false) override;
|
||||
|
||||
virtual Common::Error loadGameState(int slot);
|
||||
virtual Common::Error saveGameState(int slot, const Common::String &desc);
|
||||
|
||||
Reference in new issue
Block a user