Rename 6EE65A to push_others_right + refactor

This commit is contained in:
Jackson Davis 2014-09-01 22:06:50 +02:00
parent f0d4261659
commit fc2c3bdb51
3 changed files with 35 additions and 36 deletions

View File

@ -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;
}
}

View File

@ -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) \

View File

@ -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;