diff options
author | Johannes Schickel | 2008-04-06 16:54:51 +0000 |
---|---|---|
committer | Johannes Schickel | 2008-04-06 16:54:51 +0000 |
commit | 4b58a431da886a416a3a6eea19938357eb0a4065 (patch) | |
tree | 12c106ca8ead05daa9bc823d554e60a4155b2e81 /engines | |
parent | 16066fa3e7e8b2260328d74d0a58f2d636a5a492 (diff) | |
download | scummvm-rg350-4b58a431da886a416a3a6eea19938357eb0a4065.tar.gz scummvm-rg350-4b58a431da886a416a3a6eea19938357eb0a4065.tar.bz2 scummvm-rg350-4b58a431da886a416a3a6eea19938357eb0a4065.zip |
Implemented support for Towns (and hopefully DOS floppy too) menus.
svn-id: r31438
Diffstat (limited to 'engines')
-rw-r--r-- | engines/kyra/gui_v2.cpp | 160 | ||||
-rw-r--r-- | engines/kyra/gui_v2.h | 3 | ||||
-rw-r--r-- | engines/kyra/kyra_v2.cpp | 13 | ||||
-rw-r--r-- | engines/kyra/kyra_v2.h | 3 | ||||
-rw-r--r-- | engines/kyra/staticres.cpp | 56 | ||||
-rw-r--r-- | engines/kyra/text_v2.cpp | 3 |
6 files changed, 174 insertions, 64 deletions
diff --git a/engines/kyra/gui_v2.cpp b/engines/kyra/gui_v2.cpp index bf6cc595ca..e1ebde1ebf 100644 --- a/engines/kyra/gui_v2.cpp +++ b/engines/kyra/gui_v2.cpp @@ -1232,15 +1232,6 @@ int GUI_v2::optionsButton(Button *button) { //XXX _displayMenu = true; - if (!_vm->gameFlags().isTalkie) { - _gameOptions.item[2].enabled = false; // language settings - _gameOptions.item[2].labelId = 0; - _gameOptions.item[3].enabled = false; // text settings - _audioOptions.item[2].labelId = 0; - _audioOptions.item[3].enabled = false; // voice volume settings - _audioOptions.item[3].labelId = 0; - } - for (uint i = 0; i < ARRAYSIZE(_menuButtons); ++i) { _menuButtons[i].data0Val1 = _menuButtons[i].data1Val1 = _menuButtons[i].data2Val1 = 4; _menuButtons[i].data0Callback = _redrawShadedButtonFunctor; @@ -1467,7 +1458,7 @@ int GUI_v2::scrollDownButton(Button *button) { int GUI_v2::quitGame(Button *caller) { updateMenuButton(caller); - if (choiceDialog(0xF, 1)) { + if (choiceDialog(_vm->gameFlags().isTalkie ? 0xF : 0x17, 1)) { _displayMenu = false; _vm->_runFlag = false; _vm->_sound->beginFadeOut(); @@ -1493,6 +1484,51 @@ int GUI_v2::gameOptions(Button *caller) { updateMenuButton(caller); restorePage1(_vm->_screenBuffer); backUpPage1(_vm->_screenBuffer); + initMenu(_gameOptions); + _isOptionsMenu = true; + + const int menuX = _gameOptions.x; + const int menuY = _gameOptions.y; + + for (int i = 0; i < 4; ++i) { + int x = menuX + _sliderBarsPosition[i*2+0]; + int y = menuY + _sliderBarsPosition[i*2+1]; + _screen->drawShape(0, _vm->_buttonShapes[16], x, y, 0, 0); + drawSliderBar(i, _vm->_buttonShapes[17]); + _sliderButtons[0][i].buttonCallback = _sliderHandlerFunctor; + _sliderButtons[0][i].x = x; + _sliderButtons[0][i].y = y; + _menuButtonList = addButtonToList(_menuButtonList, &_sliderButtons[0][i]); + _sliderButtons[2][i].buttonCallback = _sliderHandlerFunctor; + _sliderButtons[2][i].x = x + 10; + _sliderButtons[2][i].y = y; + _menuButtonList = addButtonToList(_menuButtonList, &_sliderButtons[2][i]); + _sliderButtons[1][i].buttonCallback = _sliderHandlerFunctor; + _sliderButtons[1][i].x = x + 120; + _sliderButtons[1][i].y = y; + _menuButtonList = addButtonToList(_menuButtonList, &_sliderButtons[1][i]); + } + + while (_isOptionsMenu) { + processHighlights(_gameOptions, _vm->_mouseX, _vm->_mouseY); + getInput(); + } + + restorePage1(_vm->_screenBuffer); + backUpPage1(_vm->_screenBuffer); + + _vm->writeSettings(); + + initMenu(*_currentMenu); + updateAllMenuButtons(); + + return 0; +} + +int GUI_v2::gameOptionsTalkie(Button *caller) { + updateMenuButton(caller); + restorePage1(_vm->_screenBuffer); + backUpPage1(_vm->_screenBuffer); bool textEnabled = _vm->textEnabled(); int lang = _vm->_lang; @@ -1662,21 +1698,33 @@ int GUI_v2::audioOptions(Button *caller) { int GUI_v2::sliderHandler(Button *caller) { int button = 0; - if (caller->index >= 25 && caller->index <= 28) - button = caller->index - 25; - else if (caller->index >= 29 && caller->index <= 32) - button = caller->index - 29; + if (caller->index >= 24 && caller->index <= 27) + button = caller->index - 24; + else if (caller->index >= 28 && caller->index <= 31) + button = caller->index - 28; else - button = caller->index - 33; + button = caller->index - 32; - assert(button >= 0 && button <= 2); + assert(button >= 0 && button <= 3); + + int oldVolume = 0; + + if (_vm->gameFlags().isTalkie) { + oldVolume = _vm->getVolume(KyraEngine::kVolumeEntry(button)); + } else { + if (button < 2) + oldVolume = _vm->getVolume(KyraEngine::kVolumeEntry(button)); + else if (button == 2) + oldVolume = (_vm->_configWalkspeed == 3) ? 97 : 2; + else if (button == 3) + oldVolume = _vm->_configTextspeed; + } - int oldVolume = _vm->getVolume(KyraEngine::kVolumeEntry(button)); int newVolume = oldVolume; - if (caller->index >= 25 && caller->index <= 28) + if (caller->index >= 24 && caller->index <= 27) newVolume -= 10; - else if (caller->index >= 29 && caller->index <= 32) + else if (caller->index >= 28 && caller->index <= 31) newVolume += 10; else newVolume = _vm->_mouseX - caller->x - 7; @@ -1692,30 +1740,45 @@ int GUI_v2::sliderHandler(Button *caller) { drawSliderBar(button, _vm->_buttonShapes[18]); - if (button == 2) { - if (_vm->textEnabled()) - _vm->_configVoice = 2; - else - _vm->_configVoice = 1; - } + if (_vm->gameFlags().isTalkie) { + if (button == 2) { + if (_vm->textEnabled()) + _vm->_configVoice = 2; + else + _vm->_configVoice = 1; + } - _vm->setVolume(KyraEngine::kVolumeEntry(button), newVolume); + _vm->setVolume(KyraEngine::kVolumeEntry(button), newVolume); - switch (button) { - case 0: - lastMusicCommand = _vm->_lastMusicCommand; - break; + switch (button) { + case 0: + lastMusicCommand = _vm->_lastMusicCommand; + break; - case 1: - playSoundEffect = true; - break; + case 1: + playSoundEffect = true; + break; - case 2: - _vm->playVoice(90, 28); - break; + case 2: + _vm->playVoice(90, 28); + break; - default: - return 0; + default: + return 0; + } + } else { + if (button < 2) { + _vm->setVolume(KyraEngine::kVolumeEntry(button), newVolume); + if (button == 0) + lastMusicCommand = _vm->_lastMusicCommand; + else + playSoundEffect = true; + } else if (button == 2) { + _vm->_configWalkspeed = (newVolume > 48) ? 3 : 5; + _vm->setWalkspeed(_vm->_configWalkspeed); + } else if (button == 3) { + _vm->_configTextspeed = newVolume; + } } drawSliderBar(button, _vm->_buttonShapes[17]); @@ -1734,7 +1797,18 @@ void GUI_v2::drawSliderBar(int slider, const uint8 *shape) { int x = menuX + _sliderBarsPosition[slider*2+0] + 10; int y = menuY + _sliderBarsPosition[slider*2+1]; - int position = _vm->getVolume(KyraEngine::kVolumeEntry(slider)); + int position = 0; + if (_vm->gameFlags().isTalkie) { + position = _vm->getVolume(KyraEngine::kVolumeEntry(slider)); + } else { + if (slider < 2) + position = _vm->getVolume(KyraEngine::kVolumeEntry(slider)); + else if (slider == 2) + position = (_vm->_configWalkspeed == 3) ? 97 : 2; + else if (slider == 3) + position = _vm->_configTextspeed; + } + position = MAX(2, position); position = MIN(97, position); _screen->drawShape(0, shape, x+position, y, 0, 0); @@ -1908,7 +1982,7 @@ int GUI_v2::deleteMenu(Button *caller) { restorePage1(_vm->_screenBuffer); backUpPage1(_vm->_screenBuffer); _savegameOffset = 1; - _saveMenu.menuNameId = 35; + _saveMenu.menuNameId = _vm->gameFlags().isTalkie ? 35 : 1; setupSavegameNames(_saveMenu, 5); initMenu(_saveMenu); _isDeleteMenu = true; @@ -1925,10 +1999,10 @@ int GUI_v2::deleteMenu(Button *caller) { backUpPage1(_vm->_screenBuffer); initMenu(*_currentMenu); updateAllMenuButtons(); - _saveMenu.menuNameId = 9; + _saveMenu.menuNameId = _vm->gameFlags().isTalkie ? 9 : 17; return 0; } - } while (choiceDialog(0x24, 1) == 0); + } while (choiceDialog(_vm->gameFlags().isTalkie ? 0x24 : 2, 1) == 0); restorePage1(_vm->_screenBuffer); backUpPage1(_vm->_screenBuffer); @@ -1948,7 +2022,7 @@ int GUI_v2::deleteMenu(Button *caller) { Common::String newName = _vm->getSavegameFilename(*i-1); _vm->_saveFileMan->renameSavefile(oldName.c_str(), newName.c_str()); } - _saveMenu.menuNameId = 9; + _saveMenu.menuNameId = _vm->gameFlags().isTalkie ? 9 : 17; return 0; } diff --git a/engines/kyra/gui_v2.h b/engines/kyra/gui_v2.h index 3865e99810..b5a25d29bf 100644 --- a/engines/kyra/gui_v2.h +++ b/engines/kyra/gui_v2.h @@ -130,7 +130,7 @@ private: Button::Callback getScrollUpButtonHandler() const { return _scrollUpFunctor; } Button::Callback getScrollDownButtonHandler() const { return _scrollDownFunctor; } - Button _sliderButtons[3][3]; + Button _sliderButtons[3][4]; uint8 defaultColor1() const { return 0xCF; } uint8 defaultColor2() const { return 0xF8; } @@ -174,6 +174,7 @@ private: // options menu int gameOptions(Button *caller); + int gameOptionsTalkie(Button *caller); int quitOptionsMenu(Button *caller); int toggleWalkspeed(Button *caller); diff --git a/engines/kyra/kyra_v2.cpp b/engines/kyra/kyra_v2.cpp index 438d28efb1..2a73366124 100644 --- a/engines/kyra/kyra_v2.cpp +++ b/engines/kyra/kyra_v2.cpp @@ -124,6 +124,8 @@ KyraEngine_v2::KyraEngine_v2(OSystem *system, const GameFlags &flags) : KyraEngi memset(&_wsaSlots, 0, sizeof(_wsaSlots)); memset(&_buttonShapes, 0, sizeof(_buttonShapes)); + _configTextspeed = 50; + _inventoryButtons = _buttonList = 0; _dlgBuffer = 0; @@ -2257,6 +2259,17 @@ void KyraEngine_v2::registerDefaultSettings() { ConfMan.registerDefault("walkspeed", 5); } +void KyraEngine_v2::writeSettings() { + ConfMan.setInt("talkspeed", ((_configTextspeed-2) * 255) / 95); + KyraEngine::writeSettings(); +} + +void KyraEngine_v2::readSettings() { + int talkspeed = ConfMan.getInt("talkspeed"); + _configTextspeed = (talkspeed*95)/255 + 2; + KyraEngine::readSettings(); +} + } // end of namespace Kyra diff --git a/engines/kyra/kyra_v2.h b/engines/kyra/kyra_v2.h index b95b1baafc..f273b7dce1 100644 --- a/engines/kyra/kyra_v2.h +++ b/engines/kyra/kyra_v2.h @@ -313,6 +313,9 @@ protected: void cleanup(); void registerDefaultSettings(); + void writeSettings(); + void readSettings(); + uint8 _configTextspeed; // TODO: get rid of all variables having pointers to the static resources if possible // i.e. let them directly use the _staticres functions diff --git a/engines/kyra/staticres.cpp b/engines/kyra/staticres.cpp index 89fb5fb254..1618569a93 100644 --- a/engines/kyra/staticres.cpp +++ b/engines/kyra/staticres.cpp @@ -1629,14 +1629,14 @@ void GUI_v2::initStaticData() { GUI_V2_BUTTON(_scrollUpButton, 0x17, 0, 0, 1, 1, 1, 0x4487, 0, 0, 0, 0x18, 0x0F, 0xC7, 0xCF, 0xC7, 0xCF, 0xC7, 0xCF, 0); GUI_V2_BUTTON(_scrollDownButton, 0x18, 0, 0, 1, 1, 1, 0x4487, 0, 0, 0, 0x18, 0x0F, 0xC7, 0xCF, 0xC7, 0xCF, 0xC7, 0xCF, 0); - for (int i = 0; i < 3; ++i) { - GUI_V2_BUTTON(_sliderButtons[0][i], 0x19+i, 0, 0, 1, 1, 1, 0x4487, 0, 0, 0, 0x0A, 0x0E, 0xC7, 0xCF, 0xC7, 0xCF, 0xC7, 0xCF, 0); + for (int i = 0; i < 4; ++i) { + GUI_V2_BUTTON(_sliderButtons[0][i], 0x18+i, 0, 0, 1, 1, 1, 0x4487, 0, 0, 0, 0x0A, 0x0E, 0xC7, 0xCF, 0xC7, 0xCF, 0xC7, 0xCF, 0); } - for (int i = 0; i < 3; ++i) { - GUI_V2_BUTTON(_sliderButtons[1][i], 0x1D+i, 0, 0, 1, 1, 1, 0x4487, 0, 0, 0, 0x0A, 0x0E, 0xC7, 0xCF, 0xC7, 0xCF, 0xC7, 0xCF, 0); + for (int i = 0; i < 4; ++i) { + GUI_V2_BUTTON(_sliderButtons[1][i], 0x1C+i, 0, 0, 1, 1, 1, 0x4487, 0, 0, 0, 0x0A, 0x0E, 0xC7, 0xCF, 0xC7, 0xCF, 0xC7, 0xCF, 0); } - for (int i = 0; i < 3; ++i) { - GUI_V2_BUTTON(_sliderButtons[2][i], 0x21+i, 0, 0, 0, 0, 0, 0x2200, 0, 0, 0, 0x6E, 0x0E, 0xC7, 0xCF, 0xC7, 0xCF, 0xC7, 0xCF, 0); + for (int i = 0; i < 4; ++i) { + GUI_V2_BUTTON(_sliderButtons[2][i], 0x20+i, 0, 0, 0, 0, 0, 0x2200, 0, 0, 0, 0x6E, 0x0E, 0xC7, 0xCF, 0xC7, 0xCF, 0xC7, 0xCF, 0); } for (uint i = 0; i < ARRAYSIZE(_menuButtons); ++i) { @@ -1659,7 +1659,7 @@ void GUI_v2::initStaticData() { 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); + _mainMenu.item[3].callback = BUTTON_FUNCTOR(GUI_v2, this, &GUI_v2::gameOptionsTalkie); GUI_V2_MENU_ITEM(_mainMenu.item[4], 1, 0x25, -1, 0x62, 0xDC, 0x0F, 0xFC, 0xFD, -1, 0xF8, 0xF9, 0xFA, -1, 0, 0, 0, 0); _mainMenu.item[4].callback = BUTTON_FUNCTOR(GUI_v2, this, &GUI_v2::audioOptions); GUI_V2_MENU_ITEM(_mainMenu.item[5], 1, 0x05, -1, 0x73, 0xDC, 0x0F, 0xFC, 0xFD, -1, 0xF8, 0xF9, 0xFA, -1, 0, 0, 0, 0); @@ -1669,16 +1669,38 @@ void GUI_v2::initStaticData() { for (int i = 0; i < 7; ++i) _mainMenu.item[i].itemId = menuStr[0 * 8 + i + 1]; + if (!_vm->gameFlags().isTalkie) { + _mainMenu.height = 0x9C; + _mainMenu.numberOfItems = 6; + _mainMenu.item[6].enabled = false; + for (int i = 4; i < 6; ++i) + _mainMenu.item[i].callback = _mainMenu.item[i+1].callback; + _mainMenu.item[3].callback = BUTTON_FUNCTOR(GUI_v2, this, &GUI_v2::gameOptions); + _mainMenu.item[6].callback = Button::Callback(); + _mainMenu.item[5].y = 0x7F; + } + 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 = clickQuitOptionsFunctor; - for (int i = 4; i <= 6; ++i) + if (_vm->gameFlags().isTalkie) { + 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 = clickQuitOptionsFunctor; + } else { + _gameOptions.numberOfItems = 5; + GUI_V2_MENU_ITEM(_gameOptions.item[0], 0, 0x2B, 0xA0, 0x1E, 0x74, 0x0F, 0xFC, 0xFD, 5, 0xF8, 0xF9, 0xFA, -1, 0x1F, 0x10, 0x20, 0); + GUI_V2_MENU_ITEM(_gameOptions.item[1], 0, 0x2C, 0xA0, 0x2F, 0x74, 0x0F, 0xFC, 0xFD, 5, 0xF8, 0xF9, 0xFA, -1, 0x20, 0x10, 0x31, 0); + GUI_V2_MENU_ITEM(_gameOptions.item[2], 0, 0x2D, 0xA0, 0x40, 0x74, 0x0F, 0xFC, 0xFD, 5, 0xF8, 0xF9, 0xFA, -1, 0x1D, 0x10, 0x42, 0); + GUI_V2_MENU_ITEM(_gameOptions.item[3], 0, 0x2E, 0xA0, 0x51, 0x74, 0x0F, 0xFC, 0xFD, 5, 0xF8, 0xF9, 0xFA, -1, 0x1E, 0x10, 0x53, 0); + GUI_V2_MENU_ITEM(_gameOptions.item[4], 1, 0x18, 0xA0, 0x6E, 0x6C, 0x0F, 0xFC, 0xFD, 5, 0xF8, 0xF9, 0xFA, -1, 0, 0, 0, 0); + _gameOptions.item[4].callback = clickQuitOptionsFunctor; + } + + for (int i = _gameOptions.numberOfItems; i <= 6; ++i) _gameOptions.item[i].enabled = false; for (int i = 0; i < 7; ++i) _gameOptions.item[i].itemId = menuStr[1 * 8 + i + 1]; @@ -1776,7 +1798,7 @@ const uint16 GUI_v2::_menuStringsOther[] = { }; const int GUI_v2::_sliderBarsPosition[] = { - 0x92, 0x1F, 0x92, 0x30, 0x92, 0x41 + 0x92, 0x1F, 0x92, 0x30, 0x92, 0x41, 0x92, 0x52 }; const uint16 KyraEngine_v2::_itemMagicTable[] = { diff --git a/engines/kyra/text_v2.cpp b/engines/kyra/text_v2.cpp index 77eaf68d02..96a731752b 100644 --- a/engines/kyra/text_v2.cpp +++ b/engines/kyra/text_v2.cpp @@ -166,9 +166,6 @@ int KyraEngine_v2::chatGetType(const char *str) { int KyraEngine_v2::chatCalcDuration(const char *str) { static const uint8 durationMultiplicator[] = { 16, 14, 12, 10, 8, 8, 7, 6, 5, 4 }; - // TODO / HACK: imlement this correctly - const int _configTextspeed = 50; - int duration = strlen(str); duration *= _flags.isTalkie ? 8 : durationMultiplicator[(_configTextspeed / 10)]; return MAX<int>(duration, 120); |