diff options
author | Johannes Schickel | 2008-05-11 11:35:12 +0000 |
---|---|---|
committer | Johannes Schickel | 2008-05-11 11:35:12 +0000 |
commit | 35cc3a3d19f7a4c7c9f202f749a27eb1573cfad9 (patch) | |
tree | a67a44d595e4aa4e903e30c07942e9a5f8de72c8 /engines | |
parent | 7da27cf28cb48fce13ebff907743f78dd6e75bc0 (diff) | |
download | scummvm-rg350-35cc3a3d19f7a4c7c9f202f749a27eb1573cfad9.tar.gz scummvm-rg350-35cc3a3d19f7a4c7c9f202f749a27eb1573cfad9.tar.bz2 scummvm-rg350-35cc3a3d19f7a4c7c9f202f749a27eb1573cfad9.zip |
Committed slightly modified patch #1961830 "KYRA: Scroll wheel support for Kyra 2 and 3".
svn-id: r32016
Diffstat (limited to 'engines')
-rw-r--r-- | engines/kyra/gui.cpp | 7 | ||||
-rw-r--r-- | engines/kyra/gui.h | 5 | ||||
-rw-r--r-- | engines/kyra/gui_v1.cpp | 26 | ||||
-rw-r--r-- | engines/kyra/gui_v1.h | 5 | ||||
-rw-r--r-- | engines/kyra/gui_v2.cpp | 10 | ||||
-rw-r--r-- | engines/kyra/gui_v2.h | 5 | ||||
-rw-r--r-- | engines/kyra/kyra_v1.cpp | 2 | ||||
-rw-r--r-- | engines/kyra/kyra_v2.cpp | 13 | ||||
-rw-r--r-- | engines/kyra/script_v1.cpp | 2 |
9 files changed, 46 insertions, 29 deletions
diff --git a/engines/kyra/gui.cpp b/engines/kyra/gui.cpp index 1296717467..407be7a73a 100644 --- a/engines/kyra/gui.cpp +++ b/engines/kyra/gui.cpp @@ -36,7 +36,6 @@ namespace Kyra { GUI::GUI(KyraEngine *kyra) : _vm(kyra), _screen(kyra->screen()), _text(kyra->text()) { _menuButtonList = 0; - _haveScrollButtons = false; _redrawButtonFunctor = BUTTON_FUNCTOR(GUI, this, &GUI::redrawButtonCallback); _redrawShadedButtonFunctor = BUTTON_FUNCTOR(GUI, this, &GUI::redrawShadedButtonCallback); @@ -148,13 +147,12 @@ void GUI::initMenu(Menu &menu) { } if (menu.scrollUpButtonX != -1) { - _haveScrollButtons = true; - Button *scrollUpButton = getScrollUpButton(); scrollUpButton->x = menu.scrollUpButtonX + menu.x; scrollUpButton->y = menu.scrollUpButtonY + menu.y; scrollUpButton->buttonCallback = getScrollUpButtonHandler(); scrollUpButton->nextButton = 0; + scrollUpButton->mouseWheel = -1; _menuButtonList = addButtonToList(_menuButtonList, scrollUpButton); updateMenuButton(scrollUpButton); @@ -164,11 +162,10 @@ void GUI::initMenu(Menu &menu) { scrollDownButton->y = menu.scrollDownButtonY + menu.y; scrollDownButton->buttonCallback = getScrollDownButtonHandler(); scrollDownButton->nextButton = 0; + scrollDownButton->mouseWheel = 1; _menuButtonList = addButtonToList(_menuButtonList, scrollDownButton); updateMenuButton(scrollDownButton); - } else { - _haveScrollButtons = false; } _screen->showMouse(); diff --git a/engines/kyra/gui.h b/engines/kyra/gui.h index 4e59f0ca78..8023cc4810 100644 --- a/engines/kyra/gui.h +++ b/engines/kyra/gui.h @@ -75,6 +75,8 @@ struct Button { uint16 flags2; + int8 mouseWheel; + Callback buttonCallback; }; @@ -140,7 +142,7 @@ public: virtual Button *addButtonToList(Button *list, Button *newButton); virtual void processButton(Button *button) = 0; - virtual int processButtonList(Button *buttonList, uint16 inputFlags) = 0; + virtual int processButtonList(Button *buttonList, uint16 inputFlags, int8 mouseWheel) = 0; virtual int redrawShadedButtonCallback(Button *button); virtual int redrawButtonCallback(Button *button); @@ -157,7 +159,6 @@ protected: TextDisplayer *_text; Button *_menuButtonList; - bool _haveScrollButtons; bool _displayMenu; bool _displaySubMenu; bool _cancelSubMenu; diff --git a/engines/kyra/gui_v1.cpp b/engines/kyra/gui_v1.cpp index 0c66064409..fab5db0a01 100644 --- a/engines/kyra/gui_v1.cpp +++ b/engines/kyra/gui_v1.cpp @@ -198,19 +198,19 @@ GUI_v1::~GUI_v1() { delete[] _menu; } -int GUI_v1::processButtonList(Button *list, uint16 inputFlag) { - if (_haveScrollButtons) { - if (_mouseWheel < 0) - scrollUp(&_scrollUpButton); - else if (_mouseWheel > 0) - scrollDown(&_scrollDownButton); - } +int GUI_v1::processButtonList(Button *list, uint16 inputFlag, int8 mouseWheel) { while (list) { if (list->flags & 8) { list = list->nextButton; continue; } + if (mouseWheel && list->mouseWheel == mouseWheel && list->buttonCallback) { + if ((*list->buttonCallback.get())(list)) { + break; + } + } + int x = list->x; int y = list->y; assert(_screen->getScreenDim(list->dimTableIndex) != 0); @@ -460,7 +460,7 @@ int GUI_v1::buttonMenuCallback(Button *caller) { while (_displayMenu && !_vm->_quitFlag) { Common::Point mouse = _vm->getMousePos(); processHighlights(_menu[_toplevelMenu], mouse.x, mouse.y); - processButtonList(_menuButtonList, 0); + processButtonList(_menuButtonList, 0, 0); getInput(); } @@ -584,7 +584,7 @@ int GUI_v1::saveGameMenu(Button *button) { getInput(); Common::Point mouse = _vm->getMousePos(); processHighlights(_menu[2], mouse.x, mouse.y); - processButtonList(_menuButtonList, 0); + processButtonList(_menuButtonList, 0, _mouseWheel); } _screen->loadPageFromDisk("SEENPAGE.TMP", 0); @@ -633,7 +633,7 @@ int GUI_v1::loadGameMenu(Button *button) { getInput(); Common::Point mouse = _vm->getMousePos(); processHighlights(_menu[2], mouse.x, mouse.y); - processButtonList(_menuButtonList, 0); + processButtonList(_menuButtonList, 0, _mouseWheel); } _screen->loadPageFromDisk("SEENPAGE.TMP", 0); @@ -722,7 +722,7 @@ int GUI_v1::saveGame(Button *button) { updateSavegameString(); Common::Point mouse = _vm->getMousePos(); processHighlights(_menu[3], mouse.x, mouse.y); - processButtonList(_menuButtonList, 0); + processButtonList(_menuButtonList, 0, 0); } if (_cancelSubMenu) { @@ -797,7 +797,7 @@ bool GUI_v1::quitConfirm(const char *str) { getInput(); Common::Point mouse = _vm->getMousePos(); processHighlights(_menu[1], mouse.x, mouse.y); - processButtonList(_menuButtonList, 0); + processButtonList(_menuButtonList, 0, 0); } _screen->loadPageFromDisk("SEENPAGE.TMP", 0); @@ -863,7 +863,7 @@ int GUI_v1::gameControlsMenu(Button *button) { getInput(); Common::Point mouse = _vm->getMousePos(); processHighlights(_menu[5], mouse.x, mouse.y); - processButtonList(_menuButtonList, 0); + processButtonList(_menuButtonList, 0, 0); } _screen->loadPageFromDisk("SEENPAGE.TMP", 0); diff --git a/engines/kyra/gui_v1.h b/engines/kyra/gui_v1.h index 5f6d438689..65ccad6eeb 100644 --- a/engines/kyra/gui_v1.h +++ b/engines/kyra/gui_v1.h @@ -44,7 +44,8 @@ namespace Kyra { button.y = h; \ button.width = i; \ button.height = j; \ - button.flags2 = k + button.flags2 = k; \ + button.mouseWheel = 0 #define GUI_V1_MENU(menu, a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q) \ menu.x = a; \ @@ -93,7 +94,7 @@ public: ~GUI_v1(); void processButton(Button *button); - int processButtonList(Button *buttonList, uint16 inputFlags); + int processButtonList(Button *buttonList, uint16 inputFlags, int8 mouseWheel); int buttonMenuCallback(Button *caller); private: diff --git a/engines/kyra/gui_v2.cpp b/engines/kyra/gui_v2.cpp index 300f9f116d..6ee6b1e4a5 100644 --- a/engines/kyra/gui_v2.cpp +++ b/engines/kyra/gui_v2.cpp @@ -140,7 +140,7 @@ void GUI_v2::processButton(Button *button) { _screen->updateScreen(); } -int GUI_v2::processButtonList(Button *buttonList, uint16 inputFlag) { +int GUI_v2::processButtonList(Button *buttonList, uint16 inputFlag, int8 mouseWheel) { static uint16 flagsModifier = 0; if (!buttonList) @@ -236,6 +236,12 @@ int GUI_v2::processButtonList(Button *buttonList, uint16 inputFlag) { } bool unk1 = false; + + if (mouseWheel && buttonList->mouseWheel == mouseWheel) { + progress = true; + unk1 = true; + } + if (!progress) buttonList->flags2 &= ~6; @@ -848,7 +854,7 @@ void GUI_v2::checkTextfieldInput() { } } - processButtonList(_menuButtonList, keys | 0x8000); + processButtonList(_menuButtonList, keys | 0x8000, 0); } void GUI_v2::drawTextfieldBlock(int x, int y, uint8 c) { diff --git a/engines/kyra/gui_v2.h b/engines/kyra/gui_v2.h index 55b7ee6d9a..378a3cd815 100644 --- a/engines/kyra/gui_v2.h +++ b/engines/kyra/gui_v2.h @@ -51,7 +51,8 @@ namespace Kyra { button.data1Val3 = q; \ button.data2Val2 = r; \ button.data2Val3 = s; \ - button.flags2 = t; + button.flags2 = t; \ + button.mouseWheel = 0 #define GUI_V2_MENU(menu, a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q) \ menu.x = a; \ @@ -103,7 +104,7 @@ public: Button *addButtonToList(Button *list, Button *newButton); void processButton(Button *button); - int processButtonList(Button *button, uint16 inputFlag); + int processButtonList(Button *button, uint16 inputFlag, int8 mouseWheel); protected: void updateButton(Button *button); diff --git a/engines/kyra/kyra_v1.cpp b/engines/kyra/kyra_v1.cpp index 693ea74a35..2504719ef5 100644 --- a/engines/kyra/kyra_v1.cpp +++ b/engines/kyra/kyra_v1.cpp @@ -430,7 +430,7 @@ void KyraEngine_v1::mainLoop() { _screen->showMouse(); - _gui->processButtonList(_buttonList, 0); + _gui->processButtonList(_buttonList, 0, 0); updateMousePointer(); _timer->update(); updateTextFade(); diff --git a/engines/kyra/kyra_v2.cpp b/engines/kyra/kyra_v2.cpp index a2911dec84..1e1a30dec8 100644 --- a/engines/kyra/kyra_v2.cpp +++ b/engines/kyra/kyra_v2.cpp @@ -115,6 +115,7 @@ int KyraEngine_v2::checkInput(Button *buttonList, bool mainLoop) { updateInput(); int keys = 0; + int8 mouseWheel = 0; while (_eventList.size()) { Common::Event event = *_eventList.begin(); @@ -156,6 +157,14 @@ int KyraEngine_v2::checkInput(Button *buttonList, bool mainLoop) { breakLoop = true; } break; + case Common::EVENT_WHEELUP: + mouseWheel = -1; + break; + + case Common::EVENT_WHEELDOWN: + mouseWheel = 1; + break; + default: break; } @@ -169,7 +178,7 @@ int KyraEngine_v2::checkInput(Button *buttonList, bool mainLoop) { _eventList.erase(_eventList.begin()); } - return gui_v2()->processButtonList(buttonList, keys | 0x8000); + return gui_v2()->processButtonList(buttonList, keys | 0x8000, mouseWheel); } void KyraEngine_v2::updateInput() { @@ -199,6 +208,8 @@ void KyraEngine_v2::updateInput() { // fall through case Common::EVENT_LBUTTONUP: + case Common::EVENT_WHEELUP: + case Common::EVENT_WHEELDOWN: _eventList.push_back(event); break; diff --git a/engines/kyra/script_v1.cpp b/engines/kyra/script_v1.cpp index a258482802..6eb02c7511 100644 --- a/engines/kyra/script_v1.cpp +++ b/engines/kyra/script_v1.cpp @@ -1378,7 +1378,7 @@ int KyraEngine_v1::o1_waitForConfirmationMouseClick(EMCState *script) { delay(10); } // } - _gui->processButtonList(_buttonList, 0); + _gui->processButtonList(_buttonList, 0, 0); _skipFlag = false; Common::Point mouse = getMousePos(); script->regs[1] = mouse.x; |