OpenTTD Source 20241224-master-gee860a5c8e
|
GUI for trains. More...
#include "stdafx.h"
#include "window_gui.h"
#include "command_func.h"
#include "train.h"
#include "strings_func.h"
#include "vehicle_func.h"
#include "zoom_func.h"
#include "train_cmd.h"
#include "table/strings.h"
#include "safeguards.h"
Go to the source code of this file.
Data Structures | |
struct | CargoSummaryItem |
Helper struct for the cargo details information. More... | |
Typedefs | |
typedef std::vector< CargoSummaryItem > | CargoSummary |
Container for the cargo summary information. | |
Functions | |
void | CcBuildWagon (Commands, const CommandCost &result, VehicleID new_veh_id, uint, uint16_t, CargoArray, TileIndex tile, EngineID, bool, CargoID, ClientID) |
Callback for building wagons. | |
static int | HighlightDragPosition (int px, int max_width, int y, VehicleID selection, bool chain) |
Highlight the position where a rail vehicle is dragged over by drawing a light gray background. | |
void | DrawTrainImage (const Train *v, const Rect &r, VehicleID selection, EngineImageType image_type, int skip, VehicleID drag_dest) |
Draws an image of a whole train. | |
static void | TrainDetailsCargoTab (const CargoSummaryItem *item, int left, int right, int y) |
Draw the details cargo tab for the given vehicle at the given position. | |
static void | TrainDetailsInfoTab (const Vehicle *v, int left, int right, int y) |
Draw the details info tab for the given vehicle at the given position. | |
static void | TrainDetailsCapacityTab (const CargoSummaryItem *item, int left, int right, int y) |
Draw the details capacity tab for the given vehicle at the given position. | |
static void | GetCargoSummaryOfArticulatedVehicle (const Train *v, CargoSummary &summary) |
Collects the cargo transported. | |
static uint | GetLengthOfArticulatedVehicle (const Train *v) |
Get the length of an articulated vehicle. | |
int | GetTrainDetailsWndVScroll (VehicleID veh_id, TrainDetailsWindowTabs det_tab) |
Determines the number of lines in the train details window. | |
void | DrawTrainDetails (const Train *v, const Rect &r, int vscroll_pos, uint16_t vscroll_cap, TrainDetailsWindowTabs det_tab) |
Draw the details for the given vehicle at the given position. | |
Variables | |
static const uint | TRAIN_DETAILS_MIN_INDENT = 32 |
Minimum indent level in the train details window. | |
static const uint | TRAIN_DETAILS_MAX_INDENT = 72 |
Maximum indent level in the train details window; wider than this and we start on a new line. | |
static CargoSummary | _cargo_summary |
Reused container of cargo details. | |
GUI for trains.
Definition in file train_gui.cpp.
typedef std::vector<CargoSummaryItem> CargoSummary |
Container for the cargo summary information.
Definition at line 199 of file train_gui.cpp.
void CcBuildWagon | ( | Commands | cmd, |
const CommandCost & | result, | ||
VehicleID | new_veh_id, | ||
uint | , | ||
uint16_t | , | ||
CargoArray | , | ||
TileIndex | tile, | ||
EngineID | , | ||
bool | , | ||
CargoID | , | ||
ClientID | |||
) |
Callback for building wagons.
result | The result of the command. |
new_veh_id | ID of the ne vehicle. |
tile | The tile the command was executed on. |
Definition at line 29 of file train_gui.cpp.
References CommandCost::Failed(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem< Tpool >::index, InvalidateWindowClassesData(), SpecializedVehicle< T, Type >::Iterate(), Vehicle::Last(), Vehicle::tile, and WC_TRAINS_LIST.
void DrawTrainDetails | ( | const Train * | v, |
const Rect & | r, | ||
int | vscroll_pos, | ||
uint16_t | vscroll_cap, | ||
TrainDetailsWindowTabs | det_tab | ||
) |
Draw the details for the given vehicle at the given position.
v | current vehicle |
r | the Rect to draw within |
vscroll_pos | Position of scrollbar |
vscroll_cap | Number of lines currently displayed |
det_tab | Selected details tab |
Definition at line 362 of file train_gui.cpp.
References _cargo_summary, _current_text_dir, _settings_game, _sorted_cargo_specs, DIR_E, DIR_W, VehicleSpriteSeq::Draw(), DrawString(), EIT_IN_DETAILS, Vehicle::engine_type, VehicleSettings::freight_trains, FreightWagonMult(), FS_NORMAL, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_engine_pool >::Get(), GetCargoSummaryOfArticulatedVehicle(), GetCharacterHeight(), GetColourGradient(), Train::GetDisplayImageWidth(), Engine::GetGRF(), Train::GetImage(), SpecializedVehicle< T, Type >::GetNextVehicle(), GetVehiclePalette(), GfxFillRect(), Rect::Height(), WidgetDimensions::hsep_normal, Rect::Indent(), Vehicle::IsArticulatedPart(), WidgetDimensions::matrix, SpecializedVehicle< T, Type >::Next(), PALETTE_CRASH, WidgetDimensions::scaled, ScaleSpriteTrad(), SetDParam(), TD_RTL, TDW_TAB_CAPACITY, TDW_TAB_CARGO, TDW_TAB_INFO, TDW_TAB_TOTALS, TRAIN_DETAILS_MAX_INDENT, TRAIN_DETAILS_MIN_INDENT, TrainDetailsCapacityTab(), TrainDetailsCargoTab(), TrainDetailsInfoTab(), GRFFile::traininfo_vehicle_pitch, GameSettings::vehicle, Vehicle::vehstatus, and VS_CRASHED.
Referenced by VehicleDetailsWindow::DrawVehicleDetails().
void DrawTrainImage | ( | const Train * | v, |
const Rect & | r, | ||
VehicleID | selection, | ||
EngineImageType | image_type, | ||
int | skip, | ||
VehicleID | drag_dest | ||
) |
Draws an image of a whole train.
v | Front vehicle |
r | Rect to draw at |
selection | Selected vehicle to draw a frame around |
skip | Number of pixels to skip at the front (for scrolling) |
drag_dest | The vehicle another one is dragged over, INVALID_VEHICLE if none. |
Definition at line 93 of file train_gui.cpp.
References _current_text_dir, AddCargoIconOverlay(), WidgetDimensions::bevel, CenterBounds(), DIR_E, DIR_W, VehicleSpriteSeq::Draw(), DrawCargoIconOverlays(), DrawFrameRect(), Rect::Expand(), FillDrawPixelInfo(), FR_BORDERONLY, SpecializedVehicle< T, Type >::From(), Train::GetImage(), GetVehiclePalette(), Rect::Height(), HighlightDragPosition(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem< Tpool >::index, INVALID_VEHICLE, Vehicle::IsArticulatedPart(), SpecializedVehicle< T, Type >::Next(), PALETTE_CRASH, WidgetDimensions::scaled, ScaleSpriteTrad(), ShowCargoIconOverlay(), TD_RTL, Rect::Translate(), CursorVars::vehchain, Vehicle::vehstatus, VS_CRASHED, and Rect::Width().
Referenced by DrawVehicleImage(), and DepotWindow::DrawVehicleInDepot().
|
static |
Collects the cargo transported.
v | Vehicle to process |
summary | Space for the result |
Definition at line 279 of file train_gui.cpp.
References Engine::CanCarryCargo(), CargoSummaryItem::cargo, Vehicle::cargo, Vehicle::cargo_cap, Vehicle::cargo_type, GetCargoSubtypeText(), Vehicle::GetEngine(), VehicleCargoList::GetFirstStation(), Vehicle::IsArticulatedPart(), IsValidCargoID(), SpecializedVehicle< T, Type >::Next(), VehicleCargoList::StoredCount(), and CargoSummaryItem::subtype.
Referenced by DrawTrainDetails(), and GetTrainDetailsWndVScroll().
|
static |
Get the length of an articulated vehicle.
v | the vehicle to get the length of. |
Definition at line 311 of file train_gui.cpp.
References Train::GetDisplayImageWidth(), Vehicle::IsArticulatedPart(), and SpecializedVehicle< T, Type >::Next().
Referenced by GetTrainDetailsWndVScroll().
int GetTrainDetailsWndVScroll | ( | VehicleID | veh_id, |
TrainDetailsWindowTabs | det_tab | ||
) |
Determines the number of lines in the train details window.
veh_id | Train |
det_tab | Selected details tab |
Definition at line 328 of file train_gui.cpp.
References _cargo_summary, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_vehicle_pool >::Get(), SpecializedVehicle< T, Type >::Get(), GetCargoSummaryOfArticulatedVehicle(), CargoArray::GetCount(), GetLengthOfArticulatedVehicle(), SpecializedVehicle< T, Type >::GetNextVehicle(), Vehicle::Next(), ScaleSpriteTrad(), TDW_TAB_TOTALS, and TRAIN_DETAILS_MAX_INDENT.
Referenced by VehicleDetailsWindow::OnPaint().
|
static |
Highlight the position where a rail vehicle is dragged over by drawing a light gray background.
px | The current x position to draw from. |
max_width | The maximum space available to draw. |
y | The vertical centre position to draw from. |
selection | Selected vehicle that is dragged. |
chain | Whether a whole chain is dragged. |
Definition at line 60 of file train_gui.cpp.
References _current_text_dir, SpecializedVehicle< T, Type >::Get(), GetColourGradient(), GfxFillRect(), INVALID_VEHICLE, SpecializedVehicle< T, Type >::Next(), ScaleSpriteTrad(), Rect::Shrink(), and TD_RTL.
Referenced by DrawTrainImage().
|
static |
Draw the details capacity tab for the given vehicle at the given position.
item | Data to draw |
left | The left most coordinate to draw |
right | The right most coordinate to draw |
y | The y coordinate |
Definition at line 257 of file train_gui.cpp.
References _settings_game, CargoSummaryItem::capacity, CargoSummaryItem::cargo, DrawString(), VehicleSettings::freight_trains, FreightWagonMult(), IsValidCargoID(), SetDParam(), CargoSummaryItem::subtype, and GameSettings::vehicle.
Referenced by DrawTrainDetails().
|
static |
Draw the details cargo tab for the given vehicle at the given position.
item | Data to draw |
left | The left most coordinate to draw |
right | The right most coordinate to draw |
y | The y coordinate |
Definition at line 211 of file train_gui.cpp.
References _settings_game, CargoSummaryItem::amount, CargoSummaryItem::cargo, DrawString(), VehicleSettings::freight_trains, FreightWagonMult(), IsValidCargoID(), SetDParam(), CargoSummaryItem::source, and GameSettings::vehicle.
Referenced by DrawTrainDetails().
|
static |
Draw the details info tab for the given vehicle at the given position.
v | current vehicle |
left | The left most coordinate to draw |
right | The right most coordinate to draw |
y | The y coordinate |
Definition at line 235 of file train_gui.cpp.
References Vehicle::build_year, DrawString(), Vehicle::engine_type, PackEngineNameDParam(), RAILVEH_WAGON, SetDParam(), Vehicle::value, and VehicleDetails.
Referenced by DrawTrainDetails().
|
static |
Reused container of cargo details.
Definition at line 201 of file train_gui.cpp.
Referenced by DrawTrainDetails(), and GetTrainDetailsWndVScroll().
|
static |
Maximum indent level in the train details window; wider than this and we start on a new line.
Definition at line 196 of file train_gui.cpp.
Referenced by DrawTrainDetails(), and GetTrainDetailsWndVScroll().
|
static |
Minimum indent level in the train details window.
Definition at line 195 of file train_gui.cpp.
Referenced by DrawTrainDetails().