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.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 "window_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 "table/strings.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

void DepotSortList (VehicleList *list)
static void DrawVehicleProfitButton (const Vehicle *v, int x, int y)
 draw the vehicle profit button in the vehicle list window.
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.
static void DrawVehicleRefitWindow (const SubtypeList list[NUM_CARGO], int sel, 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).
void ShowVehicleRefitWindow (const Vehicle *v, VehicleOrderID order, Window *parent, bool auto_refit)
 Show the refit window for a vehicle.
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.
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 vehciles 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.
void ChangeVehicleViewWindow (VehicleID from_index, VehicleID to_index)
 Report a change in vehicle IDs (due to autoreplace) to affected vehicle windows.
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.
uint GetVehicleListHeight (VehicleType type, uint divisor)
 Get the height of a vehicle in the vehicle list GUIs.
static void ShowVehicleListWindowLocal (CompanyID company, VehicleListType vlt, VehicleType vehicle_type, uint16 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.
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.
void DrawRoadVehDetails (const Vehicle *v, int left, int right, int y)
 Draw the details for the given vehicle at the given position.
void DrawShipDetails (const Vehicle *v, int left, int right, int y)
 Draw the details for the given vehicle at the given position.
void DrawAircraftDetails (const Aircraft *v, int left, int right, int y)
 Draw the details for the given vehicle at the given position.
static void ShowVehicleDetailsWindow (const Vehicle *v)
 Shows the vehicle details window of the given vehicle.
 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 the cloning attempt of a vehicle.
void StartStopVehicle (const Vehicle *v, bool texteffect)
 Executes CMD_START_STOP_VEHICLE for given vehicle.
static bool IsVehicleRefitable (const Vehicle *v)
 Checks whether the vehicle may be refitted at the moment.
void ShowVehicleViewWindow (const Vehicle *v)
 Shows the vehicle view window of the given vehicle.
bool VehicleClicked (const Vehicle *v)
 Dispatch a "vehicle selected" event if any window waits for it.
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.
int GetVehicleWidth (Vehicle *v, EngineImageType image_type)
 Get the width of a vehicle (including all parts of the consist) in pixels.

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.
static const NWidgetPart _nested_vehicle_refit_widgets []
static const WindowDesc _vehicle_refit_desc (WDP_AUTO, 240, 174, WC_VEHICLE_REFIT, WC_VEHICLE_VIEW, WDF_UNCLICK_BUTTONS|WDF_CONSTRUCTION, _nested_vehicle_refit_widgets, lengthof(_nested_vehicle_refit_widgets))
static const NWidgetPart _nested_vehicle_list []
static WindowDesc _vehicle_list_desc (WDP_AUTO, 260, 246, WC_INVALID, WC_NONE, WDF_UNCLICK_BUTTONS, _nested_vehicle_list, lengthof(_nested_vehicle_list))
static const NWidgetPart _nested_nontrain_vehicle_details_widgets []
 Vehicle details widgets (other than train).
static const NWidgetPart _nested_train_vehicle_details_widgets []
 Train details widgets.
static const WindowDesc _train_vehicle_details_desc (WDP_AUTO, 405, 178, WC_VEHICLE_DETAILS, WC_VEHICLE_VIEW, WDF_UNCLICK_BUTTONS, _nested_train_vehicle_details_widgets, lengthof(_nested_train_vehicle_details_widgets))
 Vehicle details window descriptor.
static const WindowDesc _nontrain_vehicle_details_desc (WDP_AUTO, 405, 113, WC_VEHICLE_DETAILS, WC_VEHICLE_VIEW, WDF_UNCLICK_BUTTONS, _nested_nontrain_vehicle_details_widgets, lengthof(_nested_nontrain_vehicle_details_widgets))
 Vehicle details window descriptor for other vehicles than a train.
static const NWidgetPart _nested_vehicle_view_widgets []
 Vehicle view widgets.
static const WindowDesc _vehicle_view_desc (WDP_AUTO, 250, 116, WC_VEHICLE_VIEW, WC_NONE, WDF_UNCLICK_BUTTONS, _nested_vehicle_view_widgets, lengthof(_nested_vehicle_view_widgets))
 Vehicle view window descriptor for all vehicles but trains.
static const WindowDesc _train_view_desc (WDP_AUTO, 250, 134, WC_VEHICLE_VIEW, WC_NONE, WDF_UNCLICK_BUTTONS, _nested_vehicle_view_widgets, lengthof(_nested_vehicle_view_widgets))
 Vehicle view window descriptor for trains.
static const ZoomLevel _vehicle_view_zoom_levels []
 Zoom levels for vehicle views indexed by vehicle type.
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.

Detailed Description

The base GUI for all vehicles.

Definition in file vehicle_gui.cpp.


Enumeration Type Documentation

Command indices for the _vehicle_command_translation_table.

Definition at line 2203 of file vehicle_gui.cpp.


Function Documentation

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:
result indicates completion (or not) of the operation
tile unused
p1 unused
p2 unused

Definition at line 2665 of file vehicle_gui.cpp.

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

Referenced by BuildVehicleWindow::OnClick().

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

This is the Callback method after the cloning attempt of a vehicle.

Parameters:
result the result of the cloning command
tile unused
p1 vehicle ID
p2 unused

Definition at line 2238 of file vehicle_gui.cpp.

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

Referenced by StartStopVehicle().

void ChangeVehicleViewWindow ( VehicleID  from_index,
VehicleID  to_index 
)

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

Parameters:
from_index the old vehicle ID
to_index the new vehicle ID

Definition at line 1154 of file vehicle_gui.cpp.

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

Referenced by CopyHeadSpecificThings().

static void ChangeVehicleWindow ( WindowClass  window_class,
VehicleID  from_index,
VehicleID  to_index 
) [inline, static]

Assign a vehicle window a new vehicle.

Parameters:
window_class WindowClass to search for
from_index the old vehicle ID
to_index the new vehicle ID

Definition at line 1131 of file vehicle_gui.cpp.

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

Referenced by ChangeVehicleViewWindow().

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

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

Parameters:
v current vehicle
left The left most coordinate to draw
right The right most coordinate to draw
y The y coordinate

Definition at line 32 of file aircraft_gui.cpp.

References DrawString(), FONT_HEIGHT_NORMAL, GetCargoSubtypeText(), SA_LEFT, SA_STRIP, and SetDParam().

Referenced by VehicleDetailsWindow::DrawVehicleDetails().

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

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

Parameters:
v current vehicle
left The left most coordinate to draw
right The right most coordinate to draw
y The y coordinate

Definition at line 32 of file roadveh_gui.cpp.

References Vehicle::build_year, Vehicle::cargo, Vehicle::cargo_cap, Vehicle::cargo_type, CargoList< Tinst, Tcont >::Count(), DrawString(), CargoList< Tinst, Tcont >::Empty(), Vehicle::engine_type, VehicleCargoList::FeederShare(), FONT_HEIGHT_NORMAL, GetCargoSubtypeText(), Vehicle::HasArticulatedPart(), lastof, Vehicle::Next(), SA_LEFT, SA_STRIP, SetDParam(), VehicleCargoList::Source(), strecat(), and Vehicle::value.

Referenced by VehicleDetailsWindow::DrawVehicleDetails().

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

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

Parameters:
v current vehicle
left The left most coordinate to draw
right The right most coordinate to draw
y The y coordinate

Definition at line 60 of file ship_gui.cpp.

References Vehicle::build_year, Vehicle::cargo, Vehicle::cargo_cap, Vehicle::cargo_type, CargoList< Tinst, Tcont >::Count(), DrawString(), CargoList< Tinst, Tcont >::Empty(), Vehicle::engine_type, VehicleCargoList::FeederShare(), FONT_HEIGHT_NORMAL, GetCargoSubtypeText(), SA_LEFT, SA_STRIP, SetDParam(), VehicleCargoList::Source(), and Vehicle::value.

Referenced by VehicleDetailsWindow::DrawVehicleDetails().

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:
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 341 of file train_gui.cpp.

References _colour_gradient, _current_text_dir, _settings_game, DIR_E, DrawSprite(), DrawString(), EIT_IN_DETAILS, FONT_HEIGHT_NORMAL, VehicleSettings::freight_trains, FreightWagonMult(), GetCargoSummaryOfArticulatedVehicle(), GetVehiclePalette(), GfxFillRect(), SmallVector< T, S >::Length(), max(), 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, and WD_MATRIX_TOP.

Referenced by VehicleDetailsWindow::DrawVehicleDetails().

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:
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)

Definition at line 1240 of file vehicle_gui.cpp.

References DrawAircraftImage(), DrawRoadVehImage(), DrawShipImage(), DrawTrainImage(), BaseVehicle::type, VEH_AIRCRAFT, VEH_ROAD, VEH_SHIP, and VEH_TRAIN.

Referenced by BaseVehicleListWindow::DrawVehicleListItems(), VehicleDetailsWindow::DrawWidget(), and RefitWindow::DrawWidget().

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

draw the vehicle profit button in the vehicle list window.

Definition at line 192 of file vehicle_gui.cpp.

References Vehicle::age, DrawSprite(), Vehicle::GetDisplayProfitLastYear(), VEHICLE_PROFIT_MIN_AGE, and VEHICLE_PROFIT_THRESHOLD.

Referenced by BaseVehicleListWindow::DrawVehicleListItems().

static void DrawVehicleRefitWindow ( const SubtypeList  list[NUM_CARGO],
int  sel,
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:
list List of subtype options for each (sorted) cargo.
sel Selected refit cargo-type in the window
pos Position of the selected item in caller widow
rows Number of rows(capacity) in caller window
delta Step height in caller window
r Rectangle of the matrix widget.

Definition at line 327 of file vehicle_gui.cpp.

References CALLBACK_FAILED, RefitOption::cargo, DrawString(), RefitOption::engine, CargoSpec::Get(), Engine::GetGRFID(), GetGRFStringID(), SmallVector< T, S >::Length(), CargoSpec::name, SetDParam(), RefitOption::value, WD_MATRIX_LEFT, and WD_MATRIX_RIGHT.

Referenced by RefitWindow::DrawWidget().

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_from the vehicle to match the subtype from
v_for the vehicle to get the subtype for
dest_cargo_type Destination cargo type.
Returns:
the best sub type

Definition at line 221 of file vehicle_gui.cpp.

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

Referenced by BuildReplacementVehicle(), CmdCloneVehicle(), and LoadUnloadVehicle().

StringID GetCargoSubtypeText ( const Vehicle v  ) 
int GetTrainDetailsWndVScroll ( VehicleID  veh_id,
TrainDetailsWindowTabs  det_tab 
)

Determines the number of lines in the train details window.

Parameters:
veh_id Train
det_tab Selected details tab
Returns:
Number of line

Definition at line 298 of file train_gui.cpp.

References Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_vehicle_pool >::Get(), GetCargoSummaryOfArticulatedVehicle(), GetLengthOfArticulatedVehicle(), SmallVector< T, S >::Length(), max(), TDW_TAB_TOTALS, and TRAIN_DETAILS_MAX_INDENT.

Referenced by VehicleDetailsWindow::OnPaint().

uint GetVehicleListHeight ( VehicleType  type,
uint  divisor 
)

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

Parameters:
type the vehicle type to look at
divisor the resulting height must be dividable by this
Returns:
the height

Definition at line 1257 of file vehicle_gui.cpp.

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

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

int GetVehicleWidth ( Vehicle v,
EngineImageType  image_type 
)

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

Parameters:
v Vehicle to get the width for.
Returns:
Width of the vehicle.

Definition at line 2678 of file vehicle_gui.cpp.

References _current_text_dir, DIR_E, DIR_W, Vehicle::GetImage(), ST_NORMAL, BaseVehicle::type, UnScaleByZoom(), VEH_ROAD, VEH_TRAIN, Sprite::width, and ZOOM_LVL_GUI.

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

static bool IsVehicleRefitable ( const Vehicle v  )  [static]

Checks whether the vehicle may be refitted at the moment.

Definition at line 2262 of file vehicle_gui.cpp.

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

Referenced by VehicleViewWindow::OnPaint().

static void ShowVehicleDetailsWindow ( const Vehicle v  )  [static]
void ShowVehicleRefitWindow ( const Vehicle v,
VehicleOrderID  order,
Window parent,
bool  auto_refit 
)

Show the refit window for a vehicle.

Parameters:
*v The vehicle to show the refit window for
order of the vehicle ( ? )
parent the parent window of the refit window
auto_refit Choose cargo for auto-refitting

Definition at line 923 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 VehicleViewWindow::OnClick(), and OrdersWindow::OrderClick_Refit().

void ShowVehicleViewWindow ( const Vehicle v  ) 
void StartStopVehicle ( const Vehicle v,
bool  texteffect 
)
bool VehicleClicked ( const Vehicle v  ) 

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

Parameters:
v selected vehicle;
Returns:
did any window accept vehicle selection?

Definition at line 2637 of file vehicle_gui.cpp.

References Vehicle::First(), TileHighlightData::GetCallbackWnd(), HT_VEHICLE, Vehicle::IsPrimaryVehicle(), Window::OnVehicleSelect(), and TileHighlightData::place_mode.

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


Variable Documentation

Initial value:
 {
  NWidget(NWID_HORIZONTAL),
    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_STICKYBOX, COLOUR_GREY),
  EndContainer(),
  NWidget(WWT_PANEL, COLOUR_GREY, WID_VD_TOP_DETAILS), SetMinimalSize(405, 42), SetResize(1, 0), EndContainer(),
  NWidget(WWT_PANEL, COLOUR_GREY, WID_VD_MIDDLE_DETAILS), SetMinimalSize(405, 45), SetResize(1, 0), EndContainer(),
  NWidget(NWID_HORIZONTAL),
    NWidget(WWT_PUSHARROWBTN, COLOUR_GREY, WID_VD_DECREASE_SERVICING_INTERVAL), SetFill(0, 1),
        SetDataTip(AWV_DECREASE, STR_VEHICLE_DETAILS_DECREASE_SERVICING_INTERVAL_TOOLTIP),
    NWidget(WWT_PUSHARROWBTN, COLOUR_GREY, WID_VD_INCREASE_SERVICING_INTERVAL), SetFill(0, 1),
        SetDataTip(AWV_INCREASE, STR_VEHICLE_DETAILS_INCREASE_SERVICING_INTERVAL_TOOLTIP),
    NWidget(WWT_PANEL, COLOUR_GREY, WID_VD_SERVICING_INTERVAL), SetFill(1, 1), SetResize(1, 0), EndContainer(),
    NWidget(WWT_RESIZEBOX, COLOUR_GREY),
  EndContainer(),
}

Vehicle details widgets (other than train).

Definition at line 1698 of file vehicle_gui.cpp.

Train details widgets.

Definition at line 1719 of file vehicle_gui.cpp.

const NWidgetPart _nested_vehicle_refit_widgets[] [static]
Initial value:

Definition at line 884 of file vehicle_gui.cpp.

Vehicle view widgets.

Definition at line 2123 of file vehicle_gui.cpp.

const WindowDesc _nontrain_vehicle_details_desc(WDP_AUTO, 405, 113, WC_VEHICLE_DETAILS, WC_VEHICLE_VIEW, WDF_UNCLICK_BUTTONS, _nested_nontrain_vehicle_details_widgets, lengthof(_nested_nontrain_vehicle_details_widgets)) [static]

Vehicle details window descriptor for other vehicles than a train.

Referenced by ShowVehicleDetailsWindow().

const WindowDesc _train_vehicle_details_desc(WDP_AUTO, 405, 178, WC_VEHICLE_DETAILS, WC_VEHICLE_VIEW, WDF_UNCLICK_BUTTONS, _nested_train_vehicle_details_widgets, lengthof(_nested_train_vehicle_details_widgets)) [static]

Vehicle details window descriptor.

Referenced by ShowVehicleDetailsWindow().

const WindowDesc _train_view_desc(WDP_AUTO, 250, 134, WC_VEHICLE_VIEW, WC_NONE, WDF_UNCLICK_BUTTONS, _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.

Referenced by ShowVehicleViewWindow().

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  
  },
}

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

Definition at line 2210 of file vehicle_gui.cpp.

const WindowDesc _vehicle_view_desc(WDP_AUTO, 250, 116, WC_VEHICLE_VIEW, WC_NONE, WDF_UNCLICK_BUTTONS, _nested_vehicle_view_widgets, lengthof(_nested_vehicle_view_widgets)) [static]

Vehicle view window descriptor for all vehicles but trains.

Referenced by ShowVehicleViewWindow().

Initial value:
 {
  ZOOM_LVL_TRAIN,
  ZOOM_LVL_ROADVEH,
  ZOOM_LVL_SHIP,
  ZOOM_LVL_AIRCRAFT,
}

Zoom levels for vehicle views indexed by vehicle type.

Definition at line 2190 of file vehicle_gui.cpp.

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 210 of file vehicle_gui.cpp.