diff options
-rw-r--r-- | src/dock_gui.cpp | 98 |
1 files changed, 13 insertions, 85 deletions
diff --git a/src/dock_gui.cpp b/src/dock_gui.cpp index ecf00918c..231143723 100644 --- a/src/dock_gui.cpp +++ b/src/dock_gui.cpp @@ -148,83 +148,7 @@ enum DockToolbarWidgets { DTW_END, ///< End of toolbar widgets }; - -/** - * Handle a click in the build canal widget. - * @param w #Window in which the widget was clicked. - */ -static void BuildDocksClick_Canal(Window *w) -{ - HandlePlacePushButton(w, DTW_CANAL, SPR_CURSOR_CANAL, HT_RECT, PlaceDocks_BuildCanal); -} - -/** - * Handle a click in the build lock widget. - * @param w #Window in which the widget was clicked. - */ -static void BuildDocksClick_Lock(Window *w) -{ - HandlePlacePushButton(w, DTW_LOCK, SPR_CURSOR_LOCK, HT_SPECIAL, PlaceDocks_BuildLock); -} - -/** - * Handle a click in the demolish widget. - * @param w #Window in which the widget was clicked. - */ -static void BuildDocksClick_Demolish(Window *w) -{ - HandlePlacePushButton(w, DTW_DEMOLISH, ANIMCURSOR_DEMOLISH, HT_RECT, PlaceProc_DemolishArea); -} - -/** - * Handle a click in the build ship depot widget. - * @param w #Window in which the widget was clicked. - */ -static void BuildDocksClick_Depot(Window *w) -{ - if (!CanBuildVehicleInfrastructure(VEH_SHIP)) return; - if (HandlePlacePushButton(w, DTW_DEPOT, SPR_CURSOR_SHIP_DEPOT, HT_RECT, PlaceDocks_Depot)) ShowBuildDocksDepotPicker(w); -} - -/** - * Handle a click in the build dock widget. - * @param w #Window in which the widget was clicked. - */ -static void BuildDocksClick_Dock(Window *w) -{ - if (!CanBuildVehicleInfrastructure(VEH_SHIP)) return; - if (HandlePlacePushButton(w, DTW_STATION, SPR_CURSOR_DOCK, HT_SPECIAL, PlaceDocks_Dock)) ShowBuildDockStationPicker(w); -} - -/** - * Handle a click in the build buoy widget. - * @param w #Window in which the widget was clicked. - */ -static void BuildDocksClick_Buoy(Window *w) -{ - if (!CanBuildVehicleInfrastructure(VEH_SHIP)) return; - HandlePlacePushButton(w, DTW_BUOY, SPR_CURSOR_BOUY, HT_RECT, PlaceDocks_Buoy); -} - -/** - * Handle a click in the create river widget. - * @param w #Window in which the widget was clicked. - */ -static void BuildDocksClick_River(Window *w) -{ - if (_game_mode != GM_EDITOR) return; - HandlePlacePushButton(w, DTW_RIVER, SPR_CURSOR_RIVER, HT_RECT, PlaceDocks_BuildRiver); -} - -/** - * Handle a click in the build aqueduct widget. - * @param w #Window in which the widget was clicked. - */ -static void BuildDocksClick_Aqueduct(Window *w) -{ - HandlePlacePushButton(w, DTW_BUILD_AQUEDUCT, SPR_CURSOR_AQUEDUCT, HT_SPECIAL, PlaceDocks_Aqueduct); -} - +/** Toolbar window for constructing water infra structure. */ struct BuildDocksToolbarWindow : Window { DockToolbarWidgets last_clicked_widget; ///< Contains the last widget that has been clicked on this toolbar. @@ -255,35 +179,39 @@ struct BuildDocksToolbarWindow : Window { this->last_clicked_widget = (DockToolbarWidgets)widget; switch (widget) { case DTW_CANAL: // Build canal button - BuildDocksClick_Canal(this); + HandlePlacePushButton(this, DTW_CANAL, SPR_CURSOR_CANAL, HT_RECT, PlaceDocks_BuildCanal); break; case DTW_LOCK: // Build lock button - BuildDocksClick_Lock(this); + HandlePlacePushButton(this, DTW_LOCK, SPR_CURSOR_LOCK, HT_SPECIAL, PlaceDocks_BuildLock); break; case DTW_DEMOLISH: // Demolish aka dynamite button - BuildDocksClick_Demolish(this); + HandlePlacePushButton(this, DTW_DEMOLISH, ANIMCURSOR_DEMOLISH, HT_RECT, PlaceProc_DemolishArea); break; case DTW_DEPOT: // Build depot button - BuildDocksClick_Depot(this); + if (!CanBuildVehicleInfrastructure(VEH_SHIP)) return; + if (HandlePlacePushButton(this, DTW_DEPOT, SPR_CURSOR_SHIP_DEPOT, HT_RECT, PlaceDocks_Depot)) ShowBuildDocksDepotPicker(this); break; case DTW_STATION: // Build station button - BuildDocksClick_Dock(this); + if (!CanBuildVehicleInfrastructure(VEH_SHIP)) return; + if (HandlePlacePushButton(this, DTW_STATION, SPR_CURSOR_DOCK, HT_SPECIAL, PlaceDocks_Dock)) ShowBuildDockStationPicker(this); break; case DTW_BUOY: // Build buoy button - BuildDocksClick_Buoy(this); + if (!CanBuildVehicleInfrastructure(VEH_SHIP)) return; + HandlePlacePushButton(this, DTW_BUOY, SPR_CURSOR_BOUY, HT_RECT, PlaceDocks_Buoy); break; case DTW_RIVER: // Build river button (in scenario editor) - BuildDocksClick_River(this); + if (_game_mode != GM_EDITOR) return; + HandlePlacePushButton(this, DTW_RIVER, SPR_CURSOR_RIVER, HT_RECT, PlaceDocks_BuildRiver); break; case DTW_BUILD_AQUEDUCT: // Build aqueduct button - BuildDocksClick_Aqueduct(this); + HandlePlacePushButton(this, DTW_BUILD_AQUEDUCT, SPR_CURSOR_AQUEDUCT, HT_SPECIAL, PlaceDocks_Aqueduct); break; default: break; |