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);
235 uint unitnumber_digits;
246 this->generate_list =
true;
250 this->unitnumber_digits = 2;
283 bool free_wagon =
false;
287 int image_left = rtl ? left + this->count_width : left + this->header_width;
288 int image_right = rtl ? right - this->header_width : right - this->count_width;
295 uint x_space = free_wagon ?
ScaleGUITrad(TRAININFO_DEFAULT_VEHICLE_WIDTH) : 0;
296 DrawTrainImage(u, image_left + (rtl ? 0 : x_space), image_right - (rtl ? x_space : 0), sprite_y - 1,
309 default: NOT_REACHED();
322 int text_left = rtl ? right - this->header_width - 1 : left + diff_x;
323 int text_right = rtl ? right - diff_x : left + this->header_width - 1;
326 DrawString(text_left, text_right, y + 2, STR_DEPOT_NO_ENGINE);
349 for (byte i = 0; i < this->
num_columns && num < maxval; i++, num++) {
351 const Vehicle *v = this->vehicle_list[num];
365 const Vehicle *v = this->wagon_list[num - this->vehicle_list.
Length()];
385 enum DepotGUIAction {
392 DepotGUIAction GetVehicleFromDepotWndPt(
int x,
int y,
const Vehicle **veh, GetDepotVehiclePtData *d)
const
398 uint xt = 0, xm = 0, ym = 0;
409 if (row >= this->vscroll->
GetCapacity())
return MODE_ERROR;
413 if (this->vehicle_list.
Length() + this->wagon_list.
Length() <= pos) {
419 return MODE_DRAG_VEHICLE;
426 if (this->vehicle_list.
Length() > pos) {
427 *veh = this->vehicle_list[pos];
431 pos -= this->vehicle_list.
Length();
432 *veh = this->wagon_list[pos];
438 const Train *v = NULL;
441 d->head = d->wagon = v;
444 if (xm <= this->header_width) {
445 switch (this->type) {
447 if (wagon)
return MODE_ERROR;
451 if (xm <= this->flag_width)
return MODE_START_STOP;
459 default: NOT_REACHED();
461 return MODE_SHOW_VEHICLE;
464 if (this->type !=
VEH_TRAIN)
return MODE_DRAG_VEHICLE;
467 if (xm >= matrix_widget->
current_x - this->count_width)
return wagon ? MODE_ERROR : MODE_SHOW_VEHICLE;
470 x -= this->header_width;
473 for (; v != NULL; v = v->
Next()) {
480 return MODE_DRAG_VEHICLE;
492 DepotGUIAction mode = this->GetVehicleFromDepotWndPt(x, y, &v, &gdvp);
494 if (this->type ==
VEH_TRAIN) v = gdvp.wagon;
500 case MODE_DRAG_VEHICLE: {
507 TrainDepotMoveVehicle(v, sel, gdvp.head);
508 }
else if (v != NULL) {
513 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);
665 if (this->unitnumber_digits < new_unitnumber_digits) {
666 this->unitnumber_digits = new_unitnumber_digits;
673 uint max_width =
ScaleGUITrad(VEHICLEINFO_FULL_VEHICLE_WIDTH);
674 for (uint num = 0; num < this->vehicle_list.
Length(); num++) {
679 max_width =
max(max_width, width);
724 static const CursorID clone_icons[] = {
725 SPR_CURSOR_CLONE_TRAIN, SPR_CURSOR_CLONE_ROADVEH,
726 SPR_CURSOR_CLONE_SHIP, SPR_CURSOR_CLONE_AIRPLANE
758 if (this->vehicle_list.
Length() != 0 || this->wagon_list.
Length() != 0) {
760 byte vehtype = this->type;
766 STR_DEPOT_SELL_CONFIRMATION_TEXT,
768 DepotSellAllConfirmationCallback
774 ShowVehicleListWindow(
GetTileOwner(this->window_number), this->type, (
TileIndex)this->window_number);
786 if (str == NULL)
return;
799 DepotGUIAction mode = this->GetVehicleFromDepotWndPt(pt.x - nwi->
pos_x, pt.y - nwi->
pos_y, &v, &gdvp);
801 if (this->type ==
VEH_TRAIN) v = gdvp.wagon;
803 if (v == NULL || mode != MODE_DRAG_VEHICLE)
return false;
812 for (
const Vehicle *w = v; w != NULL; w = w->
Next()) {
813 if (w->cargo_cap > 0 && w->cargo_type <
NUM_CARGO) {
814 capacity[w->cargo_type] += w->cargo_cap;
815 loaded [w->cargo_type] += w->cargo.StoredCount();
818 if (w->type ==
VEH_TRAIN && !w->HasArticulatedPart()) {
820 if (!whole_chain)
break;
825 static char details[1024];
830 if (capacity[cargo_type] == 0)
continue;
836 pos = GetString(pos, STR_DEPOT_VEHICLE_TOOLTIP_CARGO,
lastof(details));
842 args[1] = (uint64)(
size_t)details;
843 GuiShowTooltips(
this, whole_chain ? STR_DEPOT_VEHICLE_TOOLTIP_CHAIN : STR_DEPOT_VEHICLE_TOOLTIP, 2, args, TCC_RIGHT_CLICK);
904 NWidgetBase *matrix = this->GetWidget<NWidgetBase>(widget);
908 if (this->GetVehicleFromDepotWndPt(pt.x - matrix->
pos_x, pt.y - matrix->
pos_y, &v, &gdvp) != MODE_DRAG_VEHICLE)
return;
911 if (gdvp.head != NULL) {
912 if (gdvp.wagon == NULL && gdvp.head->
Last()->
index != this->sel) {
917 new_vehicle_over = gdvp.head->
index;
918 }
else if (gdvp.wagon != NULL && gdvp.head != gdvp.wagon &&
919 gdvp.wagon->
index != this->sel &&
921 new_vehicle_over = gdvp.wagon->
index;
945 if (this->GetVehicleFromDepotWndPt(pt.x - nwi->
pos_x, pt.y - nwi->
pos_y, &v, &gdvp) == MODE_DRAG_VEHICLE && sel !=
INVALID_VEHICLE) {
949 }
else if (gdvp.wagon == NULL || gdvp.wagon->
index != sel) {
951 TrainDepotMoveVehicle(gdvp.wagon, sel, gdvp.head);
952 }
else if (gdvp.head != NULL && gdvp.head->
IsFrontEngine()) {
956 }
else if (this->GetVehicleFromDepotWndPt(pt.x - nwi->
pos_x, pt.y - nwi->
pos_y, &v, NULL) == MODE_DRAG_VEHICLE && v != NULL && sel == v->
index) {
1021 static void DepotSellAllConfirmationCallback(
Window *win,
bool confirmed)
1026 byte vehtype = w->type;
1042 default: NOT_REACHED();
1043 case VEH_TRAIN: desc = &_train_depot_desc;
break;
1044 case VEH_ROAD: desc = &_road_depot_desc;
break;
1045 case VEH_SHIP: desc = &_ship_depot_desc;
break;
1046 case VEH_AIRCRAFT: desc = &_aircraft_depot_desc;
break;