OpenTTD Source 20241224-master-gf74b0cf984
|
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 "dropdown_type.h"
#include "dropdown_func.h"
#include "timetable.h"
#include "articulated_vehicles.h"
#include "spritecache.h"
#include "core/geometry_func.hpp"
#include "core/container_func.hpp"
#include "company_base.h"
#include "engine_func.h"
#include "station_base.h"
#include "tilehighlight_func.h"
#include "zoom_func.h"
#include "depot_cmd.h"
#include "vehicle_cmd.h"
#include "order_cmd.h"
#include "roadveh_cmd.h"
#include "train_cmd.h"
#include "hotkeys.h"
#include "group_cmd.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 | |
using | RefitOptions = std::map< CargoID, std::vector< RefitOption >, CargoIDComparator > |
Available refit options (subtype and string) associated with each cargo type. | |
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 | |
template<BaseVehicleListWindow::VehicleIndividualSortFunction func> | |
static bool | VehicleIndividualToGroupSorterWrapper (GUIVehicleGroup const &a, GUIVehicleGroup const &b) |
Wrapper to convert a VehicleIndividualSortFunction to a VehicleGroupSortFunction. | |
uint | CountDigitsForAllocatingSpace (uint number) |
Get the number of digits of space required for the given number. | |
uint | GetUnitNumberDigits (VehicleList &vehicles) |
Get the number of digits the biggest unit number of a set of vehicles has. | |
static bool | CargoFilterSingle (const Vehicle *v, const CargoID cid) |
Check whether a single vehicle should pass the filter. | |
static bool | CargoFilter (const GUIVehicleGroup *vehgroup, const CargoID cid) |
Check whether a vehicle can carry a specific cargo. | |
bool | ShowCargoIconOverlay () |
Test if cargo icon overlays should be drawn. | |
void | AddCargoIconOverlay (std::vector< CargoIconOverlay > &overlays, int x, int width, const Vehicle *v) |
Add a cargo icon to the list of overlays. | |
void | DrawCargoIconOverlay (int x, int y, CargoID cid) |
Draw a cargo icon overlaying an existing sprite, with a black contrast outline. | |
void | DrawCargoIconOverlays (std::span< const CargoIconOverlay > overlays, int y) |
Draw a list of cargo icon overlays. | |
void | DepotSortList (VehicleList *list) |
static void | DrawVehicleProfitButton (TimerGameEconomy::Date age, Money display_profit_last_year, uint num_vehicles, int x, int y) |
draw the vehicle profit button in the vehicle list window. | |
uint8_t | 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 RefitOptions &refits, const RefitOption *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 bool | VehicleGroupLengthSorter (const GUIVehicleGroup &a, const GUIVehicleGroup &b) |
Sort vehicle groups by the number of vehicles in the group. | |
static bool | VehicleGroupTotalProfitThisYearSorter (const GUIVehicleGroup &a, const GUIVehicleGroup &b) |
Sort vehicle groups by the total profit this year. | |
static bool | VehicleGroupTotalProfitLastYearSorter (const GUIVehicleGroup &a, const GUIVehicleGroup &b) |
Sort vehicle groups by the total profit last year. | |
static bool | VehicleGroupAverageProfitThisYearSorter (const GUIVehicleGroup &a, const GUIVehicleGroup &b) |
Sort vehicle groups by the average profit this year. | |
static bool | VehicleGroupAverageProfitLastYearSorter (const GUIVehicleGroup &a, const GUIVehicleGroup &b) |
Sort vehicle groups by the average profit last year. | |
static bool | VehicleNumberSorter (const Vehicle *const &a, const Vehicle *const &b) |
Sort vehicles by their number. | |
static bool | VehicleNameSorter (const Vehicle *const &a, const Vehicle *const &b) |
Sort vehicles by their name. | |
static bool | VehicleAgeSorter (const Vehicle *const &a, const Vehicle *const &b) |
Sort vehicles by their age. | |
static bool | VehicleProfitThisYearSorter (const Vehicle *const &a, const Vehicle *const &b) |
Sort vehicles by this year profit. | |
static bool | VehicleProfitLastYearSorter (const Vehicle *const &a, const Vehicle *const &b) |
Sort vehicles by last year profit. | |
static bool | VehicleCargoSorter (const Vehicle *const &a, const Vehicle *const &b) |
Sort vehicles by their cargo. | |
static bool | VehicleReliabilitySorter (const Vehicle *const &a, const Vehicle *const &b) |
Sort vehicles by their reliability. | |
static bool | VehicleMaxSpeedSorter (const Vehicle *const &a, const Vehicle *const &b) |
Sort vehicles by their max speed. | |
static bool | VehicleModelSorter (const Vehicle *const &a, const Vehicle *const &b) |
Sort vehicles by model. | |
static bool | VehicleValueSorter (const Vehicle *const &a, const Vehicle *const &b) |
Sort vehicles by their value. | |
static bool | VehicleLengthSorter (const Vehicle *const &a, const Vehicle *const &b) |
Sort vehicles by their length. | |
static bool | VehicleTimeToLiveSorter (const Vehicle *const &a, const Vehicle *const &b) |
Sort vehicles by the time they can still live. | |
static bool | 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, uint order_arrow_width, VehicleOrderID start) |
static void | DrawSmallOrderList (const Order *order, int left, int right, int y, uint order_arrow_width) |
Draw small order list in the vehicle GUI, but without the little black arrow. | |
void | DrawVehicleImage (const Vehicle *v, const Rect &r, 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 int | GetUnitNumberWidth (int digits) |
Get width required for the formatted unit number display. | |
static void | ShowVehicleListWindowLocal (CompanyID company, VehicleListType vlt, VehicleType vehicle_type, uint32_t 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) |
int | GetTrainDetailsWndVScroll (VehicleID veh_id, TrainDetailsWindowTabs det_tab) |
Determines the number of lines in the train details window. | |
void | DrawTrainDetails (const Train *v, const Rect &r, int vscroll_pos, uint16_t vscroll_cap, TrainDetailsWindowTabs det_tab) |
Draw the details for the given vehicle at the given position. | |
void | DrawRoadVehDetails (const Vehicle *v, const Rect &r) |
Draw the details for the given vehicle at the given position. | |
void | DrawShipDetails (const Vehicle *v, const Rect &r) |
Draw the details for the given vehicle at the given position. | |
void | DrawAircraftDetails (const Aircraft *v, const Rect &r) |
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. | |
void | CcStartStopVehicle (Commands, const CommandCost &result, VehicleID veh_id, bool) |
This is the Callback method after attempting to start/stop 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. | |
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 | StopGlobalFollowVehicle (const Vehicle *v) |
void | CcBuildPrimaryVehicle (Commands, const CommandCost &result, VehicleID new_veh_id, uint, uint16_t, CargoArray) |
This is the Callback method after the construction attempt of a primary vehicle. | |
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. | |
void | SetMouseCursorVehicle (const Vehicle *v, EngineImageType image_type) |
Set the mouse cursor to look like a vehicle. | |
Variables | |
BaseVehicleListWindow::GroupBy | _grouping [VLT_END][VEH_COMPANY_END] |
Sorting | _sorting [BaseVehicleListWindow::GB_END] |
static BaseVehicleListWindow::VehicleIndividualSortFunction | VehicleNumberSorter |
static BaseVehicleListWindow::VehicleIndividualSortFunction | VehicleNameSorter |
static BaseVehicleListWindow::VehicleIndividualSortFunction | VehicleAgeSorter |
static BaseVehicleListWindow::VehicleIndividualSortFunction | VehicleProfitThisYearSorter |
static BaseVehicleListWindow::VehicleIndividualSortFunction | VehicleProfitLastYearSorter |
static BaseVehicleListWindow::VehicleIndividualSortFunction | VehicleCargoSorter |
static BaseVehicleListWindow::VehicleIndividualSortFunction | VehicleReliabilitySorter |
static BaseVehicleListWindow::VehicleIndividualSortFunction | VehicleMaxSpeedSorter |
static BaseVehicleListWindow::VehicleIndividualSortFunction | VehicleModelSorter |
static BaseVehicleListWindow::VehicleIndividualSortFunction | VehicleValueSorter |
static BaseVehicleListWindow::VehicleIndividualSortFunction | VehicleLengthSorter |
static BaseVehicleListWindow::VehicleIndividualSortFunction | VehicleTimeToLiveSorter |
static BaseVehicleListWindow::VehicleIndividualSortFunction | VehicleTimetableDelaySorter |
static BaseVehicleListWindow::VehicleGroupSortFunction | VehicleGroupLengthSorter |
static BaseVehicleListWindow::VehicleGroupSortFunction | VehicleGroupTotalProfitThisYearSorter |
static BaseVehicleListWindow::VehicleGroupSortFunction | VehicleGroupTotalProfitLastYearSorter |
static BaseVehicleListWindow::VehicleGroupSortFunction | VehicleGroupAverageProfitThisYearSorter |
static BaseVehicleListWindow::VehicleGroupSortFunction | VehicleGroupAverageProfitLastYearSorter |
static GUIVehicleGroupList::FilterFunction *const | _vehicle_group_filter_funcs [] |
static const Vehicle * | _last_vehicle [2] = { nullptr, nullptr } |
static const uint | MAX_REFIT_CYCLE = 256 |
Maximum number of refit cycles we try, to prevent infinite loops. | |
static constexpr 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) |
static constexpr NWidgetPart | _nested_vehicle_list [] |
static WindowDesc | _vehicle_list_other_desc (WDP_AUTO, "list_vehicles", 260, 246, WC_INVALID, WC_NONE, 0, _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) |
static constexpr NWidgetPart | _nested_nontrain_vehicle_details_widgets [] |
Vehicle details widgets (other than train). | |
static constexpr NWidgetPart | _nested_train_vehicle_details_widgets [] |
Train details widgets. | |
static StringID | _service_interval_dropdown_calendar [] |
static StringID | _service_interval_dropdown_wallclock [] |
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) |
Vehicle details window descriptor. | |
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) |
Vehicle details window descriptor for other vehicles than a train. | |
static constexpr NWidgetPart | _nested_vehicle_view_widgets [] |
Vehicle view widgets. | |
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 StringID | _vehicle_msg_translation_table [][4] |
Command codes for the shared buttons indexed by VehicleCommandTranslation and vehicle type. | |
static WindowDesc | _vehicle_view_desc (WDP_AUTO, "view_vehicle", 250, 116, WC_VEHICLE_VIEW, WC_NONE, 0, _nested_vehicle_view_widgets, &VehicleViewWindow::hotkeys) |
Vehicle view window descriptor for all vehicles but trains. | |
static WindowDesc | _train_view_desc (WDP_AUTO, "view_vehicle_train", 250, 134, WC_VEHICLE_VIEW, WC_NONE, 0, _nested_vehicle_view_widgets, &VehicleViewWindow::hotkeys) |
Vehicle view window descriptor for trains. | |
The base GUI for all vehicles.
Definition in file vehicle_gui.cpp.
using RefitOptions = std::map<CargoID, std::vector<RefitOption>, CargoIDComparator> |
Available refit options (subtype and string) associated with each cargo type.
Definition at line 689 of file vehicle_gui.cpp.
Command indices for the _vehicle_command_translation_table.
Definition at line 2953 of file vehicle_gui.cpp.
void AddCargoIconOverlay | ( | std::vector< CargoIconOverlay > & | overlays, |
int | x, | ||
int | width, | ||
const Vehicle * | v | ||
) |
Add a cargo icon to the list of overlays.
overlays | List of overlays. |
x | Horizontal position. |
width | Width available. |
v | Vehicle to add. |
Definition at line 348 of file vehicle_gui.cpp.
References _current_text_dir, Vehicle::cargo_cap, Vehicle::cargo_type, Vehicle::IsArticulatedPart(), Vehicle::Previous(), and TD_RTL.
Referenced by DrawRoadVehImage(), and DrawTrainImage().
|
static |
Check whether a vehicle can carry a specific cargo.
vehgroup | The vehicle group which contains the vehicle to be checked |
cid | The cargo what we are looking for |
Definition at line 320 of file vehicle_gui.cpp.
References CargoFilterSingle(), GUIVehicleGroup::vehicles_begin, and GUIVehicleGroup::vehicles_end.
Check whether a single vehicle should pass the filter.
v | The vehicle to check. |
cid | The cargo to filter for. |
Definition at line 280 of file vehicle_gui.cpp.
References CC_PASSENGERS, CargoFilterCriteria::CF_ANY, CargoFilterCriteria::CF_FREIGHT, CargoFilterCriteria::CF_NONE, IsCargoInClass(), and Vehicle::Next().
Referenced by CargoFilter().
void CcBuildPrimaryVehicle | ( | Commands | cmd, |
const CommandCost & | result, | ||
VehicleID | new_veh_id, | ||
uint | , | ||
uint16_t | , | ||
CargoArray | |||
) |
This is the Callback method after the construction attempt of a primary vehicle.
result | indicates completion (or not) of the operation |
new_veh_id | ID of the new vehicle. |
Definition at line 3567 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().
void CcStartStopVehicle | ( | Commands | cmd, |
const CommandCost & | result, | ||
VehicleID | veh_id, | ||
bool | |||
) |
This is the Callback method after attempting to start/stop a vehicle.
result | the result of the start/stop command |
veh_id | Vehicle ID. |
Definition at line 2986 of file vehicle_gui.cpp.
References _local_company, Ticks::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().
Report a change in vehicle IDs (due to autoreplace) to affected vehicle windows.
from_index | the old vehicle ID |
to_index | the new vehicle ID |
Definition at line 1608 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().
|
inlinestatic |
Assign a vehicle window a new vehicle.
window_class | WindowClass to search for |
from_index | the old vehicle ID |
to_index | the new vehicle ID |
Definition at line 1585 of file vehicle_gui.cpp.
References FindWindowById(), ViewportData::follow_vehicle, Window::InvalidateData(), Window::viewport, VIWD_AUTOREPLACE, TileHighlightData::window_class, TileHighlightData::window_number, and Window::window_number.
Referenced by ChangeVehicleViewWindow().
uint CountDigitsForAllocatingSpace | ( | uint | number | ) |
Get the number of digits of space required for the given number.
number | The number. |
Definition at line 189 of file vehicle_gui.cpp.
Referenced by GetUnitNumberDigits().
void DepotSortList | ( | VehicleList * | list | ) |
Definition at line 563 of file vehicle_gui.cpp.
Draw the details for the given vehicle at the given position.
v | current vehicle |
r | the Rect to draw within |
Definition at line 30 of file aircraft_gui.cpp.
References DrawString(), FS_NORMAL, GetCargoSubtypeText(), GetCharacterHeight(), SpecializedVehicle< T, Type >::Next(), PackEngineNameDParam(), WidgetDimensions::scaled, SetDParam(), VehicleDetails, and WidgetDimensions::vsep_normal.
Referenced by VehicleDetailsWindow::DrawVehicleDetails().
void DrawCargoIconOverlay | ( | int | x, |
int | y, | ||
CargoID | cid | ||
) |
Draw a cargo icon overlaying an existing sprite, with a black contrast outline.
x | Horizontal position from left. |
y | Vertical position from top. |
cid | Cargo ID to draw icon for. |
Definition at line 371 of file vehicle_gui.cpp.
References DrawSprite(), CargoSpec::Get(), CargoSpec::GetCargoIcon(), GetSpriteSize(), IsValidCargoID(), PALETTE_ALL_BLACK, ScaleGUITrad(), and ShowCargoIconOverlay().
Referenced by DrawAircraftImage(), DrawCargoIconOverlays(), and DrawShipImage().
void DrawCargoIconOverlays | ( | std::span< const CargoIconOverlay > | overlays, |
int | y | ||
) |
Draw a list of cargo icon overlays.
overlays | List of overlays. |
y | Vertical position. |
Definition at line 400 of file vehicle_gui.cpp.
References DrawCargoIconOverlay().
Referenced by DrawRoadVehImage(), and DrawTrainImage().
Draw the details for the given vehicle at the given position.
v | current vehicle |
r | the Rect to draw within |
Definition at line 29 of file roadveh_gui.cpp.
References _sorted_cargo_specs, AppendStringInPlace(), Vehicle::build_year, Vehicle::cargo, Vehicle::cargo_cap, Vehicle::cargo_type, DrawString(), Vehicle::engine_type, FS_NORMAL, GetCargoSubtypeText(), GetCharacterHeight(), VehicleCargoList::GetFeederShare(), VehicleCargoList::GetFirstStation(), GetListSeparator(), GetString(), Vehicle::HasArticulatedPart(), Vehicle::Next(), PackEngineNameDParam(), WidgetDimensions::scaled, ScaleSpriteTrad(), SetDParam(), VehicleCargoList::StoredCount(), Vehicle::value, VehicleDetails, and WidgetDimensions::vsep_normal.
Referenced by VehicleDetailsWindow::DrawVehicleDetails().
Draw the details for the given vehicle at the given position.
v | current vehicle |
r | the Rect to draw within |
Definition at line 63 of file ship_gui.cpp.
References Vehicle::build_year, Vehicle::cargo, Vehicle::cargo_cap, Vehicle::cargo_type, DrawString(), Vehicle::engine_type, FS_NORMAL, GetCargoSubtypeText(), GetCharacterHeight(), VehicleCargoList::GetFeederShare(), VehicleCargoList::GetFirstStation(), PackEngineNameDParam(), WidgetDimensions::scaled, SetDParam(), VehicleCargoList::StoredCount(), Vehicle::value, VehicleDetails, and WidgetDimensions::vsep_normal.
Referenced by VehicleDetailsWindow::DrawVehicleDetails().
|
static |
Draw small order list in the vehicle GUI, but without the little black arrow.
This is used for shared order groups.
Definition at line 1709 of file vehicle_gui.cpp.
References _current_text_dir, DrawString(), FS_SMALL, GetCharacterHeight(), Order::GetDestination(), Order::IsType(), Order::next, SA_LEFT, SetDParam(), and TD_RTL.
|
static |
Definition at line 1677 of file vehicle_gui.cpp.
|
extern |
Draw the details for the given vehicle at the given position.
v | current vehicle |
r | the Rect to draw within |
vscroll_pos | Position of scrollbar |
vscroll_cap | Number of lines currently displayed |
det_tab | Selected details tab |
Definition at line 362 of file train_gui.cpp.
References _cargo_summary, _current_text_dir, _settings_game, _sorted_cargo_specs, DIR_E, DIR_W, VehicleSpriteSeq::Draw(), DrawString(), EIT_IN_DETAILS, Vehicle::engine_type, VehicleSettings::freight_trains, FreightWagonMult(), FS_NORMAL, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_engine_pool >::Get(), GetCargoSummaryOfArticulatedVehicle(), GetCharacterHeight(), GetColourGradient(), Train::GetDisplayImageWidth(), Engine::GetGRF(), Train::GetImage(), SpecializedVehicle< T, Type >::GetNextVehicle(), GetVehiclePalette(), GfxFillRect(), Rect::Height(), WidgetDimensions::hsep_normal, Rect::Indent(), Vehicle::IsArticulatedPart(), WidgetDimensions::matrix, SpecializedVehicle< T, Type >::Next(), PALETTE_CRASH, WidgetDimensions::scaled, ScaleSpriteTrad(), SetDParam(), TD_RTL, TDW_TAB_CAPACITY, TDW_TAB_CARGO, TDW_TAB_INFO, TDW_TAB_TOTALS, TRAIN_DETAILS_MAX_INDENT, TRAIN_DETAILS_MIN_INDENT, TrainDetailsCapacityTab(), TrainDetailsCargoTab(), TrainDetailsInfoTab(), GRFFile::traininfo_vehicle_pitch, GameSettings::vehicle, Vehicle::vehstatus, and VS_CRASHED.
Referenced by VehicleDetailsWindow::DrawVehicleDetails().
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().
|
static |
draw the vehicle profit button in the vehicle list window.
Definition at line 570 of file vehicle_gui.cpp.
References DrawSprite(), VEHICLE_PROFIT_MIN_AGE, and VEHICLE_PROFIT_THRESHOLD.
Referenced by BaseVehicleListWindow::DrawVehicleListItems().
|
static |
Draw the list of available refit options for a consist and highlight the selected refit option (if any).
refits | Available refit options for each (sorted) cargo. |
sel | Selected refit option 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 700 of file vehicle_gui.cpp.
References _current_text_dir, RefitOption::cargo, DrawSprite(), DrawString(), FS_NORMAL, CargoSpec::Get(), GetCharacterHeight(), GetColourGradient(), GetSpriteSize(), Rect::Indent(), WidgetDimensions::matrix, CargoSpec::name, WidgetDimensions::scaled, SetDParam(), Rect::Shrink(), RefitOption::subtype, and TD_RTL.
Referenced by RefitWindow::DrawWidget().
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.
v_from | the vehicle to match the subtype from |
v_for | the vehicle to get the subtype for |
dest_cargo_type | Destination cargo type. |
Definition at line 599 of file vehicle_gui.cpp.
References EngineInfo::callback_mask, Engine::CanCarryCargo(), CBM_VEHICLE_CARGO_SUFFIX, GetCargoSubtypeText(), Vehicle::GetEngine(), Vehicle::GetFirstEnginePart(), Vehicle::GetNextArticulatedPart(), Vehicle::HasArticulatedPart(), HasBit(), include(), and MAX_REFIT_CYCLE.
Referenced by BuildReplacementVehicle(), CmdCloneVehicle(), LinkRefresher::HandleRefit(), and RefitVehicle().
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().
|
extern |
Determines the number of lines in the train details window.
veh_id | Train |
det_tab | Selected details tab |
Definition at line 328 of file train_gui.cpp.
References _cargo_summary, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_vehicle_pool >::Get(), SpecializedVehicle< T, Type >::Get(), GetCargoSummaryOfArticulatedVehicle(), CargoArray::GetCount(), GetLengthOfArticulatedVehicle(), SpecializedVehicle< T, Type >::GetNextVehicle(), Vehicle::Next(), ScaleSpriteTrad(), TDW_TAB_TOTALS, and TRAIN_DETAILS_MAX_INDENT.
Referenced by VehicleDetailsWindow::OnPaint().
uint GetUnitNumberDigits | ( | VehicleList & | vehicles | ) |
Get the number of digits the biggest unit number of a set of vehicles has.
vehicles | The list of vehicles. |
Definition at line 208 of file vehicle_gui.cpp.
References CountDigitsForAllocatingSpace().
Referenced by DepotWindow::OnPaint().
|
static |
Get width required for the formatted unit number display.
digits | Number of digits required for unit number. |
Definition at line 1770 of file vehicle_gui.cpp.
References GetStringBoundingBox(), and SetDParamMaxDigits().
Referenced by BaseVehicleListWindow::DrawVehicleListItems().
uint GetVehicleListHeight | ( | VehicleType | type, |
uint | divisor | ||
) |
Get the height of a vehicle in the vehicle list GUIs.
type | the vehicle type to look at |
divisor | the resulting height must be dividable by this |
Definition at line 1751 of file vehicle_gui.cpp.
References FS_SMALL, GetCharacterHeight(), GetVehicleHeight(), WidgetDimensions::matrix, WidgetDimensions::scaled, ScaleGUITrad(), VEH_SHIP, and RectPadding::Vertical().
Referenced by VehicleGroupWindow::UpdateWidgetSize(), and VehicleListWindow::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().
void InitializeGUI | ( | ) |
Definition at line 1573 of file vehicle_gui.cpp.
|
static |
Checks whether the vehicle may be refitted at the moment.
Definition at line 3010 of file vehicle_gui.cpp.
References Vehicle::engine_type, IsEngineRefittable(), Vehicle::IsGroundVehicle(), Vehicle::IsStoppedInDepot(), and Vehicle::Next().
Referenced by VehicleViewWindow::OnPaint().
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().
bool ShowCargoIconOverlay | ( | ) |
Test if cargo icon overlays should be drawn.
Definition at line 336 of file vehicle_gui.cpp.
References _ctrl_pressed, and _shift_pressed.
Referenced by DrawCargoIconOverlay(), DrawRoadVehImage(), DrawTrainImage(), DepotWindow::OnMouseLoop(), VehicleGroupWindow::OnMouseLoop(), and VehicleListWindow::OnMouseLoop().
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().
|
static |
Shows the vehicle details window of the given vehicle.
Definition at line 2879 of file vehicle_gui.cpp.
References _nontrain_vehicle_details_desc, _train_vehicle_details_desc, CloseWindowById(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem< Tpool >::index, BaseVehicle::type, VEH_TRAIN, WC_VEHICLE_ORDERS, and WC_VEHICLE_TIMETABLE.
Referenced by VehicleViewWindow::OnClick().
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.
|
static |
Definition at line 2318 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.
Sort vehicles by their age.
Definition at line 1479 of file vehicle_gui.cpp.
References Vehicle::age.
Sort vehicles by their cargo.
Definition at line 1500 of file vehicle_gui.cpp.
References Vehicle::cargo_cap, Vehicle::cargo_type, and Vehicle::Next().
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.
|
static |
Sort vehicle groups by the average profit last year.
Definition at line 1446 of file vehicle_gui.cpp.
|
static |
Sort vehicle groups by the average profit this year.
Definition at line 1440 of file vehicle_gui.cpp.
|
static |
Sort vehicle groups by the number of vehicles in the group.
Definition at line 1422 of file vehicle_gui.cpp.
|
static |
Sort vehicle groups by the total profit last year.
Definition at line 1434 of file vehicle_gui.cpp.
|
static |
Sort vehicle groups by the total profit this year.
Definition at line 1428 of file vehicle_gui.cpp.
|
static |
Wrapper to convert a VehicleIndividualSortFunction to a VehicleGroupSortFunction.
Definition at line 76 of file vehicle_gui.cpp.
References GUIVehicleGroup::vehicles_begin.
Sort vehicles by their length.
Definition at line 1553 of file vehicle_gui.cpp.
References GroundVehicleCache::cached_total_length, and Vehicle::GetGroundVehicleCache().
Sort vehicles by their max speed.
Definition at line 1526 of file vehicle_gui.cpp.
References VehicleCache::cached_max_speed, and Vehicle::vcache.
Sort vehicles by model.
Definition at line 1533 of file vehicle_gui.cpp.
References Vehicle::engine_type.
Sort vehicles by their name.
Definition at line 1458 of file vehicle_gui.cpp.
References GetString(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem< Tpool >::index, SetDParam(), and StrNaturalCompare().
Sort vehicles by their number.
Definition at line 1452 of file vehicle_gui.cpp.
References Vehicle::unitnumber.
|
static |
Sort vehicles by last year profit.
Definition at line 1493 of file vehicle_gui.cpp.
References Vehicle::GetDisplayProfitLastYear().
|
static |
Sort vehicles by this year profit.
Definition at line 1486 of file vehicle_gui.cpp.
References Vehicle::GetDisplayProfitThisYear().
Sort vehicles by their reliability.
Definition at line 1519 of file vehicle_gui.cpp.
References Vehicle::reliability.
|
static |
Sort vehicles by the timetable delay.
Definition at line 1567 of file vehicle_gui.cpp.
References BaseConsist::lateness_counter.
Sort vehicles by the time they can still live.
Definition at line 1560 of file vehicle_gui.cpp.
References Vehicle::age, and Vehicle::max_age.
Sort vehicles by their value.
Definition at line 1540 of file vehicle_gui.cpp.
References Vehicle::Next(), and Vehicle::value.
BaseVehicleListWindow::GroupBy _grouping[VLT_END][VEH_COMPANY_END] |
Definition at line 52 of file vehicle_gui.cpp.
|
static |
Definition at line 553 of file vehicle_gui.cpp.
|
staticconstexpr |
Vehicle details widgets (other than train).
Definition at line 2376 of file vehicle_gui.cpp.
|
staticconstexpr |
Train details widgets.
Definition at line 2399 of file vehicle_gui.cpp.
|
staticconstexpr |
Definition at line 1617 of file vehicle_gui.cpp.
|
staticconstexpr |
Definition at line 1329 of file vehicle_gui.cpp.
|
staticconstexpr |
Vehicle view widgets.
Definition at line 2890 of file vehicle_gui.cpp.
|
static |
Definition at line 2441 of file vehicle_gui.cpp.
|
static |
Definition at line 2447 of file vehicle_gui.cpp.
Sorting _sorting[BaseVehicleListWindow::GB_END] |
Definition at line 53 of file vehicle_gui.cpp.
|
static |
Vehicle view window descriptor for trains.
Only minimum_height and default_height are different for train view.
Referenced by ShowVehicleViewWindow().
|
static |
Definition at line 408 of file vehicle_gui.cpp.
|
static |
Command codes for the shared buttons indexed by VehicleCommandTranslation and vehicle type.
Definition at line 2960 of file vehicle_gui.cpp.
Referenced by VehicleViewWindow::OnClick(), and StartStopVehicle().
|
static |
Zoom levels for vehicle views indexed by vehicle type.
Definition at line 2940 of file vehicle_gui.cpp.
|
static |
Maximum number of refit cycles we try, to prevent infinite loops.
And we store only a byte anyway
Definition at line 588 of file vehicle_gui.cpp.
Referenced by RefitWindow::BuildRefitList(), and GetBestFittingSubType().
|
static |
Definition at line 57 of file vehicle_gui.cpp.
|
static |
Definition at line 60 of file vehicle_gui.cpp.
|
static |
Definition at line 72 of file vehicle_gui.cpp.
|
static |
Definition at line 71 of file vehicle_gui.cpp.
|
static |
Definition at line 68 of file vehicle_gui.cpp.
|
static |
Definition at line 70 of file vehicle_gui.cpp.
|
static |
Definition at line 69 of file vehicle_gui.cpp.
|
static |
Definition at line 65 of file vehicle_gui.cpp.
|
static |
Definition at line 62 of file vehicle_gui.cpp.
|
static |
Definition at line 63 of file vehicle_gui.cpp.
|
static |
Definition at line 56 of file vehicle_gui.cpp.
|
static |
Definition at line 55 of file vehicle_gui.cpp.
|
static |
Definition at line 59 of file vehicle_gui.cpp.
|
static |
Definition at line 58 of file vehicle_gui.cpp.
|
static |
Definition at line 61 of file vehicle_gui.cpp.
|
static |
Definition at line 67 of file vehicle_gui.cpp.
|
static |
Definition at line 66 of file vehicle_gui.cpp.
|
static |
Definition at line 64 of file vehicle_gui.cpp.
|
static |
Definition at line 2949 of file vehicle_gui.cpp.
|
static |
Definition at line 2950 of file vehicle_gui.cpp.
|
static |
Definition at line 2948 of file vehicle_gui.cpp.