diff --git a/OpenRCT2.xcodeproj/project.pbxproj b/OpenRCT2.xcodeproj/project.pbxproj index dfb4818b33..9d130b35e3 100644 --- a/OpenRCT2.xcodeproj/project.pbxproj +++ b/OpenRCT2.xcodeproj/project.pbxproj @@ -319,6 +319,7 @@ D45A395D1CF300AF00659A24 /* libSDL2_ttf.dylib in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = D45A38B71CF3006400659A24 /* libSDL2_ttf.dylib */; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }; }; D45A395E1CF300AF00659A24 /* libSDL2.dylib in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = D45A38B81CF3006400659A24 /* libSDL2.dylib */; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }; }; D45A395F1CF300AF00659A24 /* libspeexdsp.dylib in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = D45A38B91CF3006400659A24 /* libspeexdsp.dylib */; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }; }; + D45B202D1D1E92DB00B67CC7 /* custom_currency.c in Sources */ = {isa = PBXBuildFile; fileRef = D45B202C1D1E92DB00B67CC7 /* custom_currency.c */; }; D47304D51C4FF8250015C0EA /* libz.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = D47304D41C4FF8250015C0EA /* libz.tbd */; }; D48A8D831D00272F00649DA7 /* TcpSocket.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D48A8D811D00272F00649DA7 /* TcpSocket.cpp */; }; D49766831D03B9FE002222CD /* SoftwareDrawingEngine.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D49766811D03B9FE002222CD /* SoftwareDrawingEngine.cpp */; }; @@ -933,6 +934,7 @@ D45A39561CF3007A00659A24 /* speex_resampler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = speex_resampler.h; sourceTree = ""; }; D45A39571CF3007A00659A24 /* speexdsp_config_types.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = speexdsp_config_types.h; sourceTree = ""; }; D45A39581CF3007A00659A24 /* speexdsp_types.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = speexdsp_types.h; sourceTree = ""; }; + D45B202C1D1E92DB00B67CC7 /* custom_currency.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = custom_currency.c; sourceTree = ""; }; D47304D41C4FF8250015C0EA /* libz.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = libz.tbd; path = usr/lib/libz.tbd; sourceTree = SDKROOT; }; D4895D321C23EFDD000CD788 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = Info.plist; path = distribution/osx/Info.plist; sourceTree = SOURCE_ROOT; }; D48A8D811D00272F00649DA7 /* TcpSocket.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TcpSocket.cpp; sourceTree = ""; usesTabs = 0; }; @@ -1524,6 +1526,7 @@ D44271911CC81B3200D84D28 /* changelog.c */, D44271921CC81B3200D84D28 /* cheats.c */, D44271931CC81B3200D84D28 /* clear_scenery.c */, + D45B202C1D1E92DB00B67CC7 /* custom_currency.c */, D44271941CC81B3200D84D28 /* demolish_ride_prompt.c */, D44271951CC81B3200D84D28 /* dropdown.c */, D44271961CC81B3200D84D28 /* dropdown.h */, @@ -2094,6 +2097,7 @@ 007A05CF1CFB2C8B00F419C3 /* NetworkConnection.cpp in Sources */, C686F9341CDBC3B7009F9BFC /* merry_go_round.c in Sources */, C686F8B81CDBC37E009F9BFC /* sprite.c in Sources */, + D45B202D1D1E92DB00B67CC7 /* custom_currency.c in Sources */, C686F9221CDBC3B7009F9BFC /* stand_up_roller_coaster.c in Sources */, C686F94F1CDBC3B7009F9BFC /* dingy_slide.c in Sources */, D44272341CC81B3200D84D28 /* network.cpp in Sources */, diff --git a/contributors.md b/contributors.md index 416fe3197a..5de34b95cb 100644 --- a/contributors.md +++ b/contributors.md @@ -50,6 +50,7 @@ Includes all git commit authors. Aliases are GitHub user names. * Kelson Blakewood (spacek531) - title sequence for 0.0.4 * Hugo Wallenburg (Goddesen) - Misc. * (Nubbie) - Misc, UX +* Daniel Trujillo Viedma (gDanix) - Custom currency. ## Bug fixes * (halfbro) @@ -101,7 +102,7 @@ Includes all git commit authors. Aliases are GitHub user names. * Portuguese (BR) - (kaudy), (renansimoes) * Russian - (Soosisya) * Simplified Chinese - Naiji Ma (naijim), (izhangfei), Eric Zhao (sczyh30) -* Spanish - (mdtrooper), Josué Acevedo (Wirlie), Daniel Trujillo Viedma (gdabi); small fixes: (teapartycthulu) +* Spanish - (mdtrooper), Josué Acevedo (Wirlie), Daniel Trujillo Viedma (gDanix); small fixes: (teapartycthulu) * Swedish - (Jinxit), (mharrys), (Slimeyo), (Nubbie) * Traditional Chinese - Harry Lam (daihakken) * Norwegian - (Goddesen) diff --git a/data/language/en-GB.txt b/data/language/en-GB.txt index f84a62c850..505ff2ad58 100644 --- a/data/language/en-GB.txt +++ b/data/language/en-GB.txt @@ -4190,6 +4190,15 @@ STR_5878 :Software (hardware display) STR_5879 :OpenGL STR_5880 :Selected only STR_5881 :Non-selected only +STR_5882 :Custom currency +STR_5883 :Custom currency configuration +STR_5884 :{WINDOW_COLOUR_2}Exchange rate: +STR_5885 :{WINDOW_COLOUR_2}is equivalent to {COMMA32} GBP (£) +STR_5886 :{WINDOW_COLOUR_2}Currency symbol: +STR_5887 :Prefix +STR_5888 :Suffix +STR_5889 :Custom currency symbol +STR_5890 :Enter the currency symbol to display ############# # Scenarios # diff --git a/openrct2.vcxproj b/openrct2.vcxproj index ef0aabeab6..1561101908 100644 --- a/openrct2.vcxproj +++ b/openrct2.vcxproj @@ -257,6 +257,7 @@ + @@ -568,4 +569,4 @@ - \ No newline at end of file + diff --git a/src/config.c b/src/config.c index 4ec41c744c..d17577c8d7 100644 --- a/src/config.c +++ b/src/config.c @@ -130,6 +130,12 @@ config_enum_definition _currencyEnum[] = { END_OF_ENUM }; +config_enum_definition _currencySymbolAffixEnum[] = { + { "PREFIX", CURRENCY_PREFIX }, + { "SUFFIX", CURRENCY_SUFFIX }, + END_OF_ENUM +}; + config_enum_definition _languageEnum[] = { { "en-GB", LANGUAGE_ENGLISH_UK }, { "en-US", LANGUAGE_ENGLISH_US }, @@ -171,6 +177,9 @@ config_property_definition _generalDefinitions[] = { { offsetof(general_configuration, confirmation_prompt), "confirmation_prompt", CONFIG_VALUE_TYPE_BOOLEAN, false, NULL }, { offsetof(general_configuration, construction_marker_colour), "construction_marker_colour", CONFIG_VALUE_TYPE_UINT8, false, NULL }, { offsetof(general_configuration, currency_format), "currency_format", CONFIG_VALUE_TYPE_UINT8, CURRENCY_POUNDS, _currencyEnum }, + { offsetof(general_configuration, custom_currency_rate), "custom_currency_rate", CONFIG_VALUE_TYPE_SINT32, 10, NULL }, + { offsetof(general_configuration, custom_currency_affix), "custom_currency_affix", CONFIG_VALUE_TYPE_SINT8, CURRENCY_SUFFIX, _currencySymbolAffixEnum}, + { offsetof(general_configuration, custom_currency_symbol), "custom_currency_symbol", CONFIG_VALUE_TYPE_STRING, { .value_string = "Ctm" }, NULL }, { offsetof(general_configuration, edge_scrolling), "edge_scrolling", CONFIG_VALUE_TYPE_BOOLEAN, true, NULL }, { offsetof(general_configuration, fullscreen_mode), "fullscreen_mode", CONFIG_VALUE_TYPE_UINT8, 0, NULL }, { offsetof(general_configuration, fullscreen_height), "fullscreen_height", CONFIG_VALUE_TYPE_SINT32, -1, NULL }, @@ -470,6 +479,8 @@ bool config_open_default() return true; } + currency_load_custom_currency_config(); + return false; } diff --git a/src/config.h b/src/config.h index ba5a033006..45b9fd75cf 100644 --- a/src/config.h +++ b/src/config.h @@ -146,6 +146,9 @@ typedef struct general_configuration { sint8 measurement_format; sint8 temperature_format; sint8 currency_format; + sint32 custom_currency_rate; + sint8 custom_currency_affix; + utf8string custom_currency_symbol; sint8 construction_marker_colour; sint8 edge_scrolling; sint8 always_show_gridlines; diff --git a/src/interface/window.h b/src/interface/window.h index acdbe46d06..caf981dc91 100644 --- a/src/interface/window.h +++ b/src/interface/window.h @@ -453,6 +453,7 @@ enum { WC_NETWORK_STATUS = 126, WC_SERVER_LIST = 127, WC_SERVER_START = 128, + WC_CUSTOM_CURRENCY_CONFIG = 129, // Only used for colour schemes WC_STAFF = 220, @@ -629,6 +630,8 @@ void ride_construction_toolupdate_entrance_exit(int screenX, int screenY); void ride_construction_toolupdate_construct(int screenX, int screenY); void ride_construction_tooldown_construct(int screenX, int screenY); +void custom_currency_window_open(); + void window_maze_construction_update_pressed_widgets(); void window_track_place_open(const track_design_file_ref *tdFileRef); rct_window *window_new_ride_open(); diff --git a/src/localisation/currency.c b/src/localisation/currency.c index cc74aa051d..20476a35bc 100644 --- a/src/localisation/currency.c +++ b/src/localisation/currency.c @@ -14,10 +14,11 @@ *****************************************************************************/ #pragma endregion +#include "../config.h" #include "currency.h" #include "string_ids.h" -const currency_descriptor CurrencyDescriptors[CURRENCY_END] = { +currency_descriptor CurrencyDescriptors[CURRENCY_END] = { { "GBP", 10, CURRENCY_PREFIX, "\xC2\xA3", CURRENCY_SUFFIX, "GBP", STR_POUNDS }, // British Pound { "USD", 10, CURRENCY_PREFIX, "$", CURRENCY_PREFIX, "$", STR_DOLLARS }, // US Dollar { "FRF", 10, CURRENCY_SUFFIX, "F", CURRENCY_SUFFIX, "F", STR_FRANC }, // French Franc @@ -34,4 +35,12 @@ const currency_descriptor CurrencyDescriptors[CURRENCY_END] = { { "HKD", 100, CURRENCY_PREFIX, "$", CURRENCY_PREFIX, "HKD", STR_HONG_KONG_DOLLAR}, // Hong Kong Dollar { "TWD", 1000, CURRENCY_PREFIX, "NT$", CURRENCY_PREFIX, "NT$", STR_NEW_TAIWAN_DOLLAR}, // New Taiwan Dollar { "CNY", 100, CURRENCY_PREFIX, "CN\xC2\xA5", CURRENCY_PREFIX, "CNY", STR_CHINESE_YUAN }, // Chinese Yuan + { "CTM", 10, CURRENCY_PREFIX, "Ctm", CURRENCY_PREFIX, "Ctm", STR_CUSTOM_CURRENCY }, // Customizable currency }; + +void currency_load_custom_currency_config() +{ + CurrencyDescriptors[CURRENCY_CUSTOM].rate = gConfigGeneral.custom_currency_rate; + CurrencyDescriptors[CURRENCY_CUSTOM].affix_unicode = gConfigGeneral.custom_currency_affix; + strncpy(CurrencyDescriptors[CURRENCY_CUSTOM].symbol_unicode, gConfigGeneral.custom_currency_symbol, CURRENCY_SYMBOL_MAX_SIZE); +} diff --git a/src/localisation/currency.h b/src/localisation/currency.h index 7c96eb8ab1..6f6318ded6 100644 --- a/src/localisation/currency.h +++ b/src/localisation/currency.h @@ -38,6 +38,8 @@ typedef enum { CURRENCY_TWD, // New Taiwan Dollar CURRENCY_YUAN, // Chinese Yuan + CURRENCY_CUSTOM, // Custom currency + CURRENCY_END // Last item } CURRENCY_TYPE; @@ -61,6 +63,12 @@ typedef struct currency_descriptor { } currency_descriptor; // List of currency formats -extern const currency_descriptor CurrencyDescriptors[CURRENCY_END]; +extern currency_descriptor CurrencyDescriptors[CURRENCY_END]; + +/** + * Loads custom currency saved parameters into {@link CurrencyDescriptors}' + * custom currency entry + */ +void currency_load_custom_currency_config(); #endif diff --git a/src/localisation/localisation.c b/src/localisation/localisation.c index 7d95ea4822..0a18840a93 100644 --- a/src/localisation/localisation.c +++ b/src/localisation/localisation.c @@ -504,7 +504,7 @@ void format_currency_2dp(char **dest, long long value) } // Drop the pennies for "large" currencies - if (rate > 10) { + if (rate >= 100) { format_comma_separated_integer(dest, value / 100); } else { format_comma_separated_fixed_2dp(dest, value); diff --git a/src/localisation/string_ids.h b/src/localisation/string_ids.h index 625cd286ce..3b7ef36d08 100644 --- a/src/localisation/string_ids.h +++ b/src/localisation/string_ids.h @@ -2658,6 +2658,17 @@ enum { STR_SELECTED_ONLY = 5880, STR_NON_SELECTED_ONLY = 5881, + + STR_CUSTOM_CURRENCY = 5882, + STR_CUSTOM_CURRENCY_WINDOW_TITLE = 5883, + STR_RATE = 5884, + STR_CUSTOM_CURRENCY_EQUIVALENCY = 5885, + STR_CURRENCY_SYMBOL_TEXT = 5886, + STR_PREFIX = 5887, + STR_SUFFIX = 5888, + STR_CUSTOM_CURRENCY_SYMBOL_INPUT_TITLE = 5889, + STR_CUSTOM_CURRENCY_SYMBOL_INPUT_DESC = 5890, + // Have to include resource strings (from scenarios and objects) for the time being now that language is partially working STR_COUNT = 32768 }; diff --git a/src/windows/custom_currency.c b/src/windows/custom_currency.c new file mode 100644 index 0000000000..aeec7f9547 --- /dev/null +++ b/src/windows/custom_currency.c @@ -0,0 +1,282 @@ +#pragma region Copyright (c) 2014-2016 OpenRCT2 Developers +/***************************************************************************** + * OpenRCT2, an open source clone of Roller Coaster Tycoon 2. + * + * OpenRCT2 is the work of many authors, a full list can be found in contributors.md + * For more information, visit https://github.com/OpenRCT2/OpenRCT2 + * + * OpenRCT2 is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * A full copy of the GNU General Public License can be found in licence.txt + *****************************************************************************/ +#pragma endregion + +/** + * 'Custom currency configuration' window definition and logic. + */ + +#include "../config.h" +#include "../localisation/localisation.h" +#include "../interface/widget.h" +#include "../interface/window.h" +#include "dropdown.h" + +enum WINDOW_CUSTOM_CURRENCY_WIDGET_IDX { + WIDX_BACKGROUND, + WIDX_TITLE, + WIDX_CLOSE, + WIDX_RATE, + WIDX_RATE_UP, + WIDX_RATE_DOWN, + WIDX_SYMBOL_TEXT, + WIDX_AFFIX_DROPDOWN, + WIDX_AFFIX_DROPDOWN_BUTTON, +}; + +rct_widget window_custom_currency_widgets[] = { + { WWT_FRAME, 0, 0, 399, 0, 99, 0x0FFFFFFFF, STR_NONE }, + { WWT_CAPTION, 0, 1, 398, 1, 14, STR_CUSTOM_CURRENCY_WINDOW_TITLE, STR_WINDOW_TITLE_TIP }, + { WWT_CLOSEBOX, 0, 387, 397, 2, 13, STR_CLOSE_X, STR_CLOSE_WINDOW_TIP }, + { WWT_SPINNER, 1, 100, 200, 30, 40, 5462, STR_NONE }, + { WWT_DROPDOWN_BUTTON, 1, 189, 199, 31, 35, STR_NUMERIC_UP, STR_NONE }, + { WWT_DROPDOWN_BUTTON, 1, 189, 199, 36, 40, STR_NUMERIC_DOWN, STR_NONE }, + { WWT_DROPDOWN_BUTTON, 1, 120, 200, 50, 60, 0, STR_NONE }, + { WWT_DROPDOWN, 1, 220, 350, 50, 60, 865, STR_NONE }, + { WWT_DROPDOWN_BUTTON, 1, 339, 349, 51, 59, STR_DROPDOWN_GLYPH, STR_NONE }, + { WIDGETS_END }, +}; + + +static void custom_currency_window_mousedown(int widgetIndex, rct_window *w, rct_widget *widget); +static void custom_currency_window_dropdown(rct_window *w, int widgetIndex, int dropdownIndex); +static void custom_currency_window_text_input(struct rct_window *w, int windgetIndex, char *text); +static void custom_currency_window_paint(rct_window *w, rct_drawpixelinfo *dpi); + + +static rct_window_event_list _windowCustomCurrencyEvents = { + NULL, + NULL, + NULL, + custom_currency_window_mousedown, + custom_currency_window_dropdown, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + custom_currency_window_text_input, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + custom_currency_window_paint, + NULL +}; + + +void custom_currency_window_open() +{ + rct_window* window; + + // Check if window is already open + window = window_bring_to_front_by_class(WC_CUSTOM_CURRENCY_CONFIG); + if(window != NULL) + return; + + window = window_create_centred( + 400, + 100, + &_windowCustomCurrencyEvents, + WC_CUSTOM_CURRENCY_CONFIG, + 0 + ); + window->widgets = window_custom_currency_widgets; + window->enabled_widgets = + (1 << WIDX_CLOSE) | + (1 << WIDX_RATE) | + (1 << WIDX_RATE_UP) | + (1 << WIDX_RATE_DOWN) | + (1 << WIDX_SYMBOL_TEXT) | + (1 << WIDX_AFFIX_DROPDOWN) | + (1 << WIDX_AFFIX_DROPDOWN_BUTTON); + + window_init_scroll_widgets(window); + window->colours[0] = 22; + window->colours[1] = 22; + window->colours[2] = 22; +} + + + +static void custom_currency_window_mousedown(int widgetIndex, rct_window *w, rct_widget *widget) +{ + widget = &w->widgets[widgetIndex - 1]; + + switch(widgetIndex) { + + case WIDX_CLOSE: + window_close(w); + break; + + case WIDX_RATE_UP: + CurrencyDescriptors[CURRENCY_CUSTOM].rate += 1; + gConfigGeneral.custom_currency_rate = CurrencyDescriptors[CURRENCY_CUSTOM].rate; + config_save_default(); + window_invalidate_all(); + break; + + case WIDX_RATE_DOWN: + if(CurrencyDescriptors[CURRENCY_CUSTOM].rate > 1) { + CurrencyDescriptors[CURRENCY_CUSTOM].rate -= 1; + gConfigGeneral.custom_currency_rate = CurrencyDescriptors[CURRENCY_CUSTOM].rate; + config_save_default(); + window_invalidate_all(); + } + break; + + case WIDX_AFFIX_DROPDOWN_BUTTON: + gDropdownItemsFormat[0] = STR_DROPDOWN_MENU_LABEL; + gDropdownItemsArgs[0] = STR_PREFIX; + + gDropdownItemsFormat[1] = STR_DROPDOWN_MENU_LABEL; + gDropdownItemsArgs[1] = STR_SUFFIX; + + window_dropdown_show_text_custom_width( + w->x + widget->left, + w->y + widget->top, + widget->bottom - widget->top + 1, + w->colours[1], + DROPDOWN_FLAG_STAY_OPEN, + 2, + widget->right - widget->left - 3 + ); + + if(CurrencyDescriptors[CURRENCY_CUSTOM].affix_unicode == CURRENCY_PREFIX) { + dropdown_set_checked(0, true); + } else { + dropdown_set_checked(1, true); + } + + break; + + case WIDX_SYMBOL_TEXT: + window_text_input_raw_open( + w, + WIDX_SYMBOL_TEXT, + STR_CUSTOM_CURRENCY_SYMBOL_INPUT_TITLE, + STR_CUSTOM_CURRENCY_SYMBOL_INPUT_DESC, + CurrencyDescriptors[CURRENCY_CUSTOM].symbol_unicode, + CURRENCY_SYMBOL_MAX_SIZE + ); + break; + + } +} + +static void custom_currency_window_dropdown(rct_window *w, int widgetIndex, int dropdownIndex) +{ + if(dropdownIndex == -1) + return; + + if(widgetIndex == WIDX_AFFIX_DROPDOWN_BUTTON) { + + if(dropdownIndex == 0) { + CurrencyDescriptors[CURRENCY_CUSTOM].affix_ascii = CURRENCY_PREFIX; + CurrencyDescriptors[CURRENCY_CUSTOM].affix_unicode = CURRENCY_PREFIX; + } else if(dropdownIndex == 1) { + CurrencyDescriptors[CURRENCY_CUSTOM].affix_ascii = CURRENCY_SUFFIX; + CurrencyDescriptors[CURRENCY_CUSTOM].affix_unicode = CURRENCY_SUFFIX; + } + + + gConfigGeneral.custom_currency_affix = CurrencyDescriptors[CURRENCY_CUSTOM].affix_unicode; + config_save_default(); + + window_invalidate_all(); + + } +} + +static void custom_currency_window_text_input(struct rct_window *w, int windgetIndex, char *text) +{ + if(text != NULL) { + strncpy( + CurrencyDescriptors[CURRENCY_CUSTOM].symbol_unicode, + text, + CURRENCY_SYMBOL_MAX_SIZE + ); + + strncpy( + gConfigGeneral.custom_currency_symbol, + CurrencyDescriptors[CURRENCY_CUSTOM].symbol_unicode, + CURRENCY_SYMBOL_MAX_SIZE + ); + + config_save_default(); + window_invalidate_all(); + } +} + + +static void custom_currency_window_paint(rct_window *w, rct_drawpixelinfo *dpi) +{ + int x, y; + + set_format_arg(0, sint32, 100); + + window_draw_widgets(w, dpi); + + x = w->x + 10; + y = w->y + 30; + + gfx_draw_string_left(dpi, STR_RATE, NULL, w->colours[1], x, y); + + sint32 baseExchange = CurrencyDescriptors[CURRENCY_POUNDS].rate; + set_format_arg(0, sint32, baseExchange); + gfx_draw_string_left(dpi, STR_CUSTOM_CURRENCY_EQUIVALENCY, gCommonFormatArgs, w->colours[1], x + 200, y); + + y += 20; + + gfx_draw_string_left(dpi, STR_CURRENCY_SYMBOL_TEXT, NULL, w->colours[1], x, y); + + gfx_draw_string( + dpi, + CurrencyDescriptors[CURRENCY_CUSTOM].symbol_unicode, + w->colours[1], + w->x + window_custom_currency_widgets[WIDX_SYMBOL_TEXT].left + 1, + w->y + window_custom_currency_widgets[WIDX_SYMBOL_TEXT].top); + + if(CurrencyDescriptors[CURRENCY_CUSTOM].affix_unicode == CURRENCY_PREFIX) { + gfx_draw_string_left( + dpi, + STR_PREFIX, + w, + w->colours[1], + w->x + window_custom_currency_widgets[WIDX_AFFIX_DROPDOWN].left + 1, + w->y + window_custom_currency_widgets[WIDX_AFFIX_DROPDOWN].top + ); + } else { + gfx_draw_string_left( + dpi, + STR_SUFFIX, + w, + w->colours[1], + w->x + window_custom_currency_widgets[WIDX_AFFIX_DROPDOWN].left + 1, + w->y + window_custom_currency_widgets[WIDX_AFFIX_DROPDOWN].top + ); + } +} diff --git a/src/windows/options.c b/src/windows/options.c index 21dda00826..12b4e2e718 100644 --- a/src/windows/options.c +++ b/src/windows/options.c @@ -914,16 +914,27 @@ 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); + if(gConfigGeneral.currency_format == CURRENCY_CUSTOM){ + dropdown_set_checked(gConfigGeneral.currency_format + 1, true); + } else { + dropdown_set_checked(gConfigGeneral.currency_format, true); + } break; case WIDX_DISTANCE_DROPDOWN: gDropdownItemsFormat[0] = STR_DROPDOWN_MENU_LABEL; @@ -1181,7 +1192,12 @@ 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; + custom_currency_window_open(); + } else { + gConfigGeneral.currency_format = (sint8)dropdownIndex; + } config_save_default(); gfx_invalidate_screen(); break;