From 7d33e62d7bda071f4cc5c713c8a1b802e6915778 Mon Sep 17 00:00:00 2001 From: rubidium Date: Tue, 8 Dec 2009 23:32:32 +0000 Subject: (svn r18436) -Fix [FS#3357]: unselect an AI in the AI Settings window when it falls out of the range of active AIs --- src/ai/ai_gui.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/ai/ai_gui.cpp b/src/ai/ai_gui.cpp index 21338040b..bf65e62cf 100644 --- a/src/ai/ai_gui.cpp +++ b/src/ai/ai_gui.cpp @@ -594,10 +594,7 @@ struct AIConfigWindow : public Window { } case AIC_WIDGET_LIST: { // Select a slot - uint slot = (pt.y - this->GetWidget(widget)->pos_y) / this->line_height + this->vscroll.GetPosition(); - - if (slot == 0 || slot > _settings_newgame.difficulty.max_no_competitors) slot = INVALID_COMPANY; - this->selected_slot = (CompanyID)slot; + this->selected_slot = (CompanyID)((pt.y - this->GetWidget(widget)->pos_y) / this->line_height + this->vscroll.GetPosition()); this->InvalidateData(); break; } @@ -628,6 +625,10 @@ struct AIConfigWindow : public Window { virtual void OnInvalidateData(int data) { + if (this->selected_slot == 0 || this->selected_slot > _settings_newgame.difficulty.max_no_competitors) { + this->selected_slot = INVALID_COMPANY; + } + this->SetWidgetDisabledState(AIC_WIDGET_DECREASE, _settings_newgame.difficulty.max_no_competitors == 0); this->SetWidgetDisabledState(AIC_WIDGET_INCREASE, _settings_newgame.difficulty.max_no_competitors == MAX_COMPANIES - 1); this->SetWidgetDisabledState(AIC_WIDGET_CHANGE, this->selected_slot == INVALID_COMPANY); -- cgit v1.2.3-70-g09d2