depot_gui.cpp File Reference

#include "stdafx.h"
#include "openttd.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 "gfx_func.h"
#include "command_func.h"
#include "depot.h"
#include "vehicle_gui.h"
#include "station_map.h"
#include "newgrf_engine.h"
#include "spritecache.h"
#include "strings_func.h"
#include "window_func.h"
#include "vehicle_func.h"
#include "player_func.h"
#include "table/strings.h"
#include "table/sprites.h"

Go to the source code of this file.

Data Structures

struct  GetDepotVehiclePtData

Enumerations

enum  DepotWindowWidgets {
  DEPOT_WIDGET_CLOSEBOX = 0, DEPOT_WIDGET_CAPTION, DEPOT_WIDGET_STICKY, DEPOT_WIDGET_SELL,
  DEPOT_WIDGET_SELL_CHAIN, DEPOT_WIDGET_SELL_ALL, DEPOT_WIDGET_AUTOREPLACE, DEPOT_WIDGET_MATRIX,
  DEPOT_WIDGET_V_SCROLL, DEPOT_WIDGET_H_SCROLL, DEPOT_WIDGET_BUILD, DEPOT_WIDGET_CLONE,
  DEPOT_WIDGET_LOCATION, DEPOT_WIDGET_VEHICLE_LIST, DEPOT_WIDGET_STOP_ALL, DEPOT_WIDGET_START_ALL,
  DEPOT_WIDGET_RESIZE
}
enum  DepotGUIAction { MODE_ERROR, MODE_DRAG_VEHICLE, MODE_SHOW_VEHICLE, MODE_START_STOP }

Functions

static void DepotWndProc (Window *w, WindowEvent *e)
int WagonLengthToPixels (int len)
 Get the number of pixels for the given wagon length.
void CcCloneVehicle (bool success, TileIndex tile, uint32 p1, uint32 p2)
 This is the Callback method after the cloning attempt of a vehicle.
static void DepotSellAllConfirmationCallback (Window *w, bool confirmed)
const Sprite * GetAircraftSprite (EngineID engine)
static void DrawVehicleInDepot (Window *w, const Vehicle *v, int x, int y)
 Draw a vehicle in the depot window in the box with the top left corner at x,y.
static void DrawDepotWindow (Window *w)
static DepotGUIAction GetVehicleFromDepotWndPt (const Window *w, int x, int y, Vehicle **veh, GetDepotVehiclePtData *d)
static void TrainDepotMoveVehicle (Vehicle *wagon, VehicleID sel, Vehicle *head)
static void DepotClick (Window *w, int x, int y)
static void HandleCloneVehClick (const Vehicle *v, const Window *w)
 Clones a vehicle.
static void ClonePlaceObj (const Window *w)
static void ResizeDepotButtons (Window *w)
static void SetupStringsForDepotWindow (Window *w, VehicleType type)
static void ResizeDefaultWindowSizeForTrains ()
static void ResizeDefaultWindowSizeForRoadVehicles ()
static void ResizeDefaultWindowSize (VehicleType type)
void InitDepotWindowBlockSizes ()
static void CreateDepotListWindow (Window *w, VehicleType type)
void DepotSortList (Vehicle **v, uint16 length)
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 const Widget _depot_widgets []
static const WindowDesc _train_depot_desc
static const WindowDesc _road_depot_desc
static const WindowDesc _ship_depot_desc
static const WindowDesc _aircraft_depot_desc
uint _block_sizes [4][2]
const uint _resize_cap [][2]


Detailed Description

Definition in file depot_gui.cpp.


Enumeration Type Documentation

Enumerator:
DEPOT_WIDGET_V_SCROLL  Vertical scrollbar.
DEPOT_WIDGET_H_SCROLL  Horizontal scrollbar.

Definition at line 36 of file depot_gui.cpp.


Function Documentation

void CcCloneVehicle ( bool  success,
TileIndex  tile,
uint32  p1,
uint32  p2 
)

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

Parameters:
success indicates completion (or not) of the operation
tile unused
p1 unused
p2 unused

Definition at line 143 of file depot_gui.cpp.

References ShowVehicleViewWindow().

Referenced by HandleCloneVehClick(), and VehicleViewWndProc().

void DeleteDepotHighlightOfVehicle ( const Vehicle *  v  ) 

Removes the highlight of a vehicle in a depot window.

Parameters:
*v Vehicle to remove all highlights from

Definition at line 1013 of file depot_gui.cpp.

Referenced by CmdSellRailWagon(), CmdSellRoadVeh(), and CmdSellShip().

static void DrawVehicleInDepot ( Window *  w,
const Vehicle *  v,
int  x,
int  y 
) [static]

Draw a vehicle in the depot window in the box with the top left corner at x,y.

Parameters:
*w Window to draw in
*v Vehicle to draw
x Left side of the box to draw in
y Top of the box to draw in

Definition at line 169 of file depot_gui.cpp.

References DIR_W, and max().

static void HandleCloneVehClick ( const Vehicle *  v,
const Window *  w 
) [static]

Clones a vehicle.

Parameters:
*v is the original vehicle to clone
*w is the window of the depot where the clone is build

Definition at line 488 of file depot_gui.cpp.

References _ctrl_pressed, CcCloneVehicle(), CMD_CLONE_VEHICLE, CMD_MSG, DoCommandP(), error_str, and IsFrontEngine().

void ShowDepotWindow ( TileIndex  tile,
VehicleType  type 
)

Opens a depot window.

Parameters:
tile The tile where the depot/hangar is located
type The type of vehicles in the depot

Definition at line 988 of file depot_gui.cpp.

References AllocateWindowDescFront(), and GetTileOwner().

int WagonLengthToPixels ( int  len  ) 

Get the number of pixels for the given wagon length.

Parameters:
len Length measured in 1/8ths of a standard wagon.
Returns:
Number of pixels across.

Definition at line 68 of file train_gui.cpp.


Variable Documentation

const WindowDesc _aircraft_depot_desc [static]

Initial value:

 {
  WDP_AUTO, WDP_AUTO, 36, 27, 36, 27,
  WC_VEHICLE_DEPOT, WC_NONE,
  WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_STICKY_BUTTON | WDF_RESIZABLE,
  _depot_widgets,
  DepotWndProc
}

Definition at line 126 of file depot_gui.cpp.

const Widget _depot_widgets[] [static]

Initial value:

 {
  {   WWT_CLOSEBOX,   RESIZE_NONE,    14,     0,    10,     0,    13, STR_00C5,            STR_018B_CLOSE_WINDOW},            
  {    WWT_CAPTION,  RESIZE_RIGHT,    14,    11,    23,     0,    13, 0x0,                 STR_018C_WINDOW_TITLE_DRAG_THIS},  
  {  WWT_STICKYBOX,     RESIZE_LR,    14,    24,    35,     0,    13, 0x0,                 STR_STICKY_BUTTON},                

  
  {     WWT_IMGBTN,    RESIZE_LRB,    14,     1,    23,    14,   -32, 0x0,                 STR_NULL},                         
  {     WWT_IMGBTN,   RESIZE_LRTB,    14,     1,    23,   -55,   -32, SPR_SELL_CHAIN_TRAIN,STR_DRAG_WHOLE_TRAIN_TO_SELL_TIP}, 
  { WWT_PUSHIMGBTN,   RESIZE_LRTB,    14,     1,    23,   -31,    -9, 0x0,                 STR_NULL},                         
  { WWT_PUSHIMGBTN,   RESIZE_LRTB,    14,     1,    23,    -8,    14, 0x0,                 STR_NULL},                         

  {     WWT_MATRIX,     RESIZE_RB,    14,     0,     0,    14,    14, 0x0,                 STR_NULL},                         
  {  WWT_SCROLLBAR,    RESIZE_LRB,    14,    24,    35,    14,    14, 0x0,                 STR_0190_SCROLL_BAR_SCROLLS_LIST}, 

  { WWT_HSCROLLBAR,    RESIZE_RTB,    14,     0,     0,     3,    14, 0x0,                 STR_HSCROLL_BAR_SCROLLS_LIST},     

  
  { WWT_PUSHTXTBTN,     RESIZE_TB,    14,     0,     0,    15,    26, 0x0,                 STR_NULL},                         
  {    WWT_TEXTBTN,     RESIZE_TB,    14,     0,     0,    15,    26, 0x0,                 STR_NULL},                         
  { WWT_PUSHTXTBTN,    RESIZE_RTB,    14,     0,   -12,    15,    26, STR_00E4_LOCATION,   STR_NULL},                         
  { WWT_PUSHTXTBTN,   RESIZE_LRTB,    14,   -11,     0,    15,    26, 0x0,                 STR_NULL},                         
  { WWT_PUSHIMGBTN,   RESIZE_LRTB,    14,     1,    11,    15,    26, SPR_FLAG_VEH_STOPPED,STR_NULL},                         
  { WWT_PUSHIMGBTN,   RESIZE_LRTB,    14,    12,    23,    15,    26, SPR_FLAG_VEH_RUNNING,STR_NULL},                         
  {  WWT_RESIZEBOX,   RESIZE_LRTB,    14,    24,    35,    15,    26, 0x0,                 STR_RESIZE_BUTTON},                
  {   WIDGETS_END},
}

Definition at line 72 of file depot_gui.cpp.

const uint _resize_cap[][2]

Initial value:

 {
    {6, 10 * 29},
     {5, 5},
     {3, 3},
 {3, 4},
}

Definition at line 646 of file depot_gui.cpp.

const WindowDesc _road_depot_desc [static]

Initial value:

 {
  WDP_AUTO, WDP_AUTO, 36, 27, 36, 27,
  WC_VEHICLE_DEPOT, WC_NONE,
  WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_STICKY_BUTTON | WDF_RESIZABLE,
  _depot_widgets,
  DepotWndProc
}

Definition at line 110 of file depot_gui.cpp.

const WindowDesc _ship_depot_desc [static]

Initial value:

 {
  WDP_AUTO, WDP_AUTO, 36, 27, 36, 27,
  WC_VEHICLE_DEPOT, WC_NONE,
  WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_STICKY_BUTTON | WDF_RESIZABLE,
  _depot_widgets,
  DepotWndProc
}

Definition at line 118 of file depot_gui.cpp.

const WindowDesc _train_depot_desc [static]

Initial value:

 {
  WDP_AUTO, WDP_AUTO, 36, 27, 36, 27,
  WC_VEHICLE_DEPOT, WC_NONE,
  WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_STICKY_BUTTON | WDF_RESIZABLE,
  _depot_widgets,
  DepotWndProc
}

Definition at line 102 of file depot_gui.cpp.


Generated on Wed Oct 1 17:03:26 2008 for openttd by  doxygen 1.5.6