* Gets the slot located in the specified mouse position. * @param x Mouse X position. Returns the slot's X position. * @param y Mouse Y position. Returns the slot's Y position. * @return True if there's a slot there. */
| 133 | * @return True if there's a slot there. |
| 134 | */ |
| 135 | bool RuleInventory::checkSlotInPosition(int *x, int *y) const |
| 136 | { |
| 137 | int mouseX = *x, mouseY = *y; |
| 138 | if (_type == INV_HAND) |
| 139 | { |
| 140 | for (int xx = 0; xx < HAND_W; ++xx) |
| 141 | { |
| 142 | for (int yy = 0; yy < HAND_H; ++yy) |
| 143 | { |
| 144 | if (mouseX >= _x + xx * SLOT_W && mouseX < _x + (xx + 1) * SLOT_W && |
| 145 | mouseY >= _y + yy * SLOT_H && mouseY < _y + (yy + 1) * SLOT_H) |
| 146 | { |
| 147 | *x = 0; |
| 148 | *y = 0; |
| 149 | return true; |
| 150 | } |
| 151 | } |
| 152 | } |
| 153 | } |
| 154 | else if (_type == INV_GROUND) |
| 155 | { |
| 156 | if (mouseX >= _x && mouseX < 320 && mouseY >= _y && mouseY < 200) |
| 157 | { |
| 158 | *x = (int)floor(double(mouseX - _x) / SLOT_W); |
| 159 | *y = (int)floor(double(mouseY - _y) / SLOT_H); |
| 160 | return true; |
| 161 | } |
| 162 | } |
| 163 | else |
| 164 | { |
| 165 | for (std::vector<RuleSlot>::const_iterator i = _slots.begin(); i != _slots.end(); ++i) |
| 166 | { |
| 167 | if (mouseX >= _x + i->x * SLOT_W && mouseX < _x + (i->x + 1) * SLOT_W && |
| 168 | mouseY >= _y + i->y * SLOT_H && mouseY < _y + (i->y + 1) * SLOT_H) |
| 169 | { |
| 170 | *x = i->x; |
| 171 | *y = i->y; |
| 172 | return true; |
| 173 | } |
| 174 | } |
| 175 | } |
| 176 | return false; |
| 177 | } |
| 178 | |
| 179 | /** |
| 180 | * Checks if an item completely fits when |