1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-06 06:32:56 +01:00

Merge pull request #3952 from gDanix/custom-currency

Implement custom currencies.
This commit is contained in:
Ted John
2016-07-02 13:46:08 +01:00
committed by GitHub
13 changed files with 367 additions and 9 deletions

View File

@@ -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 = "<group>"; };
D45A39571CF3007A00659A24 /* speexdsp_config_types.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = speexdsp_config_types.h; sourceTree = "<group>"; };
D45A39581CF3007A00659A24 /* speexdsp_types.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = speexdsp_types.h; sourceTree = "<group>"; };
D45B202C1D1E92DB00B67CC7 /* custom_currency.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = custom_currency.c; sourceTree = "<group>"; };
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 = "<group>"; 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 */,

View File

@@ -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)

View File

@@ -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 #

View File

@@ -257,6 +257,7 @@
<ClCompile Include="src\windows\banner.c" />
<ClCompile Include="src\windows\cheats.c" />
<ClCompile Include="src\windows\clear_scenery.c" />
<ClCompile Include="src\windows\custom_currency.c" />
<ClCompile Include="src\windows\demolish_ride_prompt.c" />
<ClCompile Include="src\windows\dropdown.c" />
<ClCompile Include="src\windows\editor_bottom_toolbar.c" />
@@ -568,4 +569,4 @@
</ItemDefinitionGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets" />
</Project>
</Project>

View File

@@ -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;
}

View File

@@ -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;

View File

@@ -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();

View File

@@ -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);
}

View File

@@ -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

View File

@@ -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);

View File

@@ -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
};

View File

@@ -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
);
}
}

View File

@@ -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;