OpenTTD Source 20241224-master-gf74b0cf984
|
Functions related to the vehicle's GUIs. More...
#include "window_type.h"
#include "vehicle_type.h"
#include "vehicle_gui_base.h"
#include "vehiclelist.h"
#include "order_type.h"
#include "station_type.h"
#include "engine_type.h"
#include "company_type.h"
Go to the source code of this file.
Data Structures | |
struct | TestedEngineDetails |
Extra information about refitted cargo and capacity. More... | |
struct | VehicleCellSize |
Dimensions of a cell in the purchase/depot windows. More... | |
Enumerations | |
enum | TrainDetailsWindowTabs : uint8_t { TDW_TAB_CARGO = 0 , TDW_TAB_INFO , TDW_TAB_CAPACITY , TDW_TAB_TOTALS } |
The tabs in the train details window. More... | |
enum | VehicleInvalidateWindowData { VIWD_REMOVE_ALL_ORDERS = -1 , VIWD_MODIFY_ORDERS = -2 , VIWD_CONSIST_CHANGED = -3 , VIWD_AUTOREPLACE = -4 } |
Special values for vehicle-related windows for the data parameter of InvalidateWindowData. More... | |
Functions | |
void | ShowVehicleRefitWindow (const Vehicle *v, VehicleOrderID order, Window *parent, bool auto_refit=false) |
Show the refit window for a vehicle. | |
int | DrawVehiclePurchaseInfo (int left, int right, int y, EngineID engine_number, TestedEngineDetails &te) |
Draw the purchase info details of a vehicle at a given location. | |
void | DrawTrainImage (const Train *v, const Rect &r, VehicleID selection, EngineImageType image_type, int skip, VehicleID drag_dest=INVALID_VEHICLE) |
Draws an image of a whole train. | |
void | DrawRoadVehImage (const Vehicle *v, const Rect &r, VehicleID selection, EngineImageType image_type, int skip=0) |
Draws an image of a road vehicle chain. | |
void | DrawShipImage (const Vehicle *v, const Rect &r, VehicleID selection, EngineImageType image_type) |
Draws an image of a ship. | |
void | DrawAircraftImage (const Vehicle *v, const Rect &r, VehicleID selection, EngineImageType image_type) |
Draws an image of an aircraft. | |
void | ShowBuildVehicleWindow (TileIndex tile, VehicleType type) |
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. | |
void | ShowVehicleListWindow (const Vehicle *v) |
void | ShowVehicleListWindow (CompanyID company, VehicleType vehicle_type) |
void | ShowVehicleListWindow (CompanyID company, VehicleType vehicle_type, StationID station) |
void | ShowVehicleListWindow (CompanyID company, VehicleType vehicle_type, TileIndex depot_tile) |
uint | GetVehicleHeight (VehicleType type) |
Get the height of a single vehicle in the GUIs. | |
int | GetSingleVehicleWidth (const Vehicle *v, EngineImageType image_type) |
Get the width of a vehicle (part) in pixels. | |
int | GetVehicleWidth (const Vehicle *v, EngineImageType image_type) |
Get the width of a vehicle (including all parts of the consist) in pixels. | |
VehicleCellSize | GetVehicleImageCellSize (VehicleType type, EngineImageType image_type) |
Get the GUI cell size for a vehicle image. | |
WindowClass | GetWindowClassForVehicleType (VehicleType vt) |
Get WindowClass for vehicle list of given vehicle type. | |
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. | |
bool | VehicleClicked (VehicleList::const_iterator begin, VehicleList::const_iterator end) |
Dispatch a "vehicle group selected" event if any window waits for it. | |
bool | VehicleClicked (const GUIVehicleGroup &vehgroup) |
Dispatch a "vehicle group selected" event if any window waits for it. | |
void | StartStopVehicle (const Vehicle *v, bool texteffect) |
Executes CMD_START_STOP_VEHICLE for given vehicle. | |
Vehicle * | CheckClickOnVehicle (const struct Viewport *vp, int x, int y) |
void | StopGlobalFollowVehicle (const Vehicle *v) |
void | DrawVehicleImage (const Vehicle *v, const Rect &r, VehicleID selection, EngineImageType image_type, int skip) |
Draws an image of a vehicle chain. | |
void | SetMouseCursorVehicle (const Vehicle *v, EngineImageType image_type) |
Set the mouse cursor to look like a vehicle. | |
Functions related to the vehicle's GUIs.
Definition in file vehicle_gui.h.
enum TrainDetailsWindowTabs : uint8_t |
The tabs in the train details window.
Definition at line 25 of file vehicle_gui.h.
Special values for vehicle-related windows for the data parameter of InvalidateWindowData.
Enumerator | |
---|---|
VIWD_REMOVE_ALL_ORDERS | Removed / replaced all orders (after deleting / sharing). |
VIWD_MODIFY_ORDERS | Other order modifications. |
VIWD_CONSIST_CHANGED | Vehicle composition was changed. |
VIWD_AUTOREPLACE | Autoreplace replaced the vehicle. |
Definition at line 34 of file vehicle_gui.h.
void DrawAircraftImage | ( | const Vehicle * | v, |
const Rect & | r, | ||
VehicleID | selection, | ||
EngineImageType | image_type | ||
) |
Draws an image of an aircraft.
v | Front vehicle |
r | Rect to draw at |
selection | Selected vehicle to draw a frame around |
Definition at line 79 of file aircraft_gui.cpp.
References _current_text_dir, AIR_HELICOPTER, WidgetDimensions::bevel, Vehicle::cargo_cap, Vehicle::cargo_type, CenterBounds(), DIR_E, DIR_W, VehicleSpriteSeq::Draw(), DrawCargoIconOverlay(), DrawFrameRect(), Rect::Expand(), FR_BORDERONLY, SpecializedVehicle< Aircraft, VEH_AIRCRAFT >::From(), VehicleSpriteSeq::GetBounds(), Vehicle::GetImage(), GetLargestCargoIconSize(), GetVehiclePalette(), Rect::Height(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem< Tpool >::index, VehicleSpriteSeq::IsValid(), Vehicle::Next(), PALETTE_CRASH, WidgetDimensions::scaled, ScaleSpriteTrad(), VehicleSpriteSeq::Set(), Vehicle::subtype, TD_RTL, UnScaleGUI(), Vehicle::vehstatus, VS_CRASHED, and Rect::Width().
Referenced by DrawVehicleImage(), and DepotWindow::DrawVehicleInDepot().
void DrawRoadVehImage | ( | const Vehicle * | v, |
const Rect & | r, | ||
VehicleID | selection, | ||
EngineImageType | image_type, | ||
int | skip | ||
) |
Draws an image of a road vehicle chain.
v | Front vehicle |
r | Rect to draw at |
selection | Selected vehicle to draw a frame around |
skip | Number of pixels to skip at the front (for scrolling) |
Definition at line 123 of file roadveh_gui.cpp.
References _current_text_dir, AddCargoIconOverlay(), WidgetDimensions::bevel, CenterBounds(), DIR_E, DIR_W, VehicleSpriteSeq::Draw(), DrawCargoIconOverlays(), DrawFrameRect(), Rect::Expand(), FillDrawPixelInfo(), FR_BORDERONLY, SpecializedVehicle< T, Type >::From(), RoadVehicle::GetDisplayImageWidth(), RoadVehicle::GetImage(), GetVehiclePalette(), Rect::Height(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem< Tpool >::index, SpecializedVehicle< T, Type >::Next(), PALETTE_CRASH, WidgetDimensions::scaled, ScaleSpriteTrad(), ShowCargoIconOverlay(), TD_RTL, Rect::Translate(), Vehicle::vehstatus, VS_CRASHED, and Rect::Width().
Referenced by DrawVehicleImage(), and DepotWindow::DrawVehicleInDepot().
void DrawShipImage | ( | const Vehicle * | v, |
const Rect & | r, | ||
VehicleID | selection, | ||
EngineImageType | image_type | ||
) |
Draws an image of a ship.
v | Front vehicle |
r | Rect to draw at |
selection | Selected vehicle to draw a frame around |
Definition at line 30 of file ship_gui.cpp.
References _current_text_dir, WidgetDimensions::bevel, Vehicle::cargo_cap, Vehicle::cargo_type, CenterBounds(), DIR_E, DIR_W, VehicleSpriteSeq::Draw(), DrawCargoIconOverlay(), DrawFrameRect(), Rect::Expand(), FR_BORDERONLY, VehicleSpriteSeq::GetBounds(), Vehicle::GetImage(), GetVehiclePalette(), Rect::Height(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem< Tpool >::index, WidgetDimensions::scaled, ScaleSpriteTrad(), TD_RTL, UnScaleGUI(), and Rect::Width().
Referenced by DrawVehicleImage(), and DepotWindow::DrawVehicleInDepot().
void DrawTrainImage | ( | const Train * | v, |
const Rect & | r, | ||
VehicleID | selection, | ||
EngineImageType | image_type, | ||
int | skip, | ||
VehicleID | drag_dest | ||
) |
Draws an image of a whole train.
v | Front vehicle |
r | Rect to draw at |
selection | Selected vehicle to draw a frame around |
skip | Number of pixels to skip at the front (for scrolling) |
drag_dest | The vehicle another one is dragged over, INVALID_VEHICLE if none. |
Definition at line 93 of file train_gui.cpp.
References _current_text_dir, AddCargoIconOverlay(), WidgetDimensions::bevel, CenterBounds(), DIR_E, DIR_W, VehicleSpriteSeq::Draw(), DrawCargoIconOverlays(), DrawFrameRect(), Rect::Expand(), FillDrawPixelInfo(), FR_BORDERONLY, SpecializedVehicle< T, Type >::From(), Train::GetImage(), GetVehiclePalette(), Rect::Height(), HighlightDragPosition(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem< Tpool >::index, INVALID_VEHICLE, Vehicle::IsArticulatedPart(), SpecializedVehicle< T, Type >::Next(), PALETTE_CRASH, WidgetDimensions::scaled, ScaleSpriteTrad(), ShowCargoIconOverlay(), TD_RTL, Rect::Translate(), CursorVars::vehchain, Vehicle::vehstatus, VS_CRASHED, and Rect::Width().
Referenced by DrawVehicleImage(), and DepotWindow::DrawVehicleInDepot().
void DrawVehicleImage | ( | const Vehicle * | v, |
const Rect & | r, | ||
VehicleID | selection, | ||
EngineImageType | image_type, | ||
int | skip | ||
) |
Draws an image of a vehicle chain.
v | Front vehicle |
r | Rect to draw at |
selection | Selected vehicle to draw a frame around |
skip | Number of pixels to skip at the front (for scrolling) |
Definition at line 1734 of file vehicle_gui.cpp.
References DrawAircraftImage(), DrawRoadVehImage(), DrawShipImage(), DrawTrainImage(), SpecializedVehicle< T, Type >::From(), BaseVehicle::type, VEH_AIRCRAFT, VEH_ROAD, VEH_SHIP, and VEH_TRAIN.
Referenced by NewGRFInspectWindow::DrawVehicleChainWidget(), BaseVehicleListWindow::DrawVehicleListItems(), RefitWindow::DrawWidget(), and VehicleDetailsWindow::DrawWidget().
int DrawVehiclePurchaseInfo | ( | int | left, |
int | right, | ||
int | y, | ||
EngineID | engine_number, | ||
TestedEngineDetails & | te | ||
) |
Draw the purchase info details of a vehicle at a given location.
left,right,y | location where to draw the info |
engine_number | the engine of which to draw the info of |
Definition at line 917 of file build_vehicle_gui.cpp.
References _settings_client, TimerGameCalendar::ConvertDateToYMD(), TimerGame< struct Calendar >::DateToYear(), DrawAircraftPurchaseInfo(), DrawString(), FS_NORMAL, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_engine_pool >::Get(), GetCharacterHeight(), GetGRFConfig(), Engine::GetGRFID(), Engine::GetLifeLengthInDays(), GRFConfig::GetName(), ClientSettings::gui, Engine::intro_date, IsArticulatedVehicleRefittable(), RAILVEH_WAGON, Engine::reliability, SetDParam(), GUISettings::show_newgrf_name, ShowAdditionalText(), ShowRefitOptionsList(), ToPercent16(), Engine::type, VEH_AIRCRAFT, VEH_ROAD, VEH_SHIP, and VEH_TRAIN.
Referenced by ReplaceVehicleWindow::OnPaint(), and BuildVehicleWindow::OnPaint().
Get the cargo subtype text from NewGRF for the vehicle details window.
Definition at line 1406 of file vehicle_gui.cpp.
References CALLBACK_FAILED, EngineInfo::callback_mask, CBID_VEHICLE_CARGO_SUFFIX, CBM_VEHICLE_CARGO_SUFFIX, Vehicle::engine_type, ErrorUnknownCallbackResult(), Vehicle::GetGRF(), Vehicle::GetGRFID(), GetGRFStringID(), GetVehicleCallback(), and HasBit().
Referenced by RefitWindow::BuildRefitList(), DrawAircraftDetails(), DrawRoadVehDetails(), DrawShipDetails(), GetBestFittingSubType(), and GetCargoSummaryOfArticulatedVehicle().
int GetSingleVehicleWidth | ( | const Vehicle * | v, |
EngineImageType | image_type | ||
) |
Get the width of a vehicle (part) in pixels.
v | Vehicle to get the width for. |
Definition at line 3580 of file vehicle_gui.cpp.
References _current_text_dir, DIR_E, DIR_W, SpecializedVehicle< T, Type >::From(), VehicleSpriteSeq::GetBounds(), Vehicle::GetImage(), TD_RTL, BaseVehicle::type, UnScaleGUI(), VEH_ROAD, VEH_TRAIN, and Rect::Width().
Referenced by VehicleDetailsWindow::DrawWidget(), GetVehicleWidth(), and SetMouseCursorVehicle().
|
inline |
Get the height of a single vehicle in the GUIs.
type | the vehicle type to look at |
Definition at line 74 of file vehicle_gui.h.
References VEH_ROAD, and VEH_TRAIN.
Referenced by VehicleDetailsWindow::DrawWidget(), GetVehicleListHeight(), and RefitWindow::UpdateWidgetSize().
VehicleCellSize GetVehicleImageCellSize | ( | VehicleType | type, |
EngineImageType | image_type | ||
) |
Get the GUI cell size for a vehicle image.
type | Vehicle type to get the size for. |
image_type | Image type to get size for. |
Definition at line 161 of file depot_gui.cpp.
References _base_block_sizes_depot, _base_block_sizes_purchase, EIT_IN_DEPOT, and EIT_PURCHASE.
Referenced by DrawEngineList(), NewGRFInspectWindow::DrawVehicleChainWidget(), GetEngineListHeight(), DepotWindow::OnInit(), BuildVehicleWindow::UpdateWidgetSize(), and NewGRFInspectWindow::UpdateWidgetSize().
int GetVehicleWidth | ( | const Vehicle * | v, |
EngineImageType | image_type | ||
) |
Get the width of a vehicle (including all parts of the consist) in pixels.
v | Vehicle to get the width for. |
Definition at line 3604 of file vehicle_gui.cpp.
References GetSingleVehicleWidth(), SpecializedVehicle< T, Type >::Next(), BaseVehicle::type, VEH_ROAD, and VEH_TRAIN.
Referenced by RefitWindow::OnInvalidateData(), and RefitWindow::OnResize().
|
inline |
Get WindowClass for vehicle list of given vehicle type.
vt | vehicle type to check |
Definition at line 97 of file vehicle_gui.h.
References VEH_AIRCRAFT, VEH_ROAD, VEH_SHIP, VEH_TRAIN, WC_AIRCRAFT_LIST, WC_ROADVEH_LIST, WC_SHIPS_LIST, and WC_TRAINS_LIST.
Referenced by Vehicle::BeginLoading(), DepotWindow::Close(), WaypointWindow::Close(), CmdAddSharedVehicleGroup(), CmdAddVehicleGroup(), CmdAlterGroup(), CmdBuildVehicle(), CmdCloneOrder(), CmdCreateGroup(), CmdDeleteGroup(), CmdMoveOrder(), CmdRefitVehicle(), CmdRemoveAllVehiclesGroup(), CmdRenameDepot(), CmdRenameVehicle(), CmdSetAutoReplace(), CmdSetGroupFlag(), CmdStartStopVehicle(), Vehicle::Crash(), DecloneOrder(), DeleteOrder(), FindVehicleGroupWindow(), Vehicle::HandlePathfindingResult(), InsertOrder(), LoadUnloadVehicle(), Vehicle::PreDestructor(), ProcessOrders(), Vehicle::RemoveFromShared(), ShowCompanyGroup(), and Depot::~Depot().
void SetMouseCursorVehicle | ( | const Vehicle * | v, |
EngineImageType | image_type | ||
) |
Set the mouse cursor to look like a vehicle.
v | Vehicle |
image_type | Type of vehicle image to use. |
Definition at line 3622 of file vehicle_gui.cpp.
References _current_text_dir, AIR_HELICOPTER, DIR_E, DIR_W, SpecializedVehicle< Aircraft, VEH_AIRCRAFT >::From(), SpecializedVehicle< T, Type >::From(), Vehicle::GetImage(), Vehicle::GetNextArticulatedPart(), GetSingleVehicleWidth(), GetVehiclePalette(), Vehicle::HasArticulatedPart(), Vehicle::IsGroundVehicle(), VehicleSpriteSeq::IsValid(), PalSpriteID::pal, PALETTE_CRASH, ScaleSpriteTrad(), VehicleSpriteSeq::Set(), PalSpriteID::sprite, CursorVars::sprites, Vehicle::subtype, TD_RTL, BaseVehicle::type, UpdateCursorSize(), VEH_AIRCRAFT, VEH_TRAIN, Vehicle::vehstatus, and VS_CRASHED.
Referenced by DepotWindow::DepotClick(), and VehicleGroupWindow::OnClick().
void ShowBuildVehicleWindow | ( | TileIndex | tile, |
VehicleType | type | ||
) |
Definition at line 1933 of file build_vehicle_gui.cpp.
uint ShowRefitOptionsList | ( | int | left, |
int | right, | ||
int | y, | ||
EngineID | engine | ||
) |
Display list of cargo types of the engine, for the purchase information window.
Definition at line 1377 of file vehicle_gui.cpp.
References _cargo_mask, CountBits(), DrawStringMultiLine(), GetUnionOfArticulatedRefitMasks(), HasAtMostOneBit(), and SetDParam().
Referenced by DrawVehiclePurchaseInfo().
void ShowVehicleListWindow | ( | CompanyID | company, |
VehicleType | vehicle_type | ||
) |
Definition at line 2331 of file vehicle_gui.cpp.
void ShowVehicleListWindow | ( | CompanyID | company, |
VehicleType | vehicle_type, | ||
StationID | station | ||
) |
Definition at line 2350 of file vehicle_gui.cpp.
void ShowVehicleListWindow | ( | CompanyID | company, |
VehicleType | vehicle_type, | ||
TileIndex | depot_tile | ||
) |
Definition at line 2355 of file vehicle_gui.cpp.
void ShowVehicleListWindow | ( | const Vehicle * | v | ) |
Definition at line 2345 of file vehicle_gui.cpp.
void ShowVehicleRefitWindow | ( | const Vehicle * | v, |
VehicleOrderID | order, | ||
Window * | parent, | ||
bool | auto_refit | ||
) |
Show the refit window for a vehicle.
*v | The vehicle to show the refit window for |
order | of the vehicle to assign refit to, or INVALID_VEH_ORDER_ID to refit the vehicle now |
parent | the parent window of the refit window |
auto_refit | Choose cargo for auto-refitting |
Definition at line 1369 of file vehicle_gui.cpp.
References CloseWindowById(), 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 | ) |
Shows the vehicle view window of the given vehicle.
Definition at line 3504 of file vehicle_gui.cpp.
References _train_view_desc, _vehicle_view_desc, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem< Tpool >::index, BaseVehicle::type, and VEH_TRAIN.
Referenced by CcBuildPrimaryVehicle(), CcCloneVehicle(), DepotWindow::DepotClick(), NewsWindow::OnClick(), VehicleListWindow::OnClick(), and DepotWindow::OnDragDrop().
void StartStopVehicle | ( | const Vehicle * | v, |
bool | texteffect | ||
) |
Executes CMD_START_STOP_VEHICLE for given vehicle.
v | Vehicle to start/stop |
texteffect | Should a texteffect be shown? |
Definition at line 3003 of file vehicle_gui.cpp.
References _vehicle_msg_translation_table, CcStartStopVehicle(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem< Tpool >::index, Vehicle::IsPrimaryVehicle(), Vehicle::tile, and BaseVehicle::type.
Referenced by DepotWindow::DepotClick(), and VehicleViewWindow::OnClick().
void StopGlobalFollowVehicle | ( | const Vehicle * | v | ) |
Definition at line 3552 of file vehicle_gui.cpp.
bool VehicleClicked | ( | const GUIVehicleGroup & | vehgroup | ) |
Dispatch a "vehicle group selected" event if any window waits for it.
vehgroup | the GUIVehicleGroup representing the vehicle group |
Definition at line 3547 of file vehicle_gui.cpp.
References VehicleClicked(), GUIVehicleGroup::vehicles_begin, and GUIVehicleGroup::vehicles_end.
bool VehicleClicked | ( | const Vehicle * | v | ) |
Dispatch a "vehicle selected" event if any window waits for it.
v | selected vehicle; |
Definition at line 3514 of file vehicle_gui.cpp.
References Vehicle::First(), TileHighlightData::GetCallbackWnd(), HT_VEHICLE, Vehicle::IsPrimaryVehicle(), Window::OnVehicleSelect(), and TileHighlightData::place_mode.
Referenced by DepotWindow::DepotClick(), VehicleGroupWindow::OnClick(), VehicleListWindow::OnClick(), and VehicleClicked().
bool VehicleClicked | ( | VehicleList::const_iterator | begin, |
VehicleList::const_iterator | end | ||
) |
Dispatch a "vehicle group selected" event if any window waits for it.
begin | iterator to the start of the range of vehicles |
end | iterator to the end of the range of vehicles |
Definition at line 3531 of file vehicle_gui.cpp.
References TileHighlightData::GetCallbackWnd(), HT_VEHICLE, Window::OnVehicleSelect(), and TileHighlightData::place_mode.