src/depot_gui.cpp
author rubidium
Sat, 17 May 2008 13:01:30 +0000
changeset 10596 0ee9eba64c9c
parent 10595 7957c71b0dfe
child 10607 1ab30cead125
permissions -rw-r--r--
(svn r13140) -Codechange: move the gui-list-sorting out of window_gui.h so window_gui.h only needs to be included in *_gui.cpp.
4638
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
     1
/* $Id$ */
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
     2
10429
1b99254f9607 (svn r12971) -Documentation: add @file in files that missed them and add something more than whitespace as description of files that don't have a description.
rubidium
parents: 10411
diff changeset
     3
/** @file depot_gui.cpp The GUI for depots. */
6451
7baba06b4b85 (svn r8862) -Cleanup: doxygen changes, again. Mostly @files missing tags and a few comments style.
belugas
parents: 6369
diff changeset
     4
4638
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
     5
#include "stdafx.h"
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
     6
#include "openttd.h"
4654
71048359c6ac (svn r6530) -Fix r6529: added missing header file (oops)
bjarni
parents: 4653
diff changeset
     7
#include "train.h"
71048359c6ac (svn r6530) -Fix r6529: added missing header file (oops)
bjarni
parents: 4653
diff changeset
     8
#include "roadveh.h"
4638
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
     9
#include "ship.h"
4653
091f530bae28 (svn r6529) -Fix r6513: [depot window] added missing switch in CcCloneVehicle()
bjarni
parents: 4652
diff changeset
    10
#include "aircraft.h"
4638
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
    11
#include "gui.h"
8603
88c5ce6a5215 (svn r11668) -Codechange: more refactoring aimed at reducing compile time and making it more logic where function definitions can be found.
rubidium
parents: 8578
diff changeset
    12
#include "textbuf_gui.h"
8720
4e60c30e2006 (svn r11787) -Codechange: more header rewrites. This time related to viewport.h.
rubidium
parents: 8640
diff changeset
    13
#include "viewport_func.h"
4e60c30e2006 (svn r11787) -Codechange: more header rewrites. This time related to viewport.h.
rubidium
parents: 8640
diff changeset
    14
#include "gfx_func.h"
8612
6414fc21c2f3 (svn r11677) -Codechange: move price and command related types/functions to their respective places.
rubidium
parents: 8610
diff changeset
    15
#include "command_func.h"
10222
b6919c94cc77 (svn r12754) -Codechange: split depot.h into depot_map.h, depot_func.h and depot_base.h and remove quite a lot of unneeded (before this) includes of depot.h.
rubidium
parents: 9324
diff changeset
    16
#include "depot_base.h"
4638
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
    17
#include "vehicle_gui.h"
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
    18
#include "station_map.h"
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
    19
#include "newgrf_engine.h"
6223
92d2073c3d7e (svn r8661) -Fix: [depot windows] Enlarge the blocks in the depot window if a sprite is too big to fit (ships and aircraft only)
bjarni
parents: 6206
diff changeset
    20
#include "spritecache.h"
8610
17cc343a23dd (svn r11675) -Codechange: split the string types from the string functions.
rubidium
parents: 8603
diff changeset
    21
#include "strings_func.h"
8627
448ebf3a8291 (svn r11692) -Codechange: move some functions from 'functions.h' to a more logical place and remove about 50% of the includes of 'functions.h'
rubidium
parents: 8617
diff changeset
    22
#include "window_func.h"
8640
1e93b81e96d2 (svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium
parents: 8627
diff changeset
    23
#include "vehicle_func.h"
8750
fdd6054e7bae (svn r11818) -Codechange: split player.h into smaller pieces.
rubidium
parents: 8733
diff changeset
    24
#include "player_func.h"
9280
9c03416d26b1 (svn r12488) -Codechange: split order.h into order_base.h and order_func.h.
rubidium
parents: 9081
diff changeset
    25
#include "order_func.h"
10222
b6919c94cc77 (svn r12754) -Codechange: split depot.h into depot_map.h, depot_func.h and depot_base.h and remove quite a lot of unneeded (before this) includes of depot.h.
rubidium
parents: 9324
diff changeset
    26
#include "depot_base.h"
10445
2dd7d9d0a957 (svn r12987) -Codechange: split viewport and tile selection.
rubidium
parents: 10434
diff changeset
    27
#include "tilehighlight_func.h"
10596
0ee9eba64c9c (svn r13140) -Codechange: move the gui-list-sorting out of window_gui.h so window_gui.h only needs to be included in *_gui.cpp.
rubidium
parents: 10595
diff changeset
    28
#include "window_gui.h"
4649
eced6da682cb (svn r6525) -Codechange r6513: altered how to control how to move widgets around in the window. Hopefully it's a bit easier to understand now
bjarni
parents: 4646
diff changeset
    29
8760
ce0891c412ce (svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium
parents: 8750
diff changeset
    30
#include "table/strings.h"
ce0891c412ce (svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium
parents: 8750
diff changeset
    31
#include "table/sprites.h"
ce0891c412ce (svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium
parents: 8750
diff changeset
    32
4649
eced6da682cb (svn r6525) -Codechange r6513: altered how to control how to move widgets around in the window. Hopefully it's a bit easier to understand now
bjarni
parents: 4646
diff changeset
    33
/*
eced6da682cb (svn r6525) -Codechange r6513: altered how to control how to move widgets around in the window. Hopefully it's a bit easier to understand now
bjarni
parents: 4646
diff changeset
    34
 * Since all depot window sizes aren't the same, we need to modify sizes a little.
eced6da682cb (svn r6525) -Codechange r6513: altered how to control how to move widgets around in the window. Hopefully it's a bit easier to understand now
bjarni
parents: 4646
diff changeset
    35
 * It's done with the following arrays of widget indexes. Each of them tells if a widget side should be moved and in what direction.
eced6da682cb (svn r6525) -Codechange r6513: altered how to control how to move widgets around in the window. Hopefully it's a bit easier to understand now
bjarni
parents: 4646
diff changeset
    36
 * How long they should be moved and for what window types are controlled in ShowDepotWindow()
eced6da682cb (svn r6525) -Codechange r6513: altered how to control how to move widgets around in the window. Hopefully it's a bit easier to understand now
bjarni
parents: 4646
diff changeset
    37
 */
eced6da682cb (svn r6525) -Codechange r6513: altered how to control how to move widgets around in the window. Hopefully it's a bit easier to understand now
bjarni
parents: 4646
diff changeset
    38
4646
c6f774de4f6f (svn r6522) -Feature: [depot window] the buttons are now "scaled" resized
bjarni
parents: 4644
diff changeset
    39
/* Names of the widgets. Keep them in the same order as in the widget array */
5269
3f3eead5ace2 (svn r7410) -Codechange/Fix: Remove useless and unfollowable programmatic-resize, and implement it
Darkvater
parents: 5265
diff changeset
    40
enum DepotWindowWidgets {
4646
c6f774de4f6f (svn r6522) -Feature: [depot window] the buttons are now "scaled" resized
bjarni
parents: 4644
diff changeset
    41
	DEPOT_WIDGET_CLOSEBOX = 0,
c6f774de4f6f (svn r6522) -Feature: [depot window] the buttons are now "scaled" resized
bjarni
parents: 4644
diff changeset
    42
	DEPOT_WIDGET_CAPTION,
c6f774de4f6f (svn r6522) -Feature: [depot window] the buttons are now "scaled" resized
bjarni
parents: 4644
diff changeset
    43
	DEPOT_WIDGET_STICKY,
c6f774de4f6f (svn r6522) -Feature: [depot window] the buttons are now "scaled" resized
bjarni
parents: 4644
diff changeset
    44
	DEPOT_WIDGET_SELL,
4659
2f99f35d5813 (svn r6542) -Feature: [depot window] added a "sell all vehicles in depot" button
bjarni
parents: 4654
diff changeset
    45
	DEPOT_WIDGET_SELL_CHAIN,
4646
c6f774de4f6f (svn r6522) -Feature: [depot window] the buttons are now "scaled" resized
bjarni
parents: 4644
diff changeset
    46
	DEPOT_WIDGET_SELL_ALL,
4699
1f2d7bc70d0c (svn r6609) - Move the mass stop/start buttons of the depot window to the bottom row, to match all other vehicle list windows, and make it look a bit neater, (Suggested by skidd13)
peter1138
parents: 4690
diff changeset
    47
	DEPOT_WIDGET_AUTOREPLACE,
4646
c6f774de4f6f (svn r6522) -Feature: [depot window] the buttons are now "scaled" resized
bjarni
parents: 4644
diff changeset
    48
	DEPOT_WIDGET_MATRIX,
6451
7baba06b4b85 (svn r8862) -Cleanup: doxygen changes, again. Mostly @files missing tags and a few comments style.
belugas
parents: 6369
diff changeset
    49
	DEPOT_WIDGET_V_SCROLL, ///< Vertical scrollbar
7baba06b4b85 (svn r8862) -Cleanup: doxygen changes, again. Mostly @files missing tags and a few comments style.
belugas
parents: 6369
diff changeset
    50
	DEPOT_WIDGET_H_SCROLL, ///< Horizontal scrollbar
4646
c6f774de4f6f (svn r6522) -Feature: [depot window] the buttons are now "scaled" resized
bjarni
parents: 4644
diff changeset
    51
	DEPOT_WIDGET_BUILD,
c6f774de4f6f (svn r6522) -Feature: [depot window] the buttons are now "scaled" resized
bjarni
parents: 4644
diff changeset
    52
	DEPOT_WIDGET_CLONE,
c6f774de4f6f (svn r6522) -Feature: [depot window] the buttons are now "scaled" resized
bjarni
parents: 4644
diff changeset
    53
	DEPOT_WIDGET_LOCATION,
4681
7d7a89b32dd0 (svn r6586) -Feature: [depot window] added a vehicle list window with all vehicles having a certain depot in their orders
bjarni
parents: 4670
diff changeset
    54
	DEPOT_WIDGET_VEHICLE_LIST,
4699
1f2d7bc70d0c (svn r6609) - Move the mass stop/start buttons of the depot window to the bottom row, to match all other vehicle list windows, and make it look a bit neater, (Suggested by skidd13)
peter1138
parents: 4690
diff changeset
    55
	DEPOT_WIDGET_STOP_ALL,
1f2d7bc70d0c (svn r6609) - Move the mass stop/start buttons of the depot window to the bottom row, to match all other vehicle list windows, and make it look a bit neater, (Suggested by skidd13)
peter1138
parents: 4690
diff changeset
    56
	DEPOT_WIDGET_START_ALL,
4646
c6f774de4f6f (svn r6522) -Feature: [depot window] the buttons are now "scaled" resized
bjarni
parents: 4644
diff changeset
    57
	DEPOT_WIDGET_RESIZE,
4649
eced6da682cb (svn r6525) -Codechange r6513: altered how to control how to move widgets around in the window. Hopefully it's a bit easier to understand now
bjarni
parents: 4646
diff changeset
    58
};
eced6da682cb (svn r6525) -Codechange r6513: altered how to control how to move widgets around in the window. Hopefully it's a bit easier to understand now
bjarni
parents: 4646
diff changeset
    59
4638
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
    60
/* Widget array for all depot windows.
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
    61
 * If a widget is needed in some windows only (like train specific), add it for all windows
4702
5179f9adc5b3 (svn r6612) -Codechange: Use accessors for hidden_state.
belugas
parents: 4699
diff changeset
    62
 * and use HideWindowWidget in ShowDepotWindow() to remove it in the windows where it should not be
4638
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
    63
 * Keep the widget numbers in sync with the enum or really bad stuff will happen!!! */
4649
eced6da682cb (svn r6525) -Codechange r6513: altered how to control how to move widgets around in the window. Hopefully it's a bit easier to understand now
bjarni
parents: 4646
diff changeset
    64
eced6da682cb (svn r6525) -Codechange r6513: altered how to control how to move widgets around in the window. Hopefully it's a bit easier to understand now
bjarni
parents: 4646
diff changeset
    65
/* When adding widgets, place them as you would place them for the ship depot and define how you want it to move in widget_moves[]
4650
1a39612a6291 (svn r6526) -Codechange: [depot window] the train only widgets are now resized depending on the size of other widgets
bjarni
parents: 4649
diff changeset
    66
 * If you want a widget for one window only, set it to be hidden in ShowDepotWindow() for the windows where you don't want it
1a39612a6291 (svn r6526) -Codechange: [depot window] the train only widgets are now resized depending on the size of other widgets
bjarni
parents: 4649
diff changeset
    67
 * NOTE: the train only widgets are moved/resized in ShowDepotWindow() so they follow certain other widgets if they are moved to ensure that they stick together.
1a39612a6291 (svn r6526) -Codechange: [depot window] the train only widgets are now resized depending on the size of other widgets
bjarni
parents: 4649
diff changeset
    68
 *    Changing the size of those here will not have an effect at all. It should be done in ShowDepotWindow()
1a39612a6291 (svn r6526) -Codechange: [depot window] the train only widgets are now resized depending on the size of other widgets
bjarni
parents: 4649
diff changeset
    69
 */
6223
92d2073c3d7e (svn r8661) -Fix: [depot windows] Enlarge the blocks in the depot window if a sprite is too big to fit (ships and aircraft only)
bjarni
parents: 6206
diff changeset
    70
92d2073c3d7e (svn r8661) -Fix: [depot windows] Enlarge the blocks in the depot window if a sprite is too big to fit (ships and aircraft only)
bjarni
parents: 6206
diff changeset
    71
/*
92d2073c3d7e (svn r8661) -Fix: [depot windows] Enlarge the blocks in the depot window if a sprite is too big to fit (ships and aircraft only)
bjarni
parents: 6206
diff changeset
    72
 * Some of the widgets are placed outside the window (negative coordinates).
92d2073c3d7e (svn r8661) -Fix: [depot windows] Enlarge the blocks in the depot window if a sprite is too big to fit (ships and aircraft only)
bjarni
parents: 6206
diff changeset
    73
 * The reason is that they are placed relatively to the matrix and the matrix is just one pixel (in 0, 14).
92d2073c3d7e (svn r8661) -Fix: [depot windows] Enlarge the blocks in the depot window if a sprite is too big to fit (ships and aircraft only)
bjarni
parents: 6206
diff changeset
    74
 * The matrix and the rest of the window will be resized when the size of the boxes is set and then all the widgets will be inside the window.
92d2073c3d7e (svn r8661) -Fix: [depot windows] Enlarge the blocks in the depot window if a sprite is too big to fit (ships and aircraft only)
bjarni
parents: 6206
diff changeset
    75
 */
4638
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
    76
static const Widget _depot_widgets[] = {
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
    77
	{   WWT_CLOSEBOX,   RESIZE_NONE,    14,     0,    10,     0,    13, STR_00C5,            STR_018B_CLOSE_WINDOW},            // DEPOT_WIDGET_CLOSEBOX
6223
92d2073c3d7e (svn r8661) -Fix: [depot windows] Enlarge the blocks in the depot window if a sprite is too big to fit (ships and aircraft only)
bjarni
parents: 6206
diff changeset
    78
	{    WWT_CAPTION,  RESIZE_RIGHT,    14,    11,    23,     0,    13, 0x0,                 STR_018C_WINDOW_TITLE_DRAG_THIS},  // DEPOT_WIDGET_CAPTION
92d2073c3d7e (svn r8661) -Fix: [depot windows] Enlarge the blocks in the depot window if a sprite is too big to fit (ships and aircraft only)
bjarni
parents: 6206
diff changeset
    79
	{  WWT_STICKYBOX,     RESIZE_LR,    14,    24,    35,     0,    13, 0x0,                 STR_STICKY_BUTTON},                // DEPOT_WIDGET_STICKY
4640
cabffc571e55 (svn r6515) -Feature: added "start all" and "stop all" buttons to the depot windows
bjarni
parents: 4638
diff changeset
    80
4938
074f734a91ca (svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents: 4935
diff changeset
    81
	/* Widgets are set up run-time */
6223
92d2073c3d7e (svn r8661) -Fix: [depot windows] Enlarge the blocks in the depot window if a sprite is too big to fit (ships and aircraft only)
bjarni
parents: 6206
diff changeset
    82
	{     WWT_IMGBTN,    RESIZE_LRB,    14,     1,    23,    14,   -32, 0x0,                 STR_NULL},                         // DEPOT_WIDGET_SELL
92d2073c3d7e (svn r8661) -Fix: [depot windows] Enlarge the blocks in the depot window if a sprite is too big to fit (ships and aircraft only)
bjarni
parents: 6206
diff changeset
    83
	{     WWT_IMGBTN,   RESIZE_LRTB,    14,     1,    23,   -55,   -32, SPR_SELL_CHAIN_TRAIN,STR_DRAG_WHOLE_TRAIN_TO_SELL_TIP}, // DEPOT_WIDGET_SELL_CHAIN, trains only
92d2073c3d7e (svn r8661) -Fix: [depot windows] Enlarge the blocks in the depot window if a sprite is too big to fit (ships and aircraft only)
bjarni
parents: 6206
diff changeset
    84
	{ WWT_PUSHIMGBTN,   RESIZE_LRTB,    14,     1,    23,   -31,    -9, 0x0,                 STR_NULL},                         // DEPOT_WIDGET_SELL_ALL
92d2073c3d7e (svn r8661) -Fix: [depot windows] Enlarge the blocks in the depot window if a sprite is too big to fit (ships and aircraft only)
bjarni
parents: 6206
diff changeset
    85
	{ WWT_PUSHIMGBTN,   RESIZE_LRTB,    14,     1,    23,    -8,    14, 0x0,                 STR_NULL},                         // DEPOT_WIDGET_AUTOREPLACE
4638
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
    86
6223
92d2073c3d7e (svn r8661) -Fix: [depot windows] Enlarge the blocks in the depot window if a sprite is too big to fit (ships and aircraft only)
bjarni
parents: 6206
diff changeset
    87
	{     WWT_MATRIX,     RESIZE_RB,    14,     0,     0,    14,    14, 0x0,                 STR_NULL},                         // DEPOT_WIDGET_MATRIX
92d2073c3d7e (svn r8661) -Fix: [depot windows] Enlarge the blocks in the depot window if a sprite is too big to fit (ships and aircraft only)
bjarni
parents: 6206
diff changeset
    88
	{  WWT_SCROLLBAR,    RESIZE_LRB,    14,    24,    35,    14,    14, 0x0,                 STR_0190_SCROLL_BAR_SCROLLS_LIST}, // DEPOT_WIDGET_V_SCROLL
4638
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
    89
6223
92d2073c3d7e (svn r8661) -Fix: [depot windows] Enlarge the blocks in the depot window if a sprite is too big to fit (ships and aircraft only)
bjarni
parents: 6206
diff changeset
    90
	{ WWT_HSCROLLBAR,    RESIZE_RTB,    14,     0,     0,     3,    14, 0x0,                 STR_HSCROLL_BAR_SCROLLS_LIST},     // DEPOT_WIDGET_H_SCROLL, trains only
4638
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
    91
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
    92
	/* The buttons in the bottom of the window. left and right is not important as they are later resized to be equal in size
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
    93
	 * This calculation is based on right in DEPOT_WIDGET_LOCATION and it presumes left of DEPOT_WIDGET_BUILD is 0            */
6223
92d2073c3d7e (svn r8661) -Fix: [depot windows] Enlarge the blocks in the depot window if a sprite is too big to fit (ships and aircraft only)
bjarni
parents: 6206
diff changeset
    94
	{ WWT_PUSHTXTBTN,     RESIZE_TB,    14,     0,     0,    15,    26, 0x0,                 STR_NULL},                         // DEPOT_WIDGET_BUILD
92d2073c3d7e (svn r8661) -Fix: [depot windows] Enlarge the blocks in the depot window if a sprite is too big to fit (ships and aircraft only)
bjarni
parents: 6206
diff changeset
    95
	{    WWT_TEXTBTN,     RESIZE_TB,    14,     0,     0,    15,    26, 0x0,                 STR_NULL},                         // DEPOT_WIDGET_CLONE
92d2073c3d7e (svn r8661) -Fix: [depot windows] Enlarge the blocks in the depot window if a sprite is too big to fit (ships and aircraft only)
bjarni
parents: 6206
diff changeset
    96
	{ WWT_PUSHTXTBTN,    RESIZE_RTB,    14,     0,   -12,    15,    26, STR_00E4_LOCATION,   STR_NULL},                         // DEPOT_WIDGET_LOCATION
92d2073c3d7e (svn r8661) -Fix: [depot windows] Enlarge the blocks in the depot window if a sprite is too big to fit (ships and aircraft only)
bjarni
parents: 6206
diff changeset
    97
	{ WWT_PUSHTXTBTN,   RESIZE_LRTB,    14,   -11,     0,    15,    26, 0x0,                 STR_NULL},                         // DEPOT_WIDGET_VEHICLE_LIST
92d2073c3d7e (svn r8661) -Fix: [depot windows] Enlarge the blocks in the depot window if a sprite is too big to fit (ships and aircraft only)
bjarni
parents: 6206
diff changeset
    98
	{ WWT_PUSHIMGBTN,   RESIZE_LRTB,    14,     1,    11,    15,    26, SPR_FLAG_VEH_STOPPED,STR_NULL},                         // DEPOT_WIDGET_STOP_ALL
92d2073c3d7e (svn r8661) -Fix: [depot windows] Enlarge the blocks in the depot window if a sprite is too big to fit (ships and aircraft only)
bjarni
parents: 6206
diff changeset
    99
	{ WWT_PUSHIMGBTN,   RESIZE_LRTB,    14,    12,    23,    15,    26, SPR_FLAG_VEH_RUNNING,STR_NULL},                         // DEPOT_WIDGET_START_ALL
92d2073c3d7e (svn r8661) -Fix: [depot windows] Enlarge the blocks in the depot window if a sprite is too big to fit (ships and aircraft only)
bjarni
parents: 6206
diff changeset
   100
	{  WWT_RESIZEBOX,   RESIZE_LRTB,    14,    24,    35,    15,    26, 0x0,                 STR_RESIZE_BUTTON},                // DEPOT_WIDGET_RESIZE
4638
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   101
	{   WIDGETS_END},
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   102
};
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   103
10508
c5f6299d2f54 (svn r13051) -Codechange: depot_d belongs in depot_gui.cpp.
rubidium
parents: 10462
diff changeset
   104
4638
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   105
static const WindowDesc _train_depot_desc = {
7837
65d7362153a6 (svn r10704) -Codechange: provide an infrastructure to have resizable windows that are smaller than the default window size.
rubidium
parents: 7762
diff changeset
   106
	WDP_AUTO, WDP_AUTO, 36, 27, 36, 27,
6144
5a0ffbf27ced (svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents: 6075
diff changeset
   107
	WC_VEHICLE_DEPOT, WC_NONE,
4638
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   108
	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_STICKY_BUTTON | WDF_RESIZABLE,
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   109
	_depot_widgets,
10523
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   110
	NULL
4638
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   111
};
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   112
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   113
static const WindowDesc _road_depot_desc = {
7837
65d7362153a6 (svn r10704) -Codechange: provide an infrastructure to have resizable windows that are smaller than the default window size.
rubidium
parents: 7762
diff changeset
   114
	WDP_AUTO, WDP_AUTO, 36, 27, 36, 27,
6144
5a0ffbf27ced (svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents: 6075
diff changeset
   115
	WC_VEHICLE_DEPOT, WC_NONE,
4638
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   116
	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_STICKY_BUTTON | WDF_RESIZABLE,
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   117
	_depot_widgets,
10523
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   118
	NULL
4638
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   119
};
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   120
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   121
static const WindowDesc _ship_depot_desc = {
7837
65d7362153a6 (svn r10704) -Codechange: provide an infrastructure to have resizable windows that are smaller than the default window size.
rubidium
parents: 7762
diff changeset
   122
	WDP_AUTO, WDP_AUTO, 36, 27, 36, 27,
6144
5a0ffbf27ced (svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents: 6075
diff changeset
   123
	WC_VEHICLE_DEPOT, WC_NONE,
4638
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   124
	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_STICKY_BUTTON | WDF_RESIZABLE,
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   125
	_depot_widgets,
10523
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   126
	NULL
4638
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   127
};
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   128
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   129
static const WindowDesc _aircraft_depot_desc = {
7837
65d7362153a6 (svn r10704) -Codechange: provide an infrastructure to have resizable windows that are smaller than the default window size.
rubidium
parents: 7762
diff changeset
   130
	WDP_AUTO, WDP_AUTO, 36, 27, 36, 27,
6144
5a0ffbf27ced (svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents: 6075
diff changeset
   131
	WC_VEHICLE_DEPOT, WC_NONE,
4638
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   132
	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_STICKY_BUTTON | WDF_RESIZABLE,
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   133
	_depot_widgets,
10523
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   134
	NULL
4638
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   135
};
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   136
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   137
extern int WagonLengthToPixels(int len);
10523
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   138
extern void DepotSortList(Vehicle **v, uint16 length);
4638
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   139
7974
6fcdebd75c19 (svn r10985) -Codechange: unify/remove duplicate CcClone(Aircraft|RoadVeh|Ship|Train) in favour of CcCloneVehicle.
rubidium
parents: 7837
diff changeset
   140
/**
6fcdebd75c19 (svn r10985) -Codechange: unify/remove duplicate CcClone(Aircraft|RoadVeh|Ship|Train) in favour of CcCloneVehicle.
rubidium
parents: 7837
diff changeset
   141
 * This is the Callback method after the cloning attempt of a vehicle
6fcdebd75c19 (svn r10985) -Codechange: unify/remove duplicate CcClone(Aircraft|RoadVeh|Ship|Train) in favour of CcCloneVehicle.
rubidium
parents: 7837
diff changeset
   142
 * @param success indicates completion (or not) of the operation
6fcdebd75c19 (svn r10985) -Codechange: unify/remove duplicate CcClone(Aircraft|RoadVeh|Ship|Train) in favour of CcCloneVehicle.
rubidium
parents: 7837
diff changeset
   143
 * @param tile unused
6fcdebd75c19 (svn r10985) -Codechange: unify/remove duplicate CcClone(Aircraft|RoadVeh|Ship|Train) in favour of CcCloneVehicle.
rubidium
parents: 7837
diff changeset
   144
 * @param p1 unused
6fcdebd75c19 (svn r10985) -Codechange: unify/remove duplicate CcClone(Aircraft|RoadVeh|Ship|Train) in favour of CcCloneVehicle.
rubidium
parents: 7837
diff changeset
   145
 * @param p2 unused
6fcdebd75c19 (svn r10985) -Codechange: unify/remove duplicate CcClone(Aircraft|RoadVeh|Ship|Train) in favour of CcCloneVehicle.
rubidium
parents: 7837
diff changeset
   146
 */
4638
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   147
void CcCloneVehicle(bool success, TileIndex tile, uint32 p1, uint32 p2)
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   148
{
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   149
	if (!success) return;
7974
6fcdebd75c19 (svn r10985) -Codechange: unify/remove duplicate CcClone(Aircraft|RoadVeh|Ship|Train) in favour of CcCloneVehicle.
rubidium
parents: 7837
diff changeset
   150
6fcdebd75c19 (svn r10985) -Codechange: unify/remove duplicate CcClone(Aircraft|RoadVeh|Ship|Train) in favour of CcCloneVehicle.
rubidium
parents: 7837
diff changeset
   151
	Vehicle *v = GetVehicle(_new_vehicle_id);
6fcdebd75c19 (svn r10985) -Codechange: unify/remove duplicate CcClone(Aircraft|RoadVeh|Ship|Train) in favour of CcCloneVehicle.
rubidium
parents: 7837
diff changeset
   152
7982
539e32cc37ce (svn r10997) -Codechange: unify the vehicle view window. Patch by PhilSophus.
rubidium
parents: 7975
diff changeset
   153
	ShowVehicleViewWindow(v);
4638
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   154
}
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   155
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   156
static void TrainDepotMoveVehicle(Vehicle *wagon, VehicleID sel, Vehicle *head)
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   157
{
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   158
	Vehicle *v;
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   159
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   160
	v = GetVehicle(sel);
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   161
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   162
	if (v == wagon) return;
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   163
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   164
	if (wagon == NULL) {
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   165
		if (head != NULL) wagon = GetLastVehicleInChain(head);
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   166
	} else  {
7993
76b0eb3e19c9 (svn r11011) -Fix [FS#1129]: GetFirstVehicleInChain did change the game state while being marked const.
rubidium
parents: 7988
diff changeset
   167
		wagon = wagon->Previous();
4638
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   168
		if (wagon == NULL) return;
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   169
	}
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   170
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   171
	if (wagon == v) return;
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   172
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   173
	DoCommandP(v->tile, v->index + ((wagon == NULL ? INVALID_VEHICLE : wagon->index) << 16), _ctrl_pressed ? 1 : 0, NULL, CMD_MOVE_RAIL_VEHICLE | CMD_MSG(STR_8837_CAN_T_MOVE_VEHICLE));
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   174
}
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   175
6223
92d2073c3d7e (svn r8661) -Fix: [depot windows] Enlarge the blocks in the depot window if a sprite is too big to fit (ships and aircraft only)
bjarni
parents: 6206
diff changeset
   176
/* Array to hold the block sizes
92d2073c3d7e (svn r8661) -Fix: [depot windows] Enlarge the blocks in the depot window if a sprite is too big to fit (ships and aircraft only)
bjarni
parents: 6206
diff changeset
   177
 * First part is the vehicle type, while the last is 0 = x, 1 = y */
92d2073c3d7e (svn r8661) -Fix: [depot windows] Enlarge the blocks in the depot window if a sprite is too big to fit (ships and aircraft only)
bjarni
parents: 6206
diff changeset
   178
uint _block_sizes[4][2];
92d2073c3d7e (svn r8661) -Fix: [depot windows] Enlarge the blocks in the depot window if a sprite is too big to fit (ships and aircraft only)
bjarni
parents: 6206
diff changeset
   179
92d2073c3d7e (svn r8661) -Fix: [depot windows] Enlarge the blocks in the depot window if a sprite is too big to fit (ships and aircraft only)
bjarni
parents: 6206
diff changeset
   180
/* Array to hold the default resize capacities
92d2073c3d7e (svn r8661) -Fix: [depot windows] Enlarge the blocks in the depot window if a sprite is too big to fit (ships and aircraft only)
bjarni
parents: 6206
diff changeset
   181
* First part is the vehicle type, while the last is 0 = x, 1 = y */
92d2073c3d7e (svn r8661) -Fix: [depot windows] Enlarge the blocks in the depot window if a sprite is too big to fit (ships and aircraft only)
bjarni
parents: 6206
diff changeset
   182
const uint _resize_cap[][2] = {
6897
dcee0e80200b (svn r9531) -Fix (r8661) [FS#692]: The scroll settings were wrong for trains as only a part
maedhros
parents: 6585
diff changeset
   183
/* VEH_TRAIN */    {6, 10 * 29},
6585
7da94b26498a (svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium
parents: 6574
diff changeset
   184
/* VEH_ROAD */     {5, 5},
7da94b26498a (svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium
parents: 6574
diff changeset
   185
/* VEH_SHIP */     {3, 3},
7da94b26498a (svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium
parents: 6574
diff changeset
   186
/* VEH_AIRCRAFT */ {3, 4},
6223
92d2073c3d7e (svn r8661) -Fix: [depot windows] Enlarge the blocks in the depot window if a sprite is too big to fit (ships and aircraft only)
bjarni
parents: 6206
diff changeset
   187
};
92d2073c3d7e (svn r8661) -Fix: [depot windows] Enlarge the blocks in the depot window if a sprite is too big to fit (ships and aircraft only)
bjarni
parents: 6206
diff changeset
   188
92d2073c3d7e (svn r8661) -Fix: [depot windows] Enlarge the blocks in the depot window if a sprite is too big to fit (ships and aircraft only)
bjarni
parents: 6206
diff changeset
   189
static void ResizeDefaultWindowSizeForTrains()
92d2073c3d7e (svn r8661) -Fix: [depot windows] Enlarge the blocks in the depot window if a sprite is too big to fit (ships and aircraft only)
bjarni
parents: 6206
diff changeset
   190
{
6585
7da94b26498a (svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium
parents: 6574
diff changeset
   191
	_block_sizes[VEH_TRAIN][0] = 1;
7da94b26498a (svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium
parents: 6574
diff changeset
   192
	_block_sizes[VEH_TRAIN][1] = GetVehicleListHeight(VEH_TRAIN);
6223
92d2073c3d7e (svn r8661) -Fix: [depot windows] Enlarge the blocks in the depot window if a sprite is too big to fit (ships and aircraft only)
bjarni
parents: 6206
diff changeset
   193
}
92d2073c3d7e (svn r8661) -Fix: [depot windows] Enlarge the blocks in the depot window if a sprite is too big to fit (ships and aircraft only)
bjarni
parents: 6206
diff changeset
   194
92d2073c3d7e (svn r8661) -Fix: [depot windows] Enlarge the blocks in the depot window if a sprite is too big to fit (ships and aircraft only)
bjarni
parents: 6206
diff changeset
   195
static void ResizeDefaultWindowSizeForRoadVehicles()
92d2073c3d7e (svn r8661) -Fix: [depot windows] Enlarge the blocks in the depot window if a sprite is too big to fit (ships and aircraft only)
bjarni
parents: 6206
diff changeset
   196
{
6585
7da94b26498a (svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium
parents: 6574
diff changeset
   197
	_block_sizes[VEH_ROAD][0] = 56;
7da94b26498a (svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium
parents: 6574
diff changeset
   198
	_block_sizes[VEH_ROAD][1] = GetVehicleListHeight(VEH_ROAD);
6223
92d2073c3d7e (svn r8661) -Fix: [depot windows] Enlarge the blocks in the depot window if a sprite is too big to fit (ships and aircraft only)
bjarni
parents: 6206
diff changeset
   199
}
92d2073c3d7e (svn r8661) -Fix: [depot windows] Enlarge the blocks in the depot window if a sprite is too big to fit (ships and aircraft only)
bjarni
parents: 6206
diff changeset
   200
7134
c5a90dd41166 (svn r9869) -Codechange: replace some bytes with VehicleType, i.e. more type strictness.
rubidium
parents: 7117
diff changeset
   201
static void ResizeDefaultWindowSize(VehicleType type)
6223
92d2073c3d7e (svn r8661) -Fix: [depot windows] Enlarge the blocks in the depot window if a sprite is too big to fit (ships and aircraft only)
bjarni
parents: 6206
diff changeset
   202
{
92d2073c3d7e (svn r8661) -Fix: [depot windows] Enlarge the blocks in the depot window if a sprite is too big to fit (ships and aircraft only)
bjarni
parents: 6206
diff changeset
   203
	uint max_width  = 0;
92d2073c3d7e (svn r8661) -Fix: [depot windows] Enlarge the blocks in the depot window if a sprite is too big to fit (ships and aircraft only)
bjarni
parents: 6206
diff changeset
   204
	uint max_height = 0;
92d2073c3d7e (svn r8661) -Fix: [depot windows] Enlarge the blocks in the depot window if a sprite is too big to fit (ships and aircraft only)
bjarni
parents: 6206
diff changeset
   205
10382
d1d4452acbfc (svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents: 10376
diff changeset
   206
	const Engine *e;
d1d4452acbfc (svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents: 10376
diff changeset
   207
	FOR_ALL_ENGINES_OF_TYPE(e, type) {
d1d4452acbfc (svn r12924) -Feature: Introducing the so called 'engine pool' which primarily removes the fixed engine type limits and also happens to allow (with the patch option 'dynamic_engines') multiple NewGRF vehicle sets to coexist.
peter1138
parents: 10376
diff changeset
   208
		EngineID eid = e->index;
6223
92d2073c3d7e (svn r8661) -Fix: [depot windows] Enlarge the blocks in the depot window if a sprite is too big to fit (ships and aircraft only)
bjarni
parents: 6206
diff changeset
   209
		uint x, y;
92d2073c3d7e (svn r8661) -Fix: [depot windows] Enlarge the blocks in the depot window if a sprite is too big to fit (ships and aircraft only)
bjarni
parents: 6206
diff changeset
   210
92d2073c3d7e (svn r8661) -Fix: [depot windows] Enlarge the blocks in the depot window if a sprite is too big to fit (ships and aircraft only)
bjarni
parents: 6206
diff changeset
   211
		switch (type) {
92d2073c3d7e (svn r8661) -Fix: [depot windows] Enlarge the blocks in the depot window if a sprite is too big to fit (ships and aircraft only)
bjarni
parents: 6206
diff changeset
   212
			default: NOT_REACHED();
10376
a1207076a5c7 (svn r12917) -Codechange: standardise variable names called with FOR_ALL_ENGINEIDS_OF_TYPE
peter1138
parents: 10229
diff changeset
   213
			case VEH_SHIP:     GetShipSpriteSize(    eid, x, y); break;
a1207076a5c7 (svn r12917) -Codechange: standardise variable names called with FOR_ALL_ENGINEIDS_OF_TYPE
peter1138
parents: 10229
diff changeset
   214
			case VEH_AIRCRAFT: GetAircraftSpriteSize(eid, x, y); break;
6223
92d2073c3d7e (svn r8661) -Fix: [depot windows] Enlarge the blocks in the depot window if a sprite is too big to fit (ships and aircraft only)
bjarni
parents: 6206
diff changeset
   215
		}
92d2073c3d7e (svn r8661) -Fix: [depot windows] Enlarge the blocks in the depot window if a sprite is too big to fit (ships and aircraft only)
bjarni
parents: 6206
diff changeset
   216
		if (x > max_width)  max_width  = x;
92d2073c3d7e (svn r8661) -Fix: [depot windows] Enlarge the blocks in the depot window if a sprite is too big to fit (ships and aircraft only)
bjarni
parents: 6206
diff changeset
   217
		if (y > max_height) max_height = y;
92d2073c3d7e (svn r8661) -Fix: [depot windows] Enlarge the blocks in the depot window if a sprite is too big to fit (ships and aircraft only)
bjarni
parents: 6206
diff changeset
   218
	}
92d2073c3d7e (svn r8661) -Fix: [depot windows] Enlarge the blocks in the depot window if a sprite is too big to fit (ships and aircraft only)
bjarni
parents: 6206
diff changeset
   219
92d2073c3d7e (svn r8661) -Fix: [depot windows] Enlarge the blocks in the depot window if a sprite is too big to fit (ships and aircraft only)
bjarni
parents: 6206
diff changeset
   220
	switch (type) {
92d2073c3d7e (svn r8661) -Fix: [depot windows] Enlarge the blocks in the depot window if a sprite is too big to fit (ships and aircraft only)
bjarni
parents: 6206
diff changeset
   221
		default: NOT_REACHED();
6585
7da94b26498a (svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium
parents: 6574
diff changeset
   222
		case VEH_SHIP:
7da94b26498a (svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium
parents: 6574
diff changeset
   223
			_block_sizes[VEH_SHIP][0] = max(90U, max_width + 20); // we need 20 pixels from the right edge to the sprite
6223
92d2073c3d7e (svn r8661) -Fix: [depot windows] Enlarge the blocks in the depot window if a sprite is too big to fit (ships and aircraft only)
bjarni
parents: 6206
diff changeset
   224
			break;
6585
7da94b26498a (svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium
parents: 6574
diff changeset
   225
		case VEH_AIRCRAFT:
7da94b26498a (svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium
parents: 6574
diff changeset
   226
			_block_sizes[VEH_AIRCRAFT][0] = max(74U, max_width);
6223
92d2073c3d7e (svn r8661) -Fix: [depot windows] Enlarge the blocks in the depot window if a sprite is too big to fit (ships and aircraft only)
bjarni
parents: 6206
diff changeset
   227
			break;
92d2073c3d7e (svn r8661) -Fix: [depot windows] Enlarge the blocks in the depot window if a sprite is too big to fit (ships and aircraft only)
bjarni
parents: 6206
diff changeset
   228
	}
92d2073c3d7e (svn r8661) -Fix: [depot windows] Enlarge the blocks in the depot window if a sprite is too big to fit (ships and aircraft only)
bjarni
parents: 6206
diff changeset
   229
	_block_sizes[type][1] = max(GetVehicleListHeight(type), max_height);
92d2073c3d7e (svn r8661) -Fix: [depot windows] Enlarge the blocks in the depot window if a sprite is too big to fit (ships and aircraft only)
bjarni
parents: 6206
diff changeset
   230
}
92d2073c3d7e (svn r8661) -Fix: [depot windows] Enlarge the blocks in the depot window if a sprite is too big to fit (ships and aircraft only)
bjarni
parents: 6206
diff changeset
   231
92d2073c3d7e (svn r8661) -Fix: [depot windows] Enlarge the blocks in the depot window if a sprite is too big to fit (ships and aircraft only)
bjarni
parents: 6206
diff changeset
   232
/* 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
92d2073c3d7e (svn r8661) -Fix: [depot windows] Enlarge the blocks in the depot window if a sprite is too big to fit (ships and aircraft only)
bjarni
parents: 6206
diff changeset
   233
 * We will only need to call this once for each game */
92d2073c3d7e (svn r8661) -Fix: [depot windows] Enlarge the blocks in the depot window if a sprite is too big to fit (ships and aircraft only)
bjarni
parents: 6206
diff changeset
   234
void InitDepotWindowBlockSizes()
92d2073c3d7e (svn r8661) -Fix: [depot windows] Enlarge the blocks in the depot window if a sprite is too big to fit (ships and aircraft only)
bjarni
parents: 6206
diff changeset
   235
{
92d2073c3d7e (svn r8661) -Fix: [depot windows] Enlarge the blocks in the depot window if a sprite is too big to fit (ships and aircraft only)
bjarni
parents: 6206
diff changeset
   236
	ResizeDefaultWindowSizeForTrains();
92d2073c3d7e (svn r8661) -Fix: [depot windows] Enlarge the blocks in the depot window if a sprite is too big to fit (ships and aircraft only)
bjarni
parents: 6206
diff changeset
   237
	ResizeDefaultWindowSizeForRoadVehicles();
6585
7da94b26498a (svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium
parents: 6574
diff changeset
   238
	ResizeDefaultWindowSize(VEH_SHIP);
7da94b26498a (svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium
parents: 6574
diff changeset
   239
	ResizeDefaultWindowSize(VEH_AIRCRAFT);
6223
92d2073c3d7e (svn r8661) -Fix: [depot windows] Enlarge the blocks in the depot window if a sprite is too big to fit (ships and aircraft only)
bjarni
parents: 6206
diff changeset
   240
}
92d2073c3d7e (svn r8661) -Fix: [depot windows] Enlarge the blocks in the depot window if a sprite is too big to fit (ships and aircraft only)
bjarni
parents: 6206
diff changeset
   241
10523
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   242
static void DepotSellAllConfirmationCallback(Window *w, bool confirmed);
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   243
const Sprite *GetAircraftSprite(EngineID engine);
5269
3f3eead5ace2 (svn r7410) -Codechange/Fix: Remove useless and unfollowable programmatic-resize, and implement it
Darkvater
parents: 5265
diff changeset
   244
10523
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   245
struct DepotWindow : Window {
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   246
	VehicleID sel;
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   247
	VehicleType type;
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   248
	bool generate_list;
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   249
	uint16 engine_list_length;
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   250
	uint16 wagon_list_length;
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   251
	uint16 engine_count;
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   252
	uint16 wagon_count;
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   253
	Vehicle **vehicle_list;
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   254
	Vehicle **wagon_list;
6223
92d2073c3d7e (svn r8661) -Fix: [depot windows] Enlarge the blocks in the depot window if a sprite is too big to fit (ships and aircraft only)
bjarni
parents: 6206
diff changeset
   255
10525
da5bc725cda4 (svn r13069) -Codechange: it is no longer needed to pass a void *data pointer with the WE_CREATE message because nothing uses it anymore.
rubidium
parents: 10523
diff changeset
   256
	DepotWindow(const WindowDesc *desc, WindowNumber window_number) : Window(desc, window_number)
10523
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   257
	{
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   258
		this->sel = INVALID_VEHICLE;
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   259
		this->vehicle_list  = NULL;
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   260
		this->wagon_list    = NULL;
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   261
		this->engine_count  = 0;
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   262
		this->wagon_count   = 0;
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   263
		this->generate_list = true;
6223
92d2073c3d7e (svn r8661) -Fix: [depot windows] Enlarge the blocks in the depot window if a sprite is too big to fit (ships and aircraft only)
bjarni
parents: 6206
diff changeset
   264
10523
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   265
		this->FindWindowPlacementAndResize(desc);
5269
3f3eead5ace2 (svn r7410) -Codechange/Fix: Remove useless and unfollowable programmatic-resize, and implement it
Darkvater
parents: 5265
diff changeset
   266
	}
3f3eead5ace2 (svn r7410) -Codechange/Fix: Remove useless and unfollowable programmatic-resize, and implement it
Darkvater
parents: 5265
diff changeset
   267
10523
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   268
	~DepotWindow()
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   269
	{
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   270
		DeleteWindowById(WC_BUILD_VEHICLE, this->window_number);
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   271
		free((void*)this->vehicle_list);
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   272
		free((void*)this->wagon_list);
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   273
	}
5269
3f3eead5ace2 (svn r7410) -Codechange/Fix: Remove useless and unfollowable programmatic-resize, and implement it
Darkvater
parents: 5265
diff changeset
   274
10523
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   275
	/** Draw a vehicle in the depot window in the box with the top left corner at x,y
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   276
	* @param *w Window to draw in
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   277
	* @param *v Vehicle to draw
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   278
	* @param x Left side of the box to draw in
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   279
	* @param y Top of the box to draw in
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   280
	*/
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   281
	void DrawVehicleInDepot(Window *w, const Vehicle *v, int x, int y)
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   282
	{
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   283
		byte diff_x = 0, diff_y = 0;
5269
3f3eead5ace2 (svn r7410) -Codechange/Fix: Remove useless and unfollowable programmatic-resize, and implement it
Darkvater
parents: 5265
diff changeset
   284
10523
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   285
		int sprite_y = y + this->resize.step_height - GetVehicleListHeight(v->type);
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   286
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   287
		switch (v->type) {
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   288
			case VEH_TRAIN:
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   289
				DrawTrainImage(v, x + 21, sprite_y, this->sel, this->hscroll.cap + 4, this->hscroll.pos);
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   290
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   291
				/* Number of wagons relative to a standard length wagon (rounded up) */
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   292
				SetDParam(0, (v->u.rail.cached_total_length + 7) / 8);
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   293
				DrawStringRightAligned(this->widget[DEPOT_WIDGET_MATRIX].right - 1, y + 4, STR_TINY_BLACK, TC_FROMSTRING); // Draw the counter
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   294
				break;
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   295
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   296
			case VEH_ROAD:     DrawRoadVehImage( v, x + 24, sprite_y, this->sel, 1); break;
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   297
			case VEH_SHIP:     DrawShipImage(    v, x + 19, sprite_y - 1, this->sel); break;
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   298
			case VEH_AIRCRAFT: {
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   299
				const Sprite *spr = GetSprite(v->GetImage(DIR_W));
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   300
				DrawAircraftImage(v, x + 12,
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   301
									y + max(spr->height + spr->y_offs - 14, 0), // tall sprites needs an y offset
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   302
									this->sel);
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   303
			} break;
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   304
			default: NOT_REACHED();
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   305
		}
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   306
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   307
		if (this->resize.step_height == 14) {
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   308
			/* VEH_TRAIN and VEH_ROAD, which are low */
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   309
			diff_x = 15;
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   310
		} else {
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   311
			/* VEH_SHIP and VEH_AIRCRAFT, which are tall */
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   312
			diff_y = 12;
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   313
		}
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   314
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   315
		DrawSprite((v->vehstatus & VS_STOPPED) ? SPR_FLAG_VEH_STOPPED : SPR_FLAG_VEH_RUNNING, PAL_NONE, x + diff_x, y + diff_y);
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   316
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   317
		SetDParam(0, v->unitnumber);
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   318
		DrawString(x, y + 2, (uint16)(v->max_age - 366) >= v->age ? STR_00E2 : STR_00E3, TC_FROMSTRING);
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   319
	}
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   320
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   321
	void DrawDepotWindow(Window *w)
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   322
	{
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   323
		Vehicle **vl = this->vehicle_list;
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   324
		TileIndex tile = this->window_number;
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   325
		int x, y, i, maxval;
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   326
		uint16 hnum;
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   327
		uint16 num = this->engine_count;
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   328
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   329
		/* Set the row and number of boxes in each row based on the number of boxes drawn in the matrix */
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   330
		uint16 rows_in_display   = this->widget[DEPOT_WIDGET_MATRIX].data >> 8;
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   331
		uint16 boxes_in_each_row = this->widget[DEPOT_WIDGET_MATRIX].data & 0xFF;
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   332
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   333
		/* setup disabled buttons */
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   334
		this->SetWidgetsDisabledState(!IsTileOwner(tile, _local_player),
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   335
			DEPOT_WIDGET_STOP_ALL,
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   336
			DEPOT_WIDGET_START_ALL,
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   337
			DEPOT_WIDGET_SELL,
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   338
			DEPOT_WIDGET_SELL_CHAIN,
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   339
			DEPOT_WIDGET_SELL_ALL,
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   340
			DEPOT_WIDGET_BUILD,
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   341
			DEPOT_WIDGET_CLONE,
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   342
			DEPOT_WIDGET_AUTOREPLACE,
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   343
			WIDGET_LIST_END);
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   344
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   345
		/* determine amount of items for scroller */
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   346
		if (this->type == VEH_TRAIN) {
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   347
			hnum = 8;
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   348
			for (num = 0; num < this->engine_count; num++) {
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   349
				const Vehicle *v = vl[num];
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   350
				hnum = max(hnum, v->u.rail.cached_total_length);
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   351
			}
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   352
			/* Always have 1 empty row, so people can change the setting of the train */
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   353
			SetVScrollCount(w, this->engine_count + this->wagon_count + 1);
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   354
			SetHScrollCount(w, WagonLengthToPixels(hnum));
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   355
		} else {
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   356
			SetVScrollCount(w, (num + this->hscroll.cap - 1) / this->hscroll.cap);
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   357
		}
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   358
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   359
		/* locate the depot struct */
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   360
		if (this->type == VEH_AIRCRAFT) {
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   361
			SetDParam(0, GetStationIndex(tile)); // Airport name
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   362
		} else {
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   363
			Depot *depot = GetDepotByTile(tile);
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   364
			assert(depot != NULL);
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   365
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   366
			SetDParam(0, depot->town_index);
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   367
		}
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   368
10595
7957c71b0dfe (svn r13139) -Codechange: move DrawWindowWidgets and DrawWindowViewport to the Window class and remove Window from their naming.
rubidium
parents: 10554
diff changeset
   369
		w->DrawWidgets();
10523
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   370
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   371
		num = this->vscroll.pos * boxes_in_each_row;
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   372
		maxval = min(this->engine_count, num + (rows_in_display * boxes_in_each_row));
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   373
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   374
		for (x = 2, y = 15; num < maxval; y += this->resize.step_height, x = 2) { // Draw the rows
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   375
			byte i;
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   376
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   377
			for (i = 0; i < boxes_in_each_row && num < maxval; i++, num++, x += this->resize.step_width) {
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   378
				/* Draw all vehicles in the current row */
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   379
				const Vehicle *v = vl[num];
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   380
				DrawVehicleInDepot(w, v, x, y);
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   381
			}
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   382
		}
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   383
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   384
		maxval = min(this->engine_count + this->wagon_count, (this->vscroll.pos * boxes_in_each_row) + (rows_in_display * boxes_in_each_row));
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   385
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   386
		/* draw the train wagons, that do not have an engine in front */
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   387
		for (; num < maxval; num++, y += 14) {
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   388
			const Vehicle *v = this->wagon_list[num - this->engine_count];
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   389
			const Vehicle *u;
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   390
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   391
			DrawTrainImage(v, x + 50, y, this->sel, this->hscroll.cap - 29, 0);
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   392
			DrawString(x, y + 2, STR_8816, TC_FROMSTRING);
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   393
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   394
			/*Draw the train counter */
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   395
			i = 0;
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   396
			u = v;
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   397
			do i++; while ((u = u->Next()) != NULL); // Determine length of train
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   398
			SetDParam(0, i);                      // Set the counter
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   399
			DrawStringRightAligned(this->widget[DEPOT_WIDGET_MATRIX].right - 1, y + 4, STR_TINY_BLACK, TC_FROMSTRING); // Draw the counter
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   400
		}
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   401
	}
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   402
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   403
	struct GetDepotVehiclePtData {
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   404
		Vehicle *head;
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   405
		Vehicle *wagon;
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   406
	};
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   407
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   408
	enum DepotGUIAction {
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   409
		MODE_ERROR,
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   410
		MODE_DRAG_VEHICLE,
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   411
		MODE_SHOW_VEHICLE,
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   412
		MODE_START_STOP,
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   413
	};
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   414
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   415
	DepotGUIAction GetVehicleFromDepotWndPt(int x, int y, Vehicle **veh, GetDepotVehiclePtData *d) const
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   416
	{
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   417
		Vehicle **vl = this->vehicle_list;
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   418
		uint xt, row, xm = 0, ym = 0;
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   419
		int pos, skip = 0;
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   420
		uint16 boxes_in_each_row = this->widget[DEPOT_WIDGET_MATRIX].data & 0xFF;
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   421
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   422
		if (this->type == VEH_TRAIN) {
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   423
			xt = 0;
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   424
			x -= 23;
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   425
		} else {
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   426
			xt = x / this->resize.step_width;
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   427
			xm = x % this->resize.step_width;
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   428
			if (xt >= this->hscroll.cap) return MODE_ERROR;
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   429
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   430
			ym = (y - 14) % this->resize.step_height;
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   431
		}
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   432
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   433
		row = (y - 14) / this->resize.step_height;
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   434
		if (row >= this->vscroll.cap) return MODE_ERROR;
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   435
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   436
		pos = ((row + this->vscroll.pos) * boxes_in_each_row) + xt;
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   437
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   438
		if (this->engine_count + this->wagon_count <= pos) {
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   439
			if (this->type == VEH_TRAIN) {
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   440
				d->head  = NULL;
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   441
				d->wagon = NULL;
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   442
				return MODE_DRAG_VEHICLE;
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   443
			} else {
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   444
				return MODE_ERROR; // empty block, so no vehicle is selected
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   445
			}
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   446
		}
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   447
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   448
		if (this->engine_count > pos) {
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   449
			*veh = vl[pos];
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   450
			skip = this->hscroll.pos;
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   451
		} else {
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   452
			vl = this->wagon_list;
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   453
			pos -= this->engine_count;
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   454
			*veh = vl[pos];
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   455
			/* free wagons don't have an initial loco. */
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   456
			x -= _traininfo_vehicle_width;
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   457
		}
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   458
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   459
		switch (this->type) {
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   460
			case VEH_TRAIN: {
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   461
				Vehicle *v = *veh;
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   462
				d->head = d->wagon = v;
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   463
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   464
				/* either pressed the flag or the number, but only when it's a loco */
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   465
				if (x < 0 && IsFrontEngine(v)) return (x >= -10) ? MODE_START_STOP : MODE_SHOW_VEHICLE;
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   466
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   467
				skip = (skip * 8) / _traininfo_vehicle_width;
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   468
				x = (x * 8) / _traininfo_vehicle_width;
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   469
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   470
				/* Skip vehicles that are scrolled off the list */
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   471
				x += skip;
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   472
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   473
				/* find the vehicle in this row that was clicked */
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   474
				while (v != NULL && (x -= v->u.rail.cached_veh_length) >= 0) v = v->Next();
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   475
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   476
				/* if an articulated part was selected, find its parent */
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   477
				while (v != NULL && IsArticulatedPart(v)) v = v->Previous();
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   478
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   479
				d->wagon = v;
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   480
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   481
				return MODE_DRAG_VEHICLE;
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   482
				}
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   483
				break;
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   484
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   485
			case VEH_ROAD:
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   486
				if (xm >= 24) return MODE_DRAG_VEHICLE;
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   487
				if (xm <= 16) return MODE_SHOW_VEHICLE;
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   488
				break;
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   489
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   490
			case VEH_SHIP:
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   491
				if (xm >= 19) return MODE_DRAG_VEHICLE;
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   492
				if (ym <= 10) return MODE_SHOW_VEHICLE;
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   493
				break;
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   494
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   495
			case VEH_AIRCRAFT:
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   496
				if (xm >= 12) return MODE_DRAG_VEHICLE;
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   497
				if (ym <= 12) return MODE_SHOW_VEHICLE;
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   498
				break;
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   499
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   500
			default: NOT_REACHED();
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   501
		}
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   502
		return MODE_START_STOP;
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   503
	}
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   504
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   505
	void DepotClick(int x, int y)
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   506
	{
10535
7f2ce934723b (svn r13079) -Fix: certain compilers give false warning about uninitialized variable
smatz
parents: 10525
diff changeset
   507
		GetDepotVehiclePtData gdvp = { NULL, NULL };
10523
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   508
		Vehicle *v = NULL;
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   509
		DepotGUIAction mode = this->GetVehicleFromDepotWndPt(x, y, &v, &gdvp);
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   510
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   511
		/* share / copy orders */
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   512
		if (_thd.place_mode != VHM_NONE && mode != MODE_ERROR) {
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   513
			_place_clicked_vehicle = (this->type == VEH_TRAIN ? gdvp.head : v);
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   514
			return;
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   515
		}
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   516
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   517
		if (this->type == VEH_TRAIN) v = gdvp.wagon;
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   518
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   519
		switch (mode) {
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   520
			case MODE_ERROR: // invalid
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   521
				return;
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   522
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   523
			case MODE_DRAG_VEHICLE: { // start dragging of vehicle
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   524
				VehicleID sel = this->sel;
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   525
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   526
				if (this->type == VEH_TRAIN && sel != INVALID_VEHICLE) {
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   527
					this->sel = INVALID_VEHICLE;
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   528
					TrainDepotMoveVehicle(v, sel, gdvp.head);
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   529
				} else if (v != NULL) {
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   530
					int image = v->GetImage(DIR_W);
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   531
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   532
					this->sel = v->index;
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   533
					this->SetDirty();
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   534
					SetObjectToPlaceWnd(image, GetVehiclePalette(v), VHM_DRAG, this);
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   535
					_cursor.vehchain = _ctrl_pressed;
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   536
				}
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   537
			} break;
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   538
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   539
			case MODE_SHOW_VEHICLE: // show info window
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   540
				ShowVehicleViewWindow(v);
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   541
				break;
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   542
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   543
			case MODE_START_STOP: { // click start/stop flag
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   544
				uint command;
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   545
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   546
				switch (this->type) {
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   547
					case VEH_TRAIN:    command = CMD_START_STOP_TRAIN | CMD_MSG(STR_883B_CAN_T_STOP_START_TRAIN);          break;
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   548
					case VEH_ROAD:     command = CMD_START_STOP_ROADVEH | CMD_MSG(STR_9015_CAN_T_STOP_START_ROAD_VEHICLE); break;
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   549
					case VEH_SHIP:     command = CMD_START_STOP_SHIP | CMD_MSG(STR_9818_CAN_T_STOP_START_SHIP);            break;
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   550
					case VEH_AIRCRAFT: command = CMD_START_STOP_AIRCRAFT | CMD_MSG(STR_A016_CAN_T_STOP_START_AIRCRAFT);    break;
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   551
					default: NOT_REACHED(); command = 0;
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   552
				}
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   553
				DoCommandP(v->tile, v->index, 0, NULL, command);
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   554
			} break;
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   555
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   556
			default: NOT_REACHED();
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   557
		}
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   558
	}
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   559
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   560
	/**
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   561
	* Clones a vehicle
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   562
	* @param *v is the original vehicle to clone
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   563
	* @param *w is the window of the depot where the clone is build
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   564
	*/
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   565
	void HandleCloneVehClick(const Vehicle *v, const Window *w)
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   566
	{
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   567
		uint error_str;
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   568
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   569
		if (v == NULL) return;
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   570
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   571
		if (!v->IsPrimaryVehicle()) {
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   572
			v = v->First();
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   573
			/* Do nothing when clicking on a train in depot with no loc attached */
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   574
			if (v->type == VEH_TRAIN && !IsFrontEngine(v)) return;
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   575
		}
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   576
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   577
		switch (v->type) {
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   578
			case VEH_TRAIN:    error_str = CMD_MSG(STR_882B_CAN_T_BUILD_RAILROAD_VEHICLE); break;
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   579
			case VEH_ROAD:     error_str = CMD_MSG(STR_9009_CAN_T_BUILD_ROAD_VEHICLE);     break;
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   580
			case VEH_SHIP:     error_str = CMD_MSG(STR_980D_CAN_T_BUILD_SHIP);             break;
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   581
			case VEH_AIRCRAFT: error_str = CMD_MSG(STR_A008_CAN_T_BUILD_AIRCRAFT);         break;
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   582
			default: return;
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   583
		}
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   584
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   585
		DoCommandP(this->window_number, v->index, _ctrl_pressed ? 1 : 0, CcCloneVehicle, CMD_CLONE_VEHICLE | error_str);
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   586
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   587
		ResetObjectToPlace();
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   588
	}
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   589
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   590
	void ResizeDepotButtons(Window *w)
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   591
	{
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   592
		ResizeButtons(w, DEPOT_WIDGET_BUILD, DEPOT_WIDGET_LOCATION);
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   593
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   594
		if (this->type == VEH_TRAIN) {
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   595
			/* Divide the size of DEPOT_WIDGET_SELL into two equally big buttons so DEPOT_WIDGET_SELL and DEPOT_WIDGET_SELL_CHAIN will get the same size.
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   596
			* This way it will stay the same even if DEPOT_WIDGET_SELL_CHAIN is resized for some reason                                                  */
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   597
			this->widget[DEPOT_WIDGET_SELL_CHAIN].top    = ((this->widget[DEPOT_WIDGET_SELL_CHAIN].bottom - this->widget[DEPOT_WIDGET_SELL].top) / 2) + this->widget[DEPOT_WIDGET_SELL].top;
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   598
			this->widget[DEPOT_WIDGET_SELL].bottom     = this->widget[DEPOT_WIDGET_SELL_CHAIN].top - 1;
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   599
		}
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   600
	}
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   601
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   602
	/* Function to set up vehicle specific sprites and strings
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   603
	 * Only use this if it's the same widget, that's used for more than one vehicle type and it needs different text/sprites
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   604
	 * Vehicle specific text/sprites, that's in a widget, that's only shown for one vehicle type (like sell whole train) is set in the widget array
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   605
	 */
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   606
	void SetupStringsForDepotWindow(VehicleType type)
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   607
	{
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   608
		switch (type) {
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   609
			default: NOT_REACHED();
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   610
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   611
			case VEH_TRAIN:
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   612
				this->widget[DEPOT_WIDGET_CAPTION].data      = STR_8800_TRAIN_DEPOT;
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   613
				this->widget[DEPOT_WIDGET_STOP_ALL].tooltips = STR_MASS_STOP_DEPOT_TRAIN_TIP;
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   614
				this->widget[DEPOT_WIDGET_START_ALL].tooltips= STR_MASS_START_DEPOT_TRAIN_TIP;
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   615
				this->widget[DEPOT_WIDGET_SELL].tooltips     = STR_8841_DRAG_TRAIN_VEHICLE_TO_HERE;
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   616
				this->widget[DEPOT_WIDGET_SELL_ALL].tooltips = STR_DEPOT_SELL_ALL_BUTTON_TRAIN_TIP;
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   617
				this->widget[DEPOT_WIDGET_MATRIX].tooltips   = STR_883F_TRAINS_CLICK_ON_TRAIN_FOR;
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   618
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   619
				this->widget[DEPOT_WIDGET_BUILD].data        = STR_8815_NEW_VEHICLES;
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   620
				this->widget[DEPOT_WIDGET_BUILD].tooltips    = STR_8840_BUILD_NEW_TRAIN_VEHICLE;
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   621
				this->widget[DEPOT_WIDGET_CLONE].data        = STR_CLONE_TRAIN;
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   622
				this->widget[DEPOT_WIDGET_CLONE].tooltips    = STR_CLONE_TRAIN_DEPOT_INFO;
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   623
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   624
				this->widget[DEPOT_WIDGET_LOCATION].tooltips = STR_8842_CENTER_MAIN_VIEW_ON_TRAIN;
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   625
				this->widget[DEPOT_WIDGET_VEHICLE_LIST].data = STR_TRAIN;
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   626
				this->widget[DEPOT_WIDGET_VEHICLE_LIST].tooltips = STR_DEPOT_VEHICLE_ORDER_LIST_TRAIN_TIP;
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   627
				this->widget[DEPOT_WIDGET_AUTOREPLACE].tooltips = STR_DEPOT_AUTOREPLACE_TRAIN_TIP;
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   628
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   629
				/* Sprites */
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   630
				this->widget[DEPOT_WIDGET_SELL].data        = SPR_SELL_TRAIN;
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   631
				this->widget[DEPOT_WIDGET_SELL_ALL].data    = SPR_SELL_ALL_TRAIN;
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   632
				this->widget[DEPOT_WIDGET_AUTOREPLACE].data = SPR_REPLACE_TRAIN;
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   633
				break;
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   634
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   635
			case VEH_ROAD:
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   636
				this->widget[DEPOT_WIDGET_CAPTION].data      = STR_9003_ROAD_VEHICLE_DEPOT;
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   637
				this->widget[DEPOT_WIDGET_STOP_ALL].tooltips = STR_MASS_STOP_DEPOT_ROADVEH_TIP;
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   638
				this->widget[DEPOT_WIDGET_START_ALL].tooltips= STR_MASS_START_DEPOT_ROADVEH_TIP;
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   639
				this->widget[DEPOT_WIDGET_SELL].tooltips     = STR_9024_DRAG_ROAD_VEHICLE_TO_HERE;
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   640
				this->widget[DEPOT_WIDGET_SELL_ALL].tooltips = STR_DEPOT_SELL_ALL_BUTTON_ROADVEH_TIP;
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   641
				this->widget[DEPOT_WIDGET_MATRIX].tooltips   = STR_9022_VEHICLES_CLICK_ON_VEHICLE;
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   642
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   643
				this->widget[DEPOT_WIDGET_BUILD].data        = STR_9004_NEW_VEHICLES;
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   644
				this->widget[DEPOT_WIDGET_BUILD].tooltips    = STR_9023_BUILD_NEW_ROAD_VEHICLE;
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   645
				this->widget[DEPOT_WIDGET_CLONE].data        = STR_CLONE_ROAD_VEHICLE;
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   646
				this->widget[DEPOT_WIDGET_CLONE].tooltips    = STR_CLONE_ROAD_VEHICLE_DEPOT_INFO;
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   647
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   648
				this->widget[DEPOT_WIDGET_LOCATION].tooltips = STR_9025_CENTER_MAIN_VIEW_ON_ROAD;
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   649
				this->widget[DEPOT_WIDGET_VEHICLE_LIST].data = STR_LORRY;
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   650
				this->widget[DEPOT_WIDGET_VEHICLE_LIST].tooltips = STR_DEPOT_VEHICLE_ORDER_LIST_ROADVEH_TIP;
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   651
				this->widget[DEPOT_WIDGET_AUTOREPLACE].tooltips = STR_DEPOT_AUTOREPLACE_ROADVEH_TIP;
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   652
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   653
				/* Sprites */
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   654
				this->widget[DEPOT_WIDGET_SELL].data        = SPR_SELL_ROADVEH;
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   655
				this->widget[DEPOT_WIDGET_SELL_ALL].data    = SPR_SELL_ALL_ROADVEH;
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   656
				this->widget[DEPOT_WIDGET_AUTOREPLACE].data = SPR_REPLACE_ROADVEH;
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   657
				break;
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   658
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   659
			case VEH_SHIP:
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   660
				this->widget[DEPOT_WIDGET_CAPTION].data      = STR_9803_SHIP_DEPOT;
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   661
				this->widget[DEPOT_WIDGET_STOP_ALL].tooltips = STR_MASS_STOP_DEPOT_SHIP_TIP;
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   662
				this->widget[DEPOT_WIDGET_START_ALL].tooltips= STR_MASS_START_DEPOT_SHIP_TIP;
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   663
				this->widget[DEPOT_WIDGET_SELL].tooltips     = STR_9821_DRAG_SHIP_TO_HERE_TO_SELL;
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   664
				this->widget[DEPOT_WIDGET_SELL_ALL].tooltips = STR_DEPOT_SELL_ALL_BUTTON_SHIP_TIP;
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   665
				this->widget[DEPOT_WIDGET_MATRIX].tooltips   = STR_981F_SHIPS_CLICK_ON_SHIP_FOR;
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   666
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   667
				this->widget[DEPOT_WIDGET_BUILD].data        = STR_9804_NEW_SHIPS;
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   668
				this->widget[DEPOT_WIDGET_BUILD].tooltips    = STR_9820_BUILD_NEW_SHIP;
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   669
				this->widget[DEPOT_WIDGET_CLONE].data        = STR_CLONE_SHIP;
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   670
				this->widget[DEPOT_WIDGET_CLONE].tooltips    = STR_CLONE_SHIP_DEPOT_INFO;
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   671
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   672
				this->widget[DEPOT_WIDGET_LOCATION].tooltips = STR_9822_CENTER_MAIN_VIEW_ON_SHIP;
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   673
				this->widget[DEPOT_WIDGET_VEHICLE_LIST].data = STR_SHIP;
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   674
				this->widget[DEPOT_WIDGET_VEHICLE_LIST].tooltips = STR_DEPOT_VEHICLE_ORDER_LIST_SHIP_TIP;
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   675
				this->widget[DEPOT_WIDGET_AUTOREPLACE].tooltips = STR_DEPOT_AUTOREPLACE_SHIP_TIP;
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   676
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   677
				/* Sprites */
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   678
				this->widget[DEPOT_WIDGET_SELL].data        = SPR_SELL_SHIP;
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   679
				this->widget[DEPOT_WIDGET_SELL_ALL].data    = SPR_SELL_ALL_SHIP;
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   680
				this->widget[DEPOT_WIDGET_AUTOREPLACE].data = SPR_REPLACE_SHIP;
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   681
				break;
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   682
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   683
			case VEH_AIRCRAFT:
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   684
				this->widget[DEPOT_WIDGET_CAPTION].data      = STR_A002_AIRCRAFT_HANGAR;
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   685
				this->widget[DEPOT_WIDGET_STOP_ALL].tooltips = STR_MASS_STOP_HANGAR_TIP;
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   686
				this->widget[DEPOT_WIDGET_START_ALL].tooltips= STR_MASS_START_HANGAR_TIP;
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   687
				this->widget[DEPOT_WIDGET_SELL].tooltips     = STR_A023_DRAG_AIRCRAFT_TO_HERE_TO;
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   688
				this->widget[DEPOT_WIDGET_SELL_ALL].tooltips = STR_DEPOT_SELL_ALL_BUTTON_AIRCRAFT_TIP;
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   689
				this->widget[DEPOT_WIDGET_MATRIX].tooltips   = STR_A021_AIRCRAFT_CLICK_ON_AIRCRAFT;
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   690
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   691
				this->widget[DEPOT_WIDGET_BUILD].data        = STR_A003_NEW_AIRCRAFT;
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   692
				this->widget[DEPOT_WIDGET_BUILD].tooltips    = STR_A022_BUILD_NEW_AIRCRAFT;
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   693
				this->widget[DEPOT_WIDGET_CLONE].data        = STR_CLONE_AIRCRAFT;
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   694
				this->widget[DEPOT_WIDGET_CLONE].tooltips    = STR_CLONE_AIRCRAFT_INFO_HANGAR_WINDOW;
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   695
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   696
				this->widget[DEPOT_WIDGET_LOCATION].tooltips = STR_A024_CENTER_MAIN_VIEW_ON_HANGAR;
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   697
				this->widget[DEPOT_WIDGET_VEHICLE_LIST].data = STR_PLANE;
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   698
				this->widget[DEPOT_WIDGET_VEHICLE_LIST].tooltips = STR_DEPOT_VEHICLE_ORDER_LIST_AIRCRAFT_TIP;
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   699
				this->widget[DEPOT_WIDGET_AUTOREPLACE].tooltips = STR_DEPOT_AUTOREPLACE_AIRCRAFT_TIP;
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   700
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   701
				/* Sprites */
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   702
				this->widget[DEPOT_WIDGET_SELL].data        = SPR_SELL_AIRCRAFT;
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   703
				this->widget[DEPOT_WIDGET_SELL_ALL].data    = SPR_SELL_ALL_AIRCRAFT;
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   704
				this->widget[DEPOT_WIDGET_AUTOREPLACE].data = SPR_REPLACE_AIRCRAFT;
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   705
				break;
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   706
		}
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   707
	}
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   708
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   709
	void CreateDepotListWindow(VehicleType type)
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   710
	{
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   711
		this->type = type;
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   712
		_backup_orders_tile = 0;
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   713
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   714
		assert(IsPlayerBuildableVehicleType(type)); // ensure that we make the call with a valid type
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   715
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   716
		/* Resize the window according to the vehicle type */
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   717
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   718
		/* Set the number of blocks in each direction */
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   719
		this->vscroll.cap = _resize_cap[type][0];
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   720
		this->hscroll.cap = _resize_cap[type][1];
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   721
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   722
		/* Set the block size */
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   723
		this->resize.step_width  = _block_sizes[type][0];
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   724
		this->resize.step_height = _block_sizes[type][1];
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   725
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   726
		/* Enlarge the window to fit with the selected number of blocks of the selected size */
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   727
		ResizeWindow(this,
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   728
					_block_sizes[type][0] * this->hscroll.cap,
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   729
					_block_sizes[type][1] * this->vscroll.cap);
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   730
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   731
		if (type == VEH_TRAIN) {
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   732
			/* Make space for the horizontal scrollbar vertically, and the unit
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   733
			 * number, flag, and length counter horizontally. */
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   734
			ResizeWindow(this, 36, 12);
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   735
			/* substract the newly added space from the matrix since it was meant for the scrollbar */
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   736
			this->widget[DEPOT_WIDGET_MATRIX].bottom -= 12;
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   737
		}
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   738
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   739
		/* Set the minimum window size to the current window size */
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   740
		this->resize.width  = this->width;
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   741
		this->resize.height = this->height;
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   742
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   743
		this->SetupStringsForDepotWindow(type);
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   744
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   745
		this->widget[DEPOT_WIDGET_MATRIX].data =
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   746
			(this->vscroll.cap * 0x100) // number of rows to draw on the background
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   747
			+ (type == VEH_TRAIN ? 1 : this->hscroll.cap); // number of boxes in each row. Trains always have just one
5269
3f3eead5ace2 (svn r7410) -Codechange/Fix: Remove useless and unfollowable programmatic-resize, and implement it
Darkvater
parents: 5265
diff changeset
   748
3f3eead5ace2 (svn r7410) -Codechange/Fix: Remove useless and unfollowable programmatic-resize, and implement it
Darkvater
parents: 5265
diff changeset
   749
10523
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   750
		this->SetWidgetsHiddenState(type != VEH_TRAIN,
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   751
			DEPOT_WIDGET_H_SCROLL,
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   752
			DEPOT_WIDGET_SELL_CHAIN,
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   753
			WIDGET_LIST_END);
4638
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   754
10523
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   755
		ResizeDepotButtons(this);
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   756
	}
4638
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   757
10523
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   758
	virtual void OnInvalidateData(int data)
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   759
	{
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   760
		this->generate_list = true;
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   761
	}
4638
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   762
10523
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   763
	virtual void OnPaint()
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   764
	{
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   765
		if (this->generate_list) {
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   766
			/* Generate the vehicle list
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   767
			 * It's ok to use the wagon pointers for non-trains as they will be ignored */
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   768
			BuildDepotVehicleList(this->type, this->window_number,
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   769
				&this->vehicle_list, &this->engine_list_length, &this->engine_count,
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   770
				&this->wagon_list,   &this->wagon_list_length,  &this->wagon_count);
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   771
			this->generate_list = false;
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   772
			DepotSortList(this->vehicle_list, this->engine_count);
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   773
		}
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   774
		DrawDepotWindow(this);
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   775
	}
4935
aa0721b7ae79 (svn r6922) -Feature: Add proper cloning sprites and cursors, different for each vehicle. Big thanks
Darkvater
parents: 4800
diff changeset
   776
10523
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   777
	virtual void OnClick(Point pt, int widget)
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   778
	{
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   779
		switch (widget) {
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   780
			case DEPOT_WIDGET_MATRIX: // List
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   781
				this->DepotClick(pt.x, pt.y);
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   782
				break;
4638
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   783
10523
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   784
			case DEPOT_WIDGET_BUILD: // Build vehicle
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   785
				ResetObjectToPlace();
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   786
				ShowBuildVehicleWindow(this->window_number, this->type);
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   787
				break;
4640
cabffc571e55 (svn r6515) -Feature: added "start all" and "stop all" buttons to the depot windows
bjarni
parents: 4638
diff changeset
   788
10523
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   789
			case DEPOT_WIDGET_CLONE: // Clone button
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   790
				this->InvalidateWidget(DEPOT_WIDGET_CLONE);
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   791
				this->ToggleWidgetLoweredState(DEPOT_WIDGET_CLONE);
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   792
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   793
				if (this->IsWidgetLowered(DEPOT_WIDGET_CLONE)) {
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   794
					static const CursorID clone_icons[] = {
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   795
						SPR_CURSOR_CLONE_TRAIN, SPR_CURSOR_CLONE_ROADVEH,
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   796
						SPR_CURSOR_CLONE_SHIP, SPR_CURSOR_CLONE_AIRPLANE
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   797
					};
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   798
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   799
					_place_clicked_vehicle = NULL;
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   800
					SetObjectToPlaceWnd(clone_icons[this->type], PAL_NONE, VHM_RECT, this);
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   801
				} else {
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   802
					ResetObjectToPlace();
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   803
				}
4640
cabffc571e55 (svn r6515) -Feature: added "start all" and "stop all" buttons to the depot windows
bjarni
parents: 4638
diff changeset
   804
					break;
cabffc571e55 (svn r6515) -Feature: added "start all" and "stop all" buttons to the depot windows
bjarni
parents: 4638
diff changeset
   805
10523
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   806
			case DEPOT_WIDGET_LOCATION:
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   807
				if (_ctrl_pressed) {
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   808
					ShowExtraViewPortWindow(this->window_number);
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   809
				} else {
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   810
					ScrollMainWindowToTile(this->window_number);
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   811
				}
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   812
				break;
4638
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   813
10523
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   814
			case DEPOT_WIDGET_STOP_ALL:
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   815
			case DEPOT_WIDGET_START_ALL:
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   816
				DoCommandP(this->window_number, 0, this->type | (widget == DEPOT_WIDGET_START_ALL ? (1 << 5) : 0), NULL, CMD_MASS_START_STOP);
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   817
				break;
4638
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   818
10523
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   819
			case DEPOT_WIDGET_SELL_ALL:
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   820
				/* Only open the confimation window if there are anything to sell */
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   821
				if (this->engine_count != 0 || this->wagon_count != 0) {
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   822
					static const StringID confirm_captions[] = {
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   823
						STR_8800_TRAIN_DEPOT,
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   824
						STR_9003_ROAD_VEHICLE_DEPOT,
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   825
						STR_9803_SHIP_DEPOT,
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   826
						STR_A002_AIRCRAFT_HANGAR
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   827
					};
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   828
					TileIndex tile = this->window_number;
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   829
					byte vehtype = this->type;
4638
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   830
10523
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   831
					SetDParam(0, (vehtype == VEH_AIRCRAFT) ? GetStationIndex(tile) : GetDepotByTile(tile)->town_index);
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   832
					ShowQuery(
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   833
						confirm_captions[vehtype],
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   834
						STR_DEPOT_SELL_CONFIRMATION_TEXT,
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   835
						this,
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   836
						DepotSellAllConfirmationCallback
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   837
					);
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   838
				}
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   839
				break;
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   840
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   841
			case DEPOT_WIDGET_VEHICLE_LIST:
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   842
				ShowVehicleListWindow(GetTileOwner(this->window_number), this->type, (TileIndex)this->window_number);
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   843
				break;
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   844
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   845
			case DEPOT_WIDGET_AUTOREPLACE:
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   846
				DoCommandP(this->window_number, this->type, 0, NULL, CMD_DEPOT_MASS_AUTOREPLACE);
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   847
				break;
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   848
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   849
		}
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   850
	}
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   851
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   852
	virtual void OnPlaceObject(Point pt, TileIndex tile)
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   853
	{
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   854
		const Vehicle *v = CheckMouseOverVehicle();
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   855
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   856
		if (v != NULL) HandleCloneVehClick(v, this);
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   857
	}
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   858
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   859
	virtual void OnPlaceObjectAbort()
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   860
	{
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   861
		/* abort clone */
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   862
		this->RaiseWidget(DEPOT_WIDGET_CLONE);
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   863
		this->InvalidateWidget(DEPOT_WIDGET_CLONE);
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   864
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   865
		/* abort drag & drop */
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   866
		this->sel = INVALID_VEHICLE;
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   867
		this->InvalidateWidget(DEPOT_WIDGET_MATRIX);
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   868
	};
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   869
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   870
	/* check if a vehicle in a depot was clicked.. */
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   871
	virtual void OnMouseLoop()
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   872
	{
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   873
		const Vehicle *v = _place_clicked_vehicle;
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   874
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   875
		/* since OTTD checks all open depot windows, we will make sure that it triggers the one with a clicked clone button */
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   876
		if (v != NULL && this->IsWidgetLowered(DEPOT_WIDGET_CLONE)) {
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   877
			_place_clicked_vehicle = NULL;
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   878
			HandleCloneVehClick(v, this);
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   879
		}
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   880
	}
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   881
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   882
	virtual void OnDragDrop(Point pt, int widget)
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   883
	{
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   884
		switch (widget) {
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   885
			case DEPOT_WIDGET_MATRIX: {
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   886
				Vehicle *v;
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   887
				VehicleID sel = this->sel;
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   888
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   889
				this->sel = INVALID_VEHICLE;
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   890
				this->SetDirty();
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   891
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   892
				if (this->type == VEH_TRAIN) {
10547
fe1e87e92e20 (svn r13091) -Fix: certain compilers give false warning about uninitialized variable
smatz
parents: 10535
diff changeset
   893
					GetDepotVehiclePtData gdvp = { NULL, NULL };
10523
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   894
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   895
					if (this->GetVehicleFromDepotWndPt(pt.x, pt.y, &v, &gdvp) == MODE_DRAG_VEHICLE &&
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   896
						sel != INVALID_VEHICLE) {
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   897
						if (gdvp.wagon != NULL && gdvp.wagon->index == sel && _ctrl_pressed) {
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   898
							DoCommandP(GetVehicle(sel)->tile, GetVehicle(sel)->index, true, NULL, CMD_REVERSE_TRAIN_DIRECTION | CMD_MSG(STR_9033_CAN_T_MAKE_VEHICLE_TURN));
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   899
						} else if (gdvp.wagon == NULL || gdvp.wagon->index != sel) {
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   900
							TrainDepotMoveVehicle(gdvp.wagon, sel, gdvp.head);
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   901
						} else if (gdvp.head != NULL && IsFrontEngine(gdvp.head)) {
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   902
							ShowVehicleViewWindow(gdvp.head);
4638
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   903
						}
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   904
					}
10523
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   905
				} else if (this->GetVehicleFromDepotWndPt(pt.x, pt.y, &v, NULL) == MODE_DRAG_VEHICLE &&
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   906
					v != NULL &&
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   907
					sel == v->index) {
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   908
					ShowVehicleViewWindow(v);
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   909
				}
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   910
			} break;
4638
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   911
10523
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   912
			case DEPOT_WIDGET_SELL: case DEPOT_WIDGET_SELL_CHAIN:
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   913
				if (!this->IsWidgetDisabled(DEPOT_WIDGET_SELL) &&
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   914
					this->sel != INVALID_VEHICLE) {
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   915
					Vehicle *v;
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   916
					uint command;
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   917
					int sell_cmd;
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   918
					bool is_engine;
9324
bf9cc84b889d (svn r12576) -Feature(tte) [FS#337]: highlight vehicle chain when dragging in the group and depot GUI if appropriate
smatz
parents: 9280
diff changeset
   919
10523
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   920
					if (this->IsWidgetDisabled(widget)) return;
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   921
					if (this->sel == INVALID_VEHICLE) return;
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   922
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   923
					this->HandleButtonClick(widget);
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   924
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   925
					v = GetVehicle(this->sel);
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   926
					this->sel = INVALID_VEHICLE;
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   927
					this->SetDirty();
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   928
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   929
					sell_cmd = (v->type == VEH_TRAIN && (widget == DEPOT_WIDGET_SELL_CHAIN || _ctrl_pressed)) ? 1 : 0;
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   930
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   931
					is_engine = (!(v->type == VEH_TRAIN && !IsFrontEngine(v)));
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   932
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   933
					if (is_engine) {
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   934
						_backup_orders_tile = v->tile;
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   935
						BackupVehicleOrders(v);
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   936
					}
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   937
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   938
					switch (v->type) {
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   939
						case VEH_TRAIN:    command = CMD_SELL_RAIL_WAGON | CMD_MSG(STR_8839_CAN_T_SELL_RAILROAD_VEHICLE); break;
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   940
						case VEH_ROAD:     command = CMD_SELL_ROAD_VEH | CMD_MSG(STR_9014_CAN_T_SELL_ROAD_VEHICLE);       break;
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   941
						case VEH_SHIP:     command = CMD_SELL_SHIP | CMD_MSG(STR_980C_CAN_T_SELL_SHIP);                   break;
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   942
						case VEH_AIRCRAFT: command = CMD_SELL_AIRCRAFT | CMD_MSG(STR_A01C_CAN_T_SELL_AIRCRAFT);           break;
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   943
						default: NOT_REACHED(); command = 0;
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   944
					}
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   945
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   946
					if (!DoCommandP(v->tile, v->index, sell_cmd, NULL, command) && is_engine) _backup_orders_tile = 0;
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   947
				}
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   948
				break;
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   949
			default:
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   950
				this->sel = INVALID_VEHICLE;
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   951
				this->SetDirty();
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   952
		}
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   953
		_cursor.vehchain = false;
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   954
	}
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   955
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   956
	virtual void OnResize(Point new_size, Point delta)
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   957
	{
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   958
		this->vscroll.cap += delta.y / (int)this->resize.step_height;
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   959
		this->hscroll.cap += delta.x / (int)this->resize.step_width;
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   960
		this->widget[DEPOT_WIDGET_MATRIX].data = (this->vscroll.cap << 8) + (this->type == VEH_TRAIN ? 1 : this->hscroll.cap);
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   961
		ResizeDepotButtons(this);
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   962
	}
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   963
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   964
	virtual bool OnCTRLStateChange()
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   965
	{
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   966
		if (this->sel != INVALID_VEHICLE) {
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   967
			_cursor.vehchain = _ctrl_pressed;
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   968
			this->InvalidateWidget(DEPOT_WIDGET_MATRIX);
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   969
		}
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   970
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   971
		return true;
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   972
	}
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   973
};
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   974
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   975
static void DepotSellAllConfirmationCallback(Window *win, bool confirmed)
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   976
{
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   977
	if (confirmed) {
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   978
		DepotWindow *w = (DepotWindow*)win;
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   979
		TileIndex tile = w->window_number;
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   980
		byte vehtype = w->type;
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   981
		DoCommandP(tile, vehtype, 0, NULL, CMD_DEPOT_SELL_ALL_VEHICLES);
4638
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   982
	}
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   983
}
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   984
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   985
/** Opens a depot window
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   986
 * @param tile The tile where the depot/hangar is located
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   987
 * @param type The type of vehicles in the depot
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   988
 */
7134
c5a90dd41166 (svn r9869) -Codechange: replace some bytes with VehicleType, i.e. more type strictness.
rubidium
parents: 7117
diff changeset
   989
void ShowDepotWindow(TileIndex tile, VehicleType type)
4638
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   990
{
10523
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   991
	DepotWindow *w;
4638
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   992
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   993
	switch (type) {
5269
3f3eead5ace2 (svn r7410) -Codechange/Fix: Remove useless and unfollowable programmatic-resize, and implement it
Darkvater
parents: 5265
diff changeset
   994
		default: NOT_REACHED();
6585
7da94b26498a (svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium
parents: 6574
diff changeset
   995
		case VEH_TRAIN:
10523
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   996
			w = AllocateWindowDescFront<DepotWindow>(&_train_depot_desc, tile); break;
6585
7da94b26498a (svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium
parents: 6574
diff changeset
   997
		case VEH_ROAD:
10523
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
   998
			w = AllocateWindowDescFront<DepotWindow>(&_road_depot_desc, tile); break;
6585
7da94b26498a (svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium
parents: 6574
diff changeset
   999
		case VEH_SHIP:
10523
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
  1000
			w = AllocateWindowDescFront<DepotWindow>(&_ship_depot_desc, tile); break;
6585
7da94b26498a (svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium
parents: 6574
diff changeset
  1001
		case VEH_AIRCRAFT:
10523
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
  1002
			w = AllocateWindowDescFront<DepotWindow>(&_aircraft_depot_desc, tile); break;
4638
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
  1003
	}
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
  1004
10554
ca1ea275fb10 (svn r13098) -Fix [FS#2016]: segmentation fault on opening an already opened depot.
rubidium
parents: 10547
diff changeset
  1005
	if (w == NULL) return;
ca1ea275fb10 (svn r13098) -Fix [FS#2016]: segmentation fault on opening an already opened depot.
rubidium
parents: 10547
diff changeset
  1006
10523
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
  1007
	w->caption_color = GetTileOwner(tile);
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
  1008
	w->CreateDepotListWindow(type);
4638
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
  1009
}
5255
b8445fda3fe2 (svn r7385) -Fix: FS#418 Deleting Train in depot with autoreplace failes
bjarni
parents: 5125
diff changeset
  1010
b8445fda3fe2 (svn r7385) -Fix: FS#418 Deleting Train in depot with autoreplace failes
bjarni
parents: 5125
diff changeset
  1011
/** Removes the highlight of a vehicle in a depot window
b8445fda3fe2 (svn r7385) -Fix: FS#418 Deleting Train in depot with autoreplace failes
bjarni
parents: 5125
diff changeset
  1012
 * @param *v Vehicle to remove all highlights from
b8445fda3fe2 (svn r7385) -Fix: FS#418 Deleting Train in depot with autoreplace failes
bjarni
parents: 5125
diff changeset
  1013
 */
b8445fda3fe2 (svn r7385) -Fix: FS#418 Deleting Train in depot with autoreplace failes
bjarni
parents: 5125
diff changeset
  1014
void DeleteDepotHighlightOfVehicle(const Vehicle *v)
b8445fda3fe2 (svn r7385) -Fix: FS#418 Deleting Train in depot with autoreplace failes
bjarni
parents: 5125
diff changeset
  1015
{
10523
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
  1016
	DepotWindow *w;
5255
b8445fda3fe2 (svn r7385) -Fix: FS#418 Deleting Train in depot with autoreplace failes
bjarni
parents: 5125
diff changeset
  1017
5260
6d1a560dd028 (svn r7390) -Codechange r7386: only loop though the windows to find a depot window to unhighlight a vehicle in if there is a vehicle on the mouse pointer
bjarni
parents: 5256
diff changeset
  1018
	/* If we haven't got any vehicles on the mouse pointer, we haven't got any highlighted in any depots either
10523
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
  1019
	 * If that is the case, we can skip looping though the windows and save time
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
  1020
	 */
5260
6d1a560dd028 (svn r7390) -Codechange r7386: only loop though the windows to find a depot window to unhighlight a vehicle in if there is a vehicle on the mouse pointer
bjarni
parents: 5256
diff changeset
  1021
	if (_special_mouse_mode != WSM_DRAGDROP) return;
6d1a560dd028 (svn r7390) -Codechange r7386: only loop though the windows to find a depot window to unhighlight a vehicle in if there is a vehicle on the mouse pointer
bjarni
parents: 5256
diff changeset
  1022
10523
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
  1023
	w = dynamic_cast<DepotWindow*>(FindWindowById(WC_VEHICLE_DEPOT, v->tile));
5265
a15469628808 (svn r7403) -Codechange (r7386, r7385): Use available functions to find a window instead of doing
Darkvater
parents: 5260
diff changeset
  1024
	if (w != NULL) {
10523
07a6e2dc807a (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium
parents: 10508
diff changeset
  1025
		w->sel = INVALID_VEHICLE;
5265
a15469628808 (svn r7403) -Codechange (r7386, r7385): Use available functions to find a window instead of doing
Darkvater
parents: 5260
diff changeset
  1026
		ResetObjectToPlace();
5255
b8445fda3fe2 (svn r7385) -Fix: FS#418 Deleting Train in depot with autoreplace failes
bjarni
parents: 5125
diff changeset
  1027
	}
b8445fda3fe2 (svn r7385) -Fix: FS#418 Deleting Train in depot with autoreplace failes
bjarni
parents: 5125
diff changeset
  1028
}