diff --git a/src/window.c b/src/window.c index 355d5770bf..e81a530965 100644 --- a/src/window.c +++ b/src/window.c @@ -1511,3 +1511,38 @@ void window_align_tabs( rct_window *w, uint8 start_tab_id, uint8 end_tab_id ) } } } + +/** + * Finds overlapping windows and moves them if possible + * rct2: 0x006EE65A + */ +void window_move_overlapping(rct_window* window) +{ + uint16 cx = window->width + window->x; + uint16 dx = window->height + window->y; + + for (rct_window* w = g_window_list; w < RCT2_GLOBAL(RCT2_ADDRESS_NEW_WINDOW_PTR, rct_window*); w++) { + if (w == window) + continue; + if (w->flags & (WF_STICK_TO_BACK | WF_STICK_TO_FRONT)) + continue; + if (w->x >= cx) + continue; + if (w->x + w->width <= window->x) + continue; + if (w->y >= dx) + continue; + if (w->y + w->height <= window->y) + continue; + window_invalidate(w); + cx += 13; + if (cx >= RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_WIDTH, uint16)) + continue; + cx -= 10; + cx -= w->x; + w->x += cx; + window_invalidate(w); + if (w->viewport != NULL) + w->viewport->x += cx; + } +} diff --git a/src/window.h b/src/window.h index 1098eba380..440ed28b40 100644 --- a/src/window.h +++ b/src/window.h @@ -469,6 +469,7 @@ void window_staff_init_vars(); void window_event_helper(rct_window* w, short widgetIndex, WINDOW_EVENTS event); void RCT2_CALLPROC_WE_MOUSE_DOWN(int address, int widgetIndex, rct_window*w, rct_widget* widget); +void window_move_overlapping(rct_window* window); #ifdef _MSC_VER #define window_get_register(w) \ diff --git a/src/window_footpath.c b/src/window_footpath.c index db6146c5a8..f852be5ecc 100644 --- a/src/window_footpath.c +++ b/src/window_footpath.c @@ -120,7 +120,6 @@ static void window_footpath_tooldrag(); static void window_footpath_toolup(); static void window_footpath_invalidate(); static void window_footpath_paint(); -static void sub_6EE65A(rct_window* w); static void* window_footpath_events[] = { window_footpath_close, @@ -202,7 +201,7 @@ void window_footpath_open() (1 << WIDX_CONSTRUCT_BRIDGE_OR_TUNNEL); window_init_scroll_widgets(window); - sub_6EE65A(window); //RCT2_CALLPROC_EBPSAFE(0x006EE65A); + window_move_overlapping(window); show_gridlines(); window->colours[0] = 24; window->colours[1] = 24; @@ -828,36 +827,3 @@ loc_6A79B0: RCT2_CALLPROC_EBPSAFE(0x006A855C); } -static void sub_6EE65A(rct_window* window) -{ - uint16 ax = window->x; - uint16 bx = window->y; - uint16 cx = window->width; - uint16 dx = window->height; - cx += ax; - dx += bx; - for (rct_window* w = g_window_list; w < RCT2_GLOBAL(RCT2_ADDRESS_NEW_WINDOW_PTR, rct_window*); w++) { - if (w == window) - continue; - if (w->flags & (WF_STICK_TO_BACK | WF_STICK_TO_FRONT)) - continue; - if (w->x >= cx) - continue; - if (w->x + w->width <= ax) - continue; - if (w->y >= dx) - continue; - if (w->y + w->height <= bx) - continue; - window_invalidate(w); - cx += 13; - if (cx >= RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_WIDTH, uint16)) - continue; - cx -= 10; - cx -= w->x; - w->x += cx; - window_invalidate(w); - if (w->viewport != NULL) - w->viewport->x += cx; - } -}