summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2008-05-04 09:39:16 +0000
committerrubidium <rubidium@openttd.org>2008-05-04 09:39:16 +0000
commit8ca10353163dfb34174b4c2a1fad94c3286bb868 (patch)
treecf16c5b3b35ed64652f1699c981d1887983cc39c /src
parenta26b25aecc9f05727f990ee0c20acb1feef21c9b (diff)
downloadopenttd-8ca10353163dfb34174b4c2a1fad94c3286bb868.tar.xz
(svn r12939) -Codechange: do not use the window proc to determine whether a toolbar is a rail toolbar, but use the window number.
Diffstat (limited to 'src')
-rw-r--r--src/airport_gui.cpp4
-rw-r--r--src/dock_gui.cpp4
-rw-r--r--src/openttd.h7
-rw-r--r--src/rail_gui.cpp14
-rw-r--r--src/road_gui.cpp4
5 files changed, 17 insertions, 16 deletions
diff --git a/src/airport_gui.cpp b/src/airport_gui.cpp
index 991c579f0..5728380e8 100644
--- a/src/airport_gui.cpp
+++ b/src/airport_gui.cpp
@@ -139,8 +139,8 @@ void ShowBuildAirToolbar()
{
if (!IsValidPlayer(_current_player)) return;
- DeleteWindowById(WC_BUILD_TOOLBAR, 0);
- Window *w = AllocateWindowDescFront(&_air_toolbar_desc, 0);
+ DeleteWindowByClass(WC_BUILD_TOOLBAR);
+ Window *w = AllocateWindowDescFront(&_air_toolbar_desc, TRANSPORT_AIR);
if (_patches.link_terraform_toolbar) ShowTerraformToolbar(w);
}
diff --git a/src/dock_gui.cpp b/src/dock_gui.cpp
index 32d7eb00e..bc75b7fb3 100644
--- a/src/dock_gui.cpp
+++ b/src/dock_gui.cpp
@@ -232,8 +232,8 @@ void ShowBuildDocksToolbar()
{
if (!IsValidPlayer(_current_player)) return;
- DeleteWindowById(WC_BUILD_TOOLBAR, 0);
- Window *w = AllocateWindowDesc(&_build_docks_toolbar_desc);
+ DeleteWindowByClass(WC_BUILD_TOOLBAR);
+ Window *w = AllocateWindowDescFront(&_build_docks_toolbar_desc, TRANSPORT_WATER);
if (_patches.link_terraform_toolbar) ShowTerraformToolbar(w);
}
diff --git a/src/openttd.h b/src/openttd.h
index 1be4e6707..1ee6bebeb 100644
--- a/src/openttd.h
+++ b/src/openttd.h
@@ -56,9 +56,10 @@ enum TransportType {
* the values for road and rail.
*/
TRANSPORT_BEGIN = 0,
- TRANSPORT_RAIL = 0,
- TRANSPORT_ROAD = 1,
- TRANSPORT_WATER, // = 2
+ TRANSPORT_RAIL = TRANSPORT_BEGIN,
+ TRANSPORT_ROAD,
+ TRANSPORT_WATER,
+ TRANSPORT_AIR,
TRANSPORT_END,
INVALID_TRANSPORT = 0xff,
};
diff --git a/src/rail_gui.cpp b/src/rail_gui.cpp
index 748c74249..840bf8062 100644
--- a/src/rail_gui.cpp
+++ b/src/rail_gui.cpp
@@ -748,10 +748,10 @@ void ShowBuildRailToolbar(RailType railtype, int button)
if (!ValParamRailtype(railtype)) return;
// don't recreate the window if we're clicking on a button and the window exists.
- if (button < 0 || !(w = FindWindowById(WC_BUILD_TOOLBAR, 0)) || w->wndproc != BuildRailToolbWndProc) {
- DeleteWindowById(WC_BUILD_TOOLBAR, 0);
+ if (button < 0 || !(w = FindWindowById(WC_BUILD_TOOLBAR, TRANSPORT_RAIL))) {
+ DeleteWindowByClass(WC_BUILD_TOOLBAR);
_cur_railtype = railtype;
- w = AllocateWindowDesc(&_build_rail_desc);
+ w = AllocateWindowDescFront(&_build_rail_desc, TRANSPORT_RAIL);
SetupRailToolbar(railtype, w);
}
@@ -1597,8 +1597,8 @@ void ReinitGuiAfterToggleElrail(bool disable)
if (disable && _last_built_railtype == RAILTYPE_ELECTRIC) {
Window *w;
_last_built_railtype = _cur_railtype = RAILTYPE_RAIL;
- w = FindWindowById(WC_BUILD_TOOLBAR, 0);
- if (w != NULL && w->wndproc == BuildRailToolbWndProc) {
+ w = FindWindowById(WC_BUILD_TOOLBAR, TRANSPORT_RAIL);
+ if (w != NULL) {
SetupRailToolbar(_cur_railtype, w);
SetWindowDirty(w);
}
@@ -1648,8 +1648,8 @@ static void SetDefaultRailGui()
}
_last_built_railtype = _cur_railtype = rt;
- Window *w = FindWindowById(WC_BUILD_TOOLBAR, 0);
- if (w != NULL && w->wndproc == BuildRailToolbWndProc) {
+ Window *w = FindWindowById(WC_BUILD_TOOLBAR, TRANSPORT_RAIL);
+ if (w != NULL) {
SetupRailToolbar(_cur_railtype, w);
SetWindowDirty(w);
}
diff --git a/src/road_gui.cpp b/src/road_gui.cpp
index 2f184d7a9..8872f8530 100644
--- a/src/road_gui.cpp
+++ b/src/road_gui.cpp
@@ -682,8 +682,8 @@ void ShowBuildRoadToolbar(RoadType roadtype)
if (!IsValidPlayer(_current_player)) return;
_cur_roadtype = roadtype;
- DeleteWindowById(WC_BUILD_TOOLBAR, 0);
- Window *w = AllocateWindowDesc(roadtype == ROADTYPE_ROAD ? &_build_road_desc : &_build_tramway_desc);
+ DeleteWindowByClass(WC_BUILD_TOOLBAR);
+ Window *w = AllocateWindowDescFront(roadtype == ROADTYPE_ROAD ? &_build_road_desc : &_build_tramway_desc, TRANSPORT_ROAD);
if (_patches.link_terraform_toolbar) ShowTerraformToolbar(w);
}