| 2797 | } |
| 2798 | |
| 2799 | bool Gui::revealInDwarfmodeMap(int32_t x, int32_t y, int32_t z, bool center, bool highlight) |
| 2800 | { // Reverse-engineered from DF announcement and scrolling code |
| 2801 | using df::global::window_x; |
| 2802 | using df::global::window_y; |
| 2803 | using df::global::window_z; |
| 2804 | |
| 2805 | if (!window_x || !window_y || !window_z || !world || !game) |
| 2806 | return false; |
| 2807 | |
| 2808 | unfollow(); |
| 2809 | |
| 2810 | if (!Maps::isValidTilePos(x, y, z)) |
| 2811 | return false; |
| 2812 | |
| 2813 | auto dims = getDwarfmodeViewDims(); |
| 2814 | int32_t w = dims.map_x2 - dims.map_x1 + 1; |
| 2815 | int32_t h = dims.map_y2 - dims.map_y1 + 1; |
| 2816 | int32_t new_win_x, new_win_y, new_win_z; |
| 2817 | getViewCoords(new_win_x, new_win_y, new_win_z); |
| 2818 | |
| 2819 | if (center) { |
| 2820 | new_win_x = x - w / 2; |
| 2821 | new_win_y = y - h / 2; |
| 2822 | } else { |
| 2823 | // just bring it on screen |
| 2824 | if (new_win_x > (x - 5)) // equivalent to: "while (new_win_x > x - 5) new_win_x -= 10;" |
| 2825 | new_win_x -= (new_win_x - (x - 5) - 1) / 10 * 10 + 10; |
| 2826 | if (new_win_y > (y - 5)) |
| 2827 | new_win_y -= (new_win_y - (y - 5) - 1) / 10 * 10 + 10; |
| 2828 | if (new_win_x < (x + 5 - w)) |
| 2829 | new_win_x += ((x + 5 - w) - new_win_x - 1) / 10 * 10 + 10; |
| 2830 | if (new_win_y < (y + 5 - h)) |
| 2831 | new_win_y += ((y + 5 - h) - new_win_y - 1) / 10 * 10 + 10; |
| 2832 | } |
| 2833 | |
| 2834 | new_win_z = z; |
| 2835 | |
| 2836 | *window_x = new_win_x; |
| 2837 | *window_y = new_win_y; |
| 2838 | *window_z = clip_range(new_win_z, 0, (world->map.z_count - 1)); |
| 2839 | game->minimap.update = true; |
| 2840 | game->minimap.mustmake = true; |
| 2841 | |
| 2842 | if (highlight) { |
| 2843 | game->main_interface.recenter_indicator_m.x = x; |
| 2844 | game->main_interface.recenter_indicator_m.y = y; |
| 2845 | game->main_interface.recenter_indicator_m.z = z; |
| 2846 | } |
| 2847 | |
| 2848 | return true; |
| 2849 | } |
| 2850 | |
| 2851 | bool Gui::pauseRecenter(int32_t x, int32_t y, int32_t z, bool pause) |
| 2852 | { // Reverse-engineered from DF announcement code |
nothing calls this directly
no test coverage detected