Index: train_gui.c =================================================================== --- train_gui.c (revision 6418) +++ train_gui.c (working copy) @@ -357,9 +357,10 @@ { DrawPixelInfo tmp_dpi, *old_dpi; int dx = -(skip * 8) / _traininfo_vehicle_width; - /* Position of highlight box */ + // position of highlight box int highlight_l = 0; int highlight_r = 0; + bool sel_found = false; if (!FillDrawPixelInfo(&tmp_dpi, x - 2, y - 1, count + 1, 14)) return; @@ -376,9 +377,15 @@ PalSpriteID pal = (v->vehstatus & VS_CRASHED) ? PALETTE_CRASH : GetVehiclePalette(v); DrawSprite(GetTrainImage(v, DIR_W) | pal, 16 + WagonLengthToPixels(dx), 7 + (is_custom_sprite(RailVehInfo(v->engine_type)->image_index) ? _traininfo_vehicle_pitch : 0)); if (v->index == selection) { - /* Set the highlight position */ + // set the highlight position highlight_l = WagonLengthToPixels(dx) + 1; - highlight_r = WagonLengthToPixels(dx + width) + 1; + + if (!_ctrl_pressed) { + highlight_r = WagonLengthToPixels(dx + width) + 1; + } else { + // a vehicle has been selected and ctrl key is pressed + sel_found = true; + } } } } @@ -387,6 +394,11 @@ v = v->next; } while (dx < count && v != NULL); + if (sel_found == true) { + // highlight from selected vehicle to the end of the train(s)+wagon(s) + highlight_r = WagonLengthToPixels(dx) + 1; + } + if (highlight_l != highlight_r) { /* Draw the highlight. Now done after drawing all the engines, as * the next engine after the highlight could overlap it. */ @@ -697,9 +709,15 @@ _place_clicked_vehicle = NULL; HandleCloneVehClick(v, w); } + + if (_ctrl_pressed != WP(w,traindepot_d).ctrl_key_status) { + // ctrl key has been toggled + WP(w,traindepot_d).ctrl_key_status = _ctrl_pressed; + // redraw highlight around selected vehicle(s) for drag/drop + SetWindowDirty(w); + } } break; - case WE_DESTROY: DeleteWindowById(WC_BUILD_VEHICLE, w->window_number); break; @@ -761,6 +779,7 @@ break; } } break; + case WE_RESIZE: { /* Update the scroll + matrix */ w->vscroll.cap += e->sizing.diff.y / 14; Index: window.h =================================================================== --- window.h (revision 6418) +++ window.h (working copy) @@ -379,6 +379,8 @@ typedef struct { VehicleID sel; + // used to track whether the ctrl key was toggled, so that drap/drop highlight can be redrawn + bool ctrl_key_status; } traindepot_d; assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(traindepot_d));