34 #include "table/strings.h"
88 _nested_train_depot_widgets,
lengthof(_nested_train_depot_widgets)
95 _nested_train_depot_widgets,
lengthof(_nested_train_depot_widgets)
102 _nested_train_depot_widgets,
lengthof(_nested_train_depot_widgets)
106 WDP_AUTO,
"depot_aircraft", 332, 99,
109 _nested_train_depot_widgets,
lengthof(_nested_train_depot_widgets)
123 if (result.
Failed())
return;
134 if (v == wagon)
return;
137 if (head != NULL) wagon = head->
Last();
140 if (wagon == NULL)
return;
143 if (wagon == v)
return;
160 switch (image_type) {
161 case EIT_IN_DEPOT:
return _base_block_sizes_depot[type];
162 case EIT_PURCHASE:
return _base_block_sizes_purchase[type];
163 default: NOT_REACHED();
169 int max_extend_left = 0;
170 int max_extend_right = 0;
174 FOR_ALL_ENGINES_OF_TYPE(e, type) {
182 default: NOT_REACHED();
188 if (y > max_height) max_height = y;
189 if (-x_offs > max_extend_left) max_extend_left = -x_offs;
190 if ((
int)x + x_offs > max_extend_right) max_extend_right = x + x_offs;
196 switch (image_type) {
199 _base_block_sizes_depot[type].
extend_left =
Clamp(max_extend_left, min_extend, max_extend);
200 _base_block_sizes_depot[type].
extend_right =
Clamp(max_extend_right, min_extend, max_extend);
204 _base_block_sizes_purchase[type].
extend_left =
Clamp(max_extend_left, min_extend, max_extend);
205 _base_block_sizes_purchase[type].
extend_right =
Clamp(max_extend_right, min_extend, max_extend);
208 default: NOT_REACHED();
224 static void DepotSellAllConfirmationCallback(
Window *w,
bool confirmed);
234 uint unitnumber_digits;
245 this->generate_list =
true;
248 this->unitnumber_digits = 2;
281 bool free_wagon =
false;
285 int image_left = rtl ? left + this->count_width : left + this->header_width;
286 int image_right = rtl ? right - this->header_width : right - this->count_width;
293 uint x_space = free_wagon ?
ScaleGUITrad(TRAININFO_DEFAULT_VEHICLE_WIDTH) : 0;
294 DrawTrainImage(u, image_left + (rtl ? 0 : x_space), image_right - (rtl ? x_space : 0), sprite_y - 1,
307 default: NOT_REACHED();
320 int text_left = rtl ? right - this->header_width - 1 : left + diff_x;
321 int text_right = rtl ? right - diff_x : left + this->header_width - 1;
324 DrawString(text_left, text_right, y + 2, STR_DEPOT_NO_ENGINE);
347 for (byte i = 0; i < this->
num_columns && num < maxval; i++, num++) {
349 const Vehicle *v = this->vehicle_list[num];
363 const Vehicle *v = this->wagon_list[num - this->vehicle_list.
Length()];
383 enum DepotGUIAction {
390 DepotGUIAction GetVehicleFromDepotWndPt(
int x,
int y,
const Vehicle **veh, GetDepotVehiclePtData *d)
const
396 uint xt = 0, xm = 0, ym = 0;
407 if (row >= this->vscroll->
GetCapacity())
return MODE_ERROR;
411 if (this->vehicle_list.
Length() + this->wagon_list.
Length() <= pos) {
417 return MODE_DRAG_VEHICLE;
424 if (this->vehicle_list.
Length() > pos) {
425 *veh = this->vehicle_list[pos];
429 pos -= this->vehicle_list.
Length();
430 *veh = this->wagon_list[pos];
436 const Train *v = NULL;
439 d->head = d->wagon = v;
442 if (xm <= this->header_width) {
443 switch (this->type) {
445 if (wagon)
return MODE_ERROR;
448 if (xm <= this->flag_width)
return MODE_START_STOP;
456 default: NOT_REACHED();
458 return MODE_SHOW_VEHICLE;
461 if (this->type !=
VEH_TRAIN)
return MODE_DRAG_VEHICLE;
464 if (xm >= matrix_widget->
current_x - this->count_width)
return wagon ? MODE_ERROR : MODE_SHOW_VEHICLE;
467 x -= this->header_width;
470 for (; v != NULL; v = v->
Next()) {
477 return MODE_DRAG_VEHICLE;
489 DepotGUIAction mode = this->GetVehicleFromDepotWndPt(x, y, &v, &gdvp);
491 if (this->type ==
VEH_TRAIN) v = gdvp.wagon;
497 case MODE_DRAG_VEHICLE: {
504 TrainDepotMoveVehicle(v, sel, gdvp.head);
505 }
else if (v != NULL) {
510 this->sel = v->
index;
519 case MODE_SHOW_VEHICLE:
523 case MODE_START_STOP:
527 default: NOT_REACHED();
539 this->GetWidget<NWidgetCore>(
WID_D_STOP_ALL)->tool_tip = STR_DEPOT_MASS_STOP_DEPOT_TRAIN_TOOLTIP + type;
540 this->GetWidget<NWidgetCore>(
WID_D_START_ALL)->tool_tip = STR_DEPOT_MASS_START_DEPOT_TRAIN_TOOLTIP + type;
541 this->GetWidget<NWidgetCore>(
WID_D_SELL)->tool_tip = STR_DEPOT_TRAIN_SELL_TOOLTIP + type;
542 this->GetWidget<NWidgetCore>(
WID_D_SELL_ALL)->tool_tip = STR_DEPOT_SELL_ALL_BUTTON_TRAIN_TOOLTIP + type;
544 this->GetWidget<NWidgetCore>(
WID_D_BUILD)->
SetDataTip(STR_DEPOT_TRAIN_NEW_VEHICLES_BUTTON + type, STR_DEPOT_TRAIN_NEW_VEHICLES_TOOLTIP + type);
545 this->GetWidget<NWidgetCore>(
WID_D_CLONE)->
SetDataTip(STR_DEPOT_CLONE_TRAIN + type, STR_DEPOT_CLONE_TRAIN_DEPOT_INFO + type);
547 this->GetWidget<NWidgetCore>(
WID_D_LOCATION)->tool_tip = STR_DEPOT_TRAIN_LOCATION_TOOLTIP + type;
548 this->GetWidget<NWidgetCore>(
WID_D_VEHICLE_LIST)->tool_tip = STR_DEPOT_VEHICLE_ORDER_LIST_TRAIN_TOOLTIP + type;
549 this->GetWidget<NWidgetCore>(
WID_D_AUTOREPLACE)->tool_tip = STR_DEPOT_AUTOREPLACE_TRAIN_TOOLTIP + type;
550 this->GetWidget<NWidgetCore>(
WID_D_MATRIX)->tool_tip = STR_DEPOT_TRAIN_LIST_TOOLTIP + this->type;
553 default: NOT_REACHED();
559 this->GetWidget<NWidgetCore>(
WID_D_SELL)->widget_data = SPR_SELL_TRAIN;
560 this->GetWidget<NWidgetCore>(
WID_D_SELL_ALL)->widget_data = SPR_SELL_ALL_TRAIN;
561 this->GetWidget<NWidgetCore>(
WID_D_AUTOREPLACE)->widget_data = SPR_REPLACE_TRAIN;
568 this->GetWidget<NWidgetCore>(
WID_D_SELL)->widget_data = SPR_SELL_ROADVEH;
569 this->GetWidget<NWidgetCore>(
WID_D_SELL_ALL)->widget_data = SPR_SELL_ALL_ROADVEH;
570 this->GetWidget<NWidgetCore>(
WID_D_AUTOREPLACE)->widget_data = SPR_REPLACE_ROADVEH;
577 this->GetWidget<NWidgetCore>(
WID_D_SELL)->widget_data = SPR_SELL_SHIP;
578 this->GetWidget<NWidgetCore>(
WID_D_SELL_ALL)->widget_data = SPR_SELL_ALL_SHIP;
586 this->GetWidget<NWidgetCore>(
WID_D_SELL)->widget_data = SPR_SELL_AIRCRAFT;
587 this->GetWidget<NWidgetCore>(
WID_D_SELL_ALL)->widget_data = SPR_SELL_ALL_AIRCRAFT;
588 this->GetWidget<NWidgetCore>(
WID_D_AUTOREPLACE)->widget_data = SPR_REPLACE_AIRCRAFT;
609 this->count_width = 0;
625 int base_width = this->count_width + this->header_width;
631 size->height = resize->height * 6;
634 size->width = resize->width * (this->type ==
VEH_ROAD ? 5 : 3);
635 size->height = resize->height * (this->type ==
VEH_ROAD ? 5 : 3);
637 fill->width = resize->width;
638 fill->height = resize->height;
651 this->generate_list =
true;
656 if (this->generate_list) {
660 this->generate_list =
false;
661 DepotSortList(&this->vehicle_list);
664 if (this->unitnumber_digits != new_unitnumber_digits) {
665 this->unitnumber_digits = new_unitnumber_digits;
672 uint max_width =
ScaleGUITrad(VEHICLEINFO_FULL_VEHICLE_WIDTH);
673 for (uint num = 0; num < this->vehicle_list.
Length(); num++) {
678 max_width =
max(max_width, width);
723 static const CursorID clone_icons[] = {
724 SPR_CURSOR_CLONE_TRAIN, SPR_CURSOR_CLONE_ROADVEH,
725 SPR_CURSOR_CLONE_SHIP, SPR_CURSOR_CLONE_AIRPLANE
757 if (this->vehicle_list.
Length() != 0 || this->wagon_list.
Length() != 0) {
759 byte vehtype = this->type;
765 STR_DEPOT_SELL_CONFIRMATION_TEXT,
767 DepotSellAllConfirmationCallback
773 ShowVehicleListWindow(
GetTileOwner(this->window_number), this->type, (
TileIndex)this->window_number);
785 if (str == NULL)
return;
798 DepotGUIAction mode = this->GetVehicleFromDepotWndPt(pt.x - nwi->
pos_x, pt.y - nwi->
pos_y, &v, &gdvp);
800 if (this->type ==
VEH_TRAIN) v = gdvp.wagon;
802 if (v == NULL || mode != MODE_DRAG_VEHICLE)
return false;
811 for (
const Vehicle *w = v; w != NULL; w = w->
Next()) {
812 if (w->cargo_cap > 0 && w->cargo_type <
NUM_CARGO) {
813 capacity[w->cargo_type] += w->cargo_cap;
814 loaded [w->cargo_type] += w->cargo.StoredCount();
817 if (w->type ==
VEH_TRAIN && !w->HasArticulatedPart()) {
819 if (!whole_chain)
break;
824 static char details[1024];
829 if (capacity[cargo_type] == 0)
continue;
835 pos = GetString(pos, STR_DEPOT_VEHICLE_TOOLTIP_CARGO,
lastof(details));
841 args[1] = (uint64)(
size_t)details;
842 GuiShowTooltips(
this, whole_chain ? STR_DEPOT_VEHICLE_TOOLTIP_CHAIN : STR_DEPOT_VEHICLE_TOOLTIP, 2, args, TCC_RIGHT_CLICK);
885 NWidgetBase *matrix = this->GetWidget<NWidgetBase>(widget);
889 if (this->GetVehicleFromDepotWndPt(pt.x - matrix->
pos_x, pt.y - matrix->
pos_y, &v, &gdvp) != MODE_DRAG_VEHICLE)
return;
892 if (gdvp.head != NULL) {
893 if (gdvp.wagon == NULL && gdvp.head->
Last()->
index != this->sel) {
898 new_vehicle_over = gdvp.head->
index;
899 }
else if (gdvp.wagon != NULL && gdvp.head != gdvp.wagon &&
900 gdvp.wagon->
index != this->sel &&
902 new_vehicle_over = gdvp.wagon->
index;
926 if (this->GetVehicleFromDepotWndPt(pt.x - nwi->
pos_x, pt.y - nwi->
pos_y, &v, &gdvp) == MODE_DRAG_VEHICLE && sel !=
INVALID_VEHICLE) {
930 }
else if (gdvp.wagon == NULL || gdvp.wagon->
index != sel) {
932 TrainDepotMoveVehicle(gdvp.wagon, sel, gdvp.head);
933 }
else if (gdvp.head != NULL && gdvp.head->
IsFrontEngine()) {
937 }
else if (this->GetVehicleFromDepotWndPt(pt.x - nwi->
pos_x, pt.y - nwi->
pos_y, &v, NULL) == MODE_DRAG_VEHICLE && v != NULL && sel == v->
index) {
1000 static void DepotSellAllConfirmationCallback(
Window *win,
bool confirmed)
1005 byte vehtype = w->type;
1021 default: NOT_REACHED();
1022 case VEH_TRAIN: desc = &_train_depot_desc;
break;
1023 case VEH_ROAD: desc = &_road_depot_desc;
break;
1024 case VEH_SHIP: desc = &_ship_depot_desc;
break;
1025 case VEH_AIRCRAFT: desc = &_aircraft_depot_desc;
break;