19#include "table/strings.h"
33 Money feeder_share = 0;
38 DrawString(r.left, r.right, y, STR_VEHICLE_INFO_BUILT_VALUE);
43 std::array<StringID, NUM_CARGO> subtype_text{};
45 for (
const Vehicle *u = v; u !=
nullptr; u = u->
Next()) {
46 max_cargo[u->cargo_type] += u->cargo_cap;
47 if (u->cargo_cap > 0) {
49 if (text != STR_EMPTY) subtype_text[u->cargo_type] = text;
53 std::string capacity =
GetString(STR_VEHICLE_DETAILS_TRAIN_ARTICULATED_RV_CAPACITY);
59 if (max_cargo[cid] > 0) {
60 if (!first) capacity += list_separator;
66 if (subtype_text[cid] != STR_NULL) {
74 DrawString(r.left, r.right, y, capacity, TC_BLUE);
77 for (
const Vehicle *u = v; u !=
nullptr; u = u->
Next()) {
78 if (u->cargo_cap == 0)
continue;
80 str = STR_VEHICLE_DETAILS_CARGO_EMPTY;
81 if (u->cargo.StoredCount() > 0) {
85 str = STR_VEHICLE_DETAILS_CARGO_FROM;
86 feeder_share += u->cargo.GetFeederShare();
96 DrawString(r.left, r.right, y, STR_VEHICLE_INFO_CAPACITY);
99 str = STR_VEHICLE_DETAILS_CARGO_EMPTY;
104 str = STR_VEHICLE_DETAILS_CARGO_FROM;
113 DrawString(r.left, r.right, y, STR_VEHICLE_INFO_FEEDER_CARGO_VALUE);
130 int max_width = r.
Width();
138 static std::vector<CargoIconOverlay> overlays;
140 int px = rtl ? max_width + skip : -skip;
142 for (; u !=
nullptr && (rtl ? px > 0 : px < max_width); u = u->
Next())
147 if (rtl ? px + width > 0 : px - width < max_width) {
155 px += rtl ? -width : width;
163 if (v->
index == selection) {
165 Rect hr = {(rtl ? px : 0), 0, (rtl ? max_width : px) - 1, height - 1};
Class for backupping variables and making sure they are restored later.
uint8_t CargoID
Cargo slots to indicate a cargo type within a game.
std::vector< const CargoSpec * > _sorted_cargo_specs
Cargo specifications sorted alphabetically by name.
Money GetFeederShare() const
Returns total sum of the feeder share for all packets.
StationID GetFirstStation() const
Returns the first station of the first cargo packet in this list.
uint StoredCount() const
Returns sum of cargo on board the vehicle (ie not only reserved).
Direction
Defines the 8 directions on the map.
uint64_t PackEngineNameDParam(EngineID engine_id, EngineNameContext context, uint32_t extra_data=0)
Combine an engine ID and a name context to an engine name dparam.
@ VehicleDetails
Name is shown in the vehicle details GUI.
int GetCharacterHeight(FontSize size)
Get height of a character for a given font size.
int DrawString(int left, int right, int top, std::string_view str, TextColour colour, StringAlignment align, bool underline, FontSize fontsize)
Draw string, possibly truncated to make it fit in its allocated space.
bool FillDrawPixelInfo(DrawPixelInfo *n, int left, int top, int width, int height)
Set up a clipping area for only drawing into a certain area.
int CenterBounds(int min, int max, int size)
Determine where to draw a centred object inside a widget.
@ FS_NORMAL
Index of the normal font in the font tables.
uint32_t PaletteID
The number of the palette.
void DrawRoadVehImage(const Vehicle *v, const Rect &r, VehicleID selection, EngineImageType image_type, int skip)
Draws an image of a road vehicle chain.
void DrawRoadVehDetails(const Vehicle *v, const Rect &r)
Draw the details for the given vehicle at the given position.
A number of safeguards to prevent using unsafe methods.
static const PaletteID PALETTE_CRASH
Recolour sprite greying of crashed vehicles.
Definition of base types and functions in a cross-platform compatible way.
Functions related to low-level strings.
std::string_view GetListSeparator()
Get the list separator string for the current language.
void AppendStringInPlace(std::string &result, StringID string)
Resolve the given StringID and append in place into an existing std::string with all the associated D...
void SetDParam(size_t n, uint64_t v)
Set a string parameter v at index n in the global string parameter array.
std::string GetString(StringID string)
Resolve the given StringID into a std::string with all the associated DParam lookups and formatting.
TextDirection _current_text_dir
Text direction of the currently selected language.
Functions related to OTTD's strings.
@ TD_RTL
Text is written right-to-left by default.
uint32_t StringID
Numeric value that represents a string, independent of the selected language.
Class to backup a specific variable and restore it upon destruction of this object to prevent stack v...
Class for storing amounts of cargo.
Specification of a cargo type.
Data about how and where to blit pixels.
Coordinates of a point in 2D.
Tindex index
Index of this pool item.
Specification of a rectangle with absolute coordinates of all edges.
int Width() const
Get width of Rect.
int Height() const
Get height of Rect.
Rect Translate(int x, int y) const
Copy and translate Rect by x,y pixels.
Rect Expand(int s) const
Copy and expand Rect by s pixels.
Buses, trucks and trams belong to this class.
int GetDisplayImageWidth(Point *offset=nullptr) const
Get the width of a road vehicle image in the GUI.
void GetImage(Direction direction, EngineImageType image_type, VehicleSpriteSeq *result) const override
Gets the sprite to show for the given direction.
T * Next() const
Get next vehicle in the chain.
static T * From(Vehicle *v)
Converts a Vehicle to SpecializedVehicle with type checking.
Sprite sequence for a vehicle part.
void Draw(int x, int y, PaletteID default_pal, bool force_pal) const
Draw the sprite sequence.
EngineID engine_type
The type of engine used for this vehicle.
VehicleCargoList cargo
The cargo this vehicle is carrying.
uint16_t cargo_cap
total capacity
bool HasArticulatedPart() const
Check if an engine has an articulated part.
CargoID cargo_type
type of cargo this vehicle is carrying
Vehicle * Next() const
Get the next vehicle of this vehicle.
Money value
Value of the vehicle.
TimerGameCalendar::Year build_year
Year the vehicle has been built.
PaletteID GetVehiclePalette(const Vehicle *v)
Get the colour map for a vehicle.
@ VS_CRASHED
Vehicle is crashed.
Functions related to vehicles.
StringID GetCargoSubtypeText(const Vehicle *v)
Get the cargo subtype text from NewGRF for the vehicle details window.
void DrawCargoIconOverlays(std::span< const CargoIconOverlay > overlays, int y)
Draw a list of cargo icon overlays.
void AddCargoIconOverlay(std::vector< CargoIconOverlay > &overlays, int x, int width, const Vehicle *v)
Add a cargo icon to the list of overlays.
bool ShowCargoIconOverlay()
Test if cargo icon overlays should be drawn.
EngineImageType
Visualisation contexts of vehicles and engines.
uint32_t VehicleID
The type all our vehicle IDs have.
Functions, definitions and such used only by the GUI.
@ FR_BORDERONLY
Draw border only, no background.
Functions related to zooming.
int ScaleSpriteTrad(int value)
Scale traditional pixel dimensions to GUI zoom level, for drawing sprites.