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