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 "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  VehicleRefitWidgets {
  VRW_CAPTION, VRW_VEHICLE_PANEL_DISPLAY, VRW_SHOW_HSCROLLBAR, VRW_HSCROLLBAR,
  VRW_SELECTHEADER, VRW_MATRIX, VRW_SCROLLBAR, VRW_INFOPANEL,
  VRW_REFITBUTTON
}
 

Widget numbers of the vehicle refit window.

More...
enum  VehicleListWindowWidgets {
  VLW_WIDGET_CAPTION, VLW_WIDGET_SORT_ORDER, VLW_WIDGET_SORT_BY_PULLDOWN, VLW_WIDGET_LIST,
  VLW_WIDGET_SCROLLBAR, VLW_WIDGET_HIDE_BUTTONS, VLW_WIDGET_AVAILABLE_VEHICLES, VLW_WIDGET_MANAGE_VEHICLES_DROPDOWN,
  VLW_WIDGET_STOP_ALL, VLW_WIDGET_START_ALL
}
enum  VehicleDetailsWindowWidgets {
  VLD_WIDGET_CAPTION, VLD_WIDGET_RENAME_VEHICLE, VLD_WIDGET_TOP_DETAILS, VLD_WIDGET_INCREASE_SERVICING_INTERVAL,
  VLD_WIDGET_DECREASE_SERVICING_INTERVAL, VLD_WIDGET_SERVICING_INTERVAL, VLD_WIDGET_MIDDLE_DETAILS, VLD_WIDGET_MATRIX,
  VLD_WIDGET_SCROLLBAR, VLD_WIDGET_DETAILS_CARGO_CARRIED, VLD_WIDGET_DETAILS_TRAIN_VEHICLES, VLD_WIDGET_DETAILS_CAPACITY_OF_EACH,
  VLD_WIDGET_DETAILS_TOTAL_CARGO
}
 

Constants of vehicle details widget indices.


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)
 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)
 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, 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 (VLD_WIDGET_DETAILS_CARGO_CARRIED==VLD_WIDGET_DETAILS_CARGO_CARRIED+TDW_TAB_CARGO)
 assert_compile (VLD_WIDGET_DETAILS_TRAIN_VEHICLES==VLD_WIDGET_DETAILS_CARGO_CARRIED+TDW_TAB_INFO)
 assert_compile (VLD_WIDGET_DETAILS_CAPACITY_OF_EACH==VLD_WIDGET_DETAILS_CARGO_CARRIED+TDW_TAB_CAPACITY)
 assert_compile (VLD_WIDGET_DETAILS_TOTAL_CARGO==VLD_WIDGET_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)
 Get the width of a vehicle (including all parts of the consist) in pixels.
void AddVehicleCargoDestSummary (const Vehicle *v, CargoDestSummary *sum)
 Sum the cargo carried by a vehicle by final destination.

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

Widget numbers of the vehicle refit window.

Definition at line 346 of file vehicle_gui.cpp.


Function Documentation

void AddVehicleCargoDestSummary ( const Vehicle v,
CargoDestSummary sum 
)

Sum the cargo carried by a vehicle by final destination.

Parameters:
v The vehicle.
sum The cargo summary is added to this.

Definition at line 2723 of file vehicle_gui.cpp.

References Vehicle::cargo, CargoPacket::Count(), CargoPacket::DestinationID(), CargoPacket::DestinationType(), INVALID_SOURCE, and CargoList< Tinst >::Packets().

Referenced by DrawTrainDetails(), and GetTrainDetailsWndVScroll().

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 2676 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 2250 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, VS_STOPPED, 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 1141 of file vehicle_gui.cpp.

References ChangeVehicleWindow().

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 1118 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 31 of file aircraft_gui.cpp.

References Vehicle::cargo_cap, DrawString(), FONT_HEIGHT_NORMAL, GetCargoSubtypeText(), SpecializedVehicle< T, Type >::Next(), 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 >::Count(), DrawString(), CargoList< Tinst >::Empty(), Vehicle::engine_type, VehicleCargoList::FeederShare(), FONT_HEIGHT_NORMAL, GetCargoSubtypeText(), Vehicle::HasArticulatedPart(), lastof, Vehicle::Next(), NUM_CARGO, SA_LEFT, SA_STRIP, SetDParam(), CargoList< Tinst >::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 57 of file ship_gui.cpp.

References Vehicle::build_year, Vehicle::cargo, Vehicle::cargo_cap, Vehicle::cargo_type, CargoList< Tinst >::Count(), DrawString(), CargoList< Tinst >::Empty(), Vehicle::engine_type, VehicleCargoList::FeederShare(), FONT_HEIGHT_NORMAL, GetCargoSubtypeText(), SA_LEFT, SA_STRIP, SetDParam(), CargoList< Tinst >::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 
)
void DrawVehicleImage ( const Vehicle v,
int  left,
int  right,
int  y,
VehicleID  selection,
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(), SpecializedVehicle< Train, Type >::From(), 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 191 of file vehicle_gui.cpp.

References Vehicle::age, DAYS_IN_YEAR, DrawSprite(), and Vehicle::GetDisplayProfitLastYear().

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

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

Referenced by RefitWindow::DrawWidget().

byte GetBestFittingSubType ( Vehicle v_from,
Vehicle v_for 
)

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

Assuming they are going to carry the same cargo ofcourse!

Parameters:
v_from the vehicle to match the subtype from
v_for the vehicle to get the subtype for
Returns:
the best sub type

Definition at line 218 of file vehicle_gui.cpp.

References CALLBACK_FAILED, EngineInfo::callback_mask, Engine::CanCarryCargo(), Vehicle::cargo_subtype, Vehicle::cargo_type, CBID_VEHICLE_CARGO_SUFFIX, CBM_VEHICLE_CARGO_SUFFIX, Vehicle::engine_type, Vehicle::First(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_engine_pool >::Get(), GetCargoSubtypeText(), GetVehicleCallback(), HasBit(), and Vehicle::InvalidateNewGRFCache().

Referenced by BuildReplacementVehicle(), and CmdCloneVehicle().

StringID GetCargoSubtypeText ( const Vehicle v  ) 
int GetTrainDetailsWndVScroll ( VehicleID  veh_id,
TrainDetailsWindowTabs  det_tab 
)
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  ) 

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

References _current_text_dir, DIR_E, DIR_W, SpecializedVehicle< RoadVehicle, Type >::From(), SpecializedVehicle< Train, Type >::From(), Train::GetDisplayImageWidth(), Vehicle::GetImage(), SpecializedVehicle< T, Type >::Next(), ST_NORMAL, TD_RTL, BaseVehicle::type, VEH_ROAD, VEH_TRAIN, and Sprite::width.

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

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

Definition at line 914 of file vehicle_gui.cpp.

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

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 2647 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, VLD_WIDGET_CAPTION), SetDataTip(STR_VEHICLE_DETAILS_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
    NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, VLD_WIDGET_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, VLD_WIDGET_TOP_DETAILS), SetMinimalSize(405, 42), SetResize(1, 0), EndContainer(),
  NWidget(WWT_PANEL, COLOUR_GREY, VLD_WIDGET_MIDDLE_DETAILS), SetMinimalSize(405, 45), SetResize(1, 0), EndContainer(),
  NWidget(NWID_HORIZONTAL),
    NWidget(WWT_PUSHARROWBTN, COLOUR_GREY, VLD_WIDGET_DECREASE_SERVICING_INTERVAL), SetFill(0, 1),
        SetDataTip(AWV_DECREASE, STR_VEHICLE_DETAILS_DECREASE_SERVICING_INTERVAL_TOOLTIP),
    NWidget(WWT_PUSHARROWBTN, COLOUR_GREY, VLD_WIDGET_INCREASE_SERVICING_INTERVAL), SetFill(0, 1),
        SetDataTip(AWV_INCREASE, STR_VEHICLE_DETAILS_INCREASE_SERVICING_INTERVAL_TOOLTIP),
    NWidget(WWT_PANEL, COLOUR_GREY, VLD_WIDGET_SERVICING_INTERVAL), SetFill(1, 1), SetResize(1, 0), EndContainer(),
    NWidget(WWT_RESIZEBOX, COLOUR_GREY),
  EndContainer(),
}

Vehicle details widgets (other than train).

Definition at line 1715 of file vehicle_gui.cpp.

Train details widgets.

Definition at line 1736 of file vehicle_gui.cpp.

const NWidgetPart _nested_vehicle_refit_widgets[] [static]
Initial value:
 {
  NWidget(NWID_HORIZONTAL),
    NWidget(WWT_CLOSEBOX, COLOUR_GREY),
    NWidget(WWT_CAPTION, COLOUR_GREY, VRW_CAPTION), SetDataTip(STR_REFIT_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
  EndContainer(),
  
  NWidget(NWID_VERTICAL),
    NWidget(WWT_PANEL, COLOUR_GREY, VRW_VEHICLE_PANEL_DISPLAY), SetMinimalSize(228, 14), SetResize(1, 0), SetScrollbar(VRW_HSCROLLBAR), EndContainer(),
    NWidget(NWID_SELECTION, INVALID_COLOUR, VRW_SHOW_HSCROLLBAR),
      NWidget(NWID_HSCROLLBAR, COLOUR_GREY, VRW_HSCROLLBAR),
    EndContainer(),
  EndContainer(),
  NWidget(WWT_TEXTBTN, COLOUR_GREY, VRW_SELECTHEADER), SetDataTip(STR_REFIT_TITLE, STR_NULL), SetResize(1, 0),
  
  NWidget(NWID_HORIZONTAL),
    NWidget(WWT_MATRIX, COLOUR_GREY, VRW_MATRIX), SetMinimalSize(228, 112), SetResize(1, 14), SetFill(1, 1), SetDataTip(0x801, STR_NULL), SetScrollbar(VRW_SCROLLBAR),
    NWidget(NWID_VSCROLLBAR, COLOUR_GREY, VRW_SCROLLBAR),
  EndContainer(),
  NWidget(WWT_PANEL, COLOUR_GREY, VRW_INFOPANEL), SetMinimalTextLines(2, WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM), SetResize(1, 0), EndContainer(),
  NWidget(NWID_HORIZONTAL),
    NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, VRW_REFITBUTTON), SetFill(1, 0), SetResize(1, 0),
    NWidget(WWT_RESIZEBOX, COLOUR_GREY),
  EndContainer(),
}

Definition at line 876 of file vehicle_gui.cpp.

Vehicle view widgets.

Definition at line 2135 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 2222 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 levels for vehicle views indexed by vehicle type.

Definition at line 2202 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 209 of file vehicle_gui.cpp.


Generated on Sun May 8 07:30:46 2011 for OpenTTD by  doxygen 1.6.1