31#include "table/strings.h"
44 default: NOT_REACHED();
48 case VEH_SHIP:
return STR_ENGINE_PREVIEW_SHIP;
54static constexpr NWidgetPart _nested_engine_preview_widgets[] = {
93 default: NOT_REACHED();
101 size.width = std::max(size.width, x + std::abs(x_offs));
122 y += this->vehicle_space;
151 _nested_engine_preview_widgets
155void ShowEnginePreviewWindow(
EngineID engine)
157 AllocateWindowDescFront<EnginePreviewWindow>(_engine_preview_desc, engine);
168 return cap.
GetSum<uint>();
173 SetDParam(0, STR_ENGINE_PREVIEW_COST_WEIGHT);
185 SetDParam(9, STR_ENGINE_PREVIEW_CAPACITY);
190 return STR_ENGINE_PREVIEW_TEXT4;
196 uint16_t mail_capacity;
200 SetDParam(0, STR_ENGINE_PREVIEW_COST_MAX_SPEED);
204 SetDParam(3, range > 0 ? STR_ENGINE_PREVIEW_TYPE_RANGE : STR_ENGINE_PREVIEW_TYPE);
211 SetDParam(9, mail_capacity > 0 ? STR_ENGINE_PREVIEW_CAPACITY_2 : STR_ENGINE_PREVIEW_CAPACITY);
214 SetDParam(12, GetCargoIDByLabel(CT_MAIL));
217 return STR_ENGINE_PREVIEW_TEXT4;
225 SetDParam(9, STR_ENGINE_PREVIEW_CAPACITY);
231 SetDParam(0, STR_ENGINE_PREVIEW_COST_MAX_SPEED);
235 return STR_ENGINE_PREVIEW_TEXT3;
237 SetDParam(0, STR_ENGINE_PREVIEW_COST_WEIGHT);
241 SetDParam(3, STR_ENGINE_PREVIEW_SPEED_POWER_MAX_TE);
246 return STR_ENGINE_PREVIEW_TEXT4;
252 SetDParam(0, STR_ENGINE_PREVIEW_COST_MAX_SPEED);
259 SetDParam(9, STR_ENGINE_PREVIEW_CAPACITY);
263 return STR_ENGINE_PREVIEW_TEXT3;
279 return GetTrainEngineInfoString(e);
282 return GetRoadVehEngineInfoString(e);
285 return GetShipEngineInfoString(e);
288 return GetAircraftEngineInfoString(e);
290 default: NOT_REACHED();
309 DrawTrainEngine(left, right, preferred_x, y, engine, pal, image_type);
317 DrawShipEngine(left, right, preferred_x, y, engine, pal, image_type);
321 DrawAircraftEngine(left, right, preferred_x, y, engine, pal, image_type);
324 default: NOT_REACHED();
335 if (el.size() < 2)
return;
336 std::sort(el.begin(), el.end(), compare);
348 if (num_items < 2)
return;
349 assert(begin < el.size());
350 assert(begin + num_items <= el.size());
351 std::sort(el.begin() + begin, el.begin() + begin + num_items, compare);
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).
CargoArray GetCapacityOfArticulatedParts(EngineID engine)
Get the capacity of the parts of a given engine.
Functions related to articulated vehicles.
uint8_t CargoID
Cargo slots to indicate a cargo type within a game.
struct RailTypeInfo::@26 strings
Strings associated with the rail type.
StringID new_loco
Name of an engine for this type of rail in the engine preview GUI.
uint8_t acceleration_type
Acceleration type of this rail type.
struct RoadTypeInfo::@29 strings
Strings associated with the rail type.
StringID new_engine
Name of an engine for this type of road in the engine preview GUI.
static bool UsingWallclockUnits(bool newgame=false)
Check if we are using wallclock units.
Functions related to commands.
CompanyID _local_company
Company controlled by the human player at this client. Can also be COMPANY_SPECTATOR.
Functions related to companies.
Command definitions related to engines.
void EngList_Sort(GUIEngineList &el, EngList_SortTypeFunction compare)
Sort all items using quick sort and given 'CompareItems' function.
uint GetTotalCapacityOfArticulatedParts(EngineID engine)
Get the capacity of an engine with articulated parts.
StringID GetEngineCategoryName(EngineID engine)
Return the category of an engine.
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>)
StringID GetEngineInfoString(EngineID engine)
Get a multi-line string with some technical data, describing the engine.
void DrawVehicleEngine(int left, int right, int preferred_x, int y, EngineID engine, PaletteID pal, EngineImageType image_type)
Draw an engine.
Engine GUI functions, used by build_vehicle_gui and autoreplace_gui
bool EngList_SortTypeFunction(const GUIEngineListItem &, const GUIEngineListItem &)
argument type for EngList_Sort.
void DrawRoadVehEngine(int left, int right, int preferred_x, int y, EngineID engine, PaletteID pal, EngineImageType image_type)
Draw a road vehicle engine.
uint16_t EngineID
Unique identification number of an engine.
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.
@ PreviewNews
Name is shown in exclusive preview or newspaper.
int GetCharacterHeight(FontSize size)
Get height of a character for a given font size.
int GetStringHeight(std::string_view str, int maxw, FontSize fontsize)
Calculates height of string (in pixels).
bool _shift_pressed
Is Shift pressed?
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.
int DrawStringMultiLine(int left, int right, int top, int bottom, std::string_view str, TextColour colour, StringAlignment align, bool underline, FontSize fontsize)
Draw string, possibly over multiple lines.
@ SA_TOP
Top align the text.
@ SA_HOR_CENTER
Horizontally center the text.
@ SA_CENTER
Center both horizontally and vertically.
@ FS_NORMAL
Index of the normal font in the font tables.
uint32_t PaletteID
The number of the palette.
const RailTypeInfo * GetRailTypeInfo(RailType railtype)
Returns a pointer to the Railtype information for a given railtype.
const RoadTypeInfo * GetRoadTypeInfo(RoadType roadtype)
Returns a pointer to the Roadtype information for a given roadtype.
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).
A number of safeguards to prevent using unsafe methods.
GameSettings _settings_game
Game settings of a running game or the scenario editor.
Types related to global configuration settings.
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).
Definition of base types and functions in a cross-platform compatible way.
void SetDParam(size_t n, uint64_t v)
Set a string parameter v at index n in the global string parameter array.
Functions related to OTTD's strings.
int64_t PackVelocity(uint speed, VehicleType type)
Pack velocity and vehicle type for use with SCC_VELOCITY string parameter.
uint32_t StringID
Numeric value that represents a string, independent of the selected language.
Class for storing amounts of cargo.
const T GetSum() const
Get the sum of all cargo amounts.
Dimensions (a width and height) of a rectangle in 2D.
void OnInvalidateData(int data=0, bool gui_scope=true) override
Some data on this window has become invalid.
void DrawWidget(const Rect &r, WidgetID widget) const override
Draw the contents of a nested widget.
void UpdateWidgetSize(WidgetID widget, Dimension &size, const Dimension &padding, Dimension &fill, Dimension &resize) override
Update size and resize step of a widget in the window.
void OnClick(Point pt, WidgetID widget, int click_count) override
A click with the left mouse button has been made on the window.
StringID GetAircraftTypeText() const
Get the name of the aircraft type for display purposes.
uint GetPower() const
Returns the power of the engine for display and sorting purposes.
CargoID GetDefaultCargoType() const
Determines the default cargo type of an engine.
uint16_t GetRange() const
Get the range of an aircraft type.
Money GetCost() const
Return how much a new engine costs.
uint GetDisplayMaxSpeed() const
Returns max speed of the engine for display purposes.
uint GetDisplayWeight() const
Returns the weight of the engine for display purposes.
VehicleType type
Vehicle type, ie VEH_ROAD, VEH_TRAIN, etc.
uint GetDisplayDefaultCapacity(uint16_t *mail_capacity=nullptr) const
Determines the default cargo capacity of an engine for display purposes.
Money GetRunningCost() const
Return how much the running costs of this engine are.
uint GetDisplayMaxTractiveEffort() const
Returns the tractive effort of the engine for display purposes.
VehicleSettings vehicle
options for vehicles
Coordinates of a point in 2D.
Tindex index
Index of this pool item.
static Titem * Get(size_t index)
Returns Titem with given index.
RailType railtype
Railtype, mangled if elrail is disabled.
Specification of a rectangle with absolute coordinates of all edges.
RoadType roadtype
Road type.
uint8_t roadveh_acceleration_model
realistic acceleration for road vehicles
uint8_t train_acceleration_model
realistic acceleration for trains
High level window description.
Data structure for an opened window.
virtual void Close(int data=0)
Hide the window and all its child windows, and mark them for a later deletion.
ResizeInfo resize
Resize information.
const NWID * GetWidget(WidgetID widnum) const
Get the nested widget with number widnum from the nested widget tree.
void InitNested(WindowNumber number=0)
Perform complete initialization of the Window with nested widgets, to allow use.
WindowFlags flags
Window flags.
WindowNumber window_number
Window number within the window class.
Base for the train class.
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).
PaletteID GetEnginePalette(EngineID engine_type, CompanyID company)
Get the colour map for an engine.
Functions related to vehicles.
EngineImageType
Visualisation contexts of vehicles and engines.
@ EIT_PURCHASE
Vehicle drawn in purchase list, autoreplace gui, ...
@ EIT_PREVIEW
Vehicle drawn in preview window, news, ...
@ VEH_ROAD
Road vehicle type.
@ VEH_AIRCRAFT
Aircraft vehicle type.
@ VEH_SHIP
Ship vehicle type.
@ VEH_TRAIN
Train vehicle type.
Functions, definitions and such used only by the GUI.
@ WF_STICKY
Window is made sticky by user.
@ WDF_CONSTRUCTION
This window is used for construction; close it whenever changing company.
@ WDP_CENTER
Center the window.
int32_t WindowNumber
Number to differentiate different windows of the same class.
@ WC_NONE
No window, redirects to WC_MAIN_WINDOW.
@ WC_ENGINE_PREVIEW
Engine preview window; Window numbers:
Functions related to zooming.
int ScaleSpriteTrad(int value)
Scale traditional pixel dimensions to GUI zoom level, for drawing sprites.