author | bjarni |
Fri, 06 Oct 2006 22:08:37 +0000 | |
changeset 4759 | 10f7465a3c0f |
parent 4758 | 090cf0f1b35e |
child 4762 | 771ccf746531 |
permissions | -rw-r--r-- |
4638
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
1 |
/* $Id$ */ |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
2 |
|
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
3 |
#include "stdafx.h" |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
4 |
#include "openttd.h" |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
5 |
#include "functions.h" |
4654
113ca7bde069
(svn r6530) -Fix r6529: added missing header file (oops)
bjarni
parents:
4653
diff
changeset
|
6 |
#include "train.h" |
113ca7bde069
(svn r6530) -Fix r6529: added missing header file (oops)
bjarni
parents:
4653
diff
changeset
|
7 |
#include "roadveh.h" |
4638
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
8 |
#include "ship.h" |
4653
9f72ab9dc4a7
(svn r6529) -Fix r6513: [depot window] added missing switch in CcCloneVehicle()
bjarni
parents:
4652
diff
changeset
|
9 |
#include "aircraft.h" |
4638
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
10 |
#include "table/strings.h" |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
11 |
#include "table/sprites.h" |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
12 |
#include "gui.h" |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
13 |
#include "gfx.h" |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
14 |
#include "vehicle.h" |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
15 |
#include "viewport.h" |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
16 |
#include "command.h" |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
17 |
#include "depot.h" |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
18 |
#include "vehicle_gui.h" |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
19 |
#include "station_map.h" |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
20 |
#include "newgrf_engine.h" |
4668
f7256d0e7682
(svn r6562) -Codechange: merged the vehicle list window widget arrays
bjarni
parents:
4667
diff
changeset
|
21 |
#include "resize_window_widgets.h" |
4649
38d1633a897d
(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 |
|
38d1633a897d
(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 |
/* |
38d1633a897d
(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 |
* Since all depot window sizes aren't the same, we need to modify sizes a little. |
38d1633a897d
(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 |
* 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. |
38d1633a897d
(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 |
* How long they should be moved and for what window types are controlled in ShowDepotWindow() |
38d1633a897d
(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 |
*/ |
38d1633a897d
(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 |
|
4646
d3d73ee03bbc
(svn r6522) -Feature: [depot window] the buttons are now "scaled" resized
bjarni
parents:
4644
diff
changeset
|
29 |
/* Names of the widgets. Keep them in the same order as in the widget array */ |
d3d73ee03bbc
(svn r6522) -Feature: [depot window] the buttons are now "scaled" resized
bjarni
parents:
4644
diff
changeset
|
30 |
typedef enum DepotWindowWidgets { |
d3d73ee03bbc
(svn r6522) -Feature: [depot window] the buttons are now "scaled" resized
bjarni
parents:
4644
diff
changeset
|
31 |
DEPOT_WIDGET_CLOSEBOX = 0, |
d3d73ee03bbc
(svn r6522) -Feature: [depot window] the buttons are now "scaled" resized
bjarni
parents:
4644
diff
changeset
|
32 |
DEPOT_WIDGET_CAPTION, |
d3d73ee03bbc
(svn r6522) -Feature: [depot window] the buttons are now "scaled" resized
bjarni
parents:
4644
diff
changeset
|
33 |
DEPOT_WIDGET_STICKY, |
d3d73ee03bbc
(svn r6522) -Feature: [depot window] the buttons are now "scaled" resized
bjarni
parents:
4644
diff
changeset
|
34 |
DEPOT_WIDGET_SELL, |
4659
e476c76389a8
(svn r6542) -Feature: [depot window] added a "sell all vehicles in depot" button
bjarni
parents:
4654
diff
changeset
|
35 |
DEPOT_WIDGET_SELL_CHAIN, |
4646
d3d73ee03bbc
(svn r6522) -Feature: [depot window] the buttons are now "scaled" resized
bjarni
parents:
4644
diff
changeset
|
36 |
DEPOT_WIDGET_SELL_ALL, |
4699
525b5057397d
(svn r6609) - Move the mass stop/start buttons of the depot window to the bottom row, to match all other vehicle list windows, and make it look a bit neater, (Suggested by skidd13)
peter1138
parents:
4690
diff
changeset
|
37 |
DEPOT_WIDGET_AUTOREPLACE, |
4646
d3d73ee03bbc
(svn r6522) -Feature: [depot window] the buttons are now "scaled" resized
bjarni
parents:
4644
diff
changeset
|
38 |
DEPOT_WIDGET_MATRIX, |
d3d73ee03bbc
(svn r6522) -Feature: [depot window] the buttons are now "scaled" resized
bjarni
parents:
4644
diff
changeset
|
39 |
DEPOT_WIDGET_V_SCROLL, // Vertical scrollbar |
d3d73ee03bbc
(svn r6522) -Feature: [depot window] the buttons are now "scaled" resized
bjarni
parents:
4644
diff
changeset
|
40 |
DEPOT_WIDGET_H_SCROLL, // Horizontal scrollbar |
d3d73ee03bbc
(svn r6522) -Feature: [depot window] the buttons are now "scaled" resized
bjarni
parents:
4644
diff
changeset
|
41 |
DEPOT_WIDGET_BUILD, |
d3d73ee03bbc
(svn r6522) -Feature: [depot window] the buttons are now "scaled" resized
bjarni
parents:
4644
diff
changeset
|
42 |
DEPOT_WIDGET_CLONE, |
d3d73ee03bbc
(svn r6522) -Feature: [depot window] the buttons are now "scaled" resized
bjarni
parents:
4644
diff
changeset
|
43 |
DEPOT_WIDGET_LOCATION, |
4681
bc077405e9a8
(svn r6586) -Feature: [depot window] added a vehicle list window with all vehicles having a certain depot in their orders
bjarni
parents:
4670
diff
changeset
|
44 |
DEPOT_WIDGET_VEHICLE_LIST, |
4699
525b5057397d
(svn r6609) - Move the mass stop/start buttons of the depot window to the bottom row, to match all other vehicle list windows, and make it look a bit neater, (Suggested by skidd13)
peter1138
parents:
4690
diff
changeset
|
45 |
DEPOT_WIDGET_STOP_ALL, |
525b5057397d
(svn r6609) - Move the mass stop/start buttons of the depot window to the bottom row, to match all other vehicle list windows, and make it look a bit neater, (Suggested by skidd13)
peter1138
parents:
4690
diff
changeset
|
46 |
DEPOT_WIDGET_START_ALL, |
4646
d3d73ee03bbc
(svn r6522) -Feature: [depot window] the buttons are now "scaled" resized
bjarni
parents:
4644
diff
changeset
|
47 |
DEPOT_WIDGET_RESIZE, |
4651
73d828df1b28
(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
|
48 |
DEPOT_WIDGET_LAST, // used to assert if DepotWindowWidgets and widget_moves got different lengths. Due to this usage, it needs to be last |
4646
d3d73ee03bbc
(svn r6522) -Feature: [depot window] the buttons are now "scaled" resized
bjarni
parents:
4644
diff
changeset
|
49 |
} DepotWindowWidget; |
4638
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
50 |
|
4649
38d1633a897d
(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
|
51 |
/* Define how to move each widget. The order is important */ |
38d1633a897d
(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
|
52 |
static const byte widget_moves[] = { |
4668
f7256d0e7682
(svn r6562) -Codechange: merged the vehicle list window widget arrays
bjarni
parents:
4667
diff
changeset
|
53 |
WIDGET_MOVE_NONE, // DEPOT_WIDGET_CLOSEBOX |
f7256d0e7682
(svn r6562) -Codechange: merged the vehicle list window widget arrays
bjarni
parents:
4667
diff
changeset
|
54 |
WIDGET_STRETCH_RIGHT, // DEPOT_WIDGET_CAPTION |
f7256d0e7682
(svn r6562) -Codechange: merged the vehicle list window widget arrays
bjarni
parents:
4667
diff
changeset
|
55 |
WIDGET_MOVE_RIGHT, // DEPOT_WIDGET_STICKY |
f7256d0e7682
(svn r6562) -Codechange: merged the vehicle list window widget arrays
bjarni
parents:
4667
diff
changeset
|
56 |
WIDGET_MOVE_RIGHT, // DEPOT_WIDGET_SELL |
f7256d0e7682
(svn r6562) -Codechange: merged the vehicle list window widget arrays
bjarni
parents:
4667
diff
changeset
|
57 |
WIDGET_MOVE_NONE, // DEPOT_WIDGET_SELL_CHAIN |
f7256d0e7682
(svn r6562) -Codechange: merged the vehicle list window widget arrays
bjarni
parents:
4667
diff
changeset
|
58 |
WIDGET_MOVE_DOWN_RIGHT, // DEPOT_WIDGET_SELL_ALL |
4699
525b5057397d
(svn r6609) - Move the mass stop/start buttons of the depot window to the bottom row, to match all other vehicle list windows, and make it look a bit neater, (Suggested by skidd13)
peter1138
parents:
4690
diff
changeset
|
59 |
WIDGET_MOVE_DOWN_RIGHT, // DEPOT_WIDGET_AUTOREPLACE |
4668
f7256d0e7682
(svn r6562) -Codechange: merged the vehicle list window widget arrays
bjarni
parents:
4667
diff
changeset
|
60 |
WIDGET_STRETCH_DOWN_RIGHT, // DEPOT_WIDGET_MATRIX |
f7256d0e7682
(svn r6562) -Codechange: merged the vehicle list window widget arrays
bjarni
parents:
4667
diff
changeset
|
61 |
WIDGET_MOVE_RIGHT_STRETCH_DOWN, // DEPOT_WIDGET_V_SCROLL |
f7256d0e7682
(svn r6562) -Codechange: merged the vehicle list window widget arrays
bjarni
parents:
4667
diff
changeset
|
62 |
WIDGET_MOVE_NONE, // DEPOT_WIDGET_H_SCROLL |
f7256d0e7682
(svn r6562) -Codechange: merged the vehicle list window widget arrays
bjarni
parents:
4667
diff
changeset
|
63 |
WIDGET_MOVE_DOWN, // DEPOT_WIDGET_BUILD |
f7256d0e7682
(svn r6562) -Codechange: merged the vehicle list window widget arrays
bjarni
parents:
4667
diff
changeset
|
64 |
WIDGET_MOVE_DOWN, // DEPOT_WIDGET_CLONE |
f7256d0e7682
(svn r6562) -Codechange: merged the vehicle list window widget arrays
bjarni
parents:
4667
diff
changeset
|
65 |
WIDGET_MOVE_DOWN, // DEPOT_WIDGET_LOCATION |
4681
bc077405e9a8
(svn r6586) -Feature: [depot window] added a vehicle list window with all vehicles having a certain depot in their orders
bjarni
parents:
4670
diff
changeset
|
66 |
WIDGET_MOVE_DOWN_RIGHT, // DEPOT_WIDGET_VEHICLE_LIST |
4699
525b5057397d
(svn r6609) - Move the mass stop/start buttons of the depot window to the bottom row, to match all other vehicle list windows, and make it look a bit neater, (Suggested by skidd13)
peter1138
parents:
4690
diff
changeset
|
67 |
WIDGET_MOVE_DOWN_RIGHT, // DEPOT_WIDGET_STOP_ALL |
525b5057397d
(svn r6609) - Move the mass stop/start buttons of the depot window to the bottom row, to match all other vehicle list windows, and make it look a bit neater, (Suggested by skidd13)
peter1138
parents:
4690
diff
changeset
|
68 |
WIDGET_MOVE_DOWN_RIGHT, // DEPOT_WIDGET_START_ALL |
4668
f7256d0e7682
(svn r6562) -Codechange: merged the vehicle list window widget arrays
bjarni
parents:
4667
diff
changeset
|
69 |
WIDGET_MOVE_DOWN_RIGHT, // DEPOT_WIDGET_RESIZE |
4649
38d1633a897d
(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 |
}; |
38d1633a897d
(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 |
|
4638
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
72 |
/* Widget array for all depot windows. |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
73 |
* If a widget is needed in some windows only (like train specific), add it for all windows |
4702
c79e9d9f27b3
(svn r6612) -Codechange: Use accessors for hidden_state.
belugas
parents:
4699
diff
changeset
|
74 |
* and use HideWindowWidget in ShowDepotWindow() to remove it in the windows where it should not be |
4638
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
75 |
* Keep the widget numbers in sync with the enum or really bad stuff will happen!!! */ |
4649
38d1633a897d
(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 |
|
38d1633a897d
(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 |
/* 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
52adab371ed7
(svn r6526) -Codechange: [depot window] the train only widgets are now resized depending on the size of other widgets
bjarni
parents:
4649
diff
changeset
|
78 |
* 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 |
52adab371ed7
(svn r6526) -Codechange: [depot window] the train only widgets are now resized depending on the size of other widgets
bjarni
parents:
4649
diff
changeset
|
79 |
* 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. |
52adab371ed7
(svn r6526) -Codechange: [depot window] the train only widgets are now resized depending on the size of other widgets
bjarni
parents:
4649
diff
changeset
|
80 |
* Changing the size of those here will not have an effect at all. It should be done in ShowDepotWindow() |
52adab371ed7
(svn r6526) -Codechange: [depot window] the train only widgets are now resized depending on the size of other widgets
bjarni
parents:
4649
diff
changeset
|
81 |
*/ |
4638
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
82 |
static const Widget _depot_widgets[] = { |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
83 |
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, // DEPOT_WIDGET_CLOSEBOX |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
84 |
{ WWT_CAPTION, RESIZE_RIGHT, 14, 11, 292, 0, 13, 0x0, STR_018C_WINDOW_TITLE_DRAG_THIS}, // DEPOT_WIDGET_CAPTION |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
85 |
{ WWT_STICKYBOX, RESIZE_LR, 14, 293, 304, 0, 13, 0x0, STR_STICKY_BUTTON}, // DEPOT_WIDGET_STICKY |
4640
4e380e2ecfa7
(svn r6515) -Feature: added "start all" and "stop all" buttons to the depot windows
bjarni
parents:
4638
diff
changeset
|
86 |
|
4699
525b5057397d
(svn r6609) - Move the mass stop/start buttons of the depot window to the bottom row, to match all other vehicle list windows, and make it look a bit neater, (Suggested by skidd13)
peter1138
parents:
4690
diff
changeset
|
87 |
{ WWT_IMGBTN, RESIZE_LRB, 14, 270, 292, 14, 37, 0x0, STR_NULL}, // DEPOT_WIDGET_SELL |
4688
9cea258f031f
(svn r6593) -Fix: [depot window] added sprites to the buttons, that lacked one
bjarni
parents:
4686
diff
changeset
|
88 |
{ WWT_PANEL, RESIZE_LRTB, 14, 326, 348, 0, 0, SPR_SELL_CHAIN_TRAIN,STR_DRAG_WHOLE_TRAIN_TO_SELL_TIP}, // DEPOT_WIDGET_SELL_CHAIN, trains only |
4699
525b5057397d
(svn r6609) - Move the mass stop/start buttons of the depot window to the bottom row, to match all other vehicle list windows, and make it look a bit neater, (Suggested by skidd13)
peter1138
parents:
4690
diff
changeset
|
89 |
{ WWT_PUSHIMGBTN, RESIZE_LRTB, 14, 270, 292, 38, 60, 0x0, STR_NULL}, // DEPOT_WIDGET_SELL_ALL |
525b5057397d
(svn r6609) - Move the mass stop/start buttons of the depot window to the bottom row, to match all other vehicle list windows, and make it look a bit neater, (Suggested by skidd13)
peter1138
parents:
4690
diff
changeset
|
90 |
{ WWT_PUSHIMGBTN, RESIZE_LRTB, 14, 270, 292, 61, 83, 0x0, STR_NULL}, // DEPOT_WIDGET_AUTOREPLACE |
4638
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
91 |
|
4659
e476c76389a8
(svn r6542) -Feature: [depot window] added a "sell all vehicles in depot" button
bjarni
parents:
4654
diff
changeset
|
92 |
{ WWT_MATRIX, RESIZE_RB, 14, 0, 269, 14, 83, 0x0, STR_NULL}, // DEPOT_WIDGET_MATRIX |
e476c76389a8
(svn r6542) -Feature: [depot window] added a "sell all vehicles in depot" button
bjarni
parents:
4654
diff
changeset
|
93 |
{ WWT_SCROLLBAR, RESIZE_LRB, 14, 293, 304, 14, 83, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST}, // DEPOT_WIDGET_V_SCROLL |
4638
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
94 |
|
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
95 |
{ WWT_HSCROLLBAR, RESIZE_RTB, 14, 0, 325, 98, 109, 0x0, STR_HSCROLL_BAR_SCROLLS_LIST}, // DEPOT_WIDGET_H_SCROLL, trains only |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
96 |
|
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
97 |
/* The buttons in the bottom of the window. left and right is not important as they are later resized to be equal in size |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
98 |
* This calculation is based on right in DEPOT_WIDGET_LOCATION and it presumes left of DEPOT_WIDGET_BUILD is 0 */ |
4699
525b5057397d
(svn r6609) - Move the mass stop/start buttons of the depot window to the bottom row, to match all other vehicle list windows, and make it look a bit neater, (Suggested by skidd13)
peter1138
parents:
4690
diff
changeset
|
99 |
{ WWT_PUSHTXTBTN, RESIZE_TB, 14, 0, 85, 84, 95, 0x0, STR_NULL}, // DEPOT_WIDGET_BUILD |
525b5057397d
(svn r6609) - Move the mass stop/start buttons of the depot window to the bottom row, to match all other vehicle list windows, and make it look a bit neater, (Suggested by skidd13)
peter1138
parents:
4690
diff
changeset
|
100 |
{WWT_NODISTXTBTN, RESIZE_TB, 14, 86, 170, 84, 95, 0x0, STR_NULL}, // DEPOT_WIDGET_CLONE |
525b5057397d
(svn r6609) - Move the mass stop/start buttons of the depot window to the bottom row, to match all other vehicle list windows, and make it look a bit neater, (Suggested by skidd13)
peter1138
parents:
4690
diff
changeset
|
101 |
{ WWT_PUSHTXTBTN, RESIZE_TB, 14, 171, 257, 84, 95, STR_00E4_LOCATION, STR_NULL}, // DEPOT_WIDGET_LOCATION |
4681
bc077405e9a8
(svn r6586) -Feature: [depot window] added a vehicle list window with all vehicles having a certain depot in their orders
bjarni
parents:
4670
diff
changeset
|
102 |
{ WWT_PUSHTXTBTN, RESIZE_LRTB, 14, 258, 269, 84, 95, 0x0, STR_NULL}, // DEPOT_WIDGET_VEHICLE_LIST |
4699
525b5057397d
(svn r6609) - Move the mass stop/start buttons of the depot window to the bottom row, to match all other vehicle list windows, and make it look a bit neater, (Suggested by skidd13)
peter1138
parents:
4690
diff
changeset
|
103 |
{ WWT_PUSHIMGBTN, RESIZE_LRTB, 14, 270, 280, 84, 95, SPR_FLAG_VEH_STOPPED,STR_NULL}, // DEPOT_WIDGET_STOP_ALL |
525b5057397d
(svn r6609) - Move the mass stop/start buttons of the depot window to the bottom row, to match all other vehicle list windows, and make it look a bit neater, (Suggested by skidd13)
peter1138
parents:
4690
diff
changeset
|
104 |
{ WWT_PUSHIMGBTN, RESIZE_LRTB, 14, 281, 292, 84, 95, SPR_FLAG_VEH_RUNNING,STR_NULL}, // DEPOT_WIDGET_START_ALL |
4659
e476c76389a8
(svn r6542) -Feature: [depot window] added a "sell all vehicles in depot" button
bjarni
parents:
4654
diff
changeset
|
105 |
{ WWT_RESIZEBOX, RESIZE_LRTB, 14, 293, 304, 84, 95, 0x0, STR_RESIZE_BUTTON}, // DEPOT_WIDGET_RESIZE |
4638
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
106 |
{ WIDGETS_END}, |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
107 |
}; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
108 |
|
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
109 |
static void DepotWndProc(Window *w, WindowEvent *e); |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
110 |
|
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
111 |
static const WindowDesc _train_depot_desc = { |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
112 |
-1, -1, 361, 122, |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
113 |
WC_VEHICLE_DEPOT,0, |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
114 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_STICKY_BUTTON | WDF_RESIZABLE, |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
115 |
_depot_widgets, |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
116 |
DepotWndProc |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
117 |
}; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
118 |
|
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
119 |
static const WindowDesc _road_depot_desc = { |
4681
bc077405e9a8
(svn r6586) -Feature: [depot window] added a vehicle list window with all vehicles having a certain depot in their orders
bjarni
parents:
4670
diff
changeset
|
120 |
-1, -1, 315, 96, |
4638
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
121 |
WC_VEHICLE_DEPOT,0, |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
122 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_STICKY_BUTTON | WDF_RESIZABLE, |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
123 |
_depot_widgets, |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
124 |
DepotWndProc |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
125 |
}; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
126 |
|
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
127 |
static const WindowDesc _ship_depot_desc = { |
4659
e476c76389a8
(svn r6542) -Feature: [depot window] added a "sell all vehicles in depot" button
bjarni
parents:
4654
diff
changeset
|
128 |
-1, -1, 305, 96, |
4638
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
129 |
WC_VEHICLE_DEPOT,0, |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
130 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_STICKY_BUTTON | WDF_RESIZABLE, |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
131 |
_depot_widgets, |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
132 |
DepotWndProc |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
133 |
}; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
134 |
|
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
135 |
static const WindowDesc _aircraft_depot_desc = { |
4659
e476c76389a8
(svn r6542) -Feature: [depot window] added a "sell all vehicles in depot" button
bjarni
parents:
4654
diff
changeset
|
136 |
-1, -1, 331, 96, |
4638
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
137 |
WC_VEHICLE_DEPOT,0, |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
138 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_STICKY_BUTTON | WDF_RESIZABLE, |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
139 |
_depot_widgets, |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
140 |
DepotWndProc |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
141 |
}; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
142 |
|
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
143 |
extern int WagonLengthToPixels(int len); |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
144 |
|
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
145 |
void CcCloneVehicle(bool success, TileIndex tile, uint32 p1, uint32 p2) |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
146 |
{ |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
147 |
if (!success) return; |
4653
9f72ab9dc4a7
(svn r6529) -Fix r6513: [depot window] added missing switch in CcCloneVehicle()
bjarni
parents:
4652
diff
changeset
|
148 |
switch(GetVehicle(p1)->type) { |
9f72ab9dc4a7
(svn r6529) -Fix r6513: [depot window] added missing switch in CcCloneVehicle()
bjarni
parents:
4652
diff
changeset
|
149 |
case VEH_Train: CcCloneTrain( true, tile, p1, p2); break; |
9f72ab9dc4a7
(svn r6529) -Fix r6513: [depot window] added missing switch in CcCloneVehicle()
bjarni
parents:
4652
diff
changeset
|
150 |
case VEH_Road: CcCloneRoadVeh( true, tile, p1, p2); break; |
9f72ab9dc4a7
(svn r6529) -Fix r6513: [depot window] added missing switch in CcCloneVehicle()
bjarni
parents:
4652
diff
changeset
|
151 |
case VEH_Ship: CcCloneShip( true, tile, p1, p2); break; |
9f72ab9dc4a7
(svn r6529) -Fix r6513: [depot window] added missing switch in CcCloneVehicle()
bjarni
parents:
4652
diff
changeset
|
152 |
case VEH_Aircraft: CcCloneAircraft(true, tile, p1, p2); break; |
9f72ab9dc4a7
(svn r6529) -Fix r6513: [depot window] added missing switch in CcCloneVehicle()
bjarni
parents:
4652
diff
changeset
|
153 |
} |
4638
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
154 |
} |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
155 |
|
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
156 |
static inline void ShowVehicleViewWindow(const Vehicle *v) |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
157 |
{ |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
158 |
switch (v->type) { |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
159 |
case VEH_Train: ShowTrainViewWindow(v); break; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
160 |
case VEH_Road: ShowRoadVehViewWindow(v); break; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
161 |
case VEH_Ship: ShowShipViewWindow(v); break; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
162 |
case VEH_Aircraft: ShowAircraftViewWindow(v); break; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
163 |
default: NOT_REACHED(); |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
164 |
} |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
165 |
} |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
166 |
|
4659
e476c76389a8
(svn r6542) -Feature: [depot window] added a "sell all vehicles in depot" button
bjarni
parents:
4654
diff
changeset
|
167 |
static void DepotSellAllWndProc(Window *w, WindowEvent *e) |
e476c76389a8
(svn r6542) -Feature: [depot window] added a "sell all vehicles in depot" button
bjarni
parents:
4654
diff
changeset
|
168 |
{ |
4670
ad77557a614d
(svn r6567) -Fix r6542: [depot window] solved an issue where the confimation window sometimes failed to close (spotted by MacLir)
bjarni
parents:
4668
diff
changeset
|
169 |
TileIndex tile = w->window_number; |
ad77557a614d
(svn r6567) -Fix r6542: [depot window] solved an issue where the confimation window sometimes failed to close (spotted by MacLir)
bjarni
parents:
4668
diff
changeset
|
170 |
byte vehicle_type = WP(w, depot_d).type; |
ad77557a614d
(svn r6567) -Fix r6542: [depot window] solved an issue where the confimation window sometimes failed to close (spotted by MacLir)
bjarni
parents:
4668
diff
changeset
|
171 |
|
4659
e476c76389a8
(svn r6542) -Feature: [depot window] added a "sell all vehicles in depot" button
bjarni
parents:
4654
diff
changeset
|
172 |
switch (e->event) { |
e476c76389a8
(svn r6542) -Feature: [depot window] added a "sell all vehicles in depot" button
bjarni
parents:
4654
diff
changeset
|
173 |
case WE_PAINT: |
4670
ad77557a614d
(svn r6567) -Fix r6542: [depot window] solved an issue where the confimation window sometimes failed to close (spotted by MacLir)
bjarni
parents:
4668
diff
changeset
|
174 |
if (vehicle_type == VEH_Aircraft) { |
ad77557a614d
(svn r6567) -Fix r6542: [depot window] solved an issue where the confimation window sometimes failed to close (spotted by MacLir)
bjarni
parents:
4668
diff
changeset
|
175 |
SetDParam(0, GetStationIndex(tile)); // Airport name |
4659
e476c76389a8
(svn r6542) -Feature: [depot window] added a "sell all vehicles in depot" button
bjarni
parents:
4654
diff
changeset
|
176 |
} else { |
4670
ad77557a614d
(svn r6567) -Fix r6542: [depot window] solved an issue where the confimation window sometimes failed to close (spotted by MacLir)
bjarni
parents:
4668
diff
changeset
|
177 |
Depot *depot = GetDepotByTile(tile); |
4659
e476c76389a8
(svn r6542) -Feature: [depot window] added a "sell all vehicles in depot" button
bjarni
parents:
4654
diff
changeset
|
178 |
assert(depot != NULL); |
e476c76389a8
(svn r6542) -Feature: [depot window] added a "sell all vehicles in depot" button
bjarni
parents:
4654
diff
changeset
|
179 |
|
e476c76389a8
(svn r6542) -Feature: [depot window] added a "sell all vehicles in depot" button
bjarni
parents:
4654
diff
changeset
|
180 |
SetDParam(0, depot->town_index); |
e476c76389a8
(svn r6542) -Feature: [depot window] added a "sell all vehicles in depot" button
bjarni
parents:
4654
diff
changeset
|
181 |
} |
e476c76389a8
(svn r6542) -Feature: [depot window] added a "sell all vehicles in depot" button
bjarni
parents:
4654
diff
changeset
|
182 |
DrawWindowWidgets(w); |
e476c76389a8
(svn r6542) -Feature: [depot window] added a "sell all vehicles in depot" button
bjarni
parents:
4654
diff
changeset
|
183 |
|
e476c76389a8
(svn r6542) -Feature: [depot window] added a "sell all vehicles in depot" button
bjarni
parents:
4654
diff
changeset
|
184 |
DrawStringCentered(150, 25, STR_DEPOT_SELL_ALL_VEHICLE_CONFIRM, 0); |
e476c76389a8
(svn r6542) -Feature: [depot window] added a "sell all vehicles in depot" button
bjarni
parents:
4654
diff
changeset
|
185 |
DrawStringCentered(150, 38, STR_ARE_YOU_SURE, 0); |
e476c76389a8
(svn r6542) -Feature: [depot window] added a "sell all vehicles in depot" button
bjarni
parents:
4654
diff
changeset
|
186 |
break; |
e476c76389a8
(svn r6542) -Feature: [depot window] added a "sell all vehicles in depot" button
bjarni
parents:
4654
diff
changeset
|
187 |
|
e476c76389a8
(svn r6542) -Feature: [depot window] added a "sell all vehicles in depot" button
bjarni
parents:
4654
diff
changeset
|
188 |
case WE_CLICK: |
e476c76389a8
(svn r6542) -Feature: [depot window] added a "sell all vehicles in depot" button
bjarni
parents:
4654
diff
changeset
|
189 |
switch (e->we.click.widget) { |
e476c76389a8
(svn r6542) -Feature: [depot window] added a "sell all vehicles in depot" button
bjarni
parents:
4654
diff
changeset
|
190 |
case 4: |
4670
ad77557a614d
(svn r6567) -Fix r6542: [depot window] solved an issue where the confimation window sometimes failed to close (spotted by MacLir)
bjarni
parents:
4668
diff
changeset
|
191 |
/* Weird issue here. If We execute the DoCommandP first, then the window is not closed */ |
ad77557a614d
(svn r6567) -Fix r6542: [depot window] solved an issue where the confimation window sometimes failed to close (spotted by MacLir)
bjarni
parents:
4668
diff
changeset
|
192 |
DeleteWindow(w); |
ad77557a614d
(svn r6567) -Fix r6542: [depot window] solved an issue where the confimation window sometimes failed to close (spotted by MacLir)
bjarni
parents:
4668
diff
changeset
|
193 |
DoCommandP(tile, vehicle_type, 0, NULL, CMD_DEPOT_SELL_ALL_VEHICLES); |
ad77557a614d
(svn r6567) -Fix r6542: [depot window] solved an issue where the confimation window sometimes failed to close (spotted by MacLir)
bjarni
parents:
4668
diff
changeset
|
194 |
break; |
ad77557a614d
(svn r6567) -Fix r6542: [depot window] solved an issue where the confimation window sometimes failed to close (spotted by MacLir)
bjarni
parents:
4668
diff
changeset
|
195 |
|
4659
e476c76389a8
(svn r6542) -Feature: [depot window] added a "sell all vehicles in depot" button
bjarni
parents:
4654
diff
changeset
|
196 |
case 3: |
e476c76389a8
(svn r6542) -Feature: [depot window] added a "sell all vehicles in depot" button
bjarni
parents:
4654
diff
changeset
|
197 |
DeleteWindow(w); |
e476c76389a8
(svn r6542) -Feature: [depot window] added a "sell all vehicles in depot" button
bjarni
parents:
4654
diff
changeset
|
198 |
break; |
e476c76389a8
(svn r6542) -Feature: [depot window] added a "sell all vehicles in depot" button
bjarni
parents:
4654
diff
changeset
|
199 |
} |
e476c76389a8
(svn r6542) -Feature: [depot window] added a "sell all vehicles in depot" button
bjarni
parents:
4654
diff
changeset
|
200 |
break; |
e476c76389a8
(svn r6542) -Feature: [depot window] added a "sell all vehicles in depot" button
bjarni
parents:
4654
diff
changeset
|
201 |
} |
e476c76389a8
(svn r6542) -Feature: [depot window] added a "sell all vehicles in depot" button
bjarni
parents:
4654
diff
changeset
|
202 |
} |
e476c76389a8
(svn r6542) -Feature: [depot window] added a "sell all vehicles in depot" button
bjarni
parents:
4654
diff
changeset
|
203 |
|
e476c76389a8
(svn r6542) -Feature: [depot window] added a "sell all vehicles in depot" button
bjarni
parents:
4654
diff
changeset
|
204 |
static const Widget _depot_sell_all_widgets[] = { |
4670
ad77557a614d
(svn r6567) -Fix r6542: [depot window] solved an issue where the confimation window sometimes failed to close (spotted by MacLir)
bjarni
parents:
4668
diff
changeset
|
205 |
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
ad77557a614d
(svn r6567) -Fix r6542: [depot window] solved an issue where the confimation window sometimes failed to close (spotted by MacLir)
bjarni
parents:
4668
diff
changeset
|
206 |
{ WWT_CAPTION, RESIZE_NONE, 14, 11, 299, 0, 13, 0x0, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
ad77557a614d
(svn r6567) -Fix r6542: [depot window] solved an issue where the confimation window sometimes failed to close (spotted by MacLir)
bjarni
parents:
4668
diff
changeset
|
207 |
{ WWT_PANEL, RESIZE_NONE, 14, 0, 299, 14, 71, 0x0, STR_NULL}, |
4686
e438e8b2ab61
(svn r6591) -Codechange: changed strings that used the word "depot" into one for each vehicle type
bjarni
parents:
4681
diff
changeset
|
208 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 14, 85, 144, 52, 63, STR_012E_CANCEL, STR_NULL}, |
e438e8b2ab61
(svn r6591) -Codechange: changed strings that used the word "depot" into one for each vehicle type
bjarni
parents:
4681
diff
changeset
|
209 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 14, 155, 214, 52, 63, STR_SELL, STR_NULL}, |
4659
e476c76389a8
(svn r6542) -Feature: [depot window] added a "sell all vehicles in depot" button
bjarni
parents:
4654
diff
changeset
|
210 |
{ WIDGETS_END}, |
e476c76389a8
(svn r6542) -Feature: [depot window] added a "sell all vehicles in depot" button
bjarni
parents:
4654
diff
changeset
|
211 |
}; |
e476c76389a8
(svn r6542) -Feature: [depot window] added a "sell all vehicles in depot" button
bjarni
parents:
4654
diff
changeset
|
212 |
|
e476c76389a8
(svn r6542) -Feature: [depot window] added a "sell all vehicles in depot" button
bjarni
parents:
4654
diff
changeset
|
213 |
static const WindowDesc _depot_sell_all_desc = { |
e476c76389a8
(svn r6542) -Feature: [depot window] added a "sell all vehicles in depot" button
bjarni
parents:
4654
diff
changeset
|
214 |
WDP_CENTER, WDP_CENTER, 300, 72, |
4745
008f7cbbb5bc
(svn r6657) -Change: [depot window] sell all vehicles in depot confirm window now opens on top of depot window instead of in the middle of the screen
bjarni
parents:
4740
diff
changeset
|
215 |
WC_DEPOT_SELL_ALL, WC_VEHICLE_DEPOT, |
4659
e476c76389a8
(svn r6542) -Feature: [depot window] added a "sell all vehicles in depot" button
bjarni
parents:
4654
diff
changeset
|
216 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET, |
e476c76389a8
(svn r6542) -Feature: [depot window] added a "sell all vehicles in depot" button
bjarni
parents:
4654
diff
changeset
|
217 |
_depot_sell_all_widgets, |
e476c76389a8
(svn r6542) -Feature: [depot window] added a "sell all vehicles in depot" button
bjarni
parents:
4654
diff
changeset
|
218 |
DepotSellAllWndProc |
e476c76389a8
(svn r6542) -Feature: [depot window] added a "sell all vehicles in depot" button
bjarni
parents:
4654
diff
changeset
|
219 |
}; |
e476c76389a8
(svn r6542) -Feature: [depot window] added a "sell all vehicles in depot" button
bjarni
parents:
4654
diff
changeset
|
220 |
|
e476c76389a8
(svn r6542) -Feature: [depot window] added a "sell all vehicles in depot" button
bjarni
parents:
4654
diff
changeset
|
221 |
static void ShowDepotSellAllWindow(TileIndex tile, byte type) |
e476c76389a8
(svn r6542) -Feature: [depot window] added a "sell all vehicles in depot" button
bjarni
parents:
4654
diff
changeset
|
222 |
{ |
e476c76389a8
(svn r6542) -Feature: [depot window] added a "sell all vehicles in depot" button
bjarni
parents:
4654
diff
changeset
|
223 |
Window *w; |
e476c76389a8
(svn r6542) -Feature: [depot window] added a "sell all vehicles in depot" button
bjarni
parents:
4654
diff
changeset
|
224 |
|
4745
008f7cbbb5bc
(svn r6657) -Change: [depot window] sell all vehicles in depot confirm window now opens on top of depot window instead of in the middle of the screen
bjarni
parents:
4740
diff
changeset
|
225 |
_alloc_wnd_parent_num = tile; |
4659
e476c76389a8
(svn r6542) -Feature: [depot window] added a "sell all vehicles in depot" button
bjarni
parents:
4654
diff
changeset
|
226 |
w = AllocateWindowDescFront(&_depot_sell_all_desc, tile); |
e476c76389a8
(svn r6542) -Feature: [depot window] added a "sell all vehicles in depot" button
bjarni
parents:
4654
diff
changeset
|
227 |
|
e476c76389a8
(svn r6542) -Feature: [depot window] added a "sell all vehicles in depot" button
bjarni
parents:
4654
diff
changeset
|
228 |
if (w != NULL) { |
4670
ad77557a614d
(svn r6567) -Fix r6542: [depot window] solved an issue where the confimation window sometimes failed to close (spotted by MacLir)
bjarni
parents:
4668
diff
changeset
|
229 |
w->caption_color = GetTileOwner(tile); |
4659
e476c76389a8
(svn r6542) -Feature: [depot window] added a "sell all vehicles in depot" button
bjarni
parents:
4654
diff
changeset
|
230 |
WP(w, depot_d).type = type; |
e476c76389a8
(svn r6542) -Feature: [depot window] added a "sell all vehicles in depot" button
bjarni
parents:
4654
diff
changeset
|
231 |
switch (type) { |
4686
e438e8b2ab61
(svn r6591) -Codechange: changed strings that used the word "depot" into one for each vehicle type
bjarni
parents:
4681
diff
changeset
|
232 |
case VEH_Train: |
e438e8b2ab61
(svn r6591) -Codechange: changed strings that used the word "depot" into one for each vehicle type
bjarni
parents:
4681
diff
changeset
|
233 |
w->widget[1].data = STR_8800_TRAIN_DEPOT; |
e438e8b2ab61
(svn r6591) -Codechange: changed strings that used the word "depot" into one for each vehicle type
bjarni
parents:
4681
diff
changeset
|
234 |
w->widget[3].tooltips = STR_DEPOT_SELL_ALL_CANCEL_TRAIN_TIP; |
e438e8b2ab61
(svn r6591) -Codechange: changed strings that used the word "depot" into one for each vehicle type
bjarni
parents:
4681
diff
changeset
|
235 |
w->widget[4].tooltips = STR_DEPOT_SELL_ALL_TRAIN_TIP; |
e438e8b2ab61
(svn r6591) -Codechange: changed strings that used the word "depot" into one for each vehicle type
bjarni
parents:
4681
diff
changeset
|
236 |
break; |
e438e8b2ab61
(svn r6591) -Codechange: changed strings that used the word "depot" into one for each vehicle type
bjarni
parents:
4681
diff
changeset
|
237 |
|
e438e8b2ab61
(svn r6591) -Codechange: changed strings that used the word "depot" into one for each vehicle type
bjarni
parents:
4681
diff
changeset
|
238 |
case VEH_Road: |
e438e8b2ab61
(svn r6591) -Codechange: changed strings that used the word "depot" into one for each vehicle type
bjarni
parents:
4681
diff
changeset
|
239 |
w->widget[1].data = STR_9003_ROAD_VEHICLE_DEPOT; |
e438e8b2ab61
(svn r6591) -Codechange: changed strings that used the word "depot" into one for each vehicle type
bjarni
parents:
4681
diff
changeset
|
240 |
w->widget[3].tooltips = STR_DEPOT_SELL_ALL_CANCEL_ROADVEH_TIP; |
e438e8b2ab61
(svn r6591) -Codechange: changed strings that used the word "depot" into one for each vehicle type
bjarni
parents:
4681
diff
changeset
|
241 |
w->widget[4].tooltips = STR_DEPOT_SELL_ALL_ROADVEH_TIP; |
e438e8b2ab61
(svn r6591) -Codechange: changed strings that used the word "depot" into one for each vehicle type
bjarni
parents:
4681
diff
changeset
|
242 |
break; |
e438e8b2ab61
(svn r6591) -Codechange: changed strings that used the word "depot" into one for each vehicle type
bjarni
parents:
4681
diff
changeset
|
243 |
|
e438e8b2ab61
(svn r6591) -Codechange: changed strings that used the word "depot" into one for each vehicle type
bjarni
parents:
4681
diff
changeset
|
244 |
case VEH_Ship: |
e438e8b2ab61
(svn r6591) -Codechange: changed strings that used the word "depot" into one for each vehicle type
bjarni
parents:
4681
diff
changeset
|
245 |
w->widget[1].data = STR_9803_SHIP_DEPOT; |
e438e8b2ab61
(svn r6591) -Codechange: changed strings that used the word "depot" into one for each vehicle type
bjarni
parents:
4681
diff
changeset
|
246 |
w->widget[3].tooltips = STR_DEPOT_SELL_ALL_CANCEL_SHIP_TIP; |
e438e8b2ab61
(svn r6591) -Codechange: changed strings that used the word "depot" into one for each vehicle type
bjarni
parents:
4681
diff
changeset
|
247 |
w->widget[4].tooltips = STR_DEPOT_SELL_ALL_SHIP_TIP; |
e438e8b2ab61
(svn r6591) -Codechange: changed strings that used the word "depot" into one for each vehicle type
bjarni
parents:
4681
diff
changeset
|
248 |
break; |
e438e8b2ab61
(svn r6591) -Codechange: changed strings that used the word "depot" into one for each vehicle type
bjarni
parents:
4681
diff
changeset
|
249 |
|
4659
e476c76389a8
(svn r6542) -Feature: [depot window] added a "sell all vehicles in depot" button
bjarni
parents:
4654
diff
changeset
|
250 |
case VEH_Aircraft: |
e476c76389a8
(svn r6542) -Feature: [depot window] added a "sell all vehicles in depot" button
bjarni
parents:
4654
diff
changeset
|
251 |
w->widget[1].data = STR_A002_AIRCRAFT_HANGAR; |
4686
e438e8b2ab61
(svn r6591) -Codechange: changed strings that used the word "depot" into one for each vehicle type
bjarni
parents:
4681
diff
changeset
|
252 |
w->widget[3].tooltips = STR_DEPOT_SELL_ALL_CANCEL_AIRCRAFT_TIP; |
e438e8b2ab61
(svn r6591) -Codechange: changed strings that used the word "depot" into one for each vehicle type
bjarni
parents:
4681
diff
changeset
|
253 |
w->widget[4].tooltips = STR_DEPOT_SELL_ALL_AIRCRAFT_TIP; |
4659
e476c76389a8
(svn r6542) -Feature: [depot window] added a "sell all vehicles in depot" button
bjarni
parents:
4654
diff
changeset
|
254 |
break; |
e476c76389a8
(svn r6542) -Feature: [depot window] added a "sell all vehicles in depot" button
bjarni
parents:
4654
diff
changeset
|
255 |
} |
e476c76389a8
(svn r6542) -Feature: [depot window] added a "sell all vehicles in depot" button
bjarni
parents:
4654
diff
changeset
|
256 |
} |
e476c76389a8
(svn r6542) -Feature: [depot window] added a "sell all vehicles in depot" button
bjarni
parents:
4654
diff
changeset
|
257 |
} |
e476c76389a8
(svn r6542) -Feature: [depot window] added a "sell all vehicles in depot" button
bjarni
parents:
4654
diff
changeset
|
258 |
|
4754
26ddeca70f94
(svn r6668) -Codechange: [depot window] simplified the engine drawing loop in the depot window
bjarni
parents:
4745
diff
changeset
|
259 |
/** Draw a vehicle in the depot window in the box with the top left corner at x,y |
26ddeca70f94
(svn r6668) -Codechange: [depot window] simplified the engine drawing loop in the depot window
bjarni
parents:
4745
diff
changeset
|
260 |
* @param *w Window to draw in |
26ddeca70f94
(svn r6668) -Codechange: [depot window] simplified the engine drawing loop in the depot window
bjarni
parents:
4745
diff
changeset
|
261 |
* @param *v Vehicle to draw |
26ddeca70f94
(svn r6668) -Codechange: [depot window] simplified the engine drawing loop in the depot window
bjarni
parents:
4745
diff
changeset
|
262 |
* @param x Left side of the box to draw in |
26ddeca70f94
(svn r6668) -Codechange: [depot window] simplified the engine drawing loop in the depot window
bjarni
parents:
4745
diff
changeset
|
263 |
* @param y Top of the box to draw in |
26ddeca70f94
(svn r6668) -Codechange: [depot window] simplified the engine drawing loop in the depot window
bjarni
parents:
4745
diff
changeset
|
264 |
*/ |
26ddeca70f94
(svn r6668) -Codechange: [depot window] simplified the engine drawing loop in the depot window
bjarni
parents:
4745
diff
changeset
|
265 |
static void DrawVehicleInDepot(Window *w, const Vehicle *v, int x, int y) |
26ddeca70f94
(svn r6668) -Codechange: [depot window] simplified the engine drawing loop in the depot window
bjarni
parents:
4745
diff
changeset
|
266 |
{ |
26ddeca70f94
(svn r6668) -Codechange: [depot window] simplified the engine drawing loop in the depot window
bjarni
parents:
4745
diff
changeset
|
267 |
byte diff_x = 0, diff_y = 0; |
26ddeca70f94
(svn r6668) -Codechange: [depot window] simplified the engine drawing loop in the depot window
bjarni
parents:
4745
diff
changeset
|
268 |
|
26ddeca70f94
(svn r6668) -Codechange: [depot window] simplified the engine drawing loop in the depot window
bjarni
parents:
4745
diff
changeset
|
269 |
switch (v->type) { |
26ddeca70f94
(svn r6668) -Codechange: [depot window] simplified the engine drawing loop in the depot window
bjarni
parents:
4745
diff
changeset
|
270 |
case VEH_Train: |
26ddeca70f94
(svn r6668) -Codechange: [depot window] simplified the engine drawing loop in the depot window
bjarni
parents:
4745
diff
changeset
|
271 |
DrawTrainImage(v, x + 21, y, w->hscroll.cap + 4, w->hscroll.pos, WP(w,depot_d).sel); |
26ddeca70f94
(svn r6668) -Codechange: [depot window] simplified the engine drawing loop in the depot window
bjarni
parents:
4745
diff
changeset
|
272 |
|
26ddeca70f94
(svn r6668) -Codechange: [depot window] simplified the engine drawing loop in the depot window
bjarni
parents:
4745
diff
changeset
|
273 |
/* Number of wagons relative to a standard length wagon (rounded up) */ |
26ddeca70f94
(svn r6668) -Codechange: [depot window] simplified the engine drawing loop in the depot window
bjarni
parents:
4745
diff
changeset
|
274 |
SetDParam(0, (v->u.rail.cached_total_length + 7) / 8); |
26ddeca70f94
(svn r6668) -Codechange: [depot window] simplified the engine drawing loop in the depot window
bjarni
parents:
4745
diff
changeset
|
275 |
DrawStringRightAligned(w->widget[DEPOT_WIDGET_MATRIX].right - 1, y + 4, STR_TINY_BLACK, 0); // Draw the counter |
26ddeca70f94
(svn r6668) -Codechange: [depot window] simplified the engine drawing loop in the depot window
bjarni
parents:
4745
diff
changeset
|
276 |
break; |
26ddeca70f94
(svn r6668) -Codechange: [depot window] simplified the engine drawing loop in the depot window
bjarni
parents:
4745
diff
changeset
|
277 |
|
26ddeca70f94
(svn r6668) -Codechange: [depot window] simplified the engine drawing loop in the depot window
bjarni
parents:
4745
diff
changeset
|
278 |
case VEH_Road: DrawRoadVehImage( v, x + 24, y, WP(w, depot_d).sel); break; |
26ddeca70f94
(svn r6668) -Codechange: [depot window] simplified the engine drawing loop in the depot window
bjarni
parents:
4745
diff
changeset
|
279 |
case VEH_Ship: DrawShipImage( v, x + 19, y, WP(w, depot_d).sel); break; |
26ddeca70f94
(svn r6668) -Codechange: [depot window] simplified the engine drawing loop in the depot window
bjarni
parents:
4745
diff
changeset
|
280 |
case VEH_Aircraft: DrawAircraftImage(v, x + 12, y, WP(w, depot_d).sel); break; |
26ddeca70f94
(svn r6668) -Codechange: [depot window] simplified the engine drawing loop in the depot window
bjarni
parents:
4745
diff
changeset
|
281 |
default: NOT_REACHED(); |
26ddeca70f94
(svn r6668) -Codechange: [depot window] simplified the engine drawing loop in the depot window
bjarni
parents:
4745
diff
changeset
|
282 |
} |
26ddeca70f94
(svn r6668) -Codechange: [depot window] simplified the engine drawing loop in the depot window
bjarni
parents:
4745
diff
changeset
|
283 |
|
26ddeca70f94
(svn r6668) -Codechange: [depot window] simplified the engine drawing loop in the depot window
bjarni
parents:
4745
diff
changeset
|
284 |
if (w->resize.step_height == 14) { |
26ddeca70f94
(svn r6668) -Codechange: [depot window] simplified the engine drawing loop in the depot window
bjarni
parents:
4745
diff
changeset
|
285 |
/* VEH_Train and VEH_Road, which are low */ |
26ddeca70f94
(svn r6668) -Codechange: [depot window] simplified the engine drawing loop in the depot window
bjarni
parents:
4745
diff
changeset
|
286 |
diff_x = 15; |
26ddeca70f94
(svn r6668) -Codechange: [depot window] simplified the engine drawing loop in the depot window
bjarni
parents:
4745
diff
changeset
|
287 |
} else { |
26ddeca70f94
(svn r6668) -Codechange: [depot window] simplified the engine drawing loop in the depot window
bjarni
parents:
4745
diff
changeset
|
288 |
/* VEH_Ship and VEH_Aircraft, which are tall */ |
26ddeca70f94
(svn r6668) -Codechange: [depot window] simplified the engine drawing loop in the depot window
bjarni
parents:
4745
diff
changeset
|
289 |
diff_y = 12; |
26ddeca70f94
(svn r6668) -Codechange: [depot window] simplified the engine drawing loop in the depot window
bjarni
parents:
4745
diff
changeset
|
290 |
} |
26ddeca70f94
(svn r6668) -Codechange: [depot window] simplified the engine drawing loop in the depot window
bjarni
parents:
4745
diff
changeset
|
291 |
|
26ddeca70f94
(svn r6668) -Codechange: [depot window] simplified the engine drawing loop in the depot window
bjarni
parents:
4745
diff
changeset
|
292 |
DrawSprite((v->vehstatus & VS_STOPPED) ? SPR_FLAG_VEH_STOPPED : SPR_FLAG_VEH_RUNNING, x + diff_x, y + diff_y); |
26ddeca70f94
(svn r6668) -Codechange: [depot window] simplified the engine drawing loop in the depot window
bjarni
parents:
4745
diff
changeset
|
293 |
|
26ddeca70f94
(svn r6668) -Codechange: [depot window] simplified the engine drawing loop in the depot window
bjarni
parents:
4745
diff
changeset
|
294 |
SetDParam(0, v->unitnumber); |
26ddeca70f94
(svn r6668) -Codechange: [depot window] simplified the engine drawing loop in the depot window
bjarni
parents:
4745
diff
changeset
|
295 |
DrawString(x, y + 2, (uint16)(v->max_age-366) >= v->age ? STR_00E2 : STR_00E3, 0); |
26ddeca70f94
(svn r6668) -Codechange: [depot window] simplified the engine drawing loop in the depot window
bjarni
parents:
4745
diff
changeset
|
296 |
} |
26ddeca70f94
(svn r6668) -Codechange: [depot window] simplified the engine drawing loop in the depot window
bjarni
parents:
4745
diff
changeset
|
297 |
|
4638
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
298 |
static void DrawDepotWindow(Window *w) |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
299 |
{ |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
300 |
Vehicle **vl = WP(w, depot_d).vehicle_list; |
4709
a81ab800c25b
(svn r6619) -Codechange: Use accessors for disabled_state.
belugas
parents:
4702
diff
changeset
|
301 |
TileIndex tile = w->window_number; |
4638
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
302 |
int x, y, i, hnum, max; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
303 |
uint16 num = WP(w, depot_d).engine_count; |
4754
26ddeca70f94
(svn r6668) -Codechange: [depot window] simplified the engine drawing loop in the depot window
bjarni
parents:
4745
diff
changeset
|
304 |
|
26ddeca70f94
(svn r6668) -Codechange: [depot window] simplified the engine drawing loop in the depot window
bjarni
parents:
4745
diff
changeset
|
305 |
/* Set the row and number of boxes in each row based on the number of boxes drawn in the matrix */ |
26ddeca70f94
(svn r6668) -Codechange: [depot window] simplified the engine drawing loop in the depot window
bjarni
parents:
4745
diff
changeset
|
306 |
uint16 rows_in_display = w->widget[DEPOT_WIDGET_MATRIX].data >> 8; |
26ddeca70f94
(svn r6668) -Codechange: [depot window] simplified the engine drawing loop in the depot window
bjarni
parents:
4745
diff
changeset
|
307 |
uint16 boxes_in_each_row = w->widget[DEPOT_WIDGET_MATRIX].data & 0xFF; |
4638
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
308 |
|
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
309 |
/* setup disabled buttons */ |
4758
090cf0f1b35e
(svn r6672) -Codechange: [depot & vehicle windows] applied SetWindowWidgetsDisabledState() and SetWindowWidgetsHiddenState() to depot and vehicle windows
bjarni
parents:
4754
diff
changeset
|
310 |
SetWindowWidgetsDisabledState(w, !IsTileOwner(tile, _local_player), |
090cf0f1b35e
(svn r6672) -Codechange: [depot & vehicle windows] applied SetWindowWidgetsDisabledState() and SetWindowWidgetsHiddenState() to depot and vehicle windows
bjarni
parents:
4754
diff
changeset
|
311 |
DEPOT_WIDGET_STOP_ALL, |
090cf0f1b35e
(svn r6672) -Codechange: [depot & vehicle windows] applied SetWindowWidgetsDisabledState() and SetWindowWidgetsHiddenState() to depot and vehicle windows
bjarni
parents:
4754
diff
changeset
|
312 |
DEPOT_WIDGET_START_ALL, |
090cf0f1b35e
(svn r6672) -Codechange: [depot & vehicle windows] applied SetWindowWidgetsDisabledState() and SetWindowWidgetsHiddenState() to depot and vehicle windows
bjarni
parents:
4754
diff
changeset
|
313 |
DEPOT_WIDGET_SELL, |
090cf0f1b35e
(svn r6672) -Codechange: [depot & vehicle windows] applied SetWindowWidgetsDisabledState() and SetWindowWidgetsHiddenState() to depot and vehicle windows
bjarni
parents:
4754
diff
changeset
|
314 |
DEPOT_WIDGET_SELL_CHAIN, |
090cf0f1b35e
(svn r6672) -Codechange: [depot & vehicle windows] applied SetWindowWidgetsDisabledState() and SetWindowWidgetsHiddenState() to depot and vehicle windows
bjarni
parents:
4754
diff
changeset
|
315 |
DEPOT_WIDGET_SELL_ALL, |
090cf0f1b35e
(svn r6672) -Codechange: [depot & vehicle windows] applied SetWindowWidgetsDisabledState() and SetWindowWidgetsHiddenState() to depot and vehicle windows
bjarni
parents:
4754
diff
changeset
|
316 |
DEPOT_WIDGET_BUILD, |
090cf0f1b35e
(svn r6672) -Codechange: [depot & vehicle windows] applied SetWindowWidgetsDisabledState() and SetWindowWidgetsHiddenState() to depot and vehicle windows
bjarni
parents:
4754
diff
changeset
|
317 |
DEPOT_WIDGET_CLONE, |
090cf0f1b35e
(svn r6672) -Codechange: [depot & vehicle windows] applied SetWindowWidgetsDisabledState() and SetWindowWidgetsHiddenState() to depot and vehicle windows
bjarni
parents:
4754
diff
changeset
|
318 |
DEPOT_WIDGET_AUTOREPLACE, |
090cf0f1b35e
(svn r6672) -Codechange: [depot & vehicle windows] applied SetWindowWidgetsDisabledState() and SetWindowWidgetsHiddenState() to depot and vehicle windows
bjarni
parents:
4754
diff
changeset
|
319 |
WIDGET_LIST_END); |
4638
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
320 |
|
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
321 |
/* determine amount of items for scroller */ |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
322 |
if (WP(w, depot_d).type == VEH_Train) { |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
323 |
hnum = 8; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
324 |
for (num = 0; num < WP(w, depot_d).engine_count; num++) { |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
325 |
const Vehicle *v = vl[num]; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
326 |
hnum = maxu(hnum, v->u.rail.cached_total_length); |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
327 |
} |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
328 |
/* Always have 1 empty row, so people can change the setting of the train */ |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
329 |
SetVScrollCount(w, WP(w, depot_d).engine_count + WP(w, depot_d).wagon_count + 1); |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
330 |
SetHScrollCount(w, WagonLengthToPixels(hnum)); |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
331 |
} else { |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
332 |
SetVScrollCount(w, (num + w->hscroll.cap - 1) / w->hscroll.cap); |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
333 |
} |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
334 |
|
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
335 |
/* locate the depot struct */ |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
336 |
if (WP(w, depot_d).type == VEH_Aircraft) { |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
337 |
SetDParam(0, GetStationIndex(tile)); // Airport name |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
338 |
} else { |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
339 |
Depot *depot = GetDepotByTile(tile); |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
340 |
assert(depot != NULL); |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
341 |
|
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
342 |
SetDParam(0, depot->town_index); |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
343 |
} |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
344 |
|
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
345 |
DrawWindowWidgets(w); |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
346 |
|
4754
26ddeca70f94
(svn r6668) -Codechange: [depot window] simplified the engine drawing loop in the depot window
bjarni
parents:
4745
diff
changeset
|
347 |
num = w->vscroll.pos * boxes_in_each_row; |
26ddeca70f94
(svn r6668) -Codechange: [depot window] simplified the engine drawing loop in the depot window
bjarni
parents:
4745
diff
changeset
|
348 |
max = min(WP(w, depot_d).engine_count, num + (rows_in_display * boxes_in_each_row)); |
4638
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
349 |
|
4754
26ddeca70f94
(svn r6668) -Codechange: [depot window] simplified the engine drawing loop in the depot window
bjarni
parents:
4745
diff
changeset
|
350 |
for (x = 2, y = 15; num < max; y += w->resize.step_height, x = 2) { // Draw the rows |
26ddeca70f94
(svn r6668) -Codechange: [depot window] simplified the engine drawing loop in the depot window
bjarni
parents:
4745
diff
changeset
|
351 |
byte i; |
4638
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
352 |
|
4754
26ddeca70f94
(svn r6668) -Codechange: [depot window] simplified the engine drawing loop in the depot window
bjarni
parents:
4745
diff
changeset
|
353 |
for (i = 0; i < boxes_in_each_row && num < max; i++, num++, x += w->resize.step_width) { |
26ddeca70f94
(svn r6668) -Codechange: [depot window] simplified the engine drawing loop in the depot window
bjarni
parents:
4745
diff
changeset
|
354 |
/* Draw all vehicles in the current row */ |
26ddeca70f94
(svn r6668) -Codechange: [depot window] simplified the engine drawing loop in the depot window
bjarni
parents:
4745
diff
changeset
|
355 |
const Vehicle *v = vl[num]; |
26ddeca70f94
(svn r6668) -Codechange: [depot window] simplified the engine drawing loop in the depot window
bjarni
parents:
4745
diff
changeset
|
356 |
DrawVehicleInDepot(w, v, x, y); |
4638
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
357 |
} |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
358 |
} |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
359 |
|
4754
26ddeca70f94
(svn r6668) -Codechange: [depot window] simplified the engine drawing loop in the depot window
bjarni
parents:
4745
diff
changeset
|
360 |
max = min(WP(w, depot_d).engine_count + WP(w, depot_d).wagon_count, (w->vscroll.pos * boxes_in_each_row) + (rows_in_display * boxes_in_each_row)); |
4638
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
361 |
|
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
362 |
/* draw the train wagons, that do not have an engine in front */ |
4754
26ddeca70f94
(svn r6668) -Codechange: [depot window] simplified the engine drawing loop in the depot window
bjarni
parents:
4745
diff
changeset
|
363 |
for (; num < max; num++, y += 14) { |
4638
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
364 |
const Vehicle *v = WP(w, depot_d).wagon_list[num - WP(w, depot_d).engine_count]; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
365 |
const Vehicle *u; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
366 |
|
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
367 |
DrawTrainImage(v, x + 50, y, w->hscroll.cap - 29, 0, WP(w,depot_d).sel); |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
368 |
DrawString(x, y + 2, STR_8816, 0); |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
369 |
|
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
370 |
/*Draw the train counter */ |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
371 |
i = 0; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
372 |
u = v; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
373 |
do i++; while ( (u=u->next) != NULL); // Determine length of train |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
374 |
SetDParam(0, i); // Set the counter |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
375 |
DrawStringRightAligned(w->widget[DEPOT_WIDGET_MATRIX].right - 1, y + 4, STR_TINY_BLACK, 0); // Draw the counter |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
376 |
} |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
377 |
} |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
378 |
|
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
379 |
typedef struct GetDepotVehiclePtData { |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
380 |
Vehicle *head; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
381 |
Vehicle *wagon; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
382 |
} GetDepotVehiclePtData; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
383 |
|
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
384 |
enum { |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
385 |
MODE_ERROR = 1, |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
386 |
MODE_DRAG_VEHICLE = 0, |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
387 |
MODE_SHOW_VEHICLE = -1, |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
388 |
MODE_START_STOP = -2, |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
389 |
}; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
390 |
|
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
391 |
static int GetVehicleFromDepotWndPt(const Window *w, int x, int y, Vehicle **veh, GetDepotVehiclePtData *d) |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
392 |
{ |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
393 |
Vehicle **vl = WP(w, depot_d).vehicle_list; |
4641
388b816eef86
(svn r6516) -Fix r6513: killed warnings about two variables being used uninitialized
bjarni
parents:
4640
diff
changeset
|
394 |
uint xt, row, xm = 0, ym = 0; |
4638
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
395 |
int pos, skip = 0; |
4759
10f7465a3c0f
(svn r6673) -Codechange: [depot window] replaced a piece of code to calculate max number of vehicles in a row with a simple read of the matrix grid
bjarni
parents:
4758
diff
changeset
|
396 |
uint16 boxes_in_each_row = w->widget[DEPOT_WIDGET_MATRIX].data & 0xFF; |
4638
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
397 |
|
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
398 |
if (WP(w, depot_d).type == VEH_Train) { |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
399 |
xt = 0; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
400 |
x -= 23; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
401 |
} else { |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
402 |
xt = x / w->resize.step_width; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
403 |
xm = x % w->resize.step_width; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
404 |
if (xt >= w->hscroll.cap) return MODE_ERROR; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
405 |
|
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
406 |
ym = (y - 14) % w->resize.step_height; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
407 |
} |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
408 |
|
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
409 |
row = (y - 14) / w->resize.step_height; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
410 |
if (row >= w->vscroll.cap) return MODE_ERROR; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
411 |
|
4759
10f7465a3c0f
(svn r6673) -Codechange: [depot window] replaced a piece of code to calculate max number of vehicles in a row with a simple read of the matrix grid
bjarni
parents:
4758
diff
changeset
|
412 |
pos = ((row + w->vscroll.pos) * boxes_in_each_row) + xt; |
4638
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
413 |
|
4663
83330678e41c
(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
|
414 |
if (WP(w, depot_d).engine_count + WP(w, depot_d).wagon_count <= pos) { |
83330678e41c
(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
|
415 |
if (WP(w, depot_d).type == VEH_Train) { |
83330678e41c
(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
|
416 |
d->head = NULL; |
83330678e41c
(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
|
417 |
d->wagon = NULL; |
83330678e41c
(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
|
418 |
return MODE_DRAG_VEHICLE; |
83330678e41c
(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
|
419 |
} else { |
83330678e41c
(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
|
420 |
return MODE_ERROR; // empty block, so no vehicle is selected |
83330678e41c
(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
|
421 |
} |
83330678e41c
(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
|
422 |
} |
4638
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
423 |
|
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
424 |
if (WP(w, depot_d).engine_count > pos) { |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
425 |
*veh = vl[pos]; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
426 |
skip = w->hscroll.pos; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
427 |
} else { |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
428 |
vl = WP(w, depot_d).wagon_list; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
429 |
pos -= WP(w, depot_d).engine_count; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
430 |
*veh = vl[pos]; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
431 |
/* free wagons don't have an initial loco. */ |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
432 |
x -= _traininfo_vehicle_width; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
433 |
} |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
434 |
|
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
435 |
switch (WP(w, depot_d).type) { |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
436 |
case VEH_Train: { |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
437 |
Vehicle *v = *veh; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
438 |
d->head = d->wagon = v; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
439 |
|
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
440 |
/* either pressed the flag or the number, but only when it's a loco */ |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
441 |
if (x < 0 && IsFrontEngine(v)) return (x >= -10) ? MODE_START_STOP : MODE_SHOW_VEHICLE; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
442 |
|
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
443 |
skip = (skip * 8) / _traininfo_vehicle_width; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
444 |
x = (x * 8) / _traininfo_vehicle_width; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
445 |
|
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
446 |
/* Skip vehicles that are scrolled off the list */ |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
447 |
x += skip; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
448 |
|
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
449 |
/* find the vehicle in this row that was clicked */ |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
450 |
while (v != NULL && (x -= v->u.rail.cached_veh_length) >= 0) v = v->next; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
451 |
|
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
452 |
/* if an articulated part was selected, find its parent */ |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
453 |
while (v != NULL && IsArticulatedPart(v)) v = GetPrevVehicleInChain(v); |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
454 |
|
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
455 |
d->wagon = v; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
456 |
|
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
457 |
return MODE_DRAG_VEHICLE; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
458 |
} |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
459 |
break; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
460 |
|
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
461 |
case VEH_Road: |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
462 |
if (xm >= 24) return MODE_DRAG_VEHICLE; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
463 |
if (xm <= 16) return MODE_SHOW_VEHICLE; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
464 |
break; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
465 |
|
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
466 |
case VEH_Ship: |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
467 |
if (xm >= 19) return MODE_DRAG_VEHICLE; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
468 |
if (ym <= 10) return MODE_SHOW_VEHICLE; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
469 |
break; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
470 |
|
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
471 |
case VEH_Aircraft: |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
472 |
if (xm >= 12) return MODE_DRAG_VEHICLE; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
473 |
if (ym <= 12) return MODE_SHOW_VEHICLE; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
474 |
break; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
475 |
|
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
476 |
default: NOT_REACHED(); |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
477 |
} |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
478 |
return MODE_START_STOP; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
479 |
} |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
480 |
|
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
481 |
static void TrainDepotMoveVehicle(Vehicle *wagon, VehicleID sel, Vehicle *head) |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
482 |
{ |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
483 |
Vehicle *v; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
484 |
|
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
485 |
v = GetVehicle(sel); |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
486 |
|
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
487 |
if (v == wagon) return; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
488 |
|
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
489 |
if (wagon == NULL) { |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
490 |
if (head != NULL) wagon = GetLastVehicleInChain(head); |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
491 |
} else { |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
492 |
wagon = GetPrevVehicleInChain(wagon); |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
493 |
if (wagon == NULL) return; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
494 |
} |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
495 |
|
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
496 |
if (wagon == v) return; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
497 |
|
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
498 |
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)); |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
499 |
} |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
500 |
|
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
501 |
static void DepotClick(Window *w, int x, int y) |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
502 |
{ |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
503 |
GetDepotVehiclePtData gdvp; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
504 |
Vehicle *v = NULL; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
505 |
int mode = GetVehicleFromDepotWndPt(w, x, y, &v, &gdvp); |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
506 |
|
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
507 |
/* share / copy orders */ |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
508 |
if (_thd.place_mode && mode <= 0) { |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
509 |
_place_clicked_vehicle = (WP(w, depot_d).type == VEH_Train ? gdvp.head : v); |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
510 |
return; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
511 |
} |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
512 |
|
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
513 |
if (WP(w, depot_d).type == VEH_Train) v = gdvp.wagon; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
514 |
|
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
515 |
switch (mode) { |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
516 |
case MODE_ERROR: // invalid |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
517 |
return; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
518 |
|
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
519 |
case MODE_DRAG_VEHICLE: { // start dragging of vehicle |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
520 |
VehicleID sel = WP(w, depot_d).sel; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
521 |
|
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
522 |
if (WP(w, depot_d).type == VEH_Train && sel != INVALID_VEHICLE) { |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
523 |
WP(w,depot_d).sel = INVALID_VEHICLE; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
524 |
TrainDepotMoveVehicle(v, sel, gdvp.head); |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
525 |
} else if (v != NULL) { |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
526 |
int image; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
527 |
|
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
528 |
switch (WP(w, depot_d).type) { |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
529 |
case VEH_Train: image = GetTrainImage(v, DIR_W); break; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
530 |
case VEH_Road: image = GetRoadVehImage(v, DIR_W); break; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
531 |
case VEH_Ship: image = GetShipImage(v, DIR_W); break; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
532 |
case VEH_Aircraft: image = GetAircraftImage(v, DIR_W); break; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
533 |
default: NOT_REACHED(); image = 0; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
534 |
} |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
535 |
|
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
536 |
WP(w, depot_d).sel = v->index; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
537 |
SetWindowDirty(w); |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
538 |
SetObjectToPlaceWnd(GetVehiclePalette(v) | image, 4, w); |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
539 |
} |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
540 |
} |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
541 |
break; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
542 |
|
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
543 |
case MODE_SHOW_VEHICLE: // show info window |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
544 |
ShowVehicleViewWindow(v); |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
545 |
break; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
546 |
|
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
547 |
case MODE_START_STOP: { // click start/stop flag |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
548 |
uint command; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
549 |
|
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
550 |
switch (WP(w, depot_d).type) { |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
551 |
case VEH_Train: command = CMD_START_STOP_TRAIN | CMD_MSG(STR_883B_CAN_T_STOP_START_TRAIN); break; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
552 |
case VEH_Road: command = CMD_START_STOP_ROADVEH | CMD_MSG(STR_9015_CAN_T_STOP_START_ROAD_VEHICLE); break; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
553 |
case VEH_Ship: command = CMD_START_STOP_SHIP | CMD_MSG(STR_9818_CAN_T_STOP_START_SHIP); break; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
554 |
case VEH_Aircraft: command = CMD_START_STOP_AIRCRAFT | CMD_MSG(STR_A016_CAN_T_STOP_START_AIRCRAFT); break; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
555 |
default: NOT_REACHED(); command = 0; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
556 |
} |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
557 |
DoCommandP(v->tile, v->index, 0, NULL, command); |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
558 |
} |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
559 |
break; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
560 |
|
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
561 |
default: NOT_REACHED(); |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
562 |
} |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
563 |
} |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
564 |
|
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
565 |
/** |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
566 |
* Clones a vehicle |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
567 |
* @param *v is the original vehicle to clone |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
568 |
* @param *w is the window of the depot where the clone is build |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
569 |
*/ |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
570 |
static void HandleCloneVehClick(const Vehicle *v, const Window *w) |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
571 |
{ |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
572 |
uint error_str; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
573 |
|
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
574 |
if (v == NULL) return; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
575 |
|
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
576 |
if (v->type == VEH_Train && !IsFrontEngine(v)) { |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
577 |
v = GetFirstVehicleInChain(v); |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
578 |
/* Do nothing when clicking on a train in depot with no loc attached */ |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
579 |
if (!IsFrontEngine(v)) return; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
580 |
} |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
581 |
|
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
582 |
switch (v->type) { |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
583 |
case VEH_Train: error_str = CMD_MSG(STR_882B_CAN_T_BUILD_RAILROAD_VEHICLE); break; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
584 |
case VEH_Road: error_str = CMD_MSG(STR_9009_CAN_T_BUILD_ROAD_VEHICLE); break; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
585 |
case VEH_Ship: error_str = CMD_MSG(STR_980D_CAN_T_BUILD_SHIP); break; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
586 |
case VEH_Aircraft: error_str = CMD_MSG(STR_A008_CAN_T_BUILD_AIRCRAFT); break; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
587 |
default: return; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
588 |
} |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
589 |
|
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
590 |
DoCommandP(w->window_number, v->index, _ctrl_pressed ? 1 : 0, CcCloneVehicle, CMD_CLONE_VEHICLE | error_str); |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
591 |
|
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
592 |
ResetObjectToPlace(); |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
593 |
} |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
594 |
|
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
595 |
static void ClonePlaceObj(const Window *w) |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
596 |
{ |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
597 |
const Vehicle *v = CheckMouseOverVehicle(); |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
598 |
|
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
599 |
if (v != NULL) HandleCloneVehClick(v, w); |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
600 |
} |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
601 |
|
4646
d3d73ee03bbc
(svn r6522) -Feature: [depot window] the buttons are now "scaled" resized
bjarni
parents:
4644
diff
changeset
|
602 |
static void ResizeDepotButtons(Window *w) |
d3d73ee03bbc
(svn r6522) -Feature: [depot window] the buttons are now "scaled" resized
bjarni
parents:
4644
diff
changeset
|
603 |
{ |
d3d73ee03bbc
(svn r6522) -Feature: [depot window] the buttons are now "scaled" resized
bjarni
parents:
4644
diff
changeset
|
604 |
/* We got the widget moved around. Now we will make some widgets to fill the gab between some widgets in equal sizes */ |
d3d73ee03bbc
(svn r6522) -Feature: [depot window] the buttons are now "scaled" resized
bjarni
parents:
4644
diff
changeset
|
605 |
|
d3d73ee03bbc
(svn r6522) -Feature: [depot window] the buttons are now "scaled" resized
bjarni
parents:
4644
diff
changeset
|
606 |
/* Make the buttons in the bottom equal in size */ |
4681
bc077405e9a8
(svn r6586) -Feature: [depot window] added a vehicle list window with all vehicles having a certain depot in their orders
bjarni
parents:
4670
diff
changeset
|
607 |
w->widget[DEPOT_WIDGET_LOCATION].right = w->widget[DEPOT_WIDGET_VEHICLE_LIST].left - 1; |
4646
d3d73ee03bbc
(svn r6522) -Feature: [depot window] the buttons are now "scaled" resized
bjarni
parents:
4644
diff
changeset
|
608 |
w->widget[DEPOT_WIDGET_BUILD].right = w->widget[DEPOT_WIDGET_LOCATION].right / 3; |
d3d73ee03bbc
(svn r6522) -Feature: [depot window] the buttons are now "scaled" resized
bjarni
parents:
4644
diff
changeset
|
609 |
w->widget[DEPOT_WIDGET_LOCATION].left = w->widget[DEPOT_WIDGET_BUILD].right * 2; |
d3d73ee03bbc
(svn r6522) -Feature: [depot window] the buttons are now "scaled" resized
bjarni
parents:
4644
diff
changeset
|
610 |
w->widget[DEPOT_WIDGET_CLONE].left = w->widget[DEPOT_WIDGET_BUILD].right + 1; |
d3d73ee03bbc
(svn r6522) -Feature: [depot window] the buttons are now "scaled" resized
bjarni
parents:
4644
diff
changeset
|
611 |
w->widget[DEPOT_WIDGET_CLONE].right = w->widget[DEPOT_WIDGET_LOCATION].left - 1; |
d3d73ee03bbc
(svn r6522) -Feature: [depot window] the buttons are now "scaled" resized
bjarni
parents:
4644
diff
changeset
|
612 |
|
d3d73ee03bbc
(svn r6522) -Feature: [depot window] the buttons are now "scaled" resized
bjarni
parents:
4644
diff
changeset
|
613 |
if (WP(w, depot_d).type == VEH_Train) { |
4659
e476c76389a8
(svn r6542) -Feature: [depot window] added a "sell all vehicles in depot" button
bjarni
parents:
4654
diff
changeset
|
614 |
/* 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. |
e476c76389a8
(svn r6542) -Feature: [depot window] added a "sell all vehicles in depot" button
bjarni
parents:
4654
diff
changeset
|
615 |
* This way it will stay the same even if DEPOT_WIDGET_SELL_CHAIN is resized for some reason */ |
e476c76389a8
(svn r6542) -Feature: [depot window] added a "sell all vehicles in depot" button
bjarni
parents:
4654
diff
changeset
|
616 |
w->widget[DEPOT_WIDGET_SELL_CHAIN].bottom = w->widget[DEPOT_WIDGET_SELL_ALL].top - 1; |
e476c76389a8
(svn r6542) -Feature: [depot window] added a "sell all vehicles in depot" button
bjarni
parents:
4654
diff
changeset
|
617 |
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; |
e476c76389a8
(svn r6542) -Feature: [depot window] added a "sell all vehicles in depot" button
bjarni
parents:
4654
diff
changeset
|
618 |
w->widget[DEPOT_WIDGET_SELL].bottom = w->widget[DEPOT_WIDGET_SELL_CHAIN].top - 1; |
4646
d3d73ee03bbc
(svn r6522) -Feature: [depot window] the buttons are now "scaled" resized
bjarni
parents:
4644
diff
changeset
|
619 |
} |
d3d73ee03bbc
(svn r6522) -Feature: [depot window] the buttons are now "scaled" resized
bjarni
parents:
4644
diff
changeset
|
620 |
} |
d3d73ee03bbc
(svn r6522) -Feature: [depot window] the buttons are now "scaled" resized
bjarni
parents:
4644
diff
changeset
|
621 |
|
4740
953f60fa6d6a
(svn r6652) -Feature: [depot window] depot lists are now sorted, so vehicle 1 is always first and so on
bjarni
parents:
4739
diff
changeset
|
622 |
void DepotSortList(Vehicle **v, uint16 length); |
953f60fa6d6a
(svn r6652) -Feature: [depot window] depot lists are now sorted, so vehicle 1 is always first and so on
bjarni
parents:
4739
diff
changeset
|
623 |
|
4638
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
624 |
static void DepotWndProc(Window *w, WindowEvent *e) |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
625 |
{ |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
626 |
switch (e->event) { |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
627 |
case WE_CREATE: |
4739
e626ef1b522e
(svn r6651) -Coding feature: added the windowevent WE_INVALIDATE_DATA
bjarni
parents:
4733
diff
changeset
|
628 |
WP(w, depot_d).vehicle_list = NULL; |
e626ef1b522e
(svn r6651) -Coding feature: added the windowevent WE_INVALIDATE_DATA
bjarni
parents:
4733
diff
changeset
|
629 |
WP(w, depot_d).wagon_list = NULL; |
e626ef1b522e
(svn r6651) -Coding feature: added the windowevent WE_INVALIDATE_DATA
bjarni
parents:
4733
diff
changeset
|
630 |
WP(w, depot_d).engine_count = 0; |
e626ef1b522e
(svn r6651) -Coding feature: added the windowevent WE_INVALIDATE_DATA
bjarni
parents:
4733
diff
changeset
|
631 |
WP(w, depot_d).wagon_count = 0; |
e626ef1b522e
(svn r6651) -Coding feature: added the windowevent WE_INVALIDATE_DATA
bjarni
parents:
4733
diff
changeset
|
632 |
WP(w, depot_d).generate_list = true; |
e626ef1b522e
(svn r6651) -Coding feature: added the windowevent WE_INVALIDATE_DATA
bjarni
parents:
4733
diff
changeset
|
633 |
break; |
e626ef1b522e
(svn r6651) -Coding feature: added the windowevent WE_INVALIDATE_DATA
bjarni
parents:
4733
diff
changeset
|
634 |
|
e626ef1b522e
(svn r6651) -Coding feature: added the windowevent WE_INVALIDATE_DATA
bjarni
parents:
4733
diff
changeset
|
635 |
case WE_INVALIDATE_DATA: |
e626ef1b522e
(svn r6651) -Coding feature: added the windowevent WE_INVALIDATE_DATA
bjarni
parents:
4733
diff
changeset
|
636 |
WP(w, depot_d).generate_list = true; |
4638
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
637 |
break; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
638 |
|
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
639 |
case WE_PAINT: |
4739
e626ef1b522e
(svn r6651) -Coding feature: added the windowevent WE_INVALIDATE_DATA
bjarni
parents:
4733
diff
changeset
|
640 |
if (WP(w, depot_d).generate_list) { |
e626ef1b522e
(svn r6651) -Coding feature: added the windowevent WE_INVALIDATE_DATA
bjarni
parents:
4733
diff
changeset
|
641 |
/* Generate the vehicle list |
e626ef1b522e
(svn r6651) -Coding feature: added the windowevent WE_INVALIDATE_DATA
bjarni
parents:
4733
diff
changeset
|
642 |
* It's ok to use the wagon pointers for non-trains as they will be ignored */ |
e626ef1b522e
(svn r6651) -Coding feature: added the windowevent WE_INVALIDATE_DATA
bjarni
parents:
4733
diff
changeset
|
643 |
BuildDepotVehicleList(WP(w, depot_d).type, w->window_number, |
e626ef1b522e
(svn r6651) -Coding feature: added the windowevent WE_INVALIDATE_DATA
bjarni
parents:
4733
diff
changeset
|
644 |
&WP(w, depot_d).vehicle_list, &WP(w, depot_d).engine_list_length, &WP(w, depot_d).engine_count, |
e626ef1b522e
(svn r6651) -Coding feature: added the windowevent WE_INVALIDATE_DATA
bjarni
parents:
4733
diff
changeset
|
645 |
&WP(w, depot_d).wagon_list, &WP(w, depot_d).wagon_list_length, &WP(w, depot_d).wagon_count); |
e626ef1b522e
(svn r6651) -Coding feature: added the windowevent WE_INVALIDATE_DATA
bjarni
parents:
4733
diff
changeset
|
646 |
WP(w, depot_d).generate_list = false; |
4740
953f60fa6d6a
(svn r6652) -Feature: [depot window] depot lists are now sorted, so vehicle 1 is always first and so on
bjarni
parents:
4739
diff
changeset
|
647 |
DepotSortList(WP(w, depot_d).vehicle_list, WP(w, depot_d).engine_count); |
4739
e626ef1b522e
(svn r6651) -Coding feature: added the windowevent WE_INVALIDATE_DATA
bjarni
parents:
4733
diff
changeset
|
648 |
#ifndef NDEBUG |
e626ef1b522e
(svn r6651) -Coding feature: added the windowevent WE_INVALIDATE_DATA
bjarni
parents:
4733
diff
changeset
|
649 |
} else { |
e626ef1b522e
(svn r6651) -Coding feature: added the windowevent WE_INVALIDATE_DATA
bjarni
parents:
4733
diff
changeset
|
650 |
/* Here we got a piece of code, that only checks if we got a different number of vehicles in the depot list and the number of vehicles actually being in the depot. |
e626ef1b522e
(svn r6651) -Coding feature: added the windowevent WE_INVALIDATE_DATA
bjarni
parents:
4733
diff
changeset
|
651 |
* IF they aren't the same, then WE_INVALIDATE_DATA should have been called somewhere, but it wasn't and we got a bug |
e626ef1b522e
(svn r6651) -Coding feature: added the windowevent WE_INVALIDATE_DATA
bjarni
parents:
4733
diff
changeset
|
652 |
* Since this is a time consuming check and not nice to memory fragmentation, it may not stay for long, but it's a good way to check this |
e626ef1b522e
(svn r6651) -Coding feature: added the windowevent WE_INVALIDATE_DATA
bjarni
parents:
4733
diff
changeset
|
653 |
* We can turn it on/off by switching between #ifndef NDEBUG and #if 0 */ |
e626ef1b522e
(svn r6651) -Coding feature: added the windowevent WE_INVALIDATE_DATA
bjarni
parents:
4733
diff
changeset
|
654 |
Vehicle **engines = NULL, **wagons = NULL; |
e626ef1b522e
(svn r6651) -Coding feature: added the windowevent WE_INVALIDATE_DATA
bjarni
parents:
4733
diff
changeset
|
655 |
uint16 engine_count = 0, engine_length = 0; |
e626ef1b522e
(svn r6651) -Coding feature: added the windowevent WE_INVALIDATE_DATA
bjarni
parents:
4733
diff
changeset
|
656 |
uint16 wagon_count = 0, wagon_length = 0; |
e626ef1b522e
(svn r6651) -Coding feature: added the windowevent WE_INVALIDATE_DATA
bjarni
parents:
4733
diff
changeset
|
657 |
BuildDepotVehicleList(WP(w, depot_d).type, w->window_number, &engines, &engine_length, &engine_count, |
e626ef1b522e
(svn r6651) -Coding feature: added the windowevent WE_INVALIDATE_DATA
bjarni
parents:
4733
diff
changeset
|
658 |
&wagons, &wagon_length, &wagon_count); |
e626ef1b522e
(svn r6651) -Coding feature: added the windowevent WE_INVALIDATE_DATA
bjarni
parents:
4733
diff
changeset
|
659 |
|
e626ef1b522e
(svn r6651) -Coding feature: added the windowevent WE_INVALIDATE_DATA
bjarni
parents:
4733
diff
changeset
|
660 |
assert(engine_count == WP(w, depot_d).engine_count); |
e626ef1b522e
(svn r6651) -Coding feature: added the windowevent WE_INVALIDATE_DATA
bjarni
parents:
4733
diff
changeset
|
661 |
assert(wagon_count == WP(w, depot_d).wagon_count); |
e626ef1b522e
(svn r6651) -Coding feature: added the windowevent WE_INVALIDATE_DATA
bjarni
parents:
4733
diff
changeset
|
662 |
free((void*)engines); |
e626ef1b522e
(svn r6651) -Coding feature: added the windowevent WE_INVALIDATE_DATA
bjarni
parents:
4733
diff
changeset
|
663 |
free((void*)wagons); |
e626ef1b522e
(svn r6651) -Coding feature: added the windowevent WE_INVALIDATE_DATA
bjarni
parents:
4733
diff
changeset
|
664 |
#endif |
e626ef1b522e
(svn r6651) -Coding feature: added the windowevent WE_INVALIDATE_DATA
bjarni
parents:
4733
diff
changeset
|
665 |
} |
4638
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
666 |
DrawDepotWindow(w); |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
667 |
break; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
668 |
|
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
669 |
case WE_CLICK: |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
670 |
switch (e->we.click.widget) { |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
671 |
case DEPOT_WIDGET_MATRIX: // List |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
672 |
DepotClick(w, e->we.click.pt.x, e->we.click.pt.y); |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
673 |
break; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
674 |
|
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
675 |
case DEPOT_WIDGET_BUILD: // Build vehicle |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
676 |
ResetObjectToPlace(); |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
677 |
switch (WP(w, depot_d).type) { |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
678 |
case VEH_Train: ShowBuildTrainWindow(w->window_number); break; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
679 |
case VEH_Road: ShowBuildRoadVehWindow(w->window_number); break; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
680 |
case VEH_Ship: ShowBuildShipWindow(w->window_number); break; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
681 |
case VEH_Aircraft: ShowBuildAircraftWindow(w->window_number); break; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
682 |
default: NOT_REACHED(); |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
683 |
} |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
684 |
break; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
685 |
|
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
686 |
case DEPOT_WIDGET_CLONE: // Clone button |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
687 |
InvalidateWidget(w, DEPOT_WIDGET_CLONE); |
4733
7405f1da28f1
(svn r6645) -Fix(r6631): Forgot two click_state occurences
belugas
parents:
4719
diff
changeset
|
688 |
ToggleWidgetLoweredState(w, DEPOT_WIDGET_CLONE); |
4638
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
689 |
|
4733
7405f1da28f1
(svn r6645) -Fix(r6631): Forgot two click_state occurences
belugas
parents:
4719
diff
changeset
|
690 |
if (IsWindowWidgetLowered(w, DEPOT_WIDGET_CLONE)) { |
4638
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
691 |
_place_clicked_vehicle = NULL; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
692 |
SetObjectToPlaceWnd(SPR_CURSOR_CLONE, VHM_RECT, w); |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
693 |
} else { |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
694 |
ResetObjectToPlace(); |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
695 |
} |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
696 |
break; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
697 |
|
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
698 |
case DEPOT_WIDGET_LOCATION: ScrollMainWindowToTile(w->window_number); break; |
4640
4e380e2ecfa7
(svn r6515) -Feature: added "start all" and "stop all" buttons to the depot windows
bjarni
parents:
4638
diff
changeset
|
699 |
|
4e380e2ecfa7
(svn r6515) -Feature: added "start all" and "stop all" buttons to the depot windows
bjarni
parents:
4638
diff
changeset
|
700 |
case DEPOT_WIDGET_STOP_ALL: |
4e380e2ecfa7
(svn r6515) -Feature: added "start all" and "stop all" buttons to the depot windows
bjarni
parents:
4638
diff
changeset
|
701 |
case DEPOT_WIDGET_START_ALL: |
4e380e2ecfa7
(svn r6515) -Feature: added "start all" and "stop all" buttons to the depot windows
bjarni
parents:
4638
diff
changeset
|
702 |
DoCommandP(w->window_number, WP(w, depot_d).type, e->we.click.widget == DEPOT_WIDGET_START_ALL ? 1 : 0, NULL, CMD_MASS_START_STOP); |
4e380e2ecfa7
(svn r6515) -Feature: added "start all" and "stop all" buttons to the depot windows
bjarni
parents:
4638
diff
changeset
|
703 |
break; |
4e380e2ecfa7
(svn r6515) -Feature: added "start all" and "stop all" buttons to the depot windows
bjarni
parents:
4638
diff
changeset
|
704 |
|
4659
e476c76389a8
(svn r6542) -Feature: [depot window] added a "sell all vehicles in depot" button
bjarni
parents:
4654
diff
changeset
|
705 |
case DEPOT_WIDGET_SELL_ALL: |
4690
a8c4eed3c81e
(svn r6595) -Fix r6542: [depot window] clicking sell all in a depot with no vehicles will now do nothing at all (instead of opening the confination window) (spotted by glx)
bjarni
parents:
4688
diff
changeset
|
706 |
/* Only open the confimation window if there are anything to sell */ |
a8c4eed3c81e
(svn r6595) -Fix r6542: [depot window] clicking sell all in a depot with no vehicles will now do nothing at all (instead of opening the confination window) (spotted by glx)
bjarni
parents:
4688
diff
changeset
|
707 |
if (WP(w, depot_d).engine_count != 0 || WP(w, depot_d).wagon_count != 0) { |
a8c4eed3c81e
(svn r6595) -Fix r6542: [depot window] clicking sell all in a depot with no vehicles will now do nothing at all (instead of opening the confination window) (spotted by glx)
bjarni
parents:
4688
diff
changeset
|
708 |
ShowDepotSellAllWindow(w->window_number, WP(w, depot_d).type); |
a8c4eed3c81e
(svn r6595) -Fix r6542: [depot window] clicking sell all in a depot with no vehicles will now do nothing at all (instead of opening the confination window) (spotted by glx)
bjarni
parents:
4688
diff
changeset
|
709 |
} |
4659
e476c76389a8
(svn r6542) -Feature: [depot window] added a "sell all vehicles in depot" button
bjarni
parents:
4654
diff
changeset
|
710 |
break; |
e476c76389a8
(svn r6542) -Feature: [depot window] added a "sell all vehicles in depot" button
bjarni
parents:
4654
diff
changeset
|
711 |
|
4681
bc077405e9a8
(svn r6586) -Feature: [depot window] added a vehicle list window with all vehicles having a certain depot in their orders
bjarni
parents:
4670
diff
changeset
|
712 |
case DEPOT_WIDGET_VEHICLE_LIST: |
bc077405e9a8
(svn r6586) -Feature: [depot window] added a vehicle list window with all vehicles having a certain depot in their orders
bjarni
parents:
4670
diff
changeset
|
713 |
ShowVehDepotOrders(GetTileOwner(w->window_number), WP(w, depot_d).type, w->window_number); |
bc077405e9a8
(svn r6586) -Feature: [depot window] added a vehicle list window with all vehicles having a certain depot in their orders
bjarni
parents:
4670
diff
changeset
|
714 |
break; |
bc077405e9a8
(svn r6586) -Feature: [depot window] added a vehicle list window with all vehicles having a certain depot in their orders
bjarni
parents:
4670
diff
changeset
|
715 |
|
4662
e36935c7bdde
(svn r6552) -Feature: [depot window] added a "autoreplace all vehicles in depot" button
bjarni
parents:
4659
diff
changeset
|
716 |
case DEPOT_WIDGET_AUTOREPLACE: |
e36935c7bdde
(svn r6552) -Feature: [depot window] added a "autoreplace all vehicles in depot" button
bjarni
parents:
4659
diff
changeset
|
717 |
DoCommandP(w->window_number, WP(w, depot_d).type, 0, NULL, CMD_DEPOT_MASS_AUTOREPLACE); |
e36935c7bdde
(svn r6552) -Feature: [depot window] added a "autoreplace all vehicles in depot" button
bjarni
parents:
4659
diff
changeset
|
718 |
break; |
e36935c7bdde
(svn r6552) -Feature: [depot window] added a "autoreplace all vehicles in depot" button
bjarni
parents:
4659
diff
changeset
|
719 |
|
4638
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
720 |
} |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
721 |
break; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
722 |
|
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
723 |
case WE_PLACE_OBJ: { |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
724 |
ClonePlaceObj(w); |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
725 |
} break; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
726 |
|
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
727 |
case WE_ABORT_PLACE_OBJ: { |
4719
fc6e14219f72
(svn r6631) -Codechange: Use accessors for click_state.
belugas
parents:
4709
diff
changeset
|
728 |
RaiseWindowWidget(w, DEPOT_WIDGET_CLONE); |
4638
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
729 |
InvalidateWidget(w, DEPOT_WIDGET_CLONE); |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
730 |
} break; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
731 |
|
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
732 |
/* check if a vehicle in a depot was clicked.. */ |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
733 |
case WE_MOUSELOOP: { |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
734 |
const Vehicle *v = _place_clicked_vehicle; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
735 |
|
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
736 |
/* since OTTD checks all open depot windows, we will make sure that it triggers the one with a clicked clone button */ |
4719
fc6e14219f72
(svn r6631) -Codechange: Use accessors for click_state.
belugas
parents:
4709
diff
changeset
|
737 |
if (v != NULL && IsWindowWidgetLowered(w, DEPOT_WIDGET_CLONE)) { |
4638
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
738 |
_place_clicked_vehicle = NULL; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
739 |
HandleCloneVehClick(v, w); |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
740 |
} |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
741 |
} break; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
742 |
|
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
743 |
case WE_DESTROY: |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
744 |
DeleteWindowById(WC_BUILD_VEHICLE, w->window_number); |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
745 |
free((void*)WP(w, depot_d).vehicle_list); |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
746 |
free((void*)WP(w, depot_d).wagon_list); |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
747 |
break; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
748 |
|
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
749 |
case WE_DRAGDROP: |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
750 |
switch (e->we.click.widget) { |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
751 |
case DEPOT_WIDGET_MATRIX: { |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
752 |
Vehicle *v; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
753 |
VehicleID sel = WP(w, depot_d).sel; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
754 |
|
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
755 |
WP(w, depot_d).sel = INVALID_VEHICLE; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
756 |
SetWindowDirty(w); |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
757 |
|
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
758 |
if (WP(w, depot_d).type == VEH_Train) { |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
759 |
GetDepotVehiclePtData gdvp; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
760 |
|
4663
83330678e41c
(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
|
761 |
if (GetVehicleFromDepotWndPt(w, e->we.dragdrop.pt.x, e->we.dragdrop.pt.y, &v, &gdvp) == MODE_DRAG_VEHICLE && |
4638
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
762 |
sel != INVALID_VEHICLE) { |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
763 |
if (gdvp.wagon != NULL && gdvp.wagon->index == sel && _ctrl_pressed) { |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
764 |
DoCommandP(GetVehicle(sel)->tile, GetVehicle(sel)->index, true, NULL, CMD_REVERSE_TRAIN_DIRECTION | CMD_MSG(STR_9033_CAN_T_MAKE_VEHICLE_TURN)); |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
765 |
} else if (gdvp.wagon == NULL || gdvp.wagon->index != sel) { |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
766 |
TrainDepotMoveVehicle(gdvp.wagon, sel, gdvp.head); |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
767 |
} else if (gdvp.head != NULL && IsFrontEngine(gdvp.head)) { |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
768 |
ShowTrainViewWindow(gdvp.head); |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
769 |
} |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
770 |
} |
4663
83330678e41c
(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
|
771 |
} else if (GetVehicleFromDepotWndPt(w, e->we.dragdrop.pt.x, e->we.dragdrop.pt.y, &v, NULL) == MODE_DRAG_VEHICLE && |
4638
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
772 |
v != NULL && |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
773 |
sel == v->index) { |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
774 |
ShowVehicleViewWindow(v); |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
775 |
} |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
776 |
} break; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
777 |
|
4659
e476c76389a8
(svn r6542) -Feature: [depot window] added a "sell all vehicles in depot" button
bjarni
parents:
4654
diff
changeset
|
778 |
case DEPOT_WIDGET_SELL: case DEPOT_WIDGET_SELL_CHAIN: |
4709
a81ab800c25b
(svn r6619) -Codechange: Use accessors for disabled_state.
belugas
parents:
4702
diff
changeset
|
779 |
if (!IsWindowWidgetDisabled(w, DEPOT_WIDGET_SELL) && |
4638
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
780 |
WP(w, depot_d).sel != INVALID_VEHICLE) { |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
781 |
Vehicle *v; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
782 |
uint command; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
783 |
int sell_cmd; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
784 |
bool is_engine; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
785 |
|
4709
a81ab800c25b
(svn r6619) -Codechange: Use accessors for disabled_state.
belugas
parents:
4702
diff
changeset
|
786 |
if (IsWindowWidgetDisabled(w, e->we.click.widget)) return; |
4638
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
787 |
if (WP(w, depot_d).sel == INVALID_VEHICLE) return; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
788 |
|
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
789 |
HandleButtonClick(w, e->we.click.widget); |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
790 |
|
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
791 |
v = GetVehicle(WP(w, depot_d).sel); |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
792 |
WP(w, depot_d).sel = INVALID_VEHICLE; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
793 |
SetWindowDirty(w); |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
794 |
|
4659
e476c76389a8
(svn r6542) -Feature: [depot window] added a "sell all vehicles in depot" button
bjarni
parents:
4654
diff
changeset
|
795 |
sell_cmd = (v->type == VEH_Train && (e->we.click.widget == DEPOT_WIDGET_SELL_CHAIN || _ctrl_pressed)) ? 1 : 0; |
4638
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
796 |
|
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
797 |
is_engine = (!(v->type == VEH_Train && !IsFrontEngine(v))); |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
798 |
|
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
799 |
if (is_engine) { |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
800 |
_backup_orders_tile = v->tile; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
801 |
BackupVehicleOrders(v, _backup_orders_data); |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
802 |
} |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
803 |
|
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
804 |
switch (v->type) { |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
805 |
case VEH_Train: command = CMD_SELL_RAIL_WAGON | CMD_MSG(STR_8839_CAN_T_SELL_RAILROAD_VEHICLE); break; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
806 |
case VEH_Road: command = CMD_SELL_ROAD_VEH | CMD_MSG(STR_9014_CAN_T_SELL_ROAD_VEHICLE); break; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
807 |
case VEH_Ship: command = CMD_SELL_SHIP | CMD_MSG(STR_980C_CAN_T_SELL_SHIP); break; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
808 |
case VEH_Aircraft: command = CMD_SELL_AIRCRAFT | CMD_MSG(STR_A01C_CAN_T_SELL_AIRCRAFT); break; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
809 |
default: NOT_REACHED(); command = 0; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
810 |
} |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
811 |
|
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
812 |
if (!DoCommandP(v->tile, v->index, sell_cmd, NULL, command) && is_engine) _backup_orders_tile = 0; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
813 |
} |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
814 |
break; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
815 |
default: |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
816 |
WP(w, depot_d).sel = INVALID_VEHICLE; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
817 |
SetWindowDirty(w); |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
818 |
} |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
819 |
break; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
820 |
|
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
821 |
case WE_RESIZE: |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
822 |
w->vscroll.cap += e->we.sizing.diff.y / (int)w->resize.step_height; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
823 |
w->hscroll.cap += e->we.sizing.diff.x / (int)w->resize.step_width; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
824 |
w->widget[DEPOT_WIDGET_MATRIX].data = (w->vscroll.cap << 8) + (WP(w, depot_d).type == VEH_Train ? 1 : w->hscroll.cap); |
4646
d3d73ee03bbc
(svn r6522) -Feature: [depot window] the buttons are now "scaled" resized
bjarni
parents:
4644
diff
changeset
|
825 |
ResizeDepotButtons(w); |
4638
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
826 |
break; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
827 |
} |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
828 |
} |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
829 |
|
4688
9cea258f031f
(svn r6593) -Fix: [depot window] added sprites to the buttons, that lacked one
bjarni
parents:
4686
diff
changeset
|
830 |
/* Function to set up vehicle specific sprites and strings |
9cea258f031f
(svn r6593) -Fix: [depot window] added sprites to the buttons, that lacked one
bjarni
parents:
4686
diff
changeset
|
831 |
* Only use this if it's the same widget, that's used for more than one vehicle type and it needs different text/sprites |
9cea258f031f
(svn r6593) -Fix: [depot window] added sprites to the buttons, that lacked one
bjarni
parents:
4686
diff
changeset
|
832 |
* Vehicle specific text/sprites, that's in a widget, that's only shown for one vehicle type (like sell whole train) is set in the widget array |
9cea258f031f
(svn r6593) -Fix: [depot window] added sprites to the buttons, that lacked one
bjarni
parents:
4686
diff
changeset
|
833 |
*/ |
4638
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
834 |
static void SetupStringsForDepotWindow(Window *w, byte type) |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
835 |
{ |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
836 |
switch (type) { |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
837 |
case VEH_Train: |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
838 |
w->widget[DEPOT_WIDGET_CAPTION].data = STR_8800_TRAIN_DEPOT; |
4686
e438e8b2ab61
(svn r6591) -Codechange: changed strings that used the word "depot" into one for each vehicle type
bjarni
parents:
4681
diff
changeset
|
839 |
w->widget[DEPOT_WIDGET_STOP_ALL].tooltips = STR_MASS_STOP_DEPOT_TRAIN_TIP; |
e438e8b2ab61
(svn r6591) -Codechange: changed strings that used the word "depot" into one for each vehicle type
bjarni
parents:
4681
diff
changeset
|
840 |
w->widget[DEPOT_WIDGET_START_ALL].tooltips= STR_MASS_START_DEPOT_TRAIN_TIP; |
4638
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
841 |
w->widget[DEPOT_WIDGET_SELL].tooltips = STR_8841_DRAG_TRAIN_VEHICLE_TO_HERE; |
4686
e438e8b2ab61
(svn r6591) -Codechange: changed strings that used the word "depot" into one for each vehicle type
bjarni
parents:
4681
diff
changeset
|
842 |
w->widget[DEPOT_WIDGET_SELL_ALL].tooltips = STR_DEPOT_SELL_ALL_BUTTON_TRAIN_TIP; |
4638
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
843 |
w->widget[DEPOT_WIDGET_MATRIX].tooltips = STR_883F_TRAINS_CLICK_ON_TRAIN_FOR; |
4686
e438e8b2ab61
(svn r6591) -Codechange: changed strings that used the word "depot" into one for each vehicle type
bjarni
parents:
4681
diff
changeset
|
844 |
|
4638
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
845 |
w->widget[DEPOT_WIDGET_BUILD].data = STR_8815_NEW_VEHICLES; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
846 |
w->widget[DEPOT_WIDGET_BUILD].tooltips = STR_8840_BUILD_NEW_TRAIN_VEHICLE; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
847 |
w->widget[DEPOT_WIDGET_CLONE].data = STR_CLONE_TRAIN; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
848 |
w->widget[DEPOT_WIDGET_CLONE].tooltips = STR_CLONE_TRAIN_DEPOT_INFO; |
4686
e438e8b2ab61
(svn r6591) -Codechange: changed strings that used the word "depot" into one for each vehicle type
bjarni
parents:
4681
diff
changeset
|
849 |
|
4638
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
850 |
w->widget[DEPOT_WIDGET_LOCATION].tooltips = STR_8842_CENTER_MAIN_VIEW_ON_TRAIN; |
4681
bc077405e9a8
(svn r6586) -Feature: [depot window] added a vehicle list window with all vehicles having a certain depot in their orders
bjarni
parents:
4670
diff
changeset
|
851 |
w->widget[DEPOT_WIDGET_VEHICLE_LIST].data = STR_TRAIN; |
bc077405e9a8
(svn r6586) -Feature: [depot window] added a vehicle list window with all vehicles having a certain depot in their orders
bjarni
parents:
4670
diff
changeset
|
852 |
w->widget[DEPOT_WIDGET_VEHICLE_LIST].tooltips = STR_DEPOT_VEHICLE_ORDER_LIST_TRAIN_TIP; |
4686
e438e8b2ab61
(svn r6591) -Codechange: changed strings that used the word "depot" into one for each vehicle type
bjarni
parents:
4681
diff
changeset
|
853 |
w->widget[DEPOT_WIDGET_AUTOREPLACE].tooltips = STR_DEPOT_AUTOREPLACE_TRAIN_TIP; |
4688
9cea258f031f
(svn r6593) -Fix: [depot window] added sprites to the buttons, that lacked one
bjarni
parents:
4686
diff
changeset
|
854 |
|
9cea258f031f
(svn r6593) -Fix: [depot window] added sprites to the buttons, that lacked one
bjarni
parents:
4686
diff
changeset
|
855 |
/* Sprites */ |
9cea258f031f
(svn r6593) -Fix: [depot window] added sprites to the buttons, that lacked one
bjarni
parents:
4686
diff
changeset
|
856 |
w->widget[DEPOT_WIDGET_SELL].data = SPR_SELL_TRAIN; |
9cea258f031f
(svn r6593) -Fix: [depot window] added sprites to the buttons, that lacked one
bjarni
parents:
4686
diff
changeset
|
857 |
w->widget[DEPOT_WIDGET_SELL_ALL].data = SPR_SELL_ALL_TRAIN; |
9cea258f031f
(svn r6593) -Fix: [depot window] added sprites to the buttons, that lacked one
bjarni
parents:
4686
diff
changeset
|
858 |
w->widget[DEPOT_WIDGET_AUTOREPLACE].data = SPR_REPLACE_TRAIN; |
4638
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
859 |
break; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
860 |
|
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
861 |
case VEH_Road: |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
862 |
w->widget[DEPOT_WIDGET_CAPTION].data = STR_9003_ROAD_VEHICLE_DEPOT; |
4686
e438e8b2ab61
(svn r6591) -Codechange: changed strings that used the word "depot" into one for each vehicle type
bjarni
parents:
4681
diff
changeset
|
863 |
w->widget[DEPOT_WIDGET_STOP_ALL].tooltips = STR_MASS_STOP_DEPOT_ROADVEH_TIP; |
e438e8b2ab61
(svn r6591) -Codechange: changed strings that used the word "depot" into one for each vehicle type
bjarni
parents:
4681
diff
changeset
|
864 |
w->widget[DEPOT_WIDGET_START_ALL].tooltips= STR_MASS_START_DEPOT_ROADVEH_TIP; |
4638
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
865 |
w->widget[DEPOT_WIDGET_SELL].tooltips = STR_9024_DRAG_ROAD_VEHICLE_TO_HERE; |
4686
e438e8b2ab61
(svn r6591) -Codechange: changed strings that used the word "depot" into one for each vehicle type
bjarni
parents:
4681
diff
changeset
|
866 |
w->widget[DEPOT_WIDGET_SELL_ALL].tooltips = STR_DEPOT_SELL_ALL_BUTTON_ROADVEH_TIP; |
4638
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
867 |
w->widget[DEPOT_WIDGET_MATRIX].tooltips = STR_9022_VEHICLES_CLICK_ON_VEHICLE; |
4686
e438e8b2ab61
(svn r6591) -Codechange: changed strings that used the word "depot" into one for each vehicle type
bjarni
parents:
4681
diff
changeset
|
868 |
|
4638
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
869 |
w->widget[DEPOT_WIDGET_BUILD].data = STR_9004_NEW_VEHICLES; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
870 |
w->widget[DEPOT_WIDGET_BUILD].tooltips = STR_9023_BUILD_NEW_ROAD_VEHICLE; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
871 |
w->widget[DEPOT_WIDGET_CLONE].data = STR_CLONE_ROAD_VEHICLE; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
872 |
w->widget[DEPOT_WIDGET_CLONE].tooltips = STR_CLONE_ROAD_VEHICLE_DEPOT_INFO; |
4686
e438e8b2ab61
(svn r6591) -Codechange: changed strings that used the word "depot" into one for each vehicle type
bjarni
parents:
4681
diff
changeset
|
873 |
|
4638
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
874 |
w->widget[DEPOT_WIDGET_LOCATION].tooltips = STR_9025_CENTER_MAIN_VIEW_ON_ROAD; |
4681
bc077405e9a8
(svn r6586) -Feature: [depot window] added a vehicle list window with all vehicles having a certain depot in their orders
bjarni
parents:
4670
diff
changeset
|
875 |
w->widget[DEPOT_WIDGET_VEHICLE_LIST].data = STR_LORRY; |
bc077405e9a8
(svn r6586) -Feature: [depot window] added a vehicle list window with all vehicles having a certain depot in their orders
bjarni
parents:
4670
diff
changeset
|
876 |
w->widget[DEPOT_WIDGET_VEHICLE_LIST].tooltips = STR_DEPOT_VEHICLE_ORDER_LIST_ROADVEH_TIP; |
4686
e438e8b2ab61
(svn r6591) -Codechange: changed strings that used the word "depot" into one for each vehicle type
bjarni
parents:
4681
diff
changeset
|
877 |
w->widget[DEPOT_WIDGET_AUTOREPLACE].tooltips = STR_DEPOT_AUTOREPLACE_ROADVEH_TIP; |
4688
9cea258f031f
(svn r6593) -Fix: [depot window] added sprites to the buttons, that lacked one
bjarni
parents:
4686
diff
changeset
|
878 |
|
9cea258f031f
(svn r6593) -Fix: [depot window] added sprites to the buttons, that lacked one
bjarni
parents:
4686
diff
changeset
|
879 |
/* Sprites */ |
9cea258f031f
(svn r6593) -Fix: [depot window] added sprites to the buttons, that lacked one
bjarni
parents:
4686
diff
changeset
|
880 |
w->widget[DEPOT_WIDGET_SELL].data = SPR_SELL_ROADVEH; |
9cea258f031f
(svn r6593) -Fix: [depot window] added sprites to the buttons, that lacked one
bjarni
parents:
4686
diff
changeset
|
881 |
w->widget[DEPOT_WIDGET_SELL_ALL].data = SPR_SELL_ALL_ROADVEH; |
9cea258f031f
(svn r6593) -Fix: [depot window] added sprites to the buttons, that lacked one
bjarni
parents:
4686
diff
changeset
|
882 |
w->widget[DEPOT_WIDGET_AUTOREPLACE].data = SPR_REPLACE_ROADVEH; |
4638
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
883 |
break; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
884 |
|
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
885 |
case VEH_Ship: |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
886 |
w->widget[DEPOT_WIDGET_CAPTION].data = STR_9803_SHIP_DEPOT; |
4686
e438e8b2ab61
(svn r6591) -Codechange: changed strings that used the word "depot" into one for each vehicle type
bjarni
parents:
4681
diff
changeset
|
887 |
w->widget[DEPOT_WIDGET_STOP_ALL].tooltips = STR_MASS_STOP_DEPOT_SHIP_TIP; |
e438e8b2ab61
(svn r6591) -Codechange: changed strings that used the word "depot" into one for each vehicle type
bjarni
parents:
4681
diff
changeset
|
888 |
w->widget[DEPOT_WIDGET_START_ALL].tooltips= STR_MASS_START_DEPOT_SHIP_TIP; |
4638
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
889 |
w->widget[DEPOT_WIDGET_SELL].tooltips = STR_9821_DRAG_SHIP_TO_HERE_TO_SELL; |
4686
e438e8b2ab61
(svn r6591) -Codechange: changed strings that used the word "depot" into one for each vehicle type
bjarni
parents:
4681
diff
changeset
|
890 |
w->widget[DEPOT_WIDGET_SELL_ALL].tooltips = STR_DEPOT_SELL_ALL_BUTTON_SHIP_TIP; |
4638
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
891 |
w->widget[DEPOT_WIDGET_MATRIX].tooltips = STR_981F_SHIPS_CLICK_ON_SHIP_FOR; |
4686
e438e8b2ab61
(svn r6591) -Codechange: changed strings that used the word "depot" into one for each vehicle type
bjarni
parents:
4681
diff
changeset
|
892 |
|
4638
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
893 |
w->widget[DEPOT_WIDGET_BUILD].data = STR_9804_NEW_SHIPS; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
894 |
w->widget[DEPOT_WIDGET_BUILD].tooltips = STR_9820_BUILD_NEW_SHIP; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
895 |
w->widget[DEPOT_WIDGET_CLONE].data = STR_CLONE_SHIP; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
896 |
w->widget[DEPOT_WIDGET_CLONE].tooltips = STR_CLONE_SHIP_DEPOT_INFO; |
4686
e438e8b2ab61
(svn r6591) -Codechange: changed strings that used the word "depot" into one for each vehicle type
bjarni
parents:
4681
diff
changeset
|
897 |
|
4638
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
898 |
w->widget[DEPOT_WIDGET_LOCATION].tooltips = STR_9822_CENTER_MAIN_VIEW_ON_SHIP; |
4681
bc077405e9a8
(svn r6586) -Feature: [depot window] added a vehicle list window with all vehicles having a certain depot in their orders
bjarni
parents:
4670
diff
changeset
|
899 |
w->widget[DEPOT_WIDGET_VEHICLE_LIST].data = STR_SHIP; |
bc077405e9a8
(svn r6586) -Feature: [depot window] added a vehicle list window with all vehicles having a certain depot in their orders
bjarni
parents:
4670
diff
changeset
|
900 |
w->widget[DEPOT_WIDGET_VEHICLE_LIST].tooltips = STR_DEPOT_VEHICLE_ORDER_LIST_SHIP_TIP; |
4686
e438e8b2ab61
(svn r6591) -Codechange: changed strings that used the word "depot" into one for each vehicle type
bjarni
parents:
4681
diff
changeset
|
901 |
w->widget[DEPOT_WIDGET_AUTOREPLACE].tooltips = STR_DEPOT_AUTOREPLACE_SHIP_TIP; |
4688
9cea258f031f
(svn r6593) -Fix: [depot window] added sprites to the buttons, that lacked one
bjarni
parents:
4686
diff
changeset
|
902 |
|
9cea258f031f
(svn r6593) -Fix: [depot window] added sprites to the buttons, that lacked one
bjarni
parents:
4686
diff
changeset
|
903 |
/* Sprites */ |
9cea258f031f
(svn r6593) -Fix: [depot window] added sprites to the buttons, that lacked one
bjarni
parents:
4686
diff
changeset
|
904 |
w->widget[DEPOT_WIDGET_SELL].data = SPR_SELL_SHIP; |
9cea258f031f
(svn r6593) -Fix: [depot window] added sprites to the buttons, that lacked one
bjarni
parents:
4686
diff
changeset
|
905 |
w->widget[DEPOT_WIDGET_SELL_ALL].data = SPR_SELL_ALL_SHIP; |
9cea258f031f
(svn r6593) -Fix: [depot window] added sprites to the buttons, that lacked one
bjarni
parents:
4686
diff
changeset
|
906 |
w->widget[DEPOT_WIDGET_AUTOREPLACE].data = SPR_REPLACE_SHIP; |
4638
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
907 |
break; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
908 |
|
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
909 |
case VEH_Aircraft: |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
910 |
w->widget[DEPOT_WIDGET_CAPTION].data = STR_A002_AIRCRAFT_HANGAR; |
4686
e438e8b2ab61
(svn r6591) -Codechange: changed strings that used the word "depot" into one for each vehicle type
bjarni
parents:
4681
diff
changeset
|
911 |
w->widget[DEPOT_WIDGET_STOP_ALL].tooltips = STR_MASS_STOP_HANGAR_TIP; |
e438e8b2ab61
(svn r6591) -Codechange: changed strings that used the word "depot" into one for each vehicle type
bjarni
parents:
4681
diff
changeset
|
912 |
w->widget[DEPOT_WIDGET_START_ALL].tooltips= STR_MASS_START_HANGAR_TIP; |
4638
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
913 |
w->widget[DEPOT_WIDGET_SELL].tooltips = STR_A023_DRAG_AIRCRAFT_TO_HERE_TO; |
4686
e438e8b2ab61
(svn r6591) -Codechange: changed strings that used the word "depot" into one for each vehicle type
bjarni
parents:
4681
diff
changeset
|
914 |
w->widget[DEPOT_WIDGET_SELL_ALL].tooltips = STR_DEPOT_SELL_ALL_BUTTON_AIRCRAFT_TIP; |
4638
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
915 |
w->widget[DEPOT_WIDGET_MATRIX].tooltips = STR_A021_AIRCRAFT_CLICK_ON_AIRCRAFT; |
4686
e438e8b2ab61
(svn r6591) -Codechange: changed strings that used the word "depot" into one for each vehicle type
bjarni
parents:
4681
diff
changeset
|
916 |
|
4638
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
917 |
w->widget[DEPOT_WIDGET_BUILD].data = STR_A003_NEW_AIRCRAFT; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
918 |
w->widget[DEPOT_WIDGET_BUILD].tooltips = STR_A022_BUILD_NEW_AIRCRAFT; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
919 |
w->widget[DEPOT_WIDGET_CLONE].data = STR_CLONE_AIRCRAFT; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
920 |
w->widget[DEPOT_WIDGET_CLONE].tooltips = STR_CLONE_AIRCRAFT_INFO_HANGAR_WINDOW; |
4686
e438e8b2ab61
(svn r6591) -Codechange: changed strings that used the word "depot" into one for each vehicle type
bjarni
parents:
4681
diff
changeset
|
921 |
|
4638
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
922 |
w->widget[DEPOT_WIDGET_LOCATION].tooltips = STR_A024_CENTER_MAIN_VIEW_ON_HANGAR; |
4681
bc077405e9a8
(svn r6586) -Feature: [depot window] added a vehicle list window with all vehicles having a certain depot in their orders
bjarni
parents:
4670
diff
changeset
|
923 |
w->widget[DEPOT_WIDGET_VEHICLE_LIST].data = STR_PLANE; |
bc077405e9a8
(svn r6586) -Feature: [depot window] added a vehicle list window with all vehicles having a certain depot in their orders
bjarni
parents:
4670
diff
changeset
|
924 |
w->widget[DEPOT_WIDGET_VEHICLE_LIST].tooltips = STR_DEPOT_VEHICLE_ORDER_LIST_AIRCRAFT_TIP; |
4686
e438e8b2ab61
(svn r6591) -Codechange: changed strings that used the word "depot" into one for each vehicle type
bjarni
parents:
4681
diff
changeset
|
925 |
w->widget[DEPOT_WIDGET_AUTOREPLACE].tooltips = STR_DEPOT_AUTOREPLACE_AIRCRAFT_TIP; |
4688
9cea258f031f
(svn r6593) -Fix: [depot window] added sprites to the buttons, that lacked one
bjarni
parents:
4686
diff
changeset
|
926 |
|
9cea258f031f
(svn r6593) -Fix: [depot window] added sprites to the buttons, that lacked one
bjarni
parents:
4686
diff
changeset
|
927 |
/* Sprites */ |
9cea258f031f
(svn r6593) -Fix: [depot window] added sprites to the buttons, that lacked one
bjarni
parents:
4686
diff
changeset
|
928 |
w->widget[DEPOT_WIDGET_SELL].data = SPR_SELL_AIRCRAFT; |
9cea258f031f
(svn r6593) -Fix: [depot window] added sprites to the buttons, that lacked one
bjarni
parents:
4686
diff
changeset
|
929 |
w->widget[DEPOT_WIDGET_SELL_ALL].data = SPR_SELL_ALL_AIRCRAFT; |
9cea258f031f
(svn r6593) -Fix: [depot window] added sprites to the buttons, that lacked one
bjarni
parents:
4686
diff
changeset
|
930 |
w->widget[DEPOT_WIDGET_AUTOREPLACE].data = SPR_REPLACE_AIRCRAFT; |
4638
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
931 |
break; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
932 |
} |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
933 |
} |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
934 |
|
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
935 |
/** Opens a depot window |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
936 |
* @param tile The tile where the depot/hangar is located |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
937 |
* @param type The type of vehicles in the depot |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
938 |
*/ |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
939 |
void ShowDepotWindow(TileIndex tile, byte type) |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
940 |
{ |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
941 |
Window *w; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
942 |
|
4651
73d828df1b28
(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
|
943 |
/* First we ensure that the widget counts are equal in all 3 lists to prevent bad stuff from happening */ |
4652
f85116c065f1
(svn r6528) -Fix r6527: fixed an off by one error in an assert
bjarni
parents:
4651
diff
changeset
|
944 |
assert(lengthof(widget_moves) == lengthof(_depot_widgets) - 1); // we should not count WIDGETS_END |
4651
73d828df1b28
(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
|
945 |
assert(lengthof(widget_moves) == DEPOT_WIDGET_LAST); |
73d828df1b28
(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
|
946 |
|
4638
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
947 |
switch (type) { |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
948 |
case VEH_Train: w = AllocateWindowDescFront(&_train_depot_desc, tile); break; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
949 |
case VEH_Road: w = AllocateWindowDescFront(&_road_depot_desc, tile); break; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
950 |
case VEH_Ship: w = AllocateWindowDescFront(&_ship_depot_desc, tile); break; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
951 |
case VEH_Aircraft: w = AllocateWindowDescFront(&_aircraft_depot_desc, tile); break; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
952 |
default: NOT_REACHED(); w = NULL; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
953 |
} |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
954 |
|
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
955 |
if (w != NULL) { |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
956 |
int16 horizontal = 0, vertical = 0; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
957 |
w->caption_color = GetTileOwner(tile); |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
958 |
WP(w, depot_d).type = type; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
959 |
WP(w, depot_d).sel = INVALID_VEHICLE; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
960 |
_backup_orders_tile = 0; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
961 |
|
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
962 |
/* Resize the window according to the vehicle type */ |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
963 |
switch (type) { |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
964 |
case VEH_Train: |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
965 |
horizontal = 56; |
4659
e476c76389a8
(svn r6542) -Feature: [depot window] added a "sell all vehicles in depot" button
bjarni
parents:
4654
diff
changeset
|
966 |
vertical = 26; |
4638
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
967 |
w->vscroll.cap = 6; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
968 |
w->hscroll.cap = 10 * 29; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
969 |
w->resize.step_width = 1; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
970 |
w->resize.step_height = 14; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
971 |
break; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
972 |
|
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
973 |
case VEH_Road: |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
974 |
horizontal = 10; |
4681
bc077405e9a8
(svn r6586) -Feature: [depot window] added a vehicle list window with all vehicles having a certain depot in their orders
bjarni
parents:
4670
diff
changeset
|
975 |
vertical = - 14 + 14; |
bc077405e9a8
(svn r6586) -Feature: [depot window] added a vehicle list window with all vehicles having a certain depot in their orders
bjarni
parents:
4670
diff
changeset
|
976 |
w->vscroll.cap = 5; |
4638
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
977 |
w->hscroll.cap = 5; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
978 |
w->resize.step_width = 56; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
979 |
w->resize.step_height = 14; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
980 |
break; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
981 |
|
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
982 |
case VEH_Ship: |
4659
e476c76389a8
(svn r6542) -Feature: [depot window] added a "sell all vehicles in depot" button
bjarni
parents:
4654
diff
changeset
|
983 |
w->vscroll.cap = 3; |
4638
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
984 |
w->hscroll.cap = 3; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
985 |
w->resize.step_width = 90; |
4667
0004c6406554
(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
|
986 |
w->resize.step_height = 23; |
4638
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
987 |
break; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
988 |
|
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
989 |
case VEH_Aircraft: |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
990 |
horizontal = 26; |
4659
e476c76389a8
(svn r6542) -Feature: [depot window] added a "sell all vehicles in depot" button
bjarni
parents:
4654
diff
changeset
|
991 |
w->vscroll.cap = 3; |
4638
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
992 |
w->hscroll.cap = 4; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
993 |
w->resize.step_width = 74; |
4667
0004c6406554
(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
|
994 |
w->resize.step_height = 23; |
4638
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
995 |
break; |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
996 |
|
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
997 |
default: NOT_REACHED(); |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
998 |
} |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
999 |
|
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
1000 |
SetupStringsForDepotWindow(w, type); |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
1001 |
|
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
1002 |
w->widget[DEPOT_WIDGET_MATRIX].data = |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
1003 |
(w->vscroll.cap * 0x100) // number of rows to draw on the background |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
1004 |
+ (type == VEH_Train ? 1 : w->hscroll.cap); // number of boxes in each row. Trains always have just one |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
1005 |
|
4758
090cf0f1b35e
(svn r6672) -Codechange: [depot & vehicle windows] applied SetWindowWidgetsDisabledState() and SetWindowWidgetsHiddenState() to depot and vehicle windows
bjarni
parents:
4754
diff
changeset
|
1006 |
|
090cf0f1b35e
(svn r6672) -Codechange: [depot & vehicle windows] applied SetWindowWidgetsDisabledState() and SetWindowWidgetsHiddenState() to depot and vehicle windows
bjarni
parents:
4754
diff
changeset
|
1007 |
SetWindowWidgetsHiddenState(w, type != VEH_Train, |
090cf0f1b35e
(svn r6672) -Codechange: [depot & vehicle windows] applied SetWindowWidgetsDisabledState() and SetWindowWidgetsHiddenState() to depot and vehicle windows
bjarni
parents:
4754
diff
changeset
|
1008 |
DEPOT_WIDGET_H_SCROLL, |
090cf0f1b35e
(svn r6672) -Codechange: [depot & vehicle windows] applied SetWindowWidgetsDisabledState() and SetWindowWidgetsHiddenState() to depot and vehicle windows
bjarni
parents:
4754
diff
changeset
|
1009 |
DEPOT_WIDGET_H_SCROLL, |
090cf0f1b35e
(svn r6672) -Codechange: [depot & vehicle windows] applied SetWindowWidgetsDisabledState() and SetWindowWidgetsHiddenState() to depot and vehicle windows
bjarni
parents:
4754
diff
changeset
|
1010 |
WIDGET_LIST_END); |
4638
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
1011 |
|
4668
f7256d0e7682
(svn r6562) -Codechange: merged the vehicle list window widget arrays
bjarni
parents:
4667
diff
changeset
|
1012 |
/* Move the widgets to their right locations */ |
f7256d0e7682
(svn r6562) -Codechange: merged the vehicle list window widget arrays
bjarni
parents:
4667
diff
changeset
|
1013 |
ResizeWindowWidgets(w, widget_moves, lengthof(widget_moves), horizontal, vertical); |
4650
52adab371ed7
(svn r6526) -Codechange: [depot window] the train only widgets are now resized depending on the size of other widgets
bjarni
parents:
4649
diff
changeset
|
1014 |
|
52adab371ed7
(svn r6526) -Codechange: [depot window] the train only widgets are now resized depending on the size of other widgets
bjarni
parents:
4649
diff
changeset
|
1015 |
if (type == VEH_Train) { |
52adab371ed7
(svn r6526) -Codechange: [depot window] the train only widgets are now resized depending on the size of other widgets
bjarni
parents:
4649
diff
changeset
|
1016 |
/* Now we move the train only widgets so they are placed correctly |
52adab371ed7
(svn r6526) -Codechange: [depot window] the train only widgets are now resized depending on the size of other widgets
bjarni
parents:
4649
diff
changeset
|
1017 |
* Doing it here will ensure that they move if the widget they are placed on top of/aligned to are moved */ |
52adab371ed7
(svn r6526) -Codechange: [depot window] the train only widgets are now resized depending on the size of other widgets
bjarni
parents:
4649
diff
changeset
|
1018 |
|
52adab371ed7
(svn r6526) -Codechange: [depot window] the train only widgets are now resized depending on the size of other widgets
bjarni
parents:
4649
diff
changeset
|
1019 |
/* DEPOT_WIDGET_H_SCROLL is placed in the lowest part of DEPOT_WIDGET_MATRIX */ |
52adab371ed7
(svn r6526) -Codechange: [depot window] the train only widgets are now resized depending on the size of other widgets
bjarni
parents:
4649
diff
changeset
|
1020 |
w->widget[DEPOT_WIDGET_H_SCROLL].left = w->widget[DEPOT_WIDGET_MATRIX].left; |
52adab371ed7
(svn r6526) -Codechange: [depot window] the train only widgets are now resized depending on the size of other widgets
bjarni
parents:
4649
diff
changeset
|
1021 |
w->widget[DEPOT_WIDGET_H_SCROLL].right = w->widget[DEPOT_WIDGET_MATRIX].right; |
52adab371ed7
(svn r6526) -Codechange: [depot window] the train only widgets are now resized depending on the size of other widgets
bjarni
parents:
4649
diff
changeset
|
1022 |
w->widget[DEPOT_WIDGET_H_SCROLL].bottom = w->widget[DEPOT_WIDGET_MATRIX].bottom; |
52adab371ed7
(svn r6526) -Codechange: [depot window] the train only widgets are now resized depending on the size of other widgets
bjarni
parents:
4649
diff
changeset
|
1023 |
w->widget[DEPOT_WIDGET_H_SCROLL].top = w->widget[DEPOT_WIDGET_MATRIX].bottom - 11; |
52adab371ed7
(svn r6526) -Codechange: [depot window] the train only widgets are now resized depending on the size of other widgets
bjarni
parents:
4649
diff
changeset
|
1024 |
w->widget[DEPOT_WIDGET_MATRIX].bottom -= 12; |
52adab371ed7
(svn r6526) -Codechange: [depot window] the train only widgets are now resized depending on the size of other widgets
bjarni
parents:
4649
diff
changeset
|
1025 |
|
4659
e476c76389a8
(svn r6542) -Feature: [depot window] added a "sell all vehicles in depot" button
bjarni
parents:
4654
diff
changeset
|
1026 |
/* DEPOT_WIDGET_SELL_CHAIN is under DEPOT_WIDGET_SELL. They got the same left and right and height is controlled in ResizeDepotButtons() */ |
e476c76389a8
(svn r6542) -Feature: [depot window] added a "sell all vehicles in depot" button
bjarni
parents:
4654
diff
changeset
|
1027 |
w->widget[DEPOT_WIDGET_SELL_CHAIN].left = w->widget[DEPOT_WIDGET_SELL].left; |
e476c76389a8
(svn r6542) -Feature: [depot window] added a "sell all vehicles in depot" button
bjarni
parents:
4654
diff
changeset
|
1028 |
w->widget[DEPOT_WIDGET_SELL_CHAIN].right = w->widget[DEPOT_WIDGET_SELL].right; |
4650
52adab371ed7
(svn r6526) -Codechange: [depot window] the train only widgets are now resized depending on the size of other widgets
bjarni
parents:
4649
diff
changeset
|
1029 |
} |
4646
d3d73ee03bbc
(svn r6522) -Feature: [depot window] the buttons are now "scaled" resized
bjarni
parents:
4644
diff
changeset
|
1030 |
ResizeDepotButtons(w); |
4638
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
1031 |
} |
05955c6cb536
(svn r6513) -Codechange: unified the code to draw depot windows
bjarni
parents:
diff
changeset
|
1032 |
} |