From fc2c3bdb51a1d3a9f925bc3d1ff2696f5c29f981 Mon Sep 17 00:00:00 2001 From: Jackson Davis Date: Mon, 1 Sep 2014 22:06:50 +0200 Subject: [PATCH] Rename 6EE65A to push_others_right + refactor --- src/window.c | 67 +++++++++++++++++++++---------------------- src/window.h | 2 +- src/window_footpath.c | 2 +- 3 files changed, 35 insertions(+), 36 deletions(-) diff --git a/src/window.c b/src/window.c index e81a530965..9e04d0982e 100644 --- a/src/window.c +++ b/src/window.c @@ -828,6 +828,38 @@ rct_window *window_bring_to_front(rct_window *w) return w; } +/** + * + * rct2: 0x006EE65A + */ +void window_push_others_right(rct_window* window) +{ + + 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 >= window->x + window->width) + continue; + if (w->x + w->width <= window->x) + continue; + if (w->y >= window->y + window->height) + continue; + if (w->y + w->height <= window->y) + continue; + + window_invalidate(w); + if (window->x + window->width + 13 >= RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_WIDTH, uint16)) + continue; + uint16 push_amount = window->x + window->height - w->x + 3; + w->x += push_amount; + window_invalidate(w); + if (w->viewport != NULL) + w->viewport->x += push_amount; + } +} + /** * * rct2: 0x006EE6EA @@ -871,6 +903,7 @@ void window_push_others_below(rct_window *w1) } } + /** * * rct2: 0x006EE2E4 @@ -1512,37 +1545,3 @@ 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 440ed28b40..86aa034349 100644 --- a/src/window.h +++ b/src/window.h @@ -396,6 +396,7 @@ int window_get_scroll_size(rct_window *w, int scrollIndex, int *width, int *heig rct_window *window_bring_to_front_by_id(rct_windowclass cls, rct_windownumber number); rct_window *window_bring_to_front(rct_window *w); +void window_push_others_right(rct_window *w); void window_push_others_below(rct_window *w1); rct_window *window_get_main(); @@ -469,7 +470,6 @@ 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 f852be5ecc..01e4db3cb5 100644 --- a/src/window_footpath.c +++ b/src/window_footpath.c @@ -201,7 +201,7 @@ void window_footpath_open() (1 << WIDX_CONSTRUCT_BRIDGE_OR_TUNNEL); window_init_scroll_widgets(window); - window_move_overlapping(window); + window_push_others_right(window); show_gridlines(); window->colours[0] = 24; window->colours[1] = 24;