summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/depot_gui.cpp9
-rw-r--r--src/gfx_type.h2
-rw-r--r--src/group_gui.cpp2
-rw-r--r--src/roadveh_gui.cpp20
-rw-r--r--src/train_gui.cpp2
5 files changed, 32 insertions, 3 deletions
diff --git a/src/depot_gui.cpp b/src/depot_gui.cpp
index aeda3fb6f..e6f9fbcc5 100644
--- a/src/depot_gui.cpp
+++ b/src/depot_gui.cpp
@@ -441,6 +441,7 @@ static void DepotClick(Window *w, int x, int y)
WP(w, depot_d).sel = v->index;
SetWindowDirty(w);
SetObjectToPlaceWnd(image, GetVehiclePalette(v), VHM_DRAG, w);
+ _cursor.vehchain = _ctrl_pressed;
}
}
break;
@@ -957,6 +958,7 @@ static void DepotWndProc(Window *w, WindowEvent *e)
WP(w, depot_d).sel = INVALID_VEHICLE;
SetWindowDirty(w);
}
+ _cursor.vehchain = false;
break;
case WE_RESIZE:
@@ -965,6 +967,13 @@ static void DepotWndProc(Window *w, WindowEvent *e)
w->widget[DEPOT_WIDGET_MATRIX].data = (w->vscroll.cap << 8) + (WP(w, depot_d).type == VEH_TRAIN ? 1 : w->hscroll.cap);
ResizeDepotButtons(w);
break;
+
+ case WE_CTRL_CHANGED:
+ if (WP(w, depot_d).sel != INVALID_VEHICLE) {
+ _cursor.vehchain = _ctrl_pressed;
+ w->InvalidateWidget(DEPOT_WIDGET_MATRIX);
+ }
+ break;
}
}
diff --git a/src/gfx_type.h b/src/gfx_type.h
index 4e6cf28ff..e0e3a30c5 100644
--- a/src/gfx_type.h
+++ b/src/gfx_type.h
@@ -130,6 +130,8 @@ struct CursorVars {
bool dirty; ///< the rect occupied by the mouse is dirty (redraw)
bool fix_at; ///< mouse is moving, but cursor is not (used for scrolling)
bool in_window; ///< mouse inside this window, determines drawing logic
+
+ bool vehchain; ///< vehicle chain is dragged
};
struct DrawPixelInfo {
diff --git a/src/group_gui.cpp b/src/group_gui.cpp
index 85ca3ea14..23e1f5c4e 100644
--- a/src/group_gui.cpp
+++ b/src/group_gui.cpp
@@ -575,6 +575,7 @@ static void GroupWndProc(Window *w, WindowEvent *e)
if (v->IsValid()) {
SetObjectToPlaceWnd(v->GetImage(DIR_W), GetVehiclePalette(v), VHM_DRAG, w);
+ _cursor.vehchain = true;
}
SetWindowDirty(w);
@@ -687,6 +688,7 @@ static void GroupWndProc(Window *w, WindowEvent *e)
break;
}
}
+ _cursor.vehchain = false;
break;
}
diff --git a/src/roadveh_gui.cpp b/src/roadveh_gui.cpp
index 160a5874a..ba383c8bf 100644
--- a/src/roadveh_gui.cpp
+++ b/src/roadveh_gui.cpp
@@ -109,15 +109,29 @@ void DrawRoadVehImage(const Vehicle *v, int x, int y, VehicleID selection, int c
* 0, we draw enough vehicles for 10 standard vehicle lengths. */
int max_length = (count == 0) ? 80 : count * 8;
- for (int dx = 0 ; v != NULL && dx < max_length ; dx += v->u.road.cached_veh_length, v = v->Next()) {
- if (dx + v->u.road.cached_veh_length > 0 && dx <= max_length) {
+ /* Width of highlight box */
+ int highlight_w = 0;
+
+ for (int dx = 0; v != NULL && dx < max_length ; v = v->Next()) {
+ int width = v->u.road.cached_veh_length;
+
+ if (dx + width > 0 && dx <= max_length) {
SpriteID pal = (v->vehstatus & VS_CRASHED) ? PALETTE_CRASH : GetVehiclePalette(v);
DrawSprite(v->GetImage(DIR_W), pal, x + 14 + RoadVehLengthToPixels(dx), y + 6);
if (v->index == selection) {
- DrawFrameRect(x - 1, y - 1, x + 28, y + 12, 15, FR_BORDERONLY);
+ /* Set the highlight position */
+ highlight_w = RoadVehLengthToPixels(width);
+ } else if (_cursor.vehchain && highlight_w != 0) {
+ highlight_w += RoadVehLengthToPixels(width);
}
}
+
+ dx += width;
+ }
+
+ if (highlight_w != 0) {
+ DrawFrameRect(x - 1, y - 1, x - 1 + highlight_w, y + 12, 15, FR_BORDERONLY);
}
}
diff --git a/src/train_gui.cpp b/src/train_gui.cpp
index fd46a10bb..41aceb61a 100644
--- a/src/train_gui.cpp
+++ b/src/train_gui.cpp
@@ -98,6 +98,8 @@ void DrawTrainImage(const Vehicle *v, int x, int y, VehicleID selection, int cou
/* Set the highlight position */
highlight_l = WagonLengthToPixels(dx) + 1;
highlight_r = WagonLengthToPixels(dx + width) + 1;
+ } else if (_cursor.vehchain && highlight_r != 0) {
+ highlight_r += WagonLengthToPixels(width);
}
}
}