OpenTTD Source 20260512-master-g20b387b91f
depot_gui.cpp File Reference

The GUI for depots. More...

#include "stdafx.h"
#include "train.h"
#include "roadveh.h"
#include "ship.h"
#include "aircraft.h"
#include "gui.h"
#include "textbuf_gui.h"
#include "viewport_func.h"
#include "command_func.h"
#include "depot_base.h"
#include "spritecache_type.h"
#include "strings_func.h"
#include "sound_func.h"
#include "vehicle_func.h"
#include "company_func.h"
#include "tilehighlight_func.h"
#include "window_gui.h"
#include "vehiclelist.h"
#include "order_backup.h"
#include "zoom_func.h"
#include "error.h"
#include "depot_cmd.h"
#include "train_cmd.h"
#include "vehicle_cmd.h"
#include "core/geometry_func.hpp"
#include "widgets/depot_widget.h"
#include "table/strings.h"
#include "safeguards.h"

Go to the source code of this file.

Data Structures

struct  DepotWindow
struct  DepotWindow::DepotActionResult
 Result of GetVehicleFromDepotWndPt that tries to determine the action to perform. More...

Functions

void DepotSortList (VehicleList *list)
void CcCloneVehicle (Commands, const CommandCost &result, VehicleID veh_id)
 This is the Callback method after the cloning attempt of a vehicle.
static void TrainDepotMoveVehicle (const Vehicle *wagon, VehicleID sel, const Vehicle *head)
VehicleCellSize GetVehicleImageCellSize (VehicleType type, EngineImageType image_type)
 Get the GUI cell size for a vehicle image.
static void InitBlocksizeForVehicles (VehicleType type, EngineImageType image_type)
void InitDepotWindowBlockSizes ()
 Set the size of the blocks in the window so we can be sure that they are big enough for the vehicle sprites in the current game.
static void DepotSellAllConfirmationCallback (Window *w, bool confirmed)
const SpriteGetAircraftSprite (EngineID engine)
void ShowDepotWindow (TileIndex tile, VehicleType type)
 Opens a depot window.
void DeleteDepotHighlightOfVehicle (const Vehicle *v)
 Removes the highlight of a vehicle in a depot window.

Variables

static constexpr std::initializer_list< NWidgetPart_nested_train_depot_widgets
 Nested widget definition for train depots.
static WindowDesc _train_depot_desc (WindowPosition::Automatic, "depot_train", 362, 123, WC_VEHICLE_DEPOT, WC_NONE, {}, _nested_train_depot_widgets)
 Window definition for the train depot window.
static WindowDesc _road_depot_desc (WindowPosition::Automatic, "depot_roadveh", 316, 97, WC_VEHICLE_DEPOT, WC_NONE, {}, _nested_train_depot_widgets)
 Window definition for the road depot window.
static WindowDesc _ship_depot_desc (WindowPosition::Automatic, "depot_ship", 306, 99, WC_VEHICLE_DEPOT, WC_NONE, {}, _nested_train_depot_widgets)
 Window definition for the ship depot window.
static WindowDesc _aircraft_depot_desc (WindowPosition::Automatic, "depot_aircraft", 332, 99, WC_VEHICLE_DEPOT, WC_NONE, {}, _nested_train_depot_widgets)
 Window definition for the aircraft depot window.
static VehicleTypeIndexArray< VehicleCellSize_base_block_sizes_depot
 Cell size for vehicle images in the depot view.
static VehicleTypeIndexArray< VehicleCellSize_base_block_sizes_purchase
 Cell size for vehicle images in the purchase list.
static uint _consistent_train_width
 Whether trains of all lengths are consistently scaled. Either TRAININFO_DEFAULT_VEHICLE_WIDTH, VEHICLEINFO_FULL_VEHICLE_WIDTH, or 0.

Detailed Description

The GUI for depots.

Definition in file depot_gui.cpp.

Function Documentation

◆ CcCloneVehicle()

void CcCloneVehicle ( Commands ,
const CommandCost & result,
VehicleID veh_id )

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

Parameters
resultthe result of the cloning command
veh_idcloned vehicle ID

Definition at line 128 of file depot_gui.cpp.

References CommandCost::Failed(), and ShowVehicleViewWindow().

Referenced by VehicleViewWindow::OnClick(), and DepotWindow::OnVehicleSelect().

◆ DeleteDepotHighlightOfVehicle()

void DeleteDepotHighlightOfVehicle ( const Vehicle * v)

Removes the highlight of a vehicle in a depot window.

Parameters
*vVehicle to remove all highlights from

Definition at line 1200 of file depot_gui.cpp.

References _special_mouse_mode, FindWindowById(), ResetObjectToPlace(), Vehicle::tile, WC_VEHICLE_DEPOT, and WSM_DRAGDROP.

Referenced by Vehicle::PreDestructor().

◆ DepotSellAllConfirmationCallback()

void DepotSellAllConfirmationCallback ( Window * w,
bool confirmed )
static

Definition at line 1168 of file depot_gui.cpp.

◆ DepotSortList()

void DepotSortList ( VehicleList * list)
extern

Definition at line 565 of file vehicle_gui.cpp.

◆ GetVehicleImageCellSize()

VehicleCellSize GetVehicleImageCellSize ( VehicleType type,
EngineImageType image_type )

Get the GUI cell size for a vehicle image.

Parameters
typeVehicle type to get the size for.
image_typeImage type to get size for.
Precondition
image_type == EIT_IN_DEPOT || image_type == EIT_PURCHASE
Returns
Cell dimensions for the vehicle and image type.

Definition at line 166 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().

◆ InitBlocksizeForVehicles()

void InitBlocksizeForVehicles ( VehicleType type,
EngineImageType image_type )
static

Definition at line 175 of file depot_gui.cpp.

◆ InitDepotWindowBlockSizes()

void InitDepotWindowBlockSizes ( )

Set the size of the blocks in the window so we can be sure that they are big enough for the vehicle sprites in the current game.

Note
Calling this function once for each game is enough.

Definition at line 223 of file depot_gui.cpp.

References _consistent_train_width, Begin, CompanyEnd, EIT_IN_DEPOT, EIT_PURCHASE, Engine::IterateType(), and Train.

Referenced by InitWindowSystem(), and ReInitAllWindows().

◆ ShowDepotWindow()

void ShowDepotWindow ( TileIndex tile,
VehicleType type )

Opens a depot window.

Parameters
tileThe tile where the depot/hangar is located
typeThe type of vehicles in the depot

Definition at line 1183 of file depot_gui.cpp.

References _aircraft_depot_desc, _road_depot_desc, _ship_depot_desc, _train_depot_desc, Aircraft, BringWindowToFrontById(), Road, Ship, Train, and WC_VEHICLE_DEPOT.

Referenced by ClickTile_Rail(), ClickTile_Road(), ClickTile_Station(), and ClickTile_Water().

◆ TrainDepotMoveVehicle()

void TrainDepotMoveVehicle ( const Vehicle * wagon,
VehicleID sel,
const Vehicle * head )
static

Definition at line 137 of file depot_gui.cpp.

Variable Documentation

◆ _base_block_sizes_depot

VehicleTypeIndexArray<VehicleCellSize> _base_block_sizes_depot
static

Cell size for vehicle images in the depot view.

Definition at line 155 of file depot_gui.cpp.

Referenced by GetVehicleImageCellSize().

◆ _base_block_sizes_purchase

VehicleTypeIndexArray<VehicleCellSize> _base_block_sizes_purchase
static

Cell size for vehicle images in the purchase list.

Definition at line 156 of file depot_gui.cpp.

Referenced by GetVehicleImageCellSize().

◆ _consistent_train_width

uint _consistent_train_width
static

Whether trains of all lengths are consistently scaled. Either TRAININFO_DEFAULT_VEHICLE_WIDTH, VEHICLEINFO_FULL_VEHICLE_WIDTH, or 0.

Definition at line 157 of file depot_gui.cpp.

Referenced by DepotWindow::DrawVehicleInDepot(), DepotWindow::DrawWidget(), and InitDepotWindowBlockSizes().

◆ _nested_train_depot_widgets

std::initializer_list<NWidgetPart> _nested_train_depot_widgets
staticconstexpr

Nested widget definition for train depots.

Definition at line 50 of file depot_gui.cpp.