Changeset - r28787:30f7f38912f1
[Not reviewed]
master
0 7 0
Rubidium - 10 months ago 2024-02-18 10:37:41
rubidium@openttd.org
Fix a253205: remove (now) unused currency separator
7 files changed with 50 insertions and 81 deletions:
0 comments (0 inline, 0 general)
src/currency.cpp
Show inline comments
 
@@ -12,73 +12,73 @@
 

	
 
#include "currency.h"
 
#include "news_func.h"
 
#include "settings_type.h"
 
#include "string_type.h"
 
#include "timer/timer.h"
 
#include "timer/timer_game_calendar.h"
 

	
 
#include "table/strings.h"
 

	
 
#include "safeguards.h"
 

	
 
	/*   exchange rate    prefix                             code
 
	 *   |  separator        |           postfix              |  symbol_pos
 
	 *   |   |   Euro year   |              |                 |     | name
 
	 *   |   |    |          |              |                 |     |  | */
 
	/*   exchange rate             postfix         code
 
	 *   |  Euro year              |               |     symbol_pos
 
	 *   |  |          prefix      |               |     | name
 
	 *   |  |          |           |               |     |  | */
 
/** The original currency specifications. */
 
static const CurrencySpec origin_currency_specs[CURRENCY_END] = {
 
	{    1, "", CF_NOEURO, "\u00a3",   "",             "GBP", 0, STR_GAME_OPTIONS_CURRENCY_GBP    }, ///< british pound
 
	{    2, "", CF_NOEURO, "$",        "",             "USD", 0, STR_GAME_OPTIONS_CURRENCY_USD    }, ///< american dollar
 
	{    2, "", CF_ISEURO, "\u20ac",   "",             "EUR", 0, STR_GAME_OPTIONS_CURRENCY_EUR    }, ///< euro
 
	{  220, "", CF_NOEURO, "\u00a5",   "",             "JPY", 0, STR_GAME_OPTIONS_CURRENCY_JPY    }, ///< japanese yen
 
	{   27, "", 2002,      "",         NBSP "S.",      "ATS", 1, STR_GAME_OPTIONS_CURRENCY_ATS    }, ///< austrian schilling
 
	{   81, "", 2002,      "BEF" NBSP, "",             "BEF", 0, STR_GAME_OPTIONS_CURRENCY_BEF    }, ///< belgian franc
 
	{    2, "", CF_NOEURO, "CHF" NBSP, "",             "CHF", 0, STR_GAME_OPTIONS_CURRENCY_CHF    }, ///< swiss franc
 
	{   41, "", CF_NOEURO, "",         NBSP "K\u010d", "CZK", 1, STR_GAME_OPTIONS_CURRENCY_CZK    }, ///< czech koruna
 
	{    4, "", 2002,      "DM" NBSP,  "",             "DEM", 0, STR_GAME_OPTIONS_CURRENCY_DEM    }, ///< deutsche mark
 
	{   11, "", CF_NOEURO, "",         NBSP "kr",      "DKK", 1, STR_GAME_OPTIONS_CURRENCY_DKK    }, ///< danish krone
 
	{  333, "", 2002,      "Pts" NBSP, "",             "ESP", 0, STR_GAME_OPTIONS_CURRENCY_ESP    }, ///< spanish peseta
 
	{   12, "", 2002,      "",         NBSP "mk",      "FIM", 1, STR_GAME_OPTIONS_CURRENCY_FIM    }, ///< finnish markka
 
	{   13, "", 2002,      "FF" NBSP,  "",             "FRF", 0, STR_GAME_OPTIONS_CURRENCY_FRF    }, ///< french franc
 
	{  681, "", 2002,      "",         "Dr.",          "GRD", 1, STR_GAME_OPTIONS_CURRENCY_GRD    }, ///< greek drachma
 
	{  378, "", CF_NOEURO, "",         NBSP "Ft",      "HUF", 1, STR_GAME_OPTIONS_CURRENCY_HUF    }, ///< hungarian forint
 
	{  130, "", CF_NOEURO, "",         NBSP "Kr",      "ISK", 1, STR_GAME_OPTIONS_CURRENCY_ISK    }, ///< icelandic krona
 
	{ 3873, "", 2002,      "",         NBSP "L.",      "ITL", 1, STR_GAME_OPTIONS_CURRENCY_ITL    }, ///< italian lira
 
	{    4, "", 2002,      "NLG" NBSP, "",             "NLG", 0, STR_GAME_OPTIONS_CURRENCY_NLG    }, ///< dutch gulden
 
	{   12, "", CF_NOEURO, "",         NBSP "Kr",      "NOK", 1, STR_GAME_OPTIONS_CURRENCY_NOK    }, ///< norwegian krone
 
	{    6, "", CF_NOEURO, "",         NBSP "z\u0142", "PLN", 1, STR_GAME_OPTIONS_CURRENCY_PLN    }, ///< polish zloty
 
	{    5, "", CF_NOEURO, "",         NBSP "Lei",     "RON", 1, STR_GAME_OPTIONS_CURRENCY_RON    }, ///< romanian leu
 
	{   50, "", CF_NOEURO, "",         NBSP "p",       "RUR", 1, STR_GAME_OPTIONS_CURRENCY_RUR    }, ///< russian rouble
 
	{  479, "", 2007,      "",         NBSP "SIT",     "SIT", 1, STR_GAME_OPTIONS_CURRENCY_SIT    }, ///< slovenian tolar
 
	{   13, "", CF_NOEURO, "",         NBSP "Kr",      "SEK", 1, STR_GAME_OPTIONS_CURRENCY_SEK    }, ///< swedish krona
 
	{    3, "", CF_NOEURO, "",         NBSP "TL",      "TRY", 1, STR_GAME_OPTIONS_CURRENCY_TRY    }, ///< turkish lira
 
	{   60, "", 2009,      "",         NBSP "Sk",      "SKK", 1, STR_GAME_OPTIONS_CURRENCY_SKK    }, ///< slovak koruna
 
	{    4, "", CF_NOEURO, "R$" NBSP,  "",             "BRL", 0, STR_GAME_OPTIONS_CURRENCY_BRL    }, ///< brazil real
 
	{   31, "", 2011,      "",         NBSP "EEK",     "EEK", 1, STR_GAME_OPTIONS_CURRENCY_EEK    }, ///< estonian krooni
 
	{    4, "", 2015,      "",         NBSP "Lt",      "LTL", 1, STR_GAME_OPTIONS_CURRENCY_LTL    }, ///< lithuanian litas
 
	{ 1850, "", CF_NOEURO, "\u20a9",   "",             "KRW", 0, STR_GAME_OPTIONS_CURRENCY_KRW    }, ///< south korean won
 
	{   13, "", CF_NOEURO, "R" NBSP,   "",             "ZAR", 0, STR_GAME_OPTIONS_CURRENCY_ZAR    }, ///< south african rand
 
	{    1, "", CF_NOEURO, "",         "",             "",    2, STR_GAME_OPTIONS_CURRENCY_CUSTOM }, ///< custom currency (add further languages below)
 
	{    3, "", CF_NOEURO, "",         NBSP "GEL",     "GEL", 1, STR_GAME_OPTIONS_CURRENCY_GEL    }, ///< Georgian Lari
 
	{ 4901, "", CF_NOEURO, "",         NBSP "Rls",     "IRR", 1, STR_GAME_OPTIONS_CURRENCY_IRR    }, ///< Iranian Rial
 
	{   80, "", CF_NOEURO, "",         NBSP "rub",     "RUB", 1, STR_GAME_OPTIONS_CURRENCY_RUB    }, ///< New Russian Ruble
 
	{   24, "", CF_NOEURO, "$",        "",             "MXN", 0, STR_GAME_OPTIONS_CURRENCY_MXN    }, ///< Mexican peso
 
	{   40, "", CF_NOEURO, "NTD" NBSP, "",             "NTD", 0, STR_GAME_OPTIONS_CURRENCY_NTD    }, ///< new taiwan dollar
 
	{    8, "", CF_NOEURO, "\u00a5",   "",             "CNY", 0, STR_GAME_OPTIONS_CURRENCY_CNY    }, ///< chinese renminbi
 
	{   10, "", CF_NOEURO, "HKD" NBSP, "",             "HKD", 0, STR_GAME_OPTIONS_CURRENCY_HKD    }, ///< hong kong dollar
 
	{   90, "", CF_NOEURO, "\u20b9",   "",             "INR", 0, STR_GAME_OPTIONS_CURRENCY_INR    }, ///< Indian Rupee
 
	{   19, "", CF_NOEURO, "Rp",       "",             "IDR", 0, STR_GAME_OPTIONS_CURRENCY_IDR    }, ///< Indonesian Rupiah
 
	{    5, "", CF_NOEURO, "RM",       "",             "MYR", 0, STR_GAME_OPTIONS_CURRENCY_MYR    }, ///< Malaysian Ringgit
 
	{    1, "", 2014,      "",         NBSP "Ls",      "LVL", 1, STR_GAME_OPTIONS_CURRENCY_LVL    }, ///< latvian lats
 
	{    1, CF_NOEURO, "\u00a3",   "",             "GBP", 0, STR_GAME_OPTIONS_CURRENCY_GBP    }, ///< british pound
 
	{    2, CF_NOEURO, "$",        "",             "USD", 0, STR_GAME_OPTIONS_CURRENCY_USD    }, ///< american dollar
 
	{    2, CF_ISEURO, "\u20ac",   "",             "EUR", 0, STR_GAME_OPTIONS_CURRENCY_EUR    }, ///< euro
 
	{  220, CF_NOEURO, "\u00a5",   "",             "JPY", 0, STR_GAME_OPTIONS_CURRENCY_JPY    }, ///< japanese yen
 
	{   27, 2002,      "",         NBSP "S.",      "ATS", 1, STR_GAME_OPTIONS_CURRENCY_ATS    }, ///< austrian schilling
 
	{   81, 2002,      "BEF" NBSP, "",             "BEF", 0, STR_GAME_OPTIONS_CURRENCY_BEF    }, ///< belgian franc
 
	{    2, CF_NOEURO, "CHF" NBSP, "",             "CHF", 0, STR_GAME_OPTIONS_CURRENCY_CHF    }, ///< swiss franc
 
	{   41, CF_NOEURO, "",         NBSP "K\u010d", "CZK", 1, STR_GAME_OPTIONS_CURRENCY_CZK    }, ///< czech koruna
 
	{    4, 2002,      "DM" NBSP,  "",             "DEM", 0, STR_GAME_OPTIONS_CURRENCY_DEM    }, ///< deutsche mark
 
	{   11, CF_NOEURO, "",         NBSP "kr",      "DKK", 1, STR_GAME_OPTIONS_CURRENCY_DKK    }, ///< danish krone
 
	{  333, 2002,      "Pts" NBSP, "",             "ESP", 0, STR_GAME_OPTIONS_CURRENCY_ESP    }, ///< spanish peseta
 
	{   12, 2002,      "",         NBSP "mk",      "FIM", 1, STR_GAME_OPTIONS_CURRENCY_FIM    }, ///< finnish markka
 
	{   13, 2002,      "FF" NBSP,  "",             "FRF", 0, STR_GAME_OPTIONS_CURRENCY_FRF    }, ///< french franc
 
	{  681, 2002,      "",         "Dr.",          "GRD", 1, STR_GAME_OPTIONS_CURRENCY_GRD    }, ///< greek drachma
 
	{  378, CF_NOEURO, "",         NBSP "Ft",      "HUF", 1, STR_GAME_OPTIONS_CURRENCY_HUF    }, ///< hungarian forint
 
	{  130, CF_NOEURO, "",         NBSP "Kr",      "ISK", 1, STR_GAME_OPTIONS_CURRENCY_ISK    }, ///< icelandic krona
 
	{ 3873, 2002,      "",         NBSP "L.",      "ITL", 1, STR_GAME_OPTIONS_CURRENCY_ITL    }, ///< italian lira
 
	{    4, 2002,      "NLG" NBSP, "",             "NLG", 0, STR_GAME_OPTIONS_CURRENCY_NLG    }, ///< dutch gulden
 
	{   12, CF_NOEURO, "",         NBSP "Kr",      "NOK", 1, STR_GAME_OPTIONS_CURRENCY_NOK    }, ///< norwegian krone
 
	{    6, CF_NOEURO, "",         NBSP "z\u0142", "PLN", 1, STR_GAME_OPTIONS_CURRENCY_PLN    }, ///< polish zloty
 
	{    5, CF_NOEURO, "",         NBSP "Lei",     "RON", 1, STR_GAME_OPTIONS_CURRENCY_RON    }, ///< romanian leu
 
	{   50, CF_NOEURO, "",         NBSP "p",       "RUR", 1, STR_GAME_OPTIONS_CURRENCY_RUR    }, ///< russian rouble
 
	{  479, 2007,      "",         NBSP "SIT",     "SIT", 1, STR_GAME_OPTIONS_CURRENCY_SIT    }, ///< slovenian tolar
 
	{   13, CF_NOEURO, "",         NBSP "Kr",      "SEK", 1, STR_GAME_OPTIONS_CURRENCY_SEK    }, ///< swedish krona
 
	{    3, CF_NOEURO, "",         NBSP "TL",      "TRY", 1, STR_GAME_OPTIONS_CURRENCY_TRY    }, ///< turkish lira
 
	{   60, 2009,      "",         NBSP "Sk",      "SKK", 1, STR_GAME_OPTIONS_CURRENCY_SKK    }, ///< slovak koruna
 
	{    4, CF_NOEURO, "R$" NBSP,  "",             "BRL", 0, STR_GAME_OPTIONS_CURRENCY_BRL    }, ///< brazil real
 
	{   31, 2011,      "",         NBSP "EEK",     "EEK", 1, STR_GAME_OPTIONS_CURRENCY_EEK    }, ///< estonian krooni
 
	{    4, 2015,      "",         NBSP "Lt",      "LTL", 1, STR_GAME_OPTIONS_CURRENCY_LTL    }, ///< lithuanian litas
 
	{ 1850, CF_NOEURO, "\u20a9",   "",             "KRW", 0, STR_GAME_OPTIONS_CURRENCY_KRW    }, ///< south korean won
 
	{   13, CF_NOEURO, "R" NBSP,   "",             "ZAR", 0, STR_GAME_OPTIONS_CURRENCY_ZAR    }, ///< south african rand
 
	{    1, CF_NOEURO, "",         "",             "",    2, STR_GAME_OPTIONS_CURRENCY_CUSTOM }, ///< custom currency (add further languages below)
 
	{    3, CF_NOEURO, "",         NBSP "GEL",     "GEL", 1, STR_GAME_OPTIONS_CURRENCY_GEL    }, ///< Georgian Lari
 
	{ 4901, CF_NOEURO, "",         NBSP "Rls",     "IRR", 1, STR_GAME_OPTIONS_CURRENCY_IRR    }, ///< Iranian Rial
 
	{   80, CF_NOEURO, "",         NBSP "rub",     "RUB", 1, STR_GAME_OPTIONS_CURRENCY_RUB    }, ///< New Russian Ruble
 
	{   24, CF_NOEURO, "$",        "",             "MXN", 0, STR_GAME_OPTIONS_CURRENCY_MXN    }, ///< Mexican peso
 
	{   40, CF_NOEURO, "NTD" NBSP, "",             "NTD", 0, STR_GAME_OPTIONS_CURRENCY_NTD    }, ///< new taiwan dollar
 
	{    8, CF_NOEURO, "\u00a5",   "",             "CNY", 0, STR_GAME_OPTIONS_CURRENCY_CNY    }, ///< chinese renminbi
 
	{   10, CF_NOEURO, "HKD" NBSP, "",             "HKD", 0, STR_GAME_OPTIONS_CURRENCY_HKD    }, ///< hong kong dollar
 
	{   90, CF_NOEURO, "\u20b9",   "",             "INR", 0, STR_GAME_OPTIONS_CURRENCY_INR    }, ///< Indian Rupee
 
	{   19, CF_NOEURO, "Rp",       "",             "IDR", 0, STR_GAME_OPTIONS_CURRENCY_IDR    }, ///< Indonesian Rupiah
 
	{    5, CF_NOEURO, "RM",       "",             "MYR", 0, STR_GAME_OPTIONS_CURRENCY_MYR    }, ///< Malaysian Ringgit
 
	{    1, 2014,      "",         NBSP "Ls",      "LVL", 1, STR_GAME_OPTIONS_CURRENCY_LVL    }, ///< latvian lats
 
};
 

	
 
/** Array of currencies used by the system */
 
CurrencySpec _currency_specs[CURRENCY_END];
 

	
 
/**
 
 * This array represent the position of OpenTTD's currencies,
 
 * compared to TTDPatch's ones.
 
 * When a grf sends currencies, they are based on the order defined by TTDPatch.
 
 * So, we must reindex them to our own order.
 
 */
 
const byte TTDPatch_To_OTTDIndex[] =
src/currency.h
Show inline comments
 
@@ -64,45 +64,44 @@ enum Currencies {
 
	CURRENCY_CNY,       ///< Chinese Renminbi
 
	CURRENCY_HKD,       ///< Hong Kong Dollar
 
	CURRENCY_INR,       ///< Indian Rupee
 
	CURRENCY_IDR,       ///< Indonesian Rupiah
 
	CURRENCY_MYR,       ///< Malaysian Ringgit
 
	CURRENCY_LVL,       ///< Latvian Lats
 
	CURRENCY_END,       ///< always the last item
 
};
 

	
 
/** Specification of a currency. */
 
struct CurrencySpec {
 
	uint16_t rate;           ///< The conversion rate compared to the base currency.
 
	std::string separator; ///< The thousands separator for this currency.
 
	TimerGameCalendar::Year to_euro; ///< Year of switching to the Euro. May also be #CF_NOEURO or #CF_ISEURO.
 
	std::string prefix;    ///< Prefix to apply when formatting money in this currency.
 
	std::string suffix;    ///< Suffix to apply when formatting money in this currency.
 
	std::string code; ///< 3 letter untranslated code to identify the currency.
 
	/**
 
	 * The currency symbol is represented by two possible values, prefix and suffix
 
	 * Usage of one or the other is determined by #symbol_pos.
 
	 * 0 = prefix
 
	 * 1 = suffix
 
	 * 2 = both : Special case only for custom currency.
 
	 *            It is not a spec from Newgrf,
 
	 *            rather a way to let users do what they want with custom currency
 
	 */
 
	byte symbol_pos;
 
	StringID name;
 

	
 
	CurrencySpec() = default;
 

	
 
	CurrencySpec(uint16_t rate, const char *separator, TimerGameCalendar::Year to_euro, const char *prefix, const char *suffix, const char *code, byte symbol_pos, StringID name) :
 
		rate(rate), separator(separator), to_euro(to_euro), prefix(prefix), suffix(suffix), code(code), symbol_pos(symbol_pos), name(name)
 
	CurrencySpec(uint16_t rate, TimerGameCalendar::Year to_euro, const char *prefix, const char *suffix, const char *code, byte symbol_pos, StringID name) :
 
		rate(rate), to_euro(to_euro), prefix(prefix), suffix(suffix), code(code), symbol_pos(symbol_pos), name(name)
 
	{
 
	}
 
};
 

	
 
extern CurrencySpec _currency_specs[CURRENCY_END];
 

	
 
/* XXX small hack, but makes the rest of the code a bit nicer to read */
 
#define _custom_currency (_currency_specs[CURRENCY_CUSTOM])
 
#define _currency ((const CurrencySpec*)&_currency_specs[GetGameSettings().locale.currency])
 

	
 
uint64_t GetMaskOfAllowedCurrencies();
 
void ResetCurrencies(bool preserve_custom = true);
src/lang/english.txt
Show inline comments
 
@@ -1108,27 +1108,24 @@ STR_BASESET_STATUS                      
 

	
 
STR_ERROR_RESOLUTION_LIST_FAILED                                :{WHITE}Failed to retrieve a list of supported resolutions
 
STR_ERROR_FULLSCREEN_FAILED                                     :{WHITE}Fullscreen mode failed
 

	
 
# Custom currency window
 

	
 
STR_CURRENCY_WINDOW                                             :{WHITE}Custom currency
 
STR_CURRENCY_EXCHANGE_RATE                                      :{LTBLUE}Exchange rate: {ORANGE}{CURRENCY_LONG} = £ {COMMA}
 
STR_CURRENCY_DECREASE_EXCHANGE_RATE_TOOLTIP                     :{BLACK}Decrease the amount of your currency for one Pound (£)
 
STR_CURRENCY_INCREASE_EXCHANGE_RATE_TOOLTIP                     :{BLACK}Increase the amount of your currency for one Pound (£)
 
STR_CURRENCY_SET_EXCHANGE_RATE_TOOLTIP                          :{BLACK}Set the exchange rate of your currency for one Pound (£)
 

	
 
STR_CURRENCY_SEPARATOR                                          :{LTBLUE}Separator: {ORANGE}{RAW_STRING}
 
STR_CURRENCY_SET_CUSTOM_CURRENCY_SEPARATOR_TOOLTIP              :{BLACK}Set the separator for your currency
 

	
 
STR_CURRENCY_PREFIX                                             :{LTBLUE}Prefix: {ORANGE}{RAW_STRING}
 
STR_CURRENCY_SET_CUSTOM_CURRENCY_PREFIX_TOOLTIP                 :{BLACK}Set the prefix string for your currency
 
STR_CURRENCY_SUFFIX                                             :{LTBLUE}Suffix: {ORANGE}{RAW_STRING}
 
STR_CURRENCY_SET_CUSTOM_CURRENCY_SUFFIX_TOOLTIP                 :{BLACK}Set the suffix string for your currency
 

	
 
STR_CURRENCY_SWITCH_TO_EURO                                     :{LTBLUE}Switch to Euro: {ORANGE}{NUM}
 
STR_CURRENCY_SWITCH_TO_EURO_NEVER                               :{LTBLUE}Switch to Euro: {ORANGE}never
 
STR_CURRENCY_SET_CUSTOM_CURRENCY_TO_EURO_TOOLTIP                :{BLACK}Set the year to switch to Euro
 
STR_CURRENCY_DECREASE_CUSTOM_CURRENCY_TO_EURO_TOOLTIP           :{BLACK}Switch to Euro earlier
 
STR_CURRENCY_INCREASE_CUSTOM_CURRENCY_TO_EURO_TOOLTIP           :{BLACK}Switch to Euro later
 

	
 
STR_CURRENCY_PREVIEW                                            :{LTBLUE}Preview: {ORANGE}{CURRENCY_LONG}
src/newgrf.cpp
Show inline comments
 
@@ -2737,26 +2737,25 @@ static ChangeInfoResult GlobalVarChangeI
 
					_currency_specs[curidx].rate = rate / 1000;
 
				} else {
 
					GrfMsg(1, "GlobalVarChangeInfo: Currency multipliers {} out of range, ignoring", curidx);
 
				}
 
				break;
 
			}
 

	
 
			case 0x0C: { // Currency options
 
				uint curidx = GetNewgrfCurrencyIdConverted(gvid + i);
 
				uint16_t options = buf->ReadWord();
 

	
 
				if (curidx < CURRENCY_END) {
 
					_currency_specs[curidx].separator.clear();
 
					_currency_specs[curidx].separator.push_back(GB(options, 0, 8));
 
					/* Ignore the thousands separator, as this is a translated thing. */
 
					/* By specifying only one bit, we prevent errors,
 
					 * since newgrf specs said that only 0 and 1 can be set for symbol_pos */
 
					_currency_specs[curidx].symbol_pos = GB(options, 8, 1);
 
				} else {
 
					GrfMsg(1, "GlobalVarChangeInfo: Currency option {} out of range, ignoring", curidx);
 
				}
 
				break;
 
			}
 

	
 
			case 0x0D: { // Currency prefix symbol
 
				uint curidx = GetNewgrfCurrencyIdConverted(gvid + i);
 
				std::string prefix = ReadDWordAsString(buf);
src/settings_gui.cpp
Show inline comments
 
@@ -2980,25 +2980,24 @@ struct CustomCurrencyWindow : Window {
 
	void SetButtonState()
 
	{
 
		this->SetWidgetDisabledState(WID_CC_RATE_DOWN, _custom_currency.rate == 1);
 
		this->SetWidgetDisabledState(WID_CC_RATE_UP, _custom_currency.rate == UINT16_MAX);
 
		this->SetWidgetDisabledState(WID_CC_YEAR_DOWN, _custom_currency.to_euro == CF_NOEURO);
 
		this->SetWidgetDisabledState(WID_CC_YEAR_UP, _custom_currency.to_euro == CalendarTime::MAX_YEAR);
 
	}
 

	
 
	void SetStringParameters(WidgetID widget) const override
 
	{
 
		switch (widget) {
 
			case WID_CC_RATE:      SetDParam(0, 1); SetDParam(1, 1);            break;
 
			case WID_CC_SEPARATOR: SetDParamStr(0, _custom_currency.separator); break;
 
			case WID_CC_PREFIX:    SetDParamStr(0, _custom_currency.prefix);    break;
 
			case WID_CC_SUFFIX:    SetDParamStr(0, _custom_currency.suffix);    break;
 
			case WID_CC_YEAR:
 
				SetDParam(0, (_custom_currency.to_euro != CF_NOEURO) ? STR_CURRENCY_SWITCH_TO_EURO : STR_CURRENCY_SWITCH_TO_EURO_NEVER);
 
				SetDParam(1, _custom_currency.to_euro);
 
				break;
 

	
 
			case WID_CC_PREVIEW:
 
				SetDParam(0, 10000);
 
				break;
 
		}
 
	}
 
@@ -3006,25 +3005,24 @@ struct CustomCurrencyWindow : Window {
 
	void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override
 
	{
 
		switch (widget) {
 
			/* Set the appropriate width for the up/down buttons. */
 
			case WID_CC_RATE_DOWN:
 
			case WID_CC_RATE_UP:
 
			case WID_CC_YEAR_DOWN:
 
			case WID_CC_YEAR_UP:
 
				*size = maxdim(*size, {(uint)SETTING_BUTTON_WIDTH / 2, (uint)SETTING_BUTTON_HEIGHT});
 
				break;
 

	
 
			/* Set the appropriate width for the edit buttons. */
 
			case WID_CC_SEPARATOR_EDIT:
 
			case WID_CC_PREFIX_EDIT:
 
			case WID_CC_SUFFIX_EDIT:
 
				*size = maxdim(*size, {(uint)SETTING_BUTTON_WIDTH, (uint)SETTING_BUTTON_HEIGHT});
 
				break;
 

	
 
			/* Make sure the window is wide enough for the widest exchange rate */
 
			case WID_CC_RATE:
 
				SetDParam(0, 1);
 
				SetDParam(1, INT32_MAX);
 
				*size = GetStringBoundingBox(STR_CURRENCY_EXCHANGE_RATE);
 
				break;
 
		}
 
@@ -3049,32 +3047,24 @@ struct CustomCurrencyWindow : Window {
 
				if (_custom_currency.rate == UINT16_MAX) this->DisableWidget(WID_CC_RATE_UP);
 
				this->EnableWidget(WID_CC_RATE_DOWN);
 
				break;
 

	
 
			case WID_CC_RATE:
 
				SetDParam(0, _custom_currency.rate);
 
				str = STR_JUST_INT;
 
				len = 5;
 
				line = WID_CC_RATE;
 
				afilter = CS_NUMERAL;
 
				break;
 

	
 
			case WID_CC_SEPARATOR_EDIT:
 
			case WID_CC_SEPARATOR:
 
				SetDParamStr(0, _custom_currency.separator);
 
				str = STR_JUST_RAW_STRING;
 
				len = 7;
 
				line = WID_CC_SEPARATOR;
 
				break;
 

	
 
			case WID_CC_PREFIX_EDIT:
 
			case WID_CC_PREFIX:
 
				SetDParamStr(0, _custom_currency.prefix);
 
				str = STR_JUST_RAW_STRING;
 
				len = 15;
 
				line = WID_CC_PREFIX;
 
				break;
 

	
 
			case WID_CC_SUFFIX_EDIT:
 
			case WID_CC_SUFFIX:
 
				SetDParamStr(0, _custom_currency.suffix);
 
				str = STR_JUST_RAW_STRING;
 
@@ -3112,28 +3102,24 @@ struct CustomCurrencyWindow : Window {
 
		this->SetDirty();
 
	}
 

	
 
	void OnQueryTextFinished(char *str) override
 
	{
 
		if (str == nullptr) return;
 

	
 
		switch (this->query_widget) {
 
			case WID_CC_RATE:
 
				_custom_currency.rate = Clamp(atoi(str), 1, UINT16_MAX);
 
				break;
 

	
 
			case WID_CC_SEPARATOR: // Thousands separator
 
				_custom_currency.separator = str;
 
				break;
 

	
 
			case WID_CC_PREFIX:
 
				_custom_currency.prefix = str;
 
				break;
 

	
 
			case WID_CC_SUFFIX:
 
				_custom_currency.suffix = str;
 
				break;
 

	
 
			case WID_CC_YEAR: { // Year to switch to euro
 
				TimerGameCalendar::Year val = atoi(str);
 

	
 
				_custom_currency.to_euro = (val < MIN_EURO_YEAR ? CF_NOEURO : std::min(val, CalendarTime::MAX_YEAR));
 
@@ -3157,28 +3143,24 @@ static constexpr NWidgetPart _nested_cus
 
	EndContainer(),
 
	NWidget(WWT_PANEL, COLOUR_GREY),
 
		NWidget(NWID_VERTICAL), SetPIP(0, WidgetDimensions::unscaled.vsep_wide, 0), SetPadding(WidgetDimensions::unscaled.sparse),
 
			NWidget(NWID_VERTICAL, NC_EQUALSIZE), SetPIP(0, WidgetDimensions::unscaled.vsep_normal, 0),
 
				NWidget(NWID_HORIZONTAL), SetPIP(0, WidgetDimensions::unscaled.hsep_wide, 0),
 
					NWidget(NWID_HORIZONTAL, NC_EQUALSIZE),
 
						NWidget(WWT_PUSHARROWBTN, COLOUR_YELLOW, WID_CC_RATE_DOWN), SetDataTip(AWV_DECREASE, STR_CURRENCY_DECREASE_EXCHANGE_RATE_TOOLTIP),
 
						NWidget(WWT_PUSHARROWBTN, COLOUR_YELLOW, WID_CC_RATE_UP), SetDataTip(AWV_INCREASE, STR_CURRENCY_INCREASE_EXCHANGE_RATE_TOOLTIP),
 
					EndContainer(),
 
					NWidget(WWT_TEXT, COLOUR_BLUE, WID_CC_RATE), SetDataTip(STR_CURRENCY_EXCHANGE_RATE, STR_CURRENCY_SET_EXCHANGE_RATE_TOOLTIP), SetFill(1, 0),
 
				EndContainer(),
 
				NWidget(NWID_HORIZONTAL), SetPIP(0, WidgetDimensions::unscaled.hsep_wide, 0),
 
					NWidget(WWT_PUSHBTN, COLOUR_DARK_BLUE, WID_CC_SEPARATOR_EDIT), SetDataTip(0x0, STR_CURRENCY_SET_CUSTOM_CURRENCY_SEPARATOR_TOOLTIP), SetFill(0, 1),
 
					NWidget(WWT_TEXT, COLOUR_BLUE, WID_CC_SEPARATOR), SetDataTip(STR_CURRENCY_SEPARATOR, STR_CURRENCY_SET_CUSTOM_CURRENCY_SEPARATOR_TOOLTIP), SetFill(1, 0),
 
				EndContainer(),
 
				NWidget(NWID_HORIZONTAL), SetPIP(0, WidgetDimensions::unscaled.hsep_wide, 0),
 
					NWidget(WWT_PUSHBTN, COLOUR_DARK_BLUE, WID_CC_PREFIX_EDIT), SetDataTip(0x0, STR_CURRENCY_SET_CUSTOM_CURRENCY_PREFIX_TOOLTIP), SetFill(0, 1),
 
					NWidget(WWT_TEXT, COLOUR_BLUE, WID_CC_PREFIX), SetDataTip(STR_CURRENCY_PREFIX, STR_CURRENCY_SET_CUSTOM_CURRENCY_PREFIX_TOOLTIP), SetFill(1, 0),
 
				EndContainer(),
 
				NWidget(NWID_HORIZONTAL), SetPIP(0, WidgetDimensions::unscaled.hsep_wide, 0),
 
					NWidget(WWT_PUSHBTN, COLOUR_DARK_BLUE, WID_CC_SUFFIX_EDIT), SetDataTip(0x0, STR_CURRENCY_SET_CUSTOM_CURRENCY_SUFFIX_TOOLTIP), SetFill(0, 1),
 
					NWidget(WWT_TEXT, COLOUR_BLUE, WID_CC_SUFFIX), SetDataTip(STR_CURRENCY_SUFFIX, STR_CURRENCY_SET_CUSTOM_CURRENCY_SUFFIX_TOOLTIP), SetFill(1, 0),
 
				EndContainer(),
 
				NWidget(NWID_HORIZONTAL), SetPIP(0, WidgetDimensions::unscaled.hsep_wide, 0),
 
					NWidget(NWID_HORIZONTAL, NC_EQUALSIZE),
 
						NWidget(WWT_PUSHARROWBTN, COLOUR_YELLOW, WID_CC_YEAR_DOWN), SetDataTip(AWV_DECREASE, STR_CURRENCY_DECREASE_CUSTOM_CURRENCY_TO_EURO_TOOLTIP),
 
						NWidget(WWT_PUSHARROWBTN, COLOUR_YELLOW, WID_CC_YEAR_UP), SetDataTip(AWV_INCREASE, STR_CURRENCY_INCREASE_CUSTOM_CURRENCY_TO_EURO_TOOLTIP),
 
					EndContainer(),
src/table/settings/currency_settings.ini
Show inline comments
 
@@ -34,30 +34,24 @@ to       = SL_MAX_VERSION
 
cat      = SC_ADVANCED
 
extra    = 0
 
startup  = false
 

	
 

	
 
[SDT_VAR]
 
var      = rate
 
type     = SLE_UINT16
 
def      = 1
 
min      = 0
 
max      = UINT16_MAX
 

	
 
[SDT_SSTR]
 
var      = separator
 
type     = SLE_STRQ
 
def      = "".""
 
cat      = SC_BASIC
 

	
 
[SDT_VAR]
 
var      = to_euro
 
type     = SLE_INT32
 
def      = 0
 
min      = CalendarTime::MIN_YEAR
 
max      = CalendarTime::MAX_YEAR
 

	
 
[SDT_SSTR]
 
var      = prefix
 
type     = SLE_STRQ
 
def      = nullptr
 

	
src/widgets/settings_widget.h
Show inline comments
 
@@ -73,25 +73,23 @@ enum GameSettingsWidgets : WidgetID {
 
	WID_GS_RESTRICT_TYPE,      ///< Label upfront to the type drop-down box to restrict the list of settings to show
 
	WID_GS_RESTRICT_DROPDOWN,  ///< The drop down box to restrict the list of settings
 
	WID_GS_TYPE_DROPDOWN,      ///< The drop down box to choose client/game/company/all settings
 

	
 
	WID_GS_SETTING_DROPDOWN = -1, ///< Dynamically created dropdown for changing setting value.
 
};
 

	
 
/** Widgets of the #CustomCurrencyWindow class. */
 
enum CustomCurrencyWidgets : WidgetID {
 
	WID_CC_RATE_DOWN,      ///< Down button.
 
	WID_CC_RATE_UP,        ///< Up button.
 
	WID_CC_RATE,           ///< Rate of currency.
 
	WID_CC_SEPARATOR_EDIT, ///< Separator edit button.
 
	WID_CC_SEPARATOR,      ///< Current separator.
 
	WID_CC_PREFIX_EDIT,    ///< Prefix edit button.
 
	WID_CC_PREFIX,         ///< Current prefix.
 
	WID_CC_SUFFIX_EDIT,    ///< Suffix edit button.
 
	WID_CC_SUFFIX,         ///< Current suffix.
 
	WID_CC_YEAR_DOWN,      ///< Down button.
 
	WID_CC_YEAR_UP,        ///< Up button.
 
	WID_CC_YEAR,           ///< Year of introduction.
 
	WID_CC_PREVIEW,        ///< Preview.
 
};
 

	
 
#endif /* WIDGETS_SETTINGS_WIDGET_H */
0 comments (0 inline, 0 general)