30 #include "table/strings.h" 43 default: NOT_REACHED();
44 case VEH_ROAD:
return STR_ENGINE_PREVIEW_ROAD_VEHICLE;
46 case VEH_SHIP:
return STR_ENGINE_PREVIEW_SHIP;
52 static const NWidgetPart _nested_engine_preview_widgets[] = {
58 NWidget(
WWT_EMPTY, INVALID_COLOUR,
WID_EP_QUESTION),
SetMinimalSize(300, 0),
SetPadding(8, 8, 8, 8),
SetFill(1, 0),
90 default: NOT_REACHED();
96 this->vehicle_space = max<int>(40, y - y_offs);
98 size->width =
max(size->width, x - x_offs);
111 int y = r.top +
GetStringHeight(STR_ENGINE_PREVIEW_MESSAGE, r.right - r.top + 1);
120 y += this->vehicle_space;
138 if (!gui_scope)
return;
149 _nested_engine_preview_widgets,
lengthof(_nested_engine_preview_widgets)
153 void ShowEnginePreviewWindow(
EngineID engine)
155 AllocateWindowDescFront<EnginePreviewWindow>(&_engine_preview_desc, engine);
166 return cap.
GetSum<uint>();
192 uint16 mail_capacity;
204 if (mail_capacity > 0) {
208 return range > 0 ? STR_ENGINE_PREVIEW_COST_MAX_SPEED_TYPE_RANGE_CAP_CAP_RUNCOST : STR_ENGINE_PREVIEW_COST_MAX_SPEED_TYPE_CAP_CAP_RUNCOST;
211 return range > 0 ? STR_ENGINE_PREVIEW_COST_MAX_SPEED_TYPE_RANGE_CAP_RUNCOST : STR_ENGINE_PREVIEW_COST_MAX_SPEED_TYPE_CAP_RUNCOST;
228 return STR_ENGINE_PREVIEW_COST_MAX_SPEED_CAP_RUNCOST;
245 return STR_ENGINE_PREVIEW_COST_WEIGHT_SPEED_POWER_MAX_TE;
256 return STR_ENGINE_PREVIEW_COST_MAX_SPEED_CAP_RUNCOST;
272 return GetTrainEngineInfoString(e);
275 return GetRoadVehEngineInfoString(e);
278 return GetShipEngineInfoString(e);
281 return GetAircraftEngineInfoString(e);
283 default: NOT_REACHED();
302 DrawTrainEngine(left, right, preferred_x, y, engine, pal, image_type);
310 DrawShipEngine(left, right, preferred_x, y, engine, pal, image_type);
314 DrawAircraftEngine(left, right, preferred_x, y, engine, pal, image_type);
317 default: NOT_REACHED();
331 if (size < 2)
return;
344 if (num_items < 2)
return;
345 assert(begin < el->Length());
346 assert(begin + num_items <= el->Length());
347 QSortT(el->
Get(begin), num_items, compare);
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.
VehicleSettings vehicle
options for vehicles
uint32 PaletteID
The number of the palette.
GameSettings _settings_game
Game settings of a running game or the scenario editor.
static const RailtypeInfo * GetRailTypeInfo(RailType railtype)
Returns a pointer to the Railtype information for a given railtype.
Horizontally center the text.
ResizeInfo resize
Resize information.
StringID GetEngineInfoString(EngineID engine)
Get a multi-line string with some technical data, describing the engine.
StringID GetEngineCategoryName(EngineID engine)
Return the category of an engine.
Window(WindowDesc *desc)
Empty constructor, initialization has been moved to InitNested() called from the constructor of the d...
uint GetDisplayDefaultCapacity(uint16 *mail_capacity=NULL) const
Determines the default cargo capacity of an engine for display purposes.
High level window description.
WindowFlags flags
Window flags.
int left
x position of left edge of the window
StringID GetAircraftTypeText() const
Get the name of the aircraft type for display purposes.
static Titem * Get(size_t index)
Returns Titem with given index.
Base for the train class.
uint16 GetRange() const
Get the range of an aircraft type.
CargoArray GetCapacityOfArticulatedParts(EngineID engine)
Get the capacity of the parts of a given engine.
virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize)
Update size and resize step of a widget in the window.
Functions related to vehicles.
const T * Begin() const
Get the pointer to the first item (const)
virtual void OnClick(Point pt, int widget, int click_count)
A click with the left mouse button has been made on the window.
Tindex index
Index of this pool item.
int GetStringHeight(const char *str, int maxw, FontSize fontsize)
Calculates height of string (in pixels).
virtual void OnInvalidateData(int data=0, bool gui_scope=true)
Some data on this window has become invalid.
Vehicle drawn in purchase list, autoreplace gui, ...
static T max(const T a, const T b)
Returns the maximum of two values.
EngineImageType
Visualisation contexts of vehicles and engines.
struct RailtypeInfo::@39 strings
Strings associated with the rail type.
Window is made sticky by user.
CargoID GetDefaultCargoType() const
Determines the default cargo type of an engine.
Large amount of vertical space between two paragraphs of text.
StringID new_loco
Name of an engine for this type of rail in the engine preview GUI.
Functions, definitions and such used only by the GUI.
CompanyByte _local_company
Company controlled by the human player at this client. Can also be COMPANY_SPECTATOR.
Data structure for an opened window.
void InitNested(WindowNumber number=0)
Perform complete initialization of the Window with nested widgets, to allow use.
Money GetCost() const
Return how much a new engine costs.
Engine preview window; Window numbers:
uint Length() const
Get the number of items in the list.
This window is used for construction; close it whenever changing company.
#define FONT_HEIGHT_NORMAL
Height of characters in the normal (FS_NORMAL) font.
Types related to global configuration settings.
Definition of base types and functions in a cross-platform compatible way.
Center both horizontally and vertically.
PaletteID GetEnginePalette(EngineID engine_type, CompanyID company)
Get the colour map for an engine.
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.
uint8 acceleration_type
Acceleration type of this rail type.
Vehicle drawn in preview window, news, ...
Engine GUI functions, used by build_vehicle_gui and autoreplace_gui
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).
VehicleType type
Vehicle type, ie VEH_ROAD, VEH_TRAIN, etc.
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.
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.
uint32 StringID
Numeric value that represents a string, independent of the selected language.
virtual void DrawWidget(const Rect &r, int widget) const
Draw the contents of a nested widget.
uint GetDisplayMaxSpeed() const
Returns max speed of the engine for display purposes.
bool _shift_pressed
Is Shift pressed?
No window, redirects to WC_MAIN_WINDOW.
confirm the preview of an engine
uint GetPower() const
Returns the power of the engine for display and sorting purposes.
Functions related to companies.
Functions related to articulated vehicles.
Class for storing amounts of cargo.
uint16 EngineID
Unique identification number of an engine.
uint GetTotalCapacityOfArticulatedParts(EngineID engine)
Get the capacity of an engine with articulated parts.
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.
Functions related to commands.
Coordinates of a point in 2D.
uint8 train_acceleration_model
realistic acceleration for trains
void DrawRoadVehEngine(int left, int right, int preferred_x, int y, EngineID engine, PaletteID pal, EngineImageType image_type)
Draw a road vehicle engine.
uint8 roadveh_acceleration_model
realistic acceleration for road vehicles
Offset at right to draw the frame rectangular area.
Money GetRunningCost() const
Return how much the running costs of this engine are.
const T * Get(uint index) const
Get the pointer to item "number" (const)
int32 WindowNumber
Number to differentiate different windows of the same class.
Specification of a rectangle with absolute coordinates of all edges.
int CDECL EngList_SortTypeFunction(const EngineID *, const EngineID *)
argument type for EngList_Sort.
byte CargoID
Cargo slots to indicate a cargo type within a game.
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).
WindowNumber window_number
Window number within the window class.
uint GetDisplayWeight() const
Returns the weight of the engine for display purposes.
static void QSortT(T *base, uint num, int(CDECL *comparator)(const T *, const T *), bool desc=false)
Type safe qsort()
uint GetDisplayMaxTractiveEffort() const
Returns the tractive effort of the engine for display purposes.
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)...
Dimensions (a width and height) of a rectangle in 2D.
Offset at left to draw the frame rectangular area.
const T GetSum() const
Get the sum of all cargo amounts.
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.
static void SetDParam(uint n, uint64 v)
Set a string parameter v at index n in the global string parameter array.