mirror of https://github.com/OpenRCT2/OpenRCT2.git
Refactor window_scroll_to_viewport to use rct_window::ScrollToViewport
This commit is contained in:
parent
b046d45c01
commit
2053ecb688
|
@ -719,7 +719,7 @@ void window_guest_overview_mouse_up(rct_window* w, rct_widgetindex widgetIndex)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case WIDX_LOCATE:
|
case WIDX_LOCATE:
|
||||||
window_scroll_to_viewport(w);
|
w->ScrollToViewport();
|
||||||
break;
|
break;
|
||||||
case WIDX_TRACK:
|
case WIDX_TRACK:
|
||||||
{
|
{
|
||||||
|
|
|
@ -655,7 +655,7 @@ static void window_park_entrance_mouseup(rct_window* w, rct_widgetindex widgetIn
|
||||||
context_open_window(WC_LAND_RIGHTS);
|
context_open_window(WC_LAND_RIGHTS);
|
||||||
break;
|
break;
|
||||||
case WIDX_LOCATE:
|
case WIDX_LOCATE:
|
||||||
window_scroll_to_viewport(w);
|
w->ScrollToViewport();
|
||||||
break;
|
break;
|
||||||
case WIDX_RENAME:
|
case WIDX_RENAME:
|
||||||
{
|
{
|
||||||
|
|
|
@ -2047,7 +2047,7 @@ static void window_ride_main_mouseup(rct_window* w, rct_widgetindex widgetIndex)
|
||||||
window_ride_rename(w);
|
window_ride_rename(w);
|
||||||
break;
|
break;
|
||||||
case WIDX_LOCATE:
|
case WIDX_LOCATE:
|
||||||
window_scroll_to_viewport(w);
|
w->ScrollToViewport();
|
||||||
break;
|
break;
|
||||||
case WIDX_DEMOLISH:
|
case WIDX_DEMOLISH:
|
||||||
context_open_detail_window(WD_DEMOLISH_RIDE, w->number);
|
context_open_detail_window(WD_DEMOLISH_RIDE, w->number);
|
||||||
|
|
|
@ -459,7 +459,7 @@ void window_staff_overview_mouseup(rct_window* w, rct_widgetindex widgetIndex)
|
||||||
window_staff_set_page(w, widgetIndex - WIDX_TAB_1);
|
window_staff_set_page(w, widgetIndex - WIDX_TAB_1);
|
||||||
break;
|
break;
|
||||||
case WIDX_LOCATE:
|
case WIDX_LOCATE:
|
||||||
window_scroll_to_viewport(w);
|
w->ScrollToViewport();
|
||||||
break;
|
break;
|
||||||
case WIDX_PICKUP:
|
case WIDX_PICKUP:
|
||||||
{
|
{
|
||||||
|
|
|
@ -804,38 +804,6 @@ rct_window* window_get_main()
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Based on
|
|
||||||
* rct2: 0x696ee9, 0x66842F, 0x006AF3B3
|
|
||||||
*/
|
|
||||||
void window_scroll_to_viewport(rct_window* w)
|
|
||||||
{
|
|
||||||
int32_t x, y, z;
|
|
||||||
rct_window* mainWindow;
|
|
||||||
assert(w != nullptr);
|
|
||||||
// In original checked to make sure x and y were not -1 as well.
|
|
||||||
if (w->viewport == nullptr || w->viewport_focus_coordinates.y == -1)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (w->viewport_focus_sprite.type & VIEWPORT_FOCUS_TYPE_SPRITE)
|
|
||||||
{
|
|
||||||
rct_sprite* sprite = get_sprite(w->viewport_focus_sprite.sprite_id);
|
|
||||||
x = sprite->generic.x;
|
|
||||||
y = sprite->generic.y;
|
|
||||||
z = sprite->generic.z;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
x = w->viewport_focus_coordinates.x;
|
|
||||||
y = w->viewport_focus_coordinates.y & VIEWPORT_FOCUS_Y_MASK;
|
|
||||||
z = w->viewport_focus_coordinates.z;
|
|
||||||
}
|
|
||||||
|
|
||||||
mainWindow = window_get_main();
|
|
||||||
if (mainWindow != nullptr)
|
|
||||||
window_scroll_to_location(mainWindow, x, y, z);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* rct2: 0x006E7C9C
|
* rct2: 0x006E7C9C
|
||||||
|
|
|
@ -631,7 +631,6 @@ void window_push_others_below(rct_window* w1);
|
||||||
|
|
||||||
rct_window* window_get_main();
|
rct_window* window_get_main();
|
||||||
|
|
||||||
void window_scroll_to_viewport(rct_window* w);
|
|
||||||
void window_scroll_to_location(rct_window* w, int32_t x, int32_t y, int32_t z);
|
void window_scroll_to_location(rct_window* w, int32_t x, int32_t y, int32_t z);
|
||||||
void window_rotate_camera(rct_window* w, int32_t direction);
|
void window_rotate_camera(rct_window* w, int32_t direction);
|
||||||
void window_viewport_get_map_coords_by_cursor(
|
void window_viewport_get_map_coords_by_cursor(
|
||||||
|
|
|
@ -1,7 +1,37 @@
|
||||||
#include "Window_internal.h"
|
#include "Window_internal.h"
|
||||||
|
|
||||||
|
#include "../world/Sprite.h"
|
||||||
|
|
||||||
void rct_window::SetLocation(int32_t newX, int32_t newY, int32_t newZ)
|
void rct_window::SetLocation(int32_t newX, int32_t newY, int32_t newZ)
|
||||||
{
|
{
|
||||||
window_scroll_to_location(this, newX, newY, newZ);
|
window_scroll_to_location(this, newX, newY, newZ);
|
||||||
flags &= ~WF_SCROLLING_TO_LOCATION;
|
flags &= ~WF_SCROLLING_TO_LOCATION;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void rct_window::ScrollToViewport()
|
||||||
|
{
|
||||||
|
int32_t newX, newY, newZ;
|
||||||
|
rct_window* mainWindow;
|
||||||
|
|
||||||
|
// In original checked to make sure x and y were not -1 as well.
|
||||||
|
if (viewport == nullptr || viewport_focus_coordinates.y == -1)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (viewport_focus_sprite.type & VIEWPORT_FOCUS_TYPE_SPRITE)
|
||||||
|
{
|
||||||
|
rct_sprite* sprite = get_sprite(viewport_focus_sprite.sprite_id);
|
||||||
|
newX = sprite->generic.x;
|
||||||
|
newY = sprite->generic.y;
|
||||||
|
newZ = sprite->generic.z;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
newX = viewport_focus_coordinates.x;
|
||||||
|
newY = viewport_focus_coordinates.y & VIEWPORT_FOCUS_Y_MASK;
|
||||||
|
newZ = viewport_focus_coordinates.z;
|
||||||
|
}
|
||||||
|
|
||||||
|
mainWindow = window_get_main();
|
||||||
|
if (mainWindow != nullptr)
|
||||||
|
window_scroll_to_location(mainWindow, newX, newY, newZ);
|
||||||
|
}
|
||||||
|
|
|
@ -103,6 +103,7 @@ struct rct_window
|
||||||
uint16_t viewport_smart_follow_sprite; // Smart following of sprites. Handles setting viewport target sprite etc
|
uint16_t viewport_smart_follow_sprite; // Smart following of sprites. Handles setting viewport target sprite etc
|
||||||
|
|
||||||
void SetLocation(int32_t x, int32_t y, int32_t z);
|
void SetLocation(int32_t x, int32_t y, int32_t z);
|
||||||
|
void ScrollToViewport();
|
||||||
};
|
};
|
||||||
|
|
||||||
// rct2: 0x01420078
|
// rct2: 0x01420078
|
||||||
|
|
Loading…
Reference in New Issue