summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authoralberth <alberth@openttd.org>2010-12-20 19:20:38 +0000
committeralberth <alberth@openttd.org>2010-12-20 19:20:38 +0000
commit27d4a640201bfb4a085bddf4d223acfda24709c5 (patch)
treec5578aee3e5a9c9fb80e9302cb4b41029bd47c21 /src
parent1e07f74b1ed5ca63f264dd914bbecd02454d0b23 (diff)
downloadopenttd-27d4a640201bfb4a085bddf4d223acfda24709c5.tar.xz
(svn r21549) -Codechange: Unfold the _build_road_button_proc array into a switch.
Diffstat (limited to 'src')
-rw-r--r--src/road_gui.cpp68
1 files changed, 49 insertions, 19 deletions
diff --git a/src/road_gui.cpp b/src/road_gui.cpp
index 653e41675..1b92c7813 100644
--- a/src/road_gui.cpp
+++ b/src/road_gui.cpp
@@ -433,21 +433,7 @@ static void BuildRoadClick_Remove(Window *w)
SndPlayFx(SND_15_BEEP);
}
-/** Array with the handlers of the button-clicks for the road-toolbar */
-static OnButtonClick * const _build_road_button_proc[] = {
- BuildRoadClick_X_Dir,
- BuildRoadClick_Y_Dir,
- BuildRoadClick_AutoRoad,
- BuildRoadClick_Demolish,
- BuildRoadClick_Depot,
- BuildRoadClick_BusStation,
- BuildRoadClick_TruckStation,
- BuildRoadClick_OneWay,
- BuildRoadClick_Bridge,
- BuildRoadClick_Tunnel,
- BuildRoadClick_Remove
-};
-
+/** Road toolbar window handler. */
struct BuildRoadToolbarWindow : Window {
BuildRoadToolbarWindow(const WindowDesc *desc, WindowNumber window_number) : Window()
{
@@ -529,10 +515,54 @@ struct BuildRoadToolbarWindow : Window {
virtual void OnClick(Point pt, int widget, int click_count)
{
- if (widget >= RTW_ROAD_X) {
- _remove_button_clicked = false;
- _one_way_button_clicked = false;
- _build_road_button_proc[widget - RTW_ROAD_X](this);
+ _remove_button_clicked = false;
+ _one_way_button_clicked = false;
+ switch (widget) {
+ case RTW_ROAD_X:
+ BuildRoadClick_X_Dir(this);
+ break;
+
+ case RTW_ROAD_Y:
+ BuildRoadClick_Y_Dir(this);
+ break;
+
+ case RTW_AUTOROAD:
+ BuildRoadClick_AutoRoad(this);
+ break;
+
+ case RTW_DEMOLISH:
+ BuildRoadClick_Demolish(this);
+ break;
+
+ case RTW_DEPOT:
+ BuildRoadClick_Depot(this);
+ break;
+
+ case RTW_BUS_STATION:
+ BuildRoadClick_BusStation(this);
+ break;
+
+ case RTW_TRUCK_STATION:
+ BuildRoadClick_TruckStation(this);
+ break;
+
+ case RTW_ONE_WAY:
+ BuildRoadClick_OneWay(this);
+ break;
+
+ case RTW_BUILD_BRIDGE:
+ BuildRoadClick_Bridge(this);
+ break;
+
+ case RTW_BUILD_TUNNEL:
+ BuildRoadClick_Tunnel(this);
+ break;
+
+ case RTW_REMOVE:
+ BuildRoadClick_Remove(this);
+ break;
+
+ default: NOT_REACHED();
}
this->UpdateOptionWidgetStatus((RoadToolbarWidgets)widget);
if (_ctrl_pressed) RoadToolbar_CtrlChanged(this);