From 9355eef5d41f6aa173bb407963284dcd2d64be74 Mon Sep 17 00:00:00 2001 From: Daniel Trujillo Date: Wed, 22 Jun 2016 13:17:30 +0200 Subject: [PATCH] Add custom currency option Add custom currency entry to the dropdown menu of the options window --- src/windows/options.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/windows/options.c b/src/windows/options.c index 21dda00826..49344593da 100644 --- a/src/windows/options.c +++ b/src/windows/options.c @@ -914,13 +914,20 @@ static void window_options_mousedown(int widgetIndex, rct_window*w, rct_widget* dropdown_set_checked(gConfigGeneral.show_height_as_units ? 0 : 1, true); break; case WIDX_CURRENCY_DROPDOWN: - num_items = CURRENCY_END; + num_items = CURRENCY_END + 1; // All the currencies plus the separator + int num_ordinary_currencies = CURRENCY_END - 1; // All the currencies except custom currency - for (i = 0; i < num_items; i++) { + for (i = 0; i < num_ordinary_currencies; i++) { gDropdownItemsFormat[i] = STR_DROPDOWN_MENU_LABEL; gDropdownItemsArgs[i] = CurrencyDescriptors[i].stringId; } + gDropdownItemsFormat[num_ordinary_currencies] = DROPDOWN_SEPARATOR; + + gDropdownItemsFormat[num_ordinary_currencies+1] = STR_DROPDOWN_MENU_LABEL; + gDropdownItemsArgs[num_ordinary_currencies+1] = CurrencyDescriptors[CURRENCY_CUSTOM].stringId; + + window_options_show_dropdown(w, widget, num_items); dropdown_set_checked(gConfigGeneral.currency_format, true); @@ -1181,7 +1188,11 @@ static void window_options_dropdown(rct_window *w, int widgetIndex, int dropdown window_options_update_height_markers(); break; case WIDX_CURRENCY_DROPDOWN: - gConfigGeneral.currency_format = (sint8)dropdownIndex; + if(dropdownIndex == CURRENCY_CUSTOM+1) { // Add 1 because the separator occupies a position + gConfigGeneral.currency_format = (sint8)dropdownIndex-1; + } else { + gConfigGeneral.currency_format = (sint8)dropdownIndex; + } config_save_default(); gfx_invalidate_screen(); break;