Go to the documentation of this file.
31 #include "table/strings.h"
44 default: NOT_REACHED();
48 case VEH_SHIP:
return STR_ENGINE_PREVIEW_SHIP;
54 static const NWidgetPart _nested_engine_preview_widgets[] = {
60 NWidget(
WWT_EMPTY, INVALID_COLOUR,
WID_EP_QUESTION),
SetMinimalSize(300, 0),
SetPadding(8, 8, 8, 8),
SetFill(1, 0),
92 default: NOT_REACHED();
100 size->width = std::max(size->width, x - x_offs);
121 y += this->vehicle_space;
139 if (!gui_scope)
return;
150 _nested_engine_preview_widgets,
lengthof(_nested_engine_preview_widgets)
154 void ShowEnginePreviewWindow(
EngineID engine)
156 AllocateWindowDescFront<EnginePreviewWindow>(&_engine_preview_desc, engine);
167 return cap.
GetSum<uint>();
193 uint16 mail_capacity;
205 if (mail_capacity > 0) {
209 return range > 0 ? STR_ENGINE_PREVIEW_COST_MAX_SPEED_TYPE_RANGE_CAP_CAP_RUNCOST : STR_ENGINE_PREVIEW_COST_MAX_SPEED_TYPE_CAP_CAP_RUNCOST;
212 return range > 0 ? STR_ENGINE_PREVIEW_COST_MAX_SPEED_TYPE_RANGE_CAP_RUNCOST : STR_ENGINE_PREVIEW_COST_MAX_SPEED_TYPE_CAP_RUNCOST;
229 return STR_ENGINE_PREVIEW_COST_MAX_SPEED_CAP_RUNCOST;
246 return STR_ENGINE_PREVIEW_COST_WEIGHT_SPEED_POWER_MAX_TE;
257 return STR_ENGINE_PREVIEW_COST_MAX_SPEED_CAP_RUNCOST;
273 return GetTrainEngineInfoString(e);
276 return GetRoadVehEngineInfoString(e);
279 return GetShipEngineInfoString(e);
282 return GetAircraftEngineInfoString(e);
284 default: NOT_REACHED();
303 DrawTrainEngine(left, right, preferred_x, y, engine, pal, image_type);
311 DrawShipEngine(left, right, preferred_x, y, engine, pal, image_type);
315 DrawAircraftEngine(left, right, preferred_x, y, engine, pal, image_type);
318 default: NOT_REACHED();
329 if (el->size() < 2)
return;
330 std::sort(el->begin(), el->end(), compare);
342 if (num_items < 2)
return;
343 assert(begin < el->size());
344 assert(begin + num_items <= el->size());
345 std::sort(el->begin() + begin, el->begin() + begin + num_items, compare);
@ VEH_AIRCRAFT
Aircraft vehicle type.
StringID GetEngineInfoString(EngineID engine)
Get a multi-line string with some technical data, describing the engine.
StringID new_engine
Name of an engine for this type of road in the engine preview GUI.
uint GetDisplayDefaultCapacity(uint16 *mail_capacity=nullptr) const
Determines the default cargo capacity of an engine for display purposes.
void OnInvalidateData(int data=0, bool gui_scope=true) override
Some data on this window has become invalid.
const T GetSum() const
Get the sum of all cargo amounts.
@ EIT_PREVIEW
Vehicle drawn in preview window, news, ...
static Titem * Get(size_t index)
Returns Titem with given index.
uint8 train_acceleration_model
realistic acceleration for trains
Dimensions (a width and height) of a rectangle in 2D.
uint64 PackEngineNameDParam(EngineID engine_id, EngineNameContext context, uint32 extra_data=0)
Combine an engine ID and a name context to an engine name dparam.
@ WDF_CONSTRUCTION
This window is used for construction; close it whenever changing company.
bool EngList_SortTypeFunction(const GUIEngineListItem &, const GUIEngineListItem &)
argument type for EngList_Sort.
void DrawWidget(const Rect &r, int widget) const override
Draw the contents of a nested widget.
@ WC_ENGINE_PREVIEW
Engine preview window; Window numbers:
CargoArray GetCapacityOfArticulatedParts(EngineID engine)
Get the capacity of the parts of a given engine.
uint GetDisplayMaxTractiveEffort() const
Returns the tractive effort of the engine for display purposes.
Tindex index
Index of this pool item.
@ EIT_PURCHASE
Vehicle drawn in purchase list, autoreplace gui, ...
Class for storing amounts of cargo.
@ WF_STICKY
Window is made sticky by user.
void OnClick(Point pt, int widget, int click_count) override
A click with the left mouse button has been made on the window.
Money GetRunningCost() const
Return how much the running costs of this engine are.
StringID GetEngineCategoryName(EngineID engine)
Return the category of an engine.
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.
int32 WindowNumber
Number to differentiate different windows of the same class.
EngineImageType
Visualisation contexts of vehicles and engines.
@ VEH_ROAD
Road vehicle type.
CargoID GetDefaultCargoType() const
Determines the default cargo type of an engine.
RoadType roadtype
Road type.
PaletteID GetEnginePalette(EngineID engine_type, CompanyID company)
Get the colour map for an engine.
void GetShipSpriteSize(EngineID engine, uint &width, uint &height, int &xoffs, int &yoffs, EngineImageType image_type)
Get the size of the sprite of a ship sprite heading west (used for lists).
Window(WindowDesc *desc)
Empty constructor, initialization has been moved to InitNested() called from the constructor of the d...
static void SetDParam(uint n, uint64 v)
Set a string parameter v at index n in the global string parameter array.
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.
High level window description.
static const RailtypeInfo * GetRailTypeInfo(RailType railtype)
Returns a pointer to the Railtype information for a given railtype.
uint GetDisplayMaxSpeed() const
Returns max speed of the engine for display purposes.
uint16 EngineID
Unique identification number of an engine.
void DrawRoadVehEngine(int left, int right, int preferred_x, int y, EngineID engine, PaletteID pal, EngineImageType image_type)
Draw a road vehicle engine.
ResizeInfo resize
Resize information.
@ SA_TOP
Top align the text.
void InitNested(WindowNumber number=0)
Perform complete initialization of the Window with nested widgets, to allow use.
static int ScaleSpriteTrad(int value)
Scale traditional pixel dimensions to GUI zoom level, for drawing sprites.
GameSettings _settings_game
Game settings of a running game or the scenario editor.
uint GetDisplayWeight() const
Returns the weight of the engine for display purposes.
CompanyID _local_company
Company controlled by the human player at this client. Can also be COMPANY_SPECTATOR.
WindowFlags flags
Window flags.
bool _shift_pressed
Is Shift pressed?
Coordinates of a point in 2D.
Money GetCost() const
Return how much a new engine costs.
WindowNumber window_number
Window number within the window class.
@ WC_NONE
No window, redirects to WC_MAIN_WINDOW.
@ SA_HOR_CENTER
Horizontally center the text.
int GetStringHeight(const char *str, int maxw, FontSize fontsize)
Calculates height of string (in pixels).
uint8 acceleration_type
Acceleration type of this rail type.
uint32 StringID
Numeric value that represents a string, independent of the selected language.
void GetAircraftSpriteSize(EngineID engine, uint &width, uint &height, int &xoffs, int &yoffs, EngineImageType image_type)
Get the size of the sprite of an aircraft sprite heading west (used for lists).
uint8 roadveh_acceleration_model
realistic acceleration for road vehicles
uint GetPower() const
Returns the power of the engine for display and sorting purposes.
#define FONT_HEIGHT_NORMAL
Height of characters in the normal (FS_NORMAL) font.
void GetTrainSpriteSize(EngineID engine, uint &width, uint &height, int &xoffs, int &yoffs, EngineImageType image_type)
Get the size of the sprite of a train sprite heading west, or both heads (used for lists).
uint GetTotalCapacityOfArticulatedParts(EngineID engine)
Get the capacity of an engine with articulated parts.
uint32 PaletteID
The number of the palette.
void GetRoadVehSpriteSize(EngineID engine, uint &width, uint &height, int &xoffs, int &yoffs, EngineImageType image_type)
Get the size of the sprite of a road vehicle sprite heading west (used for lists).
void EngList_Sort(GUIEngineList *el, EngList_SortTypeFunction compare)
Sort all items using quick sort and given 'CompareItems' function.
static const RoadTypeInfo * GetRoadTypeInfo(RoadType roadtype)
Returns a pointer to the Roadtype information for a given roadtype.
RailType railtype
Railtype, mangled if elrail is disabled.
@ SA_CENTER
Center both horizontally and vertically.
#define lengthof(x)
Return the length of an fixed size array.
StringID new_loco
Name of an engine for this type of rail in the engine preview GUI.
void EngList_SortPartial(GUIEngineList *el, EngList_SortTypeFunction compare, size_t begin, size_t num_items)
Sort selected range of items (on indices @ <begin, begin+num_items-1>)
byte CargoID
Cargo slots to indicate a cargo type within a game.
VehicleSettings vehicle
options for vehicles
Data structure for an opened window.
@ VEH_TRAIN
Train vehicle type.
struct RailtypeInfo::@39 strings
Strings associated with the rail type.
uint16 GetRange() const
Get the range of an aircraft type.
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.
@ CT_INVALID
Invalid cargo type.
@ VEH_SHIP
Ship vehicle type.
Specification of a rectangle with absolute coordinates of all edges.
@ WDP_CENTER
Center the window.
StringID GetAircraftTypeText() const
Get the name of the aircraft type for display purposes.
void DrawVehicleEngine(int left, int right, int preferred_x, int y, EngineID engine, PaletteID pal, EngineImageType image_type)
Draw an engine.
@ PreviewNews
Name is shown in exclusive preview or newspaper.
VehicleType type
Vehicle type, ie VEH_ROAD, VEH_TRAIN, etc.
struct RoadTypeInfo::@42 strings
Strings associated with the rail type.
virtual void Close()
Hide the window and all its child windows, and mark them for a later deletion.