diff options
author | Yexo <Yexo@openttd.org> | 2009-01-21 00:36:22 +0000 |
---|---|---|
committer | Yexo <Yexo@openttd.org> | 2009-01-21 00:36:22 +0000 |
commit | 9fd38d1022fc5e7586ebcc4c83f61382889f3a0e (patch) | |
tree | a953078893ffb4445cb46becf03ced0d98fdd874 | |
parent | 78c857422b59f3cd352d7a981fcdc67ca8650688 (diff) | |
download | openttd-9fd38d1022fc5e7586ebcc4c83f61382889f3a0e.tar.xz |
(svn r15186) -Fix: Select the currently selected AI instead of the second on in the list.
-Feature: Double clicking on a slot in the AI config window results in opening the list of AIs.
-rw-r--r-- | src/ai/ai_gui.cpp | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/src/ai/ai_gui.cpp b/src/ai/ai_gui.cpp index 01fd4699c..b2e1b4be5 100644 --- a/src/ai/ai_gui.cpp +++ b/src/ai/ai_gui.cpp @@ -58,7 +58,6 @@ struct AIListWindow : public Window { CompanyID slot; AIListWindow(const WindowDesc *desc, CompanyID slot) : Window(desc, 0), - selected(0), slot(slot) { this->ai_info_list = AI::GetUniqueInfoList(); @@ -66,6 +65,20 @@ struct AIListWindow : public Window { this->vscroll.cap = (this->widget[AIL_WIDGET_LIST].bottom - this->widget[AIL_WIDGET_LIST].top) / 14 + 1; this->widget[AIL_WIDGET_LIST].data = (this->vscroll.cap << 8) + 1; SetVScrollCount(this, this->ai_info_list->size() + 1); + + /* Try if we can find the currently selected AI */ + this->selected = -1; + if (AIConfig::GetConfig(slot)->HasAI()) { + AIInfo *info = AIConfig::GetConfig(slot)->GetInfo(); + int i = 0; + for (AIInfoList::const_iterator it = this->ai_info_list->begin(); it != this->ai_info_list->end(); it++, i++) { + if ((*it).second == info) { + this->selected = i; + break; + } + } + } + this->FindWindowPlacementAndResize(desc); } @@ -497,6 +510,16 @@ struct AIConfigWindow : public Window { } } + virtual void OnDoubleClick(Point pt, int widget) + { + switch (widget) { + case AIC_WIDGET_LIST: + this->OnClick(pt, widget); + if (this->selected_slot != INVALID_COMPANY) ShowAIListWindow((CompanyID)this->selected_slot); + break; + } + } + virtual void OnResize(Point new_size, Point delta) { this->vscroll.cap += delta.y / 14; |