summaryrefslogtreecommitdiff
path: root/src/toolbar_gui.cpp
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2011-01-20 12:22:38 +0000
committerrubidium <rubidium@openttd.org>2011-01-20 12:22:38 +0000
commit2f6c840ebf94c9c0386abcb0217540a1c2a7ae85 (patch)
treebe5ded654afdcffe47d25a8d2cb6dd87531eb196 /src/toolbar_gui.cpp
parent6a2ae9281159ad17a64f88d871561382ce366697 (diff)
downloadopenttd-2f6c840ebf94c9c0386abcb0217540a1c2a7ae85.tar.xz
(svn r21866) -Feature [FS#4394]: [NewGRF] Rail type property to influence sorting of rail types in the drop down list
Diffstat (limited to 'src/toolbar_gui.cpp')
-rw-r--r--src/toolbar_gui.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/toolbar_gui.cpp b/src/toolbar_gui.cpp
index 90e107550..649552036 100644
--- a/src/toolbar_gui.cpp
+++ b/src/toolbar_gui.cpp
@@ -691,6 +691,17 @@ static CallBackFunction ToolbarZoomOutClick(Window *w)
/* --- Rail button menu --- */
+/**
+ * Compare railtypes based on their sorting order.
+ * @param first The railtype to compare to.
+ * @param second The railtype to compare.
+ * @return True iff the first should be sorted before the second.
+ */
+static bool CompareRailTypes(const DropDownListItem *first, const DropDownListItem *second)
+{
+ return GetRailTypeInfo((RailType)first->result)->sorting_order < GetRailTypeInfo((RailType)second->result)->sorting_order;
+}
+
static CallBackFunction ToolbarBuildRailClick(Window *w)
{
RailTypes used_railtypes = RAILTYPES_NONE;
@@ -722,6 +733,7 @@ static CallBackFunction ToolbarBuildRailClick(Window *w)
item->SetParam(1, rti->max_speed);
list->push_back(item);
}
+ list->sort(CompareRailTypes);
ShowDropDownList(w, list, _last_built_railtype, TBN_RAILS, 140, true, true);
SndPlayFx(SND_15_BEEP);
return CBF_NONE;