36 #include "table/strings.h" 50 static const NWidgetPart _nested_build_vehicle_widgets[] = {
72 NWidget(
WWT_MATRIX, COLOUR_GREY,
WID_BV_LIST),
SetResize(1, 1),
SetFill(1, 0),
SetMatrixDataTip(1, 0, STR_NULL),
SetScrollbar(
WID_BV_SCROLLBAR),
121 const int r = va - vb;
137 static char last_name[2][64] = {
"\0",
"\0" };
139 if (a != last_engine[0]) {
142 GetString(last_name[0], STR_ENGINE_NAME,
lastof(last_name[0]));
145 if (b != last_engine[1]) {
148 GetString(last_name[1], STR_ENGINE_NAME,
lastof(last_name[1]));
151 int r =
strnatcmp(last_name[0], last_name[1]);
168 const int r = va - vb;
234 int va =
Engine::Get(a)->GetDisplayMaxTractiveEffort();
235 int vb =
Engine::Get(b)->GetDisplayMaxTractiveEffort();
289 double v_a = (double)p_a / (
double)r_a;
290 double v_b = (double)p_b / (
double)r_b;
330 int val_a = (RailVehInfo(a)->railveh_type ==
RAILVEH_WAGON ? 1 : 0);
331 int val_b = (RailVehInfo(b)->railveh_type ==
RAILVEH_WAGON ? 1 : 0);
332 int r = val_a - val_b;
393 uint16 mail_a, mail_b;
481 STR_SORT_BY_ENGINE_ID,
483 STR_SORT_BY_MAX_SPEED,
485 STR_SORT_BY_TRACTIVE_EFFORT,
486 STR_SORT_BY_INTRO_DATE,
488 STR_SORT_BY_RUNNING_COST,
489 STR_SORT_BY_POWER_VS_RUNNING_COST,
490 STR_SORT_BY_RELIABILITY,
491 STR_SORT_BY_CARGO_CAPACITY,
495 STR_SORT_BY_ENGINE_ID,
497 STR_SORT_BY_MAX_SPEED,
499 STR_SORT_BY_TRACTIVE_EFFORT,
500 STR_SORT_BY_INTRO_DATE,
502 STR_SORT_BY_RUNNING_COST,
503 STR_SORT_BY_POWER_VS_RUNNING_COST,
504 STR_SORT_BY_RELIABILITY,
505 STR_SORT_BY_CARGO_CAPACITY,
509 STR_SORT_BY_ENGINE_ID,
511 STR_SORT_BY_MAX_SPEED,
512 STR_SORT_BY_INTRO_DATE,
514 STR_SORT_BY_RUNNING_COST,
515 STR_SORT_BY_RELIABILITY,
516 STR_SORT_BY_CARGO_CAPACITY,
520 STR_SORT_BY_ENGINE_ID,
522 STR_SORT_BY_MAX_SPEED,
523 STR_SORT_BY_INTRO_DATE,
525 STR_SORT_BY_RUNNING_COST,
526 STR_SORT_BY_RELIABILITY,
527 STR_SORT_BY_CARGO_CAPACITY,
535 if (cid ==
CF_ANY)
return true;
537 return (cid ==
CF_NONE ? refit_mask == 0 :
HasBit(refit_mask, cid));
551 if (cap[c] == 0)
continue;
555 SetDParam(2,
HasBit(refits, c) ? STR_PURCHASE_INFO_REFITTABLE : STR_EMPTY);
556 DrawString(left, right, y, STR_PURCHASE_INFO_CAPACITY);
572 DrawString(left, right, y, STR_PURCHASE_INFO_COST_REFIT);
575 DrawString(left, right, y, STR_PURCHASE_INFO_COST);
584 DrawString(left, right, y, STR_PURCHASE_INFO_WEIGHT_CWEIGHT);
592 DrawString(left, right, y, STR_PURCHASE_INFO_SPEED);
598 if (rvi->running_cost_class != INVALID_PRICE) {
600 DrawString(left, right, y, STR_PURCHASE_INFO_RUNNINGCOST);
617 DrawString(left, right, y, STR_PURCHASE_INFO_COST_REFIT_WEIGHT);
621 DrawString(left, right, y, STR_PURCHASE_INFO_COST_WEIGHT);
628 DrawString(left, right, y, STR_PURCHASE_INFO_SPEED_POWER);
634 DrawString(left, right, y, STR_PURCHASE_INFO_MAX_TE);
639 if (rvi->running_cost_class != INVALID_PRICE) {
641 DrawString(left, right, y, STR_PURCHASE_INFO_RUNNINGCOST);
649 DrawString(left, right, y, STR_PURCHASE_INFO_PWAGPOWER_PWAGWEIGHT);
666 DrawString(left, right, y, STR_PURCHASE_INFO_COST_REFIT);
669 DrawString(left, right, y, STR_PURCHASE_INFO_COST);
678 DrawString(left, right, y, STR_PURCHASE_INFO_WEIGHT_CWEIGHT);
684 DrawString(left, right, y, STR_PURCHASE_INFO_SPEED_POWER);
689 DrawString(left, right, y, STR_PURCHASE_INFO_MAX_TE);
697 DrawString(left, right, y, STR_PURCHASE_INFO_COST_REFIT_SPEED);
701 DrawString(left, right, y, STR_PURCHASE_INFO_COST_SPEED);
708 DrawString(left, right, y, STR_PURCHASE_INFO_RUNNINGCOST);
724 if (ocean_speed == canal_speed) {
729 DrawString(left, right, y, STR_PURCHASE_INFO_COST_REFIT_SPEED);
733 DrawString(left, right, y, STR_PURCHASE_INFO_COST_SPEED);
740 DrawString(left, right, y, STR_PURCHASE_INFO_COST_REFIT);
743 DrawString(left, right, y, STR_PURCHASE_INFO_COST);
748 DrawString(left, right, y, STR_PURCHASE_INFO_SPEED_OCEAN);
752 DrawString(left, right, y, STR_PURCHASE_INFO_SPEED_CANAL);
759 SetDParam(2, refittable ? STR_PURCHASE_INFO_REFITTABLE : STR_EMPTY);
760 DrawString(left, right, y, STR_PURCHASE_INFO_CAPACITY);
765 DrawString(left, right, y, STR_PURCHASE_INFO_RUNNINGCOST);
789 DrawString(left, right, y, STR_PURCHASE_INFO_COST_REFIT_SPEED);
793 DrawString(left, right, y, STR_PURCHASE_INFO_COST_SPEED);
803 DrawString(left, right, y, STR_PURCHASE_INFO_AIRCRAFT_CAPACITY);
809 SetDParam(2, refittable ? STR_PURCHASE_INFO_REFITTABLE : STR_EMPTY);
810 DrawString(left, right, y, STR_PURCHASE_INFO_CAPACITY);
816 DrawString(left, right, y, STR_PURCHASE_INFO_RUNNINGCOST);
821 DrawString(left, right, y, STR_PURCHASE_INFO_AIRCRAFT_TYPE);
828 DrawString(left, right, y, STR_PURCHASE_INFO_AIRCRAFT_RANGE);
848 if (callback > 0x400) {
871 bool articulated_cargo =
false;
874 default: NOT_REACHED();
877 y = DrawRailWagonPurchaseInfo(left, right, y, engine_number, &e->u.rail, te);
879 y = DrawRailEnginePurchaseInfo(left, right, y, engine_number, &e->u.rail, te);
881 articulated_cargo =
true;
885 y = DrawRoadVehPurchaseInfo(left, right, y, engine_number, te);
886 articulated_cargo =
true;
890 y = DrawShipPurchaseInfo(left, right, y, engine_number, refittable, te);
898 if (articulated_cargo) {
900 int new_y = DrawCargoCapacityInfo(left, right, y, engine_number, te);
905 DrawString(left, right, y, STR_PURCHASE_INFO_CAPACITY);
917 DrawString(left, right, y, STR_PURCHASE_INFO_DESIGNED_LIFE);
922 DrawString(left, right, y, STR_PURCHASE_INFO_RELIABILITY);
949 static const int sprite_y_offsets[] = { -1, -1, -2, -2 };
952 assert(max <= eng_list->size());
958 int sprite_width = sprite_left + sprite_right;
960 int sprite_x = rtl ? r - sprite_right - 1 : l + sprite_left + 1;
961 int sprite_y_offset = sprite_y_offsets[type] + step_size / 2;
979 int replace_icon_y_offset = (step_size - replace_icon.height) / 2 - 1;
981 for (; min <
max; min++, y += step_size) {
988 StringID str = hidden ? STR_HIDDEN_ENGINE_NAME : STR_ENGINE_NAME;
992 DrawString(text_left, text_right, y + normal_text_y_offset, str, tc);
1011 uint32 hidden_mask = 0;
1046 void SetBuyVehicleText()
1064 this->vehicle_type = type;
1066 this->
window_number = this->listview_mode ? (int)type : tile;
1088 widget->
tool_tip = STR_BUY_VEHICLE_TRAIN_LIST_TOOLTIP + type;
1091 widget->
tool_tip = STR_BUY_VEHICLE_TRAIN_HIDE_SHOW_TOGGLE_TOOLTIP + type;
1094 widget->
widget_data = STR_BUY_VEHICLE_TRAIN_RENAME_BUTTON + type;
1095 widget->
tool_tip = STR_BUY_VEHICLE_TRAIN_RENAME_TOOLTIP + type;
1098 widget->
widget_data = STR_SHOW_HIDDEN_ENGINES_VEHICLE_TRAIN + type;
1099 widget->
tool_tip = STR_SHOW_HIDDEN_ENGINES_VEHICLE_TRAIN_TOOLTIP + type;
1100 widget->
SetLowered(this->show_hidden_engines);
1109 this->GenerateBuildList();
1111 if (this->eng_list.size() > 0) {
1112 this->SelectEngine(this->eng_list[0]);
1121 switch (this->vehicle_type) {
1122 default: NOT_REACHED();
1124 if (this->listview_mode) {
1132 if (this->listview_mode) {
1151 uint filter_items = 0;
1154 this->cargo_filter[filter_items] =
CF_ANY;
1155 this->cargo_filter_texts[filter_items] = STR_PURCHASE_INFO_ALL_TYPES;
1161 this->cargo_filter[filter_items] =
CF_NONE;
1162 this->cargo_filter_texts[filter_items] = STR_PURCHASE_INFO_NONE;
1169 this->cargo_filter[filter_items] = cs->
Index();
1170 this->cargo_filter_texts[filter_items] = cs->
name;
1178 this->cargo_filter_criteria = 0;
1181 for (uint i = 0; i < filter_items; i++) {
1183 this->cargo_filter_criteria = i;
1197 this->sel_engine = engine;
1198 this->SetBuyVehicleText();
1209 if (!this->listview_mode) {
1235 this->eng_list.
Filter(this->cargo_filter[this->cargo_filter_criteria]);
1236 if (0 == this->eng_list.size()) {
1238 }
else if (std::find(this->eng_list.begin(), this->eng_list.end(), this->
sel_engine) == this->eng_list.end()) {
1239 this->SelectEngine(this->eng_list[0]);
1251 void GenerateBuildTrainList()
1254 int num_engines = 0;
1257 this->eng_list.clear();
1264 if (!this->show_hidden_engines && e->IsHidden(
_local_company))
continue;
1274 this->eng_list.push_back(eid);
1282 if (eid == this->sel_engine) sel_id = eid;
1285 this->SelectEngine(sel_id);
1300 void GenerateBuildRoadVehList()
1304 this->eng_list.clear();
1307 if (!this->show_hidden_engines && e->IsHidden(
_local_company))
continue;
1312 this->eng_list.push_back(eid);
1314 if (eid == this->sel_engine) sel_id = eid;
1316 this->SelectEngine(sel_id);
1320 void GenerateBuildShipList()
1323 this->eng_list.clear();
1326 if (!this->show_hidden_engines && e->IsHidden(
_local_company))
continue;
1329 this->eng_list.push_back(eid);
1331 if (eid == this->sel_engine) sel_id = eid;
1333 this->SelectEngine(sel_id);
1337 void GenerateBuildAircraftList()
1341 this->eng_list.clear();
1350 if (!this->show_hidden_engines && e->IsHidden(
_local_company))
continue;
1356 this->eng_list.push_back(eid);
1357 if (eid == this->sel_engine) sel_id = eid;
1360 this->SelectEngine(sel_id);
1364 void GenerateBuildList()
1371 switch (this->vehicle_type) {
1372 default: NOT_REACHED();
1374 this->GenerateBuildTrainList();
1375 this->eng_list.shrink_to_fit();
1379 this->GenerateBuildRoadVehList();
1382 this->GenerateBuildShipList();
1385 this->GenerateBuildAircraftList();
1394 this->eng_list.shrink_to_fit();
1402 this->descending_sort_order ^=
true;
1409 this->show_hidden_engines ^=
true;
1418 size_t num_items = this->eng_list.size();
1419 this->SelectEngine((i < num_items) ? this->eng_list[i] :
INVALID_ENGINE);
1423 }
else if (click_count > 1 && !this->listview_mode) {
1459 this->rename_engine = sel_eng;
1475 if (!gui_scope)
return;
1477 if (this->vehicle_type ==
VEH_ROAD &&
1479 this->sort_criteria > 7) {
1480 this->sort_criteria = 0;
1490 if (this->vehicle_type ==
VEH_TRAIN && !this->listview_mode) {
1493 }
else if (this->vehicle_type ==
VEH_ROAD && !this->listview_mode) {
1497 SetDParam(0, (this->listview_mode ? STR_VEHICLE_LIST_AVAILABLE_TRAINS : STR_BUY_VEHICLE_TRAIN_ALL_CAPTION) + this->vehicle_type);
1506 SetDParam(0, this->cargo_filter_texts[this->cargo_filter_criteria]);
1512 SetDParam(0, STR_BUY_VEHICLE_TRAIN_SHOW_TOGGLE_BUTTON + this->vehicle_type);
1514 SetDParam(0, STR_BUY_VEHICLE_TRAIN_HIDE_TOGGLE_BUTTON + this->vehicle_type);
1526 size->height = 3 * resize->height;
1537 d.height += padding.height;
1538 *size =
maxdim(*size, d);
1545 size->width += padding.width;
1546 size->height += padding.height;
1552 size->width += padding.width;
1553 size->height += padding.height;
1562 DrawEngineList(this->vehicle_type, r.left +
WD_FRAMERECT_LEFT, r.right -
WD_FRAMERECT_RIGHT, r.top +
WD_FRAMERECT_TOP, &this->eng_list, this->vscroll->GetPosition(),
min(this->vscroll->
GetPosition() + this->vscroll->
GetCapacity(), (uint)this->eng_list.size()), this->sel_engine,
false,
DEFAULT_GROUP);
1573 this->GenerateBuildList();
1574 this->vscroll->
SetCount((uint)this->eng_list.size());
1589 if (needed_height != this->details_height) {
1591 this->details_height = needed_height;
1600 if (str ==
nullptr)
return;
1609 if (this->sort_criteria != index) {
1610 this->sort_criteria = index;
1617 if (this->cargo_filter_criteria != index) {
1618 this->cargo_filter_criteria = index;
1623 this->SelectEngine(this->sel_engine);
1637 WDP_AUTO,
"build_vehicle", 240, 268,
1640 _nested_build_vehicle_widgets,
lengthof(_nested_build_vehicle_widgets)
bool IsEngineBuildable(EngineID engine, VehicleType type, CompanyID company)
Check if an engine is buildable.
void DrawVehicleEngine(int left, int right, int preferred_x, int y, EngineID engine, PaletteID pal, EngineImageType image_type)
Draw an engine.
Functions related to OTTD's strings.
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
static bool HasPowerOnRail(RailType enginetype, RailType tiletype)
Checks if an engine of the given RailType got power on a tile with a given RailType.
uint16 reliability
Current reliability of the engine.
void RebuildDone()
Notify the sortlist that the rebuild is done.
GameSettings _settings_game
Game settings of a running game or the scenario editor.
bool _networking
are we in networking mode?
Functions for NewGRF engines.
static const RailtypeInfo * GetRailTypeInfo(RailType railtype)
Returns a pointer to the Railtype information for a given railtype.
void DrawWidget(const Rect &r, int widget) const override
Draw the contents of a nested widget.
static const uint CALLBACK_FAILED
Different values for Callback result evaluations.
ResizeInfo resize
Resize information.
uint8 weight
Weight of a single unit of this cargo type in 1/16 ton (62.5 kg).
void DrawEngineList(VehicleType type, int l, int r, int y, const GUIEngineList *eng_list, uint16 min, uint16 max, EngineID selected_id, bool show_count, GroupID selected_group)
Engine drawing loop.
static bool EnginePowerSorter(const EngineID &a, const EngineID &b)
Determines order of engines by power.
Window(WindowDesc *desc)
Empty constructor, initialization has been moved to InitNested() called from the constructor of the d...
void SetWidgetDisabledState(byte widget_index, bool disab_stat)
Sets the enabled/disabled status of a widget.
CargoID cargo_filter[NUM_CARGO+2]
Available cargo filters; CargoID or CF_ANY or CF_NONE.
void SetWidgetLoweredState(byte widget_index, bool lowered_stat)
Sets the lowered/raised status of a widget.
GUI for building vehicles.
High level window description.
StringID GetAircraftTypeText() const
Get the name of the aircraft type for display purposes.
bool Filter(FilterFunction *decide, F filter_data)
Filter the list.
uint GetGroupNumEngines(CompanyID company, GroupID id_g, EngineID id_e)
Get the number of engines with EngineID id_e in the group with GroupID id_g and its sub-groups...
void DrawWidgets() const
Paint all widgets of a window.
static Titem * Get(size_t index)
Returns Titem with given index.
union BuildVehicleWindow::@0 filter
Filter to apply.
bool CanCarryCargo() const
Determines whether an engine can carry something.
Functions related to dates.
static bool TrainEngineCapacitySorter(const EngineID &a, const EngineID &b)
Determines order of train engines by capacity.
Offset at top to draw the frame rectangular area.
uint16 capacity
Cargo capacity.
uint16 GetRange() const
Get the range of an aircraft type.
static T SetBit(T &x, const uint8 y)
Set a bit in a variable.
void DisplayVehicleSortDropDown(Window *w, VehicleType vehicle_type, int selected, int button)
Display the dropdown for the vehicle sort criteria.
byte sort_criteria
Current sort criterium.
query cost only, don't build.
byte _engine_sort_last_criteria[]
Last set sort criteria, for each vehicle type.
void CDECL SetWidgetsDisabledState(bool disab_stat, int widgets,...)
Sets the enabled/disabled status of a list of widgets.
void ShowQueryString(StringID str, StringID caption, uint maxsize, Window *parent, CharSetFilter afilter, QueryStringFlags flags)
Show a query popup window with a textbox in it.
Base class for groups and group functions.
Maximal number of cargo types in a game.
Date intro_date
Date of introduction of the engine.
Flag for invalid railtype.
uint ApplyWaterClassSpeedFrac(uint raw_speed, bool is_ocean) const
Apply ocean/canal speed fraction to a velocity.
uint16 _returned_refit_capacity
Stores the capacity after a refit operation.
Specification of a cargo type.
VehicleType
Available vehicle types.
uint extend_right
Extend of the cell to the right.
Functions related to vehicles.
CargoTypes GetUnionOfArticulatedRefitMasks(EngineID engine, bool include_initial_cargo_type)
Ors the refit_masks of all articulated parts.
static bool CDECL CargoFilter(const EngineID *eid, const CargoID cid)
Cargo filter functions.
CompanyMask company_hidden
Bit for each company whether the engine is normally hidden in the build gui for that company...
EngineID sel_engine
Currently selected engine, or INVALID_ENGINE.
void OnQueryTextFinished(char *str) override
The query window opened from this window has closed.
Build vehicle; Window numbers:
VehicleCellSize GetVehicleImageCellSize(VehicleType type, EngineImageType image_type)
Get the GUI cell size for a vehicle image.
uint height
Vehicle cell height.
flag for invalid roadtype
static bool EngineIntroDateSorter(const EngineID &a, const EngineID &b)
Determines order of engines by introduction date.
Offset at top of a matrix cell.
void SetCargoFilterArray()
Populate the filter list and set the cargo filter criteria.
uint GetEngineListHeight(VehicleType type)
Get the height of a single 'entry' in the engine lists.
StringID build_caption
Caption of the build vehicle GUI for this rail type.
#define lastof(x)
Get the last element of an fixed size array.
void ReInit(int rx=0, int ry=0)
Re-initialize a window, and optionally change its size.
StringID GetGRFStringID(uint32 grfid, StringID stringid)
Returns the index for this stringid associated with its grfID.
Money GetCost() const
The costs as made up to this moment.
Stuff related to the text buffer GUI.
void SetFilterFuncs(FilterFunction *const *n_funcs)
Hand the array of filter function pointers to the sort list.
EngList_SortTypeFunction *const _engine_sort_functions[][11]
Sort functions for the vehicle sort criteria, for each vehicle type.
Common return value for all commands.
Vehicle drawn in purchase list, autoreplace gui, ...
byte pow_wag_weight
Extra weight applied to consist if wagon should be powered.
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.
RoadType
The different roadtypes we support.
static T max(const T a, const T b)
Returns the maximum of two values.
struct RailtypeInfo::@39 strings
Strings associated with the rail type.
void CreateNestedTree(bool fill_nested=true)
Perform the first part of the initialization of a nested widget tree.
Functions related to the vehicle's GUIs.
CargoID GetDefaultCargoType() const
Determines the default cargo type of an engine.
uint16 mail_capacity
Mail capacity if available.
StringID name
Name of this type of cargo.
Do not refit cargo of a vehicle (used in vehicle orders and auto-replace/auto-new).
bool NeedRebuild() const
Check if a rebuild is needed.
static bool AircraftRangeSorter(const EngineID &a, const EngineID &b)
Determines order of aircraft by range.
StringID build_caption
Caption of the build vehicle GUI for this rail type.
This struct contains all the info that is needed to draw and construct tracks.
bool _engine_sort_last_order[]
Last set direction of the sort order, for each vehicle type.
Force the alignment, i.e. don't swap for RTL languages.
void ForceRebuild()
Force that a rebuild is needed.
static bool AircraftEngineCargoSorter(const EngineID &a, const EngineID &b)
Determines order of aircraft by cargo.
Data structure for an opened 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.
hide or unhide a vehicle in the build vehicle and autoreplace GUIs
static bool EngineRunningCostSorter(const EngineID &a, const EngineID &b)
Determines order of engines by running costs.
Header of Action 04 "universal holder" structure and functions.
bool show_hidden_engines
State of the 'show hidden engines' button.
enable the 'Default' button ("\0" is returned)
static const RoadTypeInfo * GetRoadTypeInfo(RoadType roadtype)
Returns a pointer to the Roadtype information for a given roadtype.
Functions related to low-level strings.
This callback is called from vehicle purchase lists.
void CommandCallback(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2, uint32 cmd)
Define a callback function for the client, after the command is finished.
Money GetCost() const
Return how much a new engine costs.
RoadType roadtype
Road type to show, or INVALID_ROADTYPE.
int DrawVehiclePurchaseInfo(int left, int right, int y, EngineID engine_number, TestedEngineDetails &te)
Draw the purchase info details of a vehicle at a given location.
Offset at bottom of a matrix cell.
static bool RoadVehEngineCapacitySorter(const EngineID &a, const EngineID &b)
Determines order of road vehicles by capacity.
#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.
TestedEngineDetails te
Tested cost and capacity after refit.
This window is used for construction; close it whenever changing company.
static bool TrainEnginesThenWagonsSorter(const EngineID &a, const EngineID &b)
Determines order of train engines by engine / wagon.
Functions related to engines.
Extra information about refitted cargo and capacity.
uint16 pow_wag_power
Extra power applied to consist if wagon should be powered.
static Owner GetTileOwner(TileIndex tile)
Returns the owner of a tile.
RailType railtype
Rail type to show, or INVALID_RAILTYPE.
#define FONT_HEIGHT_NORMAL
Height of characters in the normal (FS_NORMAL) font.
simple wagon, not motorized
bool descending_sort_order
Sort direction,.
bool Succeeded() const
Did this command succeed?
void UpdateFilterByTile()
Set the filter type according to the depot type.
Definition of base types and functions in a cross-platform compatible way.
PaletteID GetEnginePalette(EngineID engine_type, CompanyID company)
Get the colour map for an engine.
Data structure to convert between Date and triplet (year, month, and day).
the length of the string is counted in characters
static CargoID _engine_sort_last_cargo_criteria[]
Last set filter criteria, for each vehicle type.
void EngList_SortPartial(GUIEngineList *el, EngList_SortTypeFunction compare, uint begin, uint num_items)
Sort selected range of items (on indices @ <begin, begin+num_items-1>)
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...
uint8 acceleration_type
Acceleration type of this rail type.
bool listview_mode
If set, only display the available vehicles and do not show a 'build' button.
bool EngList_SortTypeFunction(const EngineID &, const EngineID &)
argument type for EngList_Sort.
static bool EngineCostSorter(const EngineID &a, const EngineID &b)
Determines order of engines by purchase cost.
uint16 GroupID
Type for all group identifiers.
Engine GUI functions, used by build_vehicle_gui and autoreplace_gui
static bool EngineTractiveEffortSorter(const EngineID &a, const EngineID &b)
Determines order of engines by tractive effort.
VehicleType type
Vehicle type, ie VEH_ROAD, VEH_TRAIN, etc.
void DrawSortButtonState(int widget, SortButtonState state) const
Draw a sort button's up or down arrow symbol.
VehicleType vehicle_type
Type of vehicles shown in the window.
const Scrollbar * GetScrollbar(uint widnum) const
Return the Scrollbar to a widget index.
static bool EngineSpeedSorter(const EngineID &a, const EngineID &b)
Determines order of engines by speed.
void SetDParamMaxDigits(uint n, uint count, FontSize size)
Set DParam n to some number that is suitable for string size computations.
const StringID _engine_sort_listing[][12]
Dropdown menu strings for the vehicle sort criteria.
Offset at bottom to draw the frame rectangular area.
bool CanVehicleUseStation(EngineID engine_type, const Station *st)
Can this station be used by the given engine type?
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.
Basic functions/variables used all over the place.
struct RoadTypeInfo::@42 strings
Strings associated with the rail type.
Right offset of the text of the frame.
bool DoCommandP(const CommandContainer *container, bool my_cmd)
Shortcut for the long DoCommandP when having a container with the data.
#define lengthof(x)
Return the length of an fixed size array.
static T min(const T a, const T b)
Returns the minimum of two values.
#define FOR_ALL_SORTED_STANDARD_CARGOSPECS(var)
Loop header for iterating over 'real' cargoes, sorted by name.
Left offset of the text of the frame.
void FilterEngineList()
Filter the engine list against the currently selected cargo filter.
void StartTextRefStackUsage(const GRFFile *grffile, byte numEntries, const uint32 *values)
Start using the TTDP compatible string code parsing.
static int SortButtonWidth()
Get width of up/down arrow of sort button state.
StringID cargo_filter_texts[NUM_CARGO+3]
Texts for filter_cargo, terminated by INVALID_STRING_ID.
uint32 StringID
Numeric value that represents a string, independent of the selected language.
int details_height
Minimal needed height of the details panels (found so far).
void CcBuildWagon(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2, uint32 cmd)
Callback for building wagons.
Information about a rail vehicle.
uint GetDisplayMaxSpeed() const
Returns max speed of the engine for display purposes.
void SetDirty() const
Mark entire window as dirty (in need of re-paint)
static const CargoID CF_ANY
Special cargo filter criteria.
Dimension GetStringBoundingBox(const char *str, FontSize start_fontsize)
Return the string dimension in pixels.
bool IsHidden(CompanyID c) const
Check whether the engine is hidden in the GUI for the given company.
bool _engine_sort_direction
false = descending, true = ascending.
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).
void GetArticulatedVehicleCargoesAndRefits(EngineID engine, CargoArray *cargoes, CargoTypes *refits, CargoID cargo_type, uint16 cargo_capacity)
Get the default cargoes and refits of an articulated vehicle.
uint GetPower() const
Returns the power of the engine for display and sorting purposes.
static const EngineID INVALID_ENGINE
Constant denoting an invalid engine.
static const GroupID DEFAULT_GROUP
Ungrouped vehicles are in this group.
static int32 ClampToI32(const int64 a)
Reduce a signed 64-bit int to a signed 32-bit one.
Functions related to companies.
static bool HasPowerOnRoad(RoadType enginetype, RoadType tiletype)
Checks if an engine of the given RoadType got power on a tile with a given RoadType.
uint GetTotalCapacityOfArticulatedParts(EngineID engine)
Get the capacity of an engine with articulated parts.
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.
Both numeric and alphabetic and spaces and stuff.
RailType
Enumeration for all possible railtypes.
void OnPaint() override
The window must be repainted.
int strnatcmp(const char *s1, const char *s2, bool ignore_garbage_at_front)
Compares two strings using case insensitive natural sort.
EngineID rename_engine
Engine being renamed.
bool FilterSingleEngine(EngineID eid)
Filter a single engine.
uint16 EngineID
Unique identification number of an engine.
void SetFilterState(bool state)
Enable or disable the filter.
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.
TextDirection _current_text_dir
Text direction of the currently selected language.
bool CDECL FilterFunction(const EngineID *, CargoID)
Signature of filter function.
bool wagon_speed_limits
enable wagon speed limits
indicates a combination of two locomotives
Do not add shading to this text colour.
static int DrawAircraftPurchaseInfo(int left, int right, int y, EngineID engine_number, bool refittable, TestedEngineDetails &te)
Draw aircraft specific details in the buy window.
byte cargo_filter_criteria
Selected cargo filter.
static uint ShowAdditionalText(int left, int right, int y, EngineID engine)
Display additional text from NewGRF in the purchase information window.
static Station * GetByTile(TileIndex tile)
Get the station belonging to a specific tile.
Functions related to the drop down widget.
uint16 _returned_mail_refit_capacity
Stores the mail capacity after a refit operation (Aircraft only).
uint GetDisplayDefaultCapacity(uint16 *mail_capacity=nullptr) const
Determines the default cargo capacity of an engine for display purposes.
static uint ToPercent16(uint i)
Converts a "fract" value 0..65535 to "percent" value 0..100.
void EngList_Sort(GUIEngineList *el, EngList_SortTypeFunction compare)
Sort all items using quick sort and given 'CompareItems' function.
Functions related to commands.
Types/functions related to cargoes.
bool _network_server
network-server is active
Coordinates of a point in 2D.
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.
rename a engine (in the engine list)
uint8 train_acceleration_model
realistic acceleration for trains
Index of the small font in the font tables.
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 roadveh_acceleration_model
realistic acceleration for road vehicles
static bool EngineHasReplacementForCompany(const Company *c, EngineID engine, GroupID group)
Check if a company has a replacement set up for the given engine.
Offset at right to draw the frame rectangular area.
Money GetRunningCost() const
Return how much the running costs of this engine are.
void OnInit() override
Notification that the nested widget tree gets initialized.
static bool EngineReliabilitySorter(const EngineID &a, const EngineID &b)
Determines order of engines by reliability.
static bool HasBit(const T x, const uint8 y)
Checks if a bit in a value is set.
static bool ShipEngineCapacitySorter(const EngineID &a, const EngineID &b)
Determines order of ships by capacity.
static const TileIndex INVALID_TILE
The very nice invalid tile marker.
#define CMD_MSG(x)
Used to combine a StringID with the command.
static bool EnginePowerVsRunningCostSorter(const EngineID &a, const EngineID &b)
Determines order of engines by running costs.
CargoTypes _standard_cargo_mask
Bitmask of real cargo types available.
Specification of a rectangle with absolute coordinates of all edges.
byte CargoID
Cargo slots to indicate a cargo type within a game.
bool IsShaded() const
Is window shaded currently?
void OnInvalidateData(int data=0, bool gui_scope=true) override
Some data on this window has become invalid.
Text is written right-to-left by default.
Right align the text (must be a single bit).
WindowNumber window_number
Window number within the window class.
uint extend_left
Extend of the cell to the left.
static bool EngineNameSorter(const EngineID &a, const EngineID &b)
Determines order of engines by name.
static const uint MAX_LENGTH_ENGINE_NAME_CHARS
The maximum length of an engine name in characters including '\0'.
bool _engine_sort_show_hidden_engines[]
Last set 'show hidden engines' setting for each vehicle type.
static bool EngineNumberSorter(const EngineID &a, const EngineID &b)
Determines order of engines by engineID.
Window functions not directly related to making/drawing windows.
uint ShowRefitOptionsList(int left, int right, int y, EngineID engine)
Display list of cargo types of the engine, for the purchase information 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.
Find a place automatically.
uint GetDisplayWeight() const
Returns the weight of the engine for display purposes.
Base classes/functions for stations.
Functions related to autoreplacing.
void ConvertDateToYMD(Date date, YearMonthDay *ymd)
Converts a Date to a Year, Month & Day.
void OnDropdownSelect(int widget, int index) override
A dropdown option associated to this window has been selected.
uint GetDisplayMaxTractiveEffort() const
Returns the tractive effort of the engine for display purposes.
void OnClick(Point pt, int widget, int click_count) override
A click with the left mouse button has been made on the window.
CompanyID _local_company
Company controlled by the human player at this client. Can also be COMPANY_SPECTATOR.
static bool IsCompanyBuildableVehicleType(VehicleType type)
Is the given vehicle type buildable by a company?
Dimensions (a width and height) of a rectangle in 2D.
Offset at left to draw the frame rectangular area.
Date GetLifeLengthInDays() const
Returns the vehicle's (not model's!) life length in days.
void DrawSprite(SpriteID img, PaletteID pal, int x, int y, const SubSprite *sub, ZoomLevel zoom)
Draw a sprite, not in a viewport.
static RailType GetRailType(TileIndex t)
Gets the rail type of the given tile.
void SetStringParameters(int widget) const override
Initialize string parameters for a widget.
void OnResize() override
Called after the window got resized.
static const int DAYS_IN_LEAP_YEAR
sometimes, you need one day more...
void StopTextRefStackUsage()
Stop using the TTDP compatible string code parsing.
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.
bool IsArticulatedVehicleRefittable(EngineID engine)
Checks whether any of the articulated parts is refittable.
Dynamic data of a loaded NewGRF.
static const CargoID CF_NONE
Show only vehicles which do not carry cargo (e.g. train engines)
static void SetDParam(uint n, uint64 v)
Set a string parameter v at index n in the global string parameter array.
static Pool::IterateWrapper< Engine > IterateType(VehicleType vt, size_t from=0)
Returns an iterable ensemble of all valid engines of the given type.