OpenTTD Source
1.11.0-beta2
|
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));
253 if (show_autoreplace) list.emplace_back(
new DropDownListStringItem(STR_VEHICLE_LIST_REPLACE_VEHICLES, ADI_REPLACE,
false));
266 static const Vehicle *_last_vehicle[2] = {
nullptr,
nullptr };
268 void BaseVehicleListWindow::SortVehicleList()
273 _last_vehicle[0] = _last_vehicle[1] =
nullptr;
278 if (list->size() < 2)
return;
290 }
else if (display_profit_last_year < 0) {
291 spr = SPR_PROFIT_NEGATIVE;
293 spr = SPR_PROFIT_SOME;
295 spr = SPR_PROFIT_LOT;
318 static std::vector<StringID> subtypes;
326 byte ret_refit_cyc = 0;
327 bool success =
false;
328 if (subtypes.size() > 0) {
331 const Engine *e = v->GetEngine();
333 if (!
HasBit(e->info.refit_mask, dest_cargo_type) && v->cargo_type != dest_cargo_type)
continue;
335 CargoID old_cargo_type = v->cargo_type;
336 byte old_cargo_subtype = v->cargo_subtype;
339 v->cargo_type = dest_cargo_type;
343 v->cargo_subtype = refit_cyc;
346 v->First()->InvalidateNewGRFCache();
347 v->InvalidateNewGRFCache();
350 if (subtype == STR_EMPTY)
break;
352 if (std::find(subtypes.begin(), subtypes.end(), subtype) == subtypes.end())
continue;
355 ret_refit_cyc = refit_cyc;
361 v->cargo_type = old_cargo_type;
362 v->cargo_subtype = old_cargo_subtype;
365 v->First()->InvalidateNewGRFCache();
366 v->InvalidateNewGRFCache();
372 return ret_refit_cyc;
427 int textleft = r.left +
WD_MATRIX_LEFT + (rtl ? 0 : iconwidth + 4);
431 for (uint i = 0; current < pos + rows && i <
NUM_CARGO; i++) {
432 for (uint j = 0; current < pos + rows && j < list[i].size(); j++) {
436 if (sel[0] != (
int)i && refit.
subtype != 0xFF)
continue;
444 if (list[i].size() > 1) {
448 GfxDrawLine(iconcenter, y -
WD_MATRIX_TOP, iconcenter, j == list[i].size() - 1 ? ycenter : y -
WD_MATRIX_TOP + delta - 1, linecolour);
449 GfxDrawLine(iconcenter, ycenter, iconinner, ycenter, linecolour);
456 TextColour colour = (sel[0] == (int)i && (uint)sel[1] == j) ? TC_WHITE : TC_BLACK;
460 DrawString(textleft, textright, y, STR_JUST_STRING_STRING, colour);
491 for (uint i = 0; i <
NUM_CARGO; i++) this->list[i].clear();
495 VehicleSet vehicles_to_refit;
499 if (v->
type ==
VEH_TRAIN && std::find(vehicles_to_refit.begin(), vehicles_to_refit.end(), v->
index) == vehicles_to_refit.end())
continue;
501 CargoTypes cmask = e->info.refit_mask;
510 int current_index = 0;
515 if (!
HasBit(cmask, cid)) {
520 bool first_vehicle = this->list[current_index].size() == 0;
523 this->list[current_index].push_back({cid, 0xFF, STR_EMPTY});
549 if (subtype == STR_EMPTY)
break;
555 include(this->list[current_index], option);
558 if (subtype == STR_EMPTY) {
562 for (uint i = 1; i < l.size(); i++) {
563 if (l[i].subtype >= refit_cyc) {
573 while (pos < l.size() && l[pos].subtype != refit_cyc) pos++;
574 if (pos < l.size() && l[pos].string != subtype) {
576 l.erase(l.begin() + pos);
604 for (uint j = 0; j < this->list[i].size(); j++) {
608 if (this->sel[0] != (
int)i && refit.
subtype != 0xFF)
continue;
610 if (this->sel[0] == (
int)i && (uint)this->sel[1] == j) scroll_row = row;
617 if (scroll_row < row) this->vscroll->
ScrollTowards(scroll_row);
629 for (uint j = 0; j < this->list[i].size(); j++) {
633 if (this->sel[0] != (
int)i && refit.
subtype != 0xFF)
continue;
635 if (row == click_row) {
655 if (this->sel[0] < 0)
return nullptr;
658 if ((uint)this->sel[1] >= l.size())
return nullptr;
660 return &l[this->sel[1]];
674 this->GetWidget<NWidgetCore>(
WID_VR_MATRIX)->tool_tip = STR_REFIT_TRAIN_LIST_TOOLTIP + v->
type;
677 nwi->
tool_tip = STR_REFIT_TRAIN_REFIT_TOOLTIP + v->
type;
689 if (this->cargo !=
nullptr) {
697 this->cargo =
nullptr;
698 for (uint i = 0; this->cargo ==
nullptr && i <
NUM_CARGO; i++) {
699 for (uint j = 0; j <
list[i].size(); j++) {
700 if (
list[i][j] == current_refit_option) {
703 this->cargo = &
list[i][j];
720 if (this->hscroll !=
nullptr) this->hscroll->
SetCount(this->vehicle_width);
724 int sprite_width = std::max(0, ((
int)vehicle_panel_display->
current_x - this->vehicle_width) / 2);
725 this->sprite_left = vehicle_panel_display->
pos_x;
726 this->sprite_right = vehicle_panel_display->
pos_x + vehicle_panel_display->
current_x - 1;
728 this->sprite_right -= sprite_width;
731 this->sprite_left += sprite_width;
743 size->height =
resize->height * 8;
785 return STR_PURCHASE_INFO_AIRCRAFT_CAPACITY;
786 }
else if (money <= 0) {
788 return STR_REFIT_NEW_CAPACITY_INCOME_FROM_AIRCRAFT_REFIT;
791 return STR_REFIT_NEW_CAPACITY_COST_OF_AIRCRAFT_REFIT;
797 return STR_PURCHASE_INFO_CAPACITY;
798 }
else if (money <= 0) {
800 return STR_REFIT_NEW_CAPACITY_INCOME_FROM_REFIT;
803 return STR_REFIT_NEW_CAPACITY_COST_OF_REFIT;
821 VehicleSet vehicles_to_refit;
824 int left = INT32_MIN;
829 const bool contained = std::find(vehicles_to_refit.begin(), vehicles_to_refit.end(), u->index) != vehicles_to_refit.end();
830 if (contained &&
left == INT32_MIN) {
836 if ((!contained || u->Next() ==
nullptr) &&
left != INT32_MIN) {
837 if (u->Next() ==
nullptr && contained) {
838 int current_width = u->GetDisplayImageWidth();
839 width += current_width;
858 int current_width = u->GetDisplayImageWidth();
859 width += current_width;
875 if (this->cargo !=
nullptr) {
898 this->selected_vehicle = v->
index;
899 this->num_vehicles = UINT8_MAX;
904 if (!gui_scope)
break;
913 for (uint j = 0; j < this->list[i].size(); j++) {
917 max_width = std::max(dim.width, max_width);
922 if (this->information_width < max_width) {
923 this->information_width = max_width;
930 if (!gui_scope)
break;
937 int GetClickPosition(
int click_x)
947 void SetSelectedVehicles(
int drag_x)
949 drag_x = GetClickPosition(drag_x);
951 int left_x = std::min(this->click_x, drag_x);
952 int right_x = std::max(this->click_x, drag_x);
953 this->num_vehicles = 0;
962 bool start_counting =
false;
963 for (; u !=
nullptr; u = u->
Next()) {
965 left_x -= current_width;
966 right_x -= current_width;
968 if (left_x < 0 && !start_counting) {
969 this->selected_vehicle = u->
index;
970 start_counting =
true;
973 this->num_vehicles++;
976 this->num_vehicles++;
979 if (right_x < 0)
break;
984 if (this->num_vehicles != 0) {
993 this->selected_vehicle = v->
index;
994 this->num_vehicles = UINT8_MAX;
1005 this->click_x = GetClickPosition(pt.x - nwi->
pos_x);
1006 this->SetSelectedVehicles(pt.x - nwi->
pos_x);
1022 if (click_count == 1)
break;
1027 if (this->cargo !=
nullptr) {
1031 bool delete_window = this->selected_vehicle == v->
index && this->num_vehicles == UINT8_MAX;
1032 if (
DoCommandP(v->
tile, this->selected_vehicle, this->cargo->cargo | this->cargo->subtype << 8 | this->num_vehicles << 16, GetCmdRefitVeh(v)) && delete_window)
delete this;
1047 this->SetSelectedVehicles(pt.x - nwi->
pos_x);
1060 this->SetSelectedVehicles(pt.x - nwi->
pos_x);
1075 static const NWidgetPart _nested_vehicle_refit_widgets[] = {
1091 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),
1102 WDP_AUTO,
"view_vehicle_refit", 240, 174,
1105 _nested_vehicle_refit_widgets,
lengthof(_nested_vehicle_refit_widgets)
1133 if (cmask == lmask) {
1135 SetDParam(0, STR_PURCHASE_INFO_ALL_TYPES);
1141 SetDParam(0, STR_PURCHASE_INFO_ALL_BUT);
1170 return a.NumVehicles() < b.NumVehicles();
1176 return a.GetDisplayProfitThisYear() < b.GetDisplayProfitThisYear();
1182 return a.GetDisplayProfitLastYear() < b.GetDisplayProfitLastYear();
1188 return a.GetDisplayProfitThisYear() *
static_cast<uint
>(b.NumVehicles()) < b.GetDisplayProfitThisYear() *
static_cast<uint
>(a.NumVehicles());
1194 return a.GetDisplayProfitLastYear() *
static_cast<uint
>(b.NumVehicles()) < b.GetDisplayProfitLastYear() *
static_cast<uint
>(a.NumVehicles());
1206 static char last_name[2][64];
1208 if (a != _last_vehicle[0]) {
1209 _last_vehicle[0] = a;
1211 GetString(last_name[0], STR_VEHICLE_NAME,
lastof(last_name[0]));
1214 if (b != _last_vehicle[1]) {
1215 _last_vehicle[1] = b;
1217 GetString(last_name[1], STR_VEHICLE_NAME,
lastof(last_name[1]));
1220 int r =
strnatcmp(last_name[0], last_name[1]);
1291 for (u = a; u !=
nullptr; u = u->
Next()) diff += u->
value;
1292 for (u = b; u !=
nullptr; u = u->
Next()) diff -= u->
value;
1319 void InitializeGUI()
1363 static const NWidgetPart _nested_vehicle_list[] = {
1385 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),
1393 SetDataTip(STR_BLACK_STRING, STR_VEHICLE_LIST_AVAILABLE_ENGINES_TOOLTIP),
1396 SetDataTip(STR_VEHICLE_LIST_MANAGE_LIST, STR_VEHICLE_LIST_MANAGE_LIST_TOOLTIP),
1398 SetDataTip(SPR_FLAG_VEH_STOPPED, STR_VEHICLE_LIST_MASS_STOP_LIST_TOOLTIP),
1400 SetDataTip(SPR_FLAG_VEH_RUNNING, STR_VEHICLE_LIST_MASS_START_LIST_TOOLTIP),
1412 if (order ==
nullptr)
return;
1423 if (order->
IsType(OT_GOTO_STATION)) {
1425 DrawString(left + l_offset, right - r_offset, y, STR_TINY_BLACK_STATION);
1428 if (++i == 4)
break;
1432 order = order->
next;
1433 if (order ==
nullptr) {
1437 }
while (oid != start);
1447 while (order !=
nullptr) {
1448 if (order->
IsType(OT_GOTO_STATION)) {
1450 DrawString(left + l_offset, right - r_offset, y, STR_TINY_BLACK_STATION);
1453 if (++i == 4)
break;
1455 order = order->
next;
1475 default: NOT_REACHED();
1492 if (divisor == 1)
return base;
1495 uint rem = base % divisor;
1496 return base + (rem == 0 ? 0 : divisor - rem);
1513 int text_left =
left + (rtl ? 0 : text_offset);
1514 int text_right = right - (rtl ? text_offset : 0);
1518 int orderlist_right = right - (rtl ? std::max(
ScaleGUITrad(100) + text_offset,
width / 2) : 0);
1520 int image_left = (rtl && show_orderlist) ? orderlist_right : text_left;
1521 int image_right = (!rtl && show_orderlist) ? orderlist_left : text_right;
1523 int vehicle_button_x = rtl ? right -
GetSpriteSize(SPR_PROFIT_LOT).width :
left;
1526 uint max =
static_cast<uint
>(std::min<size_t>(this->vscroll->
GetPosition() + this->vscroll->GetCapacity(), this->vehgroups.size()));
1527 for (uint i = this->vscroll->
GetPosition(); i < max; ++i) {
1531 SetDParam(0, vehgroup.GetDisplayProfitThisYear());
1532 SetDParam(1, vehgroup.GetDisplayProfitLastYear());
1539 const Vehicle *v = vehgroup.GetSingleVehicle();
1543 if (!v->
name.empty()) {
1546 DrawString(text_left, text_right, y, STR_TINY_BLACK_VEHICLE);
1550 DrawString(text_left, text_right, y, STR_TINY_GROUP, TC_BLACK);
1557 str = STR_BLUE_COMMA;
1567 case GB_SHARED_ORDERS:
1568 assert(vehgroup.NumVehicles() > 0);
1570 for (
int i = 0; i < static_cast<int>(vehgroup.NumVehicles()); ++i) {
1571 if (image_left + 8 * i >= image_right)
break;
1589 void BaseVehicleListWindow::UpdateSortingFromGrouping()
1599 default: NOT_REACHED();
1607 void BaseVehicleListWindow::UpdateVehicleGroupBy(GroupBy group_by)
1616 this->UpdateSortingFromGrouping();
1644 this->BuildVehicleList();
1645 this->SortVehicleList();
1648 this->GetWidget<NWidgetCore>(
WID_VL_LIST)->tool_tip = STR_VEHICLE_LIST_TRAIN_LIST_TOOLTIP + this->
vli.
vtype;
1650 if (this->
vli.
type == VL_SHARED_ORDERS) {
1651 this->GetWidget<NWidgetCore>(
WID_VL_CAPTION)->widget_data = STR_VEHICLE_LIST_SHARED_ORDERS_LIST_CAPTION;
1657 this->GetWidget<NWidgetCore>(
WID_VL_CAPTION)->widget_data = STR_VEHICLE_LIST_TRAIN_CAPTION + this->
vli.
vtype;
1678 size->height = 6 *
resize->height;
1682 size->height = 4 *
resize->height;
1684 default: NOT_REACHED();
1691 d.height += padding.height;
1692 *size =
maxdim(*size, d);
1698 d.height += padding.height;
1699 d.width += padding.width;
1700 *size =
maxdim(*size, d);
1715 case VL_SHARED_ORDERS:
1730 case VL_STATION_LIST:
1742 default: NOT_REACHED();
1765 this->BuildVehicleList();
1766 this->SortVehicleList();
1817 if (id_v >= this->
vehgroups.size())
return;
1822 const Vehicle *v = vehgroup.GetSingleVehicle();
1833 case GB_SHARED_ORDERS:
1834 assert(vehgroup.NumVehicles() > 0);
1840 default: NOT_REACHED();
1866 this->UpdateVehicleGroupBy(
static_cast<GroupBy
>(index));
1874 assert(this->
vehicles.size() != 0);
1885 default: NOT_REACHED();
1889 default: NOT_REACHED();
1897 StationID station = (this->
vli.
type == VL_STATION_LIST) ? this->
vli.
index : INVALID_STATION;
1899 DEBUG(misc, 3,
"Periodic resort %d list company %d at station %d", this->
vli.
vtype, this->owner, station);
1916 if (!gui_scope &&
HasBit(data, 31) && this->
vli.
type == VL_SHARED_ORDERS) {
1919 this->window_number = this->
vli.
Pack();
1934 WDP_AUTO,
"list_vehicles", 260, 246,
1937 _nested_vehicle_list,
lengthof(_nested_vehicle_list)
1941 WDP_AUTO,
"list_vehicles_train", 325, 246,
1944 _nested_vehicle_list,
lengthof(_nested_vehicle_list)
1953 AllocateWindowDescFront<VehicleListWindow>(&_vehicle_list_train_desc, num);
1956 AllocateWindowDescFront<VehicleListWindow>(&_vehicle_list_other_desc, num);
1970 ShowVehicleListWindowLocal(company, VL_STANDARD, vehicle_type, company);
1974 void ShowVehicleListWindow(
const Vehicle *v)
1981 ShowVehicleListWindowLocal(company, VL_STATION_LIST, vehicle_type, station);
1986 uint16 depot_airport_index;
1993 ShowVehicleListWindowLocal(company, VL_DEPOT_LIST, vehicle_type, depot_airport_index);
2021 SetDataTip(STR_EMPTY, STR_SERVICE_INTERVAL_DROPDOWN_TOOLTIP),
2038 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),
2047 SetDataTip(STR_EMPTY, STR_SERVICE_INTERVAL_DROPDOWN_TOOLTIP),
2054 SetDataTip(STR_VEHICLE_DETAIL_TAB_INFORMATION, STR_VEHICLE_DETAILS_TRAIN_INFORMATION_TOOLTIP),
SetFill(1, 0),
SetResize(1, 0),
2058 SetDataTip(STR_VEHICLE_DETAIL_TAB_TOTAL_CARGO, STR_VEHICLE_DETAILS_TRAIN_TOTAL_CARGO_TOOLTIP),
SetFill(1, 0),
SetResize(1, 0),
2070 static StringID _service_interval_dropdown[] = {
2071 STR_VEHICLE_DETAILS_DEFAULT,
2072 STR_VEHICLE_DETAILS_DAYS,
2073 STR_VEHICLE_DETAILS_PERCENT,
2107 if (!gui_scope)
return;
2113 if (aimed_height != nwid_info->
current_y) {
2126 uint desired_height;
2131 for (
const Vehicle *u = v; u !=
nullptr; u = u->
Next()) {
2137 return desired_height;
2148 static const StringID info_strings[] = {
2149 STR_VEHICLE_INFO_MAX_SPEED,
2150 STR_VEHICLE_INFO_WEIGHT_POWER_MAX_SPEED,
2151 STR_VEHICLE_INFO_WEIGHT_POWER_MAX_SPEED_MAX_TE,
2152 STR_VEHICLE_INFO_PROFIT_THIS_YEAR_LAST_YEAR,
2153 STR_VEHICLE_INFO_RELIABILITY_BREAKDOWNS
2155 for (uint i = 0; i <
lengthof(info_strings); i++) {
2187 size->height = 4 *
resize->height;
2191 StringID *strs = _service_interval_dropdown;
2195 size->width += padding.width;
2203 size->width = std::max(
2216 switch (vehicle_type) {
2217 default: NOT_REACHED();
2243 default: NOT_REACHED();
2262 SetDParam(0, (v->
age + DAYS_IN_YEAR < v->max_age) ? STR_VEHICLE_INFO_AGE : STR_VEHICLE_INFO_AGE_RED);
2279 string = STR_VEHICLE_INFO_WEIGHT_POWER_MAX_SPEED;
2281 string = STR_VEHICLE_INFO_WEIGHT_POWER_MAX_SPEED_MAX_TE;
2289 string = STR_VEHICLE_INFO_MAX_SPEED_TYPE_RANGE;
2291 string = STR_VEHICLE_INFO_MAX_SPEED_TYPE;
2294 string = STR_VEHICLE_INFO_MAX_SPEED;
2323 uint text_left = r.left + (rtl ? 0 : sprite_width);
2324 uint text_right = r.right - (rtl ? sprite_width : 0);
2330 uint sprite_left = rtl ? text_right : r.left;
2331 uint sprite_right = rtl ? r.right : text_left;
2344 v->ServiceIntervalIsPercent() ? STR_VEHICLE_DETAILS_SERVICING_INTERVAL_PERCENT : STR_VEHICLE_DETAILS_SERVICING_INTERVAL_DAYS);
2365 StringID str = v->ServiceIntervalIsCustom() ?
2366 (v->ServiceIntervalIsPercent() ? STR_VEHICLE_DETAILS_PERCENT : STR_VEHICLE_DETAILS_DAYS) :
2367 STR_VEHICLE_DETAILS_DEFAULT;
2383 if (mod == v->GetServiceInterval())
return;
2391 ShowDropDownMenu(
this, _service_interval_dropdown, v->ServiceIntervalIsCustom() ? (v->ServiceIntervalIsPercent() ? 2 : 1) : 0, widget, 0, 0);
2418 bool iscustom = index != 0;
2419 bool ispercent = iscustom ? (index == 2) :
Company::Get(v->
owner)->settings.vehicle.servint_ispercent;
2430 if (nwi !=
nullptr) {
2438 WDP_AUTO,
"view_vehicle_details_train", 405, 178,
2446 WDP_AUTO,
"view_vehicle_details", 405, 113,
2478 NWidget(
NWID_VIEWPORT, INVALID_COLOUR,
WID_VV_VIEWPORT),
SetMinimalSize(226, 84),
SetResize(1, 1),
SetPadding(1, 1, 1, 1),
2488 SetDataTip(SPR_IGNORE_SIGNALS, STR_VEHICLE_VIEW_TRAIN_IGNORE_SIGNAL_TOOLTIP),
2492 SetDataTip(SPR_FORCE_VEHICLE_TURN, STR_VEHICLE_VIEW_ROAD_VEHICLE_REVERSE_TOOLTIP),
2508 WDP_AUTO,
"view_vehicle", 250, 116,
2519 WDP_AUTO,
"view_vehicle_train", 250, 134,
2542 static const int VV_INITIAL_VIEWPORT_WIDTH = 226;
2543 static const int VV_INITIAL_VIEWPORT_HEIGHT = 84;
2544 static const int VV_INITIAL_VIEWPORT_HEIGHT_TRAIN = 102;
2548 VCT_CMD_START_STOP = 0,
2550 VCT_CMD_TURN_AROUND,
2584 if (result.
Failed())
return;
2631 bool mouse_over_start_stop =
false;
2662 static const SpriteID vehicle_view_goto_depot_sprites[] = {
2663 SPR_SEND_TRAIN_TODEPOT,
2664 SPR_SEND_ROADVEH_TODEPOT,
2665 SPR_SEND_SHIP_TODEPOT,
2666 SPR_SEND_AIRCRAFT_TODEPOT,
2669 this->GetWidget<NWidgetCore>(
WID_VV_GOTO_DEPOT)->widget_data = vehicle_view_goto_depot_sprites[v->
type];
2672 static const SpriteID vehicle_view_clone_sprites[] = {
2678 this->GetWidget<NWidgetCore>(
WID_VV_CLONE)->widget_data = vehicle_view_clone_sprites[v->
type];
2682 this->GetWidget<NWidgetCore>(
WID_VV_TURN_AROUND)->tool_tip = STR_VEHICLE_VIEW_TRAIN_REVERSE_TOOLTIP;
2693 default: NOT_REACHED();
2699 this->GetWidget<NWidgetCore>(
WID_VV_START_STOP)->tool_tip = STR_VEHICLE_VIEW_TRAIN_STATUS_START_STOP_TOOLTIP + v->
type;
2700 this->GetWidget<NWidgetCore>(
WID_VV_RENAME)->tool_tip = STR_VEHICLE_DETAILS_TRAIN_RENAME + v->
type;
2701 this->GetWidget<NWidgetCore>(
WID_VV_LOCATION)->tool_tip = STR_VEHICLE_VIEW_TRAIN_CENTER_TOOLTIP + v->
type;
2702 this->GetWidget<NWidgetCore>(
WID_VV_REFIT)->tool_tip = STR_VEHICLE_VIEW_TRAIN_REFIT_TOOLTIP + v->
type;
2703 this->GetWidget<NWidgetCore>(
WID_VV_GOTO_DEPOT)->tool_tip = STR_VEHICLE_VIEW_TRAIN_SEND_TO_DEPOT_TOOLTIP + v->
type;
2704 this->GetWidget<NWidgetCore>(
WID_VV_SHOW_ORDERS)->tool_tip = STR_VEHICLE_VIEW_TRAIN_ORDERS_TOOLTIP + v->
type;
2705 this->GetWidget<NWidgetCore>(
WID_VV_SHOW_DETAILS)->tool_tip = STR_VEHICLE_VIEW_TRAIN_SHOW_DETAILS_TOOLTIP + v->
type;
2706 this->GetWidget<NWidgetCore>(
WID_VV_CLONE)->tool_tip = STR_VEHICLE_VIEW_CLONE_TRAIN_INFO + v->
type;
2708 this->UpdateButtonStatus();
2735 size->width = VV_INITIAL_VIEWPORT_WIDTH;
2736 size->height = (v->
type ==
VEH_TRAIN) ? VV_INITIAL_VIEWPORT_HEIGHT_TRAIN : VV_INITIAL_VIEWPORT_HEIGHT;
2779 str = STR_VEHICLE_STATUS_CRASHED;
2781 str = STR_VEHICLE_STATUS_BROKEN_DOWN;
2786 str = STR_VEHICLE_STATUS_TRAIN_NO_POWER;
2788 str = STR_VEHICLE_STATUS_STOPPED;
2792 str = STR_VEHICLE_STATUS_TRAIN_STOPPING_VEL;
2795 str = STR_VEHICLE_STATUS_STOPPED;
2798 str = STR_VEHICLE_STATUS_TRAIN_STUCK;
2800 str = STR_VEHICLE_STATUS_AIRCRAFT_TOO_FAR;
2802 if (mouse_over_start_stop) {
2810 case OT_GOTO_STATION: {
2813 str = STR_VEHICLE_STATUS_HEADING_FOR_STATION_VEL;
2817 case OT_GOTO_DEPOT: {
2830 str = STR_VEHICLE_STATUS_HEADING_FOR_DEPOT_VEL;
2832 str = STR_VEHICLE_STATUS_HEADING_FOR_DEPOT_SERVICE_VEL;
2838 str = STR_VEHICLE_STATUS_LOADING_UNLOADING;
2841 case OT_GOTO_WAYPOINT: {
2844 str = STR_VEHICLE_STATUS_HEADING_FOR_WAYPOINT_VEL;
2849 case OT_LEAVESTATION:
2851 str = STR_VEHICLE_STATUS_LEAVING;
2857 str = STR_VEHICLE_STATUS_NO_ORDERS_VEL;
2869 int height = r.bottom - r.top;
2873 int image = ((v->
vehstatus &
VS_STOPPED) != 0) ? SPR_FLAG_VEH_STOPPED : SPR_FLAG_VEH_RUNNING;
2874 int image_left = (rtl ? text_right + 1 : r.left) +
WD_IMGBTN_LEFT;
2877 DrawSprite(image, PAL_NONE, image_left + lowered, image_top + lowered);
2934 ShowOrdersWindow(v);
2967 if (str ==
nullptr)
return;
2975 if (start_stop != mouse_over_start_stop) {
2976 mouse_over_start_stop = start_stop;
2989 void UpdateButtonStatus()
3027 this->UpdateButtonStatus();
3055 assert(v !=
nullptr);
3064 void StopGlobalFollowVehicle(
const Vehicle *v)
3084 if (result.
Failed())
return;
3122 int vehicle_width = 0;
3123 for (
const Vehicle *u = v; u !=
nullptr; u = u->
Next()) {
3126 return vehicle_width;
3142 int total_width = 0;
3144 if (total_width >=
ScaleGUITrad(2 * (
int)VEHICLEINFO_FULL_VEHICLE_WIDTH))
break;
3152 for (uint i = 0; i < seq.count; ++i) {
3164 int offs = (
ScaleGUITrad(VEHICLEINFO_FULL_VEHICLE_WIDTH) - total_width) / 2;
3165 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.
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.
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.
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.
static void DrawSmallOrderList(const Order *order, int left, int right, int y)
Draw small order list in the vehicle GUI, but without the little black arrow.
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.