mirror of https://github.com/OpenTTD/OpenTTD
(svn r21568) -Add: Show the selected consist part at the refit window.
parent
f8c31319e9
commit
3e6ebc7158
|
@ -614,6 +614,55 @@ struct RefitWindow : public Window {
|
||||||
DrawVehicleImage(v, this->sprite_left + WD_FRAMERECT_LEFT, this->sprite_right - WD_FRAMERECT_RIGHT,
|
DrawVehicleImage(v, this->sprite_left + WD_FRAMERECT_LEFT, this->sprite_right - WD_FRAMERECT_RIGHT,
|
||||||
r.top + WD_FRAMERECT_TOP, INVALID_VEHICLE, this->hscroll != NULL ? this->hscroll->GetPosition() : 0);
|
r.top + WD_FRAMERECT_TOP, INVALID_VEHICLE, this->hscroll != NULL ? this->hscroll->GetPosition() : 0);
|
||||||
|
|
||||||
|
/* Highlight selected vehicles. */
|
||||||
|
int x = 0;
|
||||||
|
switch (v->type) {
|
||||||
|
case VEH_TRAIN: {
|
||||||
|
VehicleSet vehicles_to_refit;
|
||||||
|
GetVehicleSet(vehicles_to_refit, Vehicle::Get(this->selected_vehicle), this->num_vehicles);
|
||||||
|
|
||||||
|
int left = INT32_MIN;
|
||||||
|
int width = 0;
|
||||||
|
|
||||||
|
for (Train *u = Train::From(v); u != NULL; u = u->Next()) {
|
||||||
|
/* Start checking. */
|
||||||
|
if (vehicles_to_refit.Contains(u->index) && left == INT32_MIN) {
|
||||||
|
left = x - this->hscroll->GetPosition() + r.left + this->vehicle_margin;
|
||||||
|
width = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Draw a selection. */
|
||||||
|
if ((!vehicles_to_refit.Contains(u->index) || u->Next() == NULL) && left != INT32_MIN) {
|
||||||
|
if (u->Next() == NULL && vehicles_to_refit.Contains(u->index)) {
|
||||||
|
int current_width = u->GetDisplayImageWidth();
|
||||||
|
width += current_width;
|
||||||
|
x += current_width;
|
||||||
|
}
|
||||||
|
|
||||||
|
int right = Clamp(left + width, 0, r.right);
|
||||||
|
left = max(0, left);
|
||||||
|
|
||||||
|
if (_current_text_dir == TD_RTL) {
|
||||||
|
right = this->GetWidget<NWidgetCore>(VRW_VEHICLE_PANEL_DISPLAY)->current_x - left;
|
||||||
|
left = right - width;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (left != right) {
|
||||||
|
DrawFrameRect(left, r.top + WD_FRAMERECT_TOP, right, r.top + WD_FRAMERECT_TOP + 13, COLOUR_WHITE, FR_BORDERONLY);
|
||||||
|
}
|
||||||
|
|
||||||
|
left = INT32_MIN;
|
||||||
|
}
|
||||||
|
|
||||||
|
int current_width = u->GetDisplayImageWidth();
|
||||||
|
width += current_width;
|
||||||
|
x += current_width;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
default: break;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -737,6 +786,7 @@ struct RefitWindow : public Window {
|
||||||
NWidgetBase *nwi = this->GetWidget<NWidgetBase>(VRW_VEHICLE_PANEL_DISPLAY);
|
NWidgetBase *nwi = this->GetWidget<NWidgetBase>(VRW_VEHICLE_PANEL_DISPLAY);
|
||||||
this->click_x = GetClickPosition(pt.x - nwi->pos_x);
|
this->click_x = GetClickPosition(pt.x - nwi->pos_x);
|
||||||
this->SetSelectedVehicles(pt.x - nwi->pos_x);
|
this->SetSelectedVehicles(pt.x - nwi->pos_x);
|
||||||
|
this->SetWidgetDirty(VRW_VEHICLE_PANEL_DISPLAY);
|
||||||
SetObjectToPlaceWnd(SPR_CURSOR_MOUSE, PAL_NONE, HT_DRAG, this);
|
SetObjectToPlaceWnd(SPR_CURSOR_MOUSE, PAL_NONE, HT_DRAG, this);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -765,6 +815,19 @@ struct RefitWindow : public Window {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
virtual void OnMouseDrag(Point pt, int widget)
|
||||||
|
{
|
||||||
|
switch (widget) {
|
||||||
|
case VRW_VEHICLE_PANEL_DISPLAY: { // Vehicle image.
|
||||||
|
if (this->order != INVALID_VEH_ORDER_ID) break;
|
||||||
|
NWidgetBase *nwi = this->GetWidget<NWidgetBase>(VRW_VEHICLE_PANEL_DISPLAY);
|
||||||
|
this->SetSelectedVehicles(pt.x - nwi->pos_x);
|
||||||
|
this->SetWidgetDirty(VRW_VEHICLE_PANEL_DISPLAY);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
virtual void OnDragDrop(Point pt, int widget)
|
virtual void OnDragDrop(Point pt, int widget)
|
||||||
{
|
{
|
||||||
switch (widget) {
|
switch (widget) {
|
||||||
|
|
Loading…
Reference in New Issue