diff options
-rw-r--r-- | engines/kyra/gui_v2.cpp | 58 | ||||
-rw-r--r-- | engines/kyra/gui_v2.h | 11 | ||||
-rw-r--r-- | engines/kyra/staticres.cpp | 11 |
3 files changed, 79 insertions, 1 deletions
diff --git a/engines/kyra/gui_v2.cpp b/engines/kyra/gui_v2.cpp index 4583136743..86783af821 100644 --- a/engines/kyra/gui_v2.cpp +++ b/engines/kyra/gui_v2.cpp @@ -28,6 +28,7 @@ #include "kyra/screen.h" #include "kyra/wsamovie.h" #include "kyra/timer.h" +#include "kyra/sound.h" #include "common/savefile.h" @@ -1208,6 +1209,7 @@ int GUI_v2::optionsButton(Button *button) { initMenuLayout(_mainMenu); //XXX + initMenuLayout(_choiceMenu); _loadMenu.numberOfItems = 6; initMenuLayout(_loadMenu); initMenuLayout(_saveMenu); @@ -1408,6 +1410,24 @@ int GUI_v2::scrollDownButton(Button *button) { #pragma mark - +int GUI_v2::quitGame(Button *caller) { + updateMenuButton(caller); + if (choiceDialog(0xF, 1)) { + _displayMenu = false; + _vm->_runFlag = false; + _vm->_sound->beginFadeOut(); + _screen->fadeToBlack(); + _screen->clearCurPage(); + } + + if (_vm->_runFlag) { + initMenu(*_currentMenu); + updateAllMenuButtons(); + } + + return 0; +} + int GUI_v2::resumeGame(Button *caller) { updateMenuButton(caller); _displayMenu = false; @@ -1704,5 +1724,43 @@ void GUI_v2::drawTextfieldBlock(int x, int y, uint8 c) { _screen->fillRect(x+1, y+1, x+7, y+8, c); } +bool GUI_v2::choiceDialog(int name, bool type) { + _choiceMenu.highlightedItem = 0; + restorePage1(_vm->_screenBuffer); + backUpPage1(_vm->_screenBuffer); + if (type) + _choiceMenu.numberOfItems = 2; + else + _choiceMenu.numberOfItems = 1; + _choiceMenu.menuNameId = name; + + initMenu(_choiceMenu); + _isChoiceMenu = true; + _choice = false; + + while (_isChoiceMenu) { + processHighlights(_choiceMenu, _vm->_mouseX, _vm->_mouseY); + getInput(); + } + + restorePage1(_vm->_screenBuffer); + backUpPage1(_vm->_screenBuffer); + return _choice; +} + +int GUI_v2::choiceYes(Button *caller) { + updateMenuButton(caller); + _choice = true; + _isChoiceMenu = false; + return 0; +} + +int GUI_v2::choiceNo(Button *caller) { + updateMenuButton(caller); + _choice = false; + _isChoiceMenu = false; + return 0; +} + } // end of namespace Kyra diff --git a/engines/kyra/gui_v2.h b/engines/kyra/gui_v2.h index fbac982bd4..8fb3d3fa74 100644 --- a/engines/kyra/gui_v2.h +++ b/engines/kyra/gui_v2.h @@ -111,7 +111,7 @@ private: Button _menuButtons[7]; Button _scrollUpButton; Button _scrollDownButton; - Menu _mainMenu, _loadMenu, _saveMenu, _savenameMenu, _deathMenu; + Menu _mainMenu, _choiceMenu, _loadMenu, _saveMenu, _savenameMenu, _deathMenu; void initStaticData(); const char *getMenuTitle(const Menu &menu); @@ -152,6 +152,7 @@ private: bool _isLoadMenu; bool _isDeathMenu; bool _isSaveMenu; + bool _isChoiceMenu; bool _madeSave; bool _loadedSave; bool _restartGame; @@ -162,6 +163,7 @@ private: void setupSavegameNames(Menu &menu, int num); // main menu + int quitGame(Button *caller); int resumeGame(Button *caller); // load menu @@ -192,6 +194,13 @@ private: void checkTextfieldInput(); void drawTextfieldBlock(int x, int y, uint8 c); + // choice menu + bool _choice; + + bool choiceDialog(int name, bool type); + int choiceYes(Button *caller); + int choiceNo(Button *caller); + static const uint16 _menuStringsTalkie[]; static const uint16 _menuStringsOther[]; }; diff --git a/engines/kyra/staticres.cpp b/engines/kyra/staticres.cpp index f599e9b634..e73b27f4b1 100644 --- a/engines/kyra/staticres.cpp +++ b/engines/kyra/staticres.cpp @@ -1520,10 +1520,21 @@ void GUI_v2::initStaticData() { GUI_V2_MENU_ITEM(_mainMenu.item[3], 1, 0x04, -1, 0x51, 0xDC, 0x0F, 0xFC, 0xFD, -1, 0xF8, 0xF9, 0xFA, -1, 0, 0, 0, 0); GUI_V2_MENU_ITEM(_mainMenu.item[4], 1, 0x25, -1, 0x62, 0xDC, 0x0F, 0xFC, 0xFD, -1, 0xF8, 0xF9, 0xFA, -1, 0, 0, 0, 0); GUI_V2_MENU_ITEM(_mainMenu.item[5], 1, 0x05, -1, 0x73, 0xDC, 0x0F, 0xFC, 0xFD, -1, 0xF8, 0xF9, 0xFA, -1, 0, 0, 0, 0); + _mainMenu.item[5].callback = BUTTON_FUNCTOR(GUI_v2, this, &GUI_v2::quitGame); GUI_V2_MENU_ITEM(_mainMenu.item[6], 1, 0x06, -1, 0x90, 0xDC, 0x0F, 0xFC, 0xFD, -1, 0xF8, 0xF9, 0xFA, -1, 0, 0, 0, 0); _mainMenu.item[6].callback = BUTTON_FUNCTOR(GUI_v2, this, &GUI_v2::resumeGame); for (int i = 0; i < 7; ++i) _mainMenu.item[i].itemId = menuStr[0 * 8 + i + 1]; + + GUI_V2_MENU(_choiceMenu, -1, -1, 0x140, 0x38, 0xF8, 0xF9, 0xFA, 0, 0xFE, -1, 8, 0, 2, -1, -1, -1, -1); + GUI_V2_MENU_ITEM(_choiceMenu.item[0], 1, 0x14, 0x18, 0x1E, 0x48, 0x0F, 0xFC, 0xFD, -1, 0xF8, 0xF9, 0xFA, -1, 0, 0, 0, 0); + _choiceMenu.item[0].callback = BUTTON_FUNCTOR(GUI_v2, this, &GUI_v2::choiceYes); + GUI_V2_MENU_ITEM(_choiceMenu.item[1], 1, 0x13, 0xD8, 0x1E, 0x48, 0x0F, 0xFC, 0xFD, -1, 0xF8, 0xF9, 0xFA, -1, 0, 0, 0, 0); + _choiceMenu.item[1].callback = BUTTON_FUNCTOR(GUI_v2, this, &GUI_v2::choiceNo); + for (int i = 2; i <= 6; ++i) + _choiceMenu.item[i].enabled = false; + for (int i = 0; i < 7; ++i) + _choiceMenu.item[i].itemId = menuStr[3 * 8 + i + 1]; GUI_V2_MENU(_loadMenu, -1, -1, 0x120, 0xA0, 0xF8, 0xF9, 0xFA, menuStr[4 * 8], 0xFB, -1, 8, 0, 6, 0x84, 0x16, 0x84, 0x7C); GUI_V2_MENU_ITEM(_loadMenu.item[0], 1, 0x29, -1, 0x27, 0x100, 0xF, 0xFC, 0xFD, 5, 0xF8, 0xF9, 0xFA, -1, 0, 0, 0, 0); |