Go to the documentation of this file.
44 Sorting _sorting[BaseVehicleListWindow::GB_END];
48 static BaseVehicleListWindow::VehicleIndividualSortFunction
VehicleAgeSorter;
66 template <BaseVehicleListWindow::VehicleIndiv
idualSortFunction func>
72 BaseVehicleListWindow::VehicleGroupSortFunction *
const BaseVehicleListWindow::vehicle_group_none_sorter_funcs[] = {
73 &VehicleIndividualToGroupSorterWrapper<VehicleNumberSorter>,
74 &VehicleIndividualToGroupSorterWrapper<VehicleNameSorter>,
75 &VehicleIndividualToGroupSorterWrapper<VehicleAgeSorter>,
76 &VehicleIndividualToGroupSorterWrapper<VehicleProfitThisYearSorter>,
77 &VehicleIndividualToGroupSorterWrapper<VehicleProfitLastYearSorter>,
78 &VehicleIndividualToGroupSorterWrapper<VehicleCargoSorter>,
79 &VehicleIndividualToGroupSorterWrapper<VehicleReliabilitySorter>,
80 &VehicleIndividualToGroupSorterWrapper<VehicleMaxSpeedSorter>,
81 &VehicleIndividualToGroupSorterWrapper<VehicleModelSorter>,
82 &VehicleIndividualToGroupSorterWrapper<VehicleValueSorter>,
83 &VehicleIndividualToGroupSorterWrapper<VehicleLengthSorter>,
84 &VehicleIndividualToGroupSorterWrapper<VehicleTimeToLiveSorter>,
85 &VehicleIndividualToGroupSorterWrapper<VehicleTimetableDelaySorter>,
88 const StringID BaseVehicleListWindow::vehicle_group_none_sorter_names[] = {
92 STR_SORT_BY_PROFIT_THIS_YEAR,
93 STR_SORT_BY_PROFIT_LAST_YEAR,
94 STR_SORT_BY_TOTAL_CAPACITY_PER_CARGOTYPE,
95 STR_SORT_BY_RELIABILITY,
96 STR_SORT_BY_MAX_SPEED,
100 STR_SORT_BY_LIFE_TIME,
101 STR_SORT_BY_TIMETABLE_DELAY,
105 BaseVehicleListWindow::VehicleGroupSortFunction *
const BaseVehicleListWindow::vehicle_group_shared_orders_sorter_funcs[] = {
113 const StringID BaseVehicleListWindow::vehicle_group_shared_orders_sorter_names[] = {
114 STR_SORT_BY_NUM_VEHICLES,
115 STR_SORT_BY_TOTAL_PROFIT_THIS_YEAR,
116 STR_SORT_BY_TOTAL_PROFIT_LAST_YEAR,
117 STR_SORT_BY_AVERAGE_PROFIT_THIS_YEAR,
118 STR_SORT_BY_AVERAGE_PROFIT_LAST_YEAR,
122 const StringID BaseVehicleListWindow::vehicle_group_by_names[] = {
124 STR_GROUP_BY_SHARED_ORDERS,
128 const StringID BaseVehicleListWindow::vehicle_depot_name[] = {
129 STR_VEHICLE_LIST_SEND_TRAIN_TO_DEPOT,
130 STR_VEHICLE_LIST_SEND_ROAD_VEHICLE_TO_DEPOT,
131 STR_VEHICLE_LIST_SEND_SHIP_TO_DEPOT,
132 STR_VEHICLE_LIST_SEND_AIRCRAFT_TO_HANGAR
137 this->grouping = _grouping[vli.type][vli.vtype];
138 this->UpdateSortingFromGrouping();
148 if (number >= 10000)
return 5;
149 if (number >= 1000)
return 4;
150 if (number >= 100)
return 3;
168 for (
const Vehicle *v : vehicles) {
169 unitnumber = std::max<uint>(unitnumber, v->unitnumber);
175 void BaseVehicleListWindow::BuildVehicleList()
179 DEBUG(misc, 3,
"Building vehicle list type %d for company %d given index %d", this->
vli.
type, this->vli.company, this->vli.index);
186 uint max_unitnumber = 0;
187 for (
auto it = this->
vehicles.begin(); it != this->vehicles.end(); ++it) {
188 this->
vehgroups.emplace_back(it, it + 1);
190 max_unitnumber = std::max<uint>(max_unitnumber, (*it)->unitnumber);
195 std::stable_sort(this->
vehicles.begin(), this->vehicles.end(), [](
const Vehicle *
const &u,
const Vehicle *
const &v) {
196 return u->FirstShared() < v->FirstShared();
199 uint max_num_vehicles = 0;
201 VehicleList::const_iterator begin = this->
vehicles.begin();
202 while (begin != this->
vehicles.end()) {
203 VehicleList::const_iterator end = std::find_if_not(begin, this->
vehicles.cend(), [first_shared = (*begin)->FirstShared()](
const Vehicle *
const &v) {
204 return v->FirstShared() == first_shared;
207 this->
vehgroups.emplace_back(begin, end);
209 max_num_vehicles = std::max<uint>(max_num_vehicles,
static_cast<uint
>(end - begin));
258 if (show_autoreplace) list.emplace_back(
new DropDownListStringItem(STR_VEHICLE_LIST_REPLACE_VEHICLES, ADI_REPLACE,
false));
271 static const Vehicle *_last_vehicle[2] = {
nullptr,
nullptr };
273 void BaseVehicleListWindow::SortVehicleList()
278 _last_vehicle[0] = _last_vehicle[1] =
nullptr;
283 if (list->size() < 2)
return;
295 }
else if (display_profit_last_year < 0) {
296 spr = SPR_PROFIT_NEGATIVE;
298 spr = SPR_PROFIT_SOME;
300 spr = SPR_PROFIT_LOT;
323 static std::vector<StringID> subtypes;
331 byte ret_refit_cyc = 0;
332 bool success =
false;
333 if (subtypes.size() > 0) {
336 const Engine *e = v->GetEngine();
338 if (!
HasBit(e->info.refit_mask, dest_cargo_type) && v->cargo_type != dest_cargo_type)
continue;
340 CargoID old_cargo_type = v->cargo_type;
341 byte old_cargo_subtype = v->cargo_subtype;
344 v->cargo_type = dest_cargo_type;
348 v->cargo_subtype = refit_cyc;
351 v->First()->InvalidateNewGRFCache();
352 v->InvalidateNewGRFCache();
355 if (subtype == STR_EMPTY)
break;
357 if (std::find(subtypes.begin(), subtypes.end(), subtype) == subtypes.end())
continue;
360 ret_refit_cyc = refit_cyc;
366 v->cargo_type = old_cargo_type;
367 v->cargo_subtype = old_cargo_subtype;
370 v->First()->InvalidateNewGRFCache();
371 v->InvalidateNewGRFCache();
377 return ret_refit_cyc;
432 int textleft = r.left +
WD_MATRIX_LEFT + (rtl ? 0 : iconwidth + 4);
436 for (uint i = 0; current < pos + rows && i <
NUM_CARGO; i++) {
437 for (uint j = 0; current < pos + rows && j < list[i].size(); j++) {
441 if (sel[0] != (
int)i && refit.
subtype != 0xFF)
continue;
449 if (list[i].size() > 1) {
453 GfxDrawLine(iconcenter, y -
WD_MATRIX_TOP, iconcenter, j == list[i].size() - 1 ? ycenter : y -
WD_MATRIX_TOP + delta - 1, linecolour);
454 GfxDrawLine(iconcenter, ycenter, iconinner, ycenter, linecolour);
461 TextColour colour = (sel[0] == (int)i && (uint)sel[1] == j) ? TC_WHITE : TC_BLACK;
465 DrawString(textleft, textright, y, STR_JUST_STRING_STRING, colour);
496 for (uint i = 0; i <
NUM_CARGO; i++) this->list[i].clear();
500 VehicleSet vehicles_to_refit;
504 if (v->
type ==
VEH_TRAIN && std::find(vehicles_to_refit.begin(), vehicles_to_refit.end(), v->
index) == vehicles_to_refit.end())
continue;
506 CargoTypes cmask = e->info.refit_mask;
515 int current_index = 0;
520 if (!
HasBit(cmask, cid)) {
525 bool first_vehicle = this->list[current_index].size() == 0;
528 this->list[current_index].push_back({cid, 0xFF, STR_EMPTY});
554 if (subtype == STR_EMPTY)
break;
560 include(this->list[current_index], option);
563 if (subtype == STR_EMPTY) {
567 for (uint i = 1; i < l.size(); i++) {
568 if (l[i].subtype >= refit_cyc) {
578 while (pos < l.size() && l[pos].subtype != refit_cyc) pos++;
579 if (pos < l.size() && l[pos].string != subtype) {
581 l.erase(l.begin() + pos);
609 for (uint j = 0; j < this->list[i].size(); j++) {
613 if (this->sel[0] != (
int)i && refit.
subtype != 0xFF)
continue;
615 if (this->sel[0] == (
int)i && (uint)this->sel[1] == j) scroll_row = row;
622 if (scroll_row < row) this->vscroll->
ScrollTowards(scroll_row);
634 for (uint j = 0; j < this->list[i].size(); j++) {
638 if (this->sel[0] != (
int)i && refit.
subtype != 0xFF)
continue;
640 if (row == click_row) {
660 if (this->sel[0] < 0)
return nullptr;
663 if ((uint)this->sel[1] >= l.size())
return nullptr;
665 return &l[this->sel[1]];
679 this->GetWidget<NWidgetCore>(
WID_VR_MATRIX)->tool_tip = STR_REFIT_TRAIN_LIST_TOOLTIP + v->
type;
682 nwi->
tool_tip = STR_REFIT_TRAIN_REFIT_TOOLTIP + v->
type;
694 if (this->cargo !=
nullptr) {
702 this->cargo =
nullptr;
703 for (uint i = 0; this->cargo ==
nullptr && i <
NUM_CARGO; i++) {
704 for (uint j = 0; j <
list[i].size(); j++) {
705 if (
list[i][j] == current_refit_option) {
708 this->cargo = &
list[i][j];
725 if (this->hscroll !=
nullptr) this->hscroll->
SetCount(this->vehicle_width);
729 int sprite_width = std::max(0, ((
int)vehicle_panel_display->
current_x - this->vehicle_width) / 2);
730 this->sprite_left = vehicle_panel_display->
pos_x;
731 this->sprite_right = vehicle_panel_display->
pos_x + vehicle_panel_display->
current_x - 1;
733 this->sprite_right -= sprite_width;
736 this->sprite_left += sprite_width;
748 size->height =
resize->height * 8;
790 return STR_PURCHASE_INFO_AIRCRAFT_CAPACITY;
791 }
else if (money <= 0) {
793 return STR_REFIT_NEW_CAPACITY_INCOME_FROM_AIRCRAFT_REFIT;
796 return STR_REFIT_NEW_CAPACITY_COST_OF_AIRCRAFT_REFIT;
802 return STR_PURCHASE_INFO_CAPACITY;
803 }
else if (money <= 0) {
805 return STR_REFIT_NEW_CAPACITY_INCOME_FROM_REFIT;
808 return STR_REFIT_NEW_CAPACITY_COST_OF_REFIT;
826 VehicleSet vehicles_to_refit;
829 int left = INT32_MIN;
834 const bool contained = std::find(vehicles_to_refit.begin(), vehicles_to_refit.end(), u->index) != vehicles_to_refit.end();
835 if (contained &&
left == INT32_MIN) {
841 if ((!contained || u->Next() ==
nullptr) &&
left != INT32_MIN) {
842 if (u->Next() ==
nullptr && contained) {
843 int current_width = u->GetDisplayImageWidth();
844 width += current_width;
863 int current_width = u->GetDisplayImageWidth();
864 width += current_width;
880 if (this->cargo !=
nullptr) {
903 this->selected_vehicle = v->
index;
904 this->num_vehicles = UINT8_MAX;
909 if (!gui_scope)
break;
918 for (uint j = 0; j < this->list[i].size(); j++) {
922 max_width = std::max(dim.width, max_width);
927 if (this->information_width < max_width) {
928 this->information_width = max_width;
935 if (!gui_scope)
break;
942 int GetClickPosition(
int click_x)
952 void SetSelectedVehicles(
int drag_x)
954 drag_x = GetClickPosition(drag_x);
956 int left_x = std::min(this->click_x, drag_x);
957 int right_x = std::max(this->click_x, drag_x);
958 this->num_vehicles = 0;
967 bool start_counting =
false;
968 for (; u !=
nullptr; u = u->
Next()) {
970 left_x -= current_width;
971 right_x -= current_width;
973 if (left_x < 0 && !start_counting) {
974 this->selected_vehicle = u->
index;
975 start_counting =
true;
978 this->num_vehicles++;
981 this->num_vehicles++;
984 if (right_x < 0)
break;
989 if (this->num_vehicles != 0) {
998 this->selected_vehicle = v->
index;
999 this->num_vehicles = UINT8_MAX;
1010 this->click_x = GetClickPosition(pt.x - nwi->
pos_x);
1011 this->SetSelectedVehicles(pt.x - nwi->
pos_x);
1027 if (click_count == 1)
break;
1032 if (this->cargo !=
nullptr) {
1036 bool delete_window = this->selected_vehicle == v->
index && this->num_vehicles == UINT8_MAX;
1037 if (
DoCommandP(v->
tile, this->selected_vehicle, this->cargo->cargo | this->cargo->subtype << 8 | this->num_vehicles << 16, GetCmdRefitVeh(v)) && delete_window)
delete this;
1052 this->SetSelectedVehicles(pt.x - nwi->
pos_x);
1065 this->SetSelectedVehicles(pt.x - nwi->
pos_x);
1080 static const NWidgetPart _nested_vehicle_refit_widgets[] = {
1096 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),
1107 WDP_AUTO,
"view_vehicle_refit", 240, 174,
1110 _nested_vehicle_refit_widgets,
lengthof(_nested_vehicle_refit_widgets)
1138 if (cmask == lmask) {
1140 SetDParam(0, STR_PURCHASE_INFO_ALL_TYPES);
1146 SetDParam(0, STR_PURCHASE_INFO_ALL_BUT);
1175 return a.NumVehicles() < b.NumVehicles();
1181 return a.GetDisplayProfitThisYear() < b.GetDisplayProfitThisYear();
1187 return a.GetDisplayProfitLastYear() < b.GetDisplayProfitLastYear();
1193 return a.GetDisplayProfitThisYear() *
static_cast<uint
>(b.NumVehicles()) < b.GetDisplayProfitThisYear() *
static_cast<uint
>(a.NumVehicles());
1199 return a.GetDisplayProfitLastYear() *
static_cast<uint
>(b.NumVehicles()) < b.GetDisplayProfitLastYear() *
static_cast<uint
>(a.NumVehicles());
1211 static char last_name[2][64];
1213 if (a != _last_vehicle[0]) {
1214 _last_vehicle[0] = a;
1216 GetString(last_name[0], STR_VEHICLE_NAME,
lastof(last_name[0]));
1219 if (b != _last_vehicle[1]) {
1220 _last_vehicle[1] = b;
1222 GetString(last_name[1], STR_VEHICLE_NAME,
lastof(last_name[1]));
1225 int r =
strnatcmp(last_name[0], last_name[1]);
1296 for (u = a; u !=
nullptr; u = u->
Next()) diff += u->
value;
1297 for (u = b; u !=
nullptr; u = u->
Next()) diff -= u->
value;
1324 void InitializeGUI()
1368 static const NWidgetPart _nested_vehicle_list[] = {
1390 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),
1398 SetDataTip(STR_BLACK_STRING, STR_VEHICLE_LIST_AVAILABLE_ENGINES_TOOLTIP),
1401 SetDataTip(STR_VEHICLE_LIST_MANAGE_LIST, STR_VEHICLE_LIST_MANAGE_LIST_TOOLTIP),
1403 SetDataTip(SPR_FLAG_VEH_STOPPED, STR_VEHICLE_LIST_MASS_STOP_LIST_TOOLTIP),
1405 SetDataTip(SPR_FLAG_VEH_RUNNING, STR_VEHICLE_LIST_MASS_START_LIST_TOOLTIP),
1417 if (order ==
nullptr)
return;
1420 int l_offset = rtl ? 0 : order_arrow_width;
1421 int r_offset = rtl ? order_arrow_width : 0;
1428 if (order->
IsType(OT_GOTO_STATION)) {
1430 DrawString(left + l_offset, right - r_offset, y, STR_TINY_BLACK_STATION);
1433 if (++i == 4)
break;
1437 order = order->
next;
1438 if (order ==
nullptr) {
1442 }
while (oid != start);
1449 int l_offset = rtl ? 0 : order_arrow_width;
1450 int r_offset = rtl ? order_arrow_width : 0;
1452 while (order !=
nullptr) {
1453 if (order->
IsType(OT_GOTO_STATION)) {
1455 DrawString(left + l_offset, right - r_offset, y, STR_TINY_BLACK_STATION);
1458 if (++i == 4)
break;
1460 order = order->
next;
1480 default: NOT_REACHED();
1497 if (divisor == 1)
return base;
1500 uint rem = base % divisor;
1501 return base + (rem == 0 ? 0 : divisor - rem);
1518 int text_left =
left + (rtl ? 0 : text_offset);
1519 int text_right = right - (rtl ? text_offset : 0);
1523 int orderlist_right = right - (rtl ? std::max(
ScaleGUITrad(100) + text_offset,
width / 2) : 0);
1525 int image_left = (rtl && show_orderlist) ? orderlist_right : text_left;
1526 int image_right = (!rtl && show_orderlist) ? orderlist_left : text_right;
1528 int vehicle_button_x = rtl ? right -
GetSpriteSize(SPR_PROFIT_LOT).width :
left;
1531 uint max =
static_cast<uint
>(std::min<size_t>(this->vscroll->
GetPosition() + this->vscroll->GetCapacity(), this->vehgroups.size()));
1532 for (uint i = this->vscroll->
GetPosition(); i < max; ++i) {
1536 SetDParam(0, vehgroup.GetDisplayProfitThisYear());
1537 SetDParam(1, vehgroup.GetDisplayProfitLastYear());
1544 const Vehicle *v = vehgroup.GetSingleVehicle();
1548 if (!v->
name.empty()) {
1551 DrawString(text_left, text_right, y, STR_TINY_BLACK_VEHICLE);
1555 DrawString(text_left, text_right, y, STR_TINY_GROUP, TC_BLACK);
1562 str = STR_BLUE_COMMA;
1572 case GB_SHARED_ORDERS:
1573 assert(vehgroup.NumVehicles() > 0);
1575 for (
int i = 0; i < static_cast<int>(vehgroup.NumVehicles()); ++i) {
1576 if (image_left + 8 * i >= image_right)
break;
1594 void BaseVehicleListWindow::UpdateSortingFromGrouping()
1604 default: NOT_REACHED();
1612 void BaseVehicleListWindow::UpdateVehicleGroupBy(GroupBy group_by)
1621 this->UpdateSortingFromGrouping();
1649 this->BuildVehicleList();
1650 this->SortVehicleList();
1653 this->GetWidget<NWidgetCore>(
WID_VL_LIST)->tool_tip = STR_VEHICLE_LIST_TRAIN_LIST_TOOLTIP + this->
vli.
vtype;
1655 if (this->
vli.
type == VL_SHARED_ORDERS) {
1656 this->GetWidget<NWidgetCore>(
WID_VL_CAPTION)->widget_data = STR_VEHICLE_LIST_SHARED_ORDERS_LIST_CAPTION;
1662 this->GetWidget<NWidgetCore>(
WID_VL_CAPTION)->widget_data = STR_VEHICLE_LIST_TRAIN_CAPTION + this->
vli.
vtype;
1683 size->height = 6 *
resize->height;
1687 size->height = 4 *
resize->height;
1689 default: NOT_REACHED();
1696 d.height += padding.height;
1697 *size =
maxdim(*size, d);
1703 d.height += padding.height;
1704 d.width += padding.width;
1705 *size =
maxdim(*size, d);
1720 case VL_SHARED_ORDERS:
1735 case VL_STATION_LIST:
1747 default: NOT_REACHED();
1770 this->BuildVehicleList();
1771 this->SortVehicleList();
1822 if (id_v >= this->
vehgroups.size())
return;
1827 const Vehicle *v = vehgroup.GetSingleVehicle();
1838 case GB_SHARED_ORDERS: {
1839 assert(vehgroup.NumVehicles() > 0);
1843 if (vehgroup.NumVehicles() == 1) {
1846 ShowVehicleListWindow(v);
1851 default: NOT_REACHED();
1877 this->UpdateVehicleGroupBy(
static_cast<GroupBy
>(index));
1885 assert(this->
vehicles.size() != 0);
1896 default: NOT_REACHED();
1900 default: NOT_REACHED();
1908 StationID station = (this->
vli.
type == VL_STATION_LIST) ? this->
vli.
index : INVALID_STATION;
1910 DEBUG(misc, 3,
"Periodic resort %d list company %d at station %d", this->
vli.
vtype, this->owner, station);
1927 if (!gui_scope &&
HasBit(data, 31) && this->
vli.
type == VL_SHARED_ORDERS) {
1930 this->window_number = this->
vli.
Pack();
1945 WDP_AUTO,
"list_vehicles", 260, 246,
1948 _nested_vehicle_list,
lengthof(_nested_vehicle_list)
1952 WDP_AUTO,
"list_vehicles_train", 325, 246,
1955 _nested_vehicle_list,
lengthof(_nested_vehicle_list)
1964 AllocateWindowDescFront<VehicleListWindow>(&_vehicle_list_train_desc, num);
1967 AllocateWindowDescFront<VehicleListWindow>(&_vehicle_list_other_desc, num);
1981 ShowVehicleListWindowLocal(company, VL_STANDARD, vehicle_type, company);
1985 void ShowVehicleListWindow(
const Vehicle *v)
1992 ShowVehicleListWindowLocal(company, VL_STATION_LIST, vehicle_type, station);
1997 uint16 depot_airport_index;
2004 ShowVehicleListWindowLocal(company, VL_DEPOT_LIST, vehicle_type, depot_airport_index);
2032 SetDataTip(STR_EMPTY, STR_SERVICE_INTERVAL_DROPDOWN_TOOLTIP),
2049 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),
2058 SetDataTip(STR_EMPTY, STR_SERVICE_INTERVAL_DROPDOWN_TOOLTIP),
2065 SetDataTip(STR_VEHICLE_DETAIL_TAB_INFORMATION, STR_VEHICLE_DETAILS_TRAIN_INFORMATION_TOOLTIP),
SetFill(1, 0),
SetResize(1, 0),
2069 SetDataTip(STR_VEHICLE_DETAIL_TAB_TOTAL_CARGO, STR_VEHICLE_DETAILS_TRAIN_TOTAL_CARGO_TOOLTIP),
SetFill(1, 0),
SetResize(1, 0),
2081 static StringID _service_interval_dropdown[] = {
2082 STR_VEHICLE_DETAILS_DEFAULT,
2083 STR_VEHICLE_DETAILS_DAYS,
2084 STR_VEHICLE_DETAILS_PERCENT,
2118 if (!gui_scope)
return;
2124 if (aimed_height != nwid_info->
current_y) {
2137 uint desired_height;
2142 for (
const Vehicle *u = v; u !=
nullptr; u = u->
Next()) {
2148 return desired_height;
2159 static const StringID info_strings[] = {
2160 STR_VEHICLE_INFO_MAX_SPEED,
2161 STR_VEHICLE_INFO_WEIGHT_POWER_MAX_SPEED,
2162 STR_VEHICLE_INFO_WEIGHT_POWER_MAX_SPEED_MAX_TE,
2163 STR_VEHICLE_INFO_PROFIT_THIS_YEAR_LAST_YEAR,
2164 STR_VEHICLE_INFO_RELIABILITY_BREAKDOWNS
2166 for (uint i = 0; i <
lengthof(info_strings); i++) {
2198 size->height = 4 *
resize->height;
2202 StringID *strs = _service_interval_dropdown;
2206 size->width += padding.width;
2214 size->width = std::max(
2227 switch (vehicle_type) {
2228 default: NOT_REACHED();
2254 default: NOT_REACHED();
2273 SetDParam(0, (v->
age + DAYS_IN_YEAR < v->max_age) ? STR_VEHICLE_INFO_AGE : STR_VEHICLE_INFO_AGE_RED);
2290 string = STR_VEHICLE_INFO_WEIGHT_POWER_MAX_SPEED;
2292 string = STR_VEHICLE_INFO_WEIGHT_POWER_MAX_SPEED_MAX_TE;
2300 string = STR_VEHICLE_INFO_MAX_SPEED_TYPE_RANGE;
2302 string = STR_VEHICLE_INFO_MAX_SPEED_TYPE;
2305 string = STR_VEHICLE_INFO_MAX_SPEED;
2334 uint text_left = r.left + (rtl ? 0 : sprite_width);
2335 uint text_right = r.right - (rtl ? sprite_width : 0);
2341 uint sprite_left = rtl ? text_right : r.left;
2342 uint sprite_right = rtl ? r.right : text_left;
2355 v->ServiceIntervalIsPercent() ? STR_VEHICLE_DETAILS_SERVICING_INTERVAL_PERCENT : STR_VEHICLE_DETAILS_SERVICING_INTERVAL_DAYS);
2376 StringID str = v->ServiceIntervalIsCustom() ?
2377 (v->ServiceIntervalIsPercent() ? STR_VEHICLE_DETAILS_PERCENT : STR_VEHICLE_DETAILS_DAYS) :
2378 STR_VEHICLE_DETAILS_DEFAULT;
2394 if (mod == v->GetServiceInterval())
return;
2402 ShowDropDownMenu(
this, _service_interval_dropdown, v->ServiceIntervalIsCustom() ? (v->ServiceIntervalIsPercent() ? 2 : 1) : 0, widget, 0, 0);
2429 bool iscustom = index != 0;
2430 bool ispercent = iscustom ? (index == 2) :
Company::Get(v->
owner)->settings.vehicle.servint_ispercent;
2441 if (nwi !=
nullptr) {
2449 WDP_AUTO,
"view_vehicle_details_train", 405, 178,
2457 WDP_AUTO,
"view_vehicle_details", 405, 113,
2489 NWidget(
NWID_VIEWPORT, INVALID_COLOUR,
WID_VV_VIEWPORT),
SetMinimalSize(226, 84),
SetResize(1, 1),
SetPadding(1, 1, 1, 1),
2499 SetDataTip(SPR_IGNORE_SIGNALS, STR_VEHICLE_VIEW_TRAIN_IGNORE_SIGNAL_TOOLTIP),
2503 SetDataTip(SPR_FORCE_VEHICLE_TURN, STR_VEHICLE_VIEW_ROAD_VEHICLE_REVERSE_TOOLTIP),
2519 WDP_AUTO,
"view_vehicle", 250, 116,
2530 WDP_AUTO,
"view_vehicle_train", 250, 134,
2553 static const int VV_INITIAL_VIEWPORT_WIDTH = 226;
2554 static const int VV_INITIAL_VIEWPORT_HEIGHT = 84;
2555 static const int VV_INITIAL_VIEWPORT_HEIGHT_TRAIN = 102;
2559 VCT_CMD_START_STOP = 0,
2561 VCT_CMD_TURN_AROUND,
2595 if (result.
Failed())
return;
2642 bool mouse_over_start_stop =
false;
2673 static const SpriteID vehicle_view_goto_depot_sprites[] = {
2674 SPR_SEND_TRAIN_TODEPOT,
2675 SPR_SEND_ROADVEH_TODEPOT,
2676 SPR_SEND_SHIP_TODEPOT,
2677 SPR_SEND_AIRCRAFT_TODEPOT,
2680 this->GetWidget<NWidgetCore>(
WID_VV_GOTO_DEPOT)->widget_data = vehicle_view_goto_depot_sprites[v->
type];
2683 static const SpriteID vehicle_view_clone_sprites[] = {
2689 this->GetWidget<NWidgetCore>(
WID_VV_CLONE)->widget_data = vehicle_view_clone_sprites[v->
type];
2693 this->GetWidget<NWidgetCore>(
WID_VV_TURN_AROUND)->tool_tip = STR_VEHICLE_VIEW_TRAIN_REVERSE_TOOLTIP;
2704 default: NOT_REACHED();
2710 this->GetWidget<NWidgetCore>(
WID_VV_START_STOP)->tool_tip = STR_VEHICLE_VIEW_TRAIN_STATUS_START_STOP_TOOLTIP + v->
type;
2711 this->GetWidget<NWidgetCore>(
WID_VV_RENAME)->tool_tip = STR_VEHICLE_DETAILS_TRAIN_RENAME + v->
type;
2712 this->GetWidget<NWidgetCore>(
WID_VV_LOCATION)->tool_tip = STR_VEHICLE_VIEW_TRAIN_CENTER_TOOLTIP + v->
type;
2713 this->GetWidget<NWidgetCore>(
WID_VV_REFIT)->tool_tip = STR_VEHICLE_VIEW_TRAIN_REFIT_TOOLTIP + v->
type;
2714 this->GetWidget<NWidgetCore>(
WID_VV_GOTO_DEPOT)->tool_tip = STR_VEHICLE_VIEW_TRAIN_SEND_TO_DEPOT_TOOLTIP + v->
type;
2715 this->GetWidget<NWidgetCore>(
WID_VV_SHOW_ORDERS)->tool_tip = STR_VEHICLE_VIEW_TRAIN_ORDERS_TOOLTIP + v->
type;
2716 this->GetWidget<NWidgetCore>(
WID_VV_SHOW_DETAILS)->tool_tip = STR_VEHICLE_VIEW_TRAIN_SHOW_DETAILS_TOOLTIP + v->
type;
2717 this->GetWidget<NWidgetCore>(
WID_VV_CLONE)->tool_tip = STR_VEHICLE_VIEW_CLONE_TRAIN_INFO + v->
type;
2719 this->UpdateButtonStatus();
2746 size->width = VV_INITIAL_VIEWPORT_WIDTH;
2747 size->height = (v->
type ==
VEH_TRAIN) ? VV_INITIAL_VIEWPORT_HEIGHT_TRAIN : VV_INITIAL_VIEWPORT_HEIGHT;
2790 str = STR_VEHICLE_STATUS_CRASHED;
2792 str = STR_VEHICLE_STATUS_BROKEN_DOWN;
2797 str = STR_VEHICLE_STATUS_TRAIN_NO_POWER;
2799 str = STR_VEHICLE_STATUS_STOPPED;
2803 str = STR_VEHICLE_STATUS_TRAIN_STOPPING_VEL;
2806 str = STR_VEHICLE_STATUS_STOPPED;
2809 str = STR_VEHICLE_STATUS_TRAIN_STUCK;
2811 str = STR_VEHICLE_STATUS_AIRCRAFT_TOO_FAR;
2813 if (mouse_over_start_stop) {
2821 case OT_GOTO_STATION: {
2824 str = STR_VEHICLE_STATUS_HEADING_FOR_STATION_VEL;
2828 case OT_GOTO_DEPOT: {
2841 str = STR_VEHICLE_STATUS_HEADING_FOR_DEPOT_VEL;
2843 str = STR_VEHICLE_STATUS_HEADING_FOR_DEPOT_SERVICE_VEL;
2849 str = STR_VEHICLE_STATUS_LOADING_UNLOADING;
2852 case OT_GOTO_WAYPOINT: {
2855 str = STR_VEHICLE_STATUS_HEADING_FOR_WAYPOINT_VEL;
2860 case OT_LEAVESTATION:
2862 str = STR_VEHICLE_STATUS_LEAVING;
2868 str = STR_VEHICLE_STATUS_NO_ORDERS_VEL;
2880 int height = r.bottom - r.top;
2884 int image = ((v->
vehstatus &
VS_STOPPED) != 0) ? SPR_FLAG_VEH_STOPPED : SPR_FLAG_VEH_RUNNING;
2885 int image_left = (rtl ? text_right + 1 : r.left) +
WD_IMGBTN_LEFT;
2888 DrawSprite(image, PAL_NONE, image_left + lowered, image_top + lowered);
2945 ShowOrdersWindow(v);
2978 if (str ==
nullptr)
return;
2986 if (start_stop != mouse_over_start_stop) {
2987 mouse_over_start_stop = start_stop;
3000 void UpdateButtonStatus()
3038 this->UpdateButtonStatus();
3066 assert(v !=
nullptr);
3075 void StopGlobalFollowVehicle(
const Vehicle *v)
3095 if (result.
Failed())
return;
3133 int vehicle_width = 0;
3134 for (
const Vehicle *u = v; u !=
nullptr; u = u->
Next()) {
3137 return vehicle_width;
3153 int total_width = 0;
3155 if (total_width >=
ScaleGUITrad(2 * (
int)VEHICLEINFO_FULL_VEHICLE_WIDTH))
break;
3163 for (uint i = 0; i < seq.count; ++i) {
3175 int offs = (
ScaleGUITrad(VEHICLEINFO_FULL_VEHICLE_WIDTH) - total_width) / 2;
3176 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.
static bool IsVehicleRefitable(const Vehicle *v)
Checks whether the vehicle may be refitted at the moment.
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)
@ WD_FRAMERECT_TOP
Offset at top to draw the frame rectangular area.
uint CountDigitsForAllocatingSpace(uint number)
Get the number of digits of space required for the given number.
#define CMD_MSG(x)
Used to combine a StringID with the command.
uint32 TileIndex
The index/ID of a Tile.
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.
CommandCost DoCommand(const CommandContainer *container, DoCommandFlag flags)
Shorthand for calling the long DoCommand with a container.
@ CMD_REVERSE_TRAIN_DIRECTION
turn a train around
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.
@ BP_SHOW_BUTTONS
Show the buttons.
@ WD_MATRIX_RIGHT
Offset at right of a matrix cell.
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.
@ CMD_ORDER_REFIT
change the refit information of an order (for "goto depot" )
void CcBuildPrimaryVehicle(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2, uint32 cmd)
This is the Callback method after the construction attempt of a primary vehicle.
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.
uint8 train_acceleration_model
realistic acceleration for trains
Dimensions (a width and height) of a rectangle in 2D.
@ 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.
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.
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.
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.
void DrawRoadVehDetails(const Vehicle *v, int left, int right, int y)
Draw the details for the given vehicle at the given position.
Vehicle * Next() const
Get the next vehicle of this vehicle.
T * Next() const
Get next vehicle in the chain.
uint information_width
Width required for correctly displaying all cargoes in the information panel.
@ WD_MATRIX_TOP
Offset at top of a matrix cell.
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.
@ 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.
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.
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.
@ DEPOT_MASS_SEND
Tells that it's a mass send to depot command (type in VLW flag)
Tindex index
Index of this pool item.
static CargoSpec * Get(size_t index)
Retrieve cargo details for the given cargo ID.
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.
void CcStartStopVehicle(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2, uint32 cmd)
This is the Callback method after attempting to start/stop a vehicle.
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 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.
uint16 _returned_mail_refit_capacity
Stores the mail capacity after a refit operation (Aircraft only).
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.
#define FOR_ALL_SORTED_CARGOSPECS(var)
Loop header for iterating over cargoes, sorted by name.
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,.
Specification of a cargo type.
@ 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.
EngineImageType
Visualisation contexts of vehicles and engines.
@ CBM_VEHICLE_CARGO_SUFFIX
Show suffix after cargo name.
@ VEH_ROAD
Road vehicle type.
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.
@ SA_HOR_CENTER
Horizontally center the text.
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?
@ CMD_TURN_ROADVEH
turn a road vehicle around
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.
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)
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.
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.
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.
@ WD_IMGBTN_BOTTOM
Bottom offset of image in the button.
Dimension GetStringBoundingBox(const char *str, FontSize start_fontsize)
Return the string dimension in pixels.
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.
OrderType GetType() const
Get the type of order of this order.
void OnInit() override
Notification that the nested widget tree gets initialized.
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.
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.
CargoID Index() const
Determines index of this cargospec.
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.
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.
virtual int GetDisplaySpeed() const
Gets the speed in km-ish/h that can be sent into SetDParam for string processing.
Cached, frequently calculated values.
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:
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.
CargoTypes GetUnionOfArticulatedRefitMasks(EngineID engine, bool include_initial_cargo_type)
Ors the refit_masks of all articulated parts.
bool DoCommandP(const CommandContainer *container, bool my_cmd)
Shortcut for the long DoCommandP when having a container with the data.
void StartStopVehicle(const Vehicle *v, bool texteffect)
Executes CMD_START_STOP_VEHICLE for given vehicle.
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.
byte callback_mask
Bitmask of vehicle callbacks that have to be called.
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.
#define DEBUG(name, level,...)
Output a line of debugging information.
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.
EngineID engine_type
The type of engine used for this vehicle.
bool operator!=(const RefitOption &other) const
Inequality operator for RefitOption.
@ WD_FRAMERECT_LEFT
Offset at left to draw the frame rectangular area.
@ VS_CRASHED
Vehicle is crashed.
@ CMD_CHANGE_SERVICE_INT
change the server interval of a vehicle
Sprite sequence for a vehicle part.
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.
@ WD_FRAMERECT_RIGHT
Offset at right to draw the frame rectangular area.
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.
@ WD_FRAMERECT_BOTTOM
Offset at bottom to draw the frame rectangular area.
bool Failed() const
Did this command fail?
Order current_order
The current order (+ status, like: loading)
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.
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.
@ ODATFB_NEAREST_DEPOT
Send the vehicle to the nearest depot.
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.
static const uint32 _vehicle_command_translation_table[][4]
Command codes for the shared buttons indexed by VehicleCommandTranslation and vehicle type.
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.
Money GetCost() const
The costs as made up to this moment.
static const GroupID DEFAULT_GROUP
Ungrouped vehicles are in this group.
DepotCommand
Flags to add to p1 for goto depot commands.
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.
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.
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.
@ 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.
void DrawShipImage(const Vehicle *v, int left, int right, int y, VehicleID selection, EngineImageType image_type)
Draws an image of a ship.
@ SEL_RT_BASEPLANE
First plane of the WID_VV_SELECT_REFIT_TURN stacked widget.
@ 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.
static const int DAYS_IN_LEAP_YEAR
sometimes, you need one day more...
WindowNumber window_number
Window number within the window class.
VehicleType
Available vehicle types.
uint step_height
Step-size of height resize changes.
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.
VehicleListType
Vehicle List type flags.
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.
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.
@ ODATFB_HALT
Service the vehicle and then halt it.
@ WC_VEHICLE_REFIT
Vehicle refit; Window numbers:
uint _returned_refit_capacity
Stores the capacity after a refit operation.
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.
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.
OrderList * list
Pointer to the order list for this vehicle.
VehicleOrderID cur_real_order_index
The index to the current real (non-implicit) order.
@ CMD_START_STOP_VEHICLE
start or stop a vehicle
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.
@ WD_DROPDOWNTEXT_TOP
Top offset of the dropdown widget string.
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.
@ DEPOT_SERVICE
The vehicle will leave the depot right after arrival (service only)
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.
@ CMD_FORCE_TRAIN_PROCEED
proceed a train to pass a red signal
@ CMD_CLONE_VEHICLE
clone a 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.
Vehicle * First() const
Get the first vehicle of this vehicle chain.
void DeleteWindowById(WindowClass cls, WindowNumber number, bool force)
Delete a window by its class and window number (if it is open).
uint vehicle_margin
Margin to use while selecting vehicles when the vehicle image is centered.
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.
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
@ CMD_MASS_START_STOP
start/stop all vehicles (in a depot)
void DrawWidget(const Rect &r, int widget) const override
Draw the contents of a nested widget.
int HideDropDownMenu(Window *pw)
Delete the drop-down menu from window pw.
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 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
#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.
@ VIWD_AUTOREPLACE
Autoreplace replaced the vehicle.
static int ScaleGUITrad(int value)
Scale traditional pixel dimensions to GUI zoom level.
uint32 PaletteID
The number of the palette.
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.
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.
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.
union Vehicle::@51 orders
The orders currently assigned to the vehicle.
bool IsWidgetLowered(byte widget_index) const
Gets the lowered state of a widget.
@ 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.
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.
@ WD_IMGBTN_TOP
Top offset of image in the button.
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.
@ 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.
Order * GetFirstOrder() const
Get the first order of the order chain.
VehicleID follow_vehicle
VehicleID to follow if following a vehicle, INVALID_VEHICLE otherwise.
@ WD_MATRIX_BOTTOM
Offset at bottom of a matrix cell.
void ShowVehicleViewWindow(const Vehicle *v)
Shows the vehicle view window of the given vehicle.
void ForceRebuild()
Force that a rebuild is needed.
VehicleList vehicles
List of vehicles. This is the buffer for vehgroups to point into; if this is structurally modified,...
PalSpriteID sprite_seq[16]
current image of cursor
#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.
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.
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.
static const TileIndex INVALID_TILE
The very nice invalid tile marker.
void CcCloneVehicle(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2, uint32 cmd)
This is the Callback method after the cloning attempt of a vehicle.
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...
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).
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.
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
@ WD_DROPDOWNTEXT_BOTTOM
Bottom offset of the dropdown widget string.
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)
void DrawAircraftDetails(const Aircraft *v, int left, int right, int y)
Draw the details for the given vehicle at the given position.
bool IsEngineRefittable(EngineID engine)
Check if an engine is refittable.
Data structure for an opened window.
void RebuildDone()
Notify the sortlist that the rebuild is done.
@ VEH_TRAIN
Train vehicle type.
void DrawShipDetails(const Vehicle *v, int left, int right, int y)
Draw the details for the given vehicle at the given position.
static bool IsValidID(size_t index)
Tests whether given index can be used to get valid (non-nullptr) Titem.
@ WD_MATRIX_LEFT
Offset at left of a matrix cell.
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.
@ WD_IMGBTN_LEFT
Left offset of the image in the button.
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 DrawAircraftImage(const Vehicle *v, int left, int right, int y, VehicleID selection, EngineImageType image_type)
Draws an image of an aircraft.
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.
void DisableWidget(byte widget_index)
Sets a widget to disabled.
@ CMD_RENAME_VEHICLE
rename a whole vehicle
#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).
@ WD_IMGBTN_RIGHT
Right offset of the image in the button.
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.
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.
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.
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 GetImage(Direction direction, EngineImageType image_type, VehicleSpriteSeq *result) const
Gets the sprite to show for the given direction.