diff options
author | rubidium <rubidium@openttd.org> | 2009-09-26 17:43:06 +0000 |
---|---|---|
committer | rubidium <rubidium@openttd.org> | 2009-09-26 17:43:06 +0000 |
commit | ac99610a05dce9510a3074658edcb745e0430504 (patch) | |
tree | 40dfa784f10b08e4f89a438f7744807d6ac801e2 /src | |
parent | a47138ad34f6b74ee83e0bdb3c5c9d317465ecb3 (diff) | |
download | openttd-ac99610a05dce9510a3074658edcb745e0430504.tar.xz |
(svn r17644) -Fix [FS#3219]: some inconsistencies with the difficulty settings in the scenario editor. Also re-enable changing some difficulty settings (e.g. max loan) in the scenario editor.
Diffstat (limited to 'src')
-rw-r--r-- | src/settings.cpp | 6 | ||||
-rw-r--r-- | src/settings_gui.cpp | 14 | ||||
-rw-r--r-- | src/settings_internal.h | 7 | ||||
-rw-r--r-- | src/table/settings.h | 7 |
4 files changed, 19 insertions, 15 deletions
diff --git a/src/settings.cpp b/src/settings.cpp index 6fed56818..d7ac17356 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -1422,7 +1422,11 @@ CommandCost CmdChangeSetting(TileIndex tile, DoCommandFlag flags, uint32 p1, uin if ((sd->desc.flags & SGF_NETWORK_ONLY) && !_networking && _game_mode != GM_MENU) return CMD_ERROR; if ((sd->desc.flags & SGF_NO_NETWORK) && _networking) return CMD_ERROR; - if ((sd->desc.flags & SGF_NEWGAME_ONLY) && _game_mode != GM_MENU) return CMD_ERROR; + if ((sd->desc.flags & SGF_NEWGAME_ONLY) && + (_game_mode == GM_NORMAL || + (_game_mode == GM_EDITOR && (sd->desc.flags & SGF_SCENEDIT_TOO) == 0))) { + return CMD_ERROR; + } if (flags & DC_EXEC) { GameSettings *s = (_game_mode == GM_MENU) ? &_settings_newgame : &_settings_game; diff --git a/src/settings_gui.cpp b/src/settings_gui.cpp index a68757f42..6886d8cbc 100644 --- a/src/settings_gui.cpp +++ b/src/settings_gui.cpp @@ -547,7 +547,7 @@ public: this->opt_mod_temp = (_game_mode == GM_MENU) ? _settings_newgame : _settings_game; /* Setup disabled buttons when creating window * disable all other difficulty buttons during gameplay except for 'custom' */ - this->SetWidgetsDisabledState(_game_mode == GM_NORMAL, + this->SetWidgetsDisabledState(_game_mode != GM_MENU, GDW_LVL_EASY, GDW_LVL_MEDIUM, GDW_LVL_HARD, @@ -610,10 +610,6 @@ public: const SettingDesc *sd = GetSettingFromName("difficulty.max_no_competitors", &i) + (widget / 3); const SettingDescBase *sdb = &sd->desc; - /* Clicked disabled button? */ - bool editable = (_game_mode == GM_MENU || (sdb->flags & SGF_NEWGAME_ONLY) == 0); - if (!editable) return; - int32 val = (int32)ReadValue(GetVariableAddress(&this->opt_mod_temp, &sd->save), sd->save.conv); if (widget % 3 == 1) { /* Increase button clicked */ @@ -690,10 +686,12 @@ public: /* skip deprecated difficulty options */ if (!SlIsObjectCurrentlyValid(sd->save.version_from, sd->save.version_to)) continue; int32 value = (int32)ReadValue(GetVariableAddress(&this->opt_mod_temp, &sd->save), sd->save.conv); - bool editable = (_game_mode == GM_MENU || (sdb->flags & SGF_NEWGAME_ONLY) == 0); + bool disable = (sd->desc.flags & SGF_NEWGAME_ONLY) && + (_game_mode == GM_NORMAL || + (_game_mode == GM_EDITOR && (sd->desc.flags & SGF_SCENEDIT_TOO) == 0)); - this->SetWidgetDisabledState(GDW_OPTIONS_START + i * 3 + 0, !editable || sdb->min == value); - this->SetWidgetDisabledState(GDW_OPTIONS_START + i * 3 + 1, !editable || sdb->max == (uint32)value); + this->SetWidgetDisabledState(GDW_OPTIONS_START + i * 3 + 0, disable || sdb->min == value); + this->SetWidgetDisabledState(GDW_OPTIONS_START + i * 3 + 1, disable || sdb->max == (uint32)value); } } }; diff --git a/src/settings_internal.h b/src/settings_internal.h index a91886214..2903239c1 100644 --- a/src/settings_internal.h +++ b/src/settings_internal.h @@ -44,11 +44,12 @@ enum SettingGuiFlagLong { SGF_NETWORK_ONLY = 1 << 3, ///< this setting only applies to network games SGF_CURRENCY = 1 << 4, ///< the number represents money, so when reading value multiply by exchange rate SGF_NO_NETWORK = 1 << 5, ///< this setting does not apply to network games; it may not be changed during the game - SGF_NEWGAME_ONLY = 1 << 6, ///< this setting cannot be changed in inside a game - SGF_PER_COMPANY = 1 << 7, ///< this setting can be different for each company (saved in company struct) + SGF_NEWGAME_ONLY = 1 << 6, ///< this setting cannot be changed in a game + SGF_SCENEDIT_TOO = 1 << 7, ///< this setting can be changed in the scenario editor (only makes sense when SGF_NEWGAME_ONLY is set) + SGF_PER_COMPANY = 1 << 8, ///< this setting can be different for each company (saved in company struct) }; DECLARE_ENUM_AS_BIT_SET(SettingGuiFlagLong); -typedef SimpleTinyEnumT<SettingGuiFlagLong, byte> SettingGuiFlag; +typedef SimpleTinyEnumT<SettingGuiFlagLong, uint16> SettingGuiFlag; typedef bool OnChange(int32 var); ///< callback prototype on data modification diff --git a/src/table/settings.h b/src/table/settings.h index ceebac0ea..d81422c91 100644 --- a/src/table/settings.h +++ b/src/table/settings.h @@ -213,6 +213,7 @@ static bool UpdateClientConfigValues(int32 p1); #define CR SGF_CURRENCY #define NN SGF_NO_NETWORK #define NG SGF_NEWGAME_ONLY +#define NS (SGF_NEWGAME_ONLY | SGF_SCENEDIT_TOO) #define PC SGF_PER_COMPANY static const SettingDesc _music_settings[] = { @@ -335,14 +336,14 @@ const SettingDesc _settings[] = { SDT_CONDNULL( 1, 97, 109), SDT_CONDVAR(GameSettings, difficulty.number_towns, SLE_UINT8, 97, SL_MAX_VERSION, 0,NG, 2, 0, 4, 1, STR_NUM_VERY_LOW, DifficultyChange), SDT_CONDVAR(GameSettings, difficulty.number_industries, SLE_UINT8, 97, SL_MAX_VERSION, 0,NG, 4, 0, 4, 1, STR_NONE, DifficultyChange), - SDT_CONDVAR(GameSettings, difficulty.max_loan, SLE_UINT32, 97, SL_MAX_VERSION, 0,NG|CR,300000,100000,500000,50000,STR_NULL, DifficultyChange), - SDT_CONDVAR(GameSettings, difficulty.initial_interest, SLE_UINT8, 97, SL_MAX_VERSION, 0,NG, 2, 2, 4, 1, STR_NULL, DifficultyChange), + SDT_CONDVAR(GameSettings, difficulty.max_loan, SLE_UINT32, 97, SL_MAX_VERSION, 0,NS|CR,300000,100000,500000,50000,STR_NULL, DifficultyChange), + SDT_CONDVAR(GameSettings, difficulty.initial_interest, SLE_UINT8, 97, SL_MAX_VERSION, 0,NS, 2, 2, 4, 1, STR_NULL, DifficultyChange), SDT_CONDVAR(GameSettings, difficulty.vehicle_costs, SLE_UINT8, 97, SL_MAX_VERSION, 0, 0, 0, 0, 2, 1, STR_SEA_LEVEL_LOW, DifficultyChange), SDT_CONDVAR(GameSettings, difficulty.competitor_speed, SLE_UINT8, 97, SL_MAX_VERSION, 0, 0, 2, 0, 4, 1, STR_AI_SPEED_VERY_SLOW, DifficultyChange), SDT_CONDNULL( 1, 97, 109), SDT_CONDVAR(GameSettings, difficulty.vehicle_breakdowns, SLE_UINT8, 97, SL_MAX_VERSION, 0, 0, 1, 0, 2, 1, STR_DISASTER_NONE, DifficultyChange), SDT_CONDVAR(GameSettings, difficulty.subsidy_multiplier, SLE_UINT8, 97, SL_MAX_VERSION, 0, 0, 2, 0, 3, 1, STR_SUBSIDY_X1_5, DifficultyChange), - SDT_CONDVAR(GameSettings, difficulty.construction_cost, SLE_UINT8, 97, SL_MAX_VERSION, 0,NG, 0, 0, 2, 1, STR_SEA_LEVEL_LOW, DifficultyChange), + SDT_CONDVAR(GameSettings, difficulty.construction_cost, SLE_UINT8, 97, SL_MAX_VERSION, 0,NS, 0, 0, 2, 1, STR_SEA_LEVEL_LOW, DifficultyChange), SDT_CONDVAR(GameSettings, difficulty.terrain_type, SLE_UINT8, 97, SL_MAX_VERSION, 0,NG, 1, 0, 3, 1, STR_TERRAIN_TYPE_VERY_FLAT, DifficultyChange), SDT_CONDVAR(GameSettings, difficulty.quantity_sea_lakes, SLE_UINT8, 97, SL_MAX_VERSION, 0,NG, 0, 0, 3, 1, STR_SEA_LEVEL_VERY_LOW, DifficultyChange), SDT_CONDVAR(GameSettings, difficulty.economy, SLE_UINT8, 97, SL_MAX_VERSION, 0, 0, 0, 0, 1, 1, STR_ECONOMY_STEADY, DifficultyChange), |