aboutsummaryrefslogtreecommitdiff
path: root/engines/kyra/gui_hof.cpp
diff options
context:
space:
mode:
authorJohannes Schickel2008-05-04 15:37:41 +0000
committerJohannes Schickel2008-05-04 15:37:41 +0000
commitc15ad0e373db42e2d9ca8d37c9ba799c6556c85b (patch)
treec037cdfb1d6b85011c3429f7f1ea01da9d5c89b3 /engines/kyra/gui_hof.cpp
parentf71b4afcfa9792bd3bb2f98cc26e4614f6594fcd (diff)
downloadscummvm-rg350-c15ad0e373db42e2d9ca8d37c9ba799c6556c85b.tar.gz
scummvm-rg350-c15ad0e373db42e2d9ca8d37c9ba799c6556c85b.tar.bz2
scummvm-rg350-c15ad0e373db42e2d9ca8d37c9ba799c6556c85b.zip
Initial common base between kyra2 and kyra3 GUI code.
svn-id: r31867
Diffstat (limited to 'engines/kyra/gui_hof.cpp')
-rw-r--r--engines/kyra/gui_hof.cpp331
1 files changed, 1 insertions, 330 deletions
diff --git a/engines/kyra/gui_hof.cpp b/engines/kyra/gui_hof.cpp
index 4449b7b9c8..9916104a30 100644
--- a/engines/kyra/gui_hof.cpp
+++ b/engines/kyra/gui_hof.cpp
@@ -80,8 +80,7 @@ void KyraEngine_HoF::setupLangButtonShapes() {
}
}
-GUI_HoF::GUI_HoF(KyraEngine_HoF *vm) : GUI(vm), _vm(vm), _screen(vm->screen_v2()) {
- _backUpButtonList = _unknownButtonList = 0;
+GUI_HoF::GUI_HoF(KyraEngine_HoF *vm) : GUI_v2(vm), _vm(vm), _screen(_vm->_screen) {
initStaticData();
_currentMenu = 0;
_isDeathMenu = false;
@@ -92,334 +91,6 @@ GUI_HoF::GUI_HoF(KyraEngine_HoF *vm) : GUI(vm), _vm(vm), _screen(vm->screen_v2()
_sliderHandlerFunctor = BUTTON_FUNCTOR(GUI_HoF, this, &GUI_HoF::sliderHandler);
}
-Button *GUI_HoF::addButtonToList(Button *list, Button *newButton) {
- list = GUI::addButtonToList(list, newButton);
- _buttonListChanged = true;
- return list;
-}
-
-void GUI_HoF::processButton(Button *button) {
- if (!button)
- return;
-
- if (button->flags & 8) {
- if (button->flags & 0x10) {
- // XXX
- }
- return;
- }
-
- int entry = button->flags2 & 5;
-
- byte val1 = 0, val2 = 0, val3 = 0;
- const uint8 *dataPtr = 0;
- Button::Callback callback;
- if (entry == 1) {
- val1 = button->data1Val1;
- dataPtr = button->data1ShapePtr;
- callback = button->data1Callback;
- val2 = button->data1Val2;
- val3 = button->data1Val3;
- } else if (entry == 4 || entry == 5) {
- val1 = button->data2Val1;
- dataPtr = button->data2ShapePtr;
- callback = button->data2Callback;
- val2 = button->data2Val2;
- val3 = button->data2Val3;
- } else {
- val1 = button->data0Val1;
- dataPtr = button->data0ShapePtr;
- callback = button->data0Callback;
- val2 = button->data0Val2;
- val3 = button->data0Val3;
- }
-
- int x = 0, y = 0, x2 = 0, y2 = 0;
-
- x = button->x;
- if (x < 0)
- x += _screen->getScreenDim(button->dimTableIndex)->w << 3;
- x += _screen->getScreenDim(button->dimTableIndex)->sx << 3;
- x2 = x + button->width - 1;
-
- y = button->y;
- if (y < 0)
- y += _screen->getScreenDim(button->dimTableIndex)->h << 3;
- y += _screen->getScreenDim(button->dimTableIndex)->sy << 3;
- y2 = y + button->height - 1;
-
- switch (val1 - 1) {
- case 0:
- _screen->hideMouse();
- _screen->drawShape(_screen->_curPage, dataPtr, x, y, button->dimTableIndex, 0x10);
- _screen->showMouse();
- break;
-
- case 1:
- _screen->hideMouse();
- _screen->printText((const char*)dataPtr, x, y, val2, val3);
- _screen->showMouse();
- break;
-
- case 3:
- if (callback)
- (*callback)(button);
- break;
-
- case 4:
- _screen->hideMouse();
- _screen->drawBox(x, y, x2, y2, val2);
- _screen->showMouse();
- break;
-
- case 5:
- _screen->hideMouse();
- _screen->fillRect(x, y, x2, y2, val2, -1, true);
- _screen->showMouse();
- break;
-
- default:
- break;
- }
-
- _screen->updateScreen();
-}
-
-int GUI_HoF::processButtonList(Button *buttonList, uint16 inputFlag) {
- static uint16 flagsModifier = 0;
-
- if (!buttonList)
- return inputFlag & 0x7FFF;
-
- if (_backUpButtonList != buttonList || _buttonListChanged) {
- _unknownButtonList = 0;
- //flagsModifier |= 0x2200;
- _backUpButtonList = buttonList;
- _buttonListChanged = false;
-
- while (buttonList) {
- processButton(buttonList);
- buttonList = buttonList->nextButton;
- }
- }
-
- int mouseX = _vm->_mouseX;
- int mouseY = _vm->_mouseY;
-
- uint16 flags = 0;
-
- if (1/*!_screen_cursorDisable*/) {
- uint16 inFlags = inputFlag & 0xFF;
- uint16 temp = 0;
-
- // HACK: inFlags == 200 is our left button (up)
- if (inFlags == 199 || inFlags == 200)
- temp = 0x1000;
- if (inFlags == 198)
- temp = 0x100;
-
- if (inputFlag & 0x800)
- temp <<= 2;
-
- flags |= temp;
-
- flagsModifier &= ~((temp & 0x4400) >> 1);
- flagsModifier |= (temp & 0x1100) * 2;
- flags |= flagsModifier;
- flags |= (flagsModifier << 2) ^ 0x8800;
- }
-
- buttonList = _backUpButtonList;
- if (_unknownButtonList) {
- buttonList = _unknownButtonList;
- if (_unknownButtonList->flags & 8)
- _unknownButtonList = 0;
- }
-
- int returnValue = 0;
- while (buttonList) {
- if (buttonList->flags & 8) {
- buttonList = buttonList->nextButton;
- continue;
- }
- buttonList->flags2 &= ~0x18;
- buttonList->flags2 |= (buttonList->flags2 & 3) << 3;
-
- int x = buttonList->x;
- if (x < 0)
- x += _screen->getScreenDim(buttonList->dimTableIndex)->w << 3;
- x += _screen->getScreenDim(buttonList->dimTableIndex)->sx << 3;
-
- int y = buttonList->y;
- if (y < 0)
- y += _screen->getScreenDim(buttonList->dimTableIndex)->h;
- y += _screen->getScreenDim(buttonList->dimTableIndex)->sy;
-
- bool progress = false;
-
- if (mouseX >= x && mouseY >= y && mouseX <= x+buttonList->width && mouseY <= y+buttonList->height)
- progress = true;
-
- buttonList->flags2 &= ~0x80;
- uint16 inFlags = inputFlag & 0x7FFF;
- if (inFlags) {
- if (buttonList->unk6 == inFlags) {
- progress = true;
- flags = buttonList->flags & 0x0F00;
- buttonList->flags2 |= 0x80;
- inputFlag = 0;
- _unknownButtonList = buttonList;
- } else if (buttonList->unk8 == inFlags) {
- flags = buttonList->flags & 0xF000;
- if (!flags)
- flags = buttonList->flags & 0x0F00;
- progress = true;
- buttonList->flags2 |= 0x80;
- inputFlag = 0;
- _unknownButtonList = buttonList;
- }
- }
-
- bool unk1 = false;
- if (!progress)
- buttonList->flags2 &= ~6;
-
- if ((flags & 0x3300) && (buttonList->flags & 4) && progress && (buttonList == _unknownButtonList || !_unknownButtonList)) {
- buttonList->flags |= 6;
- if (!_unknownButtonList)
- _unknownButtonList = buttonList;
- } else if ((flags & 0x8800) && !(buttonList->flags & 4) && progress) {
- buttonList->flags2 |= 6;
- } else {
- buttonList->flags2 &= ~6;
- }
-
- bool progressSwitch = false;
- if (!_unknownButtonList) {
- progressSwitch = progress;
- } else {
- if (_unknownButtonList->flags & 0x40)
- progressSwitch = (_unknownButtonList == buttonList);
- else
- progressSwitch = progress;
- }
-
- if (progressSwitch) {
- if ((flags & 0x1100) && progress && !_unknownButtonList) {
- inputFlag = 0;
- _unknownButtonList = buttonList;
- }
-
- if ((buttonList->flags & flags) && (progress || !(buttonList->flags & 1))) {
- uint16 combinedFlags = (buttonList->flags & flags);
- combinedFlags = ((combinedFlags & 0xF000) >> 4) | (combinedFlags & 0x0F00);
- combinedFlags >>= 8;
-
- static const uint16 flagTable[] = {
- 0x000, 0x100, 0x200, 0x100, 0x400, 0x100, 0x400, 0x100, 0x800, 0x100,
- 0x200, 0x100, 0x400, 0x100, 0x400, 0x100
- };
-
- assert(combinedFlags < ARRAYSIZE(flagTable));
-
- switch (flagTable[combinedFlags]) {
- case 0x400:
- if (!(buttonList->flags & 1) || ((buttonList->flags & 1) && _unknownButtonList == buttonList)) {
- buttonList->flags2 ^= 1;
- returnValue = buttonList->index | 0x8000;
- unk1 = true;
- }
-
- if (!(buttonList->flags & 4)) {
- buttonList->flags2 &= ~4;
- buttonList->flags2 &= ~2;
- }
- break;
-
- case 0x800:
- if (!(buttonList->flags & 4)) {
- buttonList->flags2 |= 4;
- buttonList->flags2 |= 2;
- }
-
- if (!(buttonList->flags & 1))
- unk1 = true;
- break;
-
- case 0x200:
- if (buttonList->flags & 4) {
- buttonList->flags2 |= 4;
- buttonList->flags2 |= 2;
- }
-
- if (!(buttonList->flags & 1))
- unk1 = true;
- break;
-
- case 0x100:
- default:
- buttonList->flags2 ^= 1;
- returnValue = buttonList->index | 0x8000;
- unk1 = true;
- if (buttonList->flags & 4) {
- buttonList->flags2 |= 4;
- buttonList->flags2 |= 2;
- }
- _unknownButtonList = buttonList;
- break;
- }
- }
- }
-
- bool unk2 = false;
- if ((flags & 0x2200) && progress) {
- buttonList->flags2 |= 6;
- if (!(buttonList->flags & 4) && !(buttonList->flags2 & 1)) {
- unk2 = true;
- buttonList->flags2 |= 1;
- }
- }
-
- if ((flags & 0x8800) == 0x8800) {
- _unknownButtonList = 0;
- if (!progress || (buttonList->flags & 4))
- buttonList->flags2 &= ~6;
- }
-
- if (!progress && buttonList == _unknownButtonList && !(buttonList->flags & 0x40))
- _unknownButtonList = 0;
-
- if ((buttonList->flags2 & 0x18) != ((buttonList->flags2 & 3) << 3))
- processButton(buttonList);
-
- if (unk2)
- buttonList->flags2 &= ~1;
-
- if (unk1) {
- buttonList->flags2 &= 0xFF;
- buttonList->flags2 |= flags;
-
- if (buttonList->buttonCallback) {
- _vm->removeInputTop();
- if ((*buttonList->buttonCallback.get())(buttonList))
- break;
- }
-
- if (buttonList->flags & 0x20)
- break;
- }
-
- if (_unknownButtonList == buttonList && (buttonList->flags & 0x40))
- break;
-
- buttonList = buttonList->nextButton;
- }
-
- if (!returnValue)
- returnValue = inputFlag & 0x7FFF;
- return returnValue;
-}
-
const char *GUI_HoF::getMenuTitle(const Menu &menu) {
if (!menu.menuNameId)
return 0;