summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoralberth <alberth@openttd.org>2009-10-24 15:19:06 +0000
committeralberth <alberth@openttd.org>2009-10-24 15:19:06 +0000
commit11e1d3b47c653f3ab2663d9b652b2254d27201fb (patch)
tree91d18787b28934530c9d693ed2f34da124788593
parentca0521f89fc53be22e18cb56f6d9c358555246af (diff)
downloadopenttd-11e1d3b47c653f3ab2663d9b652b2254d27201fb.tar.xz
(svn r17854) -Codechange: Merge different cases of setting widget data together in the view vehicle window.
-rw-r--r--src/vehicle_gui.cpp38
1 files changed, 19 insertions, 19 deletions
diff --git a/src/vehicle_gui.cpp b/src/vehicle_gui.cpp
index 5420442dd..0e595ba5f 100644
--- a/src/vehicle_gui.cpp
+++ b/src/vehicle_gui.cpp
@@ -1642,6 +1642,7 @@ static bool IsVehicleRefitable(const Vehicle *v)
return false;
}
+/** Window manager class for viewing a vehicle. */
struct VehicleViewWindow : Window {
private:
/** Display planes available in the vehicle view window. */
@@ -1680,38 +1681,37 @@ private:
public:
VehicleViewWindow(const WindowDesc *desc, WindowNumber window_number) : Window()
{
+ this->CreateNestedTree(desc);
+
+ /* Sprites for the 'send to depot' button indexed by vehicle type. */
+ static const SpriteID vehicle_view_goto_depot_sprites[] = {
+ SPR_SEND_TRAIN_TODEPOT,
+ SPR_SEND_ROADVEH_TODEPOT,
+ SPR_SEND_SHIP_TODEPOT,
+ SPR_SEND_AIRCRAFT_TODEPOT,
+ };
const Vehicle *v = Vehicle::Get(window_number);
+ this->GetWidget<NWidgetCore>(VVW_WIDGET_GOTO_DEPOT)->widget_data = vehicle_view_goto_depot_sprites[v->type];
- this->CreateNestedTree(desc);
+ /* Sprites for the 'clone vehicle' button indexed by vehicle type. */
+ static const SpriteID vehicle_view_clone_sprites[] = {
+ SPR_CLONE_TRAIN,
+ SPR_CLONE_ROADVEH,
+ SPR_CLONE_SHIP,
+ SPR_CLONE_AIRCRAFT,
+ };
+ this->GetWidget<NWidgetCore>(VVW_WIDGET_CLONE_VEH)->widget_data = vehicle_view_clone_sprites[v->type];
- /*
- * fill in data and tooltip codes for the widgets and
- * move some of the buttons for trains
- */
switch (v->type) {
case VEH_TRAIN:
- this->GetWidget<NWidgetCore>(VVW_WIDGET_GOTO_DEPOT)->widget_data = SPR_SEND_TRAIN_TODEPOT;
- this->GetWidget<NWidgetCore>(VVW_WIDGET_CLONE_VEH)->widget_data = SPR_CLONE_TRAIN;
-
this->GetWidget<NWidgetCore>(VVW_WIDGET_TURN_AROUND)->tool_tip = STR_VEHICLE_VIEW_TRAIN_REVERSE_TOOLTIP;
break;
case VEH_ROAD:
- this->GetWidget<NWidgetCore>(VVW_WIDGET_GOTO_DEPOT)->widget_data = SPR_SEND_ROADVEH_TODEPOT;
- this->GetWidget<NWidgetCore>(VVW_WIDGET_CLONE_VEH)->widget_data = SPR_CLONE_ROADVEH;
break;
case VEH_SHIP:
- this->GetWidget<NWidgetCore>(VVW_WIDGET_GOTO_DEPOT)->widget_data = SPR_SEND_SHIP_TODEPOT;
- this->GetWidget<NWidgetCore>(VVW_WIDGET_CLONE_VEH)->widget_data = SPR_CLONE_SHIP;
-
- this->SelectPlane(SEL_RT_REFIT);
- break;
-
case VEH_AIRCRAFT:
- this->GetWidget<NWidgetCore>(VVW_WIDGET_GOTO_DEPOT)->widget_data = SPR_SEND_AIRCRAFT_TODEPOT;
- this->GetWidget<NWidgetCore>(VVW_WIDGET_CLONE_VEH)->widget_data = SPR_CLONE_AIRCRAFT;
-
this->SelectPlane(SEL_RT_REFIT);
break;