From e2b2c94ca133c8808325ae9918a4b559aae39840 Mon Sep 17 00:00:00 2001 From: Duncan Frost Date: Sat, 17 Jan 2015 09:14:17 +0000 Subject: [PATCH] Fix dropdown location at sides of the screen #690 --- src/windows/dropdown.c | 8 ++++++++ 1 file changed, 8 insertions(+) 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;