diff options
Diffstat (limited to 'engines/kyra/gui_mr.cpp')
-rw-r--r-- | engines/kyra/gui_mr.cpp | 332 |
1 files changed, 1 insertions, 331 deletions
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) { |