77 const StringID BaseVehicleListWindow::vehicle_sorter_names[] = {
81 STR_SORT_BY_PROFIT_THIS_YEAR,
82 STR_SORT_BY_PROFIT_LAST_YEAR,
83 STR_SORT_BY_TOTAL_CAPACITY_PER_CARGOTYPE,
84 STR_SORT_BY_RELIABILITY,
85 STR_SORT_BY_MAX_SPEED,
89 STR_SORT_BY_LIFE_TIME,
90 STR_SORT_BY_TIMETABLE_DELAY,
94 const StringID BaseVehicleListWindow::vehicle_depot_name[] = {
95 STR_VEHICLE_LIST_SEND_TRAIN_TO_DEPOT,
96 STR_VEHICLE_LIST_SEND_ROAD_VEHICLE_TO_DEPOT,
97 STR_VEHICLE_LIST_SEND_SHIP_TO_DEPOT,
98 STR_VEHICLE_LIST_SEND_AIRCRAFT_TO_HANGAR
110 unitnumber = max<uint>(unitnumber, (*v)->unitnumber);
113 if (unitnumber >= 10000)
return 5;
114 if (unitnumber >= 1000)
return 4;
115 if (unitnumber >= 100)
return 3;
125 void BaseVehicleListWindow::BuildVehicleList()
129 DEBUG(misc, 3,
"Building vehicle list type %d for company %d given index %d", this->
vli.
type, this->vli.company, this->vli.index);
184 static const Vehicle *_last_vehicle[2] = { NULL, NULL };
186 void BaseVehicleListWindow::SortVehicleList()
191 _last_vehicle[0] = _last_vehicle[1] = NULL;
196 if (list->
Length() < 2)
return;
209 spr = SPR_PROFIT_NEGATIVE;
211 spr = SPR_PROFIT_SOME;
213 spr = SPR_PROFIT_LOT;
244 byte ret_refit_cyc = 0;
245 bool success =
false;
246 if (subtypes.
Length() > 0) {
249 const Engine *e = v->GetEngine();
251 if (!
HasBit(e->info.refit_mask, dest_cargo_type) && v->cargo_type != dest_cargo_type)
continue;
253 CargoID old_cargo_type = v->cargo_type;
254 byte old_cargo_subtype = v->cargo_subtype;
257 v->cargo_type = dest_cargo_type;
261 v->cargo_subtype = refit_cyc;
264 v->First()->InvalidateNewGRFCache();
265 v->InvalidateNewGRFCache();
268 if (subtype == STR_EMPTY)
break;
270 if (!subtypes.
Contains(subtype))
continue;
273 ret_refit_cyc = refit_cyc;
279 v->cargo_type = old_cargo_type;
280 v->cargo_subtype = old_cargo_subtype;
283 v->First()->InvalidateNewGRFCache();
284 v->InvalidateNewGRFCache();
290 return ret_refit_cyc;
306 return other.
cargo != this->cargo || other.
string != this->string;
316 return other.
cargo == this->cargo && other.
string == this->string;
345 int textleft = r.left +
WD_MATRIX_LEFT + (rtl ? 0 : iconwidth + 4);
349 for (uint i = 0; current < pos + rows && i <
NUM_CARGO; i++) {
350 for (uint j = 0; current < pos + rows && j < list[i].
Length(); j++) {
354 if (sel[0] != (
int)i && refit.
subtype != 0xFF)
continue;
362 if (list[i].Length() > 1) {
366 GfxDrawLine(iconcenter, y -
WD_MATRIX_TOP, iconcenter, j == list[i].Length() - 1 ? ycenter : y -
WD_MATRIX_TOP + delta - 1, linecolour);
367 GfxDrawLine(iconcenter, ycenter, iconinner, ycenter, linecolour);
374 TextColour colour = (sel[0] == (int)i && (uint)sel[1] == j) ? TC_WHITE : TC_BLACK;
378 DrawString(textleft, textright, y, STR_JUST_STRING_STRING, colour);
409 for (uint i = 0; i <
NUM_CARGO; i++) this->list[i].Clear();
419 uint32 cmask = e->info.refit_mask;
428 int current_index = 0;
433 if (!
HasBit(cmask, cid)) {
438 bool first_vehicle = this->list[current_index].
Length() == 0;
444 option->
string = STR_EMPTY;
470 if (subtype == STR_EMPTY)
break;
476 this->list[current_index].
Include(option);
479 if (subtype == STR_EMPTY) {
483 for (uint i = 1; i < l.
Length(); i++) {
484 if (l[i].subtype >= refit_cyc) {
494 while (pos < l.
Length() && l[pos].subtype != refit_cyc) pos++;
495 if (pos < l.
Length() && l[pos].string != subtype) {
525 for (uint j = 0; j < this->list[i].
Length(); j++) {
529 if (this->sel[0] != (
int)i && refit.
subtype != 0xFF)
continue;
531 if (this->sel[0] == (
int)i && (uint)this->sel[1] == j) scroll_row = row;
538 if (scroll_row < row) this->vscroll->
ScrollTowards(scroll_row);
550 for (uint j = 0; j < this->list[i].
Length(); j++) {
554 if (this->sel[0] != (
int)i && refit.
subtype != 0xFF)
continue;
556 if (row == click_row) {
576 if (this->sel[0] < 0)
return NULL;
579 if ((uint)this->sel[1] >= l.
Length())
return NULL;
581 return &l[this->sel[1]];
588 this->auto_refit = auto_refit;
598 nwi->
tool_tip = STR_REFIT_TRAIN_REFIT_TOOLTIP + v->
type;
610 if (this->cargo != NULL) {
615 this->BuildRefitList();
619 for (uint i = 0; this->cargo == NULL && i <
NUM_CARGO; i++) {
620 for (uint j = 0; j < list[i].
Length(); j++) {
621 if (list[i][j] == current_refit_option) {
624 this->cargo = &list[i][j];
631 this->RefreshScrollbar();
641 if (this->hscroll != NULL) this->hscroll->
SetCount(this->vehicle_width);
645 int sprite_width =
max(0, ((
int)vehicle_panel_display->
current_x - this->vehicle_width) / 2);
646 this->sprite_left = vehicle_panel_display->
pos_x;
647 this->sprite_right = vehicle_panel_display->
pos_x + vehicle_panel_display->
current_x - 1;
649 this->sprite_right -= sprite_width;
650 this->vehicle_margin = vehicle_panel_display->
current_x - sprite_right;
652 this->sprite_left += sprite_width;
653 this->vehicle_margin = sprite_left;
664 size->height = resize->height * 8;
706 return STR_PURCHASE_INFO_AIRCRAFT_CAPACITY;
707 }
else if (money <= 0) {
709 return STR_REFIT_NEW_CAPACITY_INCOME_FROM_AIRCRAFT_REFIT;
712 return STR_REFIT_NEW_CAPACITY_COST_OF_AIRCRAFT_REFIT;
718 return STR_PURCHASE_INFO_CAPACITY;
719 }
else if (money <= 0) {
721 return STR_REFIT_NEW_CAPACITY_INCOME_FROM_REFIT;
724 return STR_REFIT_NEW_CAPACITY_COST_OF_REFIT;
745 int left = INT32_MIN;
750 if (vehicles_to_refit.
Contains(u->index) && left == INT32_MIN) {
751 left = x - this->hscroll->
GetPosition() + r.left + this->vehicle_margin;
756 if ((!vehicles_to_refit.
Contains(u->index) || u->Next() == NULL) && left != INT32_MIN) {
757 if (u->Next() == NULL && vehicles_to_refit.
Contains(u->index)) {
758 int current_width = u->GetDisplayImageWidth();
759 width += current_width;
763 int right =
Clamp(left + width, 0, r.right);
768 left = right -
width;
778 int current_width = u->GetDisplayImageWidth();
779 width += current_width;
795 if (this->cargo != NULL) {
796 StringID string = this->GetCapacityString(this->cargo);
818 this->selected_vehicle = v->
index;
819 this->num_vehicles = UINT8_MAX;
824 if (!gui_scope)
break;
825 this->BuildRefitList();
833 for (uint j = 0; j < this->list[i].
Length(); j++) {
834 StringID string = this->GetCapacityString(&list[i][j]);
837 max_width =
max(dim.width, max_width);
842 if (this->information_width < max_width) {
843 this->information_width = max_width;
850 if (!gui_scope)
break;
851 this->cargo = GetRefitOption();
852 this->RefreshScrollbar();
857 int GetClickPosition(
int click_x)
861 click_x -= this->vehicle_margin;
862 if (this->hscroll != NULL) click_x += this->hscroll->
GetPosition();
867 void SetSelectedVehicles(
int drag_x)
869 drag_x = GetClickPosition(drag_x);
871 int left_x =
min(this->click_x, drag_x);
872 int right_x =
max(this->click_x, drag_x);
873 this->num_vehicles = 0;
882 bool start_counting =
false;
883 for (; u != NULL; u = u->
Next()) {
885 left_x -= current_width;
886 right_x -= current_width;
888 if (left_x < 0 && !start_counting) {
889 this->selected_vehicle = u->
index;
890 start_counting =
true;
893 this->num_vehicles++;
896 this->num_vehicles++;
899 if (right_x < 0)
break;
904 if (this->num_vehicles != 0) {
913 this->selected_vehicle = v->
index;
914 this->num_vehicles = UINT8_MAX;
925 this->click_x = GetClickPosition(pt.x - nwi->
pos_x);
926 this->SetSelectedVehicles(pt.x - nwi->
pos_x);
942 if (click_count == 1)
break;
947 if (this->cargo != NULL) {
951 bool delete_window = this->selected_vehicle == v->
index && this->num_vehicles == UINT8_MAX;
952 if (
DoCommandP(v->
tile, this->selected_vehicle, this->cargo->cargo | this->cargo->subtype << 8 | this->num_vehicles << 16, GetCmdRefitVeh(v)) && delete_window)
delete this;
967 this->SetSelectedVehicles(pt.x - nwi->
pos_x);
980 this->SetSelectedVehicles(pt.x - nwi->
pos_x);
995 static const NWidgetPart _nested_vehicle_refit_widgets[] = {
1011 NWidget(
WWT_MATRIX, COLOUR_GREY,
WID_VR_MATRIX),
SetMinimalSize(228, 112),
SetResize(1, 14),
SetFill(1, 1),
SetMatrixDataTip(1, 0, STR_NULL),
SetScrollbar(
WID_VR_SCROLLBAR),
1022 WDP_AUTO,
"view_vehicle_refit", 240, 174,
1025 _nested_vehicle_refit_widgets,
lengthof(_nested_vehicle_refit_widgets)
1053 if (cmask == lmask) {
1055 SetDParam(0, STR_PURCHASE_INFO_ALL_TYPES);
1061 SetDParam(0, STR_PURCHASE_INFO_ALL_BUT);
1090 return (*a)->unitnumber - (*b)->unitnumber;
1096 static char last_name[2][64];
1098 if (*a != _last_vehicle[0]) {
1099 _last_vehicle[0] = *a;
1101 GetString(last_name[0], STR_VEHICLE_NAME,
lastof(last_name[0]));
1104 if (*b != _last_vehicle[1]) {
1105 _last_vehicle[1] = *b;
1107 GetString(last_name[1], STR_VEHICLE_NAME,
lastof(last_name[1]));
1110 int r =
strnatcmp(last_name[0], last_name[1]);
1117 int r = (*a)->age - (*b)->age;
1124 int r =
ClampToI32((*a)->GetDisplayProfitThisYear() - (*b)->GetDisplayProfitThisYear());
1131 int r =
ClampToI32((*a)->GetDisplayProfitLastYear() - (*b)->GetDisplayProfitLastYear());
1157 int r = (*a)->reliability - (*b)->reliability;
1164 int r = (*a)->vcache.cached_max_speed - (*b)->vcache.cached_max_speed;
1171 int r = (*a)->engine_type - (*b)->engine_type;
1181 for (u = *a; u != NULL; u = u->
Next()) diff += u->
value;
1182 for (u = *b; u != NULL; u = u->
Next()) diff -= u->
value;
1191 int r = (*a)->GetGroundVehicleCache()->cached_total_length - (*b)->GetGroundVehicleCache()->cached_total_length;
1198 int r =
ClampToI32(((*a)->max_age - (*a)->age) - ((*b)->max_age - (*b)->age));
1205 int r = (*a)->lateness_counter - (*b)->lateness_counter;
1209 void InitializeGUI()
1252 static const NWidgetPart _nested_vehicle_list[] = {
1269 NWidget(
WWT_MATRIX, COLOUR_GREY,
WID_VL_LIST),
SetMinimalSize(248, 0),
SetFill(1, 0),
SetResize(1, 1),
SetMatrixDataTip(1, 0, STR_NULL),
SetScrollbar(
WID_VL_SCROLLBAR),
1277 SetDataTip(STR_BLACK_STRING, STR_VEHICLE_LIST_AVAILABLE_ENGINES_TOOLTIP),
1280 SetDataTip(STR_VEHICLE_LIST_MANAGE_LIST, STR_VEHICLE_LIST_MANAGE_LIST_TOOLTIP),
1282 SetDataTip(SPR_FLAG_VEH_STOPPED, STR_VEHICLE_LIST_MASS_STOP_LIST_TOOLTIP),
1284 SetDataTip(SPR_FLAG_VEH_RUNNING, STR_VEHICLE_LIST_MASS_START_LIST_TOOLTIP),
1296 if (order == NULL)
return;
1307 if (order->
IsType(OT_GOTO_STATION)) {
1309 DrawString(
left + l_offset, right - r_offset, y, STR_TINY_BLACK_STATION);
1312 if (++i == 4)
break;
1316 order = order->
next;
1317 if (order == NULL) {
1321 }
while (oid != start);
1340 default: NOT_REACHED();
1357 if (divisor == 1)
return base;
1360 uint rem = base % divisor;
1361 return base + (rem == 0 ? 0 : divisor - rem);
1378 int text_left = left + (rtl ? 0 : text_offset);
1379 int text_right = right - (rtl ? text_offset : 0);
1382 int orderlist_left = left + (rtl ? 0 :
max(
ScaleGUITrad(100) + text_offset, width / 2));
1383 int orderlist_right = right - (rtl ?
max(
ScaleGUITrad(100) + text_offset, width / 2) : 0);
1385 int image_left = (rtl && show_orderlist) ? orderlist_right : text_left;
1386 int image_right = (!rtl && show_orderlist) ? orderlist_left : text_right;
1388 int vehicle_button_x = rtl ? right -
GetSpriteSize(SPR_PROFIT_LOT).width :
left;
1391 uint max =
min(this->vscroll->GetPosition() + this->vscroll->GetCapacity(), this->
vehicles.
Length());
1392 for (uint i = this->vscroll->GetPosition(); i <
max; ++i) {
1402 if (v->
name != NULL) {
1405 DrawString(text_left, text_right, y, STR_TINY_BLACK_VEHICLE);
1409 DrawString(text_left, text_right, y, STR_TINY_GROUP, TC_BLACK);
1412 if (show_orderlist) DrawSmallOrderList(v, orderlist_left, orderlist_right, y, v->
cur_real_order_index);
1415 str = STR_BLUE_COMMA;
1457 default: NOT_REACHED();
1467 this->BuildVehicleList();
1468 this->SortVehicleList();
1471 this->GetWidget<NWidgetCore>(
WID_VL_LIST)->tool_tip = STR_VEHICLE_LIST_TRAIN_LIST_TOOLTIP + this->
vli.
vtype;
1473 if (this->
vli.
type == VL_SHARED_ORDERS) {
1474 this->GetWidget<NWidgetCore>(
WID_VL_CAPTION)->widget_data = STR_VEHICLE_LIST_SHARED_ORDERS_LIST_CAPTION;
1476 this->GetWidget<NWidgetCore>(
WID_VL_CAPTION)->widget_data = STR_VEHICLE_LIST_TRAIN_CAPTION + this->
vli.
vtype;
1497 size->height = 6 * resize->height;
1501 size->height = 4 * resize->height;
1503 default: NOT_REACHED();
1510 d.height += padding.height;
1511 *size =
maxdim(*size, d);
1517 d.height += padding.height;
1518 d.width += padding.width;
1519 *size =
maxdim(*size, d);
1534 case VL_SHARED_ORDERS:
1540 SetDParam(0, this->vscroll->GetCount());
1546 SetDParam(3, this->vscroll->GetCount());
1549 case VL_STATION_LIST:
1552 SetDParam(3, this->vscroll->GetCount());
1559 SetDParam(3, this->vscroll->GetCount());
1561 default: NOT_REACHED();
1584 this->BuildVehicleList();
1585 this->SortVehicleList();
1628 uint id_v = this->vscroll->GetScrolledRowFromWidget(pt.y,
this,
WID_VL_LIST);
1671 default: NOT_REACHED();
1674 default: NOT_REACHED();
1683 StationID station = (this->
vli.
type == VL_STATION_LIST) ? this->
vli.
index : INVALID_STATION;
1685 DEBUG(misc, 3,
"Periodic resort %d list company %d at station %d", this->
vli.
vtype, this->owner, station);
1692 this->vscroll->SetCapacityFromWidget(
this,
WID_VL_LIST);
1702 if (!gui_scope &&
HasBit(data, 31) && this->
vli.
type == VL_SHARED_ORDERS) {
1720 WDP_AUTO,
"list_vehicles", 260, 246,
1723 _nested_vehicle_list,
lengthof(_nested_vehicle_list)
1727 WDP_AUTO,
"list_vehicles_train", 325, 246,
1730 _nested_vehicle_list,
lengthof(_nested_vehicle_list)
1739 AllocateWindowDescFront<VehicleListWindow>(&_vehicle_list_train_desc, num);
1742 AllocateWindowDescFront<VehicleListWindow>(&_vehicle_list_other_desc, num);
1756 ShowVehicleListWindowLocal(company, VL_STANDARD, vehicle_type, company);
1760 void ShowVehicleListWindow(
const Vehicle *v)
1767 ShowVehicleListWindowLocal(company, VL_STATION_LIST, vehicle_type, station);
1772 uint16 depot_airport_index;
1779 ShowVehicleListWindowLocal(company, VL_DEPOT_LIST, vehicle_type, depot_airport_index);
1808 SetDataTip(STR_EMPTY, STR_SERVICE_INTERVAL_DROPDOWN_TOOLTIP),
1826 NWidget(
WWT_MATRIX, COLOUR_GREY,
WID_VD_MATRIX),
SetResize(1, 1),
SetMinimalSize(393, 45),
SetMatrixDataTip(1, 0, STR_NULL),
SetFill(1, 0),
SetScrollbar(
WID_VD_SCROLLBAR),
1835 SetDataTip(STR_EMPTY, STR_SERVICE_INTERVAL_DROPDOWN_TOOLTIP),
1842 SetDataTip(STR_VEHICLE_DETAIL_TAB_INFORMATION, STR_VEHICLE_DETAILS_TRAIN_INFORMATION_TOOLTIP),
SetFill(1, 0),
SetResize(1, 0),
1846 SetDataTip(STR_VEHICLE_DETAIL_TAB_TOTAL_CARGO, STR_VEHICLE_DETAILS_TRAIN_TOTAL_CARGO_TOOLTIP),
SetFill(1, 0),
SetResize(1, 0),
1858 static StringID _service_interval_dropdown[] = {
1859 STR_VEHICLE_DETAILS_DEFAULT,
1860 STR_VEHICLE_DETAILS_DAYS,
1861 STR_VEHICLE_DETAILS_PERCENT,
1881 this->owner = v->
owner;
1897 if (!gui_scope)
return;
1901 uint aimed_height = this->GetRoadVehDetailsHeight(v);
1903 if (aimed_height != nwid_info->
current_y) {
1916 uint desired_height;
1921 for (
const Vehicle *u = v; u != NULL; u = u->
Next()) {
1927 return desired_height;
1938 static const StringID info_strings[] = {
1939 STR_VEHICLE_INFO_MAX_SPEED,
1940 STR_VEHICLE_INFO_WEIGHT_POWER_MAX_SPEED,
1941 STR_VEHICLE_INFO_WEIGHT_POWER_MAX_SPEED_MAX_TE,
1942 STR_VEHICLE_INFO_PROFIT_THIS_YEAR_LAST_YEAR,
1943 STR_VEHICLE_INFO_RELIABILITY_BREAKDOWNS
1945 for (uint i = 0; i <
lengthof(info_strings); i++) {
1958 size->height = this->GetRoadVehDetailsHeight(v);
1977 size->height = 4 * resize->height;
1981 StringID *strs = _service_interval_dropdown;
1985 size->width += padding.width;
2003 switch (vehicle_type) {
2004 default: NOT_REACHED();
2030 default: NOT_REACHED();
2049 SetDParam(0, (v->
age + DAYS_IN_YEAR < v->max_age) ? STR_VEHICLE_INFO_AGE : STR_VEHICLE_INFO_AGE_RED);
2066 string = STR_VEHICLE_INFO_WEIGHT_POWER_MAX_SPEED;
2068 string = STR_VEHICLE_INFO_WEIGHT_POWER_MAX_SPEED_MAX_TE;
2076 string = STR_VEHICLE_INFO_MAX_SPEED_TYPE_RANGE;
2078 string = STR_VEHICLE_INFO_MAX_SPEED_TYPE;
2081 string = STR_VEHICLE_INFO_MAX_SPEED;
2110 uint text_left = r.left + (rtl ? 0 : sprite_width);
2111 uint text_right = r.right - (rtl ? sprite_width : 0);
2117 uint sprite_left = rtl ? text_right : r.left;
2118 uint sprite_right = rtl ? r.right : text_left;
2131 v->ServiceIntervalIsPercent() ? STR_VEHICLE_DETAILS_SERVICING_INTERVAL_PERCENT : STR_VEHICLE_DETAILS_SERVICING_INTERVAL_DAYS);
2154 StringID str = v->ServiceIntervalIsCustom() ?
2155 (v->ServiceIntervalIsPercent() ? STR_VEHICLE_DETAILS_PERCENT : STR_VEHICLE_DETAILS_DAYS) :
2156 STR_VEHICLE_DETAILS_DEFAULT;
2180 if (mod == v->GetServiceInterval())
return;
2188 ShowDropDownMenu(
this, _service_interval_dropdown, v->ServiceIntervalIsCustom() ? (v->ServiceIntervalIsPercent() ? 2 : 1) : 0, widget, 0, 0);
2215 bool iscustom = index != 0;
2216 bool ispercent = iscustom ? (index == 2) :
Company::Get(v->
owner)->settings.vehicle.servint_ispercent;
2226 if (str == NULL)
return;
2242 WDP_AUTO,
"view_vehicle_details_train", 405, 178,
2245 _nested_train_vehicle_details_widgets,
lengthof(_nested_train_vehicle_details_widgets)
2250 WDP_AUTO,
"view_vehicle_details", 405, 113,
2253 _nested_nontrain_vehicle_details_widgets,
lengthof(_nested_nontrain_vehicle_details_widgets)
2261 AllocateWindowDescFront<VehicleDetailsWindow>((v->
type ==
VEH_TRAIN) ? &_train_vehicle_details_desc : &_nontrain_vehicle_details_desc, v->
index);
2280 NWidget(
NWID_VIEWPORT, INVALID_COLOUR,
WID_VV_VIEWPORT),
SetMinimalSize(226, 84),
SetResize(1, 1),
SetPadding(1, 1, 1, 1),
2291 SetDataTip(SPR_IGNORE_SIGNALS, STR_VEHICLE_VIEW_TRAIN_IGNORE_SIGNAL_TOOLTIP),
2295 SetDataTip(SPR_FORCE_VEHICLE_TURN, STR_VEHICLE_VIEW_ROAD_VEHICLE_REVERSE_TOOLTIP),
2310 WDP_AUTO,
"view_vehicle", 250, 116,
2313 _nested_vehicle_view_widgets,
lengthof(_nested_vehicle_view_widgets)
2321 WDP_AUTO,
"view_vehicle_train", 250, 134,
2324 _nested_vehicle_view_widgets,
lengthof(_nested_vehicle_view_widgets)
2344 static const int VV_INITIAL_VIEWPORT_WIDTH = 226;
2345 static const int VV_INITIAL_VIEWPORT_HEIGHT = 84;
2346 static const int VV_INITIAL_VIEWPORT_HEIGHT_TRAIN = 102;
2350 VCT_CMD_START_STOP = 0,
2352 VCT_CMD_TURN_AROUND,
2386 if (result.
Failed())
return;
2430 SEL_DC_BASEPLANE = SEL_DC_GOTO_DEPOT,
2431 SEL_RT_BASEPLANE = SEL_RT_REFIT,
2441 case SEL_DC_GOTO_DEPOT:
2447 case SEL_RT_TURN_AROUND:
2463 static const SpriteID vehicle_view_goto_depot_sprites[] = {
2464 SPR_SEND_TRAIN_TODEPOT,
2465 SPR_SEND_ROADVEH_TODEPOT,
2466 SPR_SEND_SHIP_TODEPOT,
2467 SPR_SEND_AIRCRAFT_TODEPOT,
2470 this->GetWidget<NWidgetCore>(
WID_VV_GOTO_DEPOT)->widget_data = vehicle_view_goto_depot_sprites[v->
type];
2473 static const SpriteID vehicle_view_clone_sprites[] = {
2479 this->GetWidget<NWidgetCore>(
WID_VV_CLONE)->widget_data = vehicle_view_clone_sprites[v->
type];
2483 this->GetWidget<NWidgetCore>(
WID_VV_TURN_AROUND)->tool_tip = STR_VEHICLE_VIEW_TRAIN_REVERSE_TOOLTIP;
2491 this->SelectPlane(SEL_RT_REFIT);
2494 default: NOT_REACHED();
2500 this->GetWidget<NWidgetCore>(
WID_VV_START_STOP)->tool_tip = STR_VEHICLE_VIEW_TRAIN_STATE_START_STOP_TOOLTIP + v->
type;
2502 this->GetWidget<NWidgetCore>(
WID_VV_REFIT)->tool_tip = STR_VEHICLE_VIEW_TRAIN_REFIT_TOOLTIP + v->
type;
2504 this->GetWidget<NWidgetCore>(
WID_VV_SHOW_ORDERS)->tool_tip = STR_VEHICLE_VIEW_TRAIN_ORDERS_TOOLTIP + v->
type;
2506 this->GetWidget<NWidgetCore>(
WID_VV_CLONE)->tool_tip = STR_VEHICLE_VIEW_CLONE_TRAIN_INFO + v->
type;
2533 size->width = VV_INITIAL_VIEWPORT_WIDTH;
2534 size->height = (v->
type ==
VEH_TRAIN) ? VV_INITIAL_VIEWPORT_HEIGHT_TRAIN : VV_INITIAL_VIEWPORT_HEIGHT;
2573 str = STR_VEHICLE_STATUS_CRASHED;
2575 str = STR_VEHICLE_STATUS_BROKEN_DOWN;
2580 str = STR_VEHICLE_STATUS_TRAIN_NO_POWER;
2582 str = STR_VEHICLE_STATUS_STOPPED;
2586 str = STR_VEHICLE_STATUS_TRAIN_STOPPING_VEL;
2589 str = STR_VEHICLE_STATUS_STOPPED;
2592 str = STR_VEHICLE_STATUS_TRAIN_STUCK;
2594 str = STR_VEHICLE_STATUS_AIRCRAFT_TOO_FAR;
2597 case OT_GOTO_STATION: {
2600 str = STR_VEHICLE_STATUS_HEADING_FOR_STATION_VEL;
2604 case OT_GOTO_DEPOT: {
2617 str = STR_VEHICLE_STATUS_HEADING_FOR_DEPOT_VEL;
2619 str = STR_VEHICLE_STATUS_HEADING_FOR_DEPOT_SERVICE_VEL;
2625 str = STR_VEHICLE_STATUS_LOADING_UNLOADING;
2628 case OT_GOTO_WAYPOINT: {
2631 str = STR_VEHICLE_STATUS_HEADING_FOR_WAYPOINT_VEL;
2636 case OT_LEAVESTATION:
2638 str = STR_VEHICLE_STATUS_LEAVING;
2644 str = STR_VEHICLE_STATUS_NO_ORDERS_VEL;
2658 int image_left = (rtl ? text_right + 1 : r.left) +
WD_IMGBTN_LEFT;
2659 int image = ((v->
vehstatus &
VS_STOPPED) != 0) ? SPR_FLAG_VEH_STOPPED : SPR_FLAG_VEH_RUNNING;
2701 ShowOrdersWindow(v);
2744 PlaneSelections plane = veh_stopped ? SEL_DC_CLONE : SEL_DC_GOTO_DEPOT;
2746 if (nwi->
shown_plane + SEL_DC_BASEPLANE != plane) {
2747 this->SelectPlane(plane);
2752 PlaneSelections plane = veh_stopped ? SEL_RT_REFIT : SEL_RT_TURN_AROUND;
2754 if (nwi->
shown_plane + SEL_RT_BASEPLANE != plane) {
2755 this->SelectPlane(plane);
2790 AllocateWindowDescFront<VehicleViewWindow>((v->
type ==
VEH_TRAIN) ? &_train_view_desc : &_vehicle_view_desc, v->
index);
2809 void StopGlobalFollowVehicle(
const Vehicle *v)
2828 if (result.
Failed())
return;
2866 int vehicle_width = 0;
2867 for (
const Vehicle *u = v; u != NULL; u = u->
Next()) {
2870 return vehicle_width;
2886 int total_width = 0;
2888 if (total_width >= 2 * (
int)VEHICLEINFO_FULL_VEHICLE_WIDTH)
break;
2896 for (uint i = 0; i < seq.count; ++i) {
2908 int offs = ((int)VEHICLEINFO_FULL_VEHICLE_WIDTH - total_width) / 2;
2909 if (rtl) offs = -offs;
static const uint32 _vehicle_command_translation_table[][4]
Command codes for the shared buttons indexed by VehicleCommandTranslation and vehicle type...
Functions related to OTTD's strings.
void DrawTrainDetails(const Train *v, int left, int right, int y, int vscroll_pos, uint16 vscroll_cap, TrainDetailsWindowTabs det_tab)
Draw the details for the given vehicle at the given position.
void ShowDropDownMenu(Window *w, const StringID *strings, int selected, int button, uint32 disabled_mask, uint32 hidden_mask, uint width)
Show a dropdown menu window near a widget of the parent window.
VehicleSettings vehicle
options for vehicles
virtual void OnTick()
Called once per (game) tick.
Functions/types related to NewGRF debugging.
CargoID cargo
Cargo to refit to.
uint32 PaletteID
The number of the palette.
Default zoom level for the aircraft view.
WindowNumber window_number
The WindowNumber of the window that is responsible for the selection mode.
Vehicle is stopped by the player.
void RebuildDone()
Notify the sortlist that the rebuild is done.
GameSettings _settings_game
Game settings of a running game or the scenario editor.
DropDownList * BuildActionDropdownList(bool show_autoreplace, bool show_group)
Display the Action dropdown window.
Definition of stuff that is very close to a company, like the company struct itself.
static Titem * GetIfValid(size_t index)
Returns Titem with given index.
Money value
Value of the vehicle.
virtual void OnInvalidateData(int data=0, bool gui_scope=true)
Some data on this window has become invalid.
Default settings for vehicles.
static const RailtypeInfo * GetRailTypeInfo(RailType railtype)
Returns a pointer to the Railtype information for a given railtype.
static const int DAYS_IN_YEAR
days per year
void ChangeVehicleViewWindow(VehicleID from_index, VehicleID to_index)
Report a change in vehicle IDs (due to autoreplace) to affected vehicle windows.
virtual void OnQueryTextFinished(char *str)
The query window opened from this window has closed.
static const uint CALLBACK_FAILED
Different values for Callback result evaluations.
CompanyID company
The company associated with this list.
PlaneSelections
Display planes available in the vehicle view window.
Horizontally center the text.
The information about a vehicle list.
ResizeInfo resize
Resize information.
virtual void OnPaint()
The window must be repainted.
Window(WindowDesc *desc)
Empty constructor, initialization has been moved to InitNested() called from the constructor of the d...
static const int VEHICLE_PROFIT_MIN_AGE
Only vehicles older than this have a meaningful profit.
static int CDECL VehicleNumberSorter(const Vehicle *const *a, const Vehicle *const *b)
Sort vehicles by their number.
void SetWidgetDisabledState(byte widget_index, bool disab_stat)
Sets the enabled/disabled status of a widget.
static int CDECL VehicleProfitThisYearSorter(const Vehicle *const *a, const Vehicle *const *b)
Sort vehicles by this year profit.
Offset at right of a matrix cell.
virtual void SetStringParameters(int widget) const
Initialize string parameters for a widget.
virtual void SetStringParameters(int widget) const
Initialize string parameters for a widget.
void SetWidgetLoweredState(byte widget_index, bool lowered_stat)
Sets the lowered/raised status of a widget.
Money GetDisplayProfitThisYear() const
Gets the profit vehicle had this year.
static int UnScaleGUI(int value)
Short-hand to apply GUI zoom level.
static WindowDesc _vehicle_view_desc(WDP_AUTO, "view_vehicle", 250, 116, WC_VEHICLE_VIEW, WC_NONE, 0, _nested_vehicle_view_widgets, lengthof(_nested_vehicle_view_widgets))
Vehicle view window descriptor for all vehicles but trains.
void DrawShipImage(const Vehicle *v, int left, int right, int y, VehicleID selection, EngineImageType image_type)
Draws an image of a ship.
Window * parent
Parent window.
High level window description.
Functions related to the autoreplace GUIs.
Vehicle * GetFirstEnginePart()
Get the first part of an articulated engine.
uint16 GetServiceIntervalClamped(uint interval, bool ispercent)
Clamp the service interval to the correct min/max.
int sprite_right
Right position of the vehicle sprite.
WindowFlags flags
Window flags.
int left
x position of left edge of the window
StringID GetAircraftTypeText() const
Get the name of the aircraft type for display purposes.
void DrawAircraftDetails(const Aircraft *v, int left, int right, int y)
Draw the details for the given vehicle at the given position.
bool VehicleClicked(const Vehicle *v)
Dispatch a "vehicle selected" event if any window waits for it.
void ErasePreservingOrder(uint pos, uint count=1)
Remove items from the vector while preserving the order of other items.
void DrawWidgets() const
Paint all widgets of a window.
static Titem * Get(size_t index)
Returns Titem with given index.
bool CanCarryCargo() const
Determines whether an engine can carry something.
virtual void SetStringParameters(int widget) const
Initialize string parameters for a widget.
void DrawVehicleImage(const Vehicle *v, int left, int right, int y, VehicleID selection, EngineImageType image_type, int skip)
Draws an image of a vehicle chain.
static Point RemapCoords(int x, int y, int z)
Map 3D world or tile coordinate to equivalent 2D coordinate as used in the viewports and smallmap...
Vehicle composition was changed.
Base for the train class.
Point sprite_pos[16]
relative position of individual sprites
virtual void DrawWidget(const Rect &r, int widget) const
Draw the contents of a nested widget.
void SetWidgetDirty(byte widget_index) const
Invalidate a widget, i.e.
virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize)
Update size and resize step of a widget in the window.
static const VehicleOrderID INVALID_VEH_ORDER_ID
Invalid vehicle order index (sentinel)
Offset at top to draw the frame rectangular area.
virtual void OnDropdownSelect(int widget, int index)
A dropdown option associated to this window has been selected.
Default zoom level for the ship view.
Functions related to debugging.
virtual void OnDragDrop(Point pt, int widget)
A dragged 'object' has been released.
Window * FindWindowById(WindowClass cls, WindowNumber number)
Find a window by its class and window number.
change the server interval of a vehicle
static void DrawVehicleProfitButton(const Vehicle *v, int x, int y)
draw the vehicle profit button in the vehicle list window.
byte _colour_gradient[COLOUR_END][8]
All 16 colour gradients 8 colours per gradient from darkest (0) to lightest (7)
uint16 cur_speed
current speed
query cost only, don't build.
void CDECL SetWidgetsDisabledState(bool disab_stat, int widgets,...)
Sets the enabled/disabled status of a list of widgets.
uint sprite_count
number of sprites to draw
void ShowQueryString(StringID str, StringID caption, uint maxsize, Window *parent, CharSetFilter afilter, QueryStringFlags flags)
Show a query popup window with a textbox in it.
static int ScaleGUITrad(int value)
Scale traditional pixel dimensions to GUI zoom level.
void ShowDropDownList(Window *w, const DropDownList *list, int selected, int button, uint width, bool auto_width, bool instant_close)
Show a drop down list.
Tab with cargo capacity of the vehicles.
bool IsStoppedInDepot() const
Check whether the vehicle is in the depot and stopped.
uint16 _returned_refit_capacity
Stores the capacity after a refit operation.
#define FOR_ALL_SORTED_CARGOSPECS(var)
Loop header for iterating over cargoes, sorted by name.
Specification of a cargo type.
GUIVehicleList vehicles
The list of vehicles.
OrderList * list
Pointer to the order list for this vehicle.
static WindowDesc _train_vehicle_details_desc(WDP_AUTO, "view_vehicle_details_train", 405, 178, WC_VEHICLE_DETAILS, WC_VEHICLE_VIEW, 0, _nested_train_vehicle_details_widgets, lengthof(_nested_train_vehicle_details_widgets))
Vehicle details window descriptor.
Default zoom level for the road vehicle view.
Functions related to vehicles.
Aircraft, helicopters, rotors and their shadows belong to this class.
static int CDECL VehicleReliabilitySorter(const Vehicle *const *a, const Vehicle *const *b)
Sort vehicles by their reliability.
virtual void OnClick(Point pt, int widget, int click_count)
A click with the left mouse button has been made on the window.
static bool IsExpected(const BaseStation *st)
Helper for checking whether the given station is of this type.
void Clear()
Remove all items from the list.
Scrollbar * vscroll
The main scrollbar.
virtual void ShowNewGRFInspectWindow() const
Show the NewGRF inspection window.
const T * Begin() const
Get the pointer to the first item (const)
Tindex index
Index of this pool item.
virtual void GetImage(Direction direction, EngineImageType image_type, VehicleSpriteSeq *result) const
Gets the sprite to show for the given direction.
static const int DAY_TICKS
1 day is 74 ticks; _date_fract used to be uint16 and incremented by 885.
Offset at top of a matrix cell.
PaletteID GetVehiclePalette(const Vehicle *v)
Get the colour map for a vehicle.
bool NeedResort()
Check if a resort is needed next loop If used the resort timer will decrease every call till 0...
bool GenerateVehicleSortList(VehicleList *list, const VehicleListIdentifier &vli)
Generate a list of vehicles based on window type.
#define lastof(x)
Get the last element of an fixed size array.
void ReInit(int rx=0, int ry=0)
Re-initialize a window, and optionally change its size.
StringID GetGRFStringID(uint32 grfid, StringID stringid)
Returns the index for this stringid associated with its grfID.
static int CDECL VehicleTimeToLiveSorter(const Vehicle *const *a, const Vehicle *const *b)
Sort vehicles by the time they can still live.
void RefreshScrollbar()
Refresh scrollbar after selection changed.
Money GetCost() const
The costs as made up to this moment.
Stuff related to the text buffer GUI.
WindowClass
Window classes.
byte GetDigitWidth(FontSize size)
Return the maximum width of single digit.
void DisableWidget(byte widget_index)
Sets a widget to disabled.
virtual void DrawWidget(const Rect &r, int widget) const
Draw the contents of a nested widget.
Common return value for all commands.
uint32 cached_power
Total power of the consist (valid only for the first engine).
virtual void OnClick(Point pt, int widget, int click_count)
A click with the left mouse button has been made on the window.
GrfSpecFeature GetGrfSpecFeature(TileIndex tile)
Get the GrfSpecFeature associated with the tile.
Determine the cargo "suffixes" for each refit possibility of a cargo.
static const VehicleID INVALID_VEHICLE
Constant representing a non-existing vehicle.
static T max(const T a, const T b)
Returns the maximum of two values.
uint8 advanced_vehicle_list
use the "advanced" vehicle list
EngineImageType
Visualisation contexts of vehicles and engines.
WindowClass cls
Class of the window,.
Cached, frequently calculated values.
TileIndex GetLocation(const Vehicle *v, bool airport=false) const
Returns a tile somewhat representing the order destination (not suitable for pathfinding).
Option to refit a vehicle chain.
static Train * From(Vehicle *v)
Converts a Vehicle to SpecializedVehicle with type checking.
Display 'goto depot' button in WID_VV_SELECT_DEPOT_CLONE stacked widget.
const T * End() const
Get the pointer behind the last valid item (const)
void CreateNestedTree(bool fill_nested=true)
Perform the first part of the initialization of a nested widget tree.
const Engine * GetEngine() const
Retrieves the engine of the vehicle.
void SetListing(Listing l)
Import sort conditions.
Window * GetCallbackWnd()
Get the window that started the current highlighting.
StringID name
Name of this type of cargo.
Display 'clone vehicle' button in WID_VV_SELECT_DEPOT_CLONE stacked widget.
int HideDropDownMenu(Window *pw)
Delete the drop-down menu from window pw.
bool NeedRebuild() const
Check if a rebuild is needed.
HighLightStyle place_mode
Method which is used to place the selection.
OrderDepotActionFlags GetDepotActionType() const
What are we going to do when in the depot.
static const ZoomLevel _vehicle_view_zoom_levels[]
Zoom levels for vehicle views indexed by vehicle type.
virtual bool OnVehicleSelect(const struct Vehicle *v)
The user clicked on a vehicle while HT_VEHICLE has been set.
DepotCommand
Flags to add to p1 for goto depot commands.
virtual void OnPaint()
Repaint vehicle details window.
uint16 servint_ships
service interval for ships
T * Append(uint to_add=1)
Append an item and return it.
Order * next
Pointer to next order. If NULL, end of list.
Vehicle * FirstShared() const
Get the first vehicle of this vehicle chain.
CompanyByte _local_company
Company controlled by the human player at this client. Can also be COMPANY_SPECTATOR.
virtual void OnResize()
Called after the window got resized.
Functions related to (drawing on) viewports.
void ForceRebuild()
Force that a rebuild is needed.
StringID string
GRF-local String to display for the cargo.
void DrawAircraftImage(const Vehicle *v, int left, int right, int y, VehicleID selection, EngineImageType image_type)
Draws an image of an aircraft.
bool IsEngineRefittable(EngineID engine)
Check if an engine is refittable.
void Resize(uint num_items)
Set the size of the vector, effectively truncating items from the end or appending uninitialised ones...
Data structure for an opened window.
byte breakdown_ctr
Counter for managing breakdown events.
bool _ctrl_pressed
Is Ctrl pressed?
void FinishInitNested(WindowNumber window_number=0)
Perform the second part of the initialization of a nested widget tree.
virtual void SetStringParameters(int widget) const
Initialize string parameters for a widget.
Autoreplace replaced the vehicle.
Vehicle drawn in vehicle details, refit window, ...
dragging items in the depot windows
uint16 cargo_cap
total capacity
Bottom offset of image in the button.
Header of Action 04 "universal holder" structure and functions.
Main window; Window numbers:
enable the 'Default' button ("\0" is returned)
Vehicle orders; Window numbers:
proceed a train to pass a red signal
virtual void OnClick(Point pt, int widget, int click_count)
A click with the left mouse button has been made on the window.
virtual int GetDisplayMaxSpeed() const
Gets the maximum speed in km-ish/h that can be sent into SetDParam for string processing.
Money GetDisplayRunningCost() const
Gets the running cost of a vehicle that can be sent into SetDParam for string processing.
Map related accessors for depots.
static int CDECL VehicleCargoSorter(const Vehicle *const *a, const Vehicle *const *b)
Sort vehicles by their cargo.
void SelectPlane(PlaneSelections plane)
Display a plane in the window.
Functions related to low-level strings.
virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize)
Update size and resize step of a widget in the window.
byte GetBestFittingSubType(Vehicle *v_from, Vehicle *v_for, CargoID dest_cargo_type)
Get the best fitting subtype when 'cloning'/'replacing' v_from with v_for.
virtual void OnMouseDrag(Point pt, int widget)
An 'object' is being dragged at the provided position, highlight the target if possible.
uint GetRoadVehDetailsHeight(const Vehicle *v)
Gets the desired height for the road vehicle details panel.
virtual bool IsPrimaryVehicle() const
Whether this is the primary vehicle in the chain.
Window manager class for viewing a vehicle.
Scrollbar * hscroll
Only used for long vehicles.
static const uint MAX_LENGTH_VEHICLE_NAME_CHARS
The maximum length of a vehicle name in characters including '\0'.
Offset at bottom of a matrix cell.
virtual void OnInvalidateData(int data=0, bool gui_scope=true)
Some data on this window has become invalid.
UnitID unitnumber
unit number, for display purposes only
#define FONT_HEIGHT_SMALL
Height of characters in the small (FS_SMALL) font.
CommandCost DoCommand(const CommandContainer *container, DoCommandFlag flags)
Shorthand for calling the long DoCommand with a container.
void DrawVehicleListItems(VehicleID selected_vehicle, int line_height, const Rect &r) const
Draw all the vehicle list items.
byte cargo_subtype
Used for livery refits (NewGRF variations)
uint Length() const
Get the number of items in the list.
bool operator!=(const MultiMapIterator< Tmap_iter1, Tlist_iter1, Tkey, Tvalue1, Tcompare > &iter1, const MultiMapIterator< Tmap_iter2, Tlist_iter2, Tkey, Tvalue2, Tcompare > &iter2)
Inverse of operator==().
static int CDECL VehicleMaxSpeedSorter(const Vehicle *const *a, const Vehicle *const *b)
Sort vehicles by their max speed.
This window is used for construction; close it whenever changing company.
bool IsWidgetLowered(byte widget_index) const
Gets the lowered state of a widget.
void CcCloneVehicle(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2)
This is the Callback method after the cloning attempt of a vehicle.
Listing GetListing() const
Export current sort conditions.
bool Contains(const T &item) const
Tests whether a item is present in the vector.
static bool IsVehicleServiceIntervalEnabled(const VehicleType vehicle_type, CompanyID company_id)
Checks whether service interval is enabled for the vehicle.
int GetSingleVehicleWidth(const Vehicle *v, EngineImageType image_type)
Get the width of a vehicle (part) in pixels.
virtual void DrawWidget(const Rect &r, int widget) const
Draw the contents of a nested widget.
Functions related to engines.
GroundVehicleCache * GetGroundVehicleCache()
Access the ground vehicle cache of the vehicle.
VehicleType
Available vehicle types.
void DrawRoadVehDetails(const Vehicle *v, int left, int right, int y)
Draw the details for the given vehicle at the given position.
uint32 index
A vehicle list type specific index.
virtual void OnDropdownSelect(int widget, int index)
A dropdown option associated to this window has been selected.
uint32 VehicleID
The type all our vehicle IDs have.
void ShowVehicleRefitWindow(const Vehicle *v, VehicleOrderID order, Window *parent, bool auto_refit)
Show the refit window for a vehicle.
bool IsType(OrderType type) const
Check whether this order is of the given type.
static void ChangeVehicleWindow(WindowClass window_class, VehicleID from_index, VehicleID to_index)
Assign a vehicle window a new vehicle.
#define FONT_HEIGHT_NORMAL
Height of characters in the normal (FS_NORMAL) font.
Simple vector template class, with automatic delete.
T * Next() const
Get next vehicle in the chain.
byte callback_mask
Bitmask of vehicle callbacks that have to be called.
ClientSettings _settings_client
The current settings for this game.
Definition of base types and functions in a cross-platform compatible way.
Show suffix after cargo name.
Tells that it's a mass send to depot command (type in VLW flag)
the length of the string is counted in characters
void DrawTrainImage(const Train *v, int left, int right, int y, VehicleID selection, EngineImageType image_type, int skip, VehicleID drag_dest)
Draws an image of a whole train.
virtual void OnInvalidateData(int data=0, bool gui_scope=true)
Some data on this window has become invalid.
void ShowCompanyGroup(CompanyID company, VehicleType vehicle_type)
Show the group window for the given company and vehicle type.
bool IsArticulatedPart() const
Check if the vehicle is an articulated part of an engine.
A number of safeguards to prevent using unsafe methods.
TextColour
Colour of the strings, see _string_colourmap in table/string_colours.h or docs/ottd-colourtext-palett...
Vehicle refit; Window numbers:
SmallVector< RefitOption, 32 > SubtypeList
List of refit subtypes associated to a cargo.
void StartStopVehicle(const Vehicle *v, bool texteffect)
Executes CMD_START_STOP_VEHICLE for given vehicle.
bool operator==(const MultiMapIterator< Tmap_iter1, Tlist_iter1, Tkey, Tvalue1, Tcompare > &iter1, const MultiMapIterator< Tmap_iter2, Tlist_iter2, Tkey, Tvalue2, Tcompare > &iter2)
Compare two MultiMap iterators.
CargoID cargo_type
type of cargo this vehicle is carrying
void DrawSortButtonState(int widget, SortButtonState state) const
Draw a sort button's up or down arrow symbol.
uint step_height
Step-size of height resize changes.
const Scrollbar * GetScrollbar(uint widnum) const
Return the Scrollbar to a widget index.
uint16 GetRange() const
Get the range of this aircraft.
static int CDECL VehicleTimetableDelaySorter(const Vehicle *const *a, const Vehicle *const *b)
Sort vehicles by the timetable delay.
Vehicle view; Window numbers:
Offset at left of a matrix cell.
VehicleOrderID order
If not INVALID_VEH_ORDER_ID, selection is part of a refit order (rather than execute directly)...
byte subtype
Subcargo to use.
byte misc_flags
Miscellaneous flags.
Order * GetFirstOrder() const
Get the first order of the order chain.
static VehicleListIdentifier UnPack(uint32 data)
Decode a packed vehicle list identifier into a new one.
TileIndex tile
Current tile index.
TrainDetailsWindowTabs tab
For train vehicles: which tab is displayed.
static int CDECL VehicleNameSorter(const Vehicle *const *a, const Vehicle *const *b)
Sort vehicles by their name.
void DrawShipDetails(const Vehicle *v, int left, int right, int y)
Draw the details for the given vehicle at the given position.
The tile has no ownership.
bool HasArticulatedPart() const
Check if an engine has an articulated part.
Vehicle timetable; Window numbers:
Offset at bottom to draw the frame rectangular area.
int DrawString(int left, int right, int top, const char *str, TextColour colour, StringAlignment align, bool underline, FontSize fontsize)
Draw string, possibly truncated to make it fit in its allocated space.
void ShowVehicleViewWindow(const Vehicle *v)
Shows the vehicle view window of the given vehicle.
int GetVehicleWidth(const Vehicle *v, EngineImageType image_type)
Get the width of a vehicle (including all parts of the consist) in pixels.
Service the vehicle and then halt it.
void DrawRoadVehImage(const Vehicle *v, int left, int right, int y, VehicleID selection, EngineImageType image_type, int skip)
Draws an image of a road vehicle chain.
Sprite sequence for a vehicle part.
bool DoCommandP(const CommandContainer *container, bool my_cmd)
Shortcut for the long DoCommandP when having a container with the data.
#define lengthof(x)
Return the length of an fixed size array.
PauseModeByte _pause_mode
The current pause mode.
VehicleID follow_vehicle
VehicleID to follow if following a vehicle, INVALID_VEHICLE otherwise.
static T min(const T a, const T b)
Returns the minimum of two values.
static const NWidgetPart _nested_train_vehicle_details_widgets[]
Train details widgets.
Default zoom level for the train view.
Right offset of the image in the button.
byte breakdowns_since_last_service
Counter for the amount of breakdowns.
uint16 reliability
Reliability.
void SetSortType(uint8 n_type)
Set the sorttype of the list.
bool Sort(SortFunction *compare)
Sort the list.
static int CDECL VehicleModelSorter(const Vehicle *const *a, const Vehicle *const *b)
Sort vehicles by model.
static int SortButtonWidth()
Get width of up/down arrow of sort button state.
Functions to cache sprites in memory.
uint32 StringID
Numeric value that represents a string, independent of the selected language.
int GetDisplayImageWidth(Point *offset=NULL) const
Get the width of a road vehicle image in the GUI.
Vehicle * First() const
Get the first vehicle of this vehicle chain.
Class for managing the vehicle details window.
bool Failed() const
Did this command fail?
Tab with cargo carried by the vehicles.
int GetDisplayImageWidth(Point *offset=NULL) const
Get the width of a train vehicle image in the GUI.
virtual void OnInvalidateData(int data=0, bool gui_scope=true)
Some data on this window has become invalid.
bool auto_refit
Select cargo for auto-refitting.
static DepotID GetDepotIndex(TileIndex t)
Get the index of which depot is attached to the tile.
Draw border only, no background.
virtual void OnResize()
Called after the window got resized.
virtual void OnTick()
Called once per (game) tick.
int vehicle_width
Width of the vehicle being drawn.
static const SpriteID SPR_CLONE_TRAIN
Clone vehicles stuff.
static T Clamp(const T a, const T min, const T max)
Clamp a value between an interval.
Functions/classes shared between the different vehicle list GUIs.
virtual void OnResize()
Called after the window got resized.
static const NWidgetPart _nested_vehicle_view_widgets[]
Vehicle view widgets.
void SetDirty() const
Mark entire window as dirty (in need of re-paint)
int sprite_left
Left position of the vehicle sprite.
#define DEBUG(name, level,...)
Output a line of debugging information.
'Train' is either a loco or a wagon.
VehicleDetailsWindow(WindowDesc *desc, WindowNumber window_number)
Initialize a newly created vehicle details window.
Dimension GetStringBoundingBox(const char *str, FontSize start_fontsize)
Return the string dimension in pixels.
virtual void DrawWidget(const Rect &r, int widget) const
Draw the contents of a nested widget.
Maximal number of cargo types in a game.
void ForceResort()
Force a resort next Sort call Reset the resort timer if used too.
Dimension maxdim(const Dimension &d1, const Dimension &d2)
Compute bounding box of both dimensions.
No window, redirects to WC_MAIN_WINDOW.
void DeleteWindowById(WindowClass cls, WindowNumber number, bool force)
Delete a window by its class and window number (if it is open).
PalSpriteID sprite_seq[16]
current image of cursor
static int CDECL VehicleProfitLastYearSorter(const Vehicle *const *a, const Vehicle *const *b)
Sort vehicles by last year profit.
char * name
Name of vehicle.
ZoomLevel
All zoom levels we know.
static const GroupID DEFAULT_GROUP
Ungrouped vehicles are in this group.
The vehicle will leave the depot right after arrival (serivce only)
static WindowDesc _nontrain_vehicle_details_desc(WDP_AUTO, "view_vehicle_details", 405, 113, WC_VEHICLE_DETAILS, WC_VEHICLE_VIEW, 0, _nested_nontrain_vehicle_details_widgets, lengthof(_nested_nontrain_vehicle_details_widgets))
Vehicle details window descriptor for other vehicles than a train.
static int32 ClampToI32(const int64 a)
Reduce a signed 64-bit int to a signed 32-bit one.
Functions related to companies.
uint GetUnitNumberDigits(VehicleList &vehicles)
Get the number of digits the biggest unit number of a set of vehicles has.
Window for the (old) vehicle listing.
virtual void OnPaint()
The window must be repainted.
static StationID GetStationIndex(TileIndex t)
Get StationID from a tile.
Vehicle drawn in vehicle list, group list, ...
bool IsNewGRFInspectable(GrfSpecFeature feature, uint index)
Can we inspect the data given a certain feature and index.
void SetObjectToPlaceWnd(CursorID icon, PaletteID pal, HighLightStyle mode, Window *w)
Change the cursor and mouse click/drag handling to a mode for performing special operations like tile...
bool ScrollMainWindowTo(int x, int y, int z, bool instant)
Scrolls the main window to given coordinates.
TrainDetailsWindowTabs
The tabs in the train details window.
Functions related to articulated vehicles.
void ErrorUnknownCallbackResult(uint32 grfid, uint16 cbid, uint16 cb_res)
Record that a NewGRF returned an unknown/invalid callback result.
Class for storing amounts of cargo.
Automatic refitting is allowed.
Both numeric and alphabetic and spaces and stuff.
StringID GetCapacityString(RefitOption *option) const
Gets the StringID to use for displaying capacity.
Display 'turn around' button in WID_VV_SELECT_REFIT_TURN stacked widget.
bool IsGroundVehicle() const
Check if the vehicle is a ground vehicle.
Train can't get a path reservation.
GUISettings gui
settings related to the GUI
void SetSelection(uint click_row)
Select a row.
void SetMouseCursorVehicle(const Vehicle *v, EngineImageType image_type)
Set the mouse cursor to look like a vehicle.
DestinationID GetDestination() const
Gets the destination of this order.
int strnatcmp(const char *s1, const char *s2, bool ignore_garbage_at_front)
Compares two strings using case insensitive natural sort.
VehicleCommandTranslation
Command indices for the _vehicle_command_translation_table.
uint32 SpriteID
The number of a sprite, without mapping bits and colourtables.
virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize)
Update size and resize step of a widget in the window.
void UpdateCursorSize()
Update cursor dimension.
uint16 EngineID
Unique identification number of an engine.
static CargoSpec * Get(size_t index)
Retrieve cargo details for the given cargo ID.
CompanyByte _current_company
Company currently doing an action.
uint32 TileIndex
The index/ID of a Tile.
static const PaletteID PALETTE_CRASH
Recolour sprite greying of crashed vehicles.
uint32 Pack() const
Pack a VehicleListIdentifier in a single uint32.
RefitOption * cargo
Refit option selected by sel.
uint16 servint_trains
service interval for trains
Vehicle * Next() const
Get the next vehicle of this vehicle.
static WindowDesc _train_view_desc(WDP_AUTO, "view_vehicle_train", 250, 134, WC_VEHICLE_VIEW, WC_NONE, 0, _nested_vehicle_view_widgets, lengthof(_nested_vehicle_view_widgets))
Vehicle view window descriptor for trains.
Date date_of_last_service
Last date the vehicle had a service at a depot.
TextDirection _current_text_dir
Text direction of the currently selected language.
void ToggleSortOrder()
Toggle the sort order Since that is the worst condition for the sort function reverse the list here...
virtual void ShowNewGRFInspectWindow() const
Show the NewGRF inspection window.
static bool HasAtMostOneBit(T value)
Test whether value has at most 1 bit set.
void GetVehicleSet(VehicleSet &set, Vehicle *v, uint8 num_vehicles)
Calculates the set of vehicles that will be affected by a given selection.
Send the vehicle to the nearest depot.
void SetDParamMaxValue(uint n, uint64 max_value, uint min_count, FontSize size)
Set DParam n to some number that is suitable for string size computations.
Tab with sum of total cargo transported.
Display 'refit' button in WID_VV_SELECT_REFIT_TURN stacked widget.
Next destination is too far away.
Top offset of image in the button.
VehicleListType type
The type of vehicle list.
void ShowReplaceGroupVehicleWindow(GroupID id_g, VehicleType vehicletype)
Show the autoreplace configuration window for a particular group.
OwnerByte owner
Which company owns the vehicle?
int CDECL SortFunction(const T *, const T *)
Signature of sort function.
Vehicle * GetNextArticulatedPart() const
Get the next part of an articulated engine.
void CcBuildPrimaryVehicle(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2)
This is the Callback method after the construction attempt of a primary vehicle.
static uint GB(const T x, const uint8 s, const uint8 n)
Fetch n bits from x, started at bit s.
Trains list; Window numbers:
Functions related to zooming.
uint information_width
Width required for correctly displaying all cargoes in the information panel.
VehicleListType
Vehicle List type flags.
static void ShowVehicleDetailsWindow(const Vehicle *v)
Shows the vehicle details window of the given vehicle.
int GetTrainDetailsWndVScroll(VehicleID veh_id, TrainDetailsWindowTabs det_tab)
Determines the number of lines in the train details window.
static const Money VEHICLE_PROFIT_THRESHOLD
Threshold for a vehicle to be considered making good profit.
change the refit information of an order (for "goto depot" )
bool Include(const T &item)
Tests whether a item is present in the vector, and appends it to the end if not.
Functions related to the drop down widget.
uint16 _returned_mail_refit_capacity
Stores the mail capacity after a refit operation (Aircraft only).
uint16 servint_aircraft
service interval for aircraft
uint32 _cargo_mask
Bitmask of cargo types available.
static uint GetVehicleHeight(VehicleType type)
Get the height of a single vehicle in the GUIs.
static uint ToPercent16(uint i)
Converts a "fract" value 0..65535 to "percent" value 0..100.
static const NWidgetPart _nested_nontrain_vehicle_details_widgets[]
Vehicle details widgets (other than train).
bool ScrollMainWindowToTile(TileIndex tile, bool instant)
Scrolls the viewport of the main window to a given location.
VehicleListIdentifier vli
Identifier of the vehicle list we want to currently show.
Vehicle details; Window numbers:
static uint CountBits(T value)
Counts the number of set bits in a variable.
Bottom offset of the dropdown widget string.
Functions/definitions that have something to do with groups.
Functions related to commands.
Coordinates of a point in 2D.
int click_x
Position of the first click while dragging.
Dimension GetSpriteSize(SpriteID sprid, Point *offset, ZoomLevel zoom)
Get the size of a sprite.
CargoID Index() const
Determines index of this cargospec.
static bool IsValidID(size_t index)
Tests whether given index can be used to get valid (non-NULL) Titem.
uint32 GetGRFID() const
Retrieve the GRF ID of the NewGRF the vehicle is tied to.
uint8 train_acceleration_model
realistic acceleration for trains
void CcStartStopVehicle(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2)
This is the Callback method after attempting to start/stop a vehicle.
Make the text effect slowly go upwards.
Ignore next signal, after the signal ignore being stuck.
static WindowClass GetWindowClassForVehicleType(VehicleType vt)
Get WindowClass for vehicle list of given vehicle type.
virtual void OnResize()
Called after the window got resized.
start/stop all vehicles (in a depot)
Window does not do autoscroll,.
static int CDECL VehicleValueSorter(const Vehicle *const *a, const Vehicle *const *b)
Sort vehicles by their value.
Order * GetOrder(int index) const
Returns order 'index' of a vehicle or NULL when it doesn't exists.
static const StringID INVALID_STRING_ID
Constant representing an invalid string (16bit in case it is used in savegames)
Owner owner
The owner of the content shown in this window. Company colour is acquired from this variable...
uint16 GetVehicleCallback(CallbackID callback, uint32 param1, uint32 param2, EngineID engine, const Vehicle *v)
Evaluate a newgrf callback for vehicles.
uint8 num_vehicles
Number of selected vehicles.
virtual bool IsNewGRFInspectable() const
Is the data related to this window NewGRF inspectable?
uint8 roadveh_acceleration_model
realistic acceleration for road vehicles
vehicle is accepted as target as well (bitmask)
Offset at right to draw the frame rectangular area.
EngineID engine_type
The type of engine used for this vehicle.
ZoomLevel zoom
The zoom level of the viewport.
void BuildRefitList()
Collects all (cargo, subcargo) refit options of a vehicle chain.
int width
width of the window (number of pixels to the right in x direction)
virtual void OnClick(Point pt, int widget, int click_count)
A click with the left mouse button has been made on the window.
uint GetVehicleListHeight(VehicleType type, uint divisor)
Get the height of a vehicle in the vehicle list GUIs.
static void DrawVehicleRefitWindow(const SubtypeList list[NUM_CARGO], const int sel[2], uint pos, uint rows, uint delta, const Rect &r)
Draw the list of available refit options for a consist and highlight the selected refit option (if an...
byte VehicleOrderID
The index of an order within its current vehicle (not pool related)
static bool HasBit(const T x, const uint8 y)
Checks if a bit in a value is set.
virtual void OnInit()
Notification that the nested widget tree gets initialized.
static const TileIndex INVALID_TILE
The very nice invalid tile marker.
const GRFFile * GetGRF() const
Retrieve the NewGRF the vehicle is tied to.
bool IsDescSortOrder() const
Check if the sort order is descending.
#define CMD_MSG(x)
Used to combine a StringID with the command.
static bool IsVehicleRefitable(const Vehicle *v)
Checks whether the vehicle may be refitted at the moment.
int32 WindowNumber
Number to differentiate different windows of the same class.
virtual int GetDisplaySpeed() const
Gets the speed in km-ish/h that can be sent into SetDParam for string processing. ...
WindowClass window_class
Window class.
uint16 servint_roadveh
service interval for road vehicles
OrderType GetType() const
Get the type of order of this order.
Specification of a rectangle with absolute coordinates of all edges.
WindowClass window_class
The WindowClass of the window that is responsible for the selection mode.
byte CargoID
Cargo slots to indicate a cargo type within a game.
byte unitnumber_digits
The number of digits of the highest unit number.
Text is written right-to-left by default.
WindowNumber window_number
Window number within the window class.
ButtonPlanes
Enumeration of planes of the button row at the bottom.
uint32 cached_max_te
Maximum tractive effort of consist (valid only for the first engine).
Functions related to tile highlights.
Owner
Enum for all companies/owners.
virtual bool IsChainInDepot() const
Check whether the whole vehicle chain is in the depot.
uint ShowRefitOptionsList(int left, int right, int y, EngineID engine)
Display list of cargo types of the engine, for the purchase information window.
StringID GetCargoSubtypeText(const Vehicle *v)
Get the cargo subtype text from NewGRF for the vehicle details window.
static const uint MAX_REFIT_CYCLE
Maximum number of refit cycles we try, to prevent infinite loops.
Find a place automatically.
Dimension GetActionDropdownSize(bool show_autoreplace, bool show_group)
Compute the size for the Action dropdown.
union Vehicle::@46 orders
The orders currently assigned to the vehicle.
SpriteID sprite
The 'real' sprite.
ViewportData * viewport
Pointer to viewport data, if present.
GUI functions that shouldn't be here.
Listing * sorting
Pointer to the vehicle type related sorting.
static const CursorID SPR_CURSOR_MOUSE
Cursor sprite numbers.
Base classes/functions for stations.
uint32 GetUnionOfArticulatedRefitMasks(EngineID engine, bool include_initial_cargo_type)
Ors the refit_masks of all articulated parts.
static void QSortT(T *base, uint num, int(CDECL *comparator)(const T *, const T *), bool desc=false)
Type safe qsort()
static int CDECL VehicleAgeSorter(const Vehicle *const *a, const Vehicle *const *b)
Sort vehicles by their age.
Left offset of the image in the button.
VehicleType vtype
The vehicle type associated with this list.
RefitOption * GetRefitOption()
Gets the RefitOption placed in the selected index.
static int CDECL VehicleLengthSorter(const Vehicle *const *a, const Vehicle *const *b)
Sort vehicles by their length.
VehicleOrderID cur_real_order_index
The index to the current real (non-implicit) order.
VehicleTypeByte type
Type of vehicle.
Dimensions (a width and height) of a rectangle in 2D.
Offset at left to draw the frame rectangular area.
static const Year MAX_YEAR
MAX_YEAR, nicely rounded value of the number of years that can be encoded in a single 32 bits date...
uint32 cached_weight
Total weight of the consist (valid only for the first engine).
void InvalidateNewGRFCache()
Invalidates cached NewGRF variables.
Money GetDisplayProfitLastYear() const
Gets the profit vehicle had last year.
void GetBounds(Rect *bounds) const
Determine shared bounds of all sprites.
uint vehicle_margin
Margin to use while selecting vehicles when the vehicle image is centered.
void DrawSprite(SpriteID img, PaletteID pal, int x, int y, const SubSprite *sub, ZoomLevel zoom)
Draw a sprite, not in a viewport.
turn a road vehicle around
Order current_order
The current order (+ status, like: loading)
VehicleID selected_vehicle
First vehicle in the current selection.
virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize)
Update size and resize step of a widget in the window.
void InvalidateData(int data=0, bool gui_scope=true)
Mark this window's data as invalid (in need of re-computing)
Top offset of the dropdown widget string.
GroupID group_id
Index of group Pool array.
static const int DAYS_IN_LEAP_YEAR
sometimes, you need one day more...
int height
Height of the window (number of pixels down in y direction)
AutoDeleteSmallVector< const DropDownListItem *, 4 > DropDownList
A drop down list is a collection of drop down list items.
int DrawStringMultiLine(int left, int right, int top, int bottom, const char *str, TextColour colour, StringAlignment align, bool underline, FontSize fontsize)
Draw string, possibly over multiple lines.
virtual void OnInvalidateData(int data=0, bool gui_scope=true)
Some data on this window has become invalid.
virtual void OnPaint()
The window must be repainted.
static void MemSetT(T *ptr, byte value, size_t num=1)
Type-safe version of memset().
VehicleOrderID GetNumManualOrders() const
Get the number of manually added orders this vehicle has.
Tab with name and value of the vehicles.
uint8 SortType() const
Get the sorttype of the list.
static void SetDParam(uint n, uint64 v)
Set a string parameter v at index n in the global string parameter array.
static void DrawVehicleDetails(const Vehicle *v, int left, int right, int y, int vscroll_pos, uint vscroll_cap, TrainDetailsWindowTabs det_tab)
Draw the details for the given vehicle at the position of the Details windows.
static const GroupID ALL_GROUP
All vehicles are in this group.
PaletteID pal
The palette (use PAL_NONE) if not needed)