diff --git a/src/interface/window.c b/src/interface/window.c index 5a2218b827..8ccfc70b82 100644 --- a/src/interface/window.c +++ b/src/interface/window.c @@ -1654,6 +1654,38 @@ void window_bubble_list_item(rct_window* w, int item_position){ w->list_item_positions[item_position + 1] = swap; } +/* rct2: 0x006ED710 + * Called after a window resize to move windows if they + * are going to be out of sight. + */ +void window_relocate_windows(int width, int height){ + int new_location = 8; + for (rct_window* w = g_window_list; w < RCT2_NEW_WINDOW; w++){ + + // Work out if the window requires moving + if (w->x + 10 < width){ + if (w->flags&(WF_STICK_TO_BACK | WF_STICK_TO_FRONT)){ + if (w->y -22 < height)continue; + } + if (w->y + 10 < height)continue; + } + + // Calculate the new locations + int x = w->x; + int y = w->y; + w->x = new_location; + w->y = new_location + 28; + + // Move the next new location so windows are not directly on top + new_location += 8; + + // Adjust the viewport if required. + if (w->viewport){ + w->viewport->x -= x - w->x; + w->viewport->y -= y - w->y; + } + } +} /** * rct2: 0x0066B905 diff --git a/src/interface/window.h b/src/interface/window.h index df38f2047f..db038fc47d 100644 --- a/src/interface/window.h +++ b/src/interface/window.h @@ -481,6 +481,7 @@ void window_update_viewport_ride_music(); // Open window functions void window_main_open(); +void window_relocate_windows(int width, int height); void window_resize_gui(int width, int height); void window_resize_gui_scenario_editor(int width, int height); void window_game_top_toolbar_open(); diff --git a/src/platform/osinterface.c b/src/platform/osinterface.c index 6d36f67f90..1927a6aaab 100644 --- a/src/platform/osinterface.c +++ b/src/platform/osinterface.c @@ -286,7 +286,7 @@ static void osinterface_resize(int width, int height) RCT2_GLOBAL(RCT2_ADDRESS_DIRTY_BLOCK_ROWS, sint32) = (height >> 3) + 1; window_resize_gui(width, height); - //RCT2_CALLPROC_EBPSAFE(0x0066B905); // resize_gui() + window_relocate_windows(width, height); gfx_invalidate_screen(); } diff --git a/src/windows/dropdown.c b/src/windows/dropdown.c index a4cf76fc46..2a02739add 100644 --- a/src/windows/dropdown.c +++ b/src/windows/dropdown.c @@ -150,6 +150,14 @@ void window_dropdown_show_text_custom_width(int x, int y, int extray, uint8 colo // Set the widgets gDropdownNumItems = num_items; _dropdown_num_rows = num_items; + + width = _dropdown_item_width * _dropdown_num_columns + 3; + int height = _dropdown_item_height * _dropdown_num_rows + 3; + if (x + width > RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_WIDTH, sint16)) + x = max(0, RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_WIDTH, sint16) - width); + if (y + height > RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_HEIGHT, sint16)) + y = max(0, RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_HEIGHT, sint16) - height); + window_dropdown_widgets[WIDX_BACKGROUND].bottom = _dropdown_item_height * num_items + 3; window_dropdown_widgets[WIDX_BACKGROUND].right = _dropdown_item_width + 3;