GUI for trains. More...
#include "stdafx.h"
#include "window_gui.h"
#include "gfx_func.h"
#include "command_func.h"
#include "vehicle_gui.h"
#include "train.h"
#include "strings_func.h"
#include "vehicle_func.h"
#include "window_func.h"
#include "table/sprites.h"
#include "table/strings.h"
Go to the source code of this file.
Data Structures | |
struct | CargoSummaryItem |
Helper struct for the cargo details information. More... | |
Typedefs | |
typedef SmallVector < CargoSummaryItem, 2 > | CargoSummary |
Container for the cargo summary information. | |
Functions | |
void | CcBuildWagon (const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2) |
Callback for building wagons. | |
static int | HighlightDragPosition (int px, int max_width, VehicleID selection) |
Highlight the position where a rail vehicle is dragged over by drawing a light gray background. | |
void | DrawTrainImage (const Train *v, int left, int right, int y, VehicleID selection, 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 Train *v, int left, int right, int y, byte line_number) |
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 transportet. | |
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, int left, int right, int y, int vscroll_pos, uint16 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 SmallVector<CargoSummaryItem, 2> CargoSummary |
Container for the cargo summary information.
Definition at line 179 of file train_gui.cpp.
void CcBuildWagon | ( | const CommandCost & | result, | |
TileIndex | tile, | |||
uint32 | p1, | |||
uint32 | p2 | |||
) |
Callback for building wagons.
result | The result of the command. | |
tile | The tile the command was executed on. | |
p1 | Additional data for the command (for the CommandProc) | |
p2 | Additional data for the command (for the CommandProc) |
Definition at line 32 of file train_gui.cpp.
References CMD_MOVE_RAIL_VEHICLE, DoCommandP(), CommandCost::Failed(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem< Tpool >::index, InvalidateWindowClassesData(), Vehicle::IsFrontEngine(), Vehicle::Last(), and Vehicle::tile.
Referenced by BuildVehicleWindow::OnClick().
void DrawTrainDetails | ( | const Train * | v, | |
int | left, | |||
int | right, | |||
int | y, | |||
int | vscroll_pos, | |||
uint16 | vscroll_cap, | |||
TrainDetailsWindowTabs | det_tab | |||
) |
Draw the details 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 | |
vscroll_pos | Position of scrollbar | |
vscroll_cap | Number of lines currently displayed | |
det_tab | Selected details tab |
Definition at line 393 of file train_gui.cpp.
References _colour_gradient, _current_text_dir, _settings_game, DIR_E, DrawSprite(), DrawString(), FONT_HEIGHT_NORMAL, VehicleSettings::freight_trains, FreightWagonMult(), SpecializedVehicle< Train, Type >::From(), GetCargoSummaryOfArticulatedVehicle(), Train::GetDisplayImageWidth(), Train::GetImage(), SpecializedVehicle< T, Type >::GetNextVehicle(), GetVehiclePalette(), GfxFillRect(), Vehicle::IsArticulatedPart(), IsWagon(), SmallVector< T, S >::Length(), max(), SpecializedVehicle< T, Type >::Next(), PALETTE_CRASH, SetDParam(), TDW_TAB_CAPACITY, TDW_TAB_CARGO, TDW_TAB_INFO, TDW_TAB_TOTALS, TRAIN_DETAILS_MAX_INDENT, TRAIN_DETAILS_MIN_INDENT, TrainDetailsCapacityTab(), TrainDetailsCargoTab(), TrainDetailsInfoTab(), GameSettings::vehicle, Vehicle::vehstatus, and WD_MATRIX_TOP.
Referenced by VehicleDetailsWindow::DrawVehicleDetails().
void DrawTrainImage | ( | const Train * | v, | |
int | left, | |||
int | right, | |||
int | y, | |||
VehicleID | selection, | |||
int | skip, | |||
VehicleID | drag_dest | |||
) |
Draws an image of a whole train.
v | Front vehicle | |
left | The minimum horizontal position | |
right | The maximum horizontal position | |
y | Vertical position 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, DIR_E, DrawFrameRect(), DrawSprite(), FillDrawPixelInfo(), FR_BORDERONLY, SpecializedVehicle< Train, Type >::From(), Train::GetDisplayImageWidth(), GetVehiclePalette(), HighlightDragPosition(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem< Tpool >::index, INVALID_VEHICLE, SpecializedVehicle< T, Type >::Next(), PALETTE_CRASH, and CursorVars::vehchain.
Referenced by DrawVehicleImage(), and DepotWindow::DrawVehicleInDepot().
static void GetCargoSummaryOfArticulatedVehicle | ( | const Train * | v, | |
CargoSummary * | summary | |||
) | [static] |
Collects the cargo transportet.
v | Vehicle to process | |
summary | Space for the result |
Definition at line 301 of file train_gui.cpp.
References CargoSummaryItem::amount, SmallVector< T, S >::Append(), CargoSummaryItem::capacity, Vehicle::cargo, CargoSummaryItem::cargo, Vehicle::cargo_cap, Vehicle::cargo_type, SmallVector< T, S >::Clear(), CargoList< Tinst, Tcont >::Count(), SmallVector< T, S >::End(), SmallVector< T, S >::Find(), GetCargoSubtypeText(), Vehicle::IsArticulatedPart(), SpecializedVehicle< T, Type >::Next(), VehicleCargoList::Source(), CargoSummaryItem::source, and CargoSummaryItem::subtype.
Referenced by DrawTrainDetails(), and GetTrainDetailsWndVScroll().
static uint GetLengthOfArticulatedVehicle | ( | const Train * | v | ) | [static] |
Get the length of an articulated vehicle.
v | the vehicle to get the length of. |
Definition at line 332 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 349 of file train_gui.cpp.
References TrainCache::cached_num_engines, SpecializedVehicle< Train, Type >::Get(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_vehicle_pool >::Get(), GetCargoSummaryOfArticulatedVehicle(), GetLengthOfArticulatedVehicle(), SpecializedVehicle< T, Type >::GetNextVehicle(), SmallVector< T, S >::Length(), max(), TDW_TAB_TOTALS, and TRAIN_DETAILS_MAX_INDENT.
Referenced by VehicleDetailsWindow::OnPaint().
static int HighlightDragPosition | ( | int | px, | |
int | max_width, | |||
VehicleID | selection | |||
) | [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. | |
selection | Selected vehicle that is dragged. |
Definition at line 63 of file train_gui.cpp.
References _colour_gradient, _current_text_dir, SpecializedVehicle< Train, Type >::Get(), Train::GetDisplayImageWidth(), GfxFillRect(), INVALID_VEHICLE, max(), min(), WD_FRAMERECT_BOTTOM, WD_FRAMERECT_LEFT, and WD_FRAMERECT_TOP.
Referenced by DrawTrainImage().
static void TrainDetailsCapacityTab | ( | const CargoSummaryItem * | item, | |
int | left, | |||
int | right, | |||
int | y | |||
) | [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 287 of file train_gui.cpp.
References _settings_game, CargoSummaryItem::capacity, CargoSummaryItem::cargo, DrawString(), VehicleSettings::freight_trains, FreightWagonMult(), SetDParam(), CargoSummaryItem::subtype, and GameSettings::vehicle.
Referenced by DrawTrainDetails().
static void TrainDetailsCargoTab | ( | const CargoSummaryItem * | item, | |
int | left, | |||
int | right, | |||
int | y | |||
) | [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 191 of file train_gui.cpp.
References _settings_game, CargoSummaryItem::amount, CargoSummaryItem::cargo, DrawString(), VehicleSettings::freight_trains, FreightWagonMult(), SetDParam(), CargoSummaryItem::source, and GameSettings::vehicle.
Referenced by DrawTrainDetails().
static void TrainDetailsInfoTab | ( | const Train * | v, | |
int | left, | |||
int | right, | |||
int | y, | |||
byte | line_number | |||
) | [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 214 of file train_gui.cpp.
References _settings_game, Vehicle::breakdown_ctr, BREAKDOWN_LOW_POWER, BREAKDOWN_LOW_SPEED, Vehicle::breakdown_severity, Vehicle::breakdown_type, Vehicle::breakdowns_since_last_service, Vehicle::build_year, VehicleCache::cached_max_speed, DrawString(), Vehicle::engine_type, SpecializedVehicle< T, Type >::First(), Train::GetCurrentMaxSpeed(), HasBit(), VehicleSettings::improved_breakdowns, RailVehicleInfo::max_speed, min(), PROP_TRAIN_SPEED, RAILVEH_WAGON, Vehicle::reliability, SA_LEFT, SA_STRIP, SetDParam(), UsesWagonOverride(), Vehicle::value, Vehicle::vcache, GameSettings::vehicle, VRF_NEED_REPAIR, and VehicleSettings::wagon_speed_limits.
Referenced by DrawTrainDetails().