diff options
Diffstat (limited to 'engines')
-rw-r--r-- | engines/kyra/gui_hof.cpp | 331 | ||||
-rw-r--r-- | engines/kyra/gui_hof.h | 84 | ||||
-rw-r--r-- | engines/kyra/gui_mr.cpp | 332 | ||||
-rw-r--r-- | engines/kyra/gui_mr.h | 44 | ||||
-rw-r--r-- | engines/kyra/gui_v2.cpp | 387 | ||||
-rw-r--r-- | engines/kyra/gui_v2.h | 120 | ||||
-rw-r--r-- | engines/kyra/kyra_v2.h | 1 | ||||
-rw-r--r-- | engines/kyra/module.mk | 1 | ||||
-rw-r--r-- | engines/kyra/staticres.cpp | 12 |
9 files changed, 530 insertions, 782 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; diff --git a/engines/kyra/gui_hof.h b/engines/kyra/gui_hof.h index 637af761d3..f48f6c88c9 100644 --- a/engines/kyra/gui_hof.h +++ b/engines/kyra/gui_hof.h @@ -23,87 +23,21 @@ * */ -#ifndef KYRA_GUI_V2_H -#define KYRA_GUI_V2_H - -#include "kyra/gui.h" - -#define GUI_V2_BUTTON(button, a, b, c, d, e, f, h, i, j, k, l, m, n, o, p, q, r, s, t) \ - button.nextButton = 0; \ - button.index = a; \ - button.unk6 = b; \ - button.unk8 = c; \ - button.data0Val1 = d; \ - button.data1Val1 = e; \ - button.data2Val1 = f; \ - button.flags = h; \ - button.data0ShapePtr = button.data1ShapePtr = button.data2ShapePtr = 0; \ - button.dimTableIndex = i; \ - button.x = j; \ - button.y = k; \ - button.width = l; \ - button.height = m; \ - button.data0Val2 = n; \ - button.data0Val3 = o; \ - button.data1Val2 = p; \ - button.data1Val3 = q; \ - button.data2Val2 = r; \ - button.data2Val3 = s; \ - button.flags2 = t; - -#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.y = b; \ - menu.width = c; \ - menu.height = d; \ - menu.bkgdColor = e; \ - menu.color1 = f; \ - menu.color2 = g; \ - menu.menuNameId = h; \ - menu.textColor = i; \ - menu.titleX = j; \ - menu.titleY = k; \ - menu.highlightedItem = l; \ - menu.numberOfItems = m; \ - menu.scrollUpButtonX = n; \ - menu.scrollUpButtonY = o; \ - menu.scrollDownButtonX = p; \ - menu.scrollDownButtonY = q - -#define GUI_V2_MENU_ITEM(item, a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q) \ - item.enabled = a; \ - item.itemId = b; \ - item.x = c; \ - item.y = d; \ - item.width = e; \ - item.height = f; \ - item.textColor = g; \ - item.highlightColor = h; \ - item.titleX = i; \ - item.bkgdColor = j; \ - item.color1 = k; \ - item.color2 = l; \ - item.saveSlot = m; \ - item.labelId = n; \ - item.labelX = o; \ - item.labelY = p; \ - item.unk1F = q +#ifndef KYRA_GUI_HOF_H +#define KYRA_GUI_HOF_H + +#include "kyra/gui_v2.h" namespace Kyra { class KyraEngine_HoF; -class Screen_v2; +class Screen_HoF; -class GUI_HoF : public GUI { +class GUI_HoF : public GUI_v2 { friend class KyraEngine_HoF; public: GUI_HoF(KyraEngine_HoF *engine); - Button *addButtonToList(Button *list, Button *newButton); - - void processButton(Button *button); - int processButtonList(Button *button, uint16 inputFlag); - int optionsButton(Button *button); private: void getInput(); @@ -146,11 +80,7 @@ private: void resetState(int item); KyraEngine_HoF *_vm; - Screen_v2 *_screen; - - bool _buttonListChanged; - Button *_backUpButtonList; - Button *_unknownButtonList; + Screen_HoF *_screen; Menu *_currentMenu; bool _isLoadMenu; diff --git a/engines/kyra/gui_mr.cpp b/engines/kyra/gui_mr.cpp index 75bc58d646..7ca6bbae7a 100644 --- a/engines/kyra/gui_mr.cpp +++ b/engines/kyra/gui_mr.cpp @@ -607,337 +607,7 @@ int KyraEngine_MR::buttonJesterStaff(Button *button) { #pragma mark - -GUI_MR::GUI_MR(KyraEngine_MR *vm) : GUI(vm), _vm(vm), _screen(vm->_screen) { - _backUpButtonList = _unknownButtonList = 0; - _buttonListChanged = false; -} - -Button *GUI_MR::addButtonToList(Button *list, Button *newButton) { - list = GUI::addButtonToList(list, newButton); - _buttonListChanged = true; - return list; -} - -void GUI_MR::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_MR::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; +GUI_MR::GUI_MR(KyraEngine_MR *vm) : GUI_v2(vm), _vm(vm), _screen(vm->_screen) { } void GUI_MR::flagButtonEnable(Button *button) { diff --git a/engines/kyra/gui_mr.h b/engines/kyra/gui_mr.h index 1797021f91..5eeb829703 100644 --- a/engines/kyra/gui_mr.h +++ b/engines/kyra/gui_mr.h @@ -23,49 +23,21 @@ * */ -#ifndef KYRA_GUI_V3_H -#define KYRA_GUI_V3_H +#ifndef KYRA_GUI_MR_H +#define KYRA_GUI_MR_H -#include "kyra/gui.h" +#include "kyra/gui_v2.h" namespace Kyra { -#define GUI_V3_BUTTON(button, a, b, c, d, e, f, h, i, j, k, l, m, n, o, p, q, r, s, t) \ - button.nextButton = 0; \ - button.index = a; \ - button.unk6 = b; \ - button.unk8 = c; \ - button.data0Val1 = d; \ - button.data1Val1 = e; \ - button.data2Val1 = f; \ - button.flags = h; \ - button.data0ShapePtr = button.data1ShapePtr = button.data2ShapePtr = 0; \ - button.dimTableIndex = i; \ - button.x = j; \ - button.y = k; \ - button.width = l; \ - button.height = m; \ - button.data0Val2 = n; \ - button.data0Val3 = o; \ - button.data1Val2 = p; \ - button.data1Val3 = q; \ - button.data2Val2 = r; \ - button.data2Val3 = s; \ - button.flags2 = t; - class KyraEngine_MR; class Screen_MR; -class GUI_MR : public GUI { +class GUI_MR : public GUI_v2 { friend class KyraEngine_MR; public: GUI_MR(KyraEngine_MR *engine); - Button *addButtonToList(Button *list, Button *newButton); - - void processButton(Button *button); - int processButtonList(Button *button, uint16 inputFlag); - void flagButtonEnable(Button *button); void flagButtonDisable(Button *button); private: @@ -81,15 +53,11 @@ private: Button::Callback getScrollUpButtonHandler() const { return Button::Callback(); } Button::Callback getScrollDownButtonHandler() const { return Button::Callback(); } - uint8 defaultColor1() const { return 0xCF; } - uint8 defaultColor2() const { return 0xF8; } + uint8 defaultColor1() const { return 0xF0; } + uint8 defaultColor2() const { return 0xD0; } KyraEngine_MR *_vm; Screen_MR *_screen; - - bool _buttonListChanged; - Button *_backUpButtonList; - Button *_unknownButtonList; }; } // end of namespace Kyra diff --git a/engines/kyra/gui_v2.cpp b/engines/kyra/gui_v2.cpp new file mode 100644 index 0000000000..e449c6b22c --- /dev/null +++ b/engines/kyra/gui_v2.cpp @@ -0,0 +1,387 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * $URL$ + * $Id$ + * + */ + +#include "kyra/gui_v2.h" +#include "kyra/kyra_v2.h" +#include "kyra/screen_v2.h" + +namespace Kyra { + +GUI_v2::GUI_v2(KyraEngine_v2 *vm) : GUI(vm), _vm(vm), _screen(vm->screen_v2()) { + _backUpButtonList = _unknownButtonList = 0; + _buttonListChanged = false; +} + +Button *GUI_v2::addButtonToList(Button *list, Button *newButton) { + list = GUI::addButtonToList(list, newButton); + _buttonListChanged = true; + return list; +} + +void GUI_v2::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_v2::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; +} + +void GUI_v2::updateButton(Button *button) { + if (!button || (button->flags & 8)) + return; + + if (button->flags2 & 1) + button->flags2 |= 8; + else + button->flags2 |= ~8; + + button->flags2 &= ~1; + + if (button->flags2 & 4) + button->flags2 |= 0x10; + else + button->flags2 &= ~0x10; + + button->flags2 &= ~4; + + processButton(button); +} + +} // end of namespace Kyra + diff --git a/engines/kyra/gui_v2.h b/engines/kyra/gui_v2.h new file mode 100644 index 0000000000..3fdc64e34f --- /dev/null +++ b/engines/kyra/gui_v2.h @@ -0,0 +1,120 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * $URL$ + * $Id$ + * + */ + +#ifndef KYRA_GUI_V2_H +#define KYRA_GUI_V2_H + +#include "kyra/gui.h" + +namespace Kyra { + +#define GUI_V2_BUTTON(button, a, b, c, d, e, f, h, i, j, k, l, m, n, o, p, q, r, s, t) \ + button.nextButton = 0; \ + button.index = a; \ + button.unk6 = b; \ + button.unk8 = c; \ + button.data0Val1 = d; \ + button.data1Val1 = e; \ + button.data2Val1 = f; \ + button.flags = h; \ + button.data0ShapePtr = button.data1ShapePtr = button.data2ShapePtr = 0; \ + button.dimTableIndex = i; \ + button.x = j; \ + button.y = k; \ + button.width = l; \ + button.height = m; \ + button.data0Val2 = n; \ + button.data0Val3 = o; \ + button.data1Val2 = p; \ + button.data1Val3 = q; \ + button.data2Val2 = r; \ + button.data2Val3 = s; \ + button.flags2 = t; + +#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.y = b; \ + menu.width = c; \ + menu.height = d; \ + menu.bkgdColor = e; \ + menu.color1 = f; \ + menu.color2 = g; \ + menu.menuNameId = h; \ + menu.textColor = i; \ + menu.titleX = j; \ + menu.titleY = k; \ + menu.highlightedItem = l; \ + menu.numberOfItems = m; \ + menu.scrollUpButtonX = n; \ + menu.scrollUpButtonY = o; \ + menu.scrollDownButtonX = p; \ + menu.scrollDownButtonY = q + +#define GUI_V2_MENU_ITEM(item, a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q) \ + item.enabled = a; \ + item.itemId = b; \ + item.x = c; \ + item.y = d; \ + item.width = e; \ + item.height = f; \ + item.textColor = g; \ + item.highlightColor = h; \ + item.titleX = i; \ + item.bkgdColor = j; \ + item.color1 = k; \ + item.color2 = l; \ + item.saveSlot = m; \ + item.labelId = n; \ + item.labelX = o; \ + item.labelY = p; \ + item.unk1F = q + +class KyraEngine_v2; +class Screen_v2; + +class GUI_v2 : public GUI { +public: + GUI_v2(KyraEngine_v2 *vm); + + Button *addButtonToList(Button *list, Button *newButton); + + void processButton(Button *button); + int processButtonList(Button *button, uint16 inputFlag); + +protected: + void updateButton(Button *button); + + KyraEngine_v2 *_vm; + Screen_v2 *_screen; + + bool _buttonListChanged; + Button *_backUpButtonList; + Button *_unknownButtonList; +}; + +} // end of namespace Kyra + +#endif + diff --git a/engines/kyra/kyra_v2.h b/engines/kyra/kyra_v2.h index 8fe682b104..0dda0d9fc6 100644 --- a/engines/kyra/kyra_v2.h +++ b/engines/kyra/kyra_v2.h @@ -39,6 +39,7 @@ class Screen_v2; class KyraEngine_v2 : public KyraEngine { friend class Debugger_v2; +friend class GUI_v2; public: struct EngineDesc { // Generic shape related diff --git a/engines/kyra/module.mk b/engines/kyra/module.mk index 71461615ef..be8341d90c 100644 --- a/engines/kyra/module.mk +++ b/engines/kyra/module.mk @@ -9,6 +9,7 @@ MODULE_OBJS := \ detection.o \ gui.o \ gui_v1.o \ + gui_v2.o \ gui_hof.o \ gui_mr.o \ items_v1.o \ diff --git a/engines/kyra/staticres.cpp b/engines/kyra/staticres.cpp index 8d9818b856..a6b2588b7b 100644 --- a/engines/kyra/staticres.cpp +++ b/engines/kyra/staticres.cpp @@ -2445,22 +2445,22 @@ void KyraEngine_MR::initMainButtonList(bool disable) { _mainButtonData = new Button[14]; assert(_mainButtonData); - GUI_V3_BUTTON(_mainButtonData[0], 1, 0, 0, 4, 4, 4, 0x4487, 0, 5, 162, 50, 25, 0xFF, 0xF0, 0xFF, 0xF0, 0xFF, 0xF0, 0); - GUI_V3_BUTTON(_mainButtonData[1], 2, 0, 0, 1, 1, 1, 0x4487, 0, 245, 156, 69, 33, 0xFF, 0xF0, 0xFF, 0xF0, 0xFF, 0xF0, 0); + GUI_V2_BUTTON(_mainButtonData[0], 1, 0, 0, 4, 4, 4, 0x4487, 0, 5, 162, 50, 25, 0xFF, 0xF0, 0xFF, 0xF0, 0xFF, 0xF0, 0); + GUI_V2_BUTTON(_mainButtonData[1], 2, 0, 0, 1, 1, 1, 0x4487, 0, 245, 156, 69, 33, 0xFF, 0xF0, 0xFF, 0xF0, 0xFF, 0xF0, 0); _mainButtonData[1].buttonCallback = BUTTON_FUNCTOR(KyraEngine_MR, this, &KyraEngine_MR::buttonMoodChange); - GUI_V3_BUTTON(_mainButtonData[2], 3, 0, 0, 1, 1, 1, 0x4487, 0, 215, 191, 24, 9, 0xFF, 0xF0, 0xFF, 0xF0, 0xFF, 0xF0, 0); + GUI_V2_BUTTON(_mainButtonData[2], 3, 0, 0, 1, 1, 1, 0x4487, 0, 215, 191, 24, 9, 0xFF, 0xF0, 0xFF, 0xF0, 0xFF, 0xF0, 0); _mainButtonData[2].buttonCallback = BUTTON_FUNCTOR(KyraEngine_MR, this, &KyraEngine_MR::buttonShowScore); - GUI_V3_BUTTON(_mainButtonData[3], 4, 0, 0, 1, 1, 1, 0x4487, 0, 215, 155, 25, 36, 0xFF, 0xF0, 0xFF, 0xF0, 0xFF, 0xF0, 0); + GUI_V2_BUTTON(_mainButtonData[3], 4, 0, 0, 1, 1, 1, 0x4487, 0, 215, 155, 25, 36, 0xFF, 0xF0, 0xFF, 0xF0, 0xFF, 0xF0, 0); _mainButtonData[3].buttonCallback = BUTTON_FUNCTOR(KyraEngine_MR, this, &KyraEngine_MR::buttonJesterStaff); Button::Callback buttonInventoryFunctor = BUTTON_FUNCTOR(KyraEngine_MR, this, &KyraEngine_MR::buttonInventory); for (int i = 0; i < 5; ++i) { - GUI_V3_BUTTON(_mainButtonData[i+4], i+5, 0, 0, 0, 0, 0, 0x1100, 0, 67+i*28, 155, 27, 21, 0xFF, 0xF0, 0xFF, 0xF0, 0xFF, 0xF0, 0); + GUI_V2_BUTTON(_mainButtonData[i+4], i+5, 0, 0, 0, 0, 0, 0x1100, 0, 67+i*28, 155, 27, 21, 0xFF, 0xF0, 0xFF, 0xF0, 0xFF, 0xF0, 0); _mainButtonData[i+4].buttonCallback = buttonInventoryFunctor; } for (int i = 0; i < 5; ++i) { - GUI_V3_BUTTON(_mainButtonData[i+9], i+10, 0, 0, 0, 0, 0, 0x1100, 0, 67+i*28, 177, 27, 21, 0xFF, 0xF0, 0xFF, 0xF0, 0xFF, 0xF0, 0); + GUI_V2_BUTTON(_mainButtonData[i+9], i+10, 0, 0, 0, 0, 0, 0x1100, 0, 67+i*28, 177, 27, 21, 0xFF, 0xF0, 0xFF, 0xF0, 0xFF, 0xF0, 0); _mainButtonData[i+9].buttonCallback = buttonInventoryFunctor; } |