depot_gui.c
author bjarni
Thu, 28 Sep 2006 19:56:29 +0000
changeset 4667 78fbb91c6c63
parent 4663 2e01fabb902f
child 4668 8b6035c51188
permissions -rw-r--r--
(svn r6561) -Fix r6513: [depot window] fixed an off by one error, that caused planes and ships to be drawn one pixel lower for each row
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
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
     3
#include "stdafx.h"
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
     4
#include "openttd.h"
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
     5
#include "functions.h"
4654
71048359c6ac (svn r6530) -Fix r6529: added missing header file (oops)
bjarni
parents: 4653
diff changeset
     6
#include "train.h"
71048359c6ac (svn r6530) -Fix r6529: added missing header file (oops)
bjarni
parents: 4653
diff changeset
     7
#include "roadveh.h"
4638
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
     8
#include "ship.h"
4653
091f530bae28 (svn r6529) -Fix r6513: [depot window] added missing switch in CcCloneVehicle()
bjarni
parents: 4652
diff changeset
     9
#include "aircraft.h"
4638
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
    10
#include "table/strings.h"
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
    11
#include "table/sprites.h"
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
    12
#include "gui.h"
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
    13
#include "gfx.h"
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
    14
#include "vehicle.h"
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
    15
#include "viewport.h"
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
    16
#include "command.h"
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
    17
#include "depot.h"
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
    18
#include "vehicle_gui.h"
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
    19
#include "station_map.h"
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
    20
#include "newgrf_engine.h"
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
    21
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
    22
enum {
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
    23
	WIDGET_DEPOT_MOVE_NONE   = 0 << 0,
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
    24
	WIDGET_DEPOT_MOVE_RIGHT  = 1 << 0,
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
    25
	WIDGET_DEPOT_MOVE_LEFT   = 1 << 1,
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
    26
	WIDGET_DEPOT_MOVE_TOP    = 1 << 2,
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
    27
	WIDGET_DEPOT_MOVE_BOTTOM = 1 << 3,
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
    28
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
	DEPOT_MOVE_NONE               = WIDGET_DEPOT_MOVE_NONE,
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
    30
	DEPOT_STRETCH_RIGHT           = WIDGET_DEPOT_MOVE_RIGHT,
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
    31
	DEPOT_MOVE_RIGHT              = WIDGET_DEPOT_MOVE_RIGHT | WIDGET_DEPOT_MOVE_LEFT,
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
    32
	DEPOT_STRETCH_DOWN            = WIDGET_DEPOT_MOVE_BOTTOM,
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
	DEPOT_MOVE_DOWN               = WIDGET_DEPOT_MOVE_BOTTOM | WIDGET_DEPOT_MOVE_TOP,
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
	DEPOT_STRETCH_DOWN_RIGHT      = DEPOT_STRETCH_DOWN | DEPOT_STRETCH_RIGHT,
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
	DEPOT_MOVE_DOWN_RIGHT         = DEPOT_MOVE_RIGHT | DEPOT_MOVE_DOWN,
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
	DEPOT_MOVE_RIGHT_STRETCH_DOWN = DEPOT_MOVE_RIGHT | DEPOT_STRETCH_DOWN,
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
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
    39
/*
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
    40
 * 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
    41
 * 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
    42
 * 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
    43
 */
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
    44
4646
c6f774de4f6f (svn r6522) -Feature: [depot window] the buttons are now "scaled" resized
bjarni
parents: 4644
diff changeset
    45
/* Names of the widgets. Keep them in the same order as in the widget array */
c6f774de4f6f (svn r6522) -Feature: [depot window] the buttons are now "scaled" resized
bjarni
parents: 4644
diff changeset
    46
typedef enum DepotWindowWidgets {
c6f774de4f6f (svn r6522) -Feature: [depot window] the buttons are now "scaled" resized
bjarni
parents: 4644
diff changeset
    47
	DEPOT_WIDGET_CLOSEBOX = 0,
c6f774de4f6f (svn r6522) -Feature: [depot window] the buttons are now "scaled" resized
bjarni
parents: 4644
diff changeset
    48
	DEPOT_WIDGET_CAPTION,
c6f774de4f6f (svn r6522) -Feature: [depot window] the buttons are now "scaled" resized
bjarni
parents: 4644
diff changeset
    49
	DEPOT_WIDGET_STICKY,
c6f774de4f6f (svn r6522) -Feature: [depot window] the buttons are now "scaled" resized
bjarni
parents: 4644
diff changeset
    50
	DEPOT_WIDGET_STOP_ALL,
c6f774de4f6f (svn r6522) -Feature: [depot window] the buttons are now "scaled" resized
bjarni
parents: 4644
diff changeset
    51
	DEPOT_WIDGET_START_ALL,
c6f774de4f6f (svn r6522) -Feature: [depot window] the buttons are now "scaled" resized
bjarni
parents: 4644
diff changeset
    52
	DEPOT_WIDGET_SELL,
4659
2f99f35d5813 (svn r6542) -Feature: [depot window] added a "sell all vehicles in depot" button
bjarni
parents: 4654
diff changeset
    53
	DEPOT_WIDGET_SELL_CHAIN,
4646
c6f774de4f6f (svn r6522) -Feature: [depot window] the buttons are now "scaled" resized
bjarni
parents: 4644
diff changeset
    54
	DEPOT_WIDGET_SELL_ALL,
c6f774de4f6f (svn r6522) -Feature: [depot window] the buttons are now "scaled" resized
bjarni
parents: 4644
diff changeset
    55
	DEPOT_WIDGET_MATRIX,
c6f774de4f6f (svn r6522) -Feature: [depot window] the buttons are now "scaled" resized
bjarni
parents: 4644
diff changeset
    56
	DEPOT_WIDGET_V_SCROLL, // Vertical scrollbar
c6f774de4f6f (svn r6522) -Feature: [depot window] the buttons are now "scaled" resized
bjarni
parents: 4644
diff changeset
    57
	DEPOT_WIDGET_H_SCROLL, // Horizontal scrollbar
c6f774de4f6f (svn r6522) -Feature: [depot window] the buttons are now "scaled" resized
bjarni
parents: 4644
diff changeset
    58
	DEPOT_WIDGET_BUILD,
c6f774de4f6f (svn r6522) -Feature: [depot window] the buttons are now "scaled" resized
bjarni
parents: 4644
diff changeset
    59
	DEPOT_WIDGET_CLONE,
c6f774de4f6f (svn r6522) -Feature: [depot window] the buttons are now "scaled" resized
bjarni
parents: 4644
diff changeset
    60
	DEPOT_WIDGET_LOCATION,
4662
a20121e5442b (svn r6552) -Feature: [depot window] added a "autoreplace all vehicles in depot" button
bjarni
parents: 4659
diff changeset
    61
	DEPOT_WIDGET_AUTOREPLACE,
4646
c6f774de4f6f (svn r6522) -Feature: [depot window] the buttons are now "scaled" resized
bjarni
parents: 4644
diff changeset
    62
	DEPOT_WIDGET_RESIZE,
4651
bf6abb428dc8 (svn r6527) -Codechange: [depot window] added asserts to ensure that widget names, widget array and array of resize info stays the same length
bjarni
parents: 4650
diff changeset
    63
	DEPOT_WIDGET_LAST, // used to assert if DepotWindowWidgets and widget_moves got different lengths. Due to this usage, it needs to be last
4646
c6f774de4f6f (svn r6522) -Feature: [depot window] the buttons are now "scaled" resized
bjarni
parents: 4644
diff changeset
    64
} DepotWindowWidget;
4638
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
    65
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
    66
/* Define how to move each widget. The order is important */
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
    67
static const byte widget_moves[] = {
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
    68
	DEPOT_MOVE_NONE,               // DEPOT_WIDGET_CLOSEBOX
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
    69
	DEPOT_STRETCH_RIGHT,           // DEPOT_WIDGET_CAPTION
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
    70
	DEPOT_MOVE_RIGHT,              // DEPOT_WIDGET_STICKY
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
    71
	DEPOT_MOVE_RIGHT,              // DEPOT_WIDGET_STOP_ALL
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
    72
	DEPOT_MOVE_RIGHT,              // DEPOT_WIDGET_START_ALL
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
    73
	DEPOT_MOVE_RIGHT,              // DEPOT_WIDGET_SELL
4659
2f99f35d5813 (svn r6542) -Feature: [depot window] added a "sell all vehicles in depot" button
bjarni
parents: 4654
diff changeset
    74
	DEPOT_MOVE_NONE,               // DEPOT_WIDGET_SELL_CHAIN
2f99f35d5813 (svn r6542) -Feature: [depot window] added a "sell all vehicles in depot" button
bjarni
parents: 4654
diff changeset
    75
	DEPOT_MOVE_DOWN_RIGHT,         // DEPOT_WIDGET_SELL_ALL
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
    76
	DEPOT_STRETCH_DOWN_RIGHT,      // DEPOT_WIDGET_MATRIX
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
    77
	DEPOT_MOVE_RIGHT_STRETCH_DOWN, // DEPOT_WIDGET_V_SCROLL
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
    78
	DEPOT_MOVE_NONE,               // DEPOT_WIDGET_H_SCROLL
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
    79
	DEPOT_MOVE_DOWN,               // DEPOT_WIDGET_BUILD
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
    80
	DEPOT_MOVE_DOWN,               // DEPOT_WIDGET_CLONE
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
    81
	DEPOT_MOVE_DOWN,               // DEPOT_WIDGET_LOCATION
4662
a20121e5442b (svn r6552) -Feature: [depot window] added a "autoreplace all vehicles in depot" button
bjarni
parents: 4659
diff changeset
    82
	DEPOT_MOVE_DOWN_RIGHT,         // DEPOT_WIDGET_AUTOREPLACE
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
    83
	DEPOT_MOVE_DOWN_RIGHT,         // DEPOT_WIDGET_RESIZE
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
    84
};
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
    85
4638
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
    86
/* Widget array for all depot windows.
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
    87
 * If a widget is needed in some windows only (like train specific), add it for all windows
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
    88
 * and use w->hidden_state in ShowDepotWindow() to remove it in the windows where it should not be
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
    89
 * 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
    90
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
    91
/* 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
    92
 * 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
    93
 * 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
    94
 *    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
    95
 */
4638
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
    96
static const Widget _depot_widgets[] = {
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
    97
	{   WWT_CLOSEBOX,   RESIZE_NONE,    14,     0,    10,     0,    13, STR_00C5,            STR_018B_CLOSE_WINDOW},            // DEPOT_WIDGET_CLOSEBOX
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
    98
	{    WWT_CAPTION,  RESIZE_RIGHT,    14,    11,   292,     0,    13, 0x0,                 STR_018C_WINDOW_TITLE_DRAG_THIS},  // DEPOT_WIDGET_CAPTION
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
    99
	{  WWT_STICKYBOX,     RESIZE_LR,    14,   293,   304,     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
   100
cabffc571e55 (svn r6515) -Feature: added "start all" and "stop all" buttons to the depot windows
bjarni
parents: 4638
diff changeset
   101
	{ WWT_PUSHIMGBTN,     RESIZE_LR,    14,   270,   280,    14,    25, SPR_FLAG_VEH_STOPPED,STR_MASS_STOP_DEPOT_TOOLTIP},      // DEPOT_WIDGET_STOP_ALL
cabffc571e55 (svn r6515) -Feature: added "start all" and "stop all" buttons to the depot windows
bjarni
parents: 4638
diff changeset
   102
	{ WWT_PUSHIMGBTN,     RESIZE_LR,    14,   281,   292,    14,    25, SPR_FLAG_VEH_RUNNING,STR_MASS_START_DEPOT_TOOLTIP},     // DEPOT_WIDGET_START_ALL
4659
2f99f35d5813 (svn r6542) -Feature: [depot window] added a "sell all vehicles in depot" button
bjarni
parents: 4654
diff changeset
   103
	{     WWT_IMGBTN,    RESIZE_LRB,    14,   270,   292,    26,    60, 0x2A9,               STR_NULL},                         // DEPOT_WIDGET_SELL
2f99f35d5813 (svn r6542) -Feature: [depot window] added a "sell all vehicles in depot" button
bjarni
parents: 4654
diff changeset
   104
	{      WWT_PANEL,   RESIZE_LRTB,    14,   326,   348,     0,     0, 0x2BF,               STR_DRAG_WHOLE_TRAIN_TO_SELL_TIP}, // DEPOT_WIDGET_SELL_CHAIN, trains only
2f99f35d5813 (svn r6542) -Feature: [depot window] added a "sell all vehicles in depot" button
bjarni
parents: 4654
diff changeset
   105
	{ WWT_PUSHIMGBTN,   RESIZE_LRTB,    14,   270,   292,    61,    83, 0x0,                 STR_DEPOT_SELL_ALL_BUTTON_TIP},    // DEPOT_WIDGET_SELL_ALL
4638
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   106
4659
2f99f35d5813 (svn r6542) -Feature: [depot window] added a "sell all vehicles in depot" button
bjarni
parents: 4654
diff changeset
   107
	{     WWT_MATRIX,     RESIZE_RB,    14,     0,   269,    14,    83, 0x0,                 STR_NULL},                         // DEPOT_WIDGET_MATRIX
2f99f35d5813 (svn r6542) -Feature: [depot window] added a "sell all vehicles in depot" button
bjarni
parents: 4654
diff changeset
   108
	{  WWT_SCROLLBAR,    RESIZE_LRB,    14,   293,   304,    14,    83, 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
   109
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   110
	{ WWT_HSCROLLBAR,    RESIZE_RTB,    14,     0,   325,    98,   109, 0x0,                 STR_HSCROLL_BAR_SCROLLS_LIST},     // DEPOT_WIDGET_H_SCROLL, trains only
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
	/* 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
   113
	 * This calculation is based on right in DEPOT_WIDGET_LOCATION and it presumes left of DEPOT_WIDGET_BUILD is 0            */
4659
2f99f35d5813 (svn r6542) -Feature: [depot window] added a "sell all vehicles in depot" button
bjarni
parents: 4654
diff changeset
   114
	{ WWT_PUSHTXTBTN,     RESIZE_TB,    14,     0,    96,    84,    95, 0x0,                 STR_NULL},                         // DEPOT_WIDGET_BUILD
2f99f35d5813 (svn r6542) -Feature: [depot window] added a "sell all vehicles in depot" button
bjarni
parents: 4654
diff changeset
   115
	{WWT_NODISTXTBTN,     RESIZE_TB,    14,    97,   194,    84,    95, 0x0,                 STR_NULL},                         // DEPOT_WIDGET_CLONE
2f99f35d5813 (svn r6542) -Feature: [depot window] added a "sell all vehicles in depot" button
bjarni
parents: 4654
diff changeset
   116
	{ WWT_PUSHTXTBTN,     RESIZE_TB,    14,   195,   292,    84,    95, STR_00E4_LOCATION,   STR_NULL},                         // DEPOT_WIDGET_LOCATION
4662
a20121e5442b (svn r6552) -Feature: [depot window] added a "autoreplace all vehicles in depot" button
bjarni
parents: 4659
diff changeset
   117
	{ WWT_PUSHIMGBTN,   RESIZE_LRTB,    14,   281,   292,    84,    95, 0x0,                 STR_DEPOT_AUTOREPLACE_TIP},        // DEPOT_WIDGET_AUTOREPLACE
4659
2f99f35d5813 (svn r6542) -Feature: [depot window] added a "sell all vehicles in depot" button
bjarni
parents: 4654
diff changeset
   118
	{  WWT_RESIZEBOX,   RESIZE_LRTB,    14,   293,   304,    84,    95, 0x0,                 STR_RESIZE_BUTTON},                // DEPOT_WIDGET_RESIZE
4638
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   119
	{   WIDGETS_END},
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
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   122
static void DepotWndProc(Window *w, WindowEvent *e);
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   123
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   124
static const WindowDesc _train_depot_desc = {
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   125
	-1, -1, 361, 122,
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   126
	WC_VEHICLE_DEPOT,0,
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   127
	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
   128
	_depot_widgets,
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   129
	DepotWndProc
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   130
};
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   131
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   132
static const WindowDesc _road_depot_desc = {
4659
2f99f35d5813 (svn r6542) -Feature: [depot window] added a "sell all vehicles in depot" button
bjarni
parents: 4654
diff changeset
   133
	-1, -1, 315, 82,
4638
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   134
	WC_VEHICLE_DEPOT,0,
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   135
	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
   136
	_depot_widgets,
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   137
	DepotWndProc
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   138
};
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   139
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   140
static const WindowDesc _ship_depot_desc = {
4659
2f99f35d5813 (svn r6542) -Feature: [depot window] added a "sell all vehicles in depot" button
bjarni
parents: 4654
diff changeset
   141
	-1, -1, 305, 96,
4638
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   142
	WC_VEHICLE_DEPOT,0,
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   143
	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
   144
	_depot_widgets,
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   145
	DepotWndProc
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   146
};
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   147
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   148
static const WindowDesc _aircraft_depot_desc = {
4659
2f99f35d5813 (svn r6542) -Feature: [depot window] added a "sell all vehicles in depot" button
bjarni
parents: 4654
diff changeset
   149
	-1, -1, 331, 96,
4638
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   150
	WC_VEHICLE_DEPOT,0,
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   151
	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
   152
	_depot_widgets,
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   153
	DepotWndProc
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
extern int WagonLengthToPixels(int len);
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
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
   159
{
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   160
	if (!success) return;
4653
091f530bae28 (svn r6529) -Fix r6513: [depot window] added missing switch in CcCloneVehicle()
bjarni
parents: 4652
diff changeset
   161
	switch(GetVehicle(p1)->type) {
091f530bae28 (svn r6529) -Fix r6513: [depot window] added missing switch in CcCloneVehicle()
bjarni
parents: 4652
diff changeset
   162
		case VEH_Train:    CcCloneTrain(   true, tile, p1, p2); break;
091f530bae28 (svn r6529) -Fix r6513: [depot window] added missing switch in CcCloneVehicle()
bjarni
parents: 4652
diff changeset
   163
		case VEH_Road:     CcCloneRoadVeh( true, tile, p1, p2); break;
091f530bae28 (svn r6529) -Fix r6513: [depot window] added missing switch in CcCloneVehicle()
bjarni
parents: 4652
diff changeset
   164
		case VEH_Ship:     CcCloneShip(    true, tile, p1, p2); break;
091f530bae28 (svn r6529) -Fix r6513: [depot window] added missing switch in CcCloneVehicle()
bjarni
parents: 4652
diff changeset
   165
		case VEH_Aircraft: CcCloneAircraft(true, tile, p1, p2); break;
091f530bae28 (svn r6529) -Fix r6513: [depot window] added missing switch in CcCloneVehicle()
bjarni
parents: 4652
diff changeset
   166
	}
4638
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   167
}
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   168
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   169
static inline void ShowVehicleViewWindow(const Vehicle *v)
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
	switch (v->type) {
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   172
		case VEH_Train:    ShowTrainViewWindow(v);    break;
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   173
		case VEH_Road:     ShowRoadVehViewWindow(v);  break;
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   174
		case VEH_Ship:     ShowShipViewWindow(v);     break;
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   175
		case VEH_Aircraft: ShowAircraftViewWindow(v); break;
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   176
		default: NOT_REACHED();
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   177
	}
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   178
}
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   179
4659
2f99f35d5813 (svn r6542) -Feature: [depot window] added a "sell all vehicles in depot" button
bjarni
parents: 4654
diff changeset
   180
static void DepotSellAllWndProc(Window *w, WindowEvent *e)
2f99f35d5813 (svn r6542) -Feature: [depot window] added a "sell all vehicles in depot" button
bjarni
parents: 4654
diff changeset
   181
{
2f99f35d5813 (svn r6542) -Feature: [depot window] added a "sell all vehicles in depot" button
bjarni
parents: 4654
diff changeset
   182
	switch (e->event) {
2f99f35d5813 (svn r6542) -Feature: [depot window] added a "sell all vehicles in depot" button
bjarni
parents: 4654
diff changeset
   183
		case WE_PAINT:
2f99f35d5813 (svn r6542) -Feature: [depot window] added a "sell all vehicles in depot" button
bjarni
parents: 4654
diff changeset
   184
			if (WP(w, depot_d).type == VEH_Aircraft) {
2f99f35d5813 (svn r6542) -Feature: [depot window] added a "sell all vehicles in depot" button
bjarni
parents: 4654
diff changeset
   185
				SetDParam(0, GetStationIndex(w->window_number)); // Airport name
2f99f35d5813 (svn r6542) -Feature: [depot window] added a "sell all vehicles in depot" button
bjarni
parents: 4654
diff changeset
   186
			} else {
2f99f35d5813 (svn r6542) -Feature: [depot window] added a "sell all vehicles in depot" button
bjarni
parents: 4654
diff changeset
   187
				Depot *depot = GetDepotByTile(w->window_number);
2f99f35d5813 (svn r6542) -Feature: [depot window] added a "sell all vehicles in depot" button
bjarni
parents: 4654
diff changeset
   188
				assert(depot != NULL);
2f99f35d5813 (svn r6542) -Feature: [depot window] added a "sell all vehicles in depot" button
bjarni
parents: 4654
diff changeset
   189
2f99f35d5813 (svn r6542) -Feature: [depot window] added a "sell all vehicles in depot" button
bjarni
parents: 4654
diff changeset
   190
				SetDParam(0, depot->town_index);
2f99f35d5813 (svn r6542) -Feature: [depot window] added a "sell all vehicles in depot" button
bjarni
parents: 4654
diff changeset
   191
			}
2f99f35d5813 (svn r6542) -Feature: [depot window] added a "sell all vehicles in depot" button
bjarni
parents: 4654
diff changeset
   192
			DrawWindowWidgets(w);
2f99f35d5813 (svn r6542) -Feature: [depot window] added a "sell all vehicles in depot" button
bjarni
parents: 4654
diff changeset
   193
2f99f35d5813 (svn r6542) -Feature: [depot window] added a "sell all vehicles in depot" button
bjarni
parents: 4654
diff changeset
   194
			DrawStringCentered(150, 25, STR_DEPOT_SELL_ALL_VEHICLE_CONFIRM, 0);
2f99f35d5813 (svn r6542) -Feature: [depot window] added a "sell all vehicles in depot" button
bjarni
parents: 4654
diff changeset
   195
			DrawStringCentered(150, 38, STR_ARE_YOU_SURE, 0);
2f99f35d5813 (svn r6542) -Feature: [depot window] added a "sell all vehicles in depot" button
bjarni
parents: 4654
diff changeset
   196
			break;
2f99f35d5813 (svn r6542) -Feature: [depot window] added a "sell all vehicles in depot" button
bjarni
parents: 4654
diff changeset
   197
2f99f35d5813 (svn r6542) -Feature: [depot window] added a "sell all vehicles in depot" button
bjarni
parents: 4654
diff changeset
   198
		case WE_CLICK:
2f99f35d5813 (svn r6542) -Feature: [depot window] added a "sell all vehicles in depot" button
bjarni
parents: 4654
diff changeset
   199
			switch (e->we.click.widget) {
2f99f35d5813 (svn r6542) -Feature: [depot window] added a "sell all vehicles in depot" button
bjarni
parents: 4654
diff changeset
   200
				case 4:
2f99f35d5813 (svn r6542) -Feature: [depot window] added a "sell all vehicles in depot" button
bjarni
parents: 4654
diff changeset
   201
					DoCommandP(w->window_number, WP(w, depot_d).type, 0, NULL, CMD_DEPOT_SELL_ALL_VEHICLES);
2f99f35d5813 (svn r6542) -Feature: [depot window] added a "sell all vehicles in depot" button
bjarni
parents: 4654
diff changeset
   202
					/* Fallthought */
2f99f35d5813 (svn r6542) -Feature: [depot window] added a "sell all vehicles in depot" button
bjarni
parents: 4654
diff changeset
   203
				case 3:
2f99f35d5813 (svn r6542) -Feature: [depot window] added a "sell all vehicles in depot" button
bjarni
parents: 4654
diff changeset
   204
					DeleteWindow(w);
2f99f35d5813 (svn r6542) -Feature: [depot window] added a "sell all vehicles in depot" button
bjarni
parents: 4654
diff changeset
   205
					break;
2f99f35d5813 (svn r6542) -Feature: [depot window] added a "sell all vehicles in depot" button
bjarni
parents: 4654
diff changeset
   206
			}
2f99f35d5813 (svn r6542) -Feature: [depot window] added a "sell all vehicles in depot" button
bjarni
parents: 4654
diff changeset
   207
			break;
2f99f35d5813 (svn r6542) -Feature: [depot window] added a "sell all vehicles in depot" button
bjarni
parents: 4654
diff changeset
   208
	}
2f99f35d5813 (svn r6542) -Feature: [depot window] added a "sell all vehicles in depot" button
bjarni
parents: 4654
diff changeset
   209
}
2f99f35d5813 (svn r6542) -Feature: [depot window] added a "sell all vehicles in depot" button
bjarni
parents: 4654
diff changeset
   210
2f99f35d5813 (svn r6542) -Feature: [depot window] added a "sell all vehicles in depot" button
bjarni
parents: 4654
diff changeset
   211
static const Widget _depot_sell_all_widgets[] = {
2f99f35d5813 (svn r6542) -Feature: [depot window] added a "sell all vehicles in depot" button
bjarni
parents: 4654
diff changeset
   212
	{   WWT_CLOSEBOX,   RESIZE_NONE,     5,     0,    10,     0,    13, STR_00C5,        STR_018B_CLOSE_WINDOW},
2f99f35d5813 (svn r6542) -Feature: [depot window] added a "sell all vehicles in depot" button
bjarni
parents: 4654
diff changeset
   213
	{    WWT_CAPTION,   RESIZE_NONE,     5,    11,   299,     0,    13, 0x0,             STR_018C_WINDOW_TITLE_DRAG_THIS},
2f99f35d5813 (svn r6542) -Feature: [depot window] added a "sell all vehicles in depot" button
bjarni
parents: 4654
diff changeset
   214
	{      WWT_PANEL,   RESIZE_NONE,     5,     0,   299,    14,    71, 0x0,             STR_NULL},
2f99f35d5813 (svn r6542) -Feature: [depot window] added a "sell all vehicles in depot" button
bjarni
parents: 4654
diff changeset
   215
	{ WWT_PUSHTXTBTN,   RESIZE_NONE,     5,    85,   144,    52,    63, STR_012E_CANCEL, STR_DEPOT_SELL_ALL_CANCEL_TIP},
2f99f35d5813 (svn r6542) -Feature: [depot window] added a "sell all vehicles in depot" button
bjarni
parents: 4654
diff changeset
   216
	{ WWT_PUSHTXTBTN,   RESIZE_NONE,     4,   155,   214,    52,    63, STR_SELL,        STR_DEPOT_SELL_ALL_TIP},
2f99f35d5813 (svn r6542) -Feature: [depot window] added a "sell all vehicles in depot" button
bjarni
parents: 4654
diff changeset
   217
	{   WIDGETS_END},
2f99f35d5813 (svn r6542) -Feature: [depot window] added a "sell all vehicles in depot" button
bjarni
parents: 4654
diff changeset
   218
};
2f99f35d5813 (svn r6542) -Feature: [depot window] added a "sell all vehicles in depot" button
bjarni
parents: 4654
diff changeset
   219
2f99f35d5813 (svn r6542) -Feature: [depot window] added a "sell all vehicles in depot" button
bjarni
parents: 4654
diff changeset
   220
static const WindowDesc _depot_sell_all_desc = {
2f99f35d5813 (svn r6542) -Feature: [depot window] added a "sell all vehicles in depot" button
bjarni
parents: 4654
diff changeset
   221
	WDP_CENTER, WDP_CENTER, 300, 72,
2f99f35d5813 (svn r6542) -Feature: [depot window] added a "sell all vehicles in depot" button
bjarni
parents: 4654
diff changeset
   222
	WC_DEPOT_SELL_ALL,0,
2f99f35d5813 (svn r6542) -Feature: [depot window] added a "sell all vehicles in depot" button
bjarni
parents: 4654
diff changeset
   223
	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET,
2f99f35d5813 (svn r6542) -Feature: [depot window] added a "sell all vehicles in depot" button
bjarni
parents: 4654
diff changeset
   224
	_depot_sell_all_widgets,
2f99f35d5813 (svn r6542) -Feature: [depot window] added a "sell all vehicles in depot" button
bjarni
parents: 4654
diff changeset
   225
	DepotSellAllWndProc
2f99f35d5813 (svn r6542) -Feature: [depot window] added a "sell all vehicles in depot" button
bjarni
parents: 4654
diff changeset
   226
};
2f99f35d5813 (svn r6542) -Feature: [depot window] added a "sell all vehicles in depot" button
bjarni
parents: 4654
diff changeset
   227
2f99f35d5813 (svn r6542) -Feature: [depot window] added a "sell all vehicles in depot" button
bjarni
parents: 4654
diff changeset
   228
static void ShowDepotSellAllWindow(TileIndex tile, byte type)
2f99f35d5813 (svn r6542) -Feature: [depot window] added a "sell all vehicles in depot" button
bjarni
parents: 4654
diff changeset
   229
{
2f99f35d5813 (svn r6542) -Feature: [depot window] added a "sell all vehicles in depot" button
bjarni
parents: 4654
diff changeset
   230
	Window *w;
2f99f35d5813 (svn r6542) -Feature: [depot window] added a "sell all vehicles in depot" button
bjarni
parents: 4654
diff changeset
   231
2f99f35d5813 (svn r6542) -Feature: [depot window] added a "sell all vehicles in depot" button
bjarni
parents: 4654
diff changeset
   232
	w = AllocateWindowDescFront(&_depot_sell_all_desc, tile);
2f99f35d5813 (svn r6542) -Feature: [depot window] added a "sell all vehicles in depot" button
bjarni
parents: 4654
diff changeset
   233
2f99f35d5813 (svn r6542) -Feature: [depot window] added a "sell all vehicles in depot" button
bjarni
parents: 4654
diff changeset
   234
	if (w != NULL) {
2f99f35d5813 (svn r6542) -Feature: [depot window] added a "sell all vehicles in depot" button
bjarni
parents: 4654
diff changeset
   235
		WP(w, depot_d).type = type;
2f99f35d5813 (svn r6542) -Feature: [depot window] added a "sell all vehicles in depot" button
bjarni
parents: 4654
diff changeset
   236
		switch (type) {
2f99f35d5813 (svn r6542) -Feature: [depot window] added a "sell all vehicles in depot" button
bjarni
parents: 4654
diff changeset
   237
			case VEH_Train:	   w->widget[1].data = STR_8800_TRAIN_DEPOT;        break;
2f99f35d5813 (svn r6542) -Feature: [depot window] added a "sell all vehicles in depot" button
bjarni
parents: 4654
diff changeset
   238
			case VEH_Road:     w->widget[1].data = STR_9003_ROAD_VEHICLE_DEPOT; break;
2f99f35d5813 (svn r6542) -Feature: [depot window] added a "sell all vehicles in depot" button
bjarni
parents: 4654
diff changeset
   239
			case VEH_Ship:     w->widget[1].data = STR_9803_SHIP_DEPOT;         break;
2f99f35d5813 (svn r6542) -Feature: [depot window] added a "sell all vehicles in depot" button
bjarni
parents: 4654
diff changeset
   240
			case VEH_Aircraft:
2f99f35d5813 (svn r6542) -Feature: [depot window] added a "sell all vehicles in depot" button
bjarni
parents: 4654
diff changeset
   241
				w->widget[1].data     = STR_A002_AIRCRAFT_HANGAR;
2f99f35d5813 (svn r6542) -Feature: [depot window] added a "sell all vehicles in depot" button
bjarni
parents: 4654
diff changeset
   242
				w->widget[3].tooltips = STR_DEPOT_SELL_ALL_CANCEL_HANGAR_TIP;
2f99f35d5813 (svn r6542) -Feature: [depot window] added a "sell all vehicles in depot" button
bjarni
parents: 4654
diff changeset
   243
				w->widget[4].tooltips = STR_DEPOT_SELL_ALL_HANGAR_TIP;
2f99f35d5813 (svn r6542) -Feature: [depot window] added a "sell all vehicles in depot" button
bjarni
parents: 4654
diff changeset
   244
				break;
2f99f35d5813 (svn r6542) -Feature: [depot window] added a "sell all vehicles in depot" button
bjarni
parents: 4654
diff changeset
   245
		}
2f99f35d5813 (svn r6542) -Feature: [depot window] added a "sell all vehicles in depot" button
bjarni
parents: 4654
diff changeset
   246
	}
2f99f35d5813 (svn r6542) -Feature: [depot window] added a "sell all vehicles in depot" button
bjarni
parents: 4654
diff changeset
   247
}
2f99f35d5813 (svn r6542) -Feature: [depot window] added a "sell all vehicles in depot" button
bjarni
parents: 4654
diff changeset
   248
4638
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   249
static void DrawDepotWindow(Window *w)
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   250
{
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   251
	Vehicle **vl = WP(w, depot_d).vehicle_list;
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   252
	TileIndex tile;
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   253
	int x, y, i, hnum, max;
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   254
	uint16 num = WP(w, depot_d).engine_count;
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   255
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   256
	tile = w->window_number;
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   257
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   258
	/* setup disabled buttons */
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   259
	w->disabled_state =
4644
c9e977fc9193 (svn r6520) -Fix r6515: "start all" and "stop all" buttons in depot windows are now disabled if you do not own the depot
bjarni
parents: 4641
diff changeset
   260
		IsTileOwner(tile, _local_player) ? 0 : ( (1 << DEPOT_WIDGET_STOP_ALL) | (1 << DEPOT_WIDGET_START_ALL) |
4659
2f99f35d5813 (svn r6542) -Feature: [depot window] added a "sell all vehicles in depot" button
bjarni
parents: 4654
diff changeset
   261
			(1 << DEPOT_WIDGET_SELL) | (1 << DEPOT_WIDGET_SELL_CHAIN) | (1 << DEPOT_WIDGET_SELL_ALL) |
4662
a20121e5442b (svn r6552) -Feature: [depot window] added a "autoreplace all vehicles in depot" button
bjarni
parents: 4659
diff changeset
   262
			(1 << DEPOT_WIDGET_BUILD) | (1 << DEPOT_WIDGET_CLONE) | (1 << DEPOT_WIDGET_AUTOREPLACE));
4638
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   263
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   264
	/* determine amount of items for scroller */
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   265
	if (WP(w, depot_d).type == VEH_Train) {
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   266
		hnum = 8;
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   267
		for (num = 0; num < WP(w, depot_d).engine_count; num++) {
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   268
			const Vehicle *v = vl[num];
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   269
			hnum = maxu(hnum, v->u.rail.cached_total_length);
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   270
		}
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   271
		/* Always have 1 empty row, so people can change the setting of the train */
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   272
		SetVScrollCount(w, WP(w, depot_d).engine_count + WP(w, depot_d).wagon_count + 1);
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   273
		SetHScrollCount(w, WagonLengthToPixels(hnum));
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   274
	} else {
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   275
		SetVScrollCount(w, (num + w->hscroll.cap - 1) / w->hscroll.cap);
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   276
	}
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   277
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   278
	/* locate the depot struct */
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   279
	if (WP(w, depot_d).type == VEH_Aircraft) {
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   280
		SetDParam(0, GetStationIndex(tile)); // Airport name
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   281
	} else {
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   282
		Depot *depot = GetDepotByTile(tile);
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   283
		assert(depot != NULL);
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   284
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   285
		SetDParam(0, depot->town_index);
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   286
	}
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   287
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   288
	DrawWindowWidgets(w);
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   289
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   290
	x = 2;
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   291
	y = 15;
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   292
	num = w->vscroll.pos * w->hscroll.cap;
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   293
	if (WP(w, depot_d).type == VEH_Train) {
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   294
		max = min(WP(w, depot_d).engine_count, w->vscroll.pos + w->vscroll.cap);
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   295
		num = w->vscroll.pos;
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   296
	} else {
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   297
		max = min(WP(w, depot_d).engine_count, num + (w->vscroll.cap * w->hscroll.cap));
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   298
		num = w->vscroll.pos * w->hscroll.cap;
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   299
	}
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   300
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   301
	for (; num < max; num++) {
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   302
		const Vehicle *v = vl[num];
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   303
		byte diff_x = 0, diff_y = 0;
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   304
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   305
		switch (WP(w, depot_d).type) {
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   306
			case VEH_Train:
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   307
				DrawTrainImage(v, x + 21, y, w->hscroll.cap + 4, w->hscroll.pos, WP(w,depot_d).sel);
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   308
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   309
				/* Number of wagons relative to a standard length wagon (rounded up) */
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   310
				SetDParam(0, (v->u.rail.cached_total_length + 7) / 8);
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   311
				DrawStringRightAligned(w->widget[DEPOT_WIDGET_MATRIX].right - 1, y + 4, STR_TINY_BLACK, 0); // Draw the counter
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   312
				break;
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   313
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   314
			case VEH_Road:     DrawRoadVehImage( v, x + 24, y, WP(w, depot_d).sel); break;
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   315
			case VEH_Ship:     DrawShipImage(    v, x + 19, y, WP(w, depot_d).sel); break;
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   316
			case VEH_Aircraft: DrawAircraftImage(v, x + 12, y, WP(w, depot_d).sel); break;
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   317
			default: NOT_REACHED();
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   318
		}
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   319
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   320
		if (w->resize.step_height == 14) {
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   321
			/* VEH_Train and VEH_Road, which are low */
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   322
			diff_x = 15;
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   323
		} else {
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   324
			/* VEH_Ship and VEH_Aircraft, which are tall */
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   325
			diff_y = 12;
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   326
		}
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   327
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   328
		DrawSprite((v->vehstatus & VS_STOPPED) ? SPR_FLAG_VEH_STOPPED : SPR_FLAG_VEH_RUNNING, x + diff_x, y + diff_y);
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   329
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   330
		SetDParam(0, v->unitnumber);
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   331
		DrawString(x, y + 2, (uint16)(v->max_age-366) >= v->age ? STR_00E2 : STR_00E3, 0);
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   332
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   333
		if (WP(w, depot_d).type == VEH_Train) {
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   334
			y += w->resize.step_height;
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   335
		} else {
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   336
			if ((x += w->resize.step_width) == 2 + (int)w->resize.step_width * w->hscroll.cap) {
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   337
				x = 2;
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   338
				y += w->resize.step_height;
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   339
			}
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   340
		}
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   341
	}
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   342
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   343
	max = min(WP(w, depot_d).engine_count + WP(w, depot_d).wagon_count, w->vscroll.pos + w->vscroll.cap);
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   344
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   345
	/* draw the train wagons, that do not have an engine in front */
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   346
	for (; num < max; num++) {
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   347
		const Vehicle *v = WP(w, depot_d).wagon_list[num - WP(w, depot_d).engine_count];
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   348
		const Vehicle *u;
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   349
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   350
		DrawTrainImage(v, x + 50, y, w->hscroll.cap - 29, 0, WP(w,depot_d).sel);
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   351
		DrawString(x, y + 2, STR_8816, 0);
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   352
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   353
		/*Draw the train counter */
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   354
		i = 0;
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   355
		u = v;
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   356
		do i++; while ( (u=u->next) != NULL); // Determine length of train
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   357
		SetDParam(0, i);                      // Set the counter
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   358
		DrawStringRightAligned(w->widget[DEPOT_WIDGET_MATRIX].right - 1, y + 4, STR_TINY_BLACK, 0); // Draw the counter
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   359
		y += 14;
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   360
	}
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   361
}
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   362
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   363
typedef struct GetDepotVehiclePtData {
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   364
	Vehicle *head;
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   365
	Vehicle *wagon;
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   366
} GetDepotVehiclePtData;
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   367
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   368
enum {
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   369
	MODE_ERROR        =  1,
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   370
	MODE_DRAG_VEHICLE =  0,
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   371
	MODE_SHOW_VEHICLE = -1,
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   372
	MODE_START_STOP   = -2,
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   373
};
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   374
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   375
static int GetVehicleFromDepotWndPt(const Window *w, int x, int y, Vehicle **veh, GetDepotVehiclePtData *d)
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   376
{
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   377
	Vehicle **vl = WP(w, depot_d).vehicle_list;
4641
acaeea0a1795 (svn r6516) -Fix r6513: killed warnings about two variables being used uninitialized
bjarni
parents: 4640
diff changeset
   378
	uint xt, row, xm = 0, ym = 0;
4638
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   379
	int pos, skip = 0;
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   380
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   381
	if (WP(w, depot_d).type == VEH_Train) {
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   382
		xt = 0;
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   383
		x -= 23;
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   384
	} else {
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   385
		xt = x / w->resize.step_width;
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   386
		xm = x % w->resize.step_width;
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   387
		if (xt >= w->hscroll.cap) return MODE_ERROR;
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   388
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   389
		ym = (y - 14) % w->resize.step_height;
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   390
	}
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   391
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   392
	row = (y - 14) / w->resize.step_height;
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   393
	if (row >= w->vscroll.cap) return MODE_ERROR;
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   394
4663
2e01fabb902f (svn r6554) -Fix r6513: [depot window] fixed a bug where moving rail vehicles from one line to another could fail under certain conditions
bjarni
parents: 4662
diff changeset
   395
	pos = (row + w->vscroll.pos) * (WP(w, depot_d).type == VEH_Train ? 1 : w->hscroll.cap) + xt;
4638
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   396
4663
2e01fabb902f (svn r6554) -Fix r6513: [depot window] fixed a bug where moving rail vehicles from one line to another could fail under certain conditions
bjarni
parents: 4662
diff changeset
   397
	if (WP(w, depot_d).engine_count + WP(w, depot_d).wagon_count <= pos) {
2e01fabb902f (svn r6554) -Fix r6513: [depot window] fixed a bug where moving rail vehicles from one line to another could fail under certain conditions
bjarni
parents: 4662
diff changeset
   398
		if (WP(w, depot_d).type == VEH_Train) {
2e01fabb902f (svn r6554) -Fix r6513: [depot window] fixed a bug where moving rail vehicles from one line to another could fail under certain conditions
bjarni
parents: 4662
diff changeset
   399
			d->head  = NULL;
2e01fabb902f (svn r6554) -Fix r6513: [depot window] fixed a bug where moving rail vehicles from one line to another could fail under certain conditions
bjarni
parents: 4662
diff changeset
   400
			d->wagon = NULL;
2e01fabb902f (svn r6554) -Fix r6513: [depot window] fixed a bug where moving rail vehicles from one line to another could fail under certain conditions
bjarni
parents: 4662
diff changeset
   401
			return MODE_DRAG_VEHICLE;
2e01fabb902f (svn r6554) -Fix r6513: [depot window] fixed a bug where moving rail vehicles from one line to another could fail under certain conditions
bjarni
parents: 4662
diff changeset
   402
		} else {
2e01fabb902f (svn r6554) -Fix r6513: [depot window] fixed a bug where moving rail vehicles from one line to another could fail under certain conditions
bjarni
parents: 4662
diff changeset
   403
			return MODE_ERROR; // empty block, so no vehicle is selected
2e01fabb902f (svn r6554) -Fix r6513: [depot window] fixed a bug where moving rail vehicles from one line to another could fail under certain conditions
bjarni
parents: 4662
diff changeset
   404
		}
2e01fabb902f (svn r6554) -Fix r6513: [depot window] fixed a bug where moving rail vehicles from one line to another could fail under certain conditions
bjarni
parents: 4662
diff changeset
   405
	}
4638
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   406
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   407
	if (WP(w, depot_d).engine_count > pos) {
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   408
		*veh = vl[pos];
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   409
		skip = w->hscroll.pos;
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   410
	} else {
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   411
		vl = WP(w, depot_d).wagon_list;
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   412
		pos -= WP(w, depot_d).engine_count;
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   413
		*veh = vl[pos];
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   414
		/* free wagons don't have an initial loco. */
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   415
		x -= _traininfo_vehicle_width;
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   416
	}
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   417
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   418
	switch (WP(w, depot_d).type) {
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   419
		case VEH_Train: {
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   420
			Vehicle *v = *veh;
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   421
			d->head = d->wagon = v;
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   422
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   423
			/* either pressed the flag or the number, but only when it's a loco */
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   424
			if (x < 0 && IsFrontEngine(v)) return (x >= -10) ? MODE_START_STOP : MODE_SHOW_VEHICLE;
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   425
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   426
			skip = (skip * 8) / _traininfo_vehicle_width;
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   427
			x = (x * 8) / _traininfo_vehicle_width;
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   428
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   429
			/* Skip vehicles that are scrolled off the list */
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   430
			x += skip;
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   431
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   432
			/* find the vehicle in this row that was clicked */
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   433
			while (v != NULL && (x -= v->u.rail.cached_veh_length) >= 0) v = v->next;
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   434
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   435
			/* if an articulated part was selected, find its parent */
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   436
			while (v != NULL && IsArticulatedPart(v)) v = GetPrevVehicleInChain(v);
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   437
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   438
			d->wagon = v;
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   439
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   440
			return MODE_DRAG_VEHICLE;
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   441
			}
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   442
			break;
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   443
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   444
		case VEH_Road:
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   445
			if (xm >= 24) return MODE_DRAG_VEHICLE;
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   446
			if (xm <= 16) return MODE_SHOW_VEHICLE;
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   447
			break;
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   448
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   449
		case VEH_Ship:
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   450
			if (xm >= 19) return MODE_DRAG_VEHICLE;
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   451
			if (ym <= 10) return MODE_SHOW_VEHICLE;
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   452
			break;
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   453
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   454
		case VEH_Aircraft:
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   455
			if (xm >= 12) return MODE_DRAG_VEHICLE;
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   456
			if (ym <= 12) return MODE_SHOW_VEHICLE;
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   457
			break;
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   458
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   459
		default: NOT_REACHED();
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   460
	}
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   461
	return MODE_START_STOP;
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   462
}
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   463
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   464
static void TrainDepotMoveVehicle(Vehicle *wagon, VehicleID sel, Vehicle *head)
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   465
{
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   466
	Vehicle *v;
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   467
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   468
	v = GetVehicle(sel);
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   469
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   470
	if (v == wagon) return;
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   471
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   472
	if (wagon == NULL) {
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   473
		if (head != NULL) wagon = GetLastVehicleInChain(head);
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   474
	} else  {
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   475
		wagon = GetPrevVehicleInChain(wagon);
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   476
		if (wagon == NULL) return;
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   477
	}
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   478
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   479
	if (wagon == v) return;
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   480
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   481
	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
   482
}
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   483
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   484
static void DepotClick(Window *w, int x, int y)
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   485
{
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   486
	GetDepotVehiclePtData gdvp;
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   487
	Vehicle *v = NULL;
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   488
	int mode = GetVehicleFromDepotWndPt(w, x, y, &v, &gdvp);
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   489
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   490
	/* share / copy orders */
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   491
	if (_thd.place_mode && mode <= 0) {
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   492
		_place_clicked_vehicle = (WP(w, depot_d).type == VEH_Train ? gdvp.head : v);
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   493
		return;
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   494
	}
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   495
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   496
	if (WP(w, depot_d).type == VEH_Train) v = gdvp.wagon;
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   497
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   498
	switch (mode) {
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   499
		case MODE_ERROR: // invalid
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   500
			return;
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   501
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   502
		case MODE_DRAG_VEHICLE: { // start dragging of vehicle
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   503
			VehicleID sel = WP(w, depot_d).sel;
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   504
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   505
			if (WP(w, depot_d).type == VEH_Train && sel != INVALID_VEHICLE) {
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   506
				WP(w,depot_d).sel = INVALID_VEHICLE;
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   507
				TrainDepotMoveVehicle(v, sel, gdvp.head);
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   508
			} else if (v != NULL) {
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   509
				int image;
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   510
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   511
				switch (WP(w, depot_d).type) {
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   512
					case VEH_Train:    image = GetTrainImage(v, DIR_W);    break;
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   513
					case VEH_Road:     image = GetRoadVehImage(v, DIR_W);  break;
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   514
					case VEH_Ship:     image = GetShipImage(v, DIR_W);     break;
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   515
					case VEH_Aircraft: image = GetAircraftImage(v, DIR_W); break;
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   516
					default: NOT_REACHED(); image = 0;
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   517
				}
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   518
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   519
				WP(w, depot_d).sel = v->index;
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   520
				SetWindowDirty(w);
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   521
				SetObjectToPlaceWnd(GetVehiclePalette(v) | image, 4, w);
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   522
			}
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   523
			}
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   524
			break;
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   525
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   526
		case MODE_SHOW_VEHICLE: // show info window
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   527
			ShowVehicleViewWindow(v);
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   528
			break;
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   529
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   530
		case MODE_START_STOP: { // click start/stop flag
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   531
			uint command;
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   532
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   533
			switch (WP(w, depot_d).type) {
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   534
				case VEH_Train:    command = CMD_START_STOP_TRAIN | CMD_MSG(STR_883B_CAN_T_STOP_START_TRAIN);          break;
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   535
				case VEH_Road:     command = CMD_START_STOP_ROADVEH | CMD_MSG(STR_9015_CAN_T_STOP_START_ROAD_VEHICLE); break;
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   536
				case VEH_Ship:     command = CMD_START_STOP_SHIP | CMD_MSG(STR_9818_CAN_T_STOP_START_SHIP);            break;
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   537
				case VEH_Aircraft: command = CMD_START_STOP_AIRCRAFT | CMD_MSG(STR_A016_CAN_T_STOP_START_AIRCRAFT);    break;
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   538
				default: NOT_REACHED(); command = 0;
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   539
			}
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   540
			DoCommandP(v->tile, v->index, 0, NULL, command);
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   541
			}
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   542
			break;
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   543
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   544
		default: NOT_REACHED();
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   545
	}
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   546
}
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   547
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   548
/**
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   549
 * Clones a vehicle
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   550
 * @param *v is the original vehicle to clone
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   551
 * @param *w is the window of the depot where the clone is build
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   552
 */
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   553
static void HandleCloneVehClick(const Vehicle *v, const Window *w)
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   554
{
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   555
	uint error_str;
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   556
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   557
	if (v == NULL) return;
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   558
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   559
	if (v->type == VEH_Train && !IsFrontEngine(v)) {
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   560
		v = GetFirstVehicleInChain(v);
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   561
		/* Do nothing when clicking on a train in depot with no loc attached */
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   562
		if (!IsFrontEngine(v)) return;
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   563
	}
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   564
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   565
	switch (v->type) {
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   566
		case VEH_Train:    error_str = CMD_MSG(STR_882B_CAN_T_BUILD_RAILROAD_VEHICLE); break;
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   567
		case VEH_Road:     error_str = CMD_MSG(STR_9009_CAN_T_BUILD_ROAD_VEHICLE);     break;
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   568
		case VEH_Ship:     error_str = CMD_MSG(STR_980D_CAN_T_BUILD_SHIP);             break;
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   569
		case VEH_Aircraft: error_str = CMD_MSG(STR_A008_CAN_T_BUILD_AIRCRAFT);         break;
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   570
		default: return;
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   571
	}
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   572
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   573
	DoCommandP(w->window_number, v->index, _ctrl_pressed ? 1 : 0, CcCloneVehicle, CMD_CLONE_VEHICLE | error_str);
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   574
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   575
	ResetObjectToPlace();
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   576
}
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   577
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   578
static void ClonePlaceObj(const Window *w)
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   579
{
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   580
	const Vehicle *v = CheckMouseOverVehicle();
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   581
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   582
	if (v != NULL) HandleCloneVehClick(v, w);
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   583
}
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   584
4646
c6f774de4f6f (svn r6522) -Feature: [depot window] the buttons are now "scaled" resized
bjarni
parents: 4644
diff changeset
   585
static void ResizeDepotButtons(Window *w)
c6f774de4f6f (svn r6522) -Feature: [depot window] the buttons are now "scaled" resized
bjarni
parents: 4644
diff changeset
   586
{
c6f774de4f6f (svn r6522) -Feature: [depot window] the buttons are now "scaled" resized
bjarni
parents: 4644
diff changeset
   587
	/* We got the widget moved around. Now we will make some widgets to fill the gab between some widgets in equal sizes */
c6f774de4f6f (svn r6522) -Feature: [depot window] the buttons are now "scaled" resized
bjarni
parents: 4644
diff changeset
   588
c6f774de4f6f (svn r6522) -Feature: [depot window] the buttons are now "scaled" resized
bjarni
parents: 4644
diff changeset
   589
	/* Make the buttons in the bottom equal in size */
4662
a20121e5442b (svn r6552) -Feature: [depot window] added a "autoreplace all vehicles in depot" button
bjarni
parents: 4659
diff changeset
   590
	w->widget[DEPOT_WIDGET_LOCATION].right = w->widget[DEPOT_WIDGET_AUTOREPLACE].left - 1;
4646
c6f774de4f6f (svn r6522) -Feature: [depot window] the buttons are now "scaled" resized
bjarni
parents: 4644
diff changeset
   591
	w->widget[DEPOT_WIDGET_BUILD].right    = w->widget[DEPOT_WIDGET_LOCATION].right / 3;
c6f774de4f6f (svn r6522) -Feature: [depot window] the buttons are now "scaled" resized
bjarni
parents: 4644
diff changeset
   592
	w->widget[DEPOT_WIDGET_LOCATION].left  = w->widget[DEPOT_WIDGET_BUILD].right * 2;
c6f774de4f6f (svn r6522) -Feature: [depot window] the buttons are now "scaled" resized
bjarni
parents: 4644
diff changeset
   593
	w->widget[DEPOT_WIDGET_CLONE].left     = w->widget[DEPOT_WIDGET_BUILD].right + 1;
c6f774de4f6f (svn r6522) -Feature: [depot window] the buttons are now "scaled" resized
bjarni
parents: 4644
diff changeset
   594
	w->widget[DEPOT_WIDGET_CLONE].right    = w->widget[DEPOT_WIDGET_LOCATION].left - 1;
c6f774de4f6f (svn r6522) -Feature: [depot window] the buttons are now "scaled" resized
bjarni
parents: 4644
diff changeset
   595
c6f774de4f6f (svn r6522) -Feature: [depot window] the buttons are now "scaled" resized
bjarni
parents: 4644
diff changeset
   596
	if (WP(w, depot_d).type == VEH_Train) {
4659
2f99f35d5813 (svn r6542) -Feature: [depot window] added a "sell all vehicles in depot" button
bjarni
parents: 4654
diff changeset
   597
		/* 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.
2f99f35d5813 (svn r6542) -Feature: [depot window] added a "sell all vehicles in depot" button
bjarni
parents: 4654
diff changeset
   598
		* This way it will stay the same even if DEPOT_WIDGET_SELL_CHAIN is resized for some reason                                                  */
2f99f35d5813 (svn r6542) -Feature: [depot window] added a "sell all vehicles in depot" button
bjarni
parents: 4654
diff changeset
   599
		w->widget[DEPOT_WIDGET_SELL_CHAIN].bottom = w->widget[DEPOT_WIDGET_SELL_ALL].top - 1;
2f99f35d5813 (svn r6542) -Feature: [depot window] added a "sell all vehicles in depot" button
bjarni
parents: 4654
diff changeset
   600
		w->widget[DEPOT_WIDGET_SELL_CHAIN].top    = ((w->widget[DEPOT_WIDGET_SELL_CHAIN].bottom - w->widget[DEPOT_WIDGET_SELL].top) / 2) + w->widget[DEPOT_WIDGET_SELL].top;
2f99f35d5813 (svn r6542) -Feature: [depot window] added a "sell all vehicles in depot" button
bjarni
parents: 4654
diff changeset
   601
		w->widget[DEPOT_WIDGET_SELL].bottom     = w->widget[DEPOT_WIDGET_SELL_CHAIN].top - 1;
4646
c6f774de4f6f (svn r6522) -Feature: [depot window] the buttons are now "scaled" resized
bjarni
parents: 4644
diff changeset
   602
	}
c6f774de4f6f (svn r6522) -Feature: [depot window] the buttons are now "scaled" resized
bjarni
parents: 4644
diff changeset
   603
}
c6f774de4f6f (svn r6522) -Feature: [depot window] the buttons are now "scaled" resized
bjarni
parents: 4644
diff changeset
   604
4638
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   605
static void DepotWndProc(Window *w, WindowEvent *e)
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   606
{
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   607
	switch (e->event) {
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   608
		case WE_CREATE:
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   609
			WP(w, depot_d).vehicle_list = NULL;
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   610
			WP(w, depot_d).wagon_list   = NULL;
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   611
			WP(w, depot_d).engine_count = 0;
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   612
			WP(w, depot_d).wagon_count  = 0;
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   613
			break;
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   614
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   615
		case WE_PAINT:
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   616
			/* Generate the vehicle list
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   617
			 * It's ok to use the wagon pointers for non-trains as they will be ignored */
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   618
			BuildDepotVehicleList(WP(w, depot_d).type, w->window_number,
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   619
				&WP(w, depot_d).vehicle_list, &WP(w, depot_d).engine_list_length, &WP(w, depot_d).engine_count,
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   620
			    &WP(w, depot_d).wagon_list,   &WP(w, depot_d).wagon_list_length,  &WP(w, depot_d).wagon_count);
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   621
			DrawDepotWindow(w);
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   622
			break;
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   623
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   624
		case WE_CLICK:
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   625
			switch (e->we.click.widget) {
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   626
				case DEPOT_WIDGET_MATRIX: // List
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   627
					DepotClick(w, e->we.click.pt.x, e->we.click.pt.y);
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   628
					break;
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   629
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   630
				case DEPOT_WIDGET_BUILD: // Build vehicle
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   631
					ResetObjectToPlace();
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   632
					switch (WP(w, depot_d).type) {
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   633
						case VEH_Train:    ShowBuildTrainWindow(w->window_number);    break;
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   634
						case VEH_Road:     ShowBuildRoadVehWindow(w->window_number);  break;
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   635
						case VEH_Ship:     ShowBuildShipWindow(w->window_number);     break;
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   636
						case VEH_Aircraft: ShowBuildAircraftWindow(w->window_number); break;
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   637
					default: NOT_REACHED();
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   638
					}
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   639
					break;
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   640
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   641
				case DEPOT_WIDGET_CLONE: // Clone button
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   642
					InvalidateWidget(w, DEPOT_WIDGET_CLONE);
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   643
					TOGGLEBIT(w->click_state, DEPOT_WIDGET_CLONE);
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   644
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   645
					if (HASBIT(w->click_state, DEPOT_WIDGET_CLONE)) {
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   646
						_place_clicked_vehicle = NULL;
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   647
						SetObjectToPlaceWnd(SPR_CURSOR_CLONE, VHM_RECT, w);
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   648
					} else {
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   649
						ResetObjectToPlace();
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   650
					}
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   651
						break;
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   652
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   653
				case DEPOT_WIDGET_LOCATION: ScrollMainWindowToTile(w->window_number); break;
4640
cabffc571e55 (svn r6515) -Feature: added "start all" and "stop all" buttons to the depot windows
bjarni
parents: 4638
diff changeset
   654
cabffc571e55 (svn r6515) -Feature: added "start all" and "stop all" buttons to the depot windows
bjarni
parents: 4638
diff changeset
   655
				case DEPOT_WIDGET_STOP_ALL:
cabffc571e55 (svn r6515) -Feature: added "start all" and "stop all" buttons to the depot windows
bjarni
parents: 4638
diff changeset
   656
				case DEPOT_WIDGET_START_ALL:
cabffc571e55 (svn r6515) -Feature: added "start all" and "stop all" buttons to the depot windows
bjarni
parents: 4638
diff changeset
   657
					DoCommandP(w->window_number, WP(w, depot_d).type, e->we.click.widget == DEPOT_WIDGET_START_ALL ? 1 : 0, NULL, CMD_MASS_START_STOP);
cabffc571e55 (svn r6515) -Feature: added "start all" and "stop all" buttons to the depot windows
bjarni
parents: 4638
diff changeset
   658
					break;
cabffc571e55 (svn r6515) -Feature: added "start all" and "stop all" buttons to the depot windows
bjarni
parents: 4638
diff changeset
   659
4659
2f99f35d5813 (svn r6542) -Feature: [depot window] added a "sell all vehicles in depot" button
bjarni
parents: 4654
diff changeset
   660
				case DEPOT_WIDGET_SELL_ALL:
2f99f35d5813 (svn r6542) -Feature: [depot window] added a "sell all vehicles in depot" button
bjarni
parents: 4654
diff changeset
   661
					ShowDepotSellAllWindow(w->window_number, WP(w, depot_d).type);
2f99f35d5813 (svn r6542) -Feature: [depot window] added a "sell all vehicles in depot" button
bjarni
parents: 4654
diff changeset
   662
					break;
2f99f35d5813 (svn r6542) -Feature: [depot window] added a "sell all vehicles in depot" button
bjarni
parents: 4654
diff changeset
   663
4662
a20121e5442b (svn r6552) -Feature: [depot window] added a "autoreplace all vehicles in depot" button
bjarni
parents: 4659
diff changeset
   664
				case DEPOT_WIDGET_AUTOREPLACE:
a20121e5442b (svn r6552) -Feature: [depot window] added a "autoreplace all vehicles in depot" button
bjarni
parents: 4659
diff changeset
   665
					DoCommandP(w->window_number, WP(w, depot_d).type, 0, NULL, CMD_DEPOT_MASS_AUTOREPLACE);
a20121e5442b (svn r6552) -Feature: [depot window] added a "autoreplace all vehicles in depot" button
bjarni
parents: 4659
diff changeset
   666
					break;
a20121e5442b (svn r6552) -Feature: [depot window] added a "autoreplace all vehicles in depot" button
bjarni
parents: 4659
diff changeset
   667
4638
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   668
			}
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   669
			break;
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   670
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   671
		case WE_PLACE_OBJ: {
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   672
			ClonePlaceObj(w);
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   673
		} break;
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   674
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   675
		case WE_ABORT_PLACE_OBJ: {
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   676
			CLRBIT(w->click_state, DEPOT_WIDGET_CLONE);
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   677
			InvalidateWidget(w, DEPOT_WIDGET_CLONE);
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   678
		} break;
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   679
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   680
			/* check if a vehicle in a depot was clicked.. */
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   681
		case WE_MOUSELOOP: {
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   682
			const Vehicle *v = _place_clicked_vehicle;
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   683
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   684
			/* since OTTD checks all open depot windows, we will make sure that it triggers the one with a clicked clone button */
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   685
			if (v != NULL && HASBIT(w->click_state, DEPOT_WIDGET_CLONE)) {
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   686
				_place_clicked_vehicle = NULL;
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   687
				HandleCloneVehClick(v, w);
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   688
			}
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   689
		} break;
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   690
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   691
		case WE_DESTROY:
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   692
			DeleteWindowById(WC_BUILD_VEHICLE, w->window_number);
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   693
			free((void*)WP(w, depot_d).vehicle_list);
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   694
			free((void*)WP(w, depot_d).wagon_list);
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   695
			break;
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   696
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   697
		case WE_DRAGDROP:
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   698
			switch (e->we.click.widget) {
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   699
				case DEPOT_WIDGET_MATRIX: {
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   700
					Vehicle *v;
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   701
					VehicleID sel = WP(w, depot_d).sel;
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   702
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   703
					WP(w, depot_d).sel = INVALID_VEHICLE;
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   704
					SetWindowDirty(w);
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   705
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   706
					if (WP(w, depot_d).type == VEH_Train) {
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   707
						GetDepotVehiclePtData gdvp;
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   708
4663
2e01fabb902f (svn r6554) -Fix r6513: [depot window] fixed a bug where moving rail vehicles from one line to another could fail under certain conditions
bjarni
parents: 4662
diff changeset
   709
						if (GetVehicleFromDepotWndPt(w, e->we.dragdrop.pt.x, e->we.dragdrop.pt.y, &v, &gdvp) == MODE_DRAG_VEHICLE &&
4638
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   710
							sel != INVALID_VEHICLE) {
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   711
							if (gdvp.wagon != NULL && gdvp.wagon->index == sel && _ctrl_pressed) {
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   712
								DoCommandP(GetVehicle(sel)->tile, GetVehicle(sel)->index, true, NULL, CMD_REVERSE_TRAIN_DIRECTION | CMD_MSG(STR_9033_CAN_T_MAKE_VEHICLE_TURN));
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   713
							} else if (gdvp.wagon == NULL || gdvp.wagon->index != sel) {
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   714
								TrainDepotMoveVehicle(gdvp.wagon, sel, gdvp.head);
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   715
							} else if (gdvp.head != NULL && IsFrontEngine(gdvp.head)) {
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   716
								ShowTrainViewWindow(gdvp.head);
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   717
							}
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   718
						}
4663
2e01fabb902f (svn r6554) -Fix r6513: [depot window] fixed a bug where moving rail vehicles from one line to another could fail under certain conditions
bjarni
parents: 4662
diff changeset
   719
					} else if (GetVehicleFromDepotWndPt(w, e->we.dragdrop.pt.x, e->we.dragdrop.pt.y, &v, NULL) == MODE_DRAG_VEHICLE &&
4638
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   720
						v != NULL &&
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   721
						sel == v->index) {
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   722
						ShowVehicleViewWindow(v);
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   723
					}
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   724
				} break;
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   725
4659
2f99f35d5813 (svn r6542) -Feature: [depot window] added a "sell all vehicles in depot" button
bjarni
parents: 4654
diff changeset
   726
				case DEPOT_WIDGET_SELL: case DEPOT_WIDGET_SELL_CHAIN:
4638
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   727
					if (!HASBIT(w->disabled_state, DEPOT_WIDGET_SELL) &&
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   728
						WP(w, depot_d).sel != INVALID_VEHICLE) {
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   729
						Vehicle *v;
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   730
						uint command;
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   731
						int sell_cmd;
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   732
						bool is_engine;
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   733
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   734
						if (HASBIT(w->disabled_state, e->we.click.widget)) return;
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   735
						if (WP(w, depot_d).sel == INVALID_VEHICLE) return;
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   736
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   737
						HandleButtonClick(w, e->we.click.widget);
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   738
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   739
						v = GetVehicle(WP(w, depot_d).sel);
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   740
						WP(w, depot_d).sel = INVALID_VEHICLE;
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   741
						SetWindowDirty(w);
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   742
4659
2f99f35d5813 (svn r6542) -Feature: [depot window] added a "sell all vehicles in depot" button
bjarni
parents: 4654
diff changeset
   743
						sell_cmd = (v->type == VEH_Train && (e->we.click.widget == DEPOT_WIDGET_SELL_CHAIN || _ctrl_pressed)) ? 1 : 0;
4638
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   744
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   745
						is_engine = (!(v->type == VEH_Train && !IsFrontEngine(v)));
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   746
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   747
						if (is_engine) {
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   748
							_backup_orders_tile = v->tile;
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   749
							BackupVehicleOrders(v, _backup_orders_data);
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   750
						}
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   751
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   752
						switch (v->type) {
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   753
							case VEH_Train:    command = CMD_SELL_RAIL_WAGON | CMD_MSG(STR_8839_CAN_T_SELL_RAILROAD_VEHICLE); break;
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   754
							case VEH_Road:     command = CMD_SELL_ROAD_VEH | CMD_MSG(STR_9014_CAN_T_SELL_ROAD_VEHICLE);       break;
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   755
							case VEH_Ship:     command = CMD_SELL_SHIP | CMD_MSG(STR_980C_CAN_T_SELL_SHIP);                   break;
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   756
							case VEH_Aircraft: command = CMD_SELL_AIRCRAFT | CMD_MSG(STR_A01C_CAN_T_SELL_AIRCRAFT);           break;
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   757
							default: NOT_REACHED(); command = 0;
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   758
						}
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   759
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   760
						if (!DoCommandP(v->tile, v->index, sell_cmd, NULL, command) && is_engine) _backup_orders_tile = 0;
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   761
					}
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   762
					break;
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   763
				default:
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   764
					WP(w, depot_d).sel = INVALID_VEHICLE;
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   765
					SetWindowDirty(w);
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   766
			}
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   767
			break;
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   768
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   769
		case WE_RESIZE:
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   770
			w->vscroll.cap += e->we.sizing.diff.y / (int)w->resize.step_height;
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   771
			w->hscroll.cap += e->we.sizing.diff.x / (int)w->resize.step_width;
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   772
			w->widget[DEPOT_WIDGET_MATRIX].data = (w->vscroll.cap << 8) + (WP(w, depot_d).type == VEH_Train ? 1 : w->hscroll.cap);
4646
c6f774de4f6f (svn r6522) -Feature: [depot window] the buttons are now "scaled" resized
bjarni
parents: 4644
diff changeset
   773
			ResizeDepotButtons(w);
4638
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   774
			break;
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   775
	}
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   776
}
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   777
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   778
static void SetupStringsForDepotWindow(Window *w, byte type)
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   779
{
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   780
	switch (type) {
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   781
		case VEH_Train:
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   782
			w->widget[DEPOT_WIDGET_CAPTION].data      = STR_8800_TRAIN_DEPOT;
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   783
			w->widget[DEPOT_WIDGET_SELL].tooltips     = STR_8841_DRAG_TRAIN_VEHICLE_TO_HERE;
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   784
			w->widget[DEPOT_WIDGET_MATRIX].tooltips   = STR_883F_TRAINS_CLICK_ON_TRAIN_FOR;
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   785
			w->widget[DEPOT_WIDGET_BUILD].data        = STR_8815_NEW_VEHICLES;
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   786
			w->widget[DEPOT_WIDGET_BUILD].tooltips    = STR_8840_BUILD_NEW_TRAIN_VEHICLE;
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   787
			w->widget[DEPOT_WIDGET_CLONE].data        = STR_CLONE_TRAIN;
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   788
			w->widget[DEPOT_WIDGET_CLONE].tooltips    = STR_CLONE_TRAIN_DEPOT_INFO;
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   789
			w->widget[DEPOT_WIDGET_LOCATION].tooltips = STR_8842_CENTER_MAIN_VIEW_ON_TRAIN;
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   790
			break;
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   791
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   792
		case VEH_Road:
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   793
			w->widget[DEPOT_WIDGET_CAPTION].data      = STR_9003_ROAD_VEHICLE_DEPOT;
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   794
			w->widget[DEPOT_WIDGET_SELL].tooltips     = STR_9024_DRAG_ROAD_VEHICLE_TO_HERE;
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   795
			w->widget[DEPOT_WIDGET_MATRIX].tooltips   = STR_9022_VEHICLES_CLICK_ON_VEHICLE;
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   796
			w->widget[DEPOT_WIDGET_BUILD].data        = STR_9004_NEW_VEHICLES;
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   797
			w->widget[DEPOT_WIDGET_BUILD].tooltips    = STR_9023_BUILD_NEW_ROAD_VEHICLE;
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   798
			w->widget[DEPOT_WIDGET_CLONE].data        = STR_CLONE_ROAD_VEHICLE;
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   799
			w->widget[DEPOT_WIDGET_CLONE].tooltips    = STR_CLONE_ROAD_VEHICLE_DEPOT_INFO;
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   800
			w->widget[DEPOT_WIDGET_LOCATION].tooltips = STR_9025_CENTER_MAIN_VIEW_ON_ROAD;
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   801
			break;
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   802
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   803
		case VEH_Ship:
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   804
			w->widget[DEPOT_WIDGET_CAPTION].data      = STR_9803_SHIP_DEPOT;
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   805
			w->widget[DEPOT_WIDGET_SELL].tooltips     = STR_9821_DRAG_SHIP_TO_HERE_TO_SELL;
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   806
			w->widget[DEPOT_WIDGET_MATRIX].tooltips   = STR_981F_SHIPS_CLICK_ON_SHIP_FOR;
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   807
			w->widget[DEPOT_WIDGET_BUILD].data        = STR_9804_NEW_SHIPS;
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   808
			w->widget[DEPOT_WIDGET_BUILD].tooltips    = STR_9820_BUILD_NEW_SHIP;
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   809
			w->widget[DEPOT_WIDGET_CLONE].data        = STR_CLONE_SHIP;
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   810
			w->widget[DEPOT_WIDGET_CLONE].tooltips    = STR_CLONE_SHIP_DEPOT_INFO;
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   811
			w->widget[DEPOT_WIDGET_LOCATION].tooltips = STR_9822_CENTER_MAIN_VIEW_ON_SHIP;
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   812
			break;
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   813
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   814
		case VEH_Aircraft:
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   815
			w->widget[DEPOT_WIDGET_CAPTION].data      = STR_A002_AIRCRAFT_HANGAR;
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   816
			w->widget[DEPOT_WIDGET_SELL].tooltips     = STR_A023_DRAG_AIRCRAFT_TO_HERE_TO;
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   817
			w->widget[DEPOT_WIDGET_MATRIX].tooltips   = STR_A021_AIRCRAFT_CLICK_ON_AIRCRAFT;
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   818
			w->widget[DEPOT_WIDGET_BUILD].data        = STR_A003_NEW_AIRCRAFT;
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   819
			w->widget[DEPOT_WIDGET_BUILD].tooltips    = STR_A022_BUILD_NEW_AIRCRAFT;
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   820
			w->widget[DEPOT_WIDGET_CLONE].data        = STR_CLONE_AIRCRAFT;
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   821
			w->widget[DEPOT_WIDGET_CLONE].tooltips    = STR_CLONE_AIRCRAFT_INFO_HANGAR_WINDOW;
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   822
			w->widget[DEPOT_WIDGET_LOCATION].tooltips = STR_A024_CENTER_MAIN_VIEW_ON_HANGAR;
4640
cabffc571e55 (svn r6515) -Feature: added "start all" and "stop all" buttons to the depot windows
bjarni
parents: 4638
diff changeset
   823
cabffc571e55 (svn r6515) -Feature: added "start all" and "stop all" buttons to the depot windows
bjarni
parents: 4638
diff changeset
   824
			/* Special strings only for hangars (using hangar instead of depot and so on) */
cabffc571e55 (svn r6515) -Feature: added "start all" and "stop all" buttons to the depot windows
bjarni
parents: 4638
diff changeset
   825
			w->widget[DEPOT_WIDGET_STOP_ALL].tooltips = STR_MASS_STOP_HANGAR_TOOLTIP;
cabffc571e55 (svn r6515) -Feature: added "start all" and "stop all" buttons to the depot windows
bjarni
parents: 4638
diff changeset
   826
			w->widget[DEPOT_WIDGET_START_ALL].tooltips=	STR_MASS_START_HANGAR_TOOLTIP;
4659
2f99f35d5813 (svn r6542) -Feature: [depot window] added a "sell all vehicles in depot" button
bjarni
parents: 4654
diff changeset
   827
			w->widget[DEPOT_WIDGET_SELL_ALL].tooltips =	STR_DEPOT_SELL_ALL_BUTTON_HANGAR_TIP;
4662
a20121e5442b (svn r6552) -Feature: [depot window] added a "autoreplace all vehicles in depot" button
bjarni
parents: 4659
diff changeset
   828
			w->widget[DEPOT_WIDGET_AUTOREPLACE].tooltips = STR_DEPOT_AUTOREPLACE_HANGAR_TIP;
4638
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   829
			break;
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   830
	}
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   831
}
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   832
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   833
/** Opens a depot window
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   834
 * @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
   835
 * @param type The type of vehicles in the depot
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   836
 */
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   837
void ShowDepotWindow(TileIndex tile, byte type)
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   838
{
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   839
	Window *w;
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   840
4651
bf6abb428dc8 (svn r6527) -Codechange: [depot window] added asserts to ensure that widget names, widget array and array of resize info stays the same length
bjarni
parents: 4650
diff changeset
   841
	/* First we ensure that the widget counts are equal in all 3 lists to prevent bad stuff from happening */
4652
4db9b10ba8d5 (svn r6528) -Fix r6527: fixed an off by one error in an assert
bjarni
parents: 4651
diff changeset
   842
	assert(lengthof(widget_moves) == lengthof(_depot_widgets) - 1); // we should not count WIDGETS_END
4651
bf6abb428dc8 (svn r6527) -Codechange: [depot window] added asserts to ensure that widget names, widget array and array of resize info stays the same length
bjarni
parents: 4650
diff changeset
   843
	assert(lengthof(widget_moves) == DEPOT_WIDGET_LAST);
bf6abb428dc8 (svn r6527) -Codechange: [depot window] added asserts to ensure that widget names, widget array and array of resize info stays the same length
bjarni
parents: 4650
diff changeset
   844
4638
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   845
	switch (type) {
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   846
		case VEH_Train:    w = AllocateWindowDescFront(&_train_depot_desc, tile);    break;
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   847
		case VEH_Road:     w = AllocateWindowDescFront(&_road_depot_desc, tile);     break;
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   848
		case VEH_Ship:     w = AllocateWindowDescFront(&_ship_depot_desc, tile);     break;
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   849
		case VEH_Aircraft: w = AllocateWindowDescFront(&_aircraft_depot_desc, tile); break;
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   850
		default: NOT_REACHED(); w = NULL;
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   851
	}
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   852
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   853
	if (w != NULL) {
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   854
		int16 horizontal = 0, vertical = 0;
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   855
		w->caption_color = GetTileOwner(tile);
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   856
		WP(w, depot_d).type = type;
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   857
		WP(w, depot_d).sel = INVALID_VEHICLE;
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   858
		_backup_orders_tile = 0;
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   859
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   860
		/* Resize the window according to the vehicle type */
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   861
		switch (type) {
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   862
			case VEH_Train:
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   863
				horizontal = 56;
4659
2f99f35d5813 (svn r6542) -Feature: [depot window] added a "sell all vehicles in depot" button
bjarni
parents: 4654
diff changeset
   864
				vertical = 26;
4638
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   865
				w->vscroll.cap = 6;
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   866
				w->hscroll.cap = 10 * 29;
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   867
				w->resize.step_width = 1;
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   868
				w->resize.step_height = 14;
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   869
				break;
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   870
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   871
			case VEH_Road:
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   872
				horizontal = 10;
4659
2f99f35d5813 (svn r6542) -Feature: [depot window] added a "sell all vehicles in depot" button
bjarni
parents: 4654
diff changeset
   873
				vertical = - 14;
2f99f35d5813 (svn r6542) -Feature: [depot window] added a "sell all vehicles in depot" button
bjarni
parents: 4654
diff changeset
   874
				w->vscroll.cap = 4;
4638
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   875
				w->hscroll.cap = 5;
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   876
				w->resize.step_width = 56;
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   877
				w->resize.step_height = 14;
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   878
				break;
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   879
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   880
			case VEH_Ship:
4659
2f99f35d5813 (svn r6542) -Feature: [depot window] added a "sell all vehicles in depot" button
bjarni
parents: 4654
diff changeset
   881
				w->vscroll.cap = 3;
4638
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   882
				w->hscroll.cap = 3;
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   883
				w->resize.step_width = 90;
4667
78fbb91c6c63 (svn r6561) -Fix r6513: [depot window] fixed an off by one error, that caused planes and ships to be drawn one pixel lower for each row
bjarni
parents: 4663
diff changeset
   884
				w->resize.step_height = 23;
4638
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   885
				break;
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   886
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   887
			case VEH_Aircraft:
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   888
				horizontal = 26;
4659
2f99f35d5813 (svn r6542) -Feature: [depot window] added a "sell all vehicles in depot" button
bjarni
parents: 4654
diff changeset
   889
				w->vscroll.cap = 3;
4638
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   890
				w->hscroll.cap = 4;
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   891
				w->resize.step_width = 74;
4667
78fbb91c6c63 (svn r6561) -Fix r6513: [depot window] fixed an off by one error, that caused planes and ships to be drawn one pixel lower for each row
bjarni
parents: 4663
diff changeset
   892
				w->resize.step_height = 23;
4638
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   893
				break;
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   894
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   895
			default: NOT_REACHED();
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   896
		}
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   897
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   898
		SetupStringsForDepotWindow(w, type);
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   899
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   900
		w->widget[DEPOT_WIDGET_MATRIX].data =
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   901
			(w->vscroll.cap * 0x100) // number of rows to draw on the background
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   902
			+ (type == VEH_Train ? 1 : w->hscroll.cap); // number of boxes in each row. Trains always have just one
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
		if (type != VEH_Train) {
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   905
			SETBIT(w->hidden_state, DEPOT_WIDGET_H_SCROLL);
4659
2f99f35d5813 (svn r6542) -Feature: [depot window] added a "sell all vehicles in depot" button
bjarni
parents: 4654
diff changeset
   906
			SETBIT(w->hidden_state, DEPOT_WIDGET_SELL_CHAIN);
4638
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   907
		}
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   908
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   909
		/* Move the widgets to their right locations
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   910
		 * Note: it's signed values so negative will make the widget move left and not right, or up instead of down */
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
   911
		{
4638
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   912
			byte i;
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   913
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
   914
			for (i = 0; i < lengthof(widget_moves); i++) {
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
   915
				if (widget_moves[i] & WIDGET_DEPOT_MOVE_LEFT)   w->widget[i].left   += horizontal;
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
   916
				if (widget_moves[i] & WIDGET_DEPOT_MOVE_RIGHT)  w->widget[i].right  += horizontal;
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
   917
				if (widget_moves[i] & WIDGET_DEPOT_MOVE_TOP)    w->widget[i].top    += vertical;
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
   918
				if (widget_moves[i] & WIDGET_DEPOT_MOVE_BOTTOM) w->widget[i].bottom += vertical;
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
   919
			}
4638
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   920
		}
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
   921
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
   922
		if (type == VEH_Train) {
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
   923
			/* Now we move the train only widgets so they are placed correctly
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
   924
			 * Doing it here will ensure that they move if the widget they are placed on top of/aligned to are moved */
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
   925
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
   926
			/* DEPOT_WIDGET_H_SCROLL is placed in the lowest part of DEPOT_WIDGET_MATRIX */
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
   927
			w->widget[DEPOT_WIDGET_H_SCROLL].left = w->widget[DEPOT_WIDGET_MATRIX].left;
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
   928
			w->widget[DEPOT_WIDGET_H_SCROLL].right = w->widget[DEPOT_WIDGET_MATRIX].right;
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
   929
			w->widget[DEPOT_WIDGET_H_SCROLL].bottom = w->widget[DEPOT_WIDGET_MATRIX].bottom;
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
   930
			w->widget[DEPOT_WIDGET_H_SCROLL].top = w->widget[DEPOT_WIDGET_MATRIX].bottom - 11;
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
   931
			w->widget[DEPOT_WIDGET_MATRIX].bottom -= 12;
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
   932
4659
2f99f35d5813 (svn r6542) -Feature: [depot window] added a "sell all vehicles in depot" button
bjarni
parents: 4654
diff changeset
   933
			/* DEPOT_WIDGET_SELL_CHAIN is under DEPOT_WIDGET_SELL. They got the same left and right and height is controlled in ResizeDepotButtons() */
2f99f35d5813 (svn r6542) -Feature: [depot window] added a "sell all vehicles in depot" button
bjarni
parents: 4654
diff changeset
   934
			w->widget[DEPOT_WIDGET_SELL_CHAIN].left = w->widget[DEPOT_WIDGET_SELL].left;
2f99f35d5813 (svn r6542) -Feature: [depot window] added a "sell all vehicles in depot" button
bjarni
parents: 4654
diff changeset
   935
			w->widget[DEPOT_WIDGET_SELL_CHAIN].right = w->widget[DEPOT_WIDGET_SELL].right;
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
   936
		}
4646
c6f774de4f6f (svn r6522) -Feature: [depot window] the buttons are now "scaled" resized
bjarni
parents: 4644
diff changeset
   937
		ResizeDepotButtons(w);
4638
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   938
	}
8abe4f10b94b (svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff changeset
   939
}