20 #include "table/strings.h"
33 if (result.
Failed())
return;
40 if (found != NULL)
return;
47 found = found->
Last();
68 dragged_width += t->GetDisplayImageWidth(NULL);
71 int drag_hlight_left = rtl ?
max(px -dragged_width, 0) : px;
72 int drag_hlight_right = rtl ? px :
min(px + dragged_width, max_width);
73 int drag_hlight_width =
max(drag_hlight_right - drag_hlight_left, 0);
75 if (drag_hlight_width > 0) {
80 return drag_hlight_width;
102 int max_width = right - left + 1;
110 int px = rtl ? max_width + skip : -skip;
111 bool sel_articulated =
false;
113 bool drag_at_end_of_train = (drag_dest == v->
index);
114 for (; v != NULL && (rtl ? px > 0 : px < max_width); v = v->
Next()) {
115 if (dragging && !drag_at_end_of_train && drag_dest == v->index) {
118 px += rtl ? -drag_hlight_width : drag_hlight_width;
124 if (rtl ? px + width > 0 : px - width < max_width) {
126 DrawSprite(v->GetImage(dir, image_type), pal, px + (rtl ? -offset.x : offset.x), height / 2 + offset.y);
129 if (!v->IsArticulatedPart()) sel_articulated =
false;
131 if (v->index == selection) {
133 highlight_l = rtl ? px - width : px;
134 highlight_r = rtl ? px - 1 : px + width - 1;
135 sel_articulated =
true;
136 }
else if ((_cursor.
vehchain && highlight_r != 0) || sel_articulated) {
138 highlight_l -= width;
140 highlight_r += width;
144 px += rtl ? -width : width;
147 if (dragging && drag_at_end_of_train) {
152 if (highlight_l != highlight_r) {
200 str =
FreightWagonMult(item->
cargo) > 1 ? STR_VEHICLE_DETAILS_CARGO_FROM_MULT : STR_VEHICLE_DETAILS_CARGO_FROM;
203 str = item->
cargo ==
INVALID_CARGO ? STR_LTBLUE_STRING : STR_VEHICLE_DETAILS_CARGO_EMPTY;
222 DrawString(left, right, y, STR_VEHICLE_DETAILS_TRAIN_WAGON_VALUE);
227 DrawString(left, right, y, STR_VEHICLE_DETAILS_TRAIN_ENGINE_BUILT_AND_VALUE);
247 str =
FreightWagonMult(item->
cargo) > 1 ? STR_VEHICLE_INFO_CAPACITY_MULT : STR_VEHICLE_INFO_CAPACITY;
251 str = STR_VEHICLE_INFO_NO_CAPACITY;
273 if (item == summary->
End()) {
279 item->
source = INVALID_STATION;
318 act_cargo[v->cargo_type] += v->cargo.StoredCount();
319 max_cargo[v->cargo_type] += v->cargo_cap;
326 if (max_cargo[i] > 0) num++;
360 int sprite_y_offset = line_height / 2;
367 int x = rtl ? right : left;
368 for (; v != NULL && vscroll_pos > -vscroll_cap; v = v->
GetNextVehicle()) {
378 if (vscroll_pos <= 0 && vscroll_pos > -vscroll_cap) {
381 if (e->
GetGRF() != NULL) {
387 px += rtl ? -width : width;
393 if (separate_sprite_row) {
398 uint num_lines =
max(1u, _cargo_summary.
Length());
399 for (uint i = 0; i < num_lines; i++) {
401 int data_left = left + (rtl ? 0 : sprite_width);
402 int data_right = right - (rtl ? sprite_width : 0);
403 if (vscroll_pos <= 0 && vscroll_pos > -vscroll_cap) {
404 int py = y - line_height * vscroll_pos + text_y_offset;
405 if (i > 0 || separate_sprite_row) {
410 if (i < _cargo_summary.
Length()) {
413 DrawString(data_left, data_right, py, STR_QUANTITY_N_A, TC_LIGHT_BLUE);
422 if (i < _cargo_summary.
Length()) {
426 DrawString(data_left, data_right, py, STR_VEHICLE_INFO_NO_CAPACITY);
430 default: NOT_REACHED();
439 Money feeder_share = 0;
441 for (
const Vehicle *u = v; u != NULL; u = u->
Next()) {
442 act_cargo[u->cargo_type] += u->cargo.StoredCount();
443 max_cargo[u->cargo_type] += u->cargo_cap;
444 feeder_share += u->cargo.FeederShare();
448 DrawString(left, right, y + text_y_offset, STR_VEHICLE_DETAILS_TRAIN_TOTAL_CAPACITY_TEXT);
452 if (max_cargo[i] > 0 && --vscroll_pos < 0 && vscroll_pos > -vscroll_cap) {
458 DrawString(left, right, y + text_y_offset,
FreightWagonMult(i) > 1 ? STR_VEHICLE_DETAILS_TRAIN_TOTAL_CAPACITY_MULT : STR_VEHICLE_DETAILS_TRAIN_TOTAL_CAPACITY);
463 DrawString(left, right, y + text_y_offset, STR_VEHICLE_INFO_FEEDER_CARGO_VALUE);