mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-02-12 09:38:28 +00:00
(svn r27630) -Codechange: Deduplicate code to attach vehicle to cursor.
This commit is contained in:
parent
cff2b49365
commit
ddc9205212
@ -505,16 +505,12 @@ struct DepotWindow : Window {
|
|||||||
this->sel = INVALID_VEHICLE;
|
this->sel = INVALID_VEHICLE;
|
||||||
TrainDepotMoveVehicle(v, sel, gdvp.head);
|
TrainDepotMoveVehicle(v, sel, gdvp.head);
|
||||||
} else if (v != NULL) {
|
} else if (v != NULL) {
|
||||||
bool rtl = _current_text_dir == TD_RTL;
|
SetObjectToPlaceWnd(SPR_CURSOR_MOUSE, PAL_NONE, HT_DRAG, this);
|
||||||
int image = v->GetImage(rtl ? DIR_E : DIR_W, EIT_IN_DEPOT);
|
SetMouseCursorVehicle(v, EIT_IN_DEPOT);
|
||||||
SetObjectToPlaceWnd(image, GetVehiclePalette(v), HT_DRAG, this);
|
_cursor.vehchain = _ctrl_pressed;
|
||||||
|
|
||||||
this->sel = v->index;
|
this->sel = v->index;
|
||||||
this->SetDirty();
|
this->SetDirty();
|
||||||
|
|
||||||
_cursor.sprite_pos[0].x = v->IsGroundVehicle() ? (16 - v->GetGroundVehicleCache()->cached_veh_length * 2) * (rtl ? -1 : 1) : 0;
|
|
||||||
_cursor.vehchain = _ctrl_pressed;
|
|
||||||
UpdateCursorSize();
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -627,8 +627,8 @@ public:
|
|||||||
|
|
||||||
this->vehicle_sel = v->index;
|
this->vehicle_sel = v->index;
|
||||||
|
|
||||||
int image = v->GetImage(_current_text_dir == TD_RTL ? DIR_E : DIR_W, EIT_IN_LIST);
|
SetObjectToPlaceWnd(SPR_CURSOR_MOUSE, PAL_NONE, HT_DRAG, this);
|
||||||
SetObjectToPlaceWnd(image, GetVehiclePalette(v), HT_DRAG, this);
|
SetMouseCursorVehicle(v, EIT_IN_LIST);
|
||||||
_cursor.vehchain = true;
|
_cursor.vehchain = true;
|
||||||
|
|
||||||
this->SetDirty();
|
this->SetDirty();
|
||||||
|
@ -2861,3 +2861,20 @@ int GetVehicleWidth(Vehicle *v, EngineImageType image_type)
|
|||||||
|
|
||||||
return vehicle_width;
|
return vehicle_width;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the mouse cursor to look like a vehicle.
|
||||||
|
* @param v Vehicle
|
||||||
|
* @param image_type Type of vehicle image to use.
|
||||||
|
*/
|
||||||
|
void SetMouseCursorVehicle(const Vehicle *v, EngineImageType image_type)
|
||||||
|
{
|
||||||
|
bool rtl = _current_text_dir == TD_RTL;
|
||||||
|
|
||||||
|
_cursor.sprite_count = 1;
|
||||||
|
_cursor.sprite_seq[0].sprite = v->GetImage(rtl ? DIR_E : DIR_W, EIT_IN_DEPOT);
|
||||||
|
_cursor.sprite_seq[0].pal = GetVehiclePalette(v);
|
||||||
|
_cursor.sprite_pos[0].x = v->IsGroundVehicle() ? (16 - v->GetGroundVehicleCache()->cached_veh_length * 2) * (rtl ? -1 : 1) : 0;
|
||||||
|
|
||||||
|
UpdateCursorSize();
|
||||||
|
}
|
||||||
|
@ -100,5 +100,6 @@ void StartStopVehicle(const Vehicle *v, bool texteffect);
|
|||||||
Vehicle *CheckClickOnVehicle(const struct ViewPort *vp, int x, int y);
|
Vehicle *CheckClickOnVehicle(const struct ViewPort *vp, int x, int y);
|
||||||
|
|
||||||
void DrawVehicleImage(const Vehicle *v, int left, int right, int y, VehicleID selection, EngineImageType image_type, int skip);
|
void DrawVehicleImage(const Vehicle *v, int left, int right, int y, VehicleID selection, EngineImageType image_type, int skip);
|
||||||
|
void SetMouseCursorVehicle(const Vehicle *v, EngineImageType image_type);
|
||||||
|
|
||||||
#endif /* VEHICLE_GUI_H */
|
#endif /* VEHICLE_GUI_H */
|
||||||
|
Loading…
Reference in New Issue
Block a user