|
OpenTTD Source 20251117-master-g7398d2e290
|
Functions to handle different currencies. More...
Go to the source code of this file.
Data Structures | |
| struct | CurrencySpec |
| Specification of a currency. More... | |
Enumerations | |
| enum | Currencies : uint8_t { CURRENCY_GBP , CURRENCY_USD , CURRENCY_EUR , CURRENCY_JPY , CURRENCY_ATS , CURRENCY_BEF , CURRENCY_CHF , CURRENCY_CZK , CURRENCY_DEM , CURRENCY_DKK , CURRENCY_ESP , CURRENCY_FIM , CURRENCY_FRF , CURRENCY_GRD , CURRENCY_HUF , CURRENCY_ISK , CURRENCY_ITL , CURRENCY_NLG , CURRENCY_NOK , CURRENCY_PLN , CURRENCY_RON , CURRENCY_RUR , CURRENCY_SIT , CURRENCY_SEK , CURRENCY_YTL , CURRENCY_SKK , CURRENCY_BRL , CURRENCY_EEK , CURRENCY_LTL , CURRENCY_KRW , CURRENCY_ZAR , CURRENCY_CUSTOM , CURRENCY_GEL , CURRENCY_IRR , CURRENCY_RUB , CURRENCY_MXN , CURRENCY_NTD , CURRENCY_CNY , CURRENCY_HKD , CURRENCY_INR , CURRENCY_IDR , CURRENCY_MYR , CURRENCY_LVL , CURRENCY_PTE , CURRENCY_UAH , CURRENCY_VND , CURRENCY_END } |
| This enum gives the currencies a unique id which must be maintained for savegame compatibility and in order to refer to them quickly, especially for referencing the custom one. More... | |
Functions | |
| CurrencySpec & | GetCustomCurrency () |
| Get the custom currency. | |
| const CurrencySpec & | GetCurrency () |
| Get the currently selected currency. | |
| uint64_t | GetMaskOfAllowedCurrencies () |
| get a mask of the allowed currencies depending on the year | |
| void | ResetCurrencies (bool preserve_custom=true) |
| Will fill _currency_specs array with default values from origin_currency_specs Called only from newgrf.cpp and settings.cpp. | |
| uint8_t | GetNewgrfCurrencyIdConverted (uint8_t grfcurr_id) |
| Will return the ottd's index correspondence to the ttdpatch's id. | |
Variables | |
| static constexpr TimerGameCalendar::Year | CF_NOEURO {0} |
| Currency never switches to the Euro (as far as known). | |
| static constexpr TimerGameCalendar::Year | CF_ISEURO {1} |
| Currency is the Euro. | |
| static constexpr TimerGameCalendar::Year | MIN_EURO_YEAR {2000} |
| The earliest year custom currencies may switch to the Euro. | |
| std::array< CurrencySpec, CURRENCY_END > | _currency_specs |
| Array of currencies used by the system. | |
Functions to handle different currencies.
Definition in file currency.h.
| enum Currencies : uint8_t |
This enum gives the currencies a unique id which must be maintained for savegame compatibility and in order to refer to them quickly, especially for referencing the custom one.
Definition at line 26 of file currency.h.
|
inline |
Get the currently selected currency.
Definition at line 119 of file currency.h.
References _currency_specs, LocaleSettings::currency, GetGameSettings(), and GameSettings::locale.
Referenced by FormatString(), CheatWindow::OnQueryTextFinished(), CompanyWindow::OnQueryTextFinished(), GameOptionsWindow::OnQueryTextFinished(), and PerformanceRatingDetailWindow::UpdateWidgetSize().
|
inline |
Get the custom currency.
Definition at line 110 of file currency.h.
References _currency_specs, and CURRENCY_CUSTOM.
Referenced by CustomCurrencyWindow::GetWidgetString(), CustomCurrencyWindow::OnClick(), CustomCurrencyWindow::OnQueryTextFinished(), and SurveySettings().
| uint64_t GetMaskOfAllowedCurrencies | ( | ) |
get a mask of the allowed currencies depending on the year
Definition at line 128 of file currency.cpp.
References _currency_specs, CF_ISEURO, CF_NOEURO, CURRENCY_CUSTOM, CURRENCY_END, SetBit(), and TimerGameCalendar::year.
| uint8_t GetNewgrfCurrencyIdConverted | ( | uint8_t | grfcurr_id | ) |
Will return the ottd's index correspondence to the ttdpatch's id.
If the id is bigger than the array, it is a grf written for ottd, thus returning the same id. Only called from newgrf.cpp
| grfcurr_id | currency id coming from newgrf |
Definition at line 119 of file currency.cpp.
References lengthof, and TTDPatch_To_OTTDIndex.
Referenced by GlobalVarChangeInfo().
| void ResetCurrencies | ( | bool | preserve_custom | ) |
Will fill _currency_specs array with default values from origin_currency_specs Called only from newgrf.cpp and settings.cpp.
| preserve_custom | will not reset custom currency |
Definition at line 163 of file currency.cpp.
References _currency_specs, CURRENCY_CUSTOM, CURRENCY_END, and origin_currency_specs.
Referenced by LoadFromConfig(), and ResetNewGRFData().
|
extern |
Array of currencies used by the system.
Definition at line 80 of file currency.cpp.
Referenced by GameOptionsWindow::BuildDropDownList(), GetCurrency(), GetCustomCurrency(), GetMaskOfAllowedCurrencies(), GameOptionsWindow::GetWidgetString(), GlobalVarChangeInfo(), and ResetCurrencies().
|
staticconstexpr |
Currency is the Euro.
Definition at line 18 of file currency.h.
Referenced by GetMaskOfAllowedCurrencies().
|
staticconstexpr |
Currency never switches to the Euro (as far as known).
Definition at line 17 of file currency.h.
Referenced by GetMaskOfAllowedCurrencies(), CustomCurrencyWindow::GetWidgetString(), CustomCurrencyWindow::OnClick(), and CustomCurrencyWindow::OnQueryTextFinished().
|
staticconstexpr |
The earliest year custom currencies may switch to the Euro.
Definition at line 19 of file currency.h.
Referenced by CustomCurrencyWindow::OnClick(), and CustomCurrencyWindow::OnQueryTextFinished().