Go to the documentation of this file.
50 Sorting _sorting[BaseVehicleListWindow::GB_END];
54 static BaseVehicleListWindow::VehicleIndividualSortFunction
VehicleAgeSorter;
72 template <BaseVehicleListWindow::VehicleIndiv
idualSortFunction func>
78 BaseVehicleListWindow::VehicleGroupSortFunction *
const BaseVehicleListWindow::vehicle_group_none_sorter_funcs[] = {
79 &VehicleIndividualToGroupSorterWrapper<VehicleNumberSorter>,
80 &VehicleIndividualToGroupSorterWrapper<VehicleNameSorter>,
81 &VehicleIndividualToGroupSorterWrapper<VehicleAgeSorter>,
82 &VehicleIndividualToGroupSorterWrapper<VehicleProfitThisYearSorter>,
83 &VehicleIndividualToGroupSorterWrapper<VehicleProfitLastYearSorter>,
84 &VehicleIndividualToGroupSorterWrapper<VehicleCargoSorter>,
85 &VehicleIndividualToGroupSorterWrapper<VehicleReliabilitySorter>,
86 &VehicleIndividualToGroupSorterWrapper<VehicleMaxSpeedSorter>,
87 &VehicleIndividualToGroupSorterWrapper<VehicleModelSorter>,
88 &VehicleIndividualToGroupSorterWrapper<VehicleValueSorter>,
89 &VehicleIndividualToGroupSorterWrapper<VehicleLengthSorter>,
90 &VehicleIndividualToGroupSorterWrapper<VehicleTimeToLiveSorter>,
91 &VehicleIndividualToGroupSorterWrapper<VehicleTimetableDelaySorter>,
94 const StringID BaseVehicleListWindow::vehicle_group_none_sorter_names[] = {
98 STR_SORT_BY_PROFIT_THIS_YEAR,
99 STR_SORT_BY_PROFIT_LAST_YEAR,
100 STR_SORT_BY_TOTAL_CAPACITY_PER_CARGOTYPE,
101 STR_SORT_BY_RELIABILITY,
102 STR_SORT_BY_MAX_SPEED,
106 STR_SORT_BY_LIFE_TIME,
107 STR_SORT_BY_TIMETABLE_DELAY,
111 BaseVehicleListWindow::VehicleGroupSortFunction *
const BaseVehicleListWindow::vehicle_group_shared_orders_sorter_funcs[] = {
119 const StringID BaseVehicleListWindow::vehicle_group_shared_orders_sorter_names[] = {
120 STR_SORT_BY_NUM_VEHICLES,
121 STR_SORT_BY_TOTAL_PROFIT_THIS_YEAR,
122 STR_SORT_BY_TOTAL_PROFIT_LAST_YEAR,
123 STR_SORT_BY_AVERAGE_PROFIT_THIS_YEAR,
124 STR_SORT_BY_AVERAGE_PROFIT_LAST_YEAR,
128 const StringID BaseVehicleListWindow::vehicle_group_by_names[] = {
130 STR_GROUP_BY_SHARED_ORDERS,
134 const StringID BaseVehicleListWindow::vehicle_depot_name[] = {
135 STR_VEHICLE_LIST_SEND_TRAIN_TO_DEPOT,
136 STR_VEHICLE_LIST_SEND_ROAD_VEHICLE_TO_DEPOT,
137 STR_VEHICLE_LIST_SEND_SHIP_TO_DEPOT,
138 STR_VEHICLE_LIST_SEND_AIRCRAFT_TO_HANGAR
144 this->grouping = _grouping[vli.type][vli.vtype];
145 this->UpdateSortingFromGrouping();
155 if (number >= 10000)
return 5;
156 if (number >= 1000)
return 4;
157 if (number >= 100)
return 3;
175 for (
const Vehicle *v : vehicles) {
176 unitnumber = std::max<uint>(unitnumber, v->unitnumber);
182 void BaseVehicleListWindow::BuildVehicleList()
186 Debug(misc, 3,
"Building vehicle list type {} for company {} given index {}", this->
vli.
type, this->vli.company, this->vli.index);
193 uint max_unitnumber = 0;
194 for (
auto it = this->
vehicles.begin(); it != this->vehicles.end(); ++it) {
195 this->
vehgroups.emplace_back(it, it + 1);
197 max_unitnumber = std::max<uint>(max_unitnumber, (*it)->unitnumber);
204 std::stable_sort(this->
vehicles.begin(), this->vehicles.end(), [](
const Vehicle *
const &u,
const Vehicle *
const &v) {
205 return u->FirstShared() < v->FirstShared();
208 uint max_num_vehicles = 0;
210 VehicleList::const_iterator begin = this->
vehicles.begin();
211 while (begin != this->
vehicles.end()) {
212 VehicleList::const_iterator end = std::find_if_not(begin, this->
vehicles.cend(), [first_shared = (*begin)->FirstShared()](
const Vehicle *
const &v) {
213 return v->FirstShared() == first_shared;
216 this->
vehgroups.emplace_back(begin, end);
218 max_num_vehicles = std::max<uint>(max_num_vehicles,
static_cast<uint
>(end - begin));
240 const Vehicle *v = (*vehgroup).GetSingleVehicle();
244 for (
const Vehicle *w = v; w !=
nullptr; w = w->
Next()) {
245 if (w->cargo_cap > 0) {
251 bool have_capacity =
false;
252 for (
const Vehicle *w = v; w !=
nullptr; w = w->
Next()) {
253 if (w->cargo_cap > 0) {
257 have_capacity =
true;
261 return have_capacity;
263 for (
const Vehicle *w = v; w !=
nullptr; w = w->
Next()) {
264 if (w->cargo_cap > 0 && w->cargo_type == cid) {
296 byte filter_items = 0;
380 if (show_autoreplace) list.emplace_back(
new DropDownListStringItem(STR_VEHICLE_LIST_REPLACE_VEHICLES, ADI_REPLACE,
false));
393 static const Vehicle *_last_vehicle[2] = {
nullptr,
nullptr };
395 void BaseVehicleListWindow::SortVehicleList()
400 _last_vehicle[0] = _last_vehicle[1] =
nullptr;
405 if (list->size() < 2)
return;
417 }
else if (display_profit_last_year < 0) {
418 spr = SPR_PROFIT_NEGATIVE;
420 spr = SPR_PROFIT_SOME;
422 spr = SPR_PROFIT_LOT;
445 static std::vector<StringID> subtypes;
453 byte ret_refit_cyc = 0;
454 bool success =
false;
455 if (subtypes.size() > 0) {
458 const Engine *e = v->GetEngine();
460 if (!
HasBit(e->info.refit_mask, dest_cargo_type) && v->cargo_type != dest_cargo_type)
continue;
462 CargoID old_cargo_type = v->cargo_type;
463 byte old_cargo_subtype = v->cargo_subtype;
466 v->cargo_type = dest_cargo_type;
470 v->cargo_subtype = refit_cyc;
473 v->First()->InvalidateNewGRFCache();
474 v->InvalidateNewGRFCache();
477 if (subtype == STR_EMPTY)
break;
479 if (std::find(subtypes.begin(), subtypes.end(), subtype) == subtypes.end())
continue;
482 ret_refit_cyc = refit_cyc;
488 v->cargo_type = old_cargo_type;
489 v->cargo_subtype = old_cargo_subtype;
492 v->First()->InvalidateNewGRFCache();
493 v->InvalidateNewGRFCache();
499 return ret_refit_cyc;
550 int iconleft = rtl ? ir.right - iconwidth : ir.left;
551 int iconcenter = rtl ? ir.right - iconwidth / 2 : ir.left + iconwidth / 2;
552 int iconinner = rtl ? ir.right - iconwidth : ir.left + iconwidth;
557 for (uint i = 0; current < pos + rows && i <
NUM_CARGO; i++) {
558 for (uint j = 0; current < pos + rows && j < list[i].size(); j++) {
562 if (sel[0] != (
int)i && refit.
subtype != 0xFF)
continue;
570 if (list[i].size() > 1) {
575 GfxDrawLine(iconcenter, ycenter, iconinner, ycenter, linecolour);
578 DrawSprite(sel[0] == (
int)i ? SPR_CIRCLE_UNFOLDED : SPR_CIRCLE_FOLDED, PAL_NONE, iconleft, tr.top + (
FONT_HEIGHT_NORMAL - iconheight) / 2);
582 TextColour colour = (sel[0] == (int)i && (uint)sel[1] == j) ? TC_WHITE : TC_BLACK;
586 DrawString(tr, STR_JUST_STRING_STRING, colour);
617 for (uint i = 0; i <
NUM_CARGO; i++) this->list[i].clear();
621 VehicleSet vehicles_to_refit;
625 if (v->
type ==
VEH_TRAIN && std::find(vehicles_to_refit.begin(), vehicles_to_refit.end(), v->
index) == vehicles_to_refit.end())
continue;
627 CargoTypes cmask = e->info.refit_mask;
636 int current_index = 0;
640 if (!
HasBit(cmask, cid)) {
645 bool first_vehicle = this->list[current_index].size() == 0;
648 this->list[current_index].push_back({cid, 0xFF, STR_EMPTY});
674 if (subtype == STR_EMPTY)
break;
680 include(this->list[current_index], option);
683 if (subtype == STR_EMPTY) {
687 for (uint i = 1; i < l.size(); i++) {
688 if (l[i].subtype >= refit_cyc) {
698 while (pos < l.size() && l[pos].subtype != refit_cyc) pos++;
699 if (pos < l.size() && l[pos].string != subtype) {
701 l.erase(l.begin() + pos);
729 for (uint j = 0; j < this->list[i].size(); j++) {
733 if (this->sel[0] != (
int)i && refit.
subtype != 0xFF)
continue;
735 if (this->sel[0] == (
int)i && (uint)this->sel[1] == j) scroll_row = row;
742 if (scroll_row < row) this->vscroll->
ScrollTowards(scroll_row);
754 for (uint j = 0; j < this->list[i].size(); j++) {
758 if (this->sel[0] != (
int)i && refit.
subtype != 0xFF)
continue;
760 if (row == click_row) {
780 if (this->sel[0] < 0)
return nullptr;
783 if ((uint)this->sel[1] >= l.size())
return nullptr;
785 return &l[this->sel[1]];
799 this->GetWidget<NWidgetCore>(
WID_VR_MATRIX)->tool_tip = STR_REFIT_TRAIN_LIST_TOOLTIP + v->
type;
802 nwi->
tool_tip = STR_REFIT_TRAIN_REFIT_TOOLTIP + v->
type;
814 if (this->cargo !=
nullptr) {
822 this->cargo =
nullptr;
823 for (uint i = 0; this->cargo ==
nullptr && i <
NUM_CARGO; i++) {
824 for (uint j = 0; j <
list[i].size(); j++) {
825 if (
list[i][j] == current_refit_option) {
828 this->cargo = &
list[i][j];
845 if (this->hscroll !=
nullptr) this->hscroll->
SetCount(this->vehicle_width);
849 int sprite_width = std::max(0, ((
int)vehicle_panel_display->
current_x - this->vehicle_width) / 2);
850 this->sprite_left = vehicle_panel_display->
pos_x;
851 this->sprite_right = vehicle_panel_display->
pos_x + vehicle_panel_display->
current_x - 1;
853 this->sprite_right -= sprite_width;
856 this->sprite_left += sprite_width;
868 size->height =
resize->height * 8;
876 size->width = this->information_width + padding.height;
902 Money money = cost.GetCost();
903 if (mail_capacity > 0) {
908 return STR_PURCHASE_INFO_AIRCRAFT_CAPACITY;
909 }
else if (money <= 0) {
911 return STR_REFIT_NEW_CAPACITY_INCOME_FROM_AIRCRAFT_REFIT;
914 return STR_REFIT_NEW_CAPACITY_COST_OF_AIRCRAFT_REFIT;
920 return STR_PURCHASE_INFO_CAPACITY;
921 }
else if (money <= 0) {
923 return STR_REFIT_NEW_CAPACITY_INCOME_FROM_REFIT;
926 return STR_REFIT_NEW_CAPACITY_COST_OF_REFIT;
944 VehicleSet vehicles_to_refit;
947 int left = INT32_MIN;
953 const int highlight_bottom = highlight_top +
height - 1;
957 const bool contained = std::find(vehicles_to_refit.begin(), vehicles_to_refit.end(), u->index) != vehicles_to_refit.end();
958 if (contained &&
left == INT32_MIN) {
964 if ((!contained || u->Next() ==
nullptr) &&
left != INT32_MIN) {
965 if (u->Next() ==
nullptr && contained) {
966 int current_width = u->GetDisplayImageWidth();
967 width += current_width;
980 Rect hr = {
left, highlight_top, right, highlight_bottom};
987 int current_width = u->GetDisplayImageWidth();
988 width += current_width;
1004 if (this->cargo !=
nullptr) {
1026 this->selected_vehicle = v->
index;
1027 this->num_vehicles = UINT8_MAX;
1032 if (!gui_scope)
break;
1041 for (uint j = 0; j < this->list[i].size(); j++) {
1045 max_width = std::max(dim.width, max_width);
1050 if (this->information_width < max_width) {
1051 this->information_width = max_width;
1058 if (!gui_scope)
break;
1065 int GetClickPosition(
int click_x)
1075 void SetSelectedVehicles(
int drag_x)
1077 drag_x = GetClickPosition(drag_x);
1079 int left_x = std::min(this->click_x, drag_x);
1080 int right_x = std::max(this->click_x, drag_x);
1081 this->num_vehicles = 0;
1090 bool start_counting =
false;
1091 for (; u !=
nullptr; u = u->
Next()) {
1093 left_x -= current_width;
1094 right_x -= current_width;
1096 if (left_x < 0 && !start_counting) {
1097 this->selected_vehicle = u->
index;
1098 start_counting =
true;
1101 this->num_vehicles++;
1104 this->num_vehicles++;
1107 if (right_x < 0)
break;
1112 if (this->num_vehicles != 0) {
1121 this->selected_vehicle = v->
index;
1122 this->num_vehicles = UINT8_MAX;
1133 this->click_x = GetClickPosition(pt.x - nwi->
pos_x);
1134 this->SetSelectedVehicles(pt.x - nwi->
pos_x);
1150 if (click_count == 1)
break;
1155 if (this->cargo !=
nullptr) {
1159 bool delete_window = this->selected_vehicle == v->
index && this->num_vehicles == UINT8_MAX;
1160 if (
Command<CMD_REFIT_VEHICLE>::Post(GetCmdRefitVehMsg(v), v->
tile, this->selected_vehicle, this->cargo->cargo, this->cargo->subtype,
false,
false, this->num_vehicles) && delete_window) this->
Close();
1175 this->SetSelectedVehicles(pt.x - nwi->
pos_x);
1188 this->SetSelectedVehicles(pt.x - nwi->
pos_x);
1203 static const NWidgetPart _nested_vehicle_refit_widgets[] = {
1219 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),
1230 WDP_AUTO,
"view_vehicle_refit", 240, 174,
1233 _nested_vehicle_refit_widgets,
lengthof(_nested_vehicle_refit_widgets)
1261 if (cmask == lmask) {
1263 SetDParam(0, STR_PURCHASE_INFO_ALL_TYPES);
1269 SetDParam(0, STR_PURCHASE_INFO_ALL_BUT);
1298 return a.NumVehicles() < b.NumVehicles();
1304 return a.GetDisplayProfitThisYear() < b.GetDisplayProfitThisYear();
1310 return a.GetDisplayProfitLastYear() < b.GetDisplayProfitLastYear();
1316 return a.GetDisplayProfitThisYear() *
static_cast<uint
>(b.NumVehicles()) < b.GetDisplayProfitThisYear() *
static_cast<uint
>(a.NumVehicles());
1322 return a.GetDisplayProfitLastYear() *
static_cast<uint
>(b.NumVehicles()) < b.GetDisplayProfitLastYear() *
static_cast<uint
>(a.NumVehicles());
1334 static char last_name[2][64];
1336 if (a != _last_vehicle[0]) {
1337 _last_vehicle[0] = a;
1339 GetString(last_name[0], STR_VEHICLE_NAME,
lastof(last_name[0]));
1342 if (b != _last_vehicle[1]) {
1343 _last_vehicle[1] = b;
1345 GetString(last_name[1], STR_VEHICLE_NAME,
lastof(last_name[1]));
1348 int r =
strnatcmp(last_name[0], last_name[1]);
1419 for (u = a; u !=
nullptr; u = u->
Next()) diff += u->
value;
1420 for (u = b; u !=
nullptr; u = u->
Next()) diff -= u->
value;
1447 void InitializeGUI()
1491 static const NWidgetPart _nested_vehicle_list[] = {
1527 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),
1535 SetDataTip(STR_BLACK_STRING, STR_VEHICLE_LIST_AVAILABLE_ENGINES_TOOLTIP),
1538 SetDataTip(STR_VEHICLE_LIST_MANAGE_LIST, STR_VEHICLE_LIST_MANAGE_LIST_TOOLTIP),
1540 SetDataTip(SPR_FLAG_VEH_STOPPED, STR_VEHICLE_LIST_MASS_STOP_LIST_TOOLTIP),
1542 SetDataTip(SPR_FLAG_VEH_RUNNING, STR_VEHICLE_LIST_MASS_START_LIST_TOOLTIP),
1554 if (order ==
nullptr)
return;
1557 int l_offset = rtl ? 0 : order_arrow_width;
1558 int r_offset = rtl ? order_arrow_width : 0;
1565 if (order->
IsType(OT_GOTO_STATION)) {
1567 DrawString(left + l_offset, right - r_offset, y, STR_TINY_BLACK_STATION);
1570 if (++i == 4)
break;
1574 order = order->
next;
1575 if (order ==
nullptr) {
1579 }
while (oid != start);
1586 int l_offset = rtl ? 0 : order_arrow_width;
1587 int r_offset = rtl ? order_arrow_width : 0;
1589 while (order !=
nullptr) {
1590 if (order->
IsType(OT_GOTO_STATION)) {
1592 DrawString(left + l_offset, right - r_offset, y, STR_TINY_BLACK_STATION);
1595 if (++i == 4)
break;
1597 order = order->
next;
1615 default: NOT_REACHED();
1632 if (divisor == 1)
return base;
1635 uint rem = base % divisor;
1636 return base + (rem == 0 ? 0 : divisor - rem);
1657 int image_left = (rtl && show_orderlist) ? olr.right : tr.left;
1658 int image_right = (!rtl && show_orderlist) ? olr.left : tr.right;
1660 int vehicle_button_x = rtl ? ir.right - profit.width : ir.left;
1662 uint max =
static_cast<uint
>(std::min<size_t>(this->vscroll->
GetPosition() + this->vscroll->GetCapacity(), this->vehgroups.size()));
1663 for (uint i = this->vscroll->
GetPosition(); i < max; ++i) {
1667 SetDParam(0, vehgroup.GetDisplayProfitThisYear());
1668 SetDParam(1, vehgroup.GetDisplayProfitLastYear());
1675 const Vehicle *v = vehgroup.GetSingleVehicle();
1685 CargoTypes vehicle_cargoes = 0;
1687 for (
auto u = v; u !=
nullptr; u = u->
Next()) {
1693 if (!v->
name.empty()) {
1699 DrawString(tr.left, tr.right, ir.top, STR_VEHICLE_LIST_NAME_AND_CARGO);
1706 DrawString(tr.left, tr.right, ir.top, STR_VEHICLE_LIST_NAME_AND_CARGO);
1710 DrawString(tr.left, tr.right, ir.top, STR_VEHICLE_LIST_CARGO);
1712 }
else if (!v->
name.empty()) {
1715 DrawString(tr.left, tr.right, ir.top, STR_TINY_BLACK_VEHICLE);
1719 DrawString(tr.left, tr.right, ir.top, STR_TINY_GROUP, TC_BLACK);
1726 str = STR_BLUE_COMMA;
1736 case GB_SHARED_ORDERS:
1737 assert(vehgroup.NumVehicles() > 0);
1739 for (
int i = 0; i < static_cast<int>(vehgroup.NumVehicles()); ++i) {
1758 void BaseVehicleListWindow::UpdateSortingFromGrouping()
1768 default: NOT_REACHED();
1776 void BaseVehicleListWindow::UpdateVehicleGroupBy(GroupBy group_by)
1785 this->UpdateSortingFromGrouping();
1821 this->BuildVehicleList();
1822 this->SortVehicleList();
1825 this->GetWidget<NWidgetCore>(
WID_VL_LIST)->tool_tip = STR_VEHICLE_LIST_TRAIN_LIST_TOOLTIP + this->
vli.
vtype;
1828 if (this->
vli.
type == VL_SHARED_ORDERS) {
1836 this->GetWidget<NWidgetCore>(
WID_VL_CAPTION)->widget_data = STR_VEHICLE_LIST_TRAIN_CAPTION + this->
vli.
vtype;
1858 size->height = 6 *
resize->height;
1862 size->height = 4 *
resize->height;
1864 default: NOT_REACHED();
1871 d.height += padding.height;
1872 *size =
maxdim(*size, d);
1882 size->width = std::max(size->width,
GetStringListWidth(this->vehicle_group_shared_orders_sorter_names));
1883 size->width += padding.width;
1892 d.height += padding.height;
1893 d.width += padding.width;
1894 *size =
maxdim(*size, d);
1914 case VL_SHARED_ORDERS:
1929 case VL_STATION_LIST:
1941 default: NOT_REACHED();
1964 this->BuildVehicleList();
1965 this->SortVehicleList();
2003 assert(this->
vli.
type == VL_SHARED_ORDERS);
2005 ShowOrdersWindow(this->
vehicles[0]);
2028 if (id_v >= this->
vehgroups.size())
return;
2033 const Vehicle *v = vehgroup.GetSingleVehicle();
2044 case GB_SHARED_ORDERS: {
2045 assert(vehgroup.NumVehicles() > 0);
2049 ShowOrdersWindow(v);
2051 if (vehgroup.NumVehicles() == 1) {
2054 ShowVehicleListWindow(v);
2061 default: NOT_REACHED();
2087 this->UpdateVehicleGroupBy(
static_cast<GroupBy
>(index));
2099 assert(this->
vehicles.size() != 0);
2110 default: NOT_REACHED();
2114 default: NOT_REACHED();
2122 StationID station = (this->
vli.
type == VL_STATION_LIST) ? this->
vli.
index : INVALID_STATION;
2124 Debug(misc, 3,
"Periodic resort {} list company {} at station {}", this->
vli.
vtype, this->owner, station);
2141 if (!gui_scope &&
HasBit(data, 31) && this->
vli.
type == VL_SHARED_ORDERS) {
2144 this->window_number = this->
vli.
Pack();
2159 WDP_AUTO,
"list_vehicles", 260, 246,
2162 _nested_vehicle_list,
lengthof(_nested_vehicle_list)
2166 WDP_AUTO,
"list_vehicles_train", 325, 246,
2169 _nested_vehicle_list,
lengthof(_nested_vehicle_list)
2178 AllocateWindowDescFront<VehicleListWindow>(&_vehicle_list_train_desc, num);
2181 AllocateWindowDescFront<VehicleListWindow>(&_vehicle_list_other_desc, num);
2195 ShowVehicleListWindowLocal(company, VL_STANDARD, vehicle_type, company);
2199 void ShowVehicleListWindow(
const Vehicle *v)
2206 ShowVehicleListWindowLocal(company, VL_STATION_LIST, vehicle_type, station);
2211 uint16 depot_airport_index;
2218 ShowVehicleListWindowLocal(company, VL_DEPOT_LIST, vehicle_type, depot_airport_index);
2246 SetDataTip(STR_EMPTY, STR_SERVICE_INTERVAL_DROPDOWN_TOOLTIP),
2263 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),
2272 SetDataTip(STR_EMPTY, STR_SERVICE_INTERVAL_DROPDOWN_TOOLTIP),
2279 SetDataTip(STR_VEHICLE_DETAIL_TAB_INFORMATION, STR_VEHICLE_DETAILS_TRAIN_INFORMATION_TOOLTIP),
SetFill(1, 0),
SetResize(1, 0),
2283 SetDataTip(STR_VEHICLE_DETAIL_TAB_TOTAL_CARGO, STR_VEHICLE_DETAILS_TRAIN_TOTAL_CARGO_TOOLTIP),
SetFill(1, 0),
SetResize(1, 0),
2295 static StringID _service_interval_dropdown[] = {
2296 STR_VEHICLE_DETAILS_DEFAULT,
2297 STR_VEHICLE_DETAILS_DAYS,
2298 STR_VEHICLE_DETAILS_PERCENT,
2332 if (!gui_scope)
return;
2338 if (aimed_height != nwid_info->
current_y) {
2351 uint desired_height;
2356 for (
const Vehicle *u = v; u !=
nullptr; u = u->
Next()) {
2362 return desired_height;
2373 static const StringID info_strings[] = {
2374 STR_VEHICLE_INFO_MAX_SPEED,
2375 STR_VEHICLE_INFO_WEIGHT_POWER_MAX_SPEED,
2376 STR_VEHICLE_INFO_WEIGHT_POWER_MAX_SPEED_MAX_TE,
2377 STR_VEHICLE_INFO_PROFIT_THIS_YEAR_LAST_YEAR,
2378 STR_VEHICLE_INFO_RELIABILITY_BREAKDOWNS
2380 for (uint i = 0; i <
lengthof(info_strings); i++) {
2385 size->width = dim.width + padding.width;
2412 size->height = 4 *
resize->height;
2416 StringID *strs = _service_interval_dropdown;
2420 size->width += padding.width;
2428 size->width = std::max(
2441 switch (vehicle_type) {
2442 default: NOT_REACHED();
2466 default: NOT_REACHED();
2485 SetDParam(0, (v->
age + DAYS_IN_YEAR < v->max_age) ? STR_VEHICLE_INFO_AGE : STR_VEHICLE_INFO_AGE_RED);
2488 DrawString(tr, STR_VEHICLE_INFO_AGE_RUNNING_COST_YR);
2502 string = STR_VEHICLE_INFO_WEIGHT_POWER_MAX_SPEED;
2504 string = STR_VEHICLE_INFO_WEIGHT_POWER_MAX_SPEED_MAX_TE;
2512 string = STR_VEHICLE_INFO_MAX_SPEED_TYPE_RANGE;
2514 string = STR_VEHICLE_INFO_MAX_SPEED_TYPE;
2517 string = STR_VEHICLE_INFO_MAX_SPEED;
2528 DrawString(tr, STR_VEHICLE_INFO_PROFIT_THIS_YEAR_LAST_YEAR_MIN_PERFORMANCE);
2530 DrawString(tr, STR_VEHICLE_INFO_PROFIT_THIS_YEAR_LAST_YEAR);
2537 DrawString(tr, STR_VEHICLE_INFO_RELIABILITY_BREAKDOWNS);
2571 v->ServiceIntervalIsPercent() ? STR_VEHICLE_DETAILS_SERVICING_INTERVAL_PERCENT : STR_VEHICLE_DETAILS_SERVICING_INTERVAL_DAYS);
2593 StringID str = v->ServiceIntervalIsCustom() ?
2594 (v->ServiceIntervalIsPercent() ? STR_VEHICLE_DETAILS_PERCENT : STR_VEHICLE_DETAILS_DAYS) :
2595 STR_VEHICLE_DETAILS_DEFAULT;
2611 if (mod == v->GetServiceInterval())
return;
2619 ShowDropDownMenu(
this, _service_interval_dropdown, v->ServiceIntervalIsCustom() ? (v->ServiceIntervalIsPercent() ? 2 : 1) : 0, widget, 0, 0);
2646 bool iscustom = index != 0;
2647 bool ispercent = iscustom ? (index == 2) :
Company::Get(v->
owner)->settings.vehicle.servint_ispercent;
2658 if (nwi !=
nullptr) {
2666 WDP_AUTO,
"view_vehicle_details_train", 405, 178,
2674 WDP_AUTO,
"view_vehicle_details", 405, 113,
2716 SetDataTip(SPR_IGNORE_SIGNALS, STR_VEHICLE_VIEW_TRAIN_IGNORE_SIGNAL_TOOLTIP),
2720 SetDataTip(SPR_FORCE_VEHICLE_TURN, STR_VEHICLE_VIEW_ROAD_VEHICLE_REVERSE_TOOLTIP),
2750 static const int VV_INITIAL_VIEWPORT_WIDTH = 226;
2751 static const int VV_INITIAL_VIEWPORT_HEIGHT = 84;
2752 static const int VV_INITIAL_VIEWPORT_HEIGHT_TRAIN = 102;
2756 VCT_CMD_START_STOP = 0,
2758 VCT_CMD_TURN_AROUND,
2764 STR_ERROR_CAN_T_STOP_START_TRAIN,
2765 STR_ERROR_CAN_T_STOP_START_ROAD_VEHICLE,
2766 STR_ERROR_CAN_T_STOP_START_SHIP,
2767 STR_ERROR_CAN_T_STOP_START_AIRCRAFT
2770 STR_ERROR_CAN_T_BUY_TRAIN,
2771 STR_ERROR_CAN_T_BUY_ROAD_VEHICLE,
2772 STR_ERROR_CAN_T_BUY_SHIP,
2773 STR_ERROR_CAN_T_BUY_AIRCRAFT
2776 STR_ERROR_CAN_T_REVERSE_DIRECTION_TRAIN,
2777 STR_ERROR_CAN_T_MAKE_ROAD_VEHICLE_TURN,
2791 if (result.
Failed())
return;
2838 bool mouse_over_start_stop =
false;
2869 static const SpriteID vehicle_view_goto_depot_sprites[] = {
2870 SPR_SEND_TRAIN_TODEPOT,
2871 SPR_SEND_ROADVEH_TODEPOT,
2872 SPR_SEND_SHIP_TODEPOT,
2873 SPR_SEND_AIRCRAFT_TODEPOT,
2876 this->GetWidget<NWidgetCore>(
WID_VV_GOTO_DEPOT)->widget_data = vehicle_view_goto_depot_sprites[v->
type];
2879 static const SpriteID vehicle_view_clone_sprites[] = {
2885 this->GetWidget<NWidgetCore>(
WID_VV_CLONE)->widget_data = vehicle_view_clone_sprites[v->
type];
2889 this->GetWidget<NWidgetCore>(
WID_VV_TURN_AROUND)->tool_tip = STR_VEHICLE_VIEW_TRAIN_REVERSE_TOOLTIP;
2900 default: NOT_REACHED();
2906 this->GetWidget<NWidgetCore>(
WID_VV_START_STOP)->tool_tip = STR_VEHICLE_VIEW_TRAIN_STATUS_START_STOP_TOOLTIP + v->
type;
2907 this->GetWidget<NWidgetCore>(
WID_VV_RENAME)->tool_tip = STR_VEHICLE_DETAILS_TRAIN_RENAME + v->
type;
2908 this->GetWidget<NWidgetCore>(
WID_VV_LOCATION)->tool_tip = STR_VEHICLE_VIEW_TRAIN_CENTER_TOOLTIP + v->
type;
2909 this->GetWidget<NWidgetCore>(
WID_VV_REFIT)->tool_tip = STR_VEHICLE_VIEW_TRAIN_REFIT_TOOLTIP + v->
type;
2910 this->GetWidget<NWidgetCore>(
WID_VV_GOTO_DEPOT)->tool_tip = STR_VEHICLE_VIEW_TRAIN_SEND_TO_DEPOT_TOOLTIP + v->
type;
2911 this->GetWidget<NWidgetCore>(
WID_VV_SHOW_ORDERS)->tool_tip = STR_VEHICLE_VIEW_TRAIN_ORDERS_TOOLTIP + v->
type;
2912 this->GetWidget<NWidgetCore>(
WID_VV_SHOW_DETAILS)->tool_tip = STR_VEHICLE_VIEW_TRAIN_SHOW_DETAILS_TOOLTIP + v->
type;
2913 this->GetWidget<NWidgetCore>(
WID_VV_CLONE)->tool_tip = STR_VEHICLE_VIEW_CLONE_TRAIN_INFO + v->
type;
2915 this->UpdateButtonStatus();
2943 size->width = VV_INITIAL_VIEWPORT_WIDTH;
2944 size->height = (v->
type ==
VEH_TRAIN) ? VV_INITIAL_VIEWPORT_HEIGHT_TRAIN : VV_INITIAL_VIEWPORT_HEIGHT;
2990 str = STR_VEHICLE_STATUS_CRASHED;
2992 str = STR_VEHICLE_STATUS_BROKEN_DOWN;
2997 str = STR_VEHICLE_STATUS_TRAIN_NO_POWER;
2999 str = STR_VEHICLE_STATUS_STOPPED;
3003 str = STR_VEHICLE_STATUS_TRAIN_STOPPING_VEL;
3006 str = STR_VEHICLE_STATUS_STOPPED;
3009 str = STR_VEHICLE_STATUS_TRAIN_STUCK;
3011 str = STR_VEHICLE_STATUS_AIRCRAFT_TOO_FAR;
3013 if (mouse_over_start_stop) {
3021 case OT_GOTO_STATION: {
3028 case OT_GOTO_DEPOT: {
3049 str = STR_VEHICLE_STATUS_LOADING_UNLOADING;
3052 case OT_GOTO_WAYPOINT: {
3060 case OT_LEAVESTATION:
3062 str = STR_VEHICLE_STATUS_LEAVING;
3068 str = STR_VEHICLE_STATUS_NO_ORDERS_VEL;
3083 DrawSpriteIgnorePadding(image, PAL_NONE, tr.
WithWidth(icon_width, rtl),
false,
SA_CENTER);
3141 ShowOrdersWindow(v);
3191 if (str ==
nullptr)
return;
3199 if (start_stop != mouse_over_start_stop) {
3200 mouse_over_start_stop = start_stop;
3213 void UpdateButtonStatus()
3251 this->UpdateButtonStatus();
3267 static Hotkey vehicleview_hotkeys[] = {
3271 HotkeyList VehicleViewWindow::hotkeys(
"vehicleview", vehicleview_hotkeys);
3275 WDP_AUTO,
"view_vehicle", 250, 116,
3279 &VehicleViewWindow::hotkeys
3287 WDP_AUTO,
"view_vehicle_train", 250, 134,
3291 &VehicleViewWindow::hotkeys
3307 assert(v !=
nullptr);
3322 bool VehicleClicked(VehicleList::const_iterator begin, VehicleList::const_iterator end)
3324 assert(begin != end);
3343 void StopGlobalFollowVehicle(
const Vehicle *v)
3361 if (result.
Failed())
return;
3399 int vehicle_width = 0;
3400 for (
const Vehicle *u = v; u !=
nullptr; u = u->
Next()) {
3403 return vehicle_width;
3419 int total_width = 0;
3421 bool rotor_seq =
false;
3424 while (v !=
nullptr) {
3425 if (total_width >=
ScaleSpriteTrad(2 * (
int)VEHICLEINFO_FULL_VEHICLE_WIDTH))
break;
3432 if (!seq.
IsValid()) seq.
Set(SPR_ROTOR_STOPPED);
3443 for (uint i = 0; i < seq.count; ++i) {
3461 if (is_ground_vehicle) {
3463 int offs = (
ScaleSpriteTrad(VEHICLEINFO_FULL_VEHICLE_WIDTH) - total_width) / 2;
3464 if (rtl) offs = -offs;
@ VEH_AIRCRAFT
Aircraft vehicle type.
int GetDisplayImageWidth(Point *offset=nullptr) const
Get the width of a train vehicle image in the GUI.
byte cargo_filter_criteria
Selected cargo filter index.
static bool IsVehicleRefitable(const Vehicle *v)
Checks whether the vehicle may be refitted at the moment.
VehicleListType
Vehicle List type flags.
static void DrawVehicleDetails(const Vehicle *v, const Rect &r, int vscroll_pos, uint vscroll_cap, TrainDetailsWindowTabs det_tab)
Draw the details for the given vehicle at the position of the Details windows.
GroundVehicleCache * GetGroundVehicleCache()
Access the ground vehicle cache of the vehicle.
virtual bool IsChainInDepot() const
Check whether the whole vehicle chain is in the depot.
@ TC_FORCED
Ignore colour changes from strings.
@ BP_HIDE_BUTTONS
Show the empty panel.
void OnPaint() override
The window must be repainted.
@ SEL_RT_TURN_AROUND
Display 'turn around' button in WID_VV_SELECT_REFIT_TURN stacked widget.
byte VehicleOrderID
The index of an order within its current vehicle (not pool related)
uint CountDigitsForAllocatingSpace(uint number)
Get the number of digits of space required for the given number.
Dimension GetActionDropdownSize(bool show_autoreplace, bool show_group)
Compute the size for the Action dropdown.
static bool VehicleGroupLengthSorter(const GUIVehicleGroup &a, const GUIVehicleGroup &b)
Sort vehicle groups by the number of vehicles in the group.
static int32 ClampToI32(const int64 a)
Reduce a signed 64-bit int to a signed 32-bit one.
@ WC_INVALID
Invalid window.
bool IsType(OrderType type) const
Check whether this order is of the given type.
uint8 SortType() const
Get the sorttype of the list.
std::vector< const Vehicle * > VehicleList
A list of vehicles.
static Titem * Get(size_t index)
Returns Titem with given index.
PlaneSelections
Display planes available in the vehicle view window.
bool ScrollMainWindowToTile(TileIndex tile, bool instant)
Scrolls the viewport of the main window to a given location.
@ CF_ANY
Show all vehicles independent of carried cargo (i.e. no filtering)
@ BP_SHOW_BUTTONS
Show the buttons.
static bool HasAtMostOneBit(T value)
Test whether value has at most 1 bit set.
uint GetRoadVehDetailsHeight(const Vehicle *v)
Gets the desired height for the road vehicle details panel.
@ TDW_TAB_INFO
Tab with name and value of the vehicles.
void ShowExtraViewportWindow(TileIndex tile=INVALID_TILE)
Show a new Extra Viewport window.
List of hotkeys for a window.
bool show_cargo_in_vehicle_lists
Show the cargoes the vehicles can carry in the list windows.
uint16 GetServiceIntervalClamped(uint interval, bool ispercent)
Clamp the service interval to the correct min/max.
CompanyID company
The company associated with this list.
static uint GB(const T x, const uint8 s, const uint8 n)
Fetch n bits from x, started at bit s.
VehicleOrderID GetNumManualOrders() const
Get the number of manually added orders this vehicle has.
Money value
Value of the vehicle.
virtual void PlayLeaveStationSound(bool force=false) const
Play the sound associated with leaving the station.
uint8 train_acceleration_model
realistic acceleration for trains
Dimensions (a width and height) of a rectangle in 2D.
@ CF_FREIGHT
Show only vehicles which carry any freight (non-passenger) cargo.
@ TE_RISING
Make the text effect slowly go upwards.
void OnInvalidateData(int data=0, bool gui_scope=true) override
Some data on this window has become invalid.
void OnResize() override
Called after the window got resized.
void DrawSortButtonState(int widget, SortButtonState state) const
Draw a sort button's up or down arrow symbol.
uint sprite_count
number of sprites to draw
static Titem * GetIfValid(size_t index)
Returns Titem with given index.
bool Sort(Comp compare)
Sort the list.
const Scrollbar * GetScrollbar(uint widnum) const
Return the Scrollbar to a widget index.
@ WDF_CONSTRUCTION
This window is used for construction; close it whenever changing company.
int click_x
Position of the first click while dragging.
void OnClick(Point pt, int widget, int click_count) override
A click with the left mouse button has been made on the window.
Commands
List of commands.
Rect Shrink(int s) const
Copy and shrink Rect by s pixels.
GroupBy grouping
How we want to group the list.
static bool VehicleGroupTotalProfitThisYearSorter(const GUIVehicleGroup &a, const GUIVehicleGroup &b)
Sort vehicle groups by the total profit this year.
The information about a vehicle list.
@ CBID_VEHICLE_CARGO_SUFFIX
Determine the cargo "suffixes" for each refit possibility of a cargo.
void OnClick(Point pt, int widget, int click_count) override
A click with the left mouse button has been made on the window.
std::vector< const CargoSpec * > _sorted_cargo_specs
Cargo specifications sorted alphabetically by name.
void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
Update size and resize step of a widget in the window.
void ReInit(int rx=0, int ry=0)
Re-initialize a window, and optionally change its size.
Vehicle * Next() const
Get the next vehicle of this vehicle.
T * Next() const
Get next vehicle in the chain.
void SetFilterType(uint8 n_type)
Set the filtertype of the list.
uint information_width
Width required for correctly displaying all cargoes in the information panel.
virtual int GetDisplayMaxSpeed() const
Gets the maximum speed in km-ish/h that can be sent into SetDParam for string processing.
TrainDetailsWindowTabs
The tabs in the train details window.
DestinationID GetDestination() const
Gets the destination of this order.
VehicleID selected_vehicle
First vehicle in the current selection.
void OnInvalidateData(int data=0, bool gui_scope=true) override
Some data on this window has become invalid.
uint order_arrow_width
Width of the arrow in the small order list.
VehicleDetailsWindow(WindowDesc *desc, WindowNumber window_number)
Initialize a newly created vehicle details window.
void Set(SpriteID sprite)
Assign a single sprite to the sequence.
@ WF_DISABLE_VP_SCROLL
Window does not do autoscroll,.
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.
ViewportData * viewport
Pointer to viewport data, if present.
void GetVehicleSet(VehicleSet &set, Vehicle *v, uint8 num_vehicles)
Calculates the set of vehicles that will be affected by a given selection.
std::vector< std::unique_ptr< const DropDownListItem > > DropDownList
A drop down list is a collection of drop down list items.
std::string name
Name of vehicle.
void OnPaint() override
The window must be repainted.
void CreateNestedTree(bool fill_nested=true)
Perform the first part of the initialization of a nested widget tree.
void DrawShipDetails(const Vehicle *v, const Rect &r)
Draw the details for the given vehicle at the given position.
Tindex index
Index of this pool item.
static CargoSpec * Get(size_t index)
Retrieve cargo details for the given cargo ID.
void DrawRoadVehDetails(const Vehicle *v, const Rect &r)
Draw the details for the given vehicle at the given position.
Class for storing amounts of cargo.
SpriteID sprite
The 'real' sprite.
GroupID group_id
Index of group Pool array.
Dimension maxdim(const Dimension &d1, const Dimension &d2)
Compute bounding box of both dimensions.
Window * FindWindowById(WindowClass cls, WindowNumber number)
Find a window by its class and window number.
Listing * sorting
Pointer to the vehicle type related sorting.
static bool HasBit(const T x, const uint8 y)
Checks if a bit in a value is set.
static constexpr TileIndex INVALID_TILE
The very nice invalid tile marker.
static int UnScaleGUI(int value)
Short-hand to apply GUI zoom level.
byte subtype
Subcargo to use.
void OnInvalidateData(int data=0, bool gui_scope=true) override
Some data on this window has become invalid.
void OnClick(Point pt, int widget, int click_count) override
A click with the left mouse button has been made on the window.
void ShowCompanyGroup(CompanyID company, VehicleType vehicle_type, GroupID group=INVALID_GROUP, bool need_existing_window=false)
Show the group window for the given company and vehicle type.
static const ZoomLevel _vehicle_view_zoom_levels[]
Zoom levels for vehicle views indexed by vehicle type.
bool include(std::vector< T > &vec, const T &item)
Helper function to append an item to a vector if it is not already contained Consider using std::set,...
@ SEL_DC_BASEPLANE
First plane of the WID_VV_SELECT_DEPOT_CLONE stacked widget.
bool _ctrl_pressed
Is Ctrl pressed?
const GRFFile * GetGRF() const
Retrieve the NewGRF the vehicle is tied to.
uint GetStringListWidth(const StringID *list, FontSize fontsize)
Get maximum width of a list of strings.
void SelectPlane(PlaneSelections plane)
Display a plane in the window.
VehicleCommandTranslation
Command indices for the _vehicle_command_translation_table.
TextColour
Colour of the strings, see _string_colourmap in table/string_colours.h or docs/ottd-colourtext-palett...
uint GetUnitNumberDigits(VehicleList &vehicles)
Get the number of digits the biggest unit number of a set of vehicles has.
VehicleList::const_iterator vehicles_begin
Pointer to beginning element of this vehicle group.
ZoomLevel
All zoom levels we know.
TrainDetailsWindowTabs tab
For train vehicles: which tab is displayed.
ClientSettings _settings_client
The current settings for this game.
void SetStringParameters(int widget) const override
Initialize string parameters for a widget.
void ChangeVehicleViewWindow(VehicleID from_index, VehicleID to_index)
Report a change in vehicle IDs (due to autoreplace) to affected vehicle windows.
@ EIT_IN_DETAILS
Vehicle drawn in vehicle details, refit window, ...
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.
WindowClass cls
Class of the window,.
@ WC_VEHICLE_TIMETABLE
Vehicle timetable; Window numbers:
Owner owner
The owner of the content shown in this window. Company colour is acquired from this variable.
int32 WindowNumber
Number to differentiate different windows of the same class.
Vehicle * GetNextArticulatedPart() const
Get the next part of an articulated engine.
Rect Expand(int s) const
Copy and expand Rect by s pixels.
EngineImageType
Visualisation contexts of vehicles and engines.
@ CBM_VEHICLE_CARGO_SUFFIX
Show suffix after cargo name.
@ VEH_ROAD
Road vehicle type.
@ CC_PASSENGERS
Passengers.
uint16 cur_speed
current speed
virtual bool IsPrimaryVehicle() const
Whether this is the primary vehicle in the chain.
bool IsGroundVehicle() const
Check if the vehicle is a ground vehicle.
uint16 servint_ships
service interval for ships
void SetSortType(uint8 n_type)
Set the sorttype of the list.
Owner owner
Which company owns the vehicle?
Owner
Enum for all companies/owners.
static bool VehicleGroupTotalProfitLastYearSorter(const GUIVehicleGroup &a, const GUIVehicleGroup &b)
Sort vehicle groups by the total profit last year.
uint16 GetVehicleCallback(CallbackID callback, uint32 param1, uint32 param2, EngineID engine, const Vehicle *v)
Evaluate a newgrf callback for vehicles.
virtual EventState OnHotkey(int hotkey)
A hotkey has been pressed.
static bool VehicleAgeSorter(const Vehicle *const &a, const Vehicle *const &b)
Sort vehicles by their age.
byte _colour_gradient[COLOUR_END][8]
All 16 colour gradients 8 colours per gradient from darkest (0) to lightest (7)
Rect WithHeight(int height, bool end=false) const
Copy Rect and set its height.
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), &VehicleViewWindow::hotkeys)
Vehicle view window descriptor for all vehicles but trains.
Point sprite_pos[16]
relative position of individual sprites
Window for the (old) vehicle listing.
static void SetDParam(uint n, uint64 v)
Set a string parameter v at index n in the global string parameter array.
void OnDropdownSelect(int widget, int index) override
A dropdown option associated to this window has been selected.
uint8 num_vehicles
Number of selected vehicles.
void SetCargoFilterIndex(byte index)
Set cargo filter list item index.
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), &VehicleViewWindow::hotkeys)
Vehicle view window descriptor for trains.
byte breakdowns_since_last_service
Counter for the amount of breakdowns.
int sprite_left
Left position of the vehicle sprite.
static bool IsVehicleServiceIntervalEnabled(const VehicleType vehicle_type, CompanyID company_id)
Checks whether service interval is enabled for the vehicle.
Dimension GetStringBoundingBox(const char *str, FontSize start_fontsize)
Return the string dimension in pixels.
void SetFilterFuncs(FilterFunction *const *n_funcs)
Hand the array of filter function pointers to the sort list.
void OnClick(Point pt, int widget, int click_count) override
A click with the left mouse button has been made on the window.
bool auto_refit
Select cargo for auto-refitting.
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.
static uint CountBits(T value)
Counts the number of set bits in a variable.
@ QSF_LEN_IN_CHARS
the length of the string is counted in characters
void SetStringParameters(int widget) const override
Initialize string parameters for a widget.
bool IsArticulatedPart() const
Check if the vehicle is an articulated part of an engine.
void OnResize() override
Called after the window got resized.
void SetCargoFilterArray()
Populate the filter list and set the cargo filter criteria.
OrderType GetType() const
Get the type of order of this order.
void OnInit() override
Notification that the nested widget tree gets initialized.
@ Service
The vehicle will leave the depot right after arrival (service only)
Aircraft, helicopters, rotors and their shadows belong to this class.
void UpdateCursorSize()
Update cursor dimension.
uint32 SpriteID
The number of a sprite, without mapping bits and colourtables.
static const GroupID ALL_GROUP
All vehicles are in this group.
SubtypeList list[NUM_CARGO]
List of refit subtypes available for each sorted cargo.
@ TDW_TAB_TOTALS
Tab with sum of total cargo transported.
High level window description.
GrfSpecFeature GetGrfSpecFeature(TileIndex tile)
Get the GrfSpecFeature associated with the tile.
int sel[2]
Index in refit options, sel[0] == -1 if nothing is selected.
void FilterVehicleList()
Filter the engine list against the currently selected cargo filter.
static const RailtypeInfo * GetRailTypeInfo(RailType railtype)
Returns a pointer to the Railtype information for a given railtype.
Money GetDisplayRunningCost() const
Gets the running cost of a vehicle that can be sent into SetDParam for string processing.
static void ShowVehicleDetailsWindow(const Vehicle *v)
Shows the vehicle details window of the given vehicle.
byte breakdown_ctr
Counter for managing breakdown events.
uint16 EngineID
Unique identification number of an engine.
VehicleListIdentifier vli
Identifier of the vehicle list we want to currently show.
DropDownList BuildActionDropdownList(bool show_autoreplace, bool show_group)
Display the Action dropdown window.
bool IsValid() const
Check whether the sequence contains any sprites.
uint16 cached_total_length
Length of the whole vehicle (valid only for the first engine).
@ EF_AUTO_REFIT
Automatic refitting is allowed.
Money GetDisplayProfitThisYear() const
Gets the profit vehicle had this year.
bool IsDescSortOrder() const
Check if the sort order is descending.
void SetStringParameters(int widget) const override
Initialize string parameters for a widget.
@ WDP_AUTO
Find a place automatically.
void SetFilterState(bool state)
Enable or disable the filter.
virtual int GetDisplaySpeed() const
Gets the speed in km-ish/h that can be sent into SetDParam for string processing.
Cached, frequently calculated values.
CargoID cargo_filter[NUM_CARGO+3]
Available cargo filters; CargoID or CF_ANY or CF_FREIGHT or CF_NONE.
ResizeInfo resize
Resize information.
static uint GetVehicleHeight(VehicleType type)
Get the height of a single vehicle in the GUIs.
Common return value for all commands.
void OnPaint() override
The window must be repainted.
@ VRF_TRAIN_STUCK
Train can't get a path reservation.
@ SEL_DC_GOTO_DEPOT
Display 'goto depot' button in WID_VV_SELECT_DEPOT_CLONE stacked widget.
@ WC_VEHICLE_VIEW
Vehicle view; Window numbers:
CargoTypes GetUnionOfArticulatedRefitMasks(EngineID engine, bool include_initial_cargo_type)
Ors the refit_masks of all articulated parts.
void StartStopVehicle(const Vehicle *v, bool texteffect)
Executes CMD_START_STOP_VEHICLE for given vehicle.
Rect Translate(int x, int y) const
Copy and translate Rect by x,y pixels.
static const VehicleOrderID INVALID_VEH_ORDER_ID
Invalid vehicle order index (sentinel)
void ShowCompanyGroupForVehicle(const Vehicle *v)
Show the group window for the given vehicle.
@ VEH_COMPANY_END
Last company-ownable type.
static const NWidgetPart _nested_nontrain_vehicle_details_widgets[]
Vehicle details widgets (other than train).
WindowNumber window_number
The WindowNumber of the window that is responsible for the selection mode.
int height
Height of the window (number of pixels down in y direction)
bool VehicleClicked(const Vehicle *v)
Dispatch a "vehicle selected" event if any window waits for it.
static bool VehicleModelSorter(const Vehicle *const &a, const Vehicle *const &b)
Sort vehicles by model.
TileIndex tile
Current tile index.
static bool VehicleGroupAverageProfitLastYearSorter(const GUIVehicleGroup &a, const GUIVehicleGroup &b)
Sort vehicle groups by the average profit last year.
static bool VehicleProfitThisYearSorter(const Vehicle *const &a, const Vehicle *const &b)
Sort vehicles by this year profit.
static const VehicleID INVALID_VEHICLE
Constant representing a non-existing vehicle.
@ ZOOM_LVL_ROADVEH
Default zoom level for the road vehicle view.
void SetDirty() const
Mark entire window as dirty (in need of re-paint)
void OnMouseOver(Point pt, int widget) override
The mouse is currently moving over the window or has just moved outside of the window.
void SetListing(Listing l)
Import sort conditions.
@ MassSend
Tells that it's a mass send to depot command (type in VLW flag)
EngineID engine_type
The type of engine used for this vehicle.
bool operator!=(const RefitOption &other) const
Inequality operator for RefitOption.
@ BP_NORMAL
Show shared orders caption and buttons.
@ VS_CRASHED
Vehicle is crashed.
Sprite sequence for a vehicle part.
uint Horizontal() const
Get total horizontal padding of RectPadding.
static bool IsExpected(const BaseStation *st)
Helper for checking whether the given station is of this type.
static bool VehicleMaxSpeedSorter(const Vehicle *const &a, const Vehicle *const &b)
Sort vehicles by their max speed.
bool Failed() const
Did this command fail?
Order current_order
The current order (+ status, like: loading)
static bool CDECL CargoFilter(const GUIVehicleGroup *vehgroup, const CargoID cid)
Cargo filter functions.
CargoTypes _cargo_mask
Bitmask of cargo types available.
int32 Date
The type to store our dates in.
virtual bool OnVehicleSelect(const struct Vehicle *v)
The user clicked on a vehicle while HT_VEHICLE has been set.
Scrollbar * vscroll
The main scrollbar.
static const SpriteID SPR_CLONE_TRAIN
Clone vehicles stuff.
void ShowDropDownList(Window *w, DropDownList &&list, int selected, int button, uint width, bool auto_width, bool instant_close)
Show a drop down list.
uint GetVehicleListHeight(VehicleType type, uint divisor)
Get the height of a vehicle in the vehicle list GUIs.
static int ScaleSpriteTrad(int value)
Scale traditional pixel dimensions to GUI zoom level, for drawing sprites.
@ BP_SHARED_ORDERS
Show the normal caption.
uint32 Pack() const
Pack a VehicleListIdentifier in a single uint32.
static bool VehicleTimetableDelaySorter(const Vehicle *const &a, const Vehicle *const &b)
Sort vehicles by the timetable delay.
GameSettings _settings_game
Game settings of a running game or the scenario editor.
Scrollbar * hscroll
Only used for long vehicles.
@ SEL_DC_CLONE
Display 'clone vehicle' button in WID_VV_SELECT_DEPOT_CLONE stacked widget.
ButtonPlanes
Enumeration of planes of the button row at the bottom.
@ WC_VEHICLE_DETAILS
Vehicle details; Window numbers:
void ShowNewGRFInspectWindow() const override
Show the NewGRF inspection window.
@ ZOOM_LVL_AIRCRAFT
Default zoom level for the aircraft view.
void SetWidgetDisabledState(byte widget_index, bool disab_stat)
Sets the enabled/disabled status of a widget.
@ VS_STOPPED
Vehicle is stopped by the player.
Window * parent
Parent window.
uint32 GetGRFID() const
Retrieve the GRF ID of the NewGRF the vehicle is tied to.
CompanyID _local_company
Company controlled by the human player at this client. Can also be COMPANY_SPECTATOR.
const Engine * GetEngine() const
Retrieves the engine of the vehicle.
void CcBuildPrimaryVehicle(Commands cmd, const CommandCost &result, VehicleID new_veh_id, uint, uint16, CargoArray)
This is the Callback method after the construction attempt of a primary vehicle.
bool GenerateVehicleSortList(VehicleList *list, const VehicleListIdentifier &vli)
Generate a list of vehicles based on window type.
void ShowQueryString(StringID str, StringID caption, uint maxsize, Window *parent, CharSetFilter afilter, QueryStringFlags flags)
Show a query popup window with a textbox in it.
int left
x position of left edge of the window
static bool VehicleGroupAverageProfitThisYearSorter(const GUIVehicleGroup &a, const GUIVehicleGroup &b)
Sort vehicle groups by the average profit this year.
WindowFlags flags
Window flags.
'Train' is either a loco or a wagon.
static void DrawSmallOrderList(const Order *order, int left, int right, int y, uint order_arrow_width)
Draw small order list in the vehicle GUI, but without the little black arrow.
Rect Indent(int indent, bool end) const
Copy Rect and indent it from its position.
static const GroupID DEFAULT_GROUP
Ungrouped vehicles are in this group.
StringID GetGRFStringID(uint32 grfid, StringID stringid)
Returns the index for this stringid associated with its grfID.
uint32 cached_max_te
Maximum tractive effort of consist (valid only for the first engine).
WindowClass
Window classes.
void SetMouseCursorVehicle(const Vehicle *v, EngineImageType image_type)
Set the mouse cursor to look like a vehicle.
uint16 callback_mask
Bitmask of vehicle callbacks that have to be called.
Rect WithWidth(int width, bool end) const
Copy Rect and set its width.
void DrawWidget(const Rect &r, int widget) const override
Draw the contents of a nested widget.
void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
Update size and resize step of a widget in the window.
CaptionPlanes
Enumeration of planes of the title row at the top.
void DrawSprite(SpriteID img, PaletteID pal, int x, int y, const SubSprite *sub, ZoomLevel zoom)
Draw a sprite, not in a viewport.
void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
Update size and resize step of a widget in the window.
void DrawAircraftDetails(const Aircraft *v, const Rect &r)
Draw the details for the given vehicle at the given position.
@ ZOOM_LVL_SHIP
Default zoom level for the ship view.
Default settings for vehicles.
void OnResize() override
Called after the window got resized.
Coordinates of a point in 2D.
bool ScrollMainWindowTo(int x, int y, int z, bool instant)
Scrolls the main window to given coordinates.
@ SEL_RT_BASEPLANE
First plane of the WID_VV_SELECT_REFIT_TURN stacked widget.
void CcStartStopVehicle(Commands cmd, const CommandCost &result, VehicleID veh_id, bool)
This is the Callback method after attempting to start/stop a vehicle.
@ WC_TRAINS_LIST
Trains list; Window numbers:
int GetSingleVehicleWidth(const Vehicle *v, EngineImageType image_type)
Get the width of a vehicle (part) in pixels.
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.
int sprite_right
Right position of the vehicle sprite.
void DrawRoadVehImage(const Vehicle *v, const Rect &r, VehicleID selection, EngineImageType image_type, int skip)
Draws an image of a road vehicle chain.
static const int DAYS_IN_LEAP_YEAR
sometimes, you need one day more...
uint16 vehicle_flags
Used for gradual loading and other miscellaneous things (.
WindowNumber window_number
Window number within the window class.
VehicleType
Available vehicle types.
uint step_height
Step-size of height resize changes.
uint Vertical() const
Get total vertical padding of RectPadding.
static void ChangeVehicleWindow(WindowClass window_class, VehicleID from_index, VehicleID to_index)
Assign a vehicle window a new vehicle.
void ToggleSortOrder()
Toggle the sort order Since that is the worst condition for the sort function reverse the list here.
bool NeedResort()
Check if a resort is needed next loop If used the resort timer will decrease every call till 0.
static bool VehicleValueSorter(const Vehicle *const &a, const Vehicle *const &b)
Sort vehicles by their value.
VehicleOrderID order
If not INVALID_VEH_ORDER_ID, selection is part of a refit order (rather than execute directly).
void InvalidateData(int data=0, bool gui_scope=true)
Mark this window's data as invalid (in need of re-computing)
byte misc_flags
Miscellaneous flags.
@ CS_ALPHANUMERAL
Both numeric and alphabetic and spaces and stuff.
@ WC_NONE
No window, redirects to WC_MAIN_WINDOW.
@ SA_HOR_CENTER
Horizontally center the text.
StringID string
GRF-local String to display for the cargo.
@ SEL_RT_REFIT
Display 'refit' button in WID_VV_SELECT_REFIT_TURN stacked widget.
byte GetDigitWidth(FontSize size)
Return the maximum width of single digit.
void Close() override
Hide the window and all its child windows, and mark them for a later deletion.
@ ODATFB_HALT
Service the vehicle and then halt it.
@ WC_VEHICLE_REFIT
Vehicle refit; Window numbers:
uint32 index
A vehicle list type specific index.
@ HT_VEHICLE
vehicle is accepted as target as well (bitmask)
#define FONT_HEIGHT_SMALL
Height of characters in the small (FS_SMALL) font.
uint32 GetDisplayMinPowerToWeight() const
Calculates the minimum power-to-weight ratio using the maximum weight of the ground vehicle.
StringID GetCargoSubtypeText(const Vehicle *v)
Get the cargo subtype text from NewGRF for the vehicle details window.
@ HT_DRAG
dragging items in the depot windows
@ VIWD_CONSIST_CHANGED
Vehicle composition was changed.
static bool VehicleLengthSorter(const Vehicle *const &a, const Vehicle *const &b)
Sort vehicles by their length.
Dimension GetSpriteSize(SpriteID sprid, Point *offset, ZoomLevel zoom)
Get the size of a sprite.
bool NeedRebuild() const
Check if a rebuild is needed.
VehicleOrderID cur_real_order_index
The index to the current real (non-implicit) order.
HighLightStyle place_mode
Method which is used to place the selection.
void DrawVehicleListItems(VehicleID selected_vehicle, int line_height, const Rect &r) const
Draw all the vehicle list items.
static WindowClass GetWindowClassForVehicleType(VehicleType vt)
Get WindowClass for vehicle list of given vehicle type.
bool operator==(const RefitOption &other) const
Equality operator for RefitOption.
@ VAF_DEST_TOO_FAR
Next destination is too far away.
void OnDropdownSelect(int widget, int index) override
A dropdown option associated to this window has been selected.
Vehicle * FirstShared() const
Get the first vehicle of this vehicle chain.
static const uint CALLBACK_FAILED
Different values for Callback result evaluations.
uint32 StringID
Numeric value that represents a string, independent of the selected language.
@ SBS_DOWN
Sort ascending.
VehicleCache vcache
Cache of often used vehicle values.
@ EIT_IN_LIST
Vehicle drawn in vehicle list, group list, ...
CompanyID _current_company
Company currently doing an action.
void RefreshScrollbar()
Refresh scrollbar after selection changed.
Class for managing the vehicle details window.
static T Clamp(const T a, const T min, const T max)
Clamp a value between an interval.
static const PaletteID PALETTE_CRASH
Recolour sprite greying of crashed vehicles.
int GetVehicleWidth(const Vehicle *v, EngineImageType image_type)
Get the width of a vehicle (including all parts of the consist) in pixels.
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.
Vehicle * First() const
Get the first vehicle of this vehicle chain.
uint vehicle_margin
Margin to use while selecting vehicles when the vehicle image is centered.
int32 lateness_counter
How many ticks late (or early if negative) this vehicle is.
uint16 cargo_cap
total capacity
bool CanCarryCargo() const
Determines whether an engine can carry something.
void OnPaint() override
Repaint vehicle details window.
static const uint MAX_LENGTH_VEHICLE_NAME_CHARS
The maximum length of a vehicle name in characters including '\0'.
int GetDisplayImageWidth(Point *offset=nullptr) const
Get the width of a road vehicle image in the GUI.
uint32 cached_power
Total power of the consist (valid only for the first engine).
uint16 servint_trains
service interval for trains
void DrawWidget(const Rect &r, int widget) const override
Draw the contents of a nested widget.
GUIVehicleGroupList vehgroups
List of (groups of) vehicles. This stores iterators of vehicles, and should be rebuilt if vehicles is...
@ TDW_TAB_CAPACITY
Tab with cargo capacity of the vehicles.
void ShowReplaceGroupVehicleWindow(GroupID id_g, VehicleType vehicletype)
Show the autoreplace configuration window for a particular group.
void CloseChildWindows(WindowClass wc=WC_INVALID) const
Close all children a window might have in a head-recursive manner.
void OnQueryTextFinished(char *str) override
The query window opened from this window has closed.
static Train * From(Vehicle *v)
Converts a Vehicle to SpecializedVehicle with type checking.
PaletteID GetVehiclePalette(const Vehicle *v)
Get the colour map for a vehicle.
uint8 roadveh_acceleration_model
realistic acceleration for road vehicles
void CDECL SetWidgetsLoweredState(bool lowered_stat, int widgets,...)
Sets the lowered/raised status of a list of widgets.
#define FONT_HEIGHT_NORMAL
Height of characters in the normal (FS_NORMAL) font.
VehicleType vtype
The vehicle type associated with this list.
Vehicle * GetFirstEnginePart()
Get the first part of an articulated engine.
static ZoomLevel ScaleZoomGUI(ZoomLevel value)
Scale zoom level relative to GUI zoom.
@ VIWD_AUTOREPLACE
Autoreplace replaced the vehicle.
bool CDECL FilterFunction(const GUIVehicleGroup *, CargoID)
Signature of filter function.
uint32 PaletteID
The number of the palette.
@ AIR_HELICOPTER
an helicopter
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.
VehicleID vehicle_sel
Selected vehicle.
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.
EventState OnHotkey(int hotkey) override
A hotkey has been pressed.
Listing GetListing() const
Export current sort conditions.
@ OWNER_NONE
The tile has no ownership.
VehicleListType type
The type of vehicle list.
void CDECL SetWidgetsDisabledState(bool disab_stat, int widgets,...)
Sets the enabled/disabled status of a list of widgets.
bool IsWidgetLowered(byte widget_index) const
Gets the lowered state of a widget.
void CcCloneVehicle(Commands cmd, const CommandCost &result, VehicleID veh_id)
This is the Callback method after the cloning attempt of a vehicle.
@ NUM_CARGO
Maximal number of cargo types in a game.
uint16 servint_aircraft
service interval for aircraft
static StationID GetStationIndex(TileIndex t)
Get StationID from a tile.
bool HasArticulatedPart() const
Check if an engine has an articulated part.
EventState
State of handling an event.
static bool VehicleNumberSorter(const Vehicle *const &a, const Vehicle *const &b)
Sort vehicles by their number.
void SetStringParameters(int widget) const override
Initialize string parameters for a widget.
static const int DAYS_IN_YEAR
days per year
static bool VehicleCargoSorter(const Vehicle *const &a, const Vehicle *const &b)
Sort vehicles by their cargo.
bool IsNewGRFInspectable() const override
Is the data related to this window NewGRF inspectable?
StringID name
Name of this type of cargo.
bool Filter(FilterFunction *decide, F filter_data)
Filter the list.
@ WC_MAIN_WINDOW
Main window; Window numbers:
void FinishInitNested(WindowNumber window_number=0)
Perform the second part of the initialization of a nested widget tree.
static const NWidgetPart _nested_vehicle_view_widgets[]
Vehicle view widgets.
UnitID unitnumber
unit number, for display purposes only
static bool VehicleTimeToLiveSorter(const Vehicle *const &a, const Vehicle *const &b)
Sort vehicles by the time they can still live.
uint16 cached_max_speed
Maximum speed of the consist (minimum of the max speed of all vehicles in the consist).
void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
Update size and resize step of a widget in the window.
uint ShowRefitOptionsList(int left, int right, int y, EngineID engine)
Display list of cargo types of the engine, for the purchase information window.
void ForceResort()
Force a resort next Sort call Reset the resort timer if used too.
@ ZOOM_LVL_TRAIN
Default zoom level for the train view.
uint32 VehicleID
The type all our vehicle IDs have.
Window manager class for viewing a vehicle.
void InvalidateNewGRFCache()
Invalidates cached NewGRF variables.
void DrawWidget(const Rect &r, int widget) const override
Draw the contents of a nested widget.
static VehicleListIdentifier UnPack(uint32 data)
Decode a packed vehicle list identifier into a new one.
byte subtype
subtype (Filled with values from AircraftSubType/DisasterSubType/EffectVehicleType/GroundVehicleSubty...
Order * GetFirstOrder() const
Get the first order of the order chain.
VehicleID follow_vehicle
VehicleID to follow if following a vehicle, INVALID_VEHICLE otherwise.
void ShowVehicleViewWindow(const Vehicle *v)
Shows the vehicle view window of the given vehicle.
void ForceRebuild()
Force that a rebuild is needed.
static int CenterBounds(int min, int max, int size)
Determine where to draw a centred object inside a widget.
VehicleList vehicles
List of vehicles. This is the buffer for vehgroups to point into; if this is structurally modified,...
@ SA_CENTER
Center both horizontally and vertically.
#define Debug(name, level, format_string,...)
Ouptut a line of debugging information.
PalSpriteID sprite_seq[16]
current image of cursor
void DrawShipImage(const Vehicle *v, const Rect &r, VehicleID selection, EngineImageType image_type)
Draws an image of a ship.
static T SetBit(T &x, const uint8 y)
Set a bit in a variable.
#define lengthof(x)
Return the length of an fixed size array.
int width
width of the window (number of pixels to the right in x direction)
ZoomLevel zoom
The zoom level of the viewport.
static int SortButtonWidth()
Get width of up/down arrow of sort button state.
void OnMouseDrag(Point pt, int widget) override
An 'object' is being dragged at the provided position, highlight the target if possible.
@ VF_PATHFINDER_LOST
Vehicle's pathfinder is lost.
WindowClass window_class
The WindowClass of the window that is responsible for the selection mode.
CargoID cargo
Cargo to refit to.
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 bool VehicleNameSorter(const Vehicle *const &a, const Vehicle *const &b)
Sort vehicles by their name.
byte CargoID
Cargo slots to indicate a cargo type within a game.
bool IsStoppedInDepot() const
Check whether the vehicle is in the depot and stopped.
void CloseWindowById(WindowClass cls, WindowNumber number, bool force)
Close a window by its class and window number (if it is open).
static uint ToPercent16(uint i)
Converts a "fract" value 0..65535 to "percent" value 0..100.
static void MemSetT(T *ptr, byte value, size_t num=1)
Type-safe version of memset().
@ TFP_SIGNAL
Ignore next signal, after the signal ignore being stuck.
void OnInvalidateData(int data=0, bool gui_scope=true) override
Some data on this window has become invalid.
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...
void DrawVehicleImage(const Vehicle *v, const Rect &r, VehicleID selection, EngineImageType image_type, int skip)
Draws an image of a vehicle chain.
uint16 servint_roadveh
service interval for road vehicles
int vehicle_width
Width of the vehicle being drawn.
int strnatcmp(const char *s1, const char *s2, bool ignore_garbage_at_front)
Compares two strings using case insensitive natural sort.
CargoID cargo_type
type of cargo this vehicle is carrying
void OnDragDrop(Point pt, int widget) override
A dragged 'object' has been released.
bool IsNewGRFInspectable(GrfSpecFeature feature, uint index)
Can we inspect the data given a certain feature and index.
void DrawWidget(const Rect &r, int widget) const override
Draw the contents of a nested widget.
static const uint MAX_REFIT_CYCLE
Maximum number of refit cycles we try, to prevent infinite loops.
TileIndex GetLocation(const Vehicle *v, bool airport=false) const
Returns a tile somewhat representing the order destination (not suitable for pathfinding).
static bool VehicleIndividualToGroupSorterWrapper(GUIVehicleGroup const &a, GUIVehicleGroup const &b)
Wrapper to convert a VehicleIndividualSortFunction to a VehicleGroupSortFunction.
static const CursorID SPR_CURSOR_MOUSE
Cursor sprite numbers.
PaletteID pal
The palette (use PAL_NONE) if not needed)
byte unitnumber_digits
The number of digits of the highest unit number.
uint8 advanced_vehicle_list
use the "advanced" vehicle list
VehicleSettings vehicle
options for vehicles
void ErrorUnknownCallbackResult(uint32 grfid, uint16 cbid, uint16 cb_res)
Record that a NewGRF returned an unknown/invalid callback result.
byte cargo_subtype
Used for livery refits (NewGRF variations)
StringID cargo_filter_texts[NUM_CARGO+4]
Texts for filter_cargo, terminated by INVALID_STRING_ID.
bool IsEngineRefittable(EngineID engine)
Check if an engine is refittable.
@ CF_NONE
Show only vehicles which do not carry cargo (e.g. train engines)
Data structure for an opened window.
void RebuildDone()
Notify the sortlist that the rebuild is done.
@ VEH_TRAIN
Train vehicle type.
static bool IsValidID(size_t index)
Tests whether given index can be used to get valid (non-nullptr) Titem.
void DrawAircraftImage(const Vehicle *v, const Rect &r, VehicleID selection, EngineImageType image_type)
Draws an image of an aircraft.
Order * GetOrder(int index) const
Returns order 'index' of a vehicle or nullptr when it doesn't exists.
VehicleType type
Type of vehicle.
void DrawWidgets() const
Paint all widgets of a window.
void BuildRefitList()
Collects all (cargo, subcargo) refit options of a vehicle chain.
@ ZOOM_LVL_OUT_4X
Zoomed 4 times out.
uint16 reliability
Reliability.
@ DC_QUERY_COST
query cost only, don't build.
static bool VehicleProfitLastYearSorter(const Vehicle *const &a, const Vehicle *const &b)
Sort vehicles by last year profit.
static void DrawVehicleProfitButton(Date age, Money display_profit_last_year, uint num_vehicles, int x, int y)
draw the vehicle profit button in the vehicle list window.
int Width() const
Get width of Rect.
Dimension GetScaledSpriteSize(SpriteID sprid)
Scale sprite size for GUI.
static bool IsCargoInClass(CargoID c, CargoClass cc)
Does cargo c have cargo class cc?
void SetWidgetDirty(byte widget_index) const
Invalidate a widget, i.e.
@ VEH_SHIP
Ship vehicle type.
RefitOption * cargo
Refit option selected by sel.
Specification of a rectangle with absolute coordinates of all edges.
void LowerWidget(byte widget_index)
Marks a widget as lowered.
@ WC_DROPDOWN_MENU
Drop down menu; Window numbers:
OrderList * orders
Pointer to the order list for this vehicle.
void GetBounds(Rect *bounds) const
Determine shared bounds of all sprites.
OrderDepotActionFlags GetDepotActionType() const
What are we going to do when in the depot.
void ShowVehicleRefitWindow(const Vehicle *v, VehicleOrderID order, Window *parent, bool auto_refit)
Show the refit window for a vehicle.
@ QSF_ENABLE_DEFAULT
enable the 'Default' button ("\0" is returned)
void OnInit() override
Notification that the nested widget tree gets initialized.
#define lastof(x)
Get the last element of an fixed size array.
Order * next
Pointer to next order. If nullptr, end of list.
void SetSelection(uint click_row)
Select a row.
uint32 cached_weight
Total weight of the consist (valid only for the first engine).
void SetWidgetLoweredState(byte widget_index, bool lowered_stat)
Sets the lowered/raised status of a widget.
StringID GetCapacityString(RefitOption *option) const
Gets the StringID to use for displaying capacity.
StringID GetAircraftTypeText() const
Get the name of the aircraft type for display purposes.
@ TD_RTL
Text is written right-to-left by default.
static const int DAY_TICKS
1 day is 74 ticks; _date_fract used to be uint16 and incremented by 885.
TextDirection _current_text_dir
Text direction of the currently selected language.
Money GetDisplayProfitLastYear() const
Gets the profit vehicle had last year.
void OnGameTick() override
Called once per (game) tick.
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...
Option to refit a vehicle chain.
static bool VehicleReliabilitySorter(const Vehicle *const &a, const Vehicle *const &b)
Sort vehicles by their reliability.
static DepotID GetDepotIndex(TileIndex t)
Get the index of which depot is attached to the tile.
static const StringID _vehicle_msg_translation_table[][4]
Command codes for the shared buttons indexed by VehicleCommandTranslation and vehicle type.
VehicleList::const_iterator vehicles_end
Pointer to past-the-end element of this vehicle group.
int GetTrainDetailsWndVScroll(VehicleID veh_id, TrainDetailsWindowTabs det_tab)
Determines the number of lines in the train details window.
static const StringID INVALID_STRING_ID
Constant representing an invalid string (16bit in case it is used in savegames)
@ WC_VEHICLE_ORDERS
Vehicle orders; Window numbers:
GUISettings gui
settings related to the GUI
@ FR_BORDERONLY
Draw border only, no background.
Date date_of_last_service
Last date the vehicle had a service at a depot.
Window * GetCallbackWnd()
Get the window that started the current highlighting.
void SetSortFuncs(SortFunction *const *n_funcs)
Hand the array of sort function pointers to the sort list.
static const int VEHICLE_PROFIT_MIN_AGE
Only vehicles older than this have a meaningful profit.
static const Money VEHICLE_PROFIT_THRESHOLD
Threshold for a vehicle to be considered making good profit.
static TileIndex TileVirtXY(uint x, uint y)
Get a tile from the virtual XY-coordinate.
All data for a single hotkey.
void DrawTrainImage(const Train *v, const Rect &r, VehicleID selection, EngineImageType image_type, int skip, VehicleID drag_dest)
Draws an image of a whole train.
void OnResize() override
Called after the window got resized.
@ TDW_TAB_CARGO
Tab with cargo carried by the vehicles.
RefitOption * GetRefitOption()
Gets the RefitOption placed in the selected index.
void DrawTrainDetails(const Train *v, const Rect &r, int vscroll_pos, uint16 vscroll_cap, TrainDetailsWindowTabs det_tab)
Draw the details for the given vehicle at the given position.
std::vector< RefitOption > SubtypeList
List of refit subtypes associated to a cargo.
static const NWidgetPart _nested_train_vehicle_details_widgets[]
Train details widgets.
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,...
virtual void Close()
Hide the window and all its child windows, and mark them for a later deletion.
virtual void GetImage(Direction direction, EngineImageType image_type, VehicleSpriteSeq *result) const
Gets the sprite to show for the given direction.