diff options
author | alberth <alberth@openttd.org> | 2010-12-04 21:38:42 +0000 |
---|---|---|
committer | alberth <alberth@openttd.org> | 2010-12-04 21:38:42 +0000 |
commit | 4a35dafcd2ecae40424510aedc1d0e59f9569902 (patch) | |
tree | b54c522ba0ac653c05df25ca97108dcad8c06b16 /src | |
parent | 2baa9f2c5d2188ab75fc0f767dc7357b25fb2d91 (diff) | |
download | openttd-4a35dafcd2ecae40424510aedc1d0e59f9569902.tar.xz |
(svn r21387) -Codechange: Add an enum for cheat numbers.
Diffstat (limited to 'src')
-rw-r--r-- | src/cheat_gui.cpp | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/src/cheat_gui.cpp b/src/cheat_gui.cpp index 97da1b668..490380668 100644 --- a/src/cheat_gui.cpp +++ b/src/cheat_gui.cpp @@ -128,6 +128,21 @@ static int32 ClickChangeDateCheat(int32 p1, int32 p2) return _cur_year; } +/** Available cheats. */ +enum CheatNumbers { + CHT_MONEY, ///< Change amount of money. + CHT_CHANGE_COMPANY, ///< Switch company. + CHT_EXTRA_DYNAMITE, ///< Dynamite anything. + CHT_CROSSINGTUNNELS, ///< Allow tunnels to cross each other. + CHT_BUILD_IN_PAUSE, ///< Allow building while paused. + CHT_NO_JETCRASH, ///< Disable jet-airplane crashes. + CHT_SETUP_PROD, ///< Allow manually editing of industry production. + CHT_SWITCH_CLIMATE, ///< Switch climate. + CHT_CHANGE_DATE, ///< Do time traveling. + + CHT_NUM_CHEATS, ///< Number of cheats. +}; + /** * Signature of handler function when user clicks at a cheat. * @param p1 The new value. @@ -146,6 +161,7 @@ struct CheatEntry { /** * The available cheats. + * Order matches with the values of #CheatNumbers */ static const CheatEntry _cheats_ui[] = { {SLE_INT32, STR_CHEAT_MONEY, &_money_cheat_amount, &_cheats.money.been_used, &ClickMoneyCheat }, @@ -159,6 +175,8 @@ static const CheatEntry _cheats_ui[] = { {SLE_INT32, STR_CHEAT_CHANGE_DATE, &_cur_year, &_cheats.change_date.been_used, &ClickChangeDateCheat }, }; +assert_compile(CHT_NUM_CHEATS == lengthof(_cheats_ui)); + /** Names of the cheat window widgets. */ enum CheatWidgets { CW_PANEL, @@ -327,7 +345,7 @@ struct CheatWindow : Window { value = ce->proc(value + ((x >= 30) ? 1 : -1), (x >= 30) ? 1 : -1); /* The first cheat (money), doesn't return a different value. */ - if (value != oldvalue || btn == 0) this->clicked = btn * 2 + 1 + ((x >= 30) != rtl ? 1 : 0); + if (value != oldvalue || btn == CHT_MONEY) this->clicked = btn * 2 + 1 + ((x >= 30) != rtl ? 1 : 0); break; } |