75 const StringID BaseVehicleListWindow::vehicle_sorter_names[] = {
79 STR_SORT_BY_PROFIT_THIS_YEAR,
80 STR_SORT_BY_PROFIT_LAST_YEAR,
81 STR_SORT_BY_TOTAL_CAPACITY_PER_CARGOTYPE,
82 STR_SORT_BY_RELIABILITY,
83 STR_SORT_BY_MAX_SPEED,
87 STR_SORT_BY_LIFE_TIME,
88 STR_SORT_BY_TIMETABLE_DELAY,
92 const StringID BaseVehicleListWindow::vehicle_depot_name[] = {
93 STR_VEHICLE_LIST_SEND_TRAIN_TO_DEPOT,
94 STR_VEHICLE_LIST_SEND_ROAD_VEHICLE_TO_DEPOT,
95 STR_VEHICLE_LIST_SEND_SHIP_TO_DEPOT,
96 STR_VEHICLE_LIST_SEND_AIRCRAFT_TO_HANGAR
107 for (
const Vehicle *v : vehicles) {
108 unitnumber = max<uint>(unitnumber, v->unitnumber);
111 if (unitnumber >= 10000)
return 5;
112 if (unitnumber >= 1000)
return 4;
113 if (unitnumber >= 100)
return 3;
123 void BaseVehicleListWindow::BuildVehicleList()
127 DEBUG(misc, 3,
"Building vehicle list type %d for company %d given index %d", this->
vli.
type, this->vli.company, this->vli.index);
169 if (show_autoreplace) list.emplace_back(
new DropDownListStringItem(STR_VEHICLE_LIST_REPLACE_VEHICLES, ADI_REPLACE,
false));
182 static const Vehicle *_last_vehicle[2] = {
nullptr,
nullptr };
184 void BaseVehicleListWindow::SortVehicleList()
189 _last_vehicle[0] = _last_vehicle[1] =
nullptr;
194 if (list->size() < 2)
return;
207 spr = SPR_PROFIT_NEGATIVE;
209 spr = SPR_PROFIT_SOME;
211 spr = SPR_PROFIT_LOT;
234 static std::vector<StringID> subtypes;
242 byte ret_refit_cyc = 0;
243 bool success =
false;
244 if (subtypes.size() > 0) {
247 const Engine *e = v->GetEngine();
249 if (!
HasBit(e->info.refit_mask, dest_cargo_type) && v->cargo_type != dest_cargo_type)
continue;
251 CargoID old_cargo_type = v->cargo_type;
252 byte old_cargo_subtype = v->cargo_subtype;
255 v->cargo_type = dest_cargo_type;
259 v->cargo_subtype = refit_cyc;
262 v->First()->InvalidateNewGRFCache();
263 v->InvalidateNewGRFCache();
266 if (subtype == STR_EMPTY)
break;
268 if (std::find(subtypes.begin(), subtypes.end(), subtype) == subtypes.end())
continue;
271 ret_refit_cyc = refit_cyc;
277 v->cargo_type = old_cargo_type;
278 v->cargo_subtype = old_cargo_subtype;
281 v->First()->InvalidateNewGRFCache();
282 v->InvalidateNewGRFCache();
288 return ret_refit_cyc;
304 return other.
cargo != this->cargo || other.
string != this->string;
314 return other.
cargo == this->cargo && other.
string == this->string;
343 int textleft = r.left +
WD_MATRIX_LEFT + (rtl ? 0 : iconwidth + 4);
347 for (uint i = 0; current < pos + rows && i <
NUM_CARGO; i++) {
348 for (uint j = 0; current < pos + rows && j < list[i].size(); j++) {
352 if (sel[0] != (
int)i && refit.
subtype != 0xFF)
continue;
360 if (list[i].size() > 1) {
364 GfxDrawLine(iconcenter, y -
WD_MATRIX_TOP, iconcenter, j == list[i].size() - 1 ? ycenter : y -
WD_MATRIX_TOP + delta - 1, linecolour);
365 GfxDrawLine(iconcenter, ycenter, iconinner, ycenter, linecolour);
372 TextColour colour = (sel[0] == (int)i && (uint)sel[1] == j) ? TC_WHITE : TC_BLACK;
376 DrawString(textleft, textright, y, STR_JUST_STRING_STRING, colour);
407 for (uint i = 0; i <
NUM_CARGO; i++) this->list[i].clear();
411 VehicleSet vehicles_to_refit;
415 if (v->
type ==
VEH_TRAIN && std::find(vehicles_to_refit.begin(), vehicles_to_refit.end(), v->
index) == vehicles_to_refit.end())
continue;
417 CargoTypes cmask = e->info.refit_mask;
426 int current_index = 0;
431 if (!
HasBit(cmask, cid)) {
436 bool first_vehicle = this->list[current_index].size() == 0;
439 this->list[current_index].push_back({cid, 0xFF, STR_EMPTY});
465 if (subtype == STR_EMPTY)
break;
471 include(this->list[current_index], option);
474 if (subtype == STR_EMPTY) {
478 for (uint i = 1; i < l.size(); i++) {
479 if (l[i].subtype >= refit_cyc) {
489 while (pos < l.size() && l[pos].subtype != refit_cyc) pos++;
490 if (pos < l.size() && l[pos].string != subtype) {
492 l.erase(l.begin() + pos);
520 for (uint j = 0; j < this->list[i].size(); j++) {
524 if (this->sel[0] != (
int)i && refit.
subtype != 0xFF)
continue;
526 if (this->sel[0] == (
int)i && (uint)this->sel[1] == j) scroll_row = row;
533 if (scroll_row < row) this->vscroll->
ScrollTowards(scroll_row);
545 for (uint j = 0; j < this->list[i].size(); j++) {
549 if (this->sel[0] != (
int)i && refit.
subtype != 0xFF)
continue;
551 if (row == click_row) {
571 if (this->sel[0] < 0)
return nullptr;
574 if ((uint)this->sel[1] >= l.size())
return nullptr;
576 return &l[this->sel[1]];
583 this->auto_refit = auto_refit;
593 nwi->
tool_tip = STR_REFIT_TRAIN_REFIT_TOOLTIP + v->
type;
605 if (this->cargo !=
nullptr) {
610 this->BuildRefitList();
613 this->cargo =
nullptr;
614 for (uint i = 0; this->cargo ==
nullptr && i <
NUM_CARGO; i++) {
615 for (uint j = 0; j < list[i].size(); j++) {
616 if (list[i][j] == current_refit_option) {
619 this->cargo = &list[i][j];
626 this->RefreshScrollbar();
636 if (this->hscroll !=
nullptr) this->hscroll->
SetCount(this->vehicle_width);
640 int sprite_width =
max(0, ((
int)vehicle_panel_display->
current_x - this->vehicle_width) / 2);
641 this->sprite_left = vehicle_panel_display->
pos_x;
642 this->sprite_right = vehicle_panel_display->
pos_x + vehicle_panel_display->
current_x - 1;
644 this->sprite_right -= sprite_width;
645 this->vehicle_margin = vehicle_panel_display->
current_x - sprite_right;
647 this->sprite_left += sprite_width;
648 this->vehicle_margin = sprite_left;
659 size->height = resize->height * 8;
701 return STR_PURCHASE_INFO_AIRCRAFT_CAPACITY;
702 }
else if (money <= 0) {
704 return STR_REFIT_NEW_CAPACITY_INCOME_FROM_AIRCRAFT_REFIT;
707 return STR_REFIT_NEW_CAPACITY_COST_OF_AIRCRAFT_REFIT;
713 return STR_PURCHASE_INFO_CAPACITY;
714 }
else if (money <= 0) {
716 return STR_REFIT_NEW_CAPACITY_INCOME_FROM_REFIT;
719 return STR_REFIT_NEW_CAPACITY_COST_OF_REFIT;
737 VehicleSet vehicles_to_refit;
740 int left = INT32_MIN;
745 const bool contained = std::find(vehicles_to_refit.begin(), vehicles_to_refit.end(), u->index) != vehicles_to_refit.end();
746 if (contained && left == INT32_MIN) {
747 left = x - this->hscroll->
GetPosition() + r.left + this->vehicle_margin;
752 if ((!contained || u->Next() ==
nullptr) && left != INT32_MIN) {
753 if (u->Next() ==
nullptr && contained) {
754 int current_width = u->GetDisplayImageWidth();
755 width += current_width;
759 int right =
Clamp(left + width, 0, r.right);
764 left = right -
width;
774 int current_width = u->GetDisplayImageWidth();
775 width += current_width;
791 if (this->cargo !=
nullptr) {
792 StringID string = this->GetCapacityString(this->cargo);
814 this->selected_vehicle = v->
index;
815 this->num_vehicles = UINT8_MAX;
820 if (!gui_scope)
break;
821 this->BuildRefitList();
829 for (uint j = 0; j < this->list[i].size(); j++) {
830 StringID string = this->GetCapacityString(&list[i][j]);
833 max_width =
max(dim.width, max_width);
838 if (this->information_width < max_width) {
839 this->information_width = max_width;
846 if (!gui_scope)
break;
847 this->cargo = GetRefitOption();
848 this->RefreshScrollbar();
853 int GetClickPosition(
int click_x)
857 click_x -= this->vehicle_margin;
858 if (this->hscroll !=
nullptr) click_x += this->hscroll->
GetPosition();
863 void SetSelectedVehicles(
int drag_x)
865 drag_x = GetClickPosition(drag_x);
867 int left_x =
min(this->click_x, drag_x);
868 int right_x =
max(this->click_x, drag_x);
869 this->num_vehicles = 0;
878 bool start_counting =
false;
879 for (; u !=
nullptr; u = u->
Next()) {
881 left_x -= current_width;
882 right_x -= current_width;
884 if (left_x < 0 && !start_counting) {
885 this->selected_vehicle = u->
index;
886 start_counting =
true;
889 this->num_vehicles++;
892 this->num_vehicles++;
895 if (right_x < 0)
break;
900 if (this->num_vehicles != 0) {
909 this->selected_vehicle = v->
index;
910 this->num_vehicles = UINT8_MAX;
921 this->click_x = GetClickPosition(pt.x - nwi->
pos_x);
922 this->SetSelectedVehicles(pt.x - nwi->
pos_x);
938 if (click_count == 1)
break;
943 if (this->cargo !=
nullptr) {
947 bool delete_window = this->selected_vehicle == v->
index && this->num_vehicles == UINT8_MAX;
948 if (
DoCommandP(v->
tile, this->selected_vehicle, this->cargo->cargo | this->cargo->subtype << 8 | this->num_vehicles << 16, GetCmdRefitVeh(v)) && delete_window)
delete this;
963 this->SetSelectedVehicles(pt.x - nwi->
pos_x);
976 this->SetSelectedVehicles(pt.x - nwi->
pos_x);
991 static const NWidgetPart _nested_vehicle_refit_widgets[] = {
1007 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),
1018 WDP_AUTO,
"view_vehicle_refit", 240, 174,
1021 _nested_vehicle_refit_widgets,
lengthof(_nested_vehicle_refit_widgets)
1049 if (cmask == lmask) {
1051 SetDParam(0, STR_PURCHASE_INFO_ALL_TYPES);
1057 SetDParam(0, STR_PURCHASE_INFO_ALL_BUT);
1092 static char last_name[2][64];
1094 if (a != _last_vehicle[0]) {
1095 _last_vehicle[0] = a;
1097 GetString(last_name[0], STR_VEHICLE_NAME,
lastof(last_name[0]));
1100 if (b != _last_vehicle[1]) {
1101 _last_vehicle[1] = b;
1103 GetString(last_name[1], STR_VEHICLE_NAME,
lastof(last_name[1]));
1106 int r =
strnatcmp(last_name[0], last_name[1]);
1177 for (u = a; u !=
nullptr; u = u->
Next()) diff += u->
value;
1178 for (u = b; u !=
nullptr; u = u->
Next()) diff -= u->
value;
1205 void InitializeGUI()
1248 static const NWidgetPart _nested_vehicle_list[] = {
1265 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),
1273 SetDataTip(STR_BLACK_STRING, STR_VEHICLE_LIST_AVAILABLE_ENGINES_TOOLTIP),
1276 SetDataTip(STR_VEHICLE_LIST_MANAGE_LIST, STR_VEHICLE_LIST_MANAGE_LIST_TOOLTIP),
1278 SetDataTip(SPR_FLAG_VEH_STOPPED, STR_VEHICLE_LIST_MASS_STOP_LIST_TOOLTIP),
1280 SetDataTip(SPR_FLAG_VEH_RUNNING, STR_VEHICLE_LIST_MASS_START_LIST_TOOLTIP),
1292 if (order ==
nullptr)
return;
1303 if (order->
IsType(OT_GOTO_STATION)) {
1305 DrawString(
left + l_offset, right - r_offset, y, STR_TINY_BLACK_STATION);
1308 if (++i == 4)
break;
1312 order = order->
next;
1313 if (order ==
nullptr) {
1317 }
while (oid != start);
1336 default: NOT_REACHED();
1353 if (divisor == 1)
return base;
1356 uint rem = base % divisor;
1357 return base + (rem == 0 ? 0 : divisor - rem);
1374 int text_left = left + (rtl ? 0 : text_offset);
1375 int text_right = right - (rtl ? text_offset : 0);
1378 int orderlist_left = left + (rtl ? 0 :
max(
ScaleGUITrad(100) + text_offset, width / 2));
1379 int orderlist_right = right - (rtl ?
max(
ScaleGUITrad(100) + text_offset, width / 2) : 0);
1381 int image_left = (rtl && show_orderlist) ? orderlist_right : text_left;
1382 int image_right = (!rtl && show_orderlist) ? orderlist_left : text_right;
1384 int vehicle_button_x = rtl ? right -
GetSpriteSize(SPR_PROFIT_LOT).width :
left;
1387 uint max =
min(this->vscroll->GetPosition() + this->vscroll->GetCapacity(), (uint)this->
vehicles.size());
1388 for (uint i = this->vscroll->GetPosition(); i <
max; ++i) {
1398 if (v->
name !=
nullptr) {
1401 DrawString(text_left, text_right, y, STR_TINY_BLACK_VEHICLE);
1405 DrawString(text_left, text_right, y, STR_TINY_GROUP, TC_BLACK);
1408 if (show_orderlist) DrawSmallOrderList(v, orderlist_left, orderlist_right, y, v->
cur_real_order_index);
1411 str = STR_BLUE_COMMA;
1453 default: NOT_REACHED();
1463 this->BuildVehicleList();
1464 this->SortVehicleList();
1467 this->GetWidget<NWidgetCore>(
WID_VL_LIST)->tool_tip = STR_VEHICLE_LIST_TRAIN_LIST_TOOLTIP + this->
vli.
vtype;
1469 if (this->
vli.
type == VL_SHARED_ORDERS) {
1470 this->GetWidget<NWidgetCore>(
WID_VL_CAPTION)->widget_data = STR_VEHICLE_LIST_SHARED_ORDERS_LIST_CAPTION;
1472 this->GetWidget<NWidgetCore>(
WID_VL_CAPTION)->widget_data = STR_VEHICLE_LIST_TRAIN_CAPTION + this->
vli.
vtype;
1493 size->height = 6 * resize->height;
1497 size->height = 4 * resize->height;
1499 default: NOT_REACHED();
1506 d.height += padding.height;
1507 *size =
maxdim(*size, d);
1513 d.height += padding.height;
1514 d.width += padding.width;
1515 *size =
maxdim(*size, d);
1530 case VL_SHARED_ORDERS:
1536 SetDParam(0, this->vscroll->GetCount());
1542 SetDParam(3, this->vscroll->GetCount());
1545 case VL_STATION_LIST:
1548 SetDParam(3, this->vscroll->GetCount());
1555 SetDParam(3, this->vscroll->GetCount());
1557 default: NOT_REACHED();
1580 this->BuildVehicleList();
1581 this->SortVehicleList();
1624 uint id_v = this->vscroll->GetScrolledRowFromWidget(pt.y,
this,
WID_VL_LIST);
1625 if (id_v >= this->
vehicles.size())
return;
1661 assert(this->
vehicles.size() != 0);
1672 default: NOT_REACHED();
1675 default: NOT_REACHED();
1683 StationID station = (this->
vli.
type == VL_STATION_LIST) ? this->
vli.
index : INVALID_STATION;
1685 DEBUG(misc, 3,
"Periodic resort %d list company %d at station %d", this->
vli.
vtype, this->owner, station);
1692 this->vscroll->SetCapacityFromWidget(
this,
WID_VL_LIST);
1702 if (!gui_scope &&
HasBit(data, 31) && this->
vli.
type == VL_SHARED_ORDERS) {
1720 WDP_AUTO,
"list_vehicles", 260, 246,
1723 _nested_vehicle_list,
lengthof(_nested_vehicle_list)
1727 WDP_AUTO,
"list_vehicles_train", 325, 246,
1730 _nested_vehicle_list,
lengthof(_nested_vehicle_list)
1739 AllocateWindowDescFront<VehicleListWindow>(&_vehicle_list_train_desc, num);
1742 AllocateWindowDescFront<VehicleListWindow>(&_vehicle_list_other_desc, num);
1756 ShowVehicleListWindowLocal(company, VL_STANDARD, vehicle_type, company);
1760 void ShowVehicleListWindow(
const Vehicle *v)
1767 ShowVehicleListWindowLocal(company, VL_STATION_LIST, vehicle_type, station);
1772 uint16 depot_airport_index;
1779 ShowVehicleListWindowLocal(company, VL_DEPOT_LIST, vehicle_type, depot_airport_index);
1808 SetDataTip(STR_EMPTY, STR_SERVICE_INTERVAL_DROPDOWN_TOOLTIP),
1826 NWidget(
WWT_MATRIX, COLOUR_GREY,
WID_VD_MATRIX),
SetResize(1, 1),
SetMinimalSize(393, 45),
SetMatrixDataTip(1, 0, STR_NULL),
SetFill(1, 0),
SetScrollbar(
WID_VD_SCROLLBAR),
1835 SetDataTip(STR_EMPTY, STR_SERVICE_INTERVAL_DROPDOWN_TOOLTIP),
1842 SetDataTip(STR_VEHICLE_DETAIL_TAB_INFORMATION, STR_VEHICLE_DETAILS_TRAIN_INFORMATION_TOOLTIP),
SetFill(1, 0),
SetResize(1, 0),
1846 SetDataTip(STR_VEHICLE_DETAIL_TAB_TOTAL_CARGO, STR_VEHICLE_DETAILS_TRAIN_TOTAL_CARGO_TOOLTIP),
SetFill(1, 0),
SetResize(1, 0),
1858 static StringID _service_interval_dropdown[] = {
1859 STR_VEHICLE_DETAILS_DEFAULT,
1860 STR_VEHICLE_DETAILS_DAYS,
1861 STR_VEHICLE_DETAILS_PERCENT,
1881 this->owner = v->
owner;
1897 if (!gui_scope)
return;
1901 uint aimed_height = this->GetRoadVehDetailsHeight(v);
1903 if (aimed_height != nwid_info->
current_y) {
1916 uint desired_height;
1921 for (
const Vehicle *u = v; u !=
nullptr; u = u->
Next()) {
1927 return desired_height;
1938 static const StringID info_strings[] = {
1939 STR_VEHICLE_INFO_MAX_SPEED,
1940 STR_VEHICLE_INFO_WEIGHT_POWER_MAX_SPEED,
1941 STR_VEHICLE_INFO_WEIGHT_POWER_MAX_SPEED_MAX_TE,
1942 STR_VEHICLE_INFO_PROFIT_THIS_YEAR_LAST_YEAR,
1943 STR_VEHICLE_INFO_RELIABILITY_BREAKDOWNS
1945 for (uint i = 0; i <
lengthof(info_strings); i++) {
1958 size->height = this->GetRoadVehDetailsHeight(v);
1977 size->height = 4 * resize->height;
1981 StringID *strs = _service_interval_dropdown;
1985 size->width += padding.width;
2003 switch (vehicle_type) {
2004 default: NOT_REACHED();
2030 default: NOT_REACHED();
2049 SetDParam(0, (v->
age + DAYS_IN_YEAR < v->max_age) ? STR_VEHICLE_INFO_AGE : STR_VEHICLE_INFO_AGE_RED);
2066 string = STR_VEHICLE_INFO_WEIGHT_POWER_MAX_SPEED;
2068 string = STR_VEHICLE_INFO_WEIGHT_POWER_MAX_SPEED_MAX_TE;
2076 string = STR_VEHICLE_INFO_MAX_SPEED_TYPE_RANGE;
2078 string = STR_VEHICLE_INFO_MAX_SPEED_TYPE;
2081 string = STR_VEHICLE_INFO_MAX_SPEED;
2110 uint text_left = r.left + (rtl ? 0 : sprite_width);
2111 uint text_right = r.right - (rtl ? sprite_width : 0);
2117 uint sprite_left = rtl ? text_right : r.left;
2118 uint sprite_right = rtl ? r.right : text_left;
2131 v->ServiceIntervalIsPercent() ? STR_VEHICLE_DETAILS_SERVICING_INTERVAL_PERCENT : STR_VEHICLE_DETAILS_SERVICING_INTERVAL_DAYS);
2154 StringID str = v->ServiceIntervalIsCustom() ?
2155 (v->ServiceIntervalIsPercent() ? STR_VEHICLE_DETAILS_PERCENT : STR_VEHICLE_DETAILS_DAYS) :
2156 STR_VEHICLE_DETAILS_DEFAULT;
2180 if (mod == v->GetServiceInterval())
return;
2188 ShowDropDownMenu(
this, _service_interval_dropdown, v->ServiceIntervalIsCustom() ? (v->ServiceIntervalIsPercent() ? 2 : 1) : 0, widget, 0, 0);
2215 bool iscustom = index != 0;
2216 bool ispercent = iscustom ? (index == 2) :
Company::Get(v->
owner)->settings.vehicle.servint_ispercent;
2226 if (str ==
nullptr)
return;
2234 if (nwi !=
nullptr) {
2242 WDP_AUTO,
"view_vehicle_details_train", 405, 178,
2245 _nested_train_vehicle_details_widgets,
lengthof(_nested_train_vehicle_details_widgets)
2250 WDP_AUTO,
"view_vehicle_details", 405, 113,
2253 _nested_nontrain_vehicle_details_widgets,
lengthof(_nested_nontrain_vehicle_details_widgets)
2261 AllocateWindowDescFront<VehicleDetailsWindow>((v->
type ==
VEH_TRAIN) ? &_train_vehicle_details_desc : &_nontrain_vehicle_details_desc, v->
index);
2280 NWidget(
NWID_VIEWPORT, INVALID_COLOUR,
WID_VV_VIEWPORT),
SetMinimalSize(226, 84),
SetResize(1, 1),
SetPadding(1, 1, 1, 1),
2291 SetDataTip(SPR_IGNORE_SIGNALS, STR_VEHICLE_VIEW_TRAIN_IGNORE_SIGNAL_TOOLTIP),
2295 SetDataTip(SPR_FORCE_VEHICLE_TURN, STR_VEHICLE_VIEW_ROAD_VEHICLE_REVERSE_TOOLTIP),
2310 WDP_AUTO,
"view_vehicle", 250, 116,
2313 _nested_vehicle_view_widgets,
lengthof(_nested_vehicle_view_widgets)
2321 WDP_AUTO,
"view_vehicle_train", 250, 134,
2324 _nested_vehicle_view_widgets,
lengthof(_nested_vehicle_view_widgets)
2344 static const int VV_INITIAL_VIEWPORT_WIDTH = 226;
2345 static const int VV_INITIAL_VIEWPORT_HEIGHT = 84;
2346 static const int VV_INITIAL_VIEWPORT_HEIGHT_TRAIN = 102;
2350 VCT_CMD_START_STOP = 0,
2352 VCT_CMD_TURN_AROUND,
2386 if (result.
Failed())
return;
2430 SEL_DC_BASEPLANE = SEL_DC_GOTO_DEPOT,
2431 SEL_RT_BASEPLANE = SEL_RT_REFIT,
2441 case SEL_DC_GOTO_DEPOT:
2447 case SEL_RT_TURN_AROUND:
2463 static const SpriteID vehicle_view_goto_depot_sprites[] = {
2464 SPR_SEND_TRAIN_TODEPOT,
2465 SPR_SEND_ROADVEH_TODEPOT,
2466 SPR_SEND_SHIP_TODEPOT,
2467 SPR_SEND_AIRCRAFT_TODEPOT,
2470 this->GetWidget<NWidgetCore>(
WID_VV_GOTO_DEPOT)->widget_data = vehicle_view_goto_depot_sprites[v->
type];
2473 static const SpriteID vehicle_view_clone_sprites[] = {
2479 this->GetWidget<NWidgetCore>(
WID_VV_CLONE)->widget_data = vehicle_view_clone_sprites[v->
type];
2483 this->GetWidget<NWidgetCore>(
WID_VV_TURN_AROUND)->tool_tip = STR_VEHICLE_VIEW_TRAIN_REVERSE_TOOLTIP;
2491 this->SelectPlane(SEL_RT_REFIT);
2494 default: NOT_REACHED();
2500 this->GetWidget<NWidgetCore>(
WID_VV_START_STOP)->tool_tip = STR_VEHICLE_VIEW_TRAIN_STATE_START_STOP_TOOLTIP + v->
type;
2502 this->GetWidget<NWidgetCore>(
WID_VV_REFIT)->tool_tip = STR_VEHICLE_VIEW_TRAIN_REFIT_TOOLTIP + v->
type;
2504 this->GetWidget<NWidgetCore>(
WID_VV_SHOW_ORDERS)->tool_tip = STR_VEHICLE_VIEW_TRAIN_ORDERS_TOOLTIP + v->
type;
2506 this->GetWidget<NWidgetCore>(
WID_VV_CLONE)->tool_tip = STR_VEHICLE_VIEW_CLONE_TRAIN_INFO + v->
type;
2508 this->UpdateButtonStatus();
2535 size->width = VV_INITIAL_VIEWPORT_WIDTH;
2536 size->height = (v->
type ==
VEH_TRAIN) ? VV_INITIAL_VIEWPORT_HEIGHT_TRAIN : VV_INITIAL_VIEWPORT_HEIGHT;
2575 str = STR_VEHICLE_STATUS_CRASHED;
2577 str = STR_VEHICLE_STATUS_BROKEN_DOWN;
2582 str = STR_VEHICLE_STATUS_TRAIN_NO_POWER;
2584 str = STR_VEHICLE_STATUS_STOPPED;
2588 str = STR_VEHICLE_STATUS_TRAIN_STOPPING_VEL;
2591 str = STR_VEHICLE_STATUS_STOPPED;
2594 str = STR_VEHICLE_STATUS_TRAIN_STUCK;
2596 str = STR_VEHICLE_STATUS_AIRCRAFT_TOO_FAR;
2599 case OT_GOTO_STATION: {
2602 str = STR_VEHICLE_STATUS_HEADING_FOR_STATION_VEL;
2606 case OT_GOTO_DEPOT: {
2619 str = STR_VEHICLE_STATUS_HEADING_FOR_DEPOT_VEL;
2621 str = STR_VEHICLE_STATUS_HEADING_FOR_DEPOT_SERVICE_VEL;
2627 str = STR_VEHICLE_STATUS_LOADING_UNLOADING;
2630 case OT_GOTO_WAYPOINT: {
2633 str = STR_VEHICLE_STATUS_HEADING_FOR_WAYPOINT_VEL;
2638 case OT_LEAVESTATION:
2640 str = STR_VEHICLE_STATUS_LEAVING;
2646 str = STR_VEHICLE_STATUS_NO_ORDERS_VEL;
2660 int image_left = (rtl ? text_right + 1 : r.left) +
WD_IMGBTN_LEFT;
2661 int image = ((v->
vehstatus &
VS_STOPPED) != 0) ? SPR_FLAG_VEH_STOPPED : SPR_FLAG_VEH_RUNNING;
2703 ShowOrdersWindow(v);
2742 void UpdateButtonStatus()
2750 PlaneSelections plane = veh_stopped ? SEL_DC_CLONE : SEL_DC_GOTO_DEPOT;
2752 if (nwi->
shown_plane + SEL_DC_BASEPLANE != plane) {
2753 this->SelectPlane(plane);
2758 PlaneSelections plane = veh_stopped ? SEL_RT_REFIT : SEL_RT_TURN_AROUND;
2760 if (nwi->
shown_plane + SEL_RT_BASEPLANE != plane) {
2761 this->SelectPlane(plane);
2780 this->UpdateButtonStatus();
2798 AllocateWindowDescFront<VehicleViewWindow>((v->
type ==
VEH_TRAIN) ? &_train_view_desc : &_vehicle_view_desc, v->
index);
2808 assert(v !=
nullptr);
2817 void StopGlobalFollowVehicle(
const Vehicle *v)
2837 if (result.
Failed())
return;
2875 int vehicle_width = 0;
2876 for (
const Vehicle *u = v; u !=
nullptr; u = u->
Next()) {
2879 return vehicle_width;
2895 int total_width = 0;
2897 if (total_width >= 2 * (
int)VEHICLEINFO_FULL_VEHICLE_WIDTH)
break;
2905 for (uint i = 0; i < seq.count; ++i) {
2917 int offs = ((int)VEHICLEINFO_FULL_VEHICLE_WIDTH - total_width) / 2;
2918 if (rtl) offs = -offs;
static const uint32 _vehicle_command_translation_table[][4]
Command codes for the shared buttons indexed by VehicleCommandTranslation and vehicle type...
Functions related to OTTD's strings.
Owner
Enum for all companies/owners.
void ShowNewGRFInspectWindow() const override
Show the NewGRF inspection window.
void DrawTrainDetails(const Train *v, int left, int right, int y, int vscroll_pos, uint16 vscroll_cap, TrainDetailsWindowTabs det_tab)
Draw the details for the given vehicle at the given position.
void ShowDropDownMenu(Window *w, const StringID *strings, int selected, int button, uint32 disabled_mask, uint32 hidden_mask, uint width)
Show a dropdown menu window near a widget of the parent window.
VehicleSettings vehicle
options for vehicles
Functions/types related to NewGRF debugging.
CargoID cargo
Cargo to refit to.
uint32 PaletteID
The number of the palette.
WindowNumber window_number
The WindowNumber of the window that is responsible for the selection mode.
Vehicle is stopped by the player.
void RebuildDone()
Notify the sortlist that the rebuild is done.
int GetDisplayImageWidth(Point *offset=nullptr) const
Get the width of a road vehicle image in the GUI.
std::vector< RefitOption > SubtypeList
List of refit subtypes associated to a cargo.
GameSettings _settings_game
Game settings of a running game or the scenario editor.
Definition of stuff that is very close to a company, like the company struct itself.
static Titem * GetIfValid(size_t index)
Returns Titem with given index.
Money value
Value of the vehicle.
Default settings for vehicles.
static const RailtypeInfo * GetRailTypeInfo(RailType railtype)
Returns a pointer to the Railtype information for a given railtype.
static const int DAYS_IN_YEAR
days per year
void ChangeVehicleViewWindow(VehicleID from_index, VehicleID to_index)
Report a change in vehicle IDs (due to autoreplace) to affected vehicle windows.
static const uint CALLBACK_FAILED
Different values for Callback result evaluations.
CompanyID company
The company associated with this list.
PlaneSelections
Display planes available in the vehicle view window.
Horizontally center the text.
The information about a vehicle list.
ResizeInfo resize
Resize information.
CargoTypes _cargo_mask
Bitmask of cargo types available.
Window(WindowDesc *desc)
Empty constructor, initialization has been moved to InitNested() called from the constructor of the d...
static const int VEHICLE_PROFIT_MIN_AGE
Only vehicles older than this have a meaningful profit.
void SetWidgetDisabledState(byte widget_index, bool disab_stat)
Sets the enabled/disabled status of a widget.
Offset at right of a matrix cell.
void SetWidgetLoweredState(byte widget_index, bool lowered_stat)
Sets the lowered/raised status of a widget.
Money GetDisplayProfitThisYear() const
Gets the profit vehicle had this year.
static int UnScaleGUI(int value)
Short-hand to apply GUI zoom level.
static WindowDesc _vehicle_view_desc(WDP_AUTO, "view_vehicle", 250, 116, WC_VEHICLE_VIEW, WC_NONE, 0, _nested_vehicle_view_widgets, lengthof(_nested_vehicle_view_widgets))
Vehicle view window descriptor for all vehicles but trains.
void DrawShipImage(const Vehicle *v, int left, int right, int y, VehicleID selection, EngineImageType image_type)
Draws an image of a ship.
Window * parent
Parent window.
High level window description.
Functions related to the autoreplace GUIs.
Vehicle * GetFirstEnginePart()
Get the first part of an articulated engine.
uint16 GetServiceIntervalClamped(uint interval, bool ispercent)
Clamp the service interval to the correct min/max.
int sprite_right
Right position of the vehicle sprite.
WindowFlags flags
Window flags.
int left
x position of left edge of the window
StringID GetAircraftTypeText() const
Get the name of the aircraft type for display purposes.
void DrawAircraftDetails(const Aircraft *v, int left, int right, int y)
Draw the details for the given vehicle at the given position.
bool VehicleClicked(const Vehicle *v)
Dispatch a "vehicle selected" event if any window waits for it.
union Vehicle::@49 orders
The orders currently assigned to the vehicle.
void DrawWidgets() const
Paint all widgets of a window.
static Titem * Get(size_t index)
Returns Titem with given index.
bool CanCarryCargo() const
Determines whether an engine can carry something.
void DrawVehicleImage(const Vehicle *v, int left, int right, int y, VehicleID selection, EngineImageType image_type, int skip)
Draws an image of a vehicle chain.
static Point RemapCoords(int x, int y, int z)
Map 3D world or tile coordinate to equivalent 2D coordinate as used in the viewports and smallmap...
Vehicle composition was changed.
Base for the train class.
Point sprite_pos[16]
relative position of individual sprites
void SetWidgetDirty(byte widget_index) const
Invalidate a widget, i.e.
static const VehicleOrderID INVALID_VEH_ORDER_ID
Invalid vehicle order index (sentinel)
Offset at top to draw the frame rectangular area.
void SetStringParameters(int widget) const override
Initialize string parameters for a widget.
void OnMouseDrag(Point pt, int widget) override
An 'object' is being dragged at the provided position, highlight the target if possible.
Functions related to debugging.
static bool VehicleValueSorter(const Vehicle *const &a, const Vehicle *const &b)
Sort vehicles by their value.
Window * FindWindowById(WindowClass cls, WindowNumber number)
Find a window by its class and window number.
change the server interval of a vehicle
static void DrawVehicleProfitButton(const Vehicle *v, int x, int y)
draw the vehicle profit button in the vehicle list window.
byte _colour_gradient[COLOUR_END][8]
All 16 colour gradients 8 colours per gradient from darkest (0) to lightest (7)
uint16 cur_speed
current speed
query cost only, don't build.
void CDECL SetWidgetsDisabledState(bool disab_stat, int widgets,...)
Sets the enabled/disabled status of a list of widgets.
uint sprite_count
number of sprites to draw
void ShowQueryString(StringID str, StringID caption, uint maxsize, Window *parent, CharSetFilter afilter, QueryStringFlags flags)
Show a query popup window with a textbox in it.
static int ScaleGUITrad(int value)
Scale traditional pixel dimensions to GUI zoom level.
Maximal number of cargo types in a game.
void OnClick(Point pt, int widget, int click_count) override
A click with the left mouse button has been made on the window.
Tab with cargo capacity of the vehicles.
bool IsStoppedInDepot() const
Check whether the vehicle is in the depot and stopped.
uint16 _returned_refit_capacity
Stores the capacity after a refit operation.
#define FOR_ALL_SORTED_CARGOSPECS(var)
Loop header for iterating over cargoes, sorted by name.
Specification of a cargo type.
VehicleType
Available vehicle types.
GUIVehicleList vehicles
The list of vehicles.
OrderList * list
Pointer to the order list for this vehicle.
static WindowDesc _train_vehicle_details_desc(WDP_AUTO, "view_vehicle_details_train", 405, 178, WC_VEHICLE_DETAILS, WC_VEHICLE_VIEW, 0, _nested_train_vehicle_details_widgets, lengthof(_nested_train_vehicle_details_widgets))
Vehicle details window descriptor.
Functions related to vehicles.
Aircraft, helicopters, rotors and their shadows belong to this class.
CargoTypes GetUnionOfArticulatedRefitMasks(EngineID engine, bool include_initial_cargo_type)
Ors the refit_masks of all articulated parts.
static bool IsExpected(const BaseStation *st)
Helper for checking whether the given station is of this type.
Scrollbar * vscroll
The main scrollbar.
void OnClick(Point pt, int widget, int click_count) override
A click with the left mouse button has been made on the window.
Tindex index
Index of this pool item.
virtual void GetImage(Direction direction, EngineImageType image_type, VehicleSpriteSeq *result) const
Gets the sprite to show for the given direction.
static const int DAY_TICKS
1 day is 74 ticks; _date_fract used to be uint16 and incremented by 885.
Offset at top of a matrix cell.
PaletteID GetVehiclePalette(const Vehicle *v)
Get the colour map for a vehicle.
bool NeedResort()
Check if a resort is needed next loop If used the resort timer will decrease every call till 0...
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.
bool GenerateVehicleSortList(VehicleList *list, const VehicleListIdentifier &vli)
Generate a list of vehicles based on window type.
#define lastof(x)
Get the last element of an fixed size array.
void SetStringParameters(int widget) const override
Initialize string parameters for a widget.
void ReInit(int rx=0, int ry=0)
Re-initialize a window, and optionally change its size.
StringID GetGRFStringID(uint32 grfid, StringID stringid)
Returns the index for this stringid associated with its grfID.
void RefreshScrollbar()
Refresh scrollbar after selection changed.
Money GetCost() const
The costs as made up to this moment.
Stuff related to the text buffer GUI.
static bool VehicleLengthSorter(const Vehicle *const &a, const Vehicle *const &b)
Sort vehicles by their length.
WindowClass
Window classes.
byte GetDigitWidth(FontSize size)
Return the maximum width of single digit.
int32 lateness_counter
How many ticks late (or early if negative) this vehicle is.
void DisableWidget(byte widget_index)
Sets a widget to disabled.
void DrawWidget(const Rect &r, int widget) const override
Draw the contents of a nested widget.
Common return value for all commands.
uint32 cached_power
Total power of the consist (valid only for the first engine).
GrfSpecFeature GetGrfSpecFeature(TileIndex tile)
Get the GrfSpecFeature associated with the tile.
Determine the cargo "suffixes" for each refit possibility of a cargo.
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.
static const VehicleID INVALID_VEHICLE
Constant representing a non-existing vehicle.
static T max(const T a, const T b)
Returns the maximum of two values.
uint8 advanced_vehicle_list
use the "advanced" vehicle list
EngineImageType
Visualisation contexts of vehicles and engines.
WindowClass cls
Class of the window,.
Cached, frequently calculated values.
TileIndex GetLocation(const Vehicle *v, bool airport=false) const
Returns a tile somewhat representing the order destination (not suitable for pathfinding).
Option to refit a vehicle chain.
static Train * From(Vehicle *v)
Converts a Vehicle to SpecializedVehicle with type checking.
Display 'goto depot' button in WID_VV_SELECT_DEPOT_CLONE stacked widget.
uint16 cached_max_speed
Maximum speed of the consist (minimum of the max speed of all vehicles in the consist).
void CreateNestedTree(bool fill_nested=true)
Perform the first part of the initialization of a nested widget tree.
const Engine * GetEngine() const
Retrieves the engine of the vehicle.
void SetListing(Listing l)
Import sort conditions.
Ignore next signal, after the signal ignore being stuck.
Window * GetCallbackWnd()
Get the window that started the current highlighting.
StringID name
Name of this type of cargo.
Display 'clone vehicle' button in WID_VV_SELECT_DEPOT_CLONE stacked widget.
int HideDropDownMenu(Window *pw)
Delete the drop-down menu from window pw.
bool NeedRebuild() const
Check if a rebuild is needed.
HighLightStyle place_mode
Method which is used to place the selection.
OrderDepotActionFlags GetDepotActionType() const
What are we going to do when in the depot.
static const ZoomLevel _vehicle_view_zoom_levels[]
Zoom levels for vehicle views indexed by vehicle type.
virtual bool OnVehicleSelect(const struct Vehicle *v)
The user clicked on a vehicle while HT_VEHICLE has been set.
DepotCommand
Flags to add to p1 for goto depot commands.
uint16 servint_ships
service interval for ships
Order * next
Pointer to next order. If nullptr, end of list.
Vehicle * FirstShared() const
Get the first vehicle of this vehicle chain.
void ShowDropDownList(Window *w, DropDownList &&list, int selected, int button, uint width, bool auto_width, bool instant_close)
Show a drop down list.
Functions related to (drawing on) viewports.
void ForceRebuild()
Force that a rebuild is needed.
void ShowCompanyGroupForVehicle(const Vehicle *v)
Show the group window for the given vehicle.
StringID string
GRF-local String to display for the cargo.
void DrawAircraftImage(const Vehicle *v, int left, int right, int y, VehicleID selection, EngineImageType image_type)
Draws an image of an aircraft.
bool IsEngineRefittable(EngineID engine)
Check if an engine is refittable.
Default zoom level for the aircraft view.
void DrawWidget(const Rect &r, int widget) const override
Draw the contents of a nested widget.
Data structure for an opened window.
byte breakdown_ctr
Counter for managing breakdown events.
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.
bool _ctrl_pressed
Is Ctrl pressed?
void FinishInitNested(WindowNumber window_number=0)
Perform the second part of the initialization of a nested widget tree.
Autoreplace replaced the vehicle.
Vehicle drawn in vehicle details, refit window, ...
dragging items in the depot windows
uint16 cargo_cap
total capacity
Bottom offset of image in the button.
Header of Action 04 "universal holder" structure and functions.
Main window; Window numbers:
enable the 'Default' button ("\0" is returned)
Vehicle orders; Window numbers:
proceed a train to pass a red signal
virtual int GetDisplayMaxSpeed() const
Gets the maximum speed in km-ish/h that can be sent into SetDParam for string processing.
std::vector< std::unique_ptr< const DropDownListItem > > DropDownList
A drop down list is a collection of drop down list items.
Money GetDisplayRunningCost() const
Gets the running cost of a vehicle that can be sent into SetDParam for string processing.
Map related accessors for depots.
void SelectPlane(PlaneSelections plane)
Display a plane in 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.
Functions related to low-level strings.
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.
The tile has no ownership.
uint GetRoadVehDetailsHeight(const Vehicle *v)
Gets the desired height for the road vehicle details panel.
virtual bool IsPrimaryVehicle() const
Whether this is the primary vehicle in the chain.
Window manager class for viewing a vehicle.
Scrollbar * hscroll
Only used for long vehicles.
static const uint MAX_LENGTH_VEHICLE_NAME_CHARS
The maximum length of a vehicle name in characters including '\0'.
Offset at bottom of a matrix cell.
UnitID unitnumber
unit number, for display purposes only
#define FONT_HEIGHT_SMALL
Height of characters in the small (FS_SMALL) font.
CommandCost DoCommand(const CommandContainer *container, DoCommandFlag flags)
Shorthand for calling the long DoCommand with a container.
void DrawVehicleListItems(VehicleID selected_vehicle, int line_height, const Rect &r) const
Draw all the vehicle list items.
byte cargo_subtype
Used for livery refits (NewGRF variations)
bool operator!=(const MultiMapIterator< Tmap_iter1, Tlist_iter1, Tkey, Tvalue1, Tcompare > &iter1, const MultiMapIterator< Tmap_iter2, Tlist_iter2, Tkey, Tvalue2, Tcompare > &iter2)
Inverse of operator==().
bool IsNewGRFInspectable() const override
Is the data related to this window NewGRF inspectable?
This window is used for construction; close it whenever changing company.
bool IsWidgetLowered(byte widget_index) const
Gets the lowered state of a widget.
void DrawWidget(const Rect &r, int widget) const override
Draw the contents of a nested widget.
Listing GetListing() const
Export current sort conditions.
static bool IsVehicleServiceIntervalEnabled(const VehicleType vehicle_type, CompanyID company_id)
Checks whether service interval is enabled for the vehicle.
int GetSingleVehicleWidth(const Vehicle *v, EngineImageType image_type)
Get the width of a vehicle (part) in pixels.
Functions related to engines.
GroundVehicleCache * GetGroundVehicleCache()
Access the ground vehicle cache of the vehicle.
void DrawRoadVehDetails(const Vehicle *v, int left, int right, int y)
Draw the details for the given vehicle at the given position.
uint32 index
A vehicle list type specific index.
void OnPaint() override
The window must be repainted.
uint32 VehicleID
The type all our vehicle IDs have.
void ShowVehicleRefitWindow(const Vehicle *v, VehicleOrderID order, Window *parent, bool auto_refit)
Show the refit window for a vehicle.
bool IsType(OrderType type) const
Check whether this order is of the given type.
DropDownList BuildActionDropdownList(bool show_autoreplace, bool show_group)
Display the Action dropdown window.
static void ChangeVehicleWindow(WindowClass window_class, VehicleID from_index, VehicleID to_index)
Assign a vehicle window a new vehicle.
#define FONT_HEIGHT_NORMAL
Height of characters in the normal (FS_NORMAL) font.
T * Next() const
Get next vehicle in the chain.
byte callback_mask
Bitmask of vehicle callbacks that have to be called.
ClientSettings _settings_client
The current settings for this game.
void OnInvalidateData(int data=0, bool gui_scope=true) override
Some data on this window has become invalid.
static bool VehicleProfitThisYearSorter(const Vehicle *const &a, const Vehicle *const &b)
Sort vehicles by this year profit.
Definition of base types and functions in a cross-platform compatible way.
Show suffix after cargo name.
static bool VehicleProfitLastYearSorter(const Vehicle *const &a, const Vehicle *const &b)
Sort vehicles by last year profit.
Tells that it's a mass send to depot command (type in VLW flag)
the length of the string is counted in characters
void DrawTrainImage(const Train *v, int left, int right, int y, VehicleID selection, EngineImageType image_type, int skip, VehicleID drag_dest)
Draws an image of a whole train.
void DrawWidget(const Rect &r, int widget) const override
Draw the contents of a nested widget.
bool IsArticulatedPart() const
Check if the vehicle is an articulated part of an engine.
A number of safeguards to prevent using unsafe methods.
TextColour
Colour of the strings, see _string_colourmap in table/string_colours.h or docs/ottd-colourtext-palett...
Default zoom level for the ship view.
Vehicle refit; Window numbers:
void OnPaint() override
The window must be repainted.
void StartStopVehicle(const Vehicle *v, bool texteffect)
Executes CMD_START_STOP_VEHICLE for given vehicle.
bool operator==(const MultiMapIterator< Tmap_iter1, Tlist_iter1, Tkey, Tvalue1, Tcompare > &iter1, const MultiMapIterator< Tmap_iter2, Tlist_iter2, Tkey, Tvalue2, Tcompare > &iter2)
Compare two MultiMap iterators.
CargoID cargo_type
type of cargo this vehicle is carrying
void DrawSortButtonState(int widget, SortButtonState state) const
Draw a sort button's up or down arrow symbol.
uint step_height
Step-size of height resize changes.
const Scrollbar * GetScrollbar(uint widnum) const
Return the Scrollbar to a widget index.
uint16 GetRange() const
Get the range of this aircraft.
Vehicle view; Window numbers:
Offset at left of a matrix cell.
VehicleOrderID order
If not INVALID_VEH_ORDER_ID, selection is part of a refit order (rather than execute directly)...
static bool VehicleModelSorter(const Vehicle *const &a, const Vehicle *const &b)
Sort vehicles by model.
byte subtype
Subcargo to use.
byte misc_flags
Miscellaneous flags.
Order * GetFirstOrder() const
Get the first order of the order chain.
static VehicleListIdentifier UnPack(uint32 data)
Decode a packed vehicle list identifier into a new one.
TileIndex tile
Current tile index.
TrainDetailsWindowTabs tab
For train vehicles: which tab is displayed.
void DrawShipDetails(const Vehicle *v, int left, int right, int y)
Draw the details for the given vehicle at the given position.
bool HasArticulatedPart() const
Check if an engine has an articulated part.
Vehicle timetable; Window numbers:
Offset at bottom to draw the frame rectangular area.
void OnResize() override
Called after the window got resized.
int DrawString(int left, int right, int top, const char *str, TextColour colour, StringAlignment align, bool underline, FontSize fontsize)
Draw string, possibly truncated to make it fit in its allocated space.
void ShowVehicleViewWindow(const Vehicle *v)
Shows the vehicle view window of the given vehicle.
int GetVehicleWidth(const Vehicle *v, EngineImageType image_type)
Get the width of a vehicle (including all parts of the consist) in pixels.
Service the vehicle and then halt it.
void DrawRoadVehImage(const Vehicle *v, int left, int right, int y, VehicleID selection, EngineImageType image_type, int skip)
Draws an image of a road vehicle chain.
void OnDropdownSelect(int widget, int index) override
A dropdown option associated to this window has been selected.
Owner owner
Which company owns the vehicle?
Sprite sequence for a vehicle part.
bool DoCommandP(const CommandContainer *container, bool my_cmd)
Shortcut for the long DoCommandP when having a container with the data.
Default zoom level for the road vehicle view.
#define lengthof(x)
Return the length of an fixed size array.
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.
VehicleID follow_vehicle
VehicleID to follow if following a vehicle, INVALID_VEHICLE otherwise.
static T min(const T a, const T b)
Returns the minimum of two values.
static const NWidgetPart _nested_train_vehicle_details_widgets[]
Train details widgets.
Right offset of the image in the button.
void OnGameTick() override
Called once per (game) tick.
byte breakdowns_since_last_service
Counter for the amount of breakdowns.
uint16 reliability
Reliability.
void SetSortType(uint8 n_type)
Set the sorttype of the list.
bool Sort(SortFunction *compare)
Sort the list.
static bool VehicleTimeToLiveSorter(const Vehicle *const &a, const Vehicle *const &b)
Sort vehicles by the time they can still live.
static int SortButtonWidth()
Get width of up/down arrow of sort button state.
void OnResize() override
Called after the window got resized.
Functions to cache sprites in memory.
uint32 StringID
Numeric value that represents a string, independent of the selected language.
Vehicle * First() const
Get the first vehicle of this vehicle chain.
Class for managing the vehicle details window.
bool Failed() const
Did this command fail?
Tab with cargo carried by the vehicles.
static bool VehicleMaxSpeedSorter(const Vehicle *const &a, const Vehicle *const &b)
Sort vehicles by their max speed.
bool auto_refit
Select cargo for auto-refitting.
static DepotID GetDepotIndex(TileIndex t)
Get the index of which depot is attached to the tile.
Draw border only, no background.
int vehicle_width
Width of the vehicle being drawn.
static bool VehicleCargoSorter(const Vehicle *const &a, const Vehicle *const &b)
Sort vehicles by their cargo.
static const SpriteID SPR_CLONE_TRAIN
Clone vehicles stuff.
static T Clamp(const T a, const T min, const T max)
Clamp a value between an interval.
Functions/classes shared between the different vehicle list GUIs.
static const NWidgetPart _nested_vehicle_view_widgets[]
Vehicle view widgets.
void SetDirty() const
Mark entire window as dirty (in need of re-paint)
int sprite_left
Left position of the vehicle sprite.
#define DEBUG(name, level,...)
Output a line of debugging information.
'Train' is either a loco or a wagon.
VehicleDetailsWindow(WindowDesc *desc, WindowNumber window_number)
Initialize a newly created vehicle details window.
void OnInvalidateData(int data=0, bool gui_scope=true) override
Some data on this window has become invalid.
Dimension GetStringBoundingBox(const char *str, FontSize start_fontsize)
Return the string dimension in pixels.
void ForceResort()
Force a resort next Sort call Reset the resort timer if used too.
Dimension maxdim(const Dimension &d1, const Dimension &d2)
Compute bounding box of both dimensions.
No window, redirects to WC_MAIN_WINDOW.
void DeleteWindowById(WindowClass cls, WindowNumber number, bool force)
Delete a window by its class and window number (if it is open).
PalSpriteID sprite_seq[16]
current image of cursor
char * name
Name of vehicle.
static const GroupID DEFAULT_GROUP
Ungrouped vehicles are in this group.
The vehicle will leave the depot right after arrival (service only)
static WindowDesc _nontrain_vehicle_details_desc(WDP_AUTO, "view_vehicle_details", 405, 113, WC_VEHICLE_DETAILS, WC_VEHICLE_VIEW, 0, _nested_nontrain_vehicle_details_widgets, lengthof(_nested_nontrain_vehicle_details_widgets))
Vehicle details window descriptor for other vehicles than a train.
static int32 ClampToI32(const int64 a)
Reduce a signed 64-bit int to a signed 32-bit one.
Functions related to companies.
uint GetUnitNumberDigits(VehicleList &vehicles)
Get the number of digits the biggest unit number of a set of vehicles has.
int GetDisplayImageWidth(Point *offset=nullptr) const
Get the width of a train vehicle image in the GUI.
Window for the (old) vehicle listing.
static StationID GetStationIndex(TileIndex t)
Get StationID from a tile.
Vehicle drawn in vehicle list, group list, ...
bool IsNewGRFInspectable(GrfSpecFeature feature, uint index)
Can we inspect the data given a certain feature and index.
void SetObjectToPlaceWnd(CursorID icon, PaletteID pal, HighLightStyle mode, Window *w)
Change the cursor and mouse click/drag handling to a mode for performing special operations like tile...
bool ScrollMainWindowTo(int x, int y, int z, bool instant)
Scrolls the main window to given coordinates.
TrainDetailsWindowTabs
The tabs in the train details window.
static bool VehicleTimetableDelaySorter(const Vehicle *const &a, const Vehicle *const &b)
Sort vehicles by the timetable delay.
Functions related to articulated vehicles.
void ErrorUnknownCallbackResult(uint32 grfid, uint16 cbid, uint16 cb_res)
Record that a NewGRF returned an unknown/invalid callback result.
Class for storing amounts of cargo.
Automatic refitting is allowed.
Both numeric and alphabetic and spaces and stuff.
StringID GetCapacityString(RefitOption *option) const
Gets the StringID to use for displaying capacity.
Display 'turn around' button in WID_VV_SELECT_REFIT_TURN stacked widget.
bool IsGroundVehicle() const
Check if the vehicle is a ground vehicle.
Train can't get a path reservation.
GUISettings gui
settings related to the GUI
void SetSelection(uint click_row)
Select a row.
void SetMouseCursorVehicle(const Vehicle *v, EngineImageType image_type)
Set the mouse cursor to look like a vehicle.
DestinationID GetDestination() const
Gets the destination of this order.
int strnatcmp(const char *s1, const char *s2, bool ignore_garbage_at_front)
Compares two strings using case insensitive natural sort.
VehicleCommandTranslation
Command indices for the _vehicle_command_translation_table.
void OnDropdownSelect(int widget, int index) override
A dropdown option associated to this window has been selected.
uint32 SpriteID
The number of a sprite, without mapping bits and colourtables.
void UpdateCursorSize()
Update cursor dimension.
uint16 EngineID
Unique identification number of an engine.
static CargoSpec * Get(size_t index)
Retrieve cargo details for the given cargo ID.
uint32 TileIndex
The index/ID of a Tile.
static const PaletteID PALETTE_CRASH
Recolour sprite greying of crashed vehicles.
uint32 Pack() const
Pack a VehicleListIdentifier in a single uint32.
RefitOption * cargo
Refit option selected by sel.
uint16 servint_trains
service interval for trains
Vehicle * Next() const
Get the next vehicle of this vehicle.
static WindowDesc _train_view_desc(WDP_AUTO, "view_vehicle_train", 250, 134, WC_VEHICLE_VIEW, WC_NONE, 0, _nested_vehicle_view_widgets, lengthof(_nested_vehicle_view_widgets))
Vehicle view window descriptor for trains.
Date date_of_last_service
Last date the vehicle had a service at a depot.
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...
TextDirection _current_text_dir
Text direction of the currently selected language.
void ToggleSortOrder()
Toggle the sort order Since that is the worst condition for the sort function reverse the list here...
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.
virtual void ShowNewGRFInspectWindow() const
Show the NewGRF inspection window.
static bool HasAtMostOneBit(T value)
Test whether value has at most 1 bit set.
void GetVehicleSet(VehicleSet &set, Vehicle *v, uint8 num_vehicles)
Calculates the set of vehicles that will be affected by a given selection.
Send the vehicle to the nearest depot.
void SetDParamMaxValue(uint n, uint64 max_value, uint min_count, FontSize size)
Set DParam n to some number that is suitable for string size computations.
Tab with sum of total cargo transported.
Display 'refit' button in WID_VV_SELECT_REFIT_TURN stacked widget.
void SetStringParameters(int widget) const override
Initialize string parameters for a widget.
Next destination is too far away.
Top offset of image in the button.
VehicleListType type
The type of vehicle list.
void ShowReplaceGroupVehicleWindow(GroupID id_g, VehicleType vehicletype)
Show the autoreplace configuration window for a particular group.
Vehicle * GetNextArticulatedPart() const
Get the next part of an articulated engine.
static uint GB(const T x, const uint8 s, const uint8 n)
Fetch n bits from x, started at bit s.
uint16 cached_total_length
Length of the whole vehicle (valid only for the first engine).
Trains list; Window numbers:
Functions related to zooming.
uint information_width
Width required for correctly displaying all cargoes in the information panel.
VehicleType type
Type of vehicle.
VehicleListType
Vehicle List type flags.
static void ShowVehicleDetailsWindow(const Vehicle *v)
Shows the vehicle details window of the given vehicle.
int GetTrainDetailsWndVScroll(VehicleID veh_id, TrainDetailsWindowTabs det_tab)
Determines the number of lines in the train details window.
void OnPaint() override
Repaint vehicle details window.
static const Money VEHICLE_PROFIT_THRESHOLD
Threshold for a vehicle to be considered making good profit.
change the refit information of an order (for "goto depot" )
void OnResize() override
Called after the window got resized.
void OnClick(Point pt, int widget, int click_count) override
A click with the left mouse button has been made on the window.
Functions related to the drop down widget.
uint16 _returned_mail_refit_capacity
Stores the mail capacity after a refit operation (Aircraft only).
uint16 servint_aircraft
service interval for aircraft
static uint GetVehicleHeight(VehicleType type)
Get the height of a single vehicle in the GUIs.
static uint ToPercent16(uint i)
Converts a "fract" value 0..65535 to "percent" value 0..100.
void SetStringParameters(int widget) const override
Initialize string parameters for a widget.
static const NWidgetPart _nested_nontrain_vehicle_details_widgets[]
Vehicle details widgets (other than train).
bool ScrollMainWindowToTile(TileIndex tile, bool instant)
Scrolls the viewport of the main window to a given location.
VehicleListIdentifier vli
Identifier of the vehicle list we want to currently show.
Vehicle details; Window numbers:
static uint CountBits(T value)
Counts the number of set bits in a variable.
Bottom offset of the dropdown widget string.
Functions/definitions that have something to do with groups.
Functions related to commands.
Coordinates of a point in 2D.
int click_x
Position of the first click while dragging.
Dimension GetSpriteSize(SpriteID sprid, Point *offset, ZoomLevel zoom)
Get the size of a sprite.
CompanyID _current_company
Company currently doing an action.
CargoID Index() const
Determines index of this cargospec.
static bool IsValidID(size_t index)
Tests whether given index can be used to get valid (non-nullptr) Titem.
uint32 GetGRFID() const
Retrieve the GRF ID of the NewGRF the vehicle is tied to.
void OnQueryTextFinished(char *str) override
The query window opened from this window has closed.
uint8 train_acceleration_model
realistic acceleration for trains
Make the text effect slowly go upwards.
static WindowClass GetWindowClassForVehicleType(VehicleType vt)
Get WindowClass for vehicle list of given vehicle type.
void OnInvalidateData(int data=0, bool gui_scope=true) override
Some data on this window has become invalid.
start/stop all vehicles (in a depot)
void OnClick(Point pt, int widget, int click_count) override
A click with the left mouse button has been made on the window.
Window does not do autoscroll,.
Order * GetOrder(int index) const
Returns order 'index' of a vehicle or nullptr when it doesn't exists.
void OnInvalidateData(int data=0, bool gui_scope=true) override
Some data on this window has become invalid.
static const StringID INVALID_STRING_ID
Constant representing an invalid string (16bit in case it is used in savegames)
Owner owner
The owner of the content shown in this window. Company colour is acquired from this variable...
uint16 GetVehicleCallback(CallbackID callback, uint32 param1, uint32 param2, EngineID engine, const Vehicle *v)
Evaluate a newgrf callback for vehicles.
uint8 num_vehicles
Number of selected vehicles.
uint8 roadveh_acceleration_model
realistic acceleration for road vehicles
vehicle is accepted as target as well (bitmask)
Offset at right to draw the frame rectangular area.
EngineID engine_type
The type of engine used for this vehicle.
ZoomLevel zoom
The zoom level of the viewport.
void BuildRefitList()
Collects all (cargo, subcargo) refit options of a vehicle chain.
int width
width of the window (number of pixels to the right in x direction)
uint GetVehicleListHeight(VehicleType type, uint divisor)
Get the height of a vehicle in the vehicle list GUIs.
static void DrawVehicleRefitWindow(const SubtypeList list[NUM_CARGO], const int sel[2], uint pos, uint rows, uint delta, const Rect &r)
Draw the list of available refit options for a consist and highlight the selected refit option (if an...
byte VehicleOrderID
The index of an order within its current vehicle (not pool related)
static bool HasBit(const T x, const uint8 y)
Checks if a bit in a value is set.
static const TileIndex INVALID_TILE
The very nice invalid tile marker.
ZoomLevel
All zoom levels we know.
const GRFFile * GetGRF() const
Retrieve the NewGRF the vehicle is tied to.
bool IsDescSortOrder() const
Check if the sort order is descending.
#define CMD_MSG(x)
Used to combine a StringID with the command.
static bool IsVehicleRefitable(const Vehicle *v)
Checks whether the vehicle may be refitted at the moment.
int32 WindowNumber
Number to differentiate different windows of the same class.
virtual int GetDisplaySpeed() const
Gets the speed in km-ish/h that can be sent into SetDParam for string processing. ...
WindowClass window_class
Window class.
uint16 servint_roadveh
service interval for road vehicles
OrderType GetType() const
Get the type of order of this order.
Specification of a rectangle with absolute coordinates of all edges.
WindowClass window_class
The WindowClass of the window that is responsible for the selection mode.
byte CargoID
Cargo slots to indicate a cargo type within a game.
byte unitnumber_digits
The number of digits of the highest unit number.
Text is written right-to-left by default.
WindowNumber window_number
Window number within the window class.
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.
ButtonPlanes
Enumeration of planes of the button row at the bottom.
uint32 cached_max_te
Maximum tractive effort of consist (valid only for the first engine).
Functions related to tile highlights.
virtual bool IsChainInDepot() const
Check whether the whole vehicle chain is in the depot.
uint ShowRefitOptionsList(int left, int right, int y, EngineID engine)
Display list of cargo types of the engine, for the purchase information window.
StringID GetCargoSubtypeText(const Vehicle *v)
Get the cargo subtype text from NewGRF for the vehicle details window.
static const uint MAX_REFIT_CYCLE
Maximum number of refit cycles we try, to prevent infinite loops.
Find a place automatically.
void OnDragDrop(Point pt, int widget) override
A dragged 'object' has been released.
Dimension GetActionDropdownSize(bool show_autoreplace, bool show_group)
Compute the size for the Action dropdown.
static bool VehicleNumberSorter(const Vehicle *const &a, const Vehicle *const &b)
Sort vehicles by their number.
std::vector< const Vehicle * > VehicleList
A list of vehicles.
void OnResize() override
Called after the window got resized.
SpriteID sprite
The 'real' sprite.
void OnPaint() override
The window must be repainted.
ViewportData * viewport
Pointer to viewport data, if present.
GUI functions that shouldn't be here.
bool SortFunction(const T &, const T &)
Signature of sort function.
Listing * sorting
Pointer to the vehicle type related sorting.
static const CursorID SPR_CURSOR_MOUSE
Cursor sprite numbers.
Base classes/functions for stations.
VehicleCache vcache
Cache of often used vehicle values.
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.
Default zoom level for the train view.
static bool VehicleReliabilitySorter(const Vehicle *const &a, const Vehicle *const &b)
Sort vehicles by their reliability.
Left offset of the image in the button.
VehicleType vtype
The vehicle type associated with this list.
RefitOption * GetRefitOption()
Gets the RefitOption placed in the selected index.
CompanyID _local_company
Company controlled by the human player at this client. Can also be COMPANY_SPECTATOR.
VehicleOrderID cur_real_order_index
The index to the current real (non-implicit) order.
Dimensions (a width and height) of a rectangle in 2D.
Offset at left to draw the frame rectangular area.
static const Year MAX_YEAR
MAX_YEAR, nicely rounded value of the number of years that can be encoded in a single 32 bits date...
uint32 cached_weight
Total weight of the consist (valid only for the first engine).
void InvalidateNewGRFCache()
Invalidates cached NewGRF variables.
Money GetDisplayProfitLastYear() const
Gets the profit vehicle had last year.
void GetBounds(Rect *bounds) const
Determine shared bounds of all sprites.
uint vehicle_margin
Margin to use while selecting vehicles when the vehicle image is centered.
static bool VehicleAgeSorter(const Vehicle *const &a, const Vehicle *const &b)
Sort vehicles by their age.
void DrawSprite(SpriteID img, PaletteID pal, int x, int y, const SubSprite *sub, ZoomLevel zoom)
Draw a sprite, not in a viewport.
turn a road vehicle around
Order current_order
The current order (+ status, like: loading)
void OnInit() override
Notification that the nested widget tree gets initialized.
VehicleID selected_vehicle
First vehicle in the current selection.
void InvalidateData(int data=0, bool gui_scope=true)
Mark this window's data as invalid (in need of re-computing)
Top offset of the dropdown widget string.
GroupID group_id
Index of group Pool array.
static const int DAYS_IN_LEAP_YEAR
sometimes, you need one day more...
static bool VehicleNameSorter(const Vehicle *const &a, const Vehicle *const &b)
Sort vehicles by their name.
int height
Height of the window (number of pixels down in y direction)
int DrawStringMultiLine(int left, int right, int top, int bottom, const char *str, TextColour colour, StringAlignment align, bool underline, FontSize fontsize)
Draw string, possibly over multiple lines.
virtual void OnInvalidateData(int data=0, bool gui_scope=true)
Some data on this window has become invalid.
static void MemSetT(T *ptr, byte value, size_t num=1)
Type-safe version of memset().
VehicleOrderID GetNumManualOrders() const
Get the number of manually added orders this vehicle has.
Tab with name and value of the vehicles.
uint8 SortType() const
Get the sorttype of the list.
static void SetDParam(uint n, uint64 v)
Set a string parameter v at index n in the global string parameter array.
static void DrawVehicleDetails(const Vehicle *v, int left, int right, int y, int vscroll_pos, uint vscroll_cap, TrainDetailsWindowTabs det_tab)
Draw the details for the given vehicle at the position of the Details windows.
static const GroupID ALL_GROUP
All vehicles are in this group.
PaletteID pal
The palette (use PAL_NONE) if not needed)