diff options
Diffstat (limited to 'engines')
-rw-r--r-- | engines/kyra/gui_v2.cpp | 161 | ||||
-rw-r--r-- | engines/kyra/gui_v2.h | 15 | ||||
-rw-r--r-- | engines/kyra/kyra_v2.cpp | 5 | ||||
-rw-r--r-- | engines/kyra/kyra_v2.h | 1 | ||||
-rw-r--r-- | engines/kyra/staticres.cpp | 37 | ||||
-rw-r--r-- | engines/kyra/timer_v2.cpp | 3 |
6 files changed, 195 insertions, 27 deletions
diff --git a/engines/kyra/gui_v2.cpp b/engines/kyra/gui_v2.cpp index 86783af821..39753ba40a 100644 --- a/engines/kyra/gui_v2.cpp +++ b/engines/kyra/gui_v2.cpp @@ -230,6 +230,7 @@ void KyraEngine_v2::gui_printString(const char *format, int x, int y, int col1, void KyraEngine_v2::loadButtonShapes() { const uint8 *src = _screen->getCPagePtr(3); _screen->loadBitmap("_BUTTONS.CSH", 3, 3, 0); + _gui->_scrollUpButton.data0ShapePtr = _buttonShapes[0] = _screen->makeShapeCopy(src, 0); _gui->_scrollUpButton.data2ShapePtr = _buttonShapes[1] = _screen->makeShapeCopy(src, 1); _gui->_scrollUpButton.data1ShapePtr = _buttonShapes[2] = _screen->makeShapeCopy(src, 2); @@ -247,6 +248,30 @@ void KyraEngine_v2::loadButtonShapes() { _buttonShapes[18] = _screen->makeShapeCopy(src, 18); } +void KyraEngine_v2::setupLangButtonShapes() { + switch (_lang) { + case 0: + _inventoryButtons[0].data0ShapePtr = _buttonShapes[6]; + _inventoryButtons[0].data1ShapePtr = _inventoryButtons[0].data2ShapePtr = _buttonShapes[7]; + break; + + case 1: + _inventoryButtons[0].data0ShapePtr = _buttonShapes[8]; + _inventoryButtons[0].data1ShapePtr = _inventoryButtons[0].data2ShapePtr = _buttonShapes[9]; + break; + + case 2: + _inventoryButtons[0].data0ShapePtr = _buttonShapes[10]; + _inventoryButtons[0].data1ShapePtr = _inventoryButtons[0].data2ShapePtr = _buttonShapes[11]; + break; + + default: + _inventoryButtons[0].data0ShapePtr = _buttonShapes[6]; + _inventoryButtons[0].data1ShapePtr = _inventoryButtons[0].data2ShapePtr = _buttonShapes[7]; + break; + } +} + GUI_v2::GUI_v2(KyraEngine_v2 *vm) : GUI(vm), _vm(vm), _screen(vm->screen_v2()) { _backUpButtonList = _unknownButtonList = 0; initStaticData(); @@ -1208,6 +1233,7 @@ int GUI_v2::optionsButton(Button *button) { } initMenuLayout(_mainMenu); + initMenuLayout(_gameOptions); //XXX initMenuLayout(_choiceMenu); _loadMenu.numberOfItems = 6; @@ -1276,7 +1302,7 @@ int GUI_v2::optionsButton(Button *button) { if (!_loadedSave && _reloadTemporarySave) { _vm->_unkSceneScreenFlag1 = true; - //XXX + _vm->loadGame("TEMP.SAV"); _vm->_unkSceneScreenFlag1 = false; } @@ -1285,6 +1311,19 @@ int GUI_v2::optionsButton(Button *button) { #pragma mark - +void GUI_v2::renewHighlight(Menu &menu) { + if (!_displayMenu) + return; + + MenuItem &item = menu.item[menu.highlightedItem]; + int x = item.x + menu.x; int y = item.y + menu.y; + int x2 = x + item.width - 1; int y2 = y + item.height - 1; + redrawText(menu); + _screen->fillRect(x+2, y+2, x2-2, y2-2, item.bkgdColor); + redrawHighlight(menu); + _screen->updateScreen(); +} + void GUI_v2::setupPalette() { //if (_isDeathMenu) // memcpy(_vm->_unkBuffer1040Bytes, _screen->getPalette(0), 768); @@ -1434,6 +1473,126 @@ int GUI_v2::resumeGame(Button *caller) { return 0; } +int GUI_v2::gameOptions(Button *caller) { + updateMenuButton(caller); + restorePage1(_vm->_screenBuffer); + backUpPage1(_vm->_screenBuffer); + bool textEnabled = _vm->textEnabled(); + int lang = _vm->_lang; + + setupOptionsButtons(); + initMenu(_gameOptions); + _isOptionsMenu = true; + + while (_isOptionsMenu) { + processHighlights(_gameOptions, _vm->_mouseX, _vm->_mouseY); + getInput(); + } + + restorePage1(_vm->_screenBuffer); + backUpPage1(_vm->_screenBuffer); + + if (textEnabled && !_vm->textEnabled() && !_vm->speechEnabled()) { + _vm->_configVoice = 1; + choiceDialog(0x1E, 0); + } + + if (_vm->_lang != lang) { + _reloadTemporarySave = true; + _vm->saveGame("TEMP.SAV", "Temporary Kyrandia 2 Savegame"); + _vm->loadCCodeBuffer("C_CODE.XXX"); + if (_vm->_flags.isTalkie) + _vm->loadOptionsBuffer("OPTIONS.XXX"); + else + _vm->_optionsBuffer = _vm->_cCodeBuffer; + _vm->loadChapterBuffer(_vm->_newChapterFile); + _vm->loadNPCScript(); + _vm->setupLangButtonShapes(); + } + + _vm->writeSettings(); + + initMenu(*_currentMenu); + updateAllMenuButtons(); + return 0; +} + +int GUI_v2::quitOptionsMenu(Button *caller) { + updateMenuButton(caller); + _isOptionsMenu = false; + return 0; +} + +int GUI_v2::toggleWalkspeed(Button *caller) { + updateMenuButton(caller); + if (_vm->_configWalkspeed == 5) + _vm->_configWalkspeed = 3; + else + _vm->_configWalkspeed = 5; + _vm->_timer->setDelay(0, _vm->_configWalkspeed); + setupOptionsButtons(); + renewHighlight(_gameOptions); + return 0; +} + +int GUI_v2::changeLanguage(Button *caller) { + updateMenuButton(caller); + ++_vm->_lang; + _vm->_lang %= 3; + setupOptionsButtons(); + renewHighlight(_gameOptions); + return 0; +} + +int GUI_v2::toggleText(Button *caller) { + updateMenuButton(caller); + + if (_vm->textEnabled()) { + if (_vm->speechEnabled()) + _vm->_configVoice = 1; + else + _vm->_configVoice = 3; + } else { + if (_vm->speechEnabled()) + _vm->_configVoice = 2; + else + _vm->_configVoice = 0; + } + + setupOptionsButtons(); + renewHighlight(_gameOptions); + return 0; +} + +void GUI_v2::setupOptionsButtons() { + if (_vm->_configWalkspeed == 3) + _gameOptions.item[0].itemId = 28; + else + _gameOptions.item[0].itemId = 27; + + if (_vm->textEnabled()) + _gameOptions.item[2].itemId = 18; + else + _gameOptions.item[2].itemId = 17; + + switch (_vm->_lang) { + case 0: + _gameOptions.item[1].itemId = 31; + break; + + case 1: + _gameOptions.item[1].itemId = 32; + break; + + case 2: + _gameOptions.item[1].itemId = 33; + break; + + default: + break; + } +} + int GUI_v2::loadMenu(Button *caller) { if (!_vm->_menuDirectlyToLoad) { updateMenuButton(caller); diff --git a/engines/kyra/gui_v2.h b/engines/kyra/gui_v2.h index 8fb3d3fa74..e8a22bc617 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, _choiceMenu, _loadMenu, _saveMenu, _savenameMenu, _deathMenu; + Menu _mainMenu, _gameOptions, _choiceMenu, _loadMenu, _saveMenu, _savenameMenu, _deathMenu; void initStaticData(); const char *getMenuTitle(const Menu &menu); @@ -133,6 +133,8 @@ private: uint8 defaultColor1() const { return 0xCF; } uint8 defaultColor2() const { return 0xF8; } + void renewHighlight(Menu &menu); + void setupPalette(); void restorePalette(); @@ -153,6 +155,7 @@ private: bool _isDeathMenu; bool _isSaveMenu; bool _isChoiceMenu; + bool _isOptionsMenu; bool _madeSave; bool _loadedSave; bool _restartGame; @@ -166,6 +169,16 @@ private: int quitGame(Button *caller); int resumeGame(Button *caller); + // options menu + int gameOptions(Button *caller); + int quitOptionsMenu(Button *caller); + + int toggleWalkspeed(Button *caller); + int changeLanguage(Button *caller); + int toggleText(Button *caller); + + void setupOptionsButtons(); + // load menu bool _noLoadProcess; int loadMenu(Button *caller); diff --git a/engines/kyra/kyra_v2.cpp b/engines/kyra/kyra_v2.cpp index 858076dacb..8742bdeb3d 100644 --- a/engines/kyra/kyra_v2.cpp +++ b/engines/kyra/kyra_v2.cpp @@ -359,11 +359,12 @@ void KyraEngine_v2::startup() { _gfxBackUpRect = new uint8[_screen->getRectSize(32, 32)]; _itemList = new Item[30]; memset(_itemList, 0, sizeof(Item)*30); - resetItemList(); loadButtonShapes(); + resetItemList(); _loadedZTable = 1; loadZShapes(_loadedZTable); initInventoryButtonList(); + setupLangButtonShapes(); loadInventoryShapes(); _res->loadFileToBuf("PALETTE.COL", _screen->_currentPalette, 0x300); @@ -404,7 +405,7 @@ void KyraEngine_v2::startup() { setNextIdleAnimTimer(); //XXX - _timer->setDelay(0, 5); + setWalkspeed(_configWalkspeed); } void KyraEngine_v2::runLoop() { diff --git a/engines/kyra/kyra_v2.h b/engines/kyra/kyra_v2.h index fc4e223f01..1475fc5d13 100644 --- a/engines/kyra/kyra_v2.h +++ b/engines/kyra/kyra_v2.h @@ -612,6 +612,7 @@ protected: GUI_v2 *_gui; void loadButtonShapes(); + void setupLangButtonShapes(); uint8 *_buttonShapes[19]; void initInventoryButtonList(); diff --git a/engines/kyra/staticres.cpp b/engines/kyra/staticres.cpp index e73b27f4b1..2bdf2028ab 100644 --- a/engines/kyra/staticres.cpp +++ b/engines/kyra/staticres.cpp @@ -1470,28 +1470,6 @@ void KyraEngine_v2::initInventoryButtonList() { for (int i = 5; i <= 14; ++i) _inventoryButtons[i].buttonCallback = inventoryCallback; - switch (_lang) { - case 0: - _inventoryButtons[0].data0ShapePtr = _buttonShapes[6]; - _inventoryButtons[0].data1ShapePtr = _inventoryButtons[0].data2ShapePtr = _buttonShapes[7]; - break; - - case 1: - _inventoryButtons[0].data0ShapePtr = _buttonShapes[8]; - _inventoryButtons[0].data1ShapePtr = _inventoryButtons[0].data2ShapePtr = _buttonShapes[9]; - break; - - case 2: - _inventoryButtons[0].data0ShapePtr = _buttonShapes[10]; - _inventoryButtons[0].data1ShapePtr = _inventoryButtons[0].data2ShapePtr = _buttonShapes[11]; - break; - - default: - _inventoryButtons[0].data0ShapePtr = _buttonShapes[6]; - _inventoryButtons[0].data1ShapePtr = _inventoryButtons[0].data2ShapePtr = _buttonShapes[7]; - break; - } - _buttonList = &_inventoryButtons[0]; for (size_t i = 1; i < 15; ++i) _buttonList = _gui->addButtonToList(_buttonList, &_inventoryButtons[i]); @@ -1518,6 +1496,7 @@ void GUI_v2::initStaticData() { _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); 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); 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); @@ -1526,6 +1505,20 @@ void GUI_v2::initStaticData() { for (int i = 0; i < 7; ++i) _mainMenu.item[i].itemId = menuStr[0 * 8 + i + 1]; + GUI_V2_MENU(_gameOptions, -1, -1, 0x120, 0x88, 0xF8, 0xF9, 0xFA, menuStr[1 * 8], 0xFB, -1, 8, 4, 4, -1, -1, -1, -1); + GUI_V2_MENU_ITEM(_gameOptions.item[0], 1, 0, 0xA0, 0x1E, 0x74, 0x0F, 0xFC, 0xFD, 5, 0xF8, 0xF9, 0xFA, -1, 0x15, 8, 0x20, 0); + _gameOptions.item[0].callback = BUTTON_FUNCTOR(GUI_v2, this, &GUI_v2::toggleWalkspeed); + GUI_V2_MENU_ITEM(_gameOptions.item[1], 1, 0, 0xA0, 0x2F, 0x74, 0x0F, 0xFC, 0xFD, 5, 0xF8, 0xF9, 0xFA, -1, 0x26, 8, 0x31, 0); + _gameOptions.item[1].callback = BUTTON_FUNCTOR(GUI_v2, this, &GUI_v2::changeLanguage); + GUI_V2_MENU_ITEM(_gameOptions.item[2], 1, 0, 0xA0, 0x40, 0x74, 0x0F, 0xFC, 0xFD, 5, 0xF8, 0xF9, 0xFA, -1, 0x16, 8, 0x42, 0); + _gameOptions.item[2].callback = BUTTON_FUNCTOR(GUI_v2, this, &GUI_v2::toggleText); + GUI_V2_MENU_ITEM(_gameOptions.item[3], 1, 0x10, -1, 0x6E, 0x6C, 0x0F, 0xFD, 0xFD, -1, 0xF8, 0xF9, 0xFA, -1, 0, 0, 0, 0); + _gameOptions.item[3].callback = BUTTON_FUNCTOR(GUI_v2, this, &GUI_v2::quitOptionsMenu); + for (int i = 4; i <= 6; ++i) + _gameOptions.item[i].enabled = false; + for (int i = 0; i < 7; ++i) + _gameOptions.item[i].itemId = menuStr[1 * 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); diff --git a/engines/kyra/timer_v2.cpp b/engines/kyra/timer_v2.cpp index 994555cc32..7e21970067 100644 --- a/engines/kyra/timer_v2.cpp +++ b/engines/kyra/timer_v2.cpp @@ -113,7 +113,8 @@ void KyraEngine_v2::setWalkspeed(uint8 newSpeed) { else newSpeed = 5; - _timer->setDelay(5, newSpeed); + _configWalkspeed = newSpeed; + _timer->setDelay(0, newSpeed); } |