summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorYexo <yexo@openttd.org>2009-01-21 00:36:22 +0000
committerYexo <yexo@openttd.org>2009-01-21 00:36:22 +0000
commite395533632234d7f2efdcf648b2dc8fc08ab4fe2 (patch)
treea953078893ffb4445cb46becf03ced0d98fdd874 /src
parentc3b7917da1517f12c111b390c83dd3bebd0ad22e (diff)
downloadopenttd-e395533632234d7f2efdcf648b2dc8fc08ab4fe2.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.
Diffstat (limited to 'src')
-rw-r--r--src/ai/ai_gui.cpp25
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;