mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2026-01-19 21:13:05 +01:00
Add configuration support for the custom currency
This commit do several things: · Add proper entries to config.c file · Load custom currency definition at start time · Save every change made from the custom currency configuration window
This commit is contained in:
@@ -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, 1, 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 },
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -323,6 +323,11 @@ void openrct2_launch()
|
||||
}
|
||||
#endif // DISABLE_NETWORK
|
||||
|
||||
// Set custom currency properties
|
||||
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);
|
||||
|
||||
openrct2_loop();
|
||||
}
|
||||
openrct2_dispose();
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
#include "../localisation/localisation.h"
|
||||
#include "../interface/widget.h"
|
||||
#include "../config.h"
|
||||
#include "dropdown.h"
|
||||
|
||||
enum WINDOW_CUSTOM_CURRENCY_WIDGET_IDX {
|
||||
@@ -134,14 +135,18 @@ static void window_custom_currency_mousedown(int widgetIndex, rct_window*w, rct_
|
||||
|
||||
case WIDX_RATE_UP:
|
||||
CurrencyDescriptors[CURRENCY_CUSTOM].rate += 1;
|
||||
gConfigGeneral.custom_currency_rate = CurrencyDescriptors[CURRENCY_CUSTOM].rate;
|
||||
config_save_default();
|
||||
invalidate_money_widgets();
|
||||
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();
|
||||
invalidate_money_widgets();
|
||||
}
|
||||
invalidate_money_widgets();
|
||||
break;
|
||||
|
||||
case WIDX_AFFIX_DROPDOWN_BUTTON:
|
||||
@@ -161,7 +166,7 @@ static void window_custom_currency_mousedown(int widgetIndex, rct_window*w, rct_
|
||||
widget->right - widget->left - 3
|
||||
);
|
||||
|
||||
if(CurrencyDescriptors[CURRENCY_CUSTOM].affix_ascii == CURRENCY_PREFIX) {
|
||||
if(CurrencyDescriptors[CURRENCY_CUSTOM].affix_unicode == CURRENCY_PREFIX) {
|
||||
dropdown_set_checked(0, true);
|
||||
} else {
|
||||
dropdown_set_checked(1, true);
|
||||
@@ -197,6 +202,10 @@ static void window_custom_currency_dropdown(rct_window *w, int widgetIndex, int
|
||||
CurrencyDescriptors[CURRENCY_CUSTOM].affix_ascii = CurrencyDescriptors[CURRENCY_CUSTOM].affix_unicode = CURRENCY_SUFFIX;
|
||||
}
|
||||
|
||||
|
||||
gConfigGeneral.custom_currency_affix = CurrencyDescriptors[CURRENCY_CUSTOM].affix_unicode;
|
||||
config_save_default();
|
||||
|
||||
invalidate_money_widgets();
|
||||
|
||||
}
|
||||
@@ -205,6 +214,8 @@ static void window_custom_currency_dropdown(rct_window *w, int widgetIndex, int
|
||||
static void window_custom_currency_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();
|
||||
invalidate_money_widgets();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1197,7 +1197,7 @@ static void window_options_dropdown(rct_window *w, int widgetIndex, int dropdown
|
||||
window_custom_currency_open();
|
||||
} else {
|
||||
gConfigGeneral.currency_format = (sint8)dropdownIndex;
|
||||
} // TODO: Save current custom currency rate
|
||||
}
|
||||
config_save_default();
|
||||
gfx_invalidate_screen();
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user