diff options
author | Florian Kagerer | 2009-06-19 18:46:19 +0000 |
---|---|---|
committer | Florian Kagerer | 2009-06-19 18:46:19 +0000 |
commit | 66445ae515b7840062e45eb550983d859da17a14 (patch) | |
tree | c76e33d6e39a4895292a59c382172a9e2ab3e19d | |
parent | f8744fde7587f36a2f8c6bbc4952e6f0f5380555 (diff) | |
download | scummvm-rg350-66445ae515b7840062e45eb550983d859da17a14.tar.gz scummvm-rg350-66445ae515b7840062e45eb550983d859da17a14.tar.bz2 scummvm-rg350-66445ae515b7840062e45eb550983d859da17a14.zip |
LOL: - implemented delete menu
- fixed some bugs in the menu code
svn-id: r41683
-rw-r--r-- | engines/kyra/gui_lol.cpp | 42 | ||||
-rw-r--r-- | engines/kyra/gui_lol.h | 4 | ||||
-rw-r--r-- | engines/kyra/staticres.cpp | 20 |
3 files changed, 56 insertions, 10 deletions
diff --git a/engines/kyra/gui_lol.cpp b/engines/kyra/gui_lol.cpp index 0465c5c6c6..a6d70c507f 100644 --- a/engines/kyra/gui_lol.cpp +++ b/engines/kyra/gui_lol.cpp @@ -2236,11 +2236,9 @@ int GUI_LoL::runMenu(Menu &menu) { while (_displayMenu) { _vm->_mouseX = _vm->_mouseY = 0; - if (_currentMenu == &_loadMenu || _currentMenu == &_saveMenu) { + if (_currentMenu == &_loadMenu || _currentMenu == &_saveMenu || _currentMenu == &_deleteMenu) { updateSaveList(true); Common::sort(_saveSlots.begin(), _saveSlots.end(), Common::Greater<int>()); - - setupSavegameNames(*_currentMenu, 4); } @@ -2313,7 +2311,7 @@ int GUI_LoL::runMenu(Menu &menu) { if (!_newMenu) _newMenu = _currentMenu; else - _lastMenu = _currentMenu; + _lastMenu = _menuResult == -1 ? _lastMenu : _currentMenu; } if (!_menuResult) @@ -2364,8 +2362,8 @@ void GUI_LoL::setupSavegameNames(Menu &menu, int num) { for (uint32 ii = 0; ii < strlen(s); ii++) { for (int iii = 0; iii < _vm->_fontConversionTableGermanSize; iii += 2) { - if (s[ii] == _vm->_fontConversionTableGerman[iii]) { - s[ii] = _vm->_fontConversionTableGerman[iii + 1]; + if ((uint8)s[ii] == _vm->_fontConversionTableGerman[iii]) { + s[ii] = (uint8)_vm->_fontConversionTableGerman[iii + 1]; break; } } @@ -2424,13 +2422,16 @@ int GUI_LoL::clickedMainMenu(Button *button) { updateMenuButton(button); switch (button->arg) { case 0x4001: + _savegameOffset = 0; _newMenu = &_loadMenu; break; case 0x4002: + _savegameOffset = 0; //_newMenu = &_saveMenu; break; case 0x4003: - //_newMenu = &_deleteMenu; + _savegameOffset = 0; + _newMenu = &_deleteMenu; break; case 0x4004: _newMenu = &_gameOptions; @@ -2467,6 +2468,23 @@ int GUI_LoL::clickedLoadMenu(Button *button) { return 1; } +int GUI_LoL::clickedSaveMenu(Button *button) { + updateMenuButton(button); + + return 1; +} + +int GUI_LoL::clickedDeleteMenu(Button *button) { + updateMenuButton(button); + + _choiceMenu.menuNameId = 0x400b; + _newMenu = (button->arg == 0x4011) ? _lastMenu : &_choiceMenu; + int16 s = (int16)button->arg; + _menuResult = _deleteMenu.item[-s - 2].saveSlot; + + return 1; +} + int GUI_LoL::clickedOptionsMenu(Button *button) { updateMenuButton(button); @@ -2516,10 +2534,14 @@ int GUI_LoL::clickedDeathMenu(Button *button) { int GUI_LoL::clickedChoiceMenu(Button *button) { updateMenuButton(button); if (button->arg == _choiceMenu.item[0].itemId) { - if (_lastMenu == &_mainMenu) + if (_lastMenu == &_mainMenu) { _vm->quitGame(); + } else if (_lastMenu == &_deleteMenu) { + _vm->_saveFileMan->removeSavefile(_vm->getSavegameFilename(_menuResult)); + _newMenu = &_mainMenu; + } } else if (button->arg == _choiceMenu.item[1].itemId) { - _newMenu = _lastMenu; + _newMenu = &_mainMenu; } return 1; } @@ -2529,6 +2551,7 @@ int GUI_LoL::scrollUp(Button *button) { if (_savegameOffset > 0) { _savegameOffset--; _newMenu = _currentMenu; + _menuResult = -1; } return 1; } @@ -2538,6 +2561,7 @@ int GUI_LoL::scrollDown(Button *button) { if ((uint)_savegameOffset < _saveSlots.size() - 4) { _savegameOffset++; _newMenu = _currentMenu; + _menuResult = -1; } return 1; } diff --git a/engines/kyra/gui_lol.h b/engines/kyra/gui_lol.h index ef636d0267..8489a2a7fc 100644 --- a/engines/kyra/gui_lol.h +++ b/engines/kyra/gui_lol.h @@ -111,6 +111,8 @@ private: int clickedMainMenu(Button *button); int clickedLoadMenu(Button *button); + int clickedSaveMenu(Button *button); + int clickedDeleteMenu(Button *button); int clickedOptionsMenu(Button *button); int clickedDeathMenu(Button *button); int clickedChoiceMenu(Button *button); @@ -136,7 +138,7 @@ private: Button _menuButtons[7]; Button _scrollUpButton; Button _scrollDownButton; - Menu _mainMenu, _gameOptions, _audioOptions, _choiceMenu, _loadMenu, _saveMenu, _savenameMenu, _deathMenu; + Menu _mainMenu, _gameOptions, _audioOptions, _choiceMenu, _loadMenu, _saveMenu, _deleteMenu, _savenameMenu, _deathMenu; Menu *_currentMenu, *_lastMenu, *_newMenu; int _menuResult; diff --git a/engines/kyra/staticres.cpp b/engines/kyra/staticres.cpp index b7d3a3a821..14f34d5ad5 100644 --- a/engines/kyra/staticres.cpp +++ b/engines/kyra/staticres.cpp @@ -2040,6 +2040,26 @@ void GUI_LoL::initStaticData() { for (int i = 0; i < 5; ++i) _loadMenu.item[i].callback = loadMenuFunctor; + GUI_LOL_MENU(_saveMenu, 10, 0x400d, 1, 5, 128, 20, 128, 118); + GUI_LOL_MENU_ITEM(_saveMenu.item[0], 0xfffe, 8, 39, 256, 15, 0, 0); + GUI_LOL_MENU_ITEM(_saveMenu.item[1], 0xfffd, 8, 56, 256, 15, 0, 0); + GUI_LOL_MENU_ITEM(_saveMenu.item[2], 0xfffc, 8, 73, 256, 15, 0, 0); + GUI_LOL_MENU_ITEM(_saveMenu.item[3], 0xfffb, 8, 90, 256, 15, 0, 0); + GUI_LOL_MENU_ITEM(_saveMenu.item[4], 0x4011, 168, 118, 96, 15, 0, 110); + Button::Callback saveMenuFunctor = BUTTON_FUNCTOR(GUI_LoL, this, &GUI_LoL::clickedSaveMenu); + for (int i = 0; i < 5; ++i) + _saveMenu.item[i].callback = saveMenuFunctor; + + GUI_LOL_MENU(_deleteMenu, 10, 0x400f, 1, 5, 128, 20, 128, 118); + GUI_LOL_MENU_ITEM(_deleteMenu.item[0], 0xfffe, 8, 39, 256, 15, 0, 0); + GUI_LOL_MENU_ITEM(_deleteMenu.item[1], 0xfffd, 8, 56, 256, 15, 0, 0); + GUI_LOL_MENU_ITEM(_deleteMenu.item[2], 0xfffc, 8, 73, 256, 15, 0, 0); + GUI_LOL_MENU_ITEM(_deleteMenu.item[3], 0xfffb, 8, 90, 256, 15, 0, 0); + GUI_LOL_MENU_ITEM(_deleteMenu.item[4], 0x4011, 168, 118, 96, 15, 0, 110); + Button::Callback deleteMenuFunctor = BUTTON_FUNCTOR(GUI_LoL, this, &GUI_LoL::clickedDeleteMenu); + for (int i = 0; i < 5; ++i) + _deleteMenu.item[i].callback = deleteMenuFunctor; + GUI_LOL_MENU(_gameOptions, 17, 0x400c, 0, 6, -1, -1, -1, -1); GUI_LOL_MENU_ITEM(_gameOptions.item[0], 0xfff7, 120, 22, 80, 15, 0x406e, 0); GUI_LOL_MENU_ITEM(_gameOptions.item[1], 0xfff6, 120, 39, 80, 15, 0x406c, 0); |