| 30 | static ScummVM::Rect v2_mouseover_boxes[7]; |
| 31 | static int8 v2_mouseover_box = -1; |
| 32 | |
| 33 | void Scumm::initV2MouseOver() { |
| 34 | int i; |
| 35 | |
| 36 | v2_mouseover_box = -1; |
| 37 | |
| 38 | // Inventory items |
| 39 | for (i = 0; i < 2; i++) { |
| 40 | v2_mouseover_boxes[i].left = 0; |
| 41 | v2_mouseover_boxes[i].right = 120; |
| 42 | v2_mouseover_boxes[i].top = 34 + 8 * i; |
| 43 | v2_mouseover_boxes[i].bottom = v2_mouseover_boxes[i].top + 8; |
| 44 | |
| 45 | v2_mouseover_boxes[i + 2].left = 200; |
| 46 | v2_mouseover_boxes[i + 2].right = 320; |
| 47 | v2_mouseover_boxes[i + 2].top = v2_mouseover_boxes[i].top; |
| 48 | v2_mouseover_boxes[i + 2].bottom = v2_mouseover_boxes[i].bottom; |
| 49 | } |
| 50 | |
| 51 | // Inventory arrows |
| 52 | |
| 53 | v2_mouseover_boxes[4].left = 145; |
| 54 | v2_mouseover_boxes[4].right = 161; |
| 55 | v2_mouseover_boxes[4].top = 32; |
| 56 | v2_mouseover_boxes[4].bottom = 40; |
| 57 | |
| 58 | v2_mouseover_boxes[5].left = 145; |
| 59 | v2_mouseover_boxes[5].right = 161; |
| 60 | v2_mouseover_boxes[5].top = 47; |
| 61 | v2_mouseover_boxes[5].bottom = 55; |
| 62 | |
| 63 | // Sentence line |
| 64 | |
| 65 | v2_mouseover_boxes[6].left = 0; |
| 66 | v2_mouseover_boxes[6].right = 320; |
| 67 | v2_mouseover_boxes[6].top = 0; |
| 68 | v2_mouseover_boxes[6].bottom = 8; |
| 69 | } |
| 70 | |
| 71 | void Scumm::checkV2MouseOver(ScummVM::Point pos) { |
| 72 | VirtScreen *vs = &virtscr[2]; |
| 73 | ScummVM::Rect rect; |
| 74 | byte *ptr, *dst; |
| 75 | int i, x, y, new_box = -1; |
| 76 | |
| 77 | // Don't do anything unless the inventory is active |
| 78 | if (!(_userState & 64)) { |
| 79 | v2_mouseover_box = -1; |
| 80 | return; |
| 81 | } |
| 82 | |
| 83 | if (_cursor.state > 0) { |
| 84 | for (i = 0; i < ARRAYSIZE(v2_mouseover_boxes); i++) { |
| 85 | rect = v2_mouseover_boxes[i]; |
| 86 | |
| 87 | if (rect.contains(pos.x, pos.y - vs->topline)) { |
| 88 | new_box = i; |
| 89 | break; |
| 90 | } |
| 91 | } |
| 92 | } |
| 93 | |
| 94 | if (new_box != v2_mouseover_box) { |
| 95 | if (v2_mouseover_box != -1) { |
| 96 | rect = v2_mouseover_boxes[v2_mouseover_box]; |
| 97 | |
| 98 | dst = ptr = vs->screenPtr + vs->xstart + rect.top * _screenWidth + rect.left; |
| 99 | |
| 100 | for (y = rect.height() - 1; y >= 0; y--) { |
| 101 | for (x = rect.width() - 1; x >= 0; x--) { |
| 102 | if (dst[x] == 14) |
| 103 | dst[x] = 5; |
| 104 | } |
| 105 | dst += _screenWidth; |
| 106 | } |
| 107 | |
| 108 | updateDirtyRect(2, rect.left, rect.right, rect.top, rect.bottom, 0); |
| 109 | } |
| 110 | |
| 111 | if (new_box != -1) { |
| 112 | rect = v2_mouseover_boxes[new_box]; |
| 113 | |
| 114 | dst = ptr = vs->screenPtr + vs->xstart + rect.top * _screenWidth + rect.left; |
| 115 | |
| 116 | for (y = rect.height() - 1; y >= 0; y--) { |
| 117 | for (x = rect.width() - 1; x >= 0; x--) { |
| 118 | if (dst[x] == 5) |
| 119 | dst[x] = 14; |
| 120 | } |
| 121 | dst += _screenWidth; |
| 122 | } |
| 123 | |
| 124 | updateDirtyRect(2, rect.left, rect.right, rect.top, rect.bottom, 0); |
| 125 | } |
| 126 | |
| 127 | v2_mouseover_box = new_box; |
| 128 | } |
| 129 | } |
| 130 | |