@@ -924,64 +924,70 @@ struct RefitWindow : public Window {
} else {
SetDParam(2, money);
return STR_REFIT_NEW_CAPACITY_COST_OF_REFIT;
}
void DrawWidget(const Rect &r, int widget) const override
{
switch (widget) {
case WID_VR_VEHICLE_PANEL_DISPLAY: {
Vehicle *v = Vehicle::Get(this->window_number);
DrawVehicleImage(v, {this->sprite_left + WidgetDimensions::scaled.framerect.left, r.top, this->sprite_right - WidgetDimensions::scaled.framerect.right, r.bottom},
DrawVehicleImage(v, {this->sprite_left, r.top, this->sprite_right, r.bottom},
INVALID_VEHICLE, EIT_IN_DETAILS, this->hscroll != nullptr ? this->hscroll->GetPosition() : 0);
/* Highlight selected vehicles. */
if (this->order != INVALID_VEH_ORDER_ID) break;
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;
/* Determine top & bottom position of the highlight.*/
const int height = ScaleSpriteTrad(12);
const int highlight_top = CenterBounds(r.top, r.bottom, height);
const int highlight_bottom = highlight_top + height - 1;
for (Train *u = Train::From(v); u != nullptr; u = u->Next()) {
/* Start checking. */
const bool contained = std::find(vehicles_to_refit.begin(), vehicles_to_refit.end(), u->index) != vehicles_to_refit.end();
if (contained && left == INT32_MIN) {
left = x - this->hscroll->GetPosition() + r.left + this->vehicle_margin;
width = 0;
/* Draw a selection. */
if ((!contained || u->Next() == nullptr) && left != INT32_MIN) {
if (u->Next() == nullptr && contained) {
int current_width = u->GetDisplayImageWidth();
width += current_width;
x += current_width;
int right = Clamp(left + width, 0, r.right);
left = std::max(0, left);
if (_current_text_dir == TD_RTL) {
right = this->GetWidget<NWidgetCore>(WID_VR_VEHICLE_PANEL_DISPLAY)->current_x - left;
right = r.Width() - left;
left = right - width;
if (left != right) {
DrawFrameRect(left, r.top + WidgetDimensions::scaled.framerect.top, right, r.top + WidgetDimensions::scaled.framerect.top + ScaleSpriteTrad(14) - 1, COLOUR_WHITE, FR_BORDERONLY);
Rect hr = {left, highlight_top, right, highlight_bottom};
DrawFrameRect(hr.Expand(WidgetDimensions::scaled.bevel), COLOUR_WHITE, FR_BORDERONLY);
left = INT32_MIN;
break;
Status change: