diff options
author | terkhen <terkhen@openttd.org> | 2010-12-21 14:00:14 +0000 |
---|---|---|
committer | terkhen <terkhen@openttd.org> | 2010-12-21 14:00:14 +0000 |
commit | 3e6ebc7158332e4d3fd604be458d3565b8c052f7 (patch) | |
tree | 564d4f18f9d640d668b6e873975ea4e8dc868d01 | |
parent | f8c31319e97433e6dc5fb39d4925f773434e87ed (diff) | |
download | openttd-3e6ebc7158332e4d3fd604be458d3565b8c052f7.tar.xz |
(svn r21568) -Add: Show the selected consist part at the refit window.
-rw-r--r-- | src/vehicle_gui.cpp | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/src/vehicle_gui.cpp b/src/vehicle_gui.cpp index 91d204791..3a20cd2f8 100644 --- a/src/vehicle_gui.cpp +++ b/src/vehicle_gui.cpp @@ -614,6 +614,55 @@ struct RefitWindow : public Window { 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); + /* 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; } @@ -737,6 +786,7 @@ struct RefitWindow : public Window { NWidgetBase *nwi = this->GetWidget<NWidgetBase>(VRW_VEHICLE_PANEL_DISPLAY); this->click_x = GetClickPosition(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); 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) { switch (widget) { |