OpenTTD

currency.h
Go to the documentation of this file.
1 /* $Id: currency.h 25076 2013-03-09 16:31:56Z planetmaker $ */
2
3 /*
4 * This file is part of OpenTTD.
5 * 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.
6 * 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.
7 * 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 */
9
12 #ifndef CURRENCY_H
13 #define CURRENCY_H
14
15 #include "date_type.h"
16 #include "strings_type.h"
17
18 static const int CF_NOEURO = 0;
19 static const int CF_ISEURO = 1;
20
26 enum Currencies {
27 CURRENCY_GBP,
28 CURRENCY_USD,
29 CURRENCY_EUR,
30 CURRENCY_JPY,
31 CURRENCY_ATS,
32 CURRENCY_BEF,
33 CURRENCY_CHF,
34 CURRENCY_CZK,
35 CURRENCY_DEM,
36 CURRENCY_DKK,
37 CURRENCY_ESP,
38 CURRENCY_FIM,
39 CURRENCY_FRF,
40 CURRENCY_GRD,
41 CURRENCY_HUF,
42 CURRENCY_ISK,
43 CURRENCY_ITL,
44 CURRENCY_NLG,
45 CURRENCY_NOK,
46 CURRENCY_PLN,
47 CURRENCY_RON,
48 CURRENCY_RUR,
49 CURRENCY_SIT,
50 CURRENCY_SEK,
51 CURRENCY_YTL,
52 CURRENCY_SKK,
53 CURRENCY_BRL,
54 CURRENCY_EEK,
55 CURRENCY_LTL,
56 CURRENCY_KRW,
57 CURRENCY_ZAR,
58 CURRENCY_CUSTOM,
59 CURRENCY_GEL,
60 CURRENCY_IRR,
61 CURRENCY_END,
62 };
63
65 struct CurrencySpec {
66 uint16 rate;
67 char separator[8];
68 Year to_euro;
69 char prefix[16];
70 char suffix[16];
80 byte symbol_pos;
81 StringID name;
82 };
83
84 extern CurrencySpec _currency_specs[CURRENCY_END];
85
86 /* XXX small hack, but makes the rest of the code a bit nicer to read */
87 #define _custom_currency (_currency_specs[CURRENCY_CUSTOM])
88 #define _currency ((const CurrencySpec*)&_currency_specs[GetGameSettings().locale.currency])
89
90 uint64 GetMaskOfAllowedCurrencies();
91 void CheckSwitchToEuro();
92 void ResetCurrencies(bool preserve_custom = true);
93 StringID *BuildCurrencyDropdown();
94 byte GetNewgrfCurrencyIdConverted(byte grfcurr_id);
95
96 #endif /* CURRENCY_H */
CURRENCY_RUR
Russian Rouble.
Definition: currency.h:48
CURRENCY_FIM
Finish Markka.
Definition: currency.h:38
CURRENCY_ITL
Italian Lira.
Definition: currency.h:43
CURRENCY_NLG
Dutch Gulden.
Definition: currency.h:44
CURRENCY_CUSTOM
Custom currency.
Definition: currency.h:58
CURRENCY_ISK
Icelandic Krona.
Definition: currency.h:42
CURRENCY_EUR
Euro.
Definition: currency.h:29
CURRENCY_KRW
South Korean Won.
Definition: currency.h:56
CURRENCY_BRL
Brazilian Real.
Definition: currency.h:53
Year
int32 Year
Type for the year, note: 0 based, i.e. starts at the year 0.
Definition: date_type.h:20
GetMaskOfAllowedCurrencies
uint64 GetMaskOfAllowedCurrencies()
get a mask of the allowed currencies depending on the year
Definition: currency.cpp:116
CURRENCY_JPY
Japanese Yen.
Definition: currency.h:30
CURRENCY_EEK
Estonian Krooni.
Definition: currency.h:54
CURRENCY_SKK
Slovak Kornuna.
Definition: currency.h:52
CurrencySpec::symbol_pos
byte symbol_pos
The currency symbol is represented by two possible values, prefix and suffix Usage of one or the othe...
Definition: currency.h:80
CURRENCY_USD
US Dollar.
Definition: currency.h:28
CheckSwitchToEuro
void CheckSwitchToEuro()
Verify if the currency chosen by the user is about to be converted to Euro.
Definition: currency.cpp:135
CURRENCY_YTL
Turkish Lira.
Definition: currency.h:51
CURRENCY_DKK
Danish Krona.
Definition: currency.h:36
Currencies
Currencies
This enum gives the currencies a unique id which must be maintained for savegame compatibility and in...
Definition: currency.h:26
_currency_specs
CurrencySpec _currency_specs[CURRENCY_END]
Array of currencies used by the system.
Definition: currency.cpp:68
CF_NOEURO
static const int CF_NOEURO
Currency never switches to the Euro (as far as known).
Definition: currency.h:18
CURRENCY_ESP
Spanish Peseta.
Definition: currency.h:37
CURRENCY_SEK
Swedish Krona.
Definition: currency.h:50
CURRENCY_GBP
British Pound.
Definition: currency.h:27
CURRENCY_RON
Romenian Leu.
Definition: currency.h:47
CURRENCY_BEF
Belgian Franc.
Definition: currency.h:32
CURRENCY_END
always the last item
Definition: currency.h:61
CURRENCY_CZK
Czech Koruna.
Definition: currency.h:34
ResetCurrencies
void ResetCurrencies(bool preserve_custom=true)
Will fill _currency_specs array with default values from origin_currency_specs Called only from newgr...
Definition: currency.cpp:151
CURRENCY_GRD
Greek Drachma.
Definition: currency.h:40
CURRENCY_FRF
French Franc.
Definition: currency.h:39
CURRENCY_NOK
Norwegian Krone.
Definition: currency.h:45
StringID
uint32 StringID
Numeric value that represents a string, independent of the selected language.
Definition: strings_type.h:18
CurrencySpec::to_euro
Year to_euro
Year of switching to the Euro. May also be CF_NOEURO or CF_ISEURO.
Definition: currency.h:68
BuildCurrencyDropdown
StringID * BuildCurrencyDropdown()
Build a list of currency names StringIDs to use in a dropdown list.
Definition: currency.cpp:163
CURRENCY_LTL
Lithuanian Litas.
Definition: currency.h:55
CURRENCY_ATS
Austrian Schilling.
Definition: currency.h:31
CURRENCY_PLN
Polish Zloty.
Definition: currency.h:46
CURRENCY_IRR
Iranian Rial.
Definition: currency.h:60
CURRENCY_SIT
Slovenian Tolar.
Definition: currency.h:49
CurrencySpec
Specification of a currency.
Definition: currency.h:65
CURRENCY_GEL
Georgian Lari.
Definition: currency.h:59
CURRENCY_ZAR
South African Rand.
Definition: currency.h:57
strings_type.h
Types related to strings.
date_type.h
Types related to the dates in OpenTTD.
CF_ISEURO
static const int CF_ISEURO
Currency is the Euro.
Definition: currency.h:19
CURRENCY_CHF
Swiss Franc.
Definition: currency.h:33
CURRENCY_DEM
Deutsche Mark.
Definition: currency.h:35
GetNewgrfCurrencyIdConverted
byte GetNewgrfCurrencyIdConverted(byte grfcurr_id)
Will return the ottd&#39;s index correspondence to the ttdpatch&#39;s id.
Definition: currency.cpp:107
CURRENCY_HUF
Hungarian Forint.
Definition: currency.h:41