move the cursor around in our inventory if mouse coords are at SLOTXY_CHEST_LAST, consider this center of equipment small inventory squares are 29x29 (roughly)
| 484 | // if mouse coords are at SLOTXY_CHEST_LAST, consider this center of equipment |
| 485 | // small inventory squares are 29x29 (roughly) |
| 486 | void InvMove(MoveDirection dir) |
| 487 | { |
| 488 | DWORD ticks = SDL_GetTicks(); |
| 489 | if (ticks - invmove < repeatRate) { |
| 490 | return; |
| 491 | } |
| 492 | invmove = ticks; |
| 493 | int x = MouseX; |
| 494 | int y = MouseY; |
| 495 | |
| 496 | // check which inventory rectangle the mouse is in, if any |
| 497 | for (int r = 0; (DWORD)r < NUM_XY_SLOTS; r++) { |
| 498 | if (x >= InvRect[r].X && x < InvRect[r].X + (INV_SLOT_SIZE_PX + 1) && y >= InvRect[r].Y - (INV_SLOT_SIZE_PX + 1) && y < InvRect[r].Y) { |
| 499 | slot = r; |
| 500 | break; |
| 501 | } |
| 502 | } |
| 503 | |
| 504 | if (slot < 0) |
| 505 | slot = 0; |
| 506 | if (slot > SLOTXY_BELT_LAST) |
| 507 | slot = SLOTXY_BELT_LAST; |
| 508 | |
| 509 | // when item is on cursor, this is the real cursor XY |
| 510 | if (dir.x == MoveDirectionX::LEFT) { |
| 511 | if (slot >= SLOTXY_HAND_RIGHT_FIRST && slot <= SLOTXY_HAND_RIGHT_LAST) { |
| 512 | x = InvRect[SLOTXY_CHEST_FIRST].X + (INV_SLOT_SIZE_PX / 2); |
| 513 | y = InvRect[SLOTXY_CHEST_FIRST].Y - (INV_SLOT_SIZE_PX / 2); |
| 514 | } else if (slot >= SLOTXY_CHEST_FIRST && slot <= SLOTXY_CHEST_LAST) { |
| 515 | x = InvRect[SLOTXY_HAND_LEFT_FIRST + 2].X + (INV_SLOT_SIZE_PX / 2); |
| 516 | y = InvRect[SLOTXY_HAND_LEFT_FIRST + 2].Y - (INV_SLOT_SIZE_PX / 2); |
| 517 | } else if (slot == SLOTXY_AMULET) { |
| 518 | x = InvRect[SLOTXY_HEAD_FIRST].X + (INV_SLOT_SIZE_PX / 2); |
| 519 | y = InvRect[SLOTXY_HEAD_FIRST].Y - (INV_SLOT_SIZE_PX / 2); |
| 520 | } else if (slot == SLOTXY_RING_RIGHT) { |
| 521 | x = InvRect[SLOTXY_RING_LEFT].X + (INV_SLOT_SIZE_PX / 2); |
| 522 | y = InvRect[SLOTXY_RING_LEFT].Y - (INV_SLOT_SIZE_PX / 2); |
| 523 | } else if (slot == SLOTXY_BELT_FIRST) { |
| 524 | // do nothing |
| 525 | } else if (slot == SLOTXY_RING_LEFT) { // left ring |
| 526 | // do nothing |
| 527 | } else if (slot >= SLOTXY_HAND_LEFT_FIRST && slot <= SLOTXY_HAND_LEFT_LAST) { // left hand |
| 528 | // do nothing |
| 529 | } else if (slot >= SLOTXY_HEAD_FIRST && slot <= SLOTXY_HEAD_LAST) { // head |
| 530 | // do nothing |
| 531 | } else if (slot > SLOTXY_INV_FIRST) { // general inventory |
| 532 | if (slot != SLOTXY_INV_FIRST && slot != 35 && slot != 45 && slot != 55) { // left bounds |
| 533 | slot -= 1; |
| 534 | x = InvRect[slot].X + (INV_SLOT_SIZE_PX / 2); |
| 535 | y = InvRect[slot].Y - (INV_SLOT_SIZE_PX / 2); |
| 536 | } |
| 537 | } |
| 538 | } else if (dir.x == MoveDirectionX::RIGHT) { |
| 539 | if (slot == SLOTXY_RING_LEFT) { |
| 540 | x = InvRect[SLOTXY_RING_RIGHT].X + (INV_SLOT_SIZE_PX / 2); |
| 541 | y = InvRect[SLOTXY_RING_RIGHT].Y - (INV_SLOT_SIZE_PX / 2); |
| 542 | } else if (slot >= SLOTXY_HAND_LEFT_FIRST && slot <= SLOTXY_HAND_LEFT_LAST) { |
| 543 | x = InvRect[SLOTXY_CHEST_FIRST].X + (INV_SLOT_SIZE_PX / 2); |
no test coverage detected