Committed slightly modified patch #1961830 "KYRA: Scroll wheel support for Kyra 2 and 3".

svn-id: r32016
This commit is contained in:
Johannes Schickel 2008-05-11 11:35:12 +00:00
parent 7da27cf28c
commit 35cc3a3d19
9 changed files with 46 additions and 29 deletions

View file

@ -36,7 +36,6 @@ namespace Kyra {
GUI::GUI(KyraEngine *kyra) GUI::GUI(KyraEngine *kyra)
: _vm(kyra), _screen(kyra->screen()), _text(kyra->text()) { : _vm(kyra), _screen(kyra->screen()), _text(kyra->text()) {
_menuButtonList = 0; _menuButtonList = 0;
_haveScrollButtons = false;
_redrawButtonFunctor = BUTTON_FUNCTOR(GUI, this, &GUI::redrawButtonCallback); _redrawButtonFunctor = BUTTON_FUNCTOR(GUI, this, &GUI::redrawButtonCallback);
_redrawShadedButtonFunctor = BUTTON_FUNCTOR(GUI, this, &GUI::redrawShadedButtonCallback); _redrawShadedButtonFunctor = BUTTON_FUNCTOR(GUI, this, &GUI::redrawShadedButtonCallback);
@ -148,13 +147,12 @@ void GUI::initMenu(Menu &menu) {
} }
if (menu.scrollUpButtonX != -1) { if (menu.scrollUpButtonX != -1) {
_haveScrollButtons = true;
Button *scrollUpButton = getScrollUpButton(); Button *scrollUpButton = getScrollUpButton();
scrollUpButton->x = menu.scrollUpButtonX + menu.x; scrollUpButton->x = menu.scrollUpButtonX + menu.x;
scrollUpButton->y = menu.scrollUpButtonY + menu.y; scrollUpButton->y = menu.scrollUpButtonY + menu.y;
scrollUpButton->buttonCallback = getScrollUpButtonHandler(); scrollUpButton->buttonCallback = getScrollUpButtonHandler();
scrollUpButton->nextButton = 0; scrollUpButton->nextButton = 0;
scrollUpButton->mouseWheel = -1;
_menuButtonList = addButtonToList(_menuButtonList, scrollUpButton); _menuButtonList = addButtonToList(_menuButtonList, scrollUpButton);
updateMenuButton(scrollUpButton); updateMenuButton(scrollUpButton);
@ -164,11 +162,10 @@ void GUI::initMenu(Menu &menu) {
scrollDownButton->y = menu.scrollDownButtonY + menu.y; scrollDownButton->y = menu.scrollDownButtonY + menu.y;
scrollDownButton->buttonCallback = getScrollDownButtonHandler(); scrollDownButton->buttonCallback = getScrollDownButtonHandler();
scrollDownButton->nextButton = 0; scrollDownButton->nextButton = 0;
scrollDownButton->mouseWheel = 1;
_menuButtonList = addButtonToList(_menuButtonList, scrollDownButton); _menuButtonList = addButtonToList(_menuButtonList, scrollDownButton);
updateMenuButton(scrollDownButton); updateMenuButton(scrollDownButton);
} else {
_haveScrollButtons = false;
} }
_screen->showMouse(); _screen->showMouse();

View file

@ -75,6 +75,8 @@ struct Button {
uint16 flags2; uint16 flags2;
int8 mouseWheel;
Callback buttonCallback; Callback buttonCallback;
}; };
@ -140,7 +142,7 @@ public:
virtual Button *addButtonToList(Button *list, Button *newButton); virtual Button *addButtonToList(Button *list, Button *newButton);
virtual void processButton(Button *button) = 0; 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 redrawShadedButtonCallback(Button *button);
virtual int redrawButtonCallback(Button *button); virtual int redrawButtonCallback(Button *button);
@ -157,7 +159,6 @@ protected:
TextDisplayer *_text; TextDisplayer *_text;
Button *_menuButtonList; Button *_menuButtonList;
bool _haveScrollButtons;
bool _displayMenu; bool _displayMenu;
bool _displaySubMenu; bool _displaySubMenu;
bool _cancelSubMenu; bool _cancelSubMenu;

View file

@ -198,19 +198,19 @@ GUI_v1::~GUI_v1() {
delete[] _menu; delete[] _menu;
} }
int GUI_v1::processButtonList(Button *list, uint16 inputFlag) { int GUI_v1::processButtonList(Button *list, uint16 inputFlag, int8 mouseWheel) {
if (_haveScrollButtons) {
if (_mouseWheel < 0)
scrollUp(&_scrollUpButton);
else if (_mouseWheel > 0)
scrollDown(&_scrollDownButton);
}
while (list) { while (list) {
if (list->flags & 8) { if (list->flags & 8) {
list = list->nextButton; list = list->nextButton;
continue; continue;
} }
if (mouseWheel && list->mouseWheel == mouseWheel && list->buttonCallback) {
if ((*list->buttonCallback.get())(list)) {
break;
}
}
int x = list->x; int x = list->x;
int y = list->y; int y = list->y;
assert(_screen->getScreenDim(list->dimTableIndex) != 0); assert(_screen->getScreenDim(list->dimTableIndex) != 0);
@ -460,7 +460,7 @@ int GUI_v1::buttonMenuCallback(Button *caller) {
while (_displayMenu && !_vm->_quitFlag) { while (_displayMenu && !_vm->_quitFlag) {
Common::Point mouse = _vm->getMousePos(); Common::Point mouse = _vm->getMousePos();
processHighlights(_menu[_toplevelMenu], mouse.x, mouse.y); processHighlights(_menu[_toplevelMenu], mouse.x, mouse.y);
processButtonList(_menuButtonList, 0); processButtonList(_menuButtonList, 0, 0);
getInput(); getInput();
} }
@ -584,7 +584,7 @@ int GUI_v1::saveGameMenu(Button *button) {
getInput(); getInput();
Common::Point mouse = _vm->getMousePos(); Common::Point mouse = _vm->getMousePos();
processHighlights(_menu[2], mouse.x, mouse.y); processHighlights(_menu[2], mouse.x, mouse.y);
processButtonList(_menuButtonList, 0); processButtonList(_menuButtonList, 0, _mouseWheel);
} }
_screen->loadPageFromDisk("SEENPAGE.TMP", 0); _screen->loadPageFromDisk("SEENPAGE.TMP", 0);
@ -633,7 +633,7 @@ int GUI_v1::loadGameMenu(Button *button) {
getInput(); getInput();
Common::Point mouse = _vm->getMousePos(); Common::Point mouse = _vm->getMousePos();
processHighlights(_menu[2], mouse.x, mouse.y); processHighlights(_menu[2], mouse.x, mouse.y);
processButtonList(_menuButtonList, 0); processButtonList(_menuButtonList, 0, _mouseWheel);
} }
_screen->loadPageFromDisk("SEENPAGE.TMP", 0); _screen->loadPageFromDisk("SEENPAGE.TMP", 0);
@ -722,7 +722,7 @@ int GUI_v1::saveGame(Button *button) {
updateSavegameString(); updateSavegameString();
Common::Point mouse = _vm->getMousePos(); Common::Point mouse = _vm->getMousePos();
processHighlights(_menu[3], mouse.x, mouse.y); processHighlights(_menu[3], mouse.x, mouse.y);
processButtonList(_menuButtonList, 0); processButtonList(_menuButtonList, 0, 0);
} }
if (_cancelSubMenu) { if (_cancelSubMenu) {
@ -797,7 +797,7 @@ bool GUI_v1::quitConfirm(const char *str) {
getInput(); getInput();
Common::Point mouse = _vm->getMousePos(); Common::Point mouse = _vm->getMousePos();
processHighlights(_menu[1], mouse.x, mouse.y); processHighlights(_menu[1], mouse.x, mouse.y);
processButtonList(_menuButtonList, 0); processButtonList(_menuButtonList, 0, 0);
} }
_screen->loadPageFromDisk("SEENPAGE.TMP", 0); _screen->loadPageFromDisk("SEENPAGE.TMP", 0);
@ -863,7 +863,7 @@ int GUI_v1::gameControlsMenu(Button *button) {
getInput(); getInput();
Common::Point mouse = _vm->getMousePos(); Common::Point mouse = _vm->getMousePos();
processHighlights(_menu[5], mouse.x, mouse.y); processHighlights(_menu[5], mouse.x, mouse.y);
processButtonList(_menuButtonList, 0); processButtonList(_menuButtonList, 0, 0);
} }
_screen->loadPageFromDisk("SEENPAGE.TMP", 0); _screen->loadPageFromDisk("SEENPAGE.TMP", 0);

View file

@ -44,7 +44,8 @@ namespace Kyra {
button.y = h; \ button.y = h; \
button.width = i; \ button.width = i; \
button.height = j; \ 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) \ #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; \ menu.x = a; \
@ -93,7 +94,7 @@ public:
~GUI_v1(); ~GUI_v1();
void processButton(Button *button); void processButton(Button *button);
int processButtonList(Button *buttonList, uint16 inputFlags); int processButtonList(Button *buttonList, uint16 inputFlags, int8 mouseWheel);
int buttonMenuCallback(Button *caller); int buttonMenuCallback(Button *caller);
private: private:

View file

@ -140,7 +140,7 @@ void GUI_v2::processButton(Button *button) {
_screen->updateScreen(); _screen->updateScreen();
} }
int GUI_v2::processButtonList(Button *buttonList, uint16 inputFlag) { int GUI_v2::processButtonList(Button *buttonList, uint16 inputFlag, int8 mouseWheel) {
static uint16 flagsModifier = 0; static uint16 flagsModifier = 0;
if (!buttonList) if (!buttonList)
@ -236,6 +236,12 @@ int GUI_v2::processButtonList(Button *buttonList, uint16 inputFlag) {
} }
bool unk1 = false; bool unk1 = false;
if (mouseWheel && buttonList->mouseWheel == mouseWheel) {
progress = true;
unk1 = true;
}
if (!progress) if (!progress)
buttonList->flags2 &= ~6; 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) { void GUI_v2::drawTextfieldBlock(int x, int y, uint8 c) {

View file

@ -51,7 +51,8 @@ namespace Kyra {
button.data1Val3 = q; \ button.data1Val3 = q; \
button.data2Val2 = r; \ button.data2Val2 = r; \
button.data2Val3 = s; \ 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) \ #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; \ menu.x = a; \
@ -103,7 +104,7 @@ public:
Button *addButtonToList(Button *list, Button *newButton); Button *addButtonToList(Button *list, Button *newButton);
void processButton(Button *button); void processButton(Button *button);
int processButtonList(Button *button, uint16 inputFlag); int processButtonList(Button *button, uint16 inputFlag, int8 mouseWheel);
protected: protected:
void updateButton(Button *button); void updateButton(Button *button);

View file

@ -430,7 +430,7 @@ void KyraEngine_v1::mainLoop() {
_screen->showMouse(); _screen->showMouse();
_gui->processButtonList(_buttonList, 0); _gui->processButtonList(_buttonList, 0, 0);
updateMousePointer(); updateMousePointer();
_timer->update(); _timer->update();
updateTextFade(); updateTextFade();

View file

@ -115,6 +115,7 @@ int KyraEngine_v2::checkInput(Button *buttonList, bool mainLoop) {
updateInput(); updateInput();
int keys = 0; int keys = 0;
int8 mouseWheel = 0;
while (_eventList.size()) { while (_eventList.size()) {
Common::Event event = *_eventList.begin(); Common::Event event = *_eventList.begin();
@ -156,6 +157,14 @@ int KyraEngine_v2::checkInput(Button *buttonList, bool mainLoop) {
breakLoop = true; breakLoop = true;
} break; } break;
case Common::EVENT_WHEELUP:
mouseWheel = -1;
break;
case Common::EVENT_WHEELDOWN:
mouseWheel = 1;
break;
default: default:
break; break;
} }
@ -169,7 +178,7 @@ int KyraEngine_v2::checkInput(Button *buttonList, bool mainLoop) {
_eventList.erase(_eventList.begin()); _eventList.erase(_eventList.begin());
} }
return gui_v2()->processButtonList(buttonList, keys | 0x8000); return gui_v2()->processButtonList(buttonList, keys | 0x8000, mouseWheel);
} }
void KyraEngine_v2::updateInput() { void KyraEngine_v2::updateInput() {
@ -199,6 +208,8 @@ void KyraEngine_v2::updateInput() {
// fall through // fall through
case Common::EVENT_LBUTTONUP: case Common::EVENT_LBUTTONUP:
case Common::EVENT_WHEELUP:
case Common::EVENT_WHEELDOWN:
_eventList.push_back(event); _eventList.push_back(event);
break; break;

View file

@ -1378,7 +1378,7 @@ int KyraEngine_v1::o1_waitForConfirmationMouseClick(EMCState *script) {
delay(10); delay(10);
} }
// } // }
_gui->processButtonList(_buttonList, 0); _gui->processButtonList(_buttonList, 0, 0);
_skipFlag = false; _skipFlag = false;
Common::Point mouse = getMousePos(); Common::Point mouse = getMousePos();
script->regs[1] = mouse.x; script->regs[1] = mouse.x;