0x004C74BB Right mouse dragging in viewports, such as the main display of the game world.
| 548 | // 0x004C74BB |
| 549 | // Right mouse dragging in viewports, such as the main display of the game world. |
| 550 | static void stateViewportRight(const MouseButton button, const int32_t x, const int32_t y) |
| 551 | { |
| 552 | auto window = WindowManager::find(_dragWindowType, _dragWindowNumber); |
| 553 | if (window == nullptr) |
| 554 | { |
| 555 | Input::state(State::reset); |
| 556 | return; |
| 557 | } |
| 558 | |
| 559 | switch (button) |
| 560 | { |
| 561 | |
| 562 | case MouseButton::released: |
| 563 | { |
| 564 | // 4C74E4 |
| 565 | _ticksSinceDragStart += getTimeSinceLastTick(); |
| 566 | auto vp = window->viewports[0]; |
| 567 | if (vp == nullptr) |
| 568 | { |
| 569 | vp = window->viewports[1]; |
| 570 | } |
| 571 | if (vp == nullptr) |
| 572 | { |
| 573 | Input::state(State::reset); |
| 574 | return; |
| 575 | } |
| 576 | |
| 577 | if (window->hasFlags(WindowFlags::viewportNoScrolling)) |
| 578 | { |
| 579 | return; |
| 580 | } |
| 581 | |
| 582 | Ui::Point dragOffset = { x, y }; |
| 583 | if (Tutorial::state() != Tutorial::State::playing) |
| 584 | { |
| 585 | // Fix #151: use relative drag from one frame to the next rather than |
| 586 | // using the relative position from the message loop |
| 587 | dragOffset = getNextDragOffset(); |
| 588 | } |
| 589 | if (dragOffset.x != 0 || dragOffset.y != 0) |
| 590 | { |
| 591 | _ticksSinceDragStart = 1000; |
| 592 | |
| 593 | auto* main = WindowManager::getMainWindow(); |
| 594 | if (Windows::Main::viewportIsFocusedOnAnyEntity(*main)) |
| 595 | { |
| 596 | Windows::Main::viewportUnfocusFromEntity(*main); |
| 597 | } |
| 598 | else |
| 599 | { |
| 600 | const auto offsetX = dragOffset.x << (vp->zoom + 1); |
| 601 | const auto offsetY = dragOffset.y << (vp->zoom + 1); |
| 602 | |
| 603 | const auto invert = Config::get().invertRightMouseViewPan ? -1 : 1; |
| 604 | |
| 605 | window->viewportConfigurations[0].savedViewX += offsetX * invert; |
| 606 | window->viewportConfigurations[0].savedViewY += offsetY * invert; |
| 607 | } |
no test coverage detected