mirror of https://github.com/OpenRCT2/OpenRCT2.git
Merge pull request #692 from duncanspumpkin/fix_dropdown
Fix dropdown location at sides of the screen
This commit is contained in:
commit
78d90fd8aa
|
@ -1654,6 +1654,38 @@ void window_bubble_list_item(rct_window* w, int item_position){
|
||||||
w->list_item_positions[item_position + 1] = swap;
|
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
|
* rct2: 0x0066B905
|
||||||
|
|
|
@ -481,6 +481,7 @@ void window_update_viewport_ride_music();
|
||||||
|
|
||||||
// Open window functions
|
// Open window functions
|
||||||
void window_main_open();
|
void window_main_open();
|
||||||
|
void window_relocate_windows(int width, int height);
|
||||||
void window_resize_gui(int width, int height);
|
void window_resize_gui(int width, int height);
|
||||||
void window_resize_gui_scenario_editor(int width, int height);
|
void window_resize_gui_scenario_editor(int width, int height);
|
||||||
void window_game_top_toolbar_open();
|
void window_game_top_toolbar_open();
|
||||||
|
|
|
@ -286,7 +286,7 @@ static void osinterface_resize(int width, int height)
|
||||||
RCT2_GLOBAL(RCT2_ADDRESS_DIRTY_BLOCK_ROWS, sint32) = (height >> 3) + 1;
|
RCT2_GLOBAL(RCT2_ADDRESS_DIRTY_BLOCK_ROWS, sint32) = (height >> 3) + 1;
|
||||||
|
|
||||||
window_resize_gui(width, height);
|
window_resize_gui(width, height);
|
||||||
//RCT2_CALLPROC_EBPSAFE(0x0066B905); // resize_gui()
|
window_relocate_windows(width, height);
|
||||||
|
|
||||||
gfx_invalidate_screen();
|
gfx_invalidate_screen();
|
||||||
}
|
}
|
||||||
|
|
|
@ -150,6 +150,14 @@ void window_dropdown_show_text_custom_width(int x, int y, int extray, uint8 colo
|
||||||
// Set the widgets
|
// Set the widgets
|
||||||
gDropdownNumItems = num_items;
|
gDropdownNumItems = num_items;
|
||||||
_dropdown_num_rows = 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].bottom = _dropdown_item_height * num_items + 3;
|
||||||
window_dropdown_widgets[WIDX_BACKGROUND].right = _dropdown_item_width + 3;
|
window_dropdown_widgets[WIDX_BACKGROUND].right = _dropdown_item_width + 3;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue