OpenTTD
Data Structures | Typedefs | Enumerations | Functions | Variables
vehicle_gui.cpp File Reference

The base GUI for all vehicles. More...

#include "stdafx.h"
#include "debug.h"
#include "company_func.h"
#include "gui.h"
#include "textbuf_gui.h"
#include "command_func.h"
#include "vehicle_gui_base.h"
#include "viewport_func.h"
#include "newgrf_text.h"
#include "newgrf_debug.h"
#include "roadveh.h"
#include "train.h"
#include "aircraft.h"
#include "depot_map.h"
#include "group_gui.h"
#include "strings_func.h"
#include "vehicle_func.h"
#include "autoreplace_gui.h"
#include "string_func.h"
#include "widgets/dropdown_func.h"
#include "timetable.h"
#include "articulated_vehicles.h"
#include "spritecache.h"
#include "core/geometry_func.hpp"
#include "company_base.h"
#include "engine_func.h"
#include "station_base.h"
#include "tilehighlight_func.h"
#include "zoom_func.h"
#include "safeguards.h"

Go to the source code of this file.

Data Structures

struct  RefitOption
 Option to refit a vehicle chain. More...
 
struct  RefitWindow
 Refit cargo window. More...
 
struct  VehicleListWindow
 Window for the (old) vehicle listing. More...
 
struct  VehicleDetailsWindow
 Class for managing the vehicle details window. More...
 
struct  VehicleViewWindow
 Window manager class for viewing a vehicle. More...
 

Typedefs

typedef SmallVector< RefitOption, 32 > SubtypeList
 List of refit subtypes associated to a cargo.
 

Enumerations

enum  VehicleCommandTranslation { VCT_CMD_START_STOP = 0, VCT_CMD_CLONE_VEH, VCT_CMD_TURN_AROUND }
 Command indices for the _vehicle_command_translation_table. More...
 

Functions

uint GetUnitNumberDigits (VehicleList &vehicles)
 Get the number of digits the biggest unit number of a set of vehicles has. More...
 
void DepotSortList (VehicleList *list)
 
static void DrawVehicleProfitButton (const Vehicle *v, int x, int y)
 draw the vehicle profit button in the vehicle list window. More...
 
byte GetBestFittingSubType (Vehicle *v_from, Vehicle *v_for, CargoID dest_cargo_type)
 Get the best fitting subtype when 'cloning'/'replacing' v_from with v_for. More...
 
static void DrawVehicleRefitWindow (const SubtypeList list[NUM_CARGO], const int sel[2], uint pos, uint rows, uint delta, const Rect &r)
 Draw the list of available refit options for a consist and highlight the selected refit option (if any). More...
 
void ShowVehicleRefitWindow (const Vehicle *v, VehicleOrderID order, Window *parent, bool auto_refit)
 Show the refit window for a vehicle. More...
 
uint ShowRefitOptionsList (int left, int right, int y, EngineID engine)
 Display list of cargo types of the engine, for the purchase information window.
 
StringID GetCargoSubtypeText (const Vehicle *v)
 Get the cargo subtype text from NewGRF for the vehicle details window. More...
 
static int CDECL VehicleNumberSorter (const Vehicle *const *a, const Vehicle *const *b)
 Sort vehicles by their number.
 
static int CDECL VehicleNameSorter (const Vehicle *const *a, const Vehicle *const *b)
 Sort vehicles by their name.
 
static int CDECL VehicleAgeSorter (const Vehicle *const *a, const Vehicle *const *b)
 Sort vehicles by their age.
 
static int CDECL VehicleProfitThisYearSorter (const Vehicle *const *a, const Vehicle *const *b)
 Sort vehicles by this year profit.
 
static int CDECL VehicleProfitLastYearSorter (const Vehicle *const *a, const Vehicle *const *b)
 Sort vehicles by last year profit.
 
static int CDECL VehicleCargoSorter (const Vehicle *const *a, const Vehicle *const *b)
 Sort vehicles by their cargo.
 
static int CDECL VehicleReliabilitySorter (const Vehicle *const *a, const Vehicle *const *b)
 Sort vehicles by their reliability.
 
static int CDECL VehicleMaxSpeedSorter (const Vehicle *const *a, const Vehicle *const *b)
 Sort vehicles by their max speed.
 
static int CDECL VehicleModelSorter (const Vehicle *const *a, const Vehicle *const *b)
 Sort vehicles by model.
 
static int CDECL VehicleValueSorter (const Vehicle *const *a, const Vehicle *const *b)
 Sort vehicles by their value.
 
static int CDECL VehicleLengthSorter (const Vehicle *const *a, const Vehicle *const *b)
 Sort vehicles by their length.
 
static int CDECL VehicleTimeToLiveSorter (const Vehicle *const *a, const Vehicle *const *b)
 Sort vehicles by the time they can still live.
 
static int CDECL VehicleTimetableDelaySorter (const Vehicle *const *a, const Vehicle *const *b)
 Sort vehicles by the timetable delay.
 
void InitializeGUI ()
 
static void ChangeVehicleWindow (WindowClass window_class, VehicleID from_index, VehicleID to_index)
 Assign a vehicle window a new vehicle. More...
 
void ChangeVehicleViewWindow (VehicleID from_index, VehicleID to_index)
 Report a change in vehicle IDs (due to autoreplace) to affected vehicle windows. More...
 
static void DrawSmallOrderList (const Vehicle *v, int left, int right, int y, VehicleOrderID start=0)
 
void DrawVehicleImage (const Vehicle *v, int left, int right, int y, VehicleID selection, EngineImageType image_type, int skip)
 Draws an image of a vehicle chain. More...
 
uint GetVehicleListHeight (VehicleType type, uint divisor)
 Get the height of a vehicle in the vehicle list GUIs. More...
 
static void ShowVehicleListWindowLocal (CompanyID company, VehicleListType vlt, VehicleType vehicle_type, uint32 unique_number)
 
void ShowVehicleListWindow (CompanyID company, VehicleType vehicle_type)
 
void ShowVehicleListWindow (const Vehicle *v)
 
void ShowVehicleListWindow (CompanyID company, VehicleType vehicle_type, StationID station)
 
void ShowVehicleListWindow (CompanyID company, VehicleType vehicle_type, TileIndex depot_tile)
 
 assert_compile (WID_VD_DETAILS_CARGO_CARRIED==WID_VD_DETAILS_CARGO_CARRIED+TDW_TAB_CARGO)
 
 assert_compile (WID_VD_DETAILS_TRAIN_VEHICLES==WID_VD_DETAILS_CARGO_CARRIED+TDW_TAB_INFO)
 
 assert_compile (WID_VD_DETAILS_CAPACITY_OF_EACH==WID_VD_DETAILS_CARGO_CARRIED+TDW_TAB_CAPACITY)
 
 assert_compile (WID_VD_DETAILS_TOTAL_CARGO==WID_VD_DETAILS_CARGO_CARRIED+TDW_TAB_TOTALS)
 
int GetTrainDetailsWndVScroll (VehicleID veh_id, TrainDetailsWindowTabs det_tab)
 Determines the number of lines in the train details window. More...
 
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. More...
 
void DrawRoadVehDetails (const Vehicle *v, int left, int right, int y)
 Draw the details for the given vehicle at the given position. More...
 
void DrawShipDetails (const Vehicle *v, int left, int right, int y)
 Draw the details for the given vehicle at the given position. More...
 
void DrawAircraftDetails (const Aircraft *v, int left, int right, int y)
 Draw the details for the given vehicle at the given position. More...
 
static void ShowVehicleDetailsWindow (const Vehicle *v)
 Shows the vehicle details window of the given vehicle. More...
 
 assert_compile (VEH_TRAIN==0)
 
 assert_compile (VEH_ROAD==1)
 
 assert_compile (VEH_SHIP==2)
 
 assert_compile (VEH_AIRCRAFT==3)
 
void CcStartStopVehicle (const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2)
 This is the Callback method after attempting to start/stop a vehicle. More...
 
void StartStopVehicle (const Vehicle *v, bool texteffect)
 Executes CMD_START_STOP_VEHICLE for given vehicle. More...
 
static bool IsVehicleRefitable (const Vehicle *v)
 Checks whether the vehicle may be refitted at the moment. More...
 
void ShowVehicleViewWindow (const Vehicle *v)
 Shows the vehicle view window of the given vehicle. More...
 
bool VehicleClicked (const Vehicle *v)
 Dispatch a "vehicle selected" event if any window waits for it. More...
 
void StopGlobalFollowVehicle (const Vehicle *v)
 
void CcBuildPrimaryVehicle (const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2)
 This is the Callback method after the construction attempt of a primary vehicle. More...
 
int GetSingleVehicleWidth (const Vehicle *v, EngineImageType image_type)
 Get the width of a vehicle (part) in pixels. More...
 
int GetVehicleWidth (const Vehicle *v, EngineImageType image_type)
 Get the width of a vehicle (including all parts of the consist) in pixels. More...
 
void SetMouseCursorVehicle (const Vehicle *v, EngineImageType image_type)
 Set the mouse cursor to look like a vehicle. More...
 

Variables

Sorting _sorting
 
static GUIVehicleList::SortFunction VehicleNumberSorter
 
static GUIVehicleList::SortFunction VehicleNameSorter
 
static GUIVehicleList::SortFunction VehicleAgeSorter
 
static GUIVehicleList::SortFunction VehicleProfitThisYearSorter
 
static GUIVehicleList::SortFunction VehicleProfitLastYearSorter
 
static GUIVehicleList::SortFunction VehicleCargoSorter
 
static GUIVehicleList::SortFunction VehicleReliabilitySorter
 
static GUIVehicleList::SortFunction VehicleMaxSpeedSorter
 
static GUIVehicleList::SortFunction VehicleModelSorter
 
static GUIVehicleList::SortFunction VehicleValueSorter
 
static GUIVehicleList::SortFunction VehicleLengthSorter
 
static GUIVehicleList::SortFunction VehicleTimeToLiveSorter
 
static GUIVehicleList::SortFunction VehicleTimetableDelaySorter
 
static const Vehicle_last_vehicle [2] = { NULL, NULL }
 
static const uint MAX_REFIT_CYCLE = 256
 Maximum number of refit cycles we try, to prevent infinite loops. More...
 
static const NWidgetPart _nested_vehicle_refit_widgets []
 
static WindowDesc _vehicle_refit_desc (WDP_AUTO, "view_vehicle_refit", 240, 174, WC_VEHICLE_REFIT, WC_VEHICLE_VIEW, WDF_CONSTRUCTION, _nested_vehicle_refit_widgets, lengthof(_nested_vehicle_refit_widgets))
 
static const NWidgetPart _nested_vehicle_list []
 
static WindowDesc _vehicle_list_other_desc (WDP_AUTO, "list_vehicles", 260, 246, WC_INVALID, WC_NONE, 0, _nested_vehicle_list, lengthof(_nested_vehicle_list))
 
static WindowDesc _vehicle_list_train_desc (WDP_AUTO, "list_vehicles_train", 325, 246, WC_TRAINS_LIST, WC_NONE, 0, _nested_vehicle_list, lengthof(_nested_vehicle_list))
 
static const NWidgetPart _nested_nontrain_vehicle_details_widgets []
 Vehicle details widgets (other than train). More...
 
static const NWidgetPart _nested_train_vehicle_details_widgets []
 Train details widgets. More...
 
static StringID _service_interval_dropdown []
 
static WindowDesc _train_vehicle_details_desc (WDP_AUTO, "view_vehicle_details_train", 405, 178, WC_VEHICLE_DETAILS, WC_VEHICLE_VIEW, 0, _nested_train_vehicle_details_widgets, lengthof(_nested_train_vehicle_details_widgets))
 Vehicle details window descriptor. More...
 
static WindowDesc _nontrain_vehicle_details_desc (WDP_AUTO, "view_vehicle_details", 405, 113, WC_VEHICLE_DETAILS, WC_VEHICLE_VIEW, 0, _nested_nontrain_vehicle_details_widgets, lengthof(_nested_nontrain_vehicle_details_widgets))
 Vehicle details window descriptor for other vehicles than a train. More...
 
static const NWidgetPart _nested_vehicle_view_widgets []
 Vehicle view widgets. More...
 
static WindowDesc _vehicle_view_desc (WDP_AUTO, "view_vehicle", 250, 116, WC_VEHICLE_VIEW, WC_NONE, 0, _nested_vehicle_view_widgets, lengthof(_nested_vehicle_view_widgets))
 Vehicle view window descriptor for all vehicles but trains. More...
 
static WindowDesc _train_view_desc (WDP_AUTO, "view_vehicle_train", 250, 134, WC_VEHICLE_VIEW, WC_NONE, 0, _nested_vehicle_view_widgets, lengthof(_nested_vehicle_view_widgets))
 Vehicle view window descriptor for trains. More...
 
static const ZoomLevel _vehicle_view_zoom_levels []
 Zoom levels for vehicle views indexed by vehicle type. More...
 
static const int VV_INITIAL_VIEWPORT_WIDTH = 226
 
static const int VV_INITIAL_VIEWPORT_HEIGHT = 84
 
static const int VV_INITIAL_VIEWPORT_HEIGHT_TRAIN = 102
 
static const uint32 _vehicle_command_translation_table [][4]
 Command codes for the shared buttons indexed by VehicleCommandTranslation and vehicle type. More...
 

Detailed Description

The base GUI for all vehicles.

Definition in file vehicle_gui.cpp.

Enumeration Type Documentation

◆ VehicleCommandTranslation

Command indices for the _vehicle_command_translation_table.

Definition at line 2349 of file vehicle_gui.cpp.

Function Documentation

◆ CcBuildPrimaryVehicle()

void CcBuildPrimaryVehicle ( const CommandCost result,
TileIndex  tile,
uint32  p1,
uint32  p2 
)

This is the Callback method after the construction attempt of a primary vehicle.

Parameters
resultindicates completion (or not) of the operation
tileunused
p1unused
p2unused

Definition at line 2826 of file vehicle_gui.cpp.

References CommandCost::Failed(), and Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_vehicle_pool >::Get().

◆ CcStartStopVehicle()

void CcStartStopVehicle ( const CommandCost result,
TileIndex  tile,
uint32  p1,
uint32  p2 
)

This is the Callback method after attempting to start/stop a vehicle.

Parameters
resultthe result of the start/stop command
tileunused
p1vehicle ID
p2unused

Definition at line 2384 of file vehicle_gui.cpp.

References _local_company, CommandCost::Failed(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_vehicle_pool >::GetIfValid(), Vehicle::IsPrimaryVehicle(), Vehicle::owner, RemapCoords(), Vehicle::vehstatus, VS_STOPPED, Vehicle::x_pos, Vehicle::y_pos, and Vehicle::z_pos.

◆ ChangeVehicleViewWindow()

void ChangeVehicleViewWindow ( VehicleID  from_index,
VehicleID  to_index 
)

Report a change in vehicle IDs (due to autoreplace) to affected vehicle windows.

Parameters
from_indexthe old vehicle ID
to_indexthe new vehicle ID

Definition at line 1243 of file vehicle_gui.cpp.

References ChangeVehicleWindow(), WC_VEHICLE_DETAILS, WC_VEHICLE_ORDERS, WC_VEHICLE_REFIT, WC_VEHICLE_TIMETABLE, and WC_VEHICLE_VIEW.

◆ ChangeVehicleWindow()

static void ChangeVehicleWindow ( WindowClass  window_class,
VehicleID  from_index,
VehicleID  to_index 
)
inlinestatic

Assign a vehicle window a new vehicle.

Parameters
window_classWindowClass to search for
from_indexthe old vehicle ID
to_indexthe new vehicle ID

Definition at line 1220 of file vehicle_gui.cpp.

References FindWindowById(), ViewportData::follow_vehicle, Window::viewport, and Window::window_number.

Referenced by ChangeVehicleViewWindow().

◆ DrawAircraftDetails()

void DrawAircraftDetails ( const Aircraft v,
int  left,
int  right,
int  y 
)

Draw the details for the given vehicle at the given position.

Parameters
vcurrent vehicle
leftThe left most coordinate to draw
rightThe right most coordinate to draw
yThe y coordinate

Definition at line 34 of file aircraft_gui.cpp.

◆ DrawRoadVehDetails()

void DrawRoadVehDetails ( const Vehicle v,
int  left,
int  right,
int  y 
)

Draw the details for the given vehicle at the given position.

Parameters
vcurrent vehicle
leftThe left most coordinate to draw
rightThe right most coordinate to draw
yThe y coordinate

Definition at line 32 of file roadveh_gui.cpp.

◆ DrawShipDetails()

void DrawShipDetails ( const Vehicle v,
int  left,
int  right,
int  y 
)

Draw the details for the given vehicle at the given position.

Parameters
vcurrent vehicle
leftThe left most coordinate to draw
rightThe right most coordinate to draw
yThe y coordinate

Definition at line 66 of file ship_gui.cpp.

◆ DrawTrainDetails()

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.

Parameters
vcurrent vehicle
leftThe left most coordinate to draw
rightThe right most coordinate to draw
yThe y coordinate
vscroll_posPosition of scrollbar
vscroll_capNumber of lines currently displayed
det_tabSelected details tab

Definition at line 356 of file train_gui.cpp.

◆ DrawVehicleImage()

void DrawVehicleImage ( const Vehicle v,
int  left,
int  right,
int  y,
VehicleID  selection,
EngineImageType  image_type,
int  skip 
)

Draws an image of a vehicle chain.

Parameters
vFront vehicle
leftThe minimum horizontal position
rightThe maximum horizontal position
yVertical position to draw at
selectionSelected vehicle to draw a frame around
skipNumber of pixels to skip at the front (for scrolling)

Definition at line 1333 of file vehicle_gui.cpp.

Referenced by RefitWindow::DrawWidget().

◆ DrawVehicleProfitButton()

static void DrawVehicleProfitButton ( const Vehicle v,
int  x,
int  y 
)
static

draw the vehicle profit button in the vehicle list window.

Definition at line 201 of file vehicle_gui.cpp.

◆ DrawVehicleRefitWindow()

static void DrawVehicleRefitWindow ( const SubtypeList  list[NUM_CARGO],
const int  sel[2],
uint  pos,
uint  rows,
uint  delta,
const Rect r 
)
static

Draw the list of available refit options for a consist and highlight the selected refit option (if any).

Parameters
listList of subtype options for each (sorted) cargo.
selSelected refit cargo-type in the window
posPosition of the selected item in caller widow
rowsNumber of rows(capacity) in caller window
deltaStep height in caller window
rRectangle of the matrix widget.

Definition at line 331 of file vehicle_gui.cpp.

◆ GetBestFittingSubType()

byte GetBestFittingSubType ( Vehicle v_from,
Vehicle v_for,
CargoID  dest_cargo_type 
)

Get the best fitting subtype when 'cloning'/'replacing' v_from with v_for.

All articulated parts of both vehicles are tested to find a possibly shared subtype. For v_for only vehicle refittable to dest_cargo_type are considered.

Parameters
v_fromthe vehicle to match the subtype from
v_forthe vehicle to get the subtype for
dest_cargo_typeDestination cargo type.
Returns
the best sub type

Definition at line 230 of file vehicle_gui.cpp.

References EngineInfo::callback_mask, Engine::CanCarryCargo(), CBM_VEHICLE_CARGO_SUFFIX, SmallVector< T, S >::Clear(), SmallVector< T, S >::Contains(), GetCargoSubtypeText(), Vehicle::GetEngine(), Vehicle::GetFirstEnginePart(), Vehicle::GetNextArticulatedPart(), Vehicle::HasArticulatedPart(), HasBit(), SmallVector< T, S >::Include(), SmallVector< T, S >::Length(), and MAX_REFIT_CYCLE.

Referenced by LinkRefresher::HandleRefit().

◆ GetCargoSubtypeText()

StringID GetCargoSubtypeText ( const Vehicle v)

Get the cargo subtype text from NewGRF for the vehicle details window.

Definition at line 1072 of file vehicle_gui.cpp.

References HasBit().

Referenced by RefitWindow::BuildRefitList(), GetBestFittingSubType(), and GetCargoSummaryOfArticulatedVehicle().

◆ GetSingleVehicleWidth()

int GetSingleVehicleWidth ( const Vehicle v,
EngineImageType  image_type 
)

◆ GetTrainDetailsWndVScroll()

int GetTrainDetailsWndVScroll ( VehicleID  veh_id,
TrainDetailsWindowTabs  det_tab 
)

◆ GetUnitNumberDigits()

uint GetUnitNumberDigits ( VehicleList vehicles)

Get the number of digits the biggest unit number of a set of vehicles has.

Parameters
vehiclesThe list of vehicles.
Returns
The number of digits to allocate space for.

Definition at line 106 of file vehicle_gui.cpp.

References SmallVector< T, S >::Begin(), DEBUG, SmallVector< T, S >::End(), GenerateVehicleSortList(), GetUnitNumberDigits(), SmallVector< T, S >::Length(), GUIList< T, F >::NeedRebuild(), GUIList< T, F >::RebuildDone(), Scrollbar::SetCount(), VehicleListIdentifier::type, BaseVehicleListWindow::unitnumber_digits, BaseVehicleListWindow::vehicles, and BaseVehicleListWindow::vli.

Referenced by GetUnitNumberDigits().

◆ GetVehicleListHeight()

uint GetVehicleListHeight ( VehicleType  type,
uint  divisor 
)

Get the height of a vehicle in the vehicle list GUIs.

Parameters
typethe vehicle type to look at
divisorthe resulting height must be dividable by this
Returns
the height

Definition at line 1350 of file vehicle_gui.cpp.

References FONT_HEIGHT_SMALL, GetVehicleHeight(), max(), ScaleGUITrad(), and VEH_SHIP.

Referenced by VehicleGroupWindow::UpdateWidgetSize(), and VehicleListWindow::UpdateWidgetSize().

◆ GetVehicleWidth()

int GetVehicleWidth ( const Vehicle v,
EngineImageType  image_type 
)

Get the width of a vehicle (including all parts of the consist) in pixels.

Parameters
vVehicle to get the width for.
Returns
Width of the vehicle.

Definition at line 2863 of file vehicle_gui.cpp.

References GetSingleVehicleWidth(), Vehicle::Next(), BaseVehicle::type, VEH_ROAD, and VEH_TRAIN.

Referenced by GetVehicleHeight(), and RefitWindow::OnResize().

◆ IsVehicleRefitable()

static bool IsVehicleRefitable ( const Vehicle v)
static

Checks whether the vehicle may be refitted at the moment.

Definition at line 2408 of file vehicle_gui.cpp.

References Vehicle::engine_type, IsEngineRefittable(), Vehicle::IsGroundVehicle(), Vehicle::IsStoppedInDepot(), and Vehicle::Next().

Referenced by VehicleViewWindow::OnPaint().

◆ SetMouseCursorVehicle()

void SetMouseCursorVehicle ( const Vehicle v,
EngineImageType  image_type 
)

Set the mouse cursor to look like a vehicle.

Parameters
vVehicle
image_typeType of vehicle image to use.

Definition at line 2881 of file vehicle_gui.cpp.

References _current_text_dir, and TD_RTL.

◆ ShowVehicleDetailsWindow()

static void ShowVehicleDetailsWindow ( const Vehicle v)
static

◆ ShowVehicleRefitWindow()

void ShowVehicleRefitWindow ( const Vehicle v,
VehicleOrderID  order,
Window parent,
bool  auto_refit 
)

Show the refit window for a vehicle.

Parameters
*vThe vehicle to show the refit window for
orderof the vehicle to assign refit to, or INVALID_VEH_ORDER_ID to refit the vehicle now
parentthe parent window of the refit window
auto_refitChoose cargo for auto-refitting

Definition at line 1035 of file vehicle_gui.cpp.

References DeleteWindowById(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem< Tpool >::index, Window::parent, and WC_VEHICLE_REFIT.

Referenced by OrdersWindow::OrderClick_Refit().

◆ ShowVehicleViewWindow()

void ShowVehicleViewWindow ( const Vehicle v)

◆ StartStopVehicle()

void StartStopVehicle ( const Vehicle v,
bool  texteffect 
)

Executes CMD_START_STOP_VEHICLE for given vehicle.

Parameters
vVehicle to start/stop
texteffectShould a texteffect be shown?

Definition at line 2401 of file vehicle_gui.cpp.

Referenced by VehicleViewWindow::OnClick().

◆ VehicleClicked()

bool VehicleClicked ( const Vehicle v)

Dispatch a "vehicle selected" event if any window waits for it.

Parameters
vselected vehicle;
Returns
did any window accept vehicle selection?

Definition at line 2798 of file vehicle_gui.cpp.

Referenced by DepotWindow::DepotClick(), and VehicleListWindow::OnClick().

Variable Documentation

◆ _nested_nontrain_vehicle_details_widgets

const NWidgetPart _nested_nontrain_vehicle_details_widgets[]
static
Initial value:
= {
NWidget(WWT_CLOSEBOX, COLOUR_GREY),
NWidget(WWT_CAPTION, COLOUR_GREY, WID_VD_CAPTION), SetDataTip(STR_VEHICLE_DETAILS_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_VD_RENAME_VEHICLE), SetMinimalSize(40, 0), SetMinimalTextLines(1, WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM + 2), SetDataTip(STR_VEHICLE_NAME_BUTTON, STR_NULL ),
NWidget(WWT_SHADEBOX, COLOUR_GREY),
NWidget(WWT_DEFSIZEBOX, COLOUR_GREY),
NWidget(WWT_STICKYBOX, COLOUR_GREY),
SetDataTip(AWV_DECREASE, STR_VEHICLE_DETAILS_DECREASE_SERVICING_INTERVAL_TOOLTIP),
SetDataTip(AWV_INCREASE, STR_VEHICLE_DETAILS_INCREASE_SERVICING_INTERVAL_TOOLTIP),
SetDataTip(STR_EMPTY, STR_SERVICE_INTERVAL_DROPDOWN_TOOLTIP),
NWidget(WWT_RESIZEBOX, COLOUR_GREY),
}
static NWidgetPart SetResize(int16 dx, int16 dy)
Widget part function for setting the resize step.
Definition: widget_type.h:930
Offset at top to draw the frame rectangular area.
Definition: window_gui.h:64
Horizontal container.
Definition: widget_type.h:75
Arrow to the right or in case of RTL to the left.
Definition: widget_type.h:38
Arrow to the left or in case of RTL to the right.
Definition: widget_type.h:37
Resize box (normally at bottom-right of a window)
Definition: widget_type.h:68
Close box (at top-left of a window)
Definition: widget_type.h:69
Rename this vehicle.
static NWidgetPart SetMinimalTextLines(uint8 lines, uint8 spacing, FontSize size=FS_NORMAL)
Widget part function for setting the minimal text lines.
Definition: widget_type.h:965
Default window size box (at top-right of a window, between WWT_SHADEBOX and WWT_STICKYBOX) ...
Definition: widget_type.h:65
static NWidgetPart SetDataTip(uint32 data, StringID tip)
Widget part function for setting the data and tooltip.
Definition: widget_type.h:1014
static NWidgetPart SetMinimalSize(int16 x, int16 y)
Widget part function for setting the minimal size.
Definition: widget_type.h:947
Decrease the servicing interval.
Normal push-button (no toggle button) with text caption.
Definition: widget_type.h:104
Simple depressed panel.
Definition: widget_type.h:50
static NWidgetPart NWidget(WidgetType tp, Colours col, int16 idx=-1)
Widget part function for starting a new &#39;real&#39; widget.
Definition: widget_type.h:1114
Offset at bottom to draw the frame rectangular area.
Definition: window_gui.h:65
Increase the servicing interval.
Details for non-trains.
Window caption (window title between closebox and stickybox)
Definition: widget_type.h:61
Panel with generic details.
static NWidgetPart EndContainer()
Widget part function for denoting the end of a container (horizontal, vertical, WWT_FRAME, WWT_INSET, or WWT_PANEL).
Definition: widget_type.h:999
Information about the servicing interval.
Drop down list.
Definition: widget_type.h:70
Normal push-button (no toggle button) with arrow caption.
Definition: widget_type.h:106
Sticky box (at top-right of a window, after WWT_DEFSIZEBOX)
Definition: widget_type.h:66
static NWidgetPart SetFill(uint fill_x, uint fill_y)
Widget part function for setting filling.
Definition: widget_type.h:983
Dropdown to select default/days/percent service interval.
Caption of window.
Shade box (at top-right of a window, between WWT_DEBUGBOX and WWT_DEFSIZEBOX)
Definition: widget_type.h:64

Vehicle details widgets (other than train).

Definition at line 1791 of file vehicle_gui.cpp.

◆ _nested_train_vehicle_details_widgets

const NWidgetPart _nested_train_vehicle_details_widgets[]
static

Train details widgets.

Definition at line 1815 of file vehicle_gui.cpp.

◆ _nested_vehicle_refit_widgets

const NWidgetPart _nested_vehicle_refit_widgets[]
static
Initial value:
= {
NWidget(WWT_CLOSEBOX, COLOUR_GREY),
NWidget(WWT_CAPTION, COLOUR_GREY, WID_VR_CAPTION), SetDataTip(STR_REFIT_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
NWidget(WWT_DEFSIZEBOX, COLOUR_GREY),
NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_VR_SELECT_HEADER), SetDataTip(STR_REFIT_TITLE, STR_NULL), SetResize(1, 0),
NWidget(WWT_MATRIX, COLOUR_GREY, WID_VR_MATRIX), SetMinimalSize(228, 112), SetResize(1, 14), SetFill(1, 1), SetMatrixDataTip(1, 0, STR_NULL), SetScrollbar(WID_VR_SCROLLBAR),
NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_VR_REFIT), SetFill(1, 0), SetResize(1, 0),
NWidget(WWT_RESIZEBOX, COLOUR_GREY),
}
static NWidgetPart SetResize(int16 dx, int16 dy)
Widget part function for setting the resize step.
Definition: widget_type.h:930
Header with question about the cargo to carry.
Offset at top to draw the frame rectangular area.
Definition: window_gui.h:64
Horizontal container.
Definition: widget_type.h:75
Resize box (normally at bottom-right of a window)
Definition: widget_type.h:68
Close box (at top-left of a window)
Definition: widget_type.h:69
static NWidgetPart SetMinimalTextLines(uint8 lines, uint8 spacing, FontSize size=FS_NORMAL)
Widget part function for setting the minimal text lines.
Definition: widget_type.h:965
Horizontal scrollbar or the vehicle display.
Display with a representation of the vehicle to refit.
static NWidgetPart SetMatrixDataTip(uint8 cols, uint8 rows, StringID tip)
Widget part function for setting the data and tooltip of WWT_MATRIX widgets.
Definition: widget_type.h:1032
Default window size box (at top-right of a window, between WWT_SHADEBOX and WWT_STICKYBOX) ...
Definition: widget_type.h:65
Scrollbar for the refit options.
Options to refit to.
static NWidgetPart SetDataTip(uint32 data, StringID tip)
Widget part function for setting the data and tooltip.
Definition: widget_type.h:1014
static NWidgetPart SetMinimalSize(int16 x, int16 y)
Widget part function for setting the minimal size.
Definition: widget_type.h:947
Normal push-button (no toggle button) with text caption.
Definition: widget_type.h:104
Simple depressed panel.
Definition: widget_type.h:50
Selection widget for the horizontal scrollbar.
Horizontal scrollbar.
Definition: widget_type.h:83
static NWidgetPart NWidget(WidgetType tp, Colours col, int16 idx=-1)
Widget part function for starting a new &#39;real&#39; widget.
Definition: widget_type.h:1114
Offset at bottom to draw the frame rectangular area.
Definition: window_gui.h:65
Grid of rows and columns.
Definition: widget_type.h:59
Window caption (window title between closebox and stickybox)
Definition: widget_type.h:61
Vertical container.
Definition: widget_type.h:77
static NWidgetPart EndContainer()
Widget part function for denoting the end of a container (horizontal, vertical, WWT_FRAME, WWT_INSET, or WWT_PANEL).
Definition: widget_type.h:999
Caption of window.
static NWidgetPart SetFill(uint fill_x, uint fill_y)
Widget part function for setting filling.
Definition: widget_type.h:983
Information about the currently selected refit option.
Perform the refit.
Vertical scrollbar.
Definition: widget_type.h:84
Stacked widgets, only one visible at a time (eg in a panel with tabs).
Definition: widget_type.h:80
static NWidgetPart SetScrollbar(int index)
Attach a scrollbar to a widget.
Definition: widget_type.h:1095
(Toggle) Button with text
Definition: widget_type.h:55

Definition at line 995 of file vehicle_gui.cpp.

◆ _nested_vehicle_view_widgets

const NWidgetPart _nested_vehicle_view_widgets[]
static

Vehicle view widgets.

Definition at line 2268 of file vehicle_gui.cpp.

◆ _nontrain_vehicle_details_desc

WindowDesc _nontrain_vehicle_details_desc(WDP_AUTO, "view_vehicle_details", 405, 113, WC_VEHICLE_DETAILS, WC_VEHICLE_VIEW, 0, _nested_nontrain_vehicle_details_widgets, lengthof(_nested_nontrain_vehicle_details_widgets))
static

Vehicle details window descriptor for other vehicles than a train.

Referenced by VehicleDetailsWindow::OnResize().

◆ _service_interval_dropdown

StringID _service_interval_dropdown[]
static
Initial value:
= {
STR_VEHICLE_DETAILS_DEFAULT,
STR_VEHICLE_DETAILS_DAYS,
STR_VEHICLE_DETAILS_PERCENT,
}
static const StringID INVALID_STRING_ID
Constant representing an invalid string (16bit in case it is used in savegames)
Definition: strings_type.h:19

Definition at line 1858 of file vehicle_gui.cpp.

◆ _train_vehicle_details_desc

WindowDesc _train_vehicle_details_desc(WDP_AUTO, "view_vehicle_details_train", 405, 178, WC_VEHICLE_DETAILS, WC_VEHICLE_VIEW, 0, _nested_train_vehicle_details_widgets, lengthof(_nested_train_vehicle_details_widgets))
static

Vehicle details window descriptor.

Referenced by VehicleDetailsWindow::OnResize().

◆ _train_view_desc

WindowDesc _train_view_desc(WDP_AUTO, "view_vehicle_train", 250, 134, WC_VEHICLE_VIEW, WC_NONE, 0, _nested_vehicle_view_widgets, lengthof(_nested_vehicle_view_widgets))
static

Vehicle view window descriptor for trains.

Only minimum_height and default_height are different for train view.

◆ _vehicle_command_translation_table

const uint32 _vehicle_command_translation_table[][4]
static
Initial value:
= {
{
CMD_START_STOP_VEHICLE | CMD_MSG(STR_ERROR_CAN_T_STOP_START_TRAIN),
CMD_START_STOP_VEHICLE | CMD_MSG(STR_ERROR_CAN_T_STOP_START_ROAD_VEHICLE),
CMD_START_STOP_VEHICLE | CMD_MSG(STR_ERROR_CAN_T_STOP_START_SHIP),
CMD_START_STOP_VEHICLE | CMD_MSG(STR_ERROR_CAN_T_STOP_START_AIRCRAFT)
},
{
CMD_CLONE_VEHICLE | CMD_MSG(STR_ERROR_CAN_T_BUY_TRAIN),
CMD_CLONE_VEHICLE | CMD_MSG(STR_ERROR_CAN_T_BUY_ROAD_VEHICLE),
CMD_CLONE_VEHICLE | CMD_MSG(STR_ERROR_CAN_T_BUY_SHIP),
CMD_CLONE_VEHICLE | CMD_MSG(STR_ERROR_CAN_T_BUY_AIRCRAFT)
},
{
CMD_REVERSE_TRAIN_DIRECTION | CMD_MSG(STR_ERROR_CAN_T_REVERSE_DIRECTION_TRAIN),
CMD_TURN_ROADVEH | CMD_MSG(STR_ERROR_CAN_T_MAKE_ROAD_VEHICLE_TURN),
0xffffffff,
0xffffffff
},
}
start or stop a vehicle
Definition: command_type.h:310
turn a train around
Definition: command_type.h:223
clone a vehicle
Definition: command_type.h:309
#define CMD_MSG(x)
Used to combine a StringID with the command.
Definition: command_type.h:366
turn a road vehicle around
Definition: command_type.h:253

Command codes for the shared buttons indexed by VehicleCommandTranslation and vehicle type.

Definition at line 2356 of file vehicle_gui.cpp.

◆ _vehicle_view_desc

WindowDesc _vehicle_view_desc(WDP_AUTO, "view_vehicle", 250, 116, WC_VEHICLE_VIEW, WC_NONE, 0, _nested_vehicle_view_widgets, lengthof(_nested_vehicle_view_widgets))
static

Vehicle view window descriptor for all vehicles but trains.

◆ _vehicle_view_zoom_levels

const ZoomLevel _vehicle_view_zoom_levels[]
static
Initial value:
= {
}
Default zoom level for the aircraft view.
Definition: zoom_type.h:39
Default zoom level for the ship view.
Definition: zoom_type.h:40
Default zoom level for the road vehicle view.
Definition: zoom_type.h:42
Default zoom level for the train view.
Definition: zoom_type.h:41

Zoom levels for vehicle views indexed by vehicle type.

Definition at line 2336 of file vehicle_gui.cpp.

◆ MAX_REFIT_CYCLE

const uint MAX_REFIT_CYCLE = 256
static

Maximum number of refit cycles we try, to prevent infinite loops.

And we store only a byte anyway

Definition at line 219 of file vehicle_gui.cpp.

Referenced by RefitWindow::BuildRefitList(), and GetBestFittingSubType().