mirror of
https://github.com/libretro/scummvm.git
synced 2024-12-14 05:38:56 +00:00
Simplify the code to check whether loading or saving a game is possible.
svn-id: r42671
This commit is contained in:
parent
4e71153249
commit
fad11ade6e
@ -472,9 +472,7 @@ ScummMenuDialog::~ScummMenuDialog() {
|
||||
}
|
||||
|
||||
void ScummMenuDialog::reflowLayout() {
|
||||
// For v4+ games do not allow to save in room 0 just as original did.
|
||||
// It is not possible to load such saves
|
||||
if ((_vm->_game.version >= 4) && (_vm->_currentRoom == 0))
|
||||
if (!_vm->canSaveGameStateCurrently())
|
||||
_saveButton->setEnabled(false);
|
||||
|
||||
Dialog::reflowLayout();
|
||||
|
@ -111,8 +111,8 @@ void ScummEngine::parseEvent(Common::Event event) {
|
||||
switch (event.type) {
|
||||
case Common::EVENT_KEYDOWN:
|
||||
if (event.kbd.keycode >= '0' && event.kbd.keycode <= '9'
|
||||
&& (event.kbd.flags == Common::KBD_ALT ||
|
||||
event.kbd.flags == Common::KBD_CTRL)) {
|
||||
&& event.kbd.flags == Common::KBD_CTRL &&
|
||||
canLoadGameStateCurrently()) {
|
||||
_saveLoadSlot = event.kbd.keycode - '0';
|
||||
|
||||
// don't overwrite autosave (slot 0)
|
||||
@ -120,8 +120,24 @@ void ScummEngine::parseEvent(Common::Event event) {
|
||||
_saveLoadSlot = 10;
|
||||
|
||||
sprintf(_saveLoadName, "Quicksave %d", _saveLoadSlot);
|
||||
_saveLoadFlag = (event.kbd.flags == Common::KBD_ALT) ? 1 : 2;
|
||||
_saveLoadFlag = 2;
|
||||
_saveTemporaryState = false;
|
||||
} else if (event.kbd.keycode >= '0' && event.kbd.keycode <= '9'
|
||||
&& event.kbd.flags == Common::KBD_ALT &&
|
||||
canSaveGameStateCurrently()) {
|
||||
_saveLoadSlot = event.kbd.keycode - '0';
|
||||
|
||||
// don't overwrite autosave (slot 0)
|
||||
if (_saveLoadSlot == 0)
|
||||
_saveLoadSlot = 10;
|
||||
|
||||
sprintf(_saveLoadName, "Quicksave %d", _saveLoadSlot);
|
||||
_saveLoadFlag = 1;
|
||||
_saveTemporaryState = false;
|
||||
} else if (event.kbd.flags == Common::KBD_CTRL && event.kbd.keycode == 'f') {
|
||||
|
||||
|
||||
|
||||
} else if (event.kbd.flags == Common::KBD_CTRL && event.kbd.keycode == 'f') {
|
||||
_fastMode ^= 1;
|
||||
} else if (event.kbd.flags == Common::KBD_CTRL && event.kbd.keycode == 'g') {
|
||||
|
@ -95,15 +95,14 @@ Common::Error ScummEngine::saveGameState(int slot, const char *desc) {
|
||||
}
|
||||
|
||||
bool ScummEngine::canSaveGameStateCurrently() {
|
||||
// For v4+ games do not allow to save in room 0
|
||||
if (_game.version >= 4)
|
||||
return (_currentRoom != 0);
|
||||
|
||||
// FIXME: For now always allow loading in V0-V3 games
|
||||
// TODO: Should we disallow saving in some more places,
|
||||
// e.g. when a SAN movie is playing? Not sure whether the
|
||||
// original EXE allowed this.
|
||||
return (VAR_MAINMENU_KEY == 0xFF || VAR(VAR_MAINMENU_KEY) != 0);
|
||||
|
||||
// SCUMM v4+ doesn't allow saving in room 0 or if
|
||||
// VAR(VAR_MAINMENU_KEY) to set to zero.
|
||||
return (VAR_MAINMENU_KEY == 0xFF || (VAR(VAR_MAINMENU_KEY) != 0 && _currentRoom != 0));
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user