Go to the documentation of this file.
18 #include "table/strings.h"
32 Money feeder_share = 0;
37 DrawString(r.left, r.right, y, STR_VEHICLE_INFO_BUILT_VALUE);
45 memset(subtype_text, 0,
sizeof(subtype_text));
47 for (
const Vehicle *u = v; u !=
nullptr; u = u->
Next()) {
48 max_cargo[u->cargo_type] += u->cargo_cap;
49 if (u->cargo_cap > 0) {
51 if (text != STR_EMPTY) subtype_text[u->cargo_type] = text;
55 GetString(capacity, STR_VEHICLE_DETAILS_TRAIN_ARTICULATED_RV_CAPACITY,
lastof(capacity));
59 if (max_cargo[i] > 0) {
64 GetString(buffer, STR_JUST_CARGO,
lastof(buffer));
69 if (subtype_text[i] != 0) {
70 GetString(buffer, subtype_text[i],
lastof(buffer));
78 DrawString(r.left, r.right, y, capacity, TC_BLUE);
81 for (
const Vehicle *u = v; u !=
nullptr; u = u->
Next()) {
82 if (u->cargo_cap == 0)
continue;
84 str = STR_VEHICLE_DETAILS_CARGO_EMPTY;
85 if (u->cargo.StoredCount() > 0) {
89 str = STR_VEHICLE_DETAILS_CARGO_FROM;
90 feeder_share += u->cargo.FeederShare();
100 DrawString(r.left, r.right, y, STR_VEHICLE_INFO_CAPACITY);
103 str = STR_VEHICLE_DETAILS_CARGO_EMPTY;
108 str = STR_VEHICLE_DETAILS_CARGO_FROM;
117 DrawString(r.left, r.right, y, STR_VEHICLE_INFO_FEEDER_CARGO_VALUE);
134 int max_width = r.
Width();
141 int px = rtl ? max_width + skip : -skip;
143 for (; u !=
nullptr && (rtl ? px > 0 : px < max_width); u = u->
Next())
148 if (rtl ? px + width > 0 : px - width < max_width) {
155 px += rtl ? -width : width;
160 if (v->
index == selection) {
162 Rect hr = {(rtl ? px : 0), 0, (rtl ? max_width : px) - 1, height - 1};
Buses, trucks and trams belong to this class.
uint StoredCount() const
Returns sum of cargo on board the vehicle (ie not only reserved).
int Height() const
Get height of Rect.
Direction
Defines the 8 directions on the map.
Money value
Value of the vehicle.
uint64 PackEngineNameDParam(EngineID engine_id, EngineNameContext context, uint32 extra_data=0)
Combine an engine ID and a name context to an engine name dparam.
Vehicle * Next() const
Get the next vehicle of this vehicle.
T * Next() const
Get next vehicle in the chain.
Tindex index
Index of this pool item.
Class for storing amounts of cargo.
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.
Rect Expand(int s) const
Copy and expand Rect by s pixels.
EngineImageType
Visualisation contexts of vehicles and engines.
void Draw(int x, int y, PaletteID default_pal, bool force_pal) const
Draw the sprite sequence.
void GetImage(Direction direction, EngineImageType image_type, VehicleSpriteSeq *result) const override
Gets the sprite to show for the given direction.
static void SetDParam(uint n, uint64 v)
Set a string parameter v at index n in the global string parameter array.
Rect Translate(int x, int y) const
Copy and translate Rect by x,y pixels.
EngineID engine_type
The type of engine used for this vehicle.
@ VS_CRASHED
Vehicle is crashed.
Sprite sequence for a vehicle part.
VehicleCargoList cargo
The cargo this vehicle is carrying.
static int ScaleSpriteTrad(int value)
Scale traditional pixel dimensions to GUI zoom level, for drawing sprites.
Coordinates of a point in 2D.
@ VehicleDetails
Name is shown in the vehicle details GUI.
void DrawRoadVehImage(const Vehicle *v, const Rect &r, VehicleID selection, EngineImageType image_type, int skip)
Draws an image of a road vehicle chain.
bool FillDrawPixelInfo(DrawPixelInfo *n, int left, int top, int width, int height)
Set up a clipping area for only drawing into a certain area.
StringID GetCargoSubtypeText(const Vehicle *v)
Get the cargo subtype text from NewGRF for the vehicle details window.
void DrawRoadVehDetails(const Vehicle *v, const Rect &r)
Draw the details for the given vehicle at the given position.
uint32 StringID
Numeric value that represents a string, independent of the selected language.
static const PaletteID PALETTE_CRASH
Recolour sprite greying of crashed vehicles.
uint16 cargo_cap
total capacity
int GetDisplayImageWidth(Point *offset=nullptr) const
Get the width of a road vehicle image in the GUI.
static RoadVehicle * From(Vehicle *v)
Converts a Vehicle to SpecializedVehicle with type checking.
PaletteID GetVehiclePalette(const Vehicle *v)
Get the colour map for a vehicle.
#define FONT_HEIGHT_NORMAL
Height of characters in the normal (FS_NORMAL) font.
uint32 PaletteID
The number of the palette.
@ NUM_CARGO
Maximal number of cargo types in a game.
bool HasArticulatedPart() const
Check if an engine has an articulated part.
Year build_year
Year the vehicle has been built.
StationID Source() const
Returns source of the first cargo packet in this list.
uint32 VehicleID
The type all our vehicle IDs have.
static int CenterBounds(int min, int max, int size)
Determine where to draw a centred object inside a widget.
byte CargoID
Cargo slots to indicate a cargo type within a game.
CargoID cargo_type
type of cargo this vehicle is carrying
int Width() const
Get width of Rect.
char * strecat(char *dst, const char *src, const char *last)
Appends characters from one string to another.
Specification of a rectangle with absolute coordinates of all edges.
Money FeederShare() const
Returns total sum of the feeder share for all packets.
#define lastof(x)
Get the last element of an fixed size array.
@ TD_RTL
Text is written right-to-left by default.
TextDirection _current_text_dir
Text direction of the currently selected language.
@ FR_BORDERONLY
Draw border only, no background.
Data about how and where to blit pixels.