2 * This file is part of OpenTTD.
3 * OpenTTD 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, version 2.
4 * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
5 * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
8 /** @file currency.h Functions to handle different currencies. */
13 #include "date_type.h"
14 #include "string_func.h"
15 #include "strings_type.h"
17 static const int CF_NOEURO
= 0; ///< Currency never switches to the Euro (as far as known).
18 static const int CF_ISEURO
= 1; ///< Currency _is_ the Euro.
21 * This enum gives the currencies a unique id which must be maintained for
22 * savegame compatibility and in order to refer to them quickly, especially
23 * for referencing the custom one.
26 CURRENCY_GBP
, ///< British Pound
27 CURRENCY_USD
, ///< US Dollar
28 CURRENCY_EUR
, ///< Euro
29 CURRENCY_JPY
, ///< Japanese Yen
30 CURRENCY_ATS
, ///< Austrian Schilling
31 CURRENCY_BEF
, ///< Belgian Franc
32 CURRENCY_CHF
, ///< Swiss Franc
33 CURRENCY_CZK
, ///< Czech Koruna
34 CURRENCY_DEM
, ///< Deutsche Mark
35 CURRENCY_DKK
, ///< Danish Krona
36 CURRENCY_ESP
, ///< Spanish Peseta
37 CURRENCY_FIM
, ///< Finish Markka
38 CURRENCY_FRF
, ///< French Franc
39 CURRENCY_GRD
, ///< Greek Drachma
40 CURRENCY_HUF
, ///< Hungarian Forint
41 CURRENCY_ISK
, ///< Icelandic Krona
42 CURRENCY_ITL
, ///< Italian Lira
43 CURRENCY_NLG
, ///< Dutch Gulden
44 CURRENCY_NOK
, ///< Norwegian Krone
45 CURRENCY_PLN
, ///< Polish Zloty
46 CURRENCY_RON
, ///< Romenian Leu
47 CURRENCY_RUR
, ///< Russian Rouble
48 CURRENCY_SIT
, ///< Slovenian Tolar
49 CURRENCY_SEK
, ///< Swedish Krona
50 CURRENCY_YTL
, ///< Turkish Lira
51 CURRENCY_SKK
, ///< Slovak Kornuna
52 CURRENCY_BRL
, ///< Brazilian Real
53 CURRENCY_EEK
, ///< Estonian Krooni
54 CURRENCY_LTL
, ///< Lithuanian Litas
55 CURRENCY_KRW
, ///< South Korean Won
56 CURRENCY_ZAR
, ///< South African Rand
57 CURRENCY_CUSTOM
, ///< Custom currency
58 CURRENCY_GEL
, ///< Georgian Lari
59 CURRENCY_IRR
, ///< Iranian Rial
60 CURRENCY_RUB
, ///< New Russian Ruble
61 CURRENCY_MXN
, ///< Mexican Peso
62 CURRENCY_NTD
, ///< New Taiwan Dollar
63 CURRENCY_CNY
, ///< Chinese Renminbi
64 CURRENCY_HKD
, ///< Hong Kong Dollar
65 CURRENCY_INR
, ///< Indian Rupee
66 CURRENCY_IDR
, ///< Indonesian Rupiah
67 CURRENCY_MYR
, ///< Malaysian Ringgit
68 CURRENCY_END
, ///< always the last item
71 /** Specification of a currency. */
73 uint16 rate
; ///< The conversion rate compared to the base currency.
74 std::string separator
; ///< The thousands separator for this currency.
75 Year to_euro
; ///< %Year of switching to the Euro. May also be #CF_NOEURO or #CF_ISEURO.
76 std::string prefix
; ///< Prefix to apply when formatting money in this currency.
77 std::string suffix
; ///< Suffix to apply when formatting money in this currency.
79 * The currency symbol is represented by two possible values, prefix and suffix
80 * Usage of one or the other is determined by #symbol_pos.
83 * 2 = both : Special case only for custom currency.
84 * It is not a spec from Newgrf,
85 * rather a way to let users do what they want with custom currency
90 CurrencySpec() = default;
92 CurrencySpec(uint16 rate
, const char *separator
, Year to_euro
, const char *prefix
, const char *suffix
, byte symbol_pos
, StringID name
) :
93 rate(rate
), separator(separator
), to_euro(to_euro
), prefix(prefix
), suffix(suffix
), symbol_pos(symbol_pos
), name(name
)
98 extern CurrencySpec _currency_specs
[CURRENCY_END
];
100 /* XXX small hack, but makes the rest of the code a bit nicer to read */
101 #define _custom_currency (_currency_specs[CURRENCY_CUSTOM])
102 #define _currency ((const CurrencySpec*)&_currency_specs[GetGameSettings().locale.currency])
104 uint64
GetMaskOfAllowedCurrencies();
105 void CheckSwitchToEuro();
106 void ResetCurrencies(bool preserve_custom
= true);
107 StringID
*BuildCurrencyDropdown();
108 byte
GetNewgrfCurrencyIdConverted(byte grfcurr_id
);
110 #endif /* CURRENCY_H */