mirror of https://github.com/OpenTTD/OpenTTD
(svn r17854) -Codechange: Merge different cases of setting widget data together in the view vehicle window.
parent
ca0521f89f
commit
11e1d3b47c
|
@ -1642,6 +1642,7 @@ static bool IsVehicleRefitable(const Vehicle *v)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Window manager class for viewing a vehicle. */
|
||||||
struct VehicleViewWindow : Window {
|
struct VehicleViewWindow : Window {
|
||||||
private:
|
private:
|
||||||
/** Display planes available in the vehicle view window. */
|
/** Display planes available in the vehicle view window. */
|
||||||
|
@ -1680,38 +1681,37 @@ private:
|
||||||
public:
|
public:
|
||||||
VehicleViewWindow(const WindowDesc *desc, WindowNumber window_number) : Window()
|
VehicleViewWindow(const WindowDesc *desc, WindowNumber window_number) : Window()
|
||||||
{
|
{
|
||||||
const Vehicle *v = Vehicle::Get(window_number);
|
|
||||||
|
|
||||||
this->CreateNestedTree(desc);
|
this->CreateNestedTree(desc);
|
||||||
|
|
||||||
/*
|
/* Sprites for the 'send to depot' button indexed by vehicle type. */
|
||||||
* fill in data and tooltip codes for the widgets and
|
static const SpriteID vehicle_view_goto_depot_sprites[] = {
|
||||||
* move some of the buttons for trains
|
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];
|
||||||
|
|
||||||
|
/* 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];
|
||||||
|
|
||||||
switch (v->type) {
|
switch (v->type) {
|
||||||
case VEH_TRAIN:
|
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;
|
this->GetWidget<NWidgetCore>(VVW_WIDGET_TURN_AROUND)->tool_tip = STR_VEHICLE_VIEW_TRAIN_REVERSE_TOOLTIP;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case VEH_ROAD:
|
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;
|
break;
|
||||||
|
|
||||||
case VEH_SHIP:
|
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:
|
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);
|
this->SelectPlane(SEL_RT_REFIT);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue