aboutsummaryrefslogtreecommitdiff
path: root/engines/kyra
diff options
context:
space:
mode:
authorJohannes Schickel2008-04-05 02:22:11 +0000
committerJohannes Schickel2008-04-05 02:22:11 +0000
commit702062757202d1d70bfc1290e7d5ffaf8052fba0 (patch)
tree2ca23ef63113d261bfa2579eff6162dcc2fbe15c /engines/kyra
parent25364dc618c820da5da780b5c5812f039abaaee2 (diff)
downloadscummvm-rg350-702062757202d1d70bfc1290e7d5ffaf8052fba0.tar.gz
scummvm-rg350-702062757202d1d70bfc1290e7d5ffaf8052fba0.tar.bz2
scummvm-rg350-702062757202d1d70bfc1290e7d5ffaf8052fba0.zip
- Implemented delete savegame menu
- Reverted hack introduced with last commit svn-id: r31395
Diffstat (limited to 'engines/kyra')
-rw-r--r--engines/kyra/gui.cpp2
-rw-r--r--engines/kyra/gui_v2.cpp82
-rw-r--r--engines/kyra/gui_v2.h5
-rw-r--r--engines/kyra/staticres.cpp1
4 files changed, 76 insertions, 14 deletions
diff --git a/engines/kyra/gui.cpp b/engines/kyra/gui.cpp
index 81771eae5a..d0151f0ed5 100644
--- a/engines/kyra/gui.cpp
+++ b/engines/kyra/gui.cpp
@@ -72,8 +72,6 @@ void GUI::initMenuLayout(Menu &menu) {
}
void GUI::initMenu(Menu &menu) {
- // HACK: else sometimes the scroll button appears after loading a savegame in kyrandia 2
- updateAllMenuButtons();
_menuButtonList = 0;
_screen->hideMouse();
diff --git a/engines/kyra/gui_v2.cpp b/engines/kyra/gui_v2.cpp
index 78705fdfb5..3d95d03238 100644
--- a/engines/kyra/gui_v2.cpp
+++ b/engines/kyra/gui_v2.cpp
@@ -1194,6 +1194,7 @@ void GUI_v2::getInput() {
_isLoadMenu = false;
_isSaveMenu = false;
_isOptionsMenu = false;
+ _isDeleteMenu = false;
}
}
@@ -1423,7 +1424,7 @@ void GUI_v2::setupSavegameNames(Menu &menu, int num) {
int GUI_v2::scrollUpButton(Button *button) {
updateMenuButton(button);
- if (_savegameOffset == 0)
+ if (_savegameOffset == (_isDeleteMenu ? 1 : 0))
return 0;
--_savegameOffset;
@@ -1431,7 +1432,7 @@ int GUI_v2::scrollUpButton(Button *button) {
setupSavegameNames(_loadMenu, 5);
// original calls something different here...
initMenu(_loadMenu);
- } else if (_isSaveMenu) {
+ } else if (_isSaveMenu || _isDeleteMenu) {
setupSavegameNames(_saveMenu, 5);
// original calls something different here...
initMenu(_saveMenu);
@@ -1445,13 +1446,13 @@ int GUI_v2::scrollDownButton(Button *button) {
++_savegameOffset;
if (uint(_savegameOffset + 5) >= _saveSlots.size())
- _savegameOffset = MAX<int>(_saveSlots.size() - 5, 0);
+ _savegameOffset = MAX<int>(_saveSlots.size() - 5, _isDeleteMenu ? 1 : 0);
if (_isLoadMenu) {
setupSavegameNames(_loadMenu, 5);
// original calls something different here...
initMenu(_loadMenu);
- } else if (_isSaveMenu) {
+ } else if (_isSaveMenu || _isDeleteMenu) {
setupSavegameNames(_saveMenu, 5);
// original calls something different here...
initMenu(_saveMenu);
@@ -1861,14 +1862,14 @@ int GUI_v2::clickSaveSlot(Button *caller) {
MenuItem &item = _saveMenu.item[caller->index-0x10];
if (item.saveSlot >= 0) {
- //if (_isDeleteMenu) {
- // _slotToDelete = item.saveSlot;
- // _isDeleteMenu = false;
- // return 0;
- //else {
+ if (_isDeleteMenu) {
+ _slotToDelete = item.saveSlot;
+ _isDeleteMenu = false;
+ return 0;
+ } else {
_saveSlot = item.saveSlot;
strcpy(_saveDescription, _vm->getTableString(item.itemId, _vm->_optionsBuffer, 0));
- //}
+ }
} else if (item.saveSlot == -2) {
_saveSlot = getNextSavegameSlot();
memset(_saveDescription, 0, sizeof(_saveDescription));
@@ -1884,7 +1885,7 @@ int GUI_v2::clickSaveSlot(Button *caller) {
backUpPage1(_vm->_screenBuffer);
if (desc) {
_isSaveMenu = false;
- //_isDeleteMenu = false;
+ _isDeleteMenu = false;
} else {
initMenu(_saveMenu);
}
@@ -1895,11 +1896,68 @@ int GUI_v2::clickSaveSlot(Button *caller) {
int GUI_v2::cancelSaveMenu(Button *caller) {
updateMenuButton(caller);
_isSaveMenu = false;
- //_isDeleteMenu = false;
+ _isDeleteMenu = false;
_noSaveProcess = true;
return 0;
}
+int GUI_v2::deleteMenu(Button *caller) {
+ updateSaveList();
+
+ updateMenuButton(caller);
+ if (_saveSlots.size() < 2) {
+ _vm->snd_playSoundEffect(0x0D);
+ return 0;
+ }
+
+ do {
+ restorePage1(_vm->_screenBuffer);
+ backUpPage1(_vm->_screenBuffer);
+ _savegameOffset = 1;
+ _saveMenu.menuNameId = 35;
+ setupSavegameNames(_saveMenu, 5);
+ initMenu(_saveMenu);
+ _isDeleteMenu = true;
+ _slotToDelete = -1;
+ updateAllMenuButtons();
+
+ while (_isDeleteMenu) {
+ processHighlights(_saveMenu, _vm->_mouseX, _vm->_mouseY);
+ getInput();
+ }
+
+ if (_slotToDelete < 1) {
+ restorePage1(_vm->_screenBuffer);
+ backUpPage1(_vm->_screenBuffer);
+ initMenu(*_currentMenu);
+ updateAllMenuButtons();
+ _saveMenu.menuNameId = 9;
+ return 0;
+ }
+ } while (choiceDialog(0x24, 1) == 0);
+
+ restorePage1(_vm->_screenBuffer);
+ backUpPage1(_vm->_screenBuffer);
+ initMenu(*_currentMenu);
+ updateAllMenuButtons();
+ _vm->_saveFileMan->removeSavefile(_vm->getSavegameFilename(_slotToDelete));
+ Common::Array<int>::iterator i = Common::find(_saveSlots.begin(), _saveSlots.end(), _slotToDelete);
+ int lastSlot = _slotToDelete;
+ while (i != _saveSlots.end()) {
+ ++i;
+ if (i == _saveSlots.end())
+ break;
+ if (lastSlot + 1 != *i)
+ break;
+ Common::String oldName = _vm->getSavegameFilename(*i);
+ Common::String newName = _vm->getSavegameFilename(*i-1);
+ _vm->_saveFileMan->renameSavefile(oldName.c_str(), newName.c_str());
+ lastSlot = *i;
+ }
+ _saveMenu.menuNameId = 9;
+ return 0;
+}
+
const char *GUI_v2::nameInputProcess(char *buffer, int x, int y, uint8 c1, uint8 c2, uint8 c3, int bufferSize) {
bool running = true;
int curPos = strlen(buffer);
diff --git a/engines/kyra/gui_v2.h b/engines/kyra/gui_v2.h
index a10f47faba..3865e99810 100644
--- a/engines/kyra/gui_v2.h
+++ b/engines/kyra/gui_v2.h
@@ -156,6 +156,7 @@ private:
bool _isLoadMenu;
bool _isDeathMenu;
bool _isSaveMenu;
+ bool _isDeleteMenu;
bool _isChoiceMenu;
bool _isOptionsMenu;
bool _madeSave;
@@ -206,6 +207,10 @@ private:
int clickSaveSlot(Button *caller);
int cancelSaveMenu(Button *caller);
+ // delete menu
+ int _slotToDelete;
+ int deleteMenu(Button *caller);
+
// savename menu
bool _finishNameInput, _cancelNameInput;
Common::KeyState _keyPressed;
diff --git a/engines/kyra/staticres.cpp b/engines/kyra/staticres.cpp
index 1552996348..8c67308ee9 100644
--- a/engines/kyra/staticres.cpp
+++ b/engines/kyra/staticres.cpp
@@ -1508,6 +1508,7 @@ void GUI_v2::initStaticData() {
GUI_V2_MENU_ITEM(_mainMenu.item[1], 1, 0x03, -1, 0x2F, 0xDC, 0x0F, 0xFC, 0xFD, -1, 0xF8, 0xF9, 0xFA, -1, 0, 0, 0, 0);
_mainMenu.item[1].callback = BUTTON_FUNCTOR(GUI_v2, this, &GUI_v2::saveMenu);
GUI_V2_MENU_ITEM(_mainMenu.item[2], 1, 0x23, -1, 0x40, 0xDC, 0x0F, 0xFC, 0xFD, -1, 0xF8, 0xF9, 0xFA, -1, 0, 0, 0, 0);
+ _mainMenu.item[2].callback = BUTTON_FUNCTOR(GUI_v2, this, &GUI_v2::deleteMenu);
GUI_V2_MENU_ITEM(_mainMenu.item[3], 1, 0x04, -1, 0x51, 0xDC, 0x0F, 0xFC, 0xFD, -1, 0xF8, 0xF9, 0xFA, -1, 0, 0, 0, 0);
_mainMenu.item[3].callback = BUTTON_FUNCTOR(GUI_v2, this, &GUI_v2::gameOptions);
GUI_V2_MENU_ITEM(_mainMenu.item[4], 1, 0x25, -1, 0x62, 0xDC, 0x0F, 0xFC, 0xFD, -1, 0xF8, 0xF9, 0xFA, -1, 0, 0, 0, 0);