summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorglx22 <glx22@users.noreply.github.com>2019-01-27 22:01:09 +0100
committerCharles Pigott <charlespigott@googlemail.com>2019-01-27 21:01:09 +0000
commit654b635f6fb866fcc3ccabcf8333f3b7495ebb26 (patch)
tree309bda43ecdb797ae0ede74d3e5c0fffa86504f4 /src
parent80c7965c65d5552482a51f39e5f1e03aeeb423c2 (diff)
downloadopenttd-654b635f6fb866fcc3ccabcf8333f3b7495ebb26.tar.xz
Fix #7122: OnClick() and DrawWidget() editability was inconsistent in AISettingsWindow (#7123)
Diffstat (limited to 'src')
-rw-r--r--src/ai/ai_gui.cpp10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/ai/ai_gui.cpp b/src/ai/ai_gui.cpp
index 4b248f5ef..8dad16fab 100644
--- a/src/ai/ai_gui.cpp
+++ b/src/ai/ai_gui.cpp
@@ -378,7 +378,7 @@ struct AISettingsWindow : public Window {
for (; this->vscroll->IsVisible(i) && it != visible_settings.end(); i++, it++) {
const ScriptConfigItem &config_item = **it;
int current_value = config->GetSetting((config_item).name);
- bool editable = _game_mode == GM_MENU || ((this->slot != OWNER_DEITY) && !Company::IsValidID(this->slot)) || (config_item.flags & SCRIPTCONFIG_INGAME) != 0;
+ bool editable = this->IsEditableItem(config_item);
StringID str;
TextColour colour;
@@ -441,7 +441,7 @@ struct AISettingsWindow : public Window {
VisibleSettingsList::const_iterator it = this->visible_settings.begin();
for (int i = 0; i < num; i++) it++;
const ScriptConfigItem config_item = **it;
- if (_game_mode == GM_NORMAL && ((this->slot == OWNER_DEITY) || Company::IsValidID(this->slot)) && (config_item.flags & SCRIPTCONFIG_INGAME) == 0) return;
+ if (!this->IsEditableItem(config_item)) return;
if (this->clicked_row != num) {
DeleteChildWindows(WC_QUERY_STRING);
@@ -586,6 +586,12 @@ struct AISettingsWindow : public Window {
{
this->RebuildVisibleSettings();
}
+
+private:
+ bool IsEditableItem(const ScriptConfigItem config_item) const
+ {
+ return _game_mode == GM_MENU || ((this->slot != OWNER_DEITY) && !Company::IsValidID(this->slot)) || (config_item.flags & SCRIPTCONFIG_INGAME) != 0;
+ }
};
/** Widgets for the AI settings window. */