annotate src/depot_gui.cpp @ 13034:6eb3f749890a draft

(svn r17532) -Codechange: Rename several Invalidate functions to SetDirty for more consistency and distinguishability.
author frosch <frosch@openttd.org>
date Sun, 13 Sep 2009 19:15:59 +0000
parents 045a6264ea5b
children 090bac35e7e4
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1 /* $Id$ */
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
2
12778
bc7926153e19 (svn r17248) -Fix: add GPL license notice where appropriate
rubidium <rubidium@openttd.org>
parents: 12762
diff changeset
3 /*
bc7926153e19 (svn r17248) -Fix: add GPL license notice where appropriate
rubidium <rubidium@openttd.org>
parents: 12762
diff changeset
4 * This file is part of OpenTTD.
bc7926153e19 (svn r17248) -Fix: add GPL license notice where appropriate
rubidium <rubidium@openttd.org>
parents: 12762
diff changeset
5 * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
bc7926153e19 (svn r17248) -Fix: add GPL license notice where appropriate
rubidium <rubidium@openttd.org>
parents: 12762
diff changeset
6 * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
bc7926153e19 (svn r17248) -Fix: add GPL license notice where appropriate
rubidium <rubidium@openttd.org>
parents: 12762
diff changeset
7 * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
bc7926153e19 (svn r17248) -Fix: add GPL license notice where appropriate
rubidium <rubidium@openttd.org>
parents: 12762
diff changeset
8 */
bc7926153e19 (svn r17248) -Fix: add GPL license notice where appropriate
rubidium <rubidium@openttd.org>
parents: 12762
diff changeset
9
9111
d48433370037 (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 <rubidium@openttd.org>
parents: 9094
diff changeset
10 /** @file depot_gui.cpp The GUI for depots. */
6125
46d001ebacf6 (svn r8862) -Cleanup: doxygen changes, again. Mostly @files missing tags and a few comments style.
belugas <belugas@openttd.org>
parents: 6043
diff changeset
11
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
12 #include "train.h"
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
13 #include "ship.h"
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
14 #include "aircraft.h"
11984
b6d3e583be86 (svn r16390) -Codechange: move u.road to RoadVehicle.
rubidium <rubidium@openttd.org>
parents: 11922
diff changeset
15 #include "roadveh.h"
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
16 #include "gui.h"
8107
f65cf2bc3255 (svn r11668) -Codechange: more refactoring aimed at reducing compile time and making it more logic where function definitions can be found.
rubidium <rubidium@openttd.org>
parents: 8082
diff changeset
17 #include "textbuf_gui.h"
8224
c45446125bf0 (svn r11787) -Codechange: more header rewrites. This time related to viewport.h.
rubidium <rubidium@openttd.org>
parents: 8144
diff changeset
18 #include "viewport_func.h"
c45446125bf0 (svn r11787) -Codechange: more header rewrites. This time related to viewport.h.
rubidium <rubidium@openttd.org>
parents: 8144
diff changeset
19 #include "gfx_func.h"
8116
9cc845deddfe (svn r11677) -Codechange: move price and command related types/functions to their respective places.
rubidium <rubidium@openttd.org>
parents: 8114
diff changeset
20 #include "command_func.h"
8962
322e2779f67a (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 <rubidium@openttd.org>
parents: 8828
diff changeset
21 #include "depot_base.h"
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
22 #include "vehicle_gui.h"
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
23 #include "newgrf_engine.h"
5972
6ece78140826 (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 <bjarni@openttd.org>
parents: 5955
diff changeset
24 #include "spritecache.h"
8114
2d6af5d7a142 (svn r11675) -Codechange: split the string types from the string functions.
rubidium <rubidium@openttd.org>
parents: 8107
diff changeset
25 #include "strings_func.h"
8131
e300ac8001ae (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 <rubidium@openttd.org>
parents: 8121
diff changeset
26 #include "window_func.h"
8144
d18c8a0bb638 (svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium <rubidium@openttd.org>
parents: 8131
diff changeset
27 #include "vehicle_func.h"
10208
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents: 10207
diff changeset
28 #include "company_func.h"
9127
428852b86d4d (svn r12987) -Codechange: split viewport and tile selection.
rubidium <rubidium@openttd.org>
parents: 9116
diff changeset
29 #include "tilehighlight_func.h"
9274
85a62fb8608f (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 <rubidium@openttd.org>
parents: 9273
diff changeset
30 #include "window_gui.h"
9396
bbf7586724f4 (svn r13307) -Codechange: Separate VehicleList and its two functions so only the 3 users include it, reducing dependencies on misc/smallvec.h
peter1138 <peter1138@openttd.org>
parents: 9351
diff changeset
31 #include "vehiclelist.h"
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
32
8264
2495310e220f (svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium <rubidium@openttd.org>
parents: 8254
diff changeset
33 #include "table/strings.h"
2495310e220f (svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium <rubidium@openttd.org>
parents: 8254
diff changeset
34 #include "table/sprites.h"
2495310e220f (svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium <rubidium@openttd.org>
parents: 8254
diff changeset
35
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
36 /*
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
37 * Since all depot window sizes aren't the same, we need to modify sizes a little.
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
38 * 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.
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
39 * How long they should be moved and for what window types are controlled in ShowDepotWindow()
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
40 */
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
41
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
42 /* Names of the widgets. Keep them in the same order as in the widget array */
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
43 enum DepotWindowWidgets {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
44 DEPOT_WIDGET_CLOSEBOX = 0,
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
45 DEPOT_WIDGET_CAPTION,
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
46 DEPOT_WIDGET_STICKY,
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
47 DEPOT_WIDGET_SELL,
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
48 DEPOT_WIDGET_SELL_CHAIN,
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
49 DEPOT_WIDGET_SELL_ALL,
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
50 DEPOT_WIDGET_AUTOREPLACE,
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
51 DEPOT_WIDGET_MATRIX,
6125
46d001ebacf6 (svn r8862) -Cleanup: doxygen changes, again. Mostly @files missing tags and a few comments style.
belugas <belugas@openttd.org>
parents: 6043
diff changeset
52 DEPOT_WIDGET_V_SCROLL, ///< Vertical scrollbar
46d001ebacf6 (svn r8862) -Cleanup: doxygen changes, again. Mostly @files missing tags and a few comments style.
belugas <belugas@openttd.org>
parents: 6043
diff changeset
53 DEPOT_WIDGET_H_SCROLL, ///< Horizontal scrollbar
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
54 DEPOT_WIDGET_BUILD,
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
55 DEPOT_WIDGET_CLONE,
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
56 DEPOT_WIDGET_LOCATION,
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
57 DEPOT_WIDGET_VEHICLE_LIST,
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
58 DEPOT_WIDGET_STOP_ALL,
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
59 DEPOT_WIDGET_START_ALL,
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
60 DEPOT_WIDGET_RESIZE,
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
61 };
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
62
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
63 /* Widget array for all depot windows.
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
64 * If a widget is needed in some windows only (like train specific), add it for all windows
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
65 * and use HideWindowWidget in ShowDepotWindow() to remove it in the windows where it should not be
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
66 * Keep the widget numbers in sync with the enum or really bad stuff will happen!!! */
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
67
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
68 /* 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[]
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
69 * 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
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
70 * 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.
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
71 * Changing the size of those here will not have an effect at all. It should be done in ShowDepotWindow()
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
72 */
5972
6ece78140826 (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 <bjarni@openttd.org>
parents: 5955
diff changeset
73
6ece78140826 (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 <bjarni@openttd.org>
parents: 5955
diff changeset
74 /*
6ece78140826 (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 <bjarni@openttd.org>
parents: 5955
diff changeset
75 * Some of the widgets are placed outside the window (negative coordinates).
6ece78140826 (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 <bjarni@openttd.org>
parents: 5955
diff changeset
76 * The reason is that they are placed relatively to the matrix and the matrix is just one pixel (in 0, 14).
6ece78140826 (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 <bjarni@openttd.org>
parents: 5955
diff changeset
77 * 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.
6ece78140826 (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 <bjarni@openttd.org>
parents: 5955
diff changeset
78 */
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
79 static const Widget _depot_widgets[] = {
11730
a39da1e4c1f5 (svn r16118) -Change/cleanup: remove the hexadecimal 'in TTD the string had this ID' from 'some' strings and replace the string name with something more sensible.
rubidium <rubidium@openttd.org>
parents: 11702
diff changeset
80 { WWT_CLOSEBOX, RESIZE_NONE, COLOUR_GREY, 0, 10, 0, 13, STR_BLACK_CROSS, STR_TOOLTIP_CLOSE_WINDOW}, // DEPOT_WIDGET_CLOSEBOX
a39da1e4c1f5 (svn r16118) -Change/cleanup: remove the hexadecimal 'in TTD the string had this ID' from 'some' strings and replace the string name with something more sensible.
rubidium <rubidium@openttd.org>
parents: 11702
diff changeset
81 { WWT_CAPTION, RESIZE_RIGHT, COLOUR_GREY, 11, 23, 0, 13, 0x0, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS}, // DEPOT_WIDGET_CAPTION
12632
e41943276802 (svn r17075) -Codechange: rename ~750 strings to be more uniform with their relatives
rubidium <rubidium@openttd.org>
parents: 12485
diff changeset
82 { WWT_STICKYBOX, RESIZE_LR, COLOUR_GREY, 24, 35, 0, 13, 0x0, STR_TOOLTIP_STICKY}, // DEPOT_WIDGET_STICKY
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
83
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
84 /* Widgets are set up run-time */
9751
8702be5e8787 (svn r13887) -Codechange: Replace numbers with Colours enum on autoreplace, build_vehicle, cheat, depot and dock guis.
belugas <belugas@openttd.org>
parents: 9670
diff changeset
85 { WWT_IMGBTN, RESIZE_LRB, COLOUR_GREY, 1, 23, 14, -32, 0x0, STR_NULL}, // DEPOT_WIDGET_SELL
12632
e41943276802 (svn r17075) -Codechange: rename ~750 strings to be more uniform with their relatives
rubidium <rubidium@openttd.org>
parents: 12485
diff changeset
86 { WWT_IMGBTN, RESIZE_LRTB, COLOUR_GREY, 1, 23, -55, -32, SPR_SELL_CHAIN_TRAIN,STR_DEPOT_DRAG_WHOLE_TRAIN_TO_SELL_TOOLTIP}, // DEPOT_WIDGET_SELL_CHAIN, trains only
9751
8702be5e8787 (svn r13887) -Codechange: Replace numbers with Colours enum on autoreplace, build_vehicle, cheat, depot and dock guis.
belugas <belugas@openttd.org>
parents: 9670
diff changeset
87 { WWT_PUSHIMGBTN, RESIZE_LRTB, COLOUR_GREY, 1, 23, -31, -9, 0x0, STR_NULL}, // DEPOT_WIDGET_SELL_ALL
8702be5e8787 (svn r13887) -Codechange: Replace numbers with Colours enum on autoreplace, build_vehicle, cheat, depot and dock guis.
belugas <belugas@openttd.org>
parents: 9670
diff changeset
88 { WWT_PUSHIMGBTN, RESIZE_LRTB, COLOUR_GREY, 1, 23, -8, 14, 0x0, STR_NULL}, // DEPOT_WIDGET_AUTOREPLACE
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
89
9751
8702be5e8787 (svn r13887) -Codechange: Replace numbers with Colours enum on autoreplace, build_vehicle, cheat, depot and dock guis.
belugas <belugas@openttd.org>
parents: 9670
diff changeset
90 { WWT_MATRIX, RESIZE_RB, COLOUR_GREY, 0, 0, 14, 14, 0x0, STR_NULL}, // DEPOT_WIDGET_MATRIX
11730
a39da1e4c1f5 (svn r16118) -Change/cleanup: remove the hexadecimal 'in TTD the string had this ID' from 'some' strings and replace the string name with something more sensible.
rubidium <rubidium@openttd.org>
parents: 11702
diff changeset
91 { WWT_SCROLLBAR, RESIZE_LRB, COLOUR_GREY, 24, 35, 14, 14, 0x0, STR_TOOLTIP_VSCROLL_BAR_SCROLLS_LIST}, // DEPOT_WIDGET_V_SCROLL
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
92
11730
a39da1e4c1f5 (svn r16118) -Change/cleanup: remove the hexadecimal 'in TTD the string had this ID' from 'some' strings and replace the string name with something more sensible.
rubidium <rubidium@openttd.org>
parents: 11702
diff changeset
93 { WWT_HSCROLLBAR, RESIZE_RTB, COLOUR_GREY, 0, 0, 3, 14, 0x0, STR_TOOLTIP_HSCROLL_BAR_SCROLLS_LIST}, // DEPOT_WIDGET_H_SCROLL, trains only
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
94
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
95 /* The buttons in the bottom of the window. left and right is not important as they are later resized to be equal in size
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
96 * This calculation is based on right in DEPOT_WIDGET_LOCATION and it presumes left of DEPOT_WIDGET_BUILD is 0 */
9751
8702be5e8787 (svn r13887) -Codechange: Replace numbers with Colours enum on autoreplace, build_vehicle, cheat, depot and dock guis.
belugas <belugas@openttd.org>
parents: 9670
diff changeset
97 { WWT_PUSHTXTBTN, RESIZE_TB, COLOUR_GREY, 0, 0, 15, 26, 0x0, STR_NULL}, // DEPOT_WIDGET_BUILD
8702be5e8787 (svn r13887) -Codechange: Replace numbers with Colours enum on autoreplace, build_vehicle, cheat, depot and dock guis.
belugas <belugas@openttd.org>
parents: 9670
diff changeset
98 { WWT_TEXTBTN, RESIZE_TB, COLOUR_GREY, 0, 0, 15, 26, 0x0, STR_NULL}, // DEPOT_WIDGET_CLONE
11730
a39da1e4c1f5 (svn r16118) -Change/cleanup: remove the hexadecimal 'in TTD the string had this ID' from 'some' strings and replace the string name with something more sensible.
rubidium <rubidium@openttd.org>
parents: 11702
diff changeset
99 { WWT_PUSHTXTBTN, RESIZE_RTB, COLOUR_GREY, 0, -12, 15, 26, STR_BUTTON_LOCATION, STR_NULL}, // DEPOT_WIDGET_LOCATION
9751
8702be5e8787 (svn r13887) -Codechange: Replace numbers with Colours enum on autoreplace, build_vehicle, cheat, depot and dock guis.
belugas <belugas@openttd.org>
parents: 9670
diff changeset
100 { WWT_PUSHTXTBTN, RESIZE_LRTB, COLOUR_GREY, -11, 0, 15, 26, 0x0, STR_NULL}, // DEPOT_WIDGET_VEHICLE_LIST
8702be5e8787 (svn r13887) -Codechange: Replace numbers with Colours enum on autoreplace, build_vehicle, cheat, depot and dock guis.
belugas <belugas@openttd.org>
parents: 9670
diff changeset
101 { WWT_PUSHIMGBTN, RESIZE_LRTB, COLOUR_GREY, 1, 11, 15, 26, SPR_FLAG_VEH_STOPPED,STR_NULL}, // DEPOT_WIDGET_STOP_ALL
8702be5e8787 (svn r13887) -Codechange: Replace numbers with Colours enum on autoreplace, build_vehicle, cheat, depot and dock guis.
belugas <belugas@openttd.org>
parents: 9670
diff changeset
102 { WWT_PUSHIMGBTN, RESIZE_LRTB, COLOUR_GREY, 12, 23, 15, 26, SPR_FLAG_VEH_RUNNING,STR_NULL}, // DEPOT_WIDGET_START_ALL
12632
e41943276802 (svn r17075) -Codechange: rename ~750 strings to be more uniform with their relatives
rubidium <rubidium@openttd.org>
parents: 12485
diff changeset
103 { WWT_RESIZEBOX, RESIZE_LRTB, COLOUR_GREY, 24, 35, 15, 26, 0x0, STR_TOOLTIP_RESIZE}, // DEPOT_WIDGET_RESIZE
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
104 { WIDGETS_END},
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
105 };
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
106
9188
20be86848948 (svn r13051) -Codechange: depot_d belongs in depot_gui.cpp.
rubidium <rubidium@openttd.org>
parents: 9143
diff changeset
107
11373
474ba6cc0946 (svn r15723) -Codechange: use a constructor for WindowDescs as that makes expanding them much easier (Alberth)
rubidium <rubidium@openttd.org>
parents: 11368
diff changeset
108 static const WindowDesc _train_depot_desc(
10503
60daa84bb001 (svn r14758) -Fix: determine the real size of a depot before trying to place it.
rubidium <rubidium@openttd.org>
parents: 10499
diff changeset
109 WDP_AUTO, WDP_AUTO, 36, 27, 362, 123,
5893
8547517ef719 (svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium <rubidium@openttd.org>
parents: 5824
diff changeset
110 WC_VEHICLE_DEPOT, WC_NONE,
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
111 WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_STICKY_BUTTON | WDF_RESIZABLE,
11373
474ba6cc0946 (svn r15723) -Codechange: use a constructor for WindowDescs as that makes expanding them much easier (Alberth)
rubidium <rubidium@openttd.org>
parents: 11368
diff changeset
112 _depot_widgets
474ba6cc0946 (svn r15723) -Codechange: use a constructor for WindowDescs as that makes expanding them much easier (Alberth)
rubidium <rubidium@openttd.org>
parents: 11368
diff changeset
113 );
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
114
11373
474ba6cc0946 (svn r15723) -Codechange: use a constructor for WindowDescs as that makes expanding them much easier (Alberth)
rubidium <rubidium@openttd.org>
parents: 11368
diff changeset
115 static const WindowDesc _road_depot_desc(
10503
60daa84bb001 (svn r14758) -Fix: determine the real size of a depot before trying to place it.
rubidium <rubidium@openttd.org>
parents: 10499
diff changeset
116 WDP_AUTO, WDP_AUTO, 36, 27, 316, 97,
5893
8547517ef719 (svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium <rubidium@openttd.org>
parents: 5824
diff changeset
117 WC_VEHICLE_DEPOT, WC_NONE,
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
118 WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_STICKY_BUTTON | WDF_RESIZABLE,
11373
474ba6cc0946 (svn r15723) -Codechange: use a constructor for WindowDescs as that makes expanding them much easier (Alberth)
rubidium <rubidium@openttd.org>
parents: 11368
diff changeset
119 _depot_widgets
474ba6cc0946 (svn r15723) -Codechange: use a constructor for WindowDescs as that makes expanding them much easier (Alberth)
rubidium <rubidium@openttd.org>
parents: 11368
diff changeset
120 );
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
121
11373
474ba6cc0946 (svn r15723) -Codechange: use a constructor for WindowDescs as that makes expanding them much easier (Alberth)
rubidium <rubidium@openttd.org>
parents: 11368
diff changeset
122 static const WindowDesc _ship_depot_desc(
10503
60daa84bb001 (svn r14758) -Fix: determine the real size of a depot before trying to place it.
rubidium <rubidium@openttd.org>
parents: 10499
diff changeset
123 WDP_AUTO, WDP_AUTO, 36, 27, 306, 99,
5893
8547517ef719 (svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium <rubidium@openttd.org>
parents: 5824
diff changeset
124 WC_VEHICLE_DEPOT, WC_NONE,
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
125 WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_STICKY_BUTTON | WDF_RESIZABLE,
11373
474ba6cc0946 (svn r15723) -Codechange: use a constructor for WindowDescs as that makes expanding them much easier (Alberth)
rubidium <rubidium@openttd.org>
parents: 11368
diff changeset
126 _depot_widgets
474ba6cc0946 (svn r15723) -Codechange: use a constructor for WindowDescs as that makes expanding them much easier (Alberth)
rubidium <rubidium@openttd.org>
parents: 11368
diff changeset
127 );
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
128
11373
474ba6cc0946 (svn r15723) -Codechange: use a constructor for WindowDescs as that makes expanding them much easier (Alberth)
rubidium <rubidium@openttd.org>
parents: 11368
diff changeset
129 static const WindowDesc _aircraft_depot_desc(
10503
60daa84bb001 (svn r14758) -Fix: determine the real size of a depot before trying to place it.
rubidium <rubidium@openttd.org>
parents: 10499
diff changeset
130 WDP_AUTO, WDP_AUTO, 36, 27, 332, 99,
5893
8547517ef719 (svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium <rubidium@openttd.org>
parents: 5824
diff changeset
131 WC_VEHICLE_DEPOT, WC_NONE,
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
132 WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_STICKY_BUTTON | WDF_RESIZABLE,
11373
474ba6cc0946 (svn r15723) -Codechange: use a constructor for WindowDescs as that makes expanding them much easier (Alberth)
rubidium <rubidium@openttd.org>
parents: 11368
diff changeset
133 _depot_widgets
474ba6cc0946 (svn r15723) -Codechange: use a constructor for WindowDescs as that makes expanding them much easier (Alberth)
rubidium <rubidium@openttd.org>
parents: 11368
diff changeset
134 );
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
135
9351
feaf9bae7580 (svn r13248) -Codechange: Use VehicleList for depot GUI.
peter1138 <peter1138@openttd.org>
parents: 9344
diff changeset
136 extern void DepotSortList(VehicleList *list);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
137
7478
29e4afeffd1e (svn r10985) -Codechange: unify/remove duplicate CcClone(Aircraft|RoadVeh|Ship|Train) in favour of CcCloneVehicle.
rubidium <rubidium@openttd.org>
parents: 7341
diff changeset
138 /**
29e4afeffd1e (svn r10985) -Codechange: unify/remove duplicate CcClone(Aircraft|RoadVeh|Ship|Train) in favour of CcCloneVehicle.
rubidium <rubidium@openttd.org>
parents: 7341
diff changeset
139 * This is the Callback method after the cloning attempt of a vehicle
29e4afeffd1e (svn r10985) -Codechange: unify/remove duplicate CcClone(Aircraft|RoadVeh|Ship|Train) in favour of CcCloneVehicle.
rubidium <rubidium@openttd.org>
parents: 7341
diff changeset
140 * @param success indicates completion (or not) of the operation
29e4afeffd1e (svn r10985) -Codechange: unify/remove duplicate CcClone(Aircraft|RoadVeh|Ship|Train) in favour of CcCloneVehicle.
rubidium <rubidium@openttd.org>
parents: 7341
diff changeset
141 * @param tile unused
29e4afeffd1e (svn r10985) -Codechange: unify/remove duplicate CcClone(Aircraft|RoadVeh|Ship|Train) in favour of CcCloneVehicle.
rubidium <rubidium@openttd.org>
parents: 7341
diff changeset
142 * @param p1 unused
29e4afeffd1e (svn r10985) -Codechange: unify/remove duplicate CcClone(Aircraft|RoadVeh|Ship|Train) in favour of CcCloneVehicle.
rubidium <rubidium@openttd.org>
parents: 7341
diff changeset
143 * @param p2 unused
29e4afeffd1e (svn r10985) -Codechange: unify/remove duplicate CcClone(Aircraft|RoadVeh|Ship|Train) in favour of CcCloneVehicle.
rubidium <rubidium@openttd.org>
parents: 7341
diff changeset
144 */
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
145 void CcCloneVehicle(bool success, TileIndex tile, uint32 p1, uint32 p2)
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
146 {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
147 if (!success) return;
7478
29e4afeffd1e (svn r10985) -Codechange: unify/remove duplicate CcClone(Aircraft|RoadVeh|Ship|Train) in favour of CcCloneVehicle.
rubidium <rubidium@openttd.org>
parents: 7341
diff changeset
148
11922
0a4b63f3f3c3 (svn r16325) -Codechange: replace GetPoolItem(index) by PoolItem::Get(index)
smatz <smatz@openttd.org>
parents: 11896
diff changeset
149 const Vehicle *v = Vehicle::Get(_new_vehicle_id);
7478
29e4afeffd1e (svn r10985) -Codechange: unify/remove duplicate CcClone(Aircraft|RoadVeh|Ship|Train) in favour of CcCloneVehicle.
rubidium <rubidium@openttd.org>
parents: 7341
diff changeset
150
7486
1af81beda3fb (svn r10997) -Codechange: unify the vehicle view window. Patch by PhilSophus.
rubidium <rubidium@openttd.org>
parents: 7479
diff changeset
151 ShowVehicleViewWindow(v);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
152 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
153
9344
5940dd28c40d (svn r13240) -Codechange: More const-ness for GUI code.
peter1138 <peter1138@openttd.org>
parents: 9343
diff changeset
154 static void TrainDepotMoveVehicle(const Vehicle *wagon, VehicleID sel, const Vehicle *head)
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
155 {
11922
0a4b63f3f3c3 (svn r16325) -Codechange: replace GetPoolItem(index) by PoolItem::Get(index)
smatz <smatz@openttd.org>
parents: 11896
diff changeset
156 const Vehicle *v = Vehicle::Get(sel);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
157
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
158 if (v == wagon) return;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
159
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
160 if (wagon == NULL) {
12460
4acae7d6f5ed (svn r16894) -Codechange: Add [Specialised]Vehicle::Last().
frosch <frosch@openttd.org>
parents: 12450
diff changeset
161 if (head != NULL) wagon = head->Last();
12762
839af08c39fc (svn r17228) -Codechange: some coding style fixes
rubidium <rubidium@openttd.org>
parents: 12729
diff changeset
162 } else {
7497
797ff0b0e0a5 (svn r11011) -Fix [FS#1129]: GetFirstVehicleInChain did change the game state while being marked const.
rubidium <rubidium@openttd.org>
parents: 7492
diff changeset
163 wagon = wagon->Previous();
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
164 if (wagon == NULL) return;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
165 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
166
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
167 if (wagon == v) return;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
168
11730
a39da1e4c1f5 (svn r16118) -Change/cleanup: remove the hexadecimal 'in TTD the string had this ID' from 'some' strings and replace the string name with something more sensible.
rubidium <rubidium@openttd.org>
parents: 11702
diff changeset
169 DoCommandP(v->tile, v->index + ((wagon == NULL ? INVALID_VEHICLE : wagon->index) << 16), _ctrl_pressed ? 1 : 0, CMD_MOVE_RAIL_VEHICLE | CMD_MSG(STR_ERROR_CAN_T_MOVE_VEHICLE));
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
170 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
171
5972
6ece78140826 (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 <bjarni@openttd.org>
parents: 5955
diff changeset
172 /* Array to hold the block sizes
6ece78140826 (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 <bjarni@openttd.org>
parents: 5955
diff changeset
173 * First part is the vehicle type, while the last is 0 = x, 1 = y */
6ece78140826 (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 <bjarni@openttd.org>
parents: 5955
diff changeset
174 uint _block_sizes[4][2];
6ece78140826 (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 <bjarni@openttd.org>
parents: 5955
diff changeset
175
6ece78140826 (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 <bjarni@openttd.org>
parents: 5955
diff changeset
176 /* Array to hold the default resize capacities
11361
02313cc6114e (svn r15711) -Codechange: lots of whitespace cleanup/fixes
rubidium <rubidium@openttd.org>
parents: 11084
diff changeset
177 * First part is the vehicle type, while the last is 0 = x, 1 = y */
5972
6ece78140826 (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 <bjarni@openttd.org>
parents: 5955
diff changeset
178 const uint _resize_cap[][2] = {
6401
79373384d9c4 (svn r9531) -Fix (r8661) [FS#692]: The scroll settings were wrong for trains as only a part
maedhros <maedhros@openttd.org>
parents: 6259
diff changeset
179 /* VEH_TRAIN */ {6, 10 * 29},
6259
4a39d6291d58 (svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium <rubidium@openttd.org>
parents: 6248
diff changeset
180 /* VEH_ROAD */ {5, 5},
4a39d6291d58 (svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium <rubidium@openttd.org>
parents: 6248
diff changeset
181 /* VEH_SHIP */ {3, 3},
4a39d6291d58 (svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium <rubidium@openttd.org>
parents: 6248
diff changeset
182 /* VEH_AIRCRAFT */ {3, 4},
5972
6ece78140826 (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 <bjarni@openttd.org>
parents: 5955
diff changeset
183 };
6ece78140826 (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 <bjarni@openttd.org>
parents: 5955
diff changeset
184
6ece78140826 (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 <bjarni@openttd.org>
parents: 5955
diff changeset
185 static void ResizeDefaultWindowSizeForTrains()
6ece78140826 (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 <bjarni@openttd.org>
parents: 5955
diff changeset
186 {
6259
4a39d6291d58 (svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium <rubidium@openttd.org>
parents: 6248
diff changeset
187 _block_sizes[VEH_TRAIN][0] = 1;
4a39d6291d58 (svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium <rubidium@openttd.org>
parents: 6248
diff changeset
188 _block_sizes[VEH_TRAIN][1] = GetVehicleListHeight(VEH_TRAIN);
5972
6ece78140826 (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 <bjarni@openttd.org>
parents: 5955
diff changeset
189 }
6ece78140826 (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 <bjarni@openttd.org>
parents: 5955
diff changeset
190
6ece78140826 (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 <bjarni@openttd.org>
parents: 5955
diff changeset
191 static void ResizeDefaultWindowSizeForRoadVehicles()
6ece78140826 (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 <bjarni@openttd.org>
parents: 5955
diff changeset
192 {
6259
4a39d6291d58 (svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium <rubidium@openttd.org>
parents: 6248
diff changeset
193 _block_sizes[VEH_ROAD][0] = 56;
4a39d6291d58 (svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium <rubidium@openttd.org>
parents: 6248
diff changeset
194 _block_sizes[VEH_ROAD][1] = GetVehicleListHeight(VEH_ROAD);
5972
6ece78140826 (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 <bjarni@openttd.org>
parents: 5955
diff changeset
195 }
6ece78140826 (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 <bjarni@openttd.org>
parents: 5955
diff changeset
196
6638
5479975c4e36 (svn r9869) -Codechange: replace some bytes with VehicleType, i.e. more type strictness.
rubidium <rubidium@openttd.org>
parents: 6621
diff changeset
197 static void ResizeDefaultWindowSize(VehicleType type)
5972
6ece78140826 (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 <bjarni@openttd.org>
parents: 5955
diff changeset
198 {
6ece78140826 (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 <bjarni@openttd.org>
parents: 5955
diff changeset
199 uint max_width = 0;
6ece78140826 (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 <bjarni@openttd.org>
parents: 5955
diff changeset
200 uint max_height = 0;
6ece78140826 (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 <bjarni@openttd.org>
parents: 5955
diff changeset
201
9070
11b5b3f4175d (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 <peter1138@openttd.org>
parents: 9065
diff changeset
202 const Engine *e;
11b5b3f4175d (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 <peter1138@openttd.org>
parents: 9065
diff changeset
203 FOR_ALL_ENGINES_OF_TYPE(e, type) {
11b5b3f4175d (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 <peter1138@openttd.org>
parents: 9065
diff changeset
204 EngineID eid = e->index;
5972
6ece78140826 (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 <bjarni@openttd.org>
parents: 5955
diff changeset
205 uint x, y;
6ece78140826 (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 <bjarni@openttd.org>
parents: 5955
diff changeset
206
6ece78140826 (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 <bjarni@openttd.org>
parents: 5955
diff changeset
207 switch (type) {
6ece78140826 (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 <bjarni@openttd.org>
parents: 5955
diff changeset
208 default: NOT_REACHED();
9065
d341f7b59228 (svn r12917) -Codechange: standardise variable names called with FOR_ALL_ENGINEIDS_OF_TYPE
peter1138 <peter1138@openttd.org>
parents: 8969
diff changeset
209 case VEH_SHIP: GetShipSpriteSize( eid, x, y); break;
d341f7b59228 (svn r12917) -Codechange: standardise variable names called with FOR_ALL_ENGINEIDS_OF_TYPE
peter1138 <peter1138@openttd.org>
parents: 8969
diff changeset
210 case VEH_AIRCRAFT: GetAircraftSpriteSize(eid, x, y); break;
5972
6ece78140826 (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 <bjarni@openttd.org>
parents: 5955
diff changeset
211 }
6ece78140826 (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 <bjarni@openttd.org>
parents: 5955
diff changeset
212 if (x > max_width) max_width = x;
6ece78140826 (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 <bjarni@openttd.org>
parents: 5955
diff changeset
213 if (y > max_height) max_height = y;
6ece78140826 (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 <bjarni@openttd.org>
parents: 5955
diff changeset
214 }
6ece78140826 (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 <bjarni@openttd.org>
parents: 5955
diff changeset
215
6ece78140826 (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 <bjarni@openttd.org>
parents: 5955
diff changeset
216 switch (type) {
6ece78140826 (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 <bjarni@openttd.org>
parents: 5955
diff changeset
217 default: NOT_REACHED();
6259
4a39d6291d58 (svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium <rubidium@openttd.org>
parents: 6248
diff changeset
218 case VEH_SHIP:
4a39d6291d58 (svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium <rubidium@openttd.org>
parents: 6248
diff changeset
219 _block_sizes[VEH_SHIP][0] = max(90U, max_width + 20); // we need 20 pixels from the right edge to the sprite
5972
6ece78140826 (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 <bjarni@openttd.org>
parents: 5955
diff changeset
220 break;
6259
4a39d6291d58 (svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium <rubidium@openttd.org>
parents: 6248
diff changeset
221 case VEH_AIRCRAFT:
4a39d6291d58 (svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium <rubidium@openttd.org>
parents: 6248
diff changeset
222 _block_sizes[VEH_AIRCRAFT][0] = max(74U, max_width);
5972
6ece78140826 (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 <bjarni@openttd.org>
parents: 5955
diff changeset
223 break;
6ece78140826 (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 <bjarni@openttd.org>
parents: 5955
diff changeset
224 }
6ece78140826 (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 <bjarni@openttd.org>
parents: 5955
diff changeset
225 _block_sizes[type][1] = max(GetVehicleListHeight(type), max_height);
6ece78140826 (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 <bjarni@openttd.org>
parents: 5955
diff changeset
226 }
6ece78140826 (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 <bjarni@openttd.org>
parents: 5955
diff changeset
227
6ece78140826 (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 <bjarni@openttd.org>
parents: 5955
diff changeset
228 /* 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
6ece78140826 (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 <bjarni@openttd.org>
parents: 5955
diff changeset
229 * We will only need to call this once for each game */
6ece78140826 (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 <bjarni@openttd.org>
parents: 5955
diff changeset
230 void InitDepotWindowBlockSizes()
6ece78140826 (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 <bjarni@openttd.org>
parents: 5955
diff changeset
231 {
6ece78140826 (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 <bjarni@openttd.org>
parents: 5955
diff changeset
232 ResizeDefaultWindowSizeForTrains();
6ece78140826 (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 <bjarni@openttd.org>
parents: 5955
diff changeset
233 ResizeDefaultWindowSizeForRoadVehicles();
6259
4a39d6291d58 (svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium <rubidium@openttd.org>
parents: 6248
diff changeset
234 ResizeDefaultWindowSize(VEH_SHIP);
4a39d6291d58 (svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium <rubidium@openttd.org>
parents: 6248
diff changeset
235 ResizeDefaultWindowSize(VEH_AIRCRAFT);
5972
6ece78140826 (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 <bjarni@openttd.org>
parents: 5955
diff changeset
236 }
6ece78140826 (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 <bjarni@openttd.org>
parents: 5955
diff changeset
237
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
238 static void DepotSellAllConfirmationCallback(Window *w, bool confirmed);
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
239 const Sprite *GetAircraftSprite(EngineID engine);
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
240
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
241 struct DepotWindow : Window {
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
242 VehicleID sel;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
243 VehicleType type;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
244 bool generate_list;
9351
feaf9bae7580 (svn r13248) -Codechange: Use VehicleList for depot GUI.
peter1138 <peter1138@openttd.org>
parents: 9344
diff changeset
245 VehicleList vehicle_list;
feaf9bae7580 (svn r13248) -Codechange: Use VehicleList for depot GUI.
peter1138 <peter1138@openttd.org>
parents: 9344
diff changeset
246 VehicleList wagon_list;
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
247
10503
60daa84bb001 (svn r14758) -Fix: determine the real size of a depot before trying to place it.
rubidium <rubidium@openttd.org>
parents: 10499
diff changeset
248 DepotWindow(const WindowDesc *desc, TileIndex tile, VehicleType type) : Window(desc, tile)
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
249 {
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
250 this->sel = INVALID_VEHICLE;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
251 this->generate_list = true;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
252
11084
e07c7d3925c8 (svn r15427) -Codechange: give w->caption_color a more sensible name as it holds the owner of whatever is shown in the window
rubidium <rubidium@openttd.org>
parents: 10960
diff changeset
253 this->owner = GetTileOwner(tile);
10503
60daa84bb001 (svn r14758) -Fix: determine the real size of a depot before trying to place it.
rubidium <rubidium@openttd.org>
parents: 10499
diff changeset
254 this->CreateDepotListWindow(type);
60daa84bb001 (svn r14758) -Fix: determine the real size of a depot before trying to place it.
rubidium <rubidium@openttd.org>
parents: 10499
diff changeset
255
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
256 this->FindWindowPlacementAndResize(desc);
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
257 }
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
258
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
259 ~DepotWindow()
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
260 {
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
261 DeleteWindowById(WC_BUILD_VEHICLE, this->window_number);
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
262 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
263
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
264 /** Draw a vehicle in the depot window in the box with the top left corner at x,y
11361
02313cc6114e (svn r15711) -Codechange: lots of whitespace cleanup/fixes
rubidium <rubidium@openttd.org>
parents: 11084
diff changeset
265 * @param *w Window to draw in
02313cc6114e (svn r15711) -Codechange: lots of whitespace cleanup/fixes
rubidium <rubidium@openttd.org>
parents: 11084
diff changeset
266 * @param *v Vehicle to draw
02313cc6114e (svn r15711) -Codechange: lots of whitespace cleanup/fixes
rubidium <rubidium@openttd.org>
parents: 11084
diff changeset
267 * @param x Left side of the box to draw in
02313cc6114e (svn r15711) -Codechange: lots of whitespace cleanup/fixes
rubidium <rubidium@openttd.org>
parents: 11084
diff changeset
268 * @param y Top of the box to draw in
02313cc6114e (svn r15711) -Codechange: lots of whitespace cleanup/fixes
rubidium <rubidium@openttd.org>
parents: 11084
diff changeset
269 */
12876
6f97f7fe9a93 (svn r17368) -Codechange: remove pointless passing of 'this' as parameter
rubidium <rubidium@openttd.org>
parents: 12778
diff changeset
270 void DrawVehicleInDepot(const Vehicle *v, int x, int y)
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
271 {
12440
83a4c35ab350 (svn r16874) -Change: Give the number behind free wagon chains in depots the same meaning as for trains.
frosch <frosch@openttd.org>
parents: 12433
diff changeset
272 bool free_wagon = false;
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
273 int sprite_y = y + this->resize.step_height - GetVehicleListHeight(v->type);
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
274
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
275 switch (v->type) {
12440
83a4c35ab350 (svn r16874) -Change: Give the number behind free wagon chains in depots the same meaning as for trains.
frosch <frosch@openttd.org>
parents: 12433
diff changeset
276 case VEH_TRAIN: {
83a4c35ab350 (svn r16874) -Change: Give the number behind free wagon chains in depots the same meaning as for trains.
frosch <frosch@openttd.org>
parents: 12433
diff changeset
277 const Train *u = Train::From(v);
83a4c35ab350 (svn r16874) -Change: Give the number behind free wagon chains in depots the same meaning as for trains.
frosch <frosch@openttd.org>
parents: 12433
diff changeset
278 free_wagon = u->IsFreeWagon();
83a4c35ab350 (svn r16874) -Change: Give the number behind free wagon chains in depots the same meaning as for trains.
frosch <frosch@openttd.org>
parents: 12433
diff changeset
279
83a4c35ab350 (svn r16874) -Change: Give the number behind free wagon chains in depots the same meaning as for trains.
frosch <frosch@openttd.org>
parents: 12433
diff changeset
280 uint x_space = free_wagon ? TRAININFO_DEFAULT_VEHICLE_WIDTH : 0;
12877
e63af9c28034 (svn r17369) -Codechange: make the depot, group and industry GUIs use the scrollbar wrappers
rubidium <rubidium@openttd.org>
parents: 12876
diff changeset
281 DrawTrainImage(u, x + 24 + x_space, sprite_y - 1, this->sel, this->hscroll.GetCapacity() - x_space, this->hscroll.GetPosition());
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
282
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
283 /* Number of wagons relative to a standard length wagon (rounded up) */
12440
83a4c35ab350 (svn r16874) -Change: Give the number behind free wagon chains in depots the same meaning as for trains.
frosch <frosch@openttd.org>
parents: 12433
diff changeset
284 SetDParam(0, (u->tcache.cached_total_length + 7) / 8);
12632
e41943276802 (svn r17075) -Codechange: rename ~750 strings to be more uniform with their relatives
rubidium <rubidium@openttd.org>
parents: 12485
diff changeset
285 DrawString(this->widget[DEPOT_WIDGET_MATRIX].left, this->widget[DEPOT_WIDGET_MATRIX].right - 1, y + 4, STR_TINY_BLACK_COMA, TC_FROMSTRING, SA_RIGHT); // Draw the counter
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
286 break;
12440
83a4c35ab350 (svn r16874) -Change: Give the number behind free wagon chains in depots the same meaning as for trains.
frosch <frosch@openttd.org>
parents: 12433
diff changeset
287 }
5972
6ece78140826 (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 <bjarni@openttd.org>
parents: 5955
diff changeset
288
12433
c3588e7cb8f6 (svn r16867) -Feature(ette): Turn variable 0E/8E (vertical offset for trains in depot) and variable 1E/9E bit 3 (wagon width in depot) into grf-local variables.
frosch <frosch@openttd.org>
parents: 12411
diff changeset
289 case VEH_ROAD: DrawRoadVehImage( v, x + 24, sprite_y, this->sel, ROADVEHINFO_DEFAULT_VEHICLE_WIDTH); break;
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
290 case VEH_SHIP: DrawShipImage( v, x + 19, sprite_y - 1, this->sel); break;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
291 case VEH_AIRCRAFT: {
10056
7867701f63e4 (svn r14223) -Codechange: make GetSprite aware of the 4 different types of sprites: fonts, recolour, mapgen and normal sprites.
rubidium <rubidium@openttd.org>
parents: 9931
diff changeset
292 const Sprite *spr = GetSprite(v->GetImage(DIR_W), ST_NORMAL);
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
293 DrawAircraftImage(v, x + 12,
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
294 y + max(spr->height + spr->y_offs - 14, 0), // tall sprites needs an y offset
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
295 this->sel);
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
296 } break;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
297 default: NOT_REACHED();
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
298 }
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
299
12440
83a4c35ab350 (svn r16874) -Change: Give the number behind free wagon chains in depots the same meaning as for trains.
frosch <frosch@openttd.org>
parents: 12433
diff changeset
300 if (free_wagon) {
83a4c35ab350 (svn r16874) -Change: Give the number behind free wagon chains in depots the same meaning as for trains.
frosch <frosch@openttd.org>
parents: 12433
diff changeset
301 DrawString(x, this->widget[DEPOT_WIDGET_MATRIX].right - 1, y + 2, STR_DEPOT_NO_ENGINE);
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
302 } else {
12440
83a4c35ab350 (svn r16874) -Change: Give the number behind free wagon chains in depots the same meaning as for trains.
frosch <frosch@openttd.org>
parents: 12433
diff changeset
303 byte diff_x = 0, diff_y = 0;
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
304
12440
83a4c35ab350 (svn r16874) -Change: Give the number behind free wagon chains in depots the same meaning as for trains.
frosch <frosch@openttd.org>
parents: 12433
diff changeset
305 if (v->type == VEH_TRAIN || v->type == VEH_ROAD) {
83a4c35ab350 (svn r16874) -Change: Give the number behind free wagon chains in depots the same meaning as for trains.
frosch <frosch@openttd.org>
parents: 12433
diff changeset
306 /* Arrange unitnumber and flag horizontally */
83a4c35ab350 (svn r16874) -Change: Give the number behind free wagon chains in depots the same meaning as for trains.
frosch <frosch@openttd.org>
parents: 12433
diff changeset
307 diff_x = 15;
83a4c35ab350 (svn r16874) -Change: Give the number behind free wagon chains in depots the same meaning as for trains.
frosch <frosch@openttd.org>
parents: 12433
diff changeset
308 } else {
83a4c35ab350 (svn r16874) -Change: Give the number behind free wagon chains in depots the same meaning as for trains.
frosch <frosch@openttd.org>
parents: 12433
diff changeset
309 /* Arrange unitnumber and flag vertically */
83a4c35ab350 (svn r16874) -Change: Give the number behind free wagon chains in depots the same meaning as for trains.
frosch <frosch@openttd.org>
parents: 12433
diff changeset
310 diff_y = 12;
83a4c35ab350 (svn r16874) -Change: Give the number behind free wagon chains in depots the same meaning as for trains.
frosch <frosch@openttd.org>
parents: 12433
diff changeset
311 }
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
312
12440
83a4c35ab350 (svn r16874) -Change: Give the number behind free wagon chains in depots the same meaning as for trains.
frosch <frosch@openttd.org>
parents: 12433
diff changeset
313 DrawSprite((v->vehstatus & VS_STOPPED) ? SPR_FLAG_VEH_STOPPED : SPR_FLAG_VEH_RUNNING, PAL_NONE, x + diff_x, y + diff_y);
83a4c35ab350 (svn r16874) -Change: Give the number behind free wagon chains in depots the same meaning as for trains.
frosch <frosch@openttd.org>
parents: 12433
diff changeset
314
83a4c35ab350 (svn r16874) -Change: Give the number behind free wagon chains in depots the same meaning as for trains.
frosch <frosch@openttd.org>
parents: 12433
diff changeset
315 SetDParam(0, v->unitnumber);
83a4c35ab350 (svn r16874) -Change: Give the number behind free wagon chains in depots the same meaning as for trains.
frosch <frosch@openttd.org>
parents: 12433
diff changeset
316 DrawString(x, this->widget[DEPOT_WIDGET_MATRIX].right - 1, y + 2, (uint16)(v->max_age - DAYS_IN_LEAP_YEAR) >= v->age ? STR_BLACK_COMMA : STR_RED_COMMA);
83a4c35ab350 (svn r16874) -Change: Give the number behind free wagon chains in depots the same meaning as for trains.
frosch <frosch@openttd.org>
parents: 12433
diff changeset
317 }
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
318 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
319
12876
6f97f7fe9a93 (svn r17368) -Codechange: remove pointless passing of 'this' as parameter
rubidium <rubidium@openttd.org>
parents: 12778
diff changeset
320 void DrawDepotWindow()
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
321 {
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
322 TileIndex tile = this->window_number;
12440
83a4c35ab350 (svn r16874) -Change: Give the number behind free wagon chains in depots the same meaning as for trains.
frosch <frosch@openttd.org>
parents: 12433
diff changeset
323 int x, y, maxval;
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
324
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
325 /* Set the row and number of boxes in each row based on the number of boxes drawn in the matrix */
12411
9fdbb4594b82 (svn r16845) -Codechange: Introduction of constants for describing the bits in a WWT_MATRIX data field.
alberth <alberth@openttd.org>
parents: 12390
diff changeset
326 uint16 rows_in_display = GB(this->widget[DEPOT_WIDGET_MATRIX].data, MAT_ROW_START, MAT_ROW_BITS);
9fdbb4594b82 (svn r16845) -Codechange: Introduction of constants for describing the bits in a WWT_MATRIX data field.
alberth <alberth@openttd.org>
parents: 12390
diff changeset
327 uint16 boxes_in_each_row = GB(this->widget[DEPOT_WIDGET_MATRIX].data, MAT_COL_START, MAT_COL_BITS);
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
328
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
329 /* setup disabled buttons */
10207
c54d140df948 (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents: 10056
diff changeset
330 this->SetWidgetsDisabledState(!IsTileOwner(tile, _local_company),
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
331 DEPOT_WIDGET_STOP_ALL,
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
332 DEPOT_WIDGET_START_ALL,
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
333 DEPOT_WIDGET_SELL,
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
334 DEPOT_WIDGET_SELL_CHAIN,
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
335 DEPOT_WIDGET_SELL_ALL,
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
336 DEPOT_WIDGET_BUILD,
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
337 DEPOT_WIDGET_CLONE,
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
338 DEPOT_WIDGET_AUTOREPLACE,
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
339 WIDGET_LIST_END);
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
340
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
341 /* determine amount of items for scroller */
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
342 if (this->type == VEH_TRAIN) {
12433
c3588e7cb8f6 (svn r16867) -Feature(ette): Turn variable 0E/8E (vertical offset for trains in depot) and variable 1E/9E bit 3 (wagon width in depot) into grf-local variables.
frosch <frosch@openttd.org>
parents: 12411
diff changeset
343 uint max_width = VEHICLEINFO_FULL_VEHICLE_WIDTH;
9351
feaf9bae7580 (svn r13248) -Codechange: Use VehicleList for depot GUI.
peter1138 <peter1138@openttd.org>
parents: 9344
diff changeset
344 for (uint num = 0; num < this->vehicle_list.Length(); num++) {
12433
c3588e7cb8f6 (svn r16867) -Feature(ette): Turn variable 0E/8E (vertical offset for trains in depot) and variable 1E/9E bit 3 (wagon width in depot) into grf-local variables.
frosch <frosch@openttd.org>
parents: 12411
diff changeset
345 uint width = 0;
c3588e7cb8f6 (svn r16867) -Feature(ette): Turn variable 0E/8E (vertical offset for trains in depot) and variable 1E/9E bit 3 (wagon width in depot) into grf-local variables.
frosch <frosch@openttd.org>
parents: 12411
diff changeset
346 for (const Train *v = Train::From(this->vehicle_list[num]); v != NULL; v = v->Next()) {
c3588e7cb8f6 (svn r16867) -Feature(ette): Turn variable 0E/8E (vertical offset for trains in depot) and variable 1E/9E bit 3 (wagon width in depot) into grf-local variables.
frosch <frosch@openttd.org>
parents: 12411
diff changeset
347 width += v->GetDisplayImageWidth();
c3588e7cb8f6 (svn r16867) -Feature(ette): Turn variable 0E/8E (vertical offset for trains in depot) and variable 1E/9E bit 3 (wagon width in depot) into grf-local variables.
frosch <frosch@openttd.org>
parents: 12411
diff changeset
348 }
c3588e7cb8f6 (svn r16867) -Feature(ette): Turn variable 0E/8E (vertical offset for trains in depot) and variable 1E/9E bit 3 (wagon width in depot) into grf-local variables.
frosch <frosch@openttd.org>
parents: 12411
diff changeset
349 max_width = max(max_width, width);
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
350 }
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
351 /* Always have 1 empty row, so people can change the setting of the train */
12877
e63af9c28034 (svn r17369) -Codechange: make the depot, group and industry GUIs use the scrollbar wrappers
rubidium <rubidium@openttd.org>
parents: 12876
diff changeset
352 this->vscroll.SetCount(this->vehicle_list.Length() + this->wagon_list.Length() + 1);
e63af9c28034 (svn r17369) -Codechange: make the depot, group and industry GUIs use the scrollbar wrappers
rubidium <rubidium@openttd.org>
parents: 12876
diff changeset
353 this->hscroll.SetCount(max_width);
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
354 } else {
12877
e63af9c28034 (svn r17369) -Codechange: make the depot, group and industry GUIs use the scrollbar wrappers
rubidium <rubidium@openttd.org>
parents: 12876
diff changeset
355 this->vscroll.SetCount((this->vehicle_list.Length() + this->hscroll.GetCapacity() - 1) / this->hscroll.GetCapacity());
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
356 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
357
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
358 /* locate the depot struct */
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
359 if (this->type == VEH_AIRCRAFT) {
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
360 SetDParam(0, GetStationIndex(tile)); // Airport name
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
361 } else {
12231
2f16fe37d1b8 (svn r16646) -Codechange: rename GetDepotByTile() to Depot::GetByTile()
smatz <smatz@openttd.org>
parents: 12114
diff changeset
362 Depot *depot = Depot::GetByTile(tile);
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
363 assert(depot != NULL);
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
364
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
365 SetDParam(0, depot->town_index);
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
366 }
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
367
12876
6f97f7fe9a93 (svn r17368) -Codechange: remove pointless passing of 'this' as parameter
rubidium <rubidium@openttd.org>
parents: 12778
diff changeset
368 this->DrawWidgets();
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
369
12877
e63af9c28034 (svn r17369) -Codechange: make the depot, group and industry GUIs use the scrollbar wrappers
rubidium <rubidium@openttd.org>
parents: 12876
diff changeset
370 uint16 num = this->vscroll.GetPosition() * boxes_in_each_row;
9351
feaf9bae7580 (svn r13248) -Codechange: Use VehicleList for depot GUI.
peter1138 <peter1138@openttd.org>
parents: 9344
diff changeset
371 maxval = min(this->vehicle_list.Length(), num + (rows_in_display * boxes_in_each_row));
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
372
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
373 for (x = 2, y = 15; num < maxval; y += this->resize.step_height, x = 2) { // Draw the rows
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
374 byte i;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
375
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
376 for (i = 0; i < boxes_in_each_row && num < maxval; i++, num++, x += this->resize.step_width) {
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
377 /* Draw all vehicles in the current row */
9351
feaf9bae7580 (svn r13248) -Codechange: Use VehicleList for depot GUI.
peter1138 <peter1138@openttd.org>
parents: 9344
diff changeset
378 const Vehicle *v = this->vehicle_list[num];
12876
6f97f7fe9a93 (svn r17368) -Codechange: remove pointless passing of 'this' as parameter
rubidium <rubidium@openttd.org>
parents: 12778
diff changeset
379 this->DrawVehicleInDepot(v, x, y);
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
380 }
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
381 }
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
382
12877
e63af9c28034 (svn r17369) -Codechange: make the depot, group and industry GUIs use the scrollbar wrappers
rubidium <rubidium@openttd.org>
parents: 12876
diff changeset
383 maxval = min(this->vehicle_list.Length() + this->wagon_list.Length(), (this->vscroll.GetPosition() * boxes_in_each_row) + (rows_in_display * boxes_in_each_row));
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
384
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
385 /* draw the train wagons, that do not have an engine in front */
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
386 for (; num < maxval; num++, y += 14) {
12440
83a4c35ab350 (svn r16874) -Change: Give the number behind free wagon chains in depots the same meaning as for trains.
frosch <frosch@openttd.org>
parents: 12433
diff changeset
387 const Vehicle *v = this->wagon_list[num - this->vehicle_list.Length()];
12876
6f97f7fe9a93 (svn r17368) -Codechange: remove pointless passing of 'this' as parameter
rubidium <rubidium@openttd.org>
parents: 12778
diff changeset
388 this->DrawVehicleInDepot(v, x, y);
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
389 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
390 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
391
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
392 struct GetDepotVehiclePtData {
9344
5940dd28c40d (svn r13240) -Codechange: More const-ness for GUI code.
peter1138 <peter1138@openttd.org>
parents: 9343
diff changeset
393 const Vehicle *head;
5940dd28c40d (svn r13240) -Codechange: More const-ness for GUI code.
peter1138 <peter1138@openttd.org>
parents: 9343
diff changeset
394 const Vehicle *wagon;
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
395 };
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
396
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
397 enum DepotGUIAction {
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
398 MODE_ERROR,
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
399 MODE_DRAG_VEHICLE,
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
400 MODE_SHOW_VEHICLE,
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
401 MODE_START_STOP,
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
402 };
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
403
9344
5940dd28c40d (svn r13240) -Codechange: More const-ness for GUI code.
peter1138 <peter1138@openttd.org>
parents: 9343
diff changeset
404 DepotGUIAction GetVehicleFromDepotWndPt(int x, int y, const Vehicle **veh, GetDepotVehiclePtData *d) const
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
405 {
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
406 uint xt, row, xm = 0, ym = 0;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
407 int pos, skip = 0;
12411
9fdbb4594b82 (svn r16845) -Codechange: Introduction of constants for describing the bits in a WWT_MATRIX data field.
alberth <alberth@openttd.org>
parents: 12390
diff changeset
408 uint16 boxes_in_each_row = GB(this->widget[DEPOT_WIDGET_MATRIX].data, MAT_COL_START, MAT_COL_BITS);
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
409
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
410 if (this->type == VEH_TRAIN) {
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
411 xt = 0;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
412 x -= 23;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
413 } else {
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
414 xt = x / this->resize.step_width;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
415 xm = x % this->resize.step_width;
12877
e63af9c28034 (svn r17369) -Codechange: make the depot, group and industry GUIs use the scrollbar wrappers
rubidium <rubidium@openttd.org>
parents: 12876
diff changeset
416 if (xt >= this->hscroll.GetCapacity()) return MODE_ERROR;
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
417
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
418 ym = (y - 14) % this->resize.step_height;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
419 }
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
420
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
421 row = (y - 14) / this->resize.step_height;
12877
e63af9c28034 (svn r17369) -Codechange: make the depot, group and industry GUIs use the scrollbar wrappers
rubidium <rubidium@openttd.org>
parents: 12876
diff changeset
422 if (row >= this->vscroll.GetCapacity()) return MODE_ERROR;
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
423
12877
e63af9c28034 (svn r17369) -Codechange: make the depot, group and industry GUIs use the scrollbar wrappers
rubidium <rubidium@openttd.org>
parents: 12876
diff changeset
424 pos = ((row + this->vscroll.GetPosition()) * boxes_in_each_row) + xt;
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
425
9351
feaf9bae7580 (svn r13248) -Codechange: Use VehicleList for depot GUI.
peter1138 <peter1138@openttd.org>
parents: 9344
diff changeset
426 if ((int)(this->vehicle_list.Length() + this->wagon_list.Length()) <= pos) {
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
427 if (this->type == VEH_TRAIN) {
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
428 d->head = NULL;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
429 d->wagon = NULL;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
430 return MODE_DRAG_VEHICLE;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
431 } else {
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
432 return MODE_ERROR; // empty block, so no vehicle is selected
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
433 }
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
434 }
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
435
9351
feaf9bae7580 (svn r13248) -Codechange: Use VehicleList for depot GUI.
peter1138 <peter1138@openttd.org>
parents: 9344
diff changeset
436 if ((int)this->vehicle_list.Length() > pos) {
feaf9bae7580 (svn r13248) -Codechange: Use VehicleList for depot GUI.
peter1138 <peter1138@openttd.org>
parents: 9344
diff changeset
437 *veh = this->vehicle_list[pos];
12877
e63af9c28034 (svn r17369) -Codechange: make the depot, group and industry GUIs use the scrollbar wrappers
rubidium <rubidium@openttd.org>
parents: 12876
diff changeset
438 skip = this->hscroll.GetPosition();
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
439 } else {
9351
feaf9bae7580 (svn r13248) -Codechange: Use VehicleList for depot GUI.
peter1138 <peter1138@openttd.org>
parents: 9344
diff changeset
440 pos -= this->vehicle_list.Length();
feaf9bae7580 (svn r13248) -Codechange: Use VehicleList for depot GUI.
peter1138 <peter1138@openttd.org>
parents: 9344
diff changeset
441 *veh = this->wagon_list[pos];
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
442 /* free wagons don't have an initial loco. */
12433
c3588e7cb8f6 (svn r16867) -Feature(ette): Turn variable 0E/8E (vertical offset for trains in depot) and variable 1E/9E bit 3 (wagon width in depot) into grf-local variables.
frosch <frosch@openttd.org>
parents: 12411
diff changeset
443 x -= VEHICLEINFO_FULL_VEHICLE_WIDTH;
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
444 }
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
445
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
446 switch (this->type) {
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
447 case VEH_TRAIN: {
12300
7ec79afe8c18 (svn r16717) -Codechange: make IsFrontEngine() member of Train
smatz <smatz@openttd.org>
parents: 12263
diff changeset
448 const Train *v = Train::From(*veh);
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
449 d->head = d->wagon = v;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
450
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
451 /* either pressed the flag or the number, but only when it's a loco */
12300
7ec79afe8c18 (svn r16717) -Codechange: make IsFrontEngine() member of Train
smatz <smatz@openttd.org>
parents: 12263
diff changeset
452 if (x < 0 && v->IsFrontEngine()) return (x >= -10) ? MODE_START_STOP : MODE_SHOW_VEHICLE;
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
453
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
454 /* Skip vehicles that are scrolled off the list */
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
455 x += skip;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
456
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
457 /* find the vehicle in this row that was clicked */
12433
c3588e7cb8f6 (svn r16867) -Feature(ette): Turn variable 0E/8E (vertical offset for trains in depot) and variable 1E/9E bit 3 (wagon width in depot) into grf-local variables.
frosch <frosch@openttd.org>
parents: 12411
diff changeset
458 for (; v != NULL; v = v->Next()) {
c3588e7cb8f6 (svn r16867) -Feature(ette): Turn variable 0E/8E (vertical offset for trains in depot) and variable 1E/9E bit 3 (wagon width in depot) into grf-local variables.
frosch <frosch@openttd.org>
parents: 12411
diff changeset
459 x -= v->GetDisplayImageWidth();
c3588e7cb8f6 (svn r16867) -Feature(ette): Turn variable 0E/8E (vertical offset for trains in depot) and variable 1E/9E bit 3 (wagon width in depot) into grf-local variables.
frosch <frosch@openttd.org>
parents: 12411
diff changeset
460 if (x < 0) break;
c3588e7cb8f6 (svn r16867) -Feature(ette): Turn variable 0E/8E (vertical offset for trains in depot) and variable 1E/9E bit 3 (wagon width in depot) into grf-local variables.
frosch <frosch@openttd.org>
parents: 12411
diff changeset
461 }
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
462
12450
af266072d46c (svn r16884) -Codechange: Add Train::GetFirstEnginePart() and use it.
frosch <frosch@openttd.org>
parents: 12440
diff changeset
463 d->wagon = (v != NULL ? v->GetFirstEnginePart() : NULL);
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
464
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
465 return MODE_DRAG_VEHICLE;
12387
ebf5d196267b (svn r16817) -Codechange: Scroll depots horizontally in pixels instead of 1/8 vehicle length.
frosch <frosch@openttd.org>
parents: 12374
diff changeset
466 }
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
467
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
468 case VEH_ROAD:
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
469 if (xm >= 24) return MODE_DRAG_VEHICLE;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
470 if (xm <= 16) return MODE_SHOW_VEHICLE;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
471 break;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
472
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
473 case VEH_SHIP:
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
474 if (xm >= 19) return MODE_DRAG_VEHICLE;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
475 if (ym <= 10) return MODE_SHOW_VEHICLE;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
476 break;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
477
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
478 case VEH_AIRCRAFT:
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
479 if (xm >= 12) return MODE_DRAG_VEHICLE;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
480 if (ym <= 12) return MODE_SHOW_VEHICLE;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
481 break;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
482
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
483 default: NOT_REACHED();
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
484 }
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
485 return MODE_START_STOP;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
486 }
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
487
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
488 void DepotClick(int x, int y)
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
489 {
9213
d288bb9876c7 (svn r13079) -Fix: certain compilers give false warning about uninitialized variable
smatz <smatz@openttd.org>
parents: 9203
diff changeset
490 GetDepotVehiclePtData gdvp = { NULL, NULL };
9344
5940dd28c40d (svn r13240) -Codechange: More const-ness for GUI code.
peter1138 <peter1138@openttd.org>
parents: 9343
diff changeset
491 const Vehicle *v = NULL;
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
492 DepotGUIAction mode = this->GetVehicleFromDepotWndPt(x, y, &v, &gdvp);
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
493
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
494 /* share / copy orders */
11702
cdaad565efe5 (svn r16088) -Codechange: merge HighLightStyle and ViewportHighlightMode as they are basically the same thing
rubidium <rubidium@openttd.org>
parents: 11524
diff changeset
495 if (_thd.place_mode != HT_NONE && mode != MODE_ERROR) {
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
496 _place_clicked_vehicle = (this->type == VEH_TRAIN ? gdvp.head : v);
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
497 return;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
498 }
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
499
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
500 if (this->type == VEH_TRAIN) v = gdvp.wagon;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
501
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
502 switch (mode) {
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
503 case MODE_ERROR: // invalid
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
504 return;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
505
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
506 case MODE_DRAG_VEHICLE: { // start dragging of vehicle
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
507 VehicleID sel = this->sel;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
508
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
509 if (this->type == VEH_TRAIN && sel != INVALID_VEHICLE) {
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
510 this->sel = INVALID_VEHICLE;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
511 TrainDepotMoveVehicle(v, sel, gdvp.head);
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
512 } else if (v != NULL) {
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
513 int image = v->GetImage(DIR_W);
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
514
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
515 this->sel = v->index;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
516 this->SetDirty();
11702
cdaad565efe5 (svn r16088) -Codechange: merge HighLightStyle and ViewportHighlightMode as they are basically the same thing
rubidium <rubidium@openttd.org>
parents: 11524
diff changeset
517 SetObjectToPlaceWnd(image, GetVehiclePalette(v), HT_DRAG, this);
9670
cbf60a2ecf07 (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 <rubidium@openttd.org>
parents: 9396
diff changeset
518
cbf60a2ecf07 (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 <rubidium@openttd.org>
parents: 9396
diff changeset
519 switch (v->type) {
cbf60a2ecf07 (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 <rubidium@openttd.org>
parents: 9396
diff changeset
520 case VEH_TRAIN:
12114
f020ec6be498 (svn r16527) -Codechange: use static member functions instead of simple casts when converting Vehicle to specialised vehicle types. Includes safety check
smatz <smatz@openttd.org>
parents: 12027
diff changeset
521 _cursor.short_vehicle_offset = 16 - Train::From(v)->tcache.cached_veh_length * 2;
9670
cbf60a2ecf07 (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 <rubidium@openttd.org>
parents: 9396
diff changeset
522 break;
cbf60a2ecf07 (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 <rubidium@openttd.org>
parents: 9396
diff changeset
523
cbf60a2ecf07 (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 <rubidium@openttd.org>
parents: 9396
diff changeset
524 case VEH_ROAD:
12114
f020ec6be498 (svn r16527) -Codechange: use static member functions instead of simple casts when converting Vehicle to specialised vehicle types. Includes safety check
smatz <smatz@openttd.org>
parents: 12027
diff changeset
525 _cursor.short_vehicle_offset = 16 - RoadVehicle::From(v)->rcache.cached_veh_length * 2;
9670
cbf60a2ecf07 (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 <rubidium@openttd.org>
parents: 9396
diff changeset
526 break;
cbf60a2ecf07 (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 <rubidium@openttd.org>
parents: 9396
diff changeset
527
cbf60a2ecf07 (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 <rubidium@openttd.org>
parents: 9396
diff changeset
528 default:
cbf60a2ecf07 (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 <rubidium@openttd.org>
parents: 9396
diff changeset
529 _cursor.short_vehicle_offset = 0;
cbf60a2ecf07 (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 <rubidium@openttd.org>
parents: 9396
diff changeset
530 break;
cbf60a2ecf07 (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 <rubidium@openttd.org>
parents: 9396
diff changeset
531 }
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
532 _cursor.vehchain = _ctrl_pressed;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
533 }
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
534 } break;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
535
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
536 case MODE_SHOW_VEHICLE: // show info window
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
537 ShowVehicleViewWindow(v);
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
538 break;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
539
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
540 case MODE_START_STOP: { // click start/stop flag
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
541 uint command;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
542
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
543 switch (this->type) {
11730
a39da1e4c1f5 (svn r16118) -Change/cleanup: remove the hexadecimal 'in TTD the string had this ID' from 'some' strings and replace the string name with something more sensible.
rubidium <rubidium@openttd.org>
parents: 11702
diff changeset
544 case VEH_TRAIN: command = CMD_START_STOP_VEHICLE | CMD_MSG(STR_ERROR_CAN_T_STOP_START_TRAIN); break;
a39da1e4c1f5 (svn r16118) -Change/cleanup: remove the hexadecimal 'in TTD the string had this ID' from 'some' strings and replace the string name with something more sensible.
rubidium <rubidium@openttd.org>
parents: 11702
diff changeset
545 case VEH_ROAD: command = CMD_START_STOP_VEHICLE | CMD_MSG(STR_ERROR_CAN_T_STOP_START_ROAD_VEHICLE); break;
a39da1e4c1f5 (svn r16118) -Change/cleanup: remove the hexadecimal 'in TTD the string had this ID' from 'some' strings and replace the string name with something more sensible.
rubidium <rubidium@openttd.org>
parents: 11702
diff changeset
546 case VEH_SHIP: command = CMD_START_STOP_VEHICLE | CMD_MSG(STR_ERROR_CAN_T_STOP_START_SHIP); break;
a39da1e4c1f5 (svn r16118) -Change/cleanup: remove the hexadecimal 'in TTD the string had this ID' from 'some' strings and replace the string name with something more sensible.
rubidium <rubidium@openttd.org>
parents: 11702
diff changeset
547 case VEH_AIRCRAFT: command = CMD_START_STOP_VEHICLE | CMD_MSG(STR_ERROR_CAN_T_STOP_START_AIRCRAFT); break;
12027
54dbb2d04329 (svn r16434) -Cleanup: remove some dead code; primarily stuff that can't be reached like break after returns or break after functions that never return (i.e. NOT_REACHED)
rubidium <rubidium@openttd.org>
parents: 12015
diff changeset
548 default: NOT_REACHED();
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
549 }
10499
45ca88a8de7d (svn r14754) -Codechange: get rid of _cmd_text and just pass it as (optional) parameter.
rubidium <rubidium@openttd.org>
parents: 10208
diff changeset
550 DoCommandP(v->tile, v->index, 0, command);
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
551 } break;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
552
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
553 default: NOT_REACHED();
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
554 }
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
555 }
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
556
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
557 /**
11361
02313cc6114e (svn r15711) -Codechange: lots of whitespace cleanup/fixes
rubidium <rubidium@openttd.org>
parents: 11084
diff changeset
558 * Clones a vehicle
02313cc6114e (svn r15711) -Codechange: lots of whitespace cleanup/fixes
rubidium <rubidium@openttd.org>
parents: 11084
diff changeset
559 * @param *v is the original vehicle to clone
02313cc6114e (svn r15711) -Codechange: lots of whitespace cleanup/fixes
rubidium <rubidium@openttd.org>
parents: 11084
diff changeset
560 */
12390
cca34a3de96e (svn r16820) -Codechange: remove unused parameter in HandleCloneVehClick()
smatz <smatz@openttd.org>
parents: 12387
diff changeset
561 void HandleCloneVehClick(const Vehicle *v)
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
562 {
12483
84df0c285bc4 (svn r16920) -Codechange: shuffle some strings around to simplify looking up vehicle type specific strings for a specific message
rubidium <rubidium@openttd.org>
parents: 12482
diff changeset
563 if (v == NULL || !IsCompanyBuildableVehicleType(v)) return;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
564
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
565 if (!v->IsPrimaryVehicle()) {
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
566 v = v->First();
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
567 /* Do nothing when clicking on a train in depot with no loc attached */
12300
7ec79afe8c18 (svn r16717) -Codechange: make IsFrontEngine() member of Train
smatz <smatz@openttd.org>
parents: 12263
diff changeset
568 if (v->type == VEH_TRAIN && !Train::From(v)->IsFrontEngine()) return;
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
569 }
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
570
12953
045a6264ea5b (svn r17446) -Codechange: rename BUILD with BUY for strings that are about building (in the future buying) vehicles.
rubidium <rubidium@openttd.org>
parents: 12877
diff changeset
571 DoCommandP(this->window_number, v->index, _ctrl_pressed ? 1 : 0, CMD_CLONE_VEHICLE | CMD_MSG(STR_ERROR_CAN_T_BUY_TRAIN + v->type), CcCloneVehicle);
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
572
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
573 ResetObjectToPlace();
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
574 }
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
575
12876
6f97f7fe9a93 (svn r17368) -Codechange: remove pointless passing of 'this' as parameter
rubidium <rubidium@openttd.org>
parents: 12778
diff changeset
576 void ResizeDepotButtons()
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
577 {
12876
6f97f7fe9a93 (svn r17368) -Codechange: remove pointless passing of 'this' as parameter
rubidium <rubidium@openttd.org>
parents: 12778
diff changeset
578 ResizeButtons(this, DEPOT_WIDGET_BUILD, DEPOT_WIDGET_LOCATION);
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
579
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
580 if (this->type == VEH_TRAIN) {
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
581 /* 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.
11361
02313cc6114e (svn r15711) -Codechange: lots of whitespace cleanup/fixes
rubidium <rubidium@openttd.org>
parents: 11084
diff changeset
582 * This way it will stay the same even if DEPOT_WIDGET_SELL_CHAIN is resized for some reason */
12483
84df0c285bc4 (svn r16920) -Codechange: shuffle some strings around to simplify looking up vehicle type specific strings for a specific message
rubidium <rubidium@openttd.org>
parents: 12482
diff changeset
583 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;
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
584 this->widget[DEPOT_WIDGET_SELL].bottom = this->widget[DEPOT_WIDGET_SELL_CHAIN].top - 1;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
585 }
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
586 }
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
587
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
588 /* Function to set up vehicle specific sprites and strings
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
589 * Only use this if it's the same widget, that's used for more than one vehicle type and it needs different text/sprites
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
590 * 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
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
591 */
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
592 void SetupStringsForDepotWindow(VehicleType type)
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
593 {
12483
84df0c285bc4 (svn r16920) -Codechange: shuffle some strings around to simplify looking up vehicle type specific strings for a specific message
rubidium <rubidium@openttd.org>
parents: 12482
diff changeset
594 this->widget[DEPOT_WIDGET_CAPTION].data = STR_DEPOT_TRAIN_CAPTION + type;
12632
e41943276802 (svn r17075) -Codechange: rename ~750 strings to be more uniform with their relatives
rubidium <rubidium@openttd.org>
parents: 12485
diff changeset
595 this->widget[DEPOT_WIDGET_STOP_ALL].tooltips = STR_DEPOT_MASS_STOP_DEPOT_TRAIN_TOOLTIP + type;
e41943276802 (svn r17075) -Codechange: rename ~750 strings to be more uniform with their relatives
rubidium <rubidium@openttd.org>
parents: 12485
diff changeset
596 this->widget[DEPOT_WIDGET_START_ALL].tooltips = STR_DEPOT_MASS_START_DEPOT_TRAIN_TOOLTIP + type;
12483
84df0c285bc4 (svn r16920) -Codechange: shuffle some strings around to simplify looking up vehicle type specific strings for a specific message
rubidium <rubidium@openttd.org>
parents: 12482
diff changeset
597 this->widget[DEPOT_WIDGET_SELL].tooltips = STR_DEPOT_TRAIN_SELL_TOOLTIP + type;
12632
e41943276802 (svn r17075) -Codechange: rename ~750 strings to be more uniform with their relatives
rubidium <rubidium@openttd.org>
parents: 12485
diff changeset
598 this->widget[DEPOT_WIDGET_SELL_ALL].tooltips = STR_DEPOT_SELL_ALL_BUTTON_TRAIN_TOOLTIP + type;
12483
84df0c285bc4 (svn r16920) -Codechange: shuffle some strings around to simplify looking up vehicle type specific strings for a specific message
rubidium <rubidium@openttd.org>
parents: 12482
diff changeset
599
84df0c285bc4 (svn r16920) -Codechange: shuffle some strings around to simplify looking up vehicle type specific strings for a specific message
rubidium <rubidium@openttd.org>
parents: 12482
diff changeset
600 this->widget[DEPOT_WIDGET_BUILD].data = STR_DEPOT_TRAIN_NEW_VEHICLES_BUTTON + type;
84df0c285bc4 (svn r16920) -Codechange: shuffle some strings around to simplify looking up vehicle type specific strings for a specific message
rubidium <rubidium@openttd.org>
parents: 12482
diff changeset
601 this->widget[DEPOT_WIDGET_BUILD].tooltips = STR_DEPOT_TRAIN_NEW_VEHICLES_TOOLTIP + type;
12632
e41943276802 (svn r17075) -Codechange: rename ~750 strings to be more uniform with their relatives
rubidium <rubidium@openttd.org>
parents: 12485
diff changeset
602 this->widget[DEPOT_WIDGET_CLONE].data = STR_DEPOT_CLONE_TRAIN + type;
e41943276802 (svn r17075) -Codechange: rename ~750 strings to be more uniform with their relatives
rubidium <rubidium@openttd.org>
parents: 12485
diff changeset
603 this->widget[DEPOT_WIDGET_CLONE].tooltips = STR_DEPOT_CLONE_TRAIN_DEPOT_INFO + type;
12483
84df0c285bc4 (svn r16920) -Codechange: shuffle some strings around to simplify looking up vehicle type specific strings for a specific message
rubidium <rubidium@openttd.org>
parents: 12482
diff changeset
604
84df0c285bc4 (svn r16920) -Codechange: shuffle some strings around to simplify looking up vehicle type specific strings for a specific message
rubidium <rubidium@openttd.org>
parents: 12482
diff changeset
605 this->widget[DEPOT_WIDGET_LOCATION].tooltips = STR_DEPOT_TRAIN_LOCATION_TOOLTIP + type;
12632
e41943276802 (svn r17075) -Codechange: rename ~750 strings to be more uniform with their relatives
rubidium <rubidium@openttd.org>
parents: 12485
diff changeset
606 this->widget[DEPOT_WIDGET_VEHICLE_LIST].tooltips = STR_DEPOT_VEHICLE_ORDER_LIST_TRAIN_TOOLTIP + type;
e41943276802 (svn r17075) -Codechange: rename ~750 strings to be more uniform with their relatives
rubidium <rubidium@openttd.org>
parents: 12485
diff changeset
607 this->widget[DEPOT_WIDGET_AUTOREPLACE].tooltips = STR_DEPOT_AUTOREPLACE_TRAIN_TOOLTIP + type;
12483
84df0c285bc4 (svn r16920) -Codechange: shuffle some strings around to simplify looking up vehicle type specific strings for a specific message
rubidium <rubidium@openttd.org>
parents: 12482
diff changeset
608
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
609 switch (type) {
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
610 default: NOT_REACHED();
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
611
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
612 case VEH_TRAIN:
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
613 this->widget[DEPOT_WIDGET_VEHICLE_LIST].data = STR_TRAIN;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
614
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
615 /* Sprites */
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
616 this->widget[DEPOT_WIDGET_SELL].data = SPR_SELL_TRAIN;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
617 this->widget[DEPOT_WIDGET_SELL_ALL].data = SPR_SELL_ALL_TRAIN;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
618 this->widget[DEPOT_WIDGET_AUTOREPLACE].data = SPR_REPLACE_TRAIN;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
619 break;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
620
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
621 case VEH_ROAD:
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
622 this->widget[DEPOT_WIDGET_VEHICLE_LIST].data = STR_LORRY;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
623
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
624 /* Sprites */
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
625 this->widget[DEPOT_WIDGET_SELL].data = SPR_SELL_ROADVEH;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
626 this->widget[DEPOT_WIDGET_SELL_ALL].data = SPR_SELL_ALL_ROADVEH;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
627 this->widget[DEPOT_WIDGET_AUTOREPLACE].data = SPR_REPLACE_ROADVEH;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
628 break;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
629
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
630 case VEH_SHIP:
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
631 this->widget[DEPOT_WIDGET_VEHICLE_LIST].data = STR_SHIP;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
632
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
633 /* Sprites */
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
634 this->widget[DEPOT_WIDGET_SELL].data = SPR_SELL_SHIP;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
635 this->widget[DEPOT_WIDGET_SELL_ALL].data = SPR_SELL_ALL_SHIP;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
636 this->widget[DEPOT_WIDGET_AUTOREPLACE].data = SPR_REPLACE_SHIP;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
637 break;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
638
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
639 case VEH_AIRCRAFT:
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
640 this->widget[DEPOT_WIDGET_VEHICLE_LIST].data = STR_PLANE;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
641
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
642 /* Sprites */
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
643 this->widget[DEPOT_WIDGET_SELL].data = SPR_SELL_AIRCRAFT;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
644 this->widget[DEPOT_WIDGET_SELL_ALL].data = SPR_SELL_ALL_AIRCRAFT;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
645 this->widget[DEPOT_WIDGET_AUTOREPLACE].data = SPR_REPLACE_AIRCRAFT;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
646 break;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
647 }
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
648 }
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
649
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
650 void CreateDepotListWindow(VehicleType type)
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
651 {
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
652 this->type = type;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
653 _backup_orders_tile = 0;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
654
10207
c54d140df948 (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents: 10056
diff changeset
655 assert(IsCompanyBuildableVehicleType(type)); // ensure that we make the call with a valid type
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
656
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
657 /* Resize the window according to the vehicle type */
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
658
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
659 /* Set the number of blocks in each direction */
12877
e63af9c28034 (svn r17369) -Codechange: make the depot, group and industry GUIs use the scrollbar wrappers
rubidium <rubidium@openttd.org>
parents: 12876
diff changeset
660 this->vscroll.SetCapacity(_resize_cap[type][0]);
e63af9c28034 (svn r17369) -Codechange: make the depot, group and industry GUIs use the scrollbar wrappers
rubidium <rubidium@openttd.org>
parents: 12876
diff changeset
661 this->hscroll.SetCapacity(_resize_cap[type][1]);
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
662
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
663 /* Set the block size */
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
664 this->resize.step_width = _block_sizes[type][0];
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
665 this->resize.step_height = _block_sizes[type][1];
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
666
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
667 /* Enlarge the window to fit with the selected number of blocks of the selected size */
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
668 ResizeWindow(this,
12877
e63af9c28034 (svn r17369) -Codechange: make the depot, group and industry GUIs use the scrollbar wrappers
rubidium <rubidium@openttd.org>
parents: 12876
diff changeset
669 _block_sizes[type][0] * this->hscroll.GetCapacity(),
e63af9c28034 (svn r17369) -Codechange: make the depot, group and industry GUIs use the scrollbar wrappers
rubidium <rubidium@openttd.org>
parents: 12876
diff changeset
670 _block_sizes[type][1] * this->vscroll.GetCapacity());
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
671
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
672 if (type == VEH_TRAIN) {
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
673 /* Make space for the horizontal scrollbar vertically, and the unit
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
674 * number, flag, and length counter horizontally. */
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
675 ResizeWindow(this, 36, 12);
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
676 /* substract the newly added space from the matrix since it was meant for the scrollbar */
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
677 this->widget[DEPOT_WIDGET_MATRIX].bottom -= 12;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
678 }
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
679
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
680 /* Set the minimum window size to the current window size */
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
681 this->resize.width = this->width;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
682 this->resize.height = this->height;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
683
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
684 this->SetupStringsForDepotWindow(type);
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
685
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
686 this->widget[DEPOT_WIDGET_MATRIX].data =
12877
e63af9c28034 (svn r17369) -Codechange: make the depot, group and industry GUIs use the scrollbar wrappers
rubidium <rubidium@openttd.org>
parents: 12876
diff changeset
687 (this->vscroll.GetCapacity() << MAT_ROW_START) // number of rows to draw on the background
e63af9c28034 (svn r17369) -Codechange: make the depot, group and industry GUIs use the scrollbar wrappers
rubidium <rubidium@openttd.org>
parents: 12876
diff changeset
688 + ((type == VEH_TRAIN ? 1 : this->hscroll.GetCapacity()) << MAT_COL_START); // number of boxes in each row. Trains always have just one
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
689
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
690
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
691 this->SetWidgetsHiddenState(type != VEH_TRAIN,
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
692 DEPOT_WIDGET_H_SCROLL,
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
693 DEPOT_WIDGET_SELL_CHAIN,
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
694 WIDGET_LIST_END);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
695
12876
6f97f7fe9a93 (svn r17368) -Codechange: remove pointless passing of 'this' as parameter
rubidium <rubidium@openttd.org>
parents: 12778
diff changeset
696 this->ResizeDepotButtons();
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
697 }
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
698
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
699 virtual void OnInvalidateData(int data)
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
700 {
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
701 this->generate_list = true;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
702 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
703
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
704 virtual void OnPaint()
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
705 {
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
706 if (this->generate_list) {
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
707 /* Generate the vehicle list
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
708 * It's ok to use the wagon pointers for non-trains as they will be ignored */
9351
feaf9bae7580 (svn r13248) -Codechange: Use VehicleList for depot GUI.
peter1138 <peter1138@openttd.org>
parents: 9344
diff changeset
709 BuildDepotVehicleList(this->type, this->window_number, &this->vehicle_list, &this->wagon_list);
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
710 this->generate_list = false;
9351
feaf9bae7580 (svn r13248) -Codechange: Use VehicleList for depot GUI.
peter1138 <peter1138@openttd.org>
parents: 9344
diff changeset
711 DepotSortList(&this->vehicle_list);
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
712 }
12876
6f97f7fe9a93 (svn r17368) -Codechange: remove pointless passing of 'this' as parameter
rubidium <rubidium@openttd.org>
parents: 12778
diff changeset
713 this->DrawDepotWindow();
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
714 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
715
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
716 virtual void OnClick(Point pt, int widget)
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
717 {
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
718 switch (widget) {
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
719 case DEPOT_WIDGET_MATRIX: // List
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
720 this->DepotClick(pt.x, pt.y);
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
721 break;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
722
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
723 case DEPOT_WIDGET_BUILD: // Build vehicle
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
724 ResetObjectToPlace();
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
725 ShowBuildVehicleWindow(this->window_number, this->type);
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
726 break;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
727
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
728 case DEPOT_WIDGET_CLONE: // Clone button
13034
6eb3f749890a (svn r17532) -Codechange: Rename several Invalidate functions to SetDirty for more consistency and distinguishability.
frosch <frosch@openttd.org>
parents: 12953
diff changeset
729 this->SetWidgetDirty(DEPOT_WIDGET_CLONE);
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
730 this->ToggleWidgetLoweredState(DEPOT_WIDGET_CLONE);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
731
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
732 if (this->IsWidgetLowered(DEPOT_WIDGET_CLONE)) {
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
733 static const CursorID clone_icons[] = {
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
734 SPR_CURSOR_CLONE_TRAIN, SPR_CURSOR_CLONE_ROADVEH,
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
735 SPR_CURSOR_CLONE_SHIP, SPR_CURSOR_CLONE_AIRPLANE
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
736 };
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
737
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
738 _place_clicked_vehicle = NULL;
11702
cdaad565efe5 (svn r16088) -Codechange: merge HighLightStyle and ViewportHighlightMode as they are basically the same thing
rubidium <rubidium@openttd.org>
parents: 11524
diff changeset
739 SetObjectToPlaceWnd(clone_icons[this->type], PAL_NONE, HT_RECT, this);
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
740 } else {
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
741 ResetObjectToPlace();
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
742 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
743 break;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
744
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
745 case DEPOT_WIDGET_LOCATION:
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
746 if (_ctrl_pressed) {
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
747 ShowExtraViewPortWindow(this->window_number);
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
748 } else {
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
749 ScrollMainWindowToTile(this->window_number);
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
750 }
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
751 break;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
752
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
753 case DEPOT_WIDGET_STOP_ALL:
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
754 case DEPOT_WIDGET_START_ALL:
10499
45ca88a8de7d (svn r14754) -Codechange: get rid of _cmd_text and just pass it as (optional) parameter.
rubidium <rubidium@openttd.org>
parents: 10208
diff changeset
755 DoCommandP(this->window_number, 0, this->type | (widget == DEPOT_WIDGET_START_ALL ? (1 << 5) : 0), CMD_MASS_START_STOP);
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
756 break;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
757
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
758 case DEPOT_WIDGET_SELL_ALL:
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
759 /* Only open the confimation window if there are anything to sell */
9351
feaf9bae7580 (svn r13248) -Codechange: Use VehicleList for depot GUI.
peter1138 <peter1138@openttd.org>
parents: 9344
diff changeset
760 if (this->vehicle_list.Length() != 0 || this->wagon_list.Length() != 0) {
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
761 TileIndex tile = this->window_number;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
762 byte vehtype = this->type;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
763
12231
2f16fe37d1b8 (svn r16646) -Codechange: rename GetDepotByTile() to Depot::GetByTile()
smatz <smatz@openttd.org>
parents: 12114
diff changeset
764 SetDParam(0, (vehtype == VEH_AIRCRAFT) ? GetStationIndex(tile) : Depot::GetByTile(tile)->town_index);
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
765 ShowQuery(
12483
84df0c285bc4 (svn r16920) -Codechange: shuffle some strings around to simplify looking up vehicle type specific strings for a specific message
rubidium <rubidium@openttd.org>
parents: 12482
diff changeset
766 STR_DEPOT_TRAIN_CAPTION + vehtype,
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
767 STR_DEPOT_SELL_CONFIRMATION_TEXT,
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
768 this,
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
769 DepotSellAllConfirmationCallback
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
770 );
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
771 }
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
772 break;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
773
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
774 case DEPOT_WIDGET_VEHICLE_LIST:
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
775 ShowVehicleListWindow(GetTileOwner(this->window_number), this->type, (TileIndex)this->window_number);
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
776 break;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
777
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
778 case DEPOT_WIDGET_AUTOREPLACE:
10499
45ca88a8de7d (svn r14754) -Codechange: get rid of _cmd_text and just pass it as (optional) parameter.
rubidium <rubidium@openttd.org>
parents: 10208
diff changeset
779 DoCommandP(this->window_number, this->type, 0, CMD_DEPOT_MASS_AUTOREPLACE);
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
780 break;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
781
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
782 }
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
783 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
784
9782
93d9386b56ac (svn r13923) -Feature: Show [total-]cargo info in depot when [ctrl-]right-clicking on vehicle.
frosch <frosch@openttd.org>
parents: 9751
diff changeset
785 virtual void OnRightClick(Point pt, int widget)
93d9386b56ac (svn r13923) -Feature: Show [total-]cargo info in depot when [ctrl-]right-clicking on vehicle.
frosch <frosch@openttd.org>
parents: 9751
diff changeset
786 {
93d9386b56ac (svn r13923) -Feature: Show [total-]cargo info in depot when [ctrl-]right-clicking on vehicle.
frosch <frosch@openttd.org>
parents: 9751
diff changeset
787 if (widget != DEPOT_WIDGET_MATRIX) return;
93d9386b56ac (svn r13923) -Feature: Show [total-]cargo info in depot when [ctrl-]right-clicking on vehicle.
frosch <frosch@openttd.org>
parents: 9751
diff changeset
788
93d9386b56ac (svn r13923) -Feature: Show [total-]cargo info in depot when [ctrl-]right-clicking on vehicle.
frosch <frosch@openttd.org>
parents: 9751
diff changeset
789 GetDepotVehiclePtData gdvp = { NULL, NULL };
93d9386b56ac (svn r13923) -Feature: Show [total-]cargo info in depot when [ctrl-]right-clicking on vehicle.
frosch <frosch@openttd.org>
parents: 9751
diff changeset
790 const Vehicle *v = NULL;
93d9386b56ac (svn r13923) -Feature: Show [total-]cargo info in depot when [ctrl-]right-clicking on vehicle.
frosch <frosch@openttd.org>
parents: 9751
diff changeset
791 DepotGUIAction mode = this->GetVehicleFromDepotWndPt(pt.x, pt.y, &v, &gdvp);
93d9386b56ac (svn r13923) -Feature: Show [total-]cargo info in depot when [ctrl-]right-clicking on vehicle.
frosch <frosch@openttd.org>
parents: 9751
diff changeset
792
93d9386b56ac (svn r13923) -Feature: Show [total-]cargo info in depot when [ctrl-]right-clicking on vehicle.
frosch <frosch@openttd.org>
parents: 9751
diff changeset
793 if (this->type == VEH_TRAIN) v = gdvp.wagon;
93d9386b56ac (svn r13923) -Feature: Show [total-]cargo info in depot when [ctrl-]right-clicking on vehicle.
frosch <frosch@openttd.org>
parents: 9751
diff changeset
794
93d9386b56ac (svn r13923) -Feature: Show [total-]cargo info in depot when [ctrl-]right-clicking on vehicle.
frosch <frosch@openttd.org>
parents: 9751
diff changeset
795 if (v != NULL && mode == MODE_DRAG_VEHICLE) {
12261
c42d8d239142 (svn r16676) -Codechange: Rename AcceptedCargo to CargoArray and its instances to more meaningful names.
frosch <frosch@openttd.org>
parents: 12231
diff changeset
796 CargoArray capacity, loaded;
9782
93d9386b56ac (svn r13923) -Feature: Show [total-]cargo info in depot when [ctrl-]right-clicking on vehicle.
frosch <frosch@openttd.org>
parents: 9751
diff changeset
797
93d9386b56ac (svn r13923) -Feature: Show [total-]cargo info in depot when [ctrl-]right-clicking on vehicle.
frosch <frosch@openttd.org>
parents: 9751
diff changeset
798 /* Display info for single (articulated) vehicle, or for whole chain starting with selected vehicle */
93d9386b56ac (svn r13923) -Feature: Show [total-]cargo info in depot when [ctrl-]right-clicking on vehicle.
frosch <frosch@openttd.org>
parents: 9751
diff changeset
799 bool whole_chain = (this->type == VEH_TRAIN && _ctrl_pressed);
93d9386b56ac (svn r13923) -Feature: Show [total-]cargo info in depot when [ctrl-]right-clicking on vehicle.
frosch <frosch@openttd.org>
parents: 9751
diff changeset
800
93d9386b56ac (svn r13923) -Feature: Show [total-]cargo info in depot when [ctrl-]right-clicking on vehicle.
frosch <frosch@openttd.org>
parents: 9751
diff changeset
801 /* loop through vehicle chain and collect cargos */
93d9386b56ac (svn r13923) -Feature: Show [total-]cargo info in depot when [ctrl-]right-clicking on vehicle.
frosch <frosch@openttd.org>
parents: 9751
diff changeset
802 uint num = 0;
93d9386b56ac (svn r13923) -Feature: Show [total-]cargo info in depot when [ctrl-]right-clicking on vehicle.
frosch <frosch@openttd.org>
parents: 9751
diff changeset
803 for (const Vehicle *w = v; w != NULL; w = w->Next()) {
93d9386b56ac (svn r13923) -Feature: Show [total-]cargo info in depot when [ctrl-]right-clicking on vehicle.
frosch <frosch@openttd.org>
parents: 9751
diff changeset
804 if (w->cargo_cap > 0 && w->cargo_type < NUM_CARGO) {
93d9386b56ac (svn r13923) -Feature: Show [total-]cargo info in depot when [ctrl-]right-clicking on vehicle.
frosch <frosch@openttd.org>
parents: 9751
diff changeset
805 capacity[w->cargo_type] += w->cargo_cap;
93d9386b56ac (svn r13923) -Feature: Show [total-]cargo info in depot when [ctrl-]right-clicking on vehicle.
frosch <frosch@openttd.org>
parents: 9751
diff changeset
806 loaded [w->cargo_type] += w->cargo.Count();
93d9386b56ac (svn r13923) -Feature: Show [total-]cargo info in depot when [ctrl-]right-clicking on vehicle.
frosch <frosch@openttd.org>
parents: 9751
diff changeset
807 }
93d9386b56ac (svn r13923) -Feature: Show [total-]cargo info in depot when [ctrl-]right-clicking on vehicle.
frosch <frosch@openttd.org>
parents: 9751
diff changeset
808
12305
217431f4bc67 (svn r16722) -Codechange: unify the naming of the Is/Set/HasArticulatedPart functions
rubidium <rubidium@openttd.org>
parents: 12302
diff changeset
809 if (w->type == VEH_TRAIN && !Train::From(w)->HasArticulatedPart()) {
9782
93d9386b56ac (svn r13923) -Feature: Show [total-]cargo info in depot when [ctrl-]right-clicking on vehicle.
frosch <frosch@openttd.org>
parents: 9751
diff changeset
810 num++;
93d9386b56ac (svn r13923) -Feature: Show [total-]cargo info in depot when [ctrl-]right-clicking on vehicle.
frosch <frosch@openttd.org>
parents: 9751
diff changeset
811 if (!whole_chain) break;
93d9386b56ac (svn r13923) -Feature: Show [total-]cargo info in depot when [ctrl-]right-clicking on vehicle.
frosch <frosch@openttd.org>
parents: 9751
diff changeset
812 }
93d9386b56ac (svn r13923) -Feature: Show [total-]cargo info in depot when [ctrl-]right-clicking on vehicle.
frosch <frosch@openttd.org>
parents: 9751
diff changeset
813 }
93d9386b56ac (svn r13923) -Feature: Show [total-]cargo info in depot when [ctrl-]right-clicking on vehicle.
frosch <frosch@openttd.org>
parents: 9751
diff changeset
814
93d9386b56ac (svn r13923) -Feature: Show [total-]cargo info in depot when [ctrl-]right-clicking on vehicle.
frosch <frosch@openttd.org>
parents: 9751
diff changeset
815 /* Build tooltipstring */
93d9386b56ac (svn r13923) -Feature: Show [total-]cargo info in depot when [ctrl-]right-clicking on vehicle.
frosch <frosch@openttd.org>
parents: 9751
diff changeset
816 static char details[1024];
93d9386b56ac (svn r13923) -Feature: Show [total-]cargo info in depot when [ctrl-]right-clicking on vehicle.
frosch <frosch@openttd.org>
parents: 9751
diff changeset
817 details[0] = '\0';
93d9386b56ac (svn r13923) -Feature: Show [total-]cargo info in depot when [ctrl-]right-clicking on vehicle.
frosch <frosch@openttd.org>
parents: 9751
diff changeset
818 char *pos = details;
93d9386b56ac (svn r13923) -Feature: Show [total-]cargo info in depot when [ctrl-]right-clicking on vehicle.
frosch <frosch@openttd.org>
parents: 9751
diff changeset
819
93d9386b56ac (svn r13923) -Feature: Show [total-]cargo info in depot when [ctrl-]right-clicking on vehicle.
frosch <frosch@openttd.org>
parents: 9751
diff changeset
820 for (CargoID cargo_type = 0; cargo_type < NUM_CARGO; cargo_type++) {
93d9386b56ac (svn r13923) -Feature: Show [total-]cargo info in depot when [ctrl-]right-clicking on vehicle.
frosch <frosch@openttd.org>
parents: 9751
diff changeset
821 if (capacity[cargo_type] == 0) continue;
93d9386b56ac (svn r13923) -Feature: Show [total-]cargo info in depot when [ctrl-]right-clicking on vehicle.
frosch <frosch@openttd.org>
parents: 9751
diff changeset
822
93d9386b56ac (svn r13923) -Feature: Show [total-]cargo info in depot when [ctrl-]right-clicking on vehicle.
frosch <frosch@openttd.org>
parents: 9751
diff changeset
823 SetDParam(0, cargo_type); // {CARGO} #1
93d9386b56ac (svn r13923) -Feature: Show [total-]cargo info in depot when [ctrl-]right-clicking on vehicle.
frosch <frosch@openttd.org>
parents: 9751
diff changeset
824 SetDParam(1, loaded[cargo_type]); // {CARGO} #2
93d9386b56ac (svn r13923) -Feature: Show [total-]cargo info in depot when [ctrl-]right-clicking on vehicle.
frosch <frosch@openttd.org>
parents: 9751
diff changeset
825 SetDParam(2, cargo_type); // {SHORTCARGO} #1
93d9386b56ac (svn r13923) -Feature: Show [total-]cargo info in depot when [ctrl-]right-clicking on vehicle.
frosch <frosch@openttd.org>
parents: 9751
diff changeset
826 SetDParam(3, capacity[cargo_type]); // {SHORTCARGO} #2
93d9386b56ac (svn r13923) -Feature: Show [total-]cargo info in depot when [ctrl-]right-clicking on vehicle.
frosch <frosch@openttd.org>
parents: 9751
diff changeset
827 pos = GetString(pos, STR_DEPOT_VEHICLE_TOOLTIP_CARGO, lastof(details));
93d9386b56ac (svn r13923) -Feature: Show [total-]cargo info in depot when [ctrl-]right-clicking on vehicle.
frosch <frosch@openttd.org>
parents: 9751
diff changeset
828 }
93d9386b56ac (svn r13923) -Feature: Show [total-]cargo info in depot when [ctrl-]right-clicking on vehicle.
frosch <frosch@openttd.org>
parents: 9751
diff changeset
829
93d9386b56ac (svn r13923) -Feature: Show [total-]cargo info in depot when [ctrl-]right-clicking on vehicle.
frosch <frosch@openttd.org>
parents: 9751
diff changeset
830 /* Show tooltip window */
93d9386b56ac (svn r13923) -Feature: Show [total-]cargo info in depot when [ctrl-]right-clicking on vehicle.
frosch <frosch@openttd.org>
parents: 9751
diff changeset
831 uint64 args[2];
93d9386b56ac (svn r13923) -Feature: Show [total-]cargo info in depot when [ctrl-]right-clicking on vehicle.
frosch <frosch@openttd.org>
parents: 9751
diff changeset
832 args[0] = (whole_chain ? num : v->engine_type);
9826
480b465fb25f (svn r13968) -Fix (r13923): 'cast from pointer to integer of different size' warning
glx <glx@openttd.org>
parents: 9782
diff changeset
833 args[1] = (uint64)(size_t)details;
9782
93d9386b56ac (svn r13923) -Feature: Show [total-]cargo info in depot when [ctrl-]right-clicking on vehicle.
frosch <frosch@openttd.org>
parents: 9751
diff changeset
834 GuiShowTooltips(whole_chain ? STR_DEPOT_VEHICLE_TOOLTIP_CHAIN : STR_DEPOT_VEHICLE_TOOLTIP, 2, args);
93d9386b56ac (svn r13923) -Feature: Show [total-]cargo info in depot when [ctrl-]right-clicking on vehicle.
frosch <frosch@openttd.org>
parents: 9751
diff changeset
835 } else {
93d9386b56ac (svn r13923) -Feature: Show [total-]cargo info in depot when [ctrl-]right-clicking on vehicle.
frosch <frosch@openttd.org>
parents: 9751
diff changeset
836 /* Show tooltip help */
12483
84df0c285bc4 (svn r16920) -Codechange: shuffle some strings around to simplify looking up vehicle type specific strings for a specific message
rubidium <rubidium@openttd.org>
parents: 12482
diff changeset
837 GuiShowTooltips(STR_DEPOT_TRAIN_LIST_TOOLTIP + this->type);
9782
93d9386b56ac (svn r13923) -Feature: Show [total-]cargo info in depot when [ctrl-]right-clicking on vehicle.
frosch <frosch@openttd.org>
parents: 9751
diff changeset
838 }
93d9386b56ac (svn r13923) -Feature: Show [total-]cargo info in depot when [ctrl-]right-clicking on vehicle.
frosch <frosch@openttd.org>
parents: 9751
diff changeset
839 }
93d9386b56ac (svn r13923) -Feature: Show [total-]cargo info in depot when [ctrl-]right-clicking on vehicle.
frosch <frosch@openttd.org>
parents: 9751
diff changeset
840
93d9386b56ac (svn r13923) -Feature: Show [total-]cargo info in depot when [ctrl-]right-clicking on vehicle.
frosch <frosch@openttd.org>
parents: 9751
diff changeset
841
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
842 virtual void OnPlaceObject(Point pt, TileIndex tile)
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
843 {
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
844 const Vehicle *v = CheckMouseOverVehicle();
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
845
12390
cca34a3de96e (svn r16820) -Codechange: remove unused parameter in HandleCloneVehClick()
smatz <smatz@openttd.org>
parents: 12387
diff changeset
846 if (v != NULL) this->HandleCloneVehClick(v);
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
847 }
8585
2880bcf43f14 (svn r12166) -Fix [FS#337]: when drag&drop mode was cancelled by keyboard input, depot/group window wasn't updated (original patch by GrimRC)
smatz <smatz@openttd.org>
parents: 8479
diff changeset
848
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
849 virtual void OnPlaceObjectAbort()
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
850 {
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
851 /* abort clone */
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
852 this->RaiseWidget(DEPOT_WIDGET_CLONE);
13034
6eb3f749890a (svn r17532) -Codechange: Rename several Invalidate functions to SetDirty for more consistency and distinguishability.
frosch <frosch@openttd.org>
parents: 12953
diff changeset
853 this->SetWidgetDirty(DEPOT_WIDGET_CLONE);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
854
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
855 /* abort drag & drop */
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
856 this->sel = INVALID_VEHICLE;
13034
6eb3f749890a (svn r17532) -Codechange: Rename several Invalidate functions to SetDirty for more consistency and distinguishability.
frosch <frosch@openttd.org>
parents: 12953
diff changeset
857 this->SetWidgetDirty(DEPOT_WIDGET_MATRIX);
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
858 };
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
859
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
860 /* check if a vehicle in a depot was clicked.. */
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
861 virtual void OnMouseLoop()
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
862 {
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
863 const Vehicle *v = _place_clicked_vehicle;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
864
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
865 /* since OTTD checks all open depot windows, we will make sure that it triggers the one with a clicked clone button */
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
866 if (v != NULL && this->IsWidgetLowered(DEPOT_WIDGET_CLONE)) {
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
867 _place_clicked_vehicle = NULL;
12390
cca34a3de96e (svn r16820) -Codechange: remove unused parameter in HandleCloneVehClick()
smatz <smatz@openttd.org>
parents: 12387
diff changeset
868 this->HandleCloneVehClick(v);
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
869 }
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
870 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
871
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
872 virtual void OnDragDrop(Point pt, int widget)
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
873 {
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
874 switch (widget) {
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
875 case DEPOT_WIDGET_MATRIX: {
9344
5940dd28c40d (svn r13240) -Codechange: More const-ness for GUI code.
peter1138 <peter1138@openttd.org>
parents: 9343
diff changeset
876 const Vehicle *v = NULL;
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
877 VehicleID sel = this->sel;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
878
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
879 this->sel = INVALID_VEHICLE;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
880 this->SetDirty();
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
881
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
882 if (this->type == VEH_TRAIN) {
9225
1e40b8e2533d (svn r13091) -Fix: certain compilers give false warning about uninitialized variable
smatz <smatz@openttd.org>
parents: 9213
diff changeset
883 GetDepotVehiclePtData gdvp = { NULL, NULL };
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
884
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
885 if (this->GetVehicleFromDepotWndPt(pt.x, pt.y, &v, &gdvp) == MODE_DRAG_VEHICLE &&
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
886 sel != INVALID_VEHICLE) {
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
887 if (gdvp.wagon != NULL && gdvp.wagon->index == sel && _ctrl_pressed) {
12351
65732f6bed3f (svn r16772) -Fix [FS#3019]: don't use the same error message for turning around road vehicles and flipping parts of trains in the depot
rubidium <rubidium@openttd.org>
parents: 12305
diff changeset
888 DoCommandP(Vehicle::Get(sel)->tile, Vehicle::Get(sel)->index, true, CMD_REVERSE_TRAIN_DIRECTION | CMD_MSG(STR_ERROR_CAN_T_REVERSE_DIRECTION_RAIL_VEHICLE));
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
889 } else if (gdvp.wagon == NULL || gdvp.wagon->index != sel) {
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
890 TrainDepotMoveVehicle(gdvp.wagon, sel, gdvp.head);
12300
7ec79afe8c18 (svn r16717) -Codechange: make IsFrontEngine() member of Train
smatz <smatz@openttd.org>
parents: 12263
diff changeset
891 } else if (gdvp.head != NULL && Train::From(gdvp.head)->IsFrontEngine()) {
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
892 ShowVehicleViewWindow(gdvp.head);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
893 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
894 }
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
895 } else if (this->GetVehicleFromDepotWndPt(pt.x, pt.y, &v, NULL) == MODE_DRAG_VEHICLE &&
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
896 v != NULL &&
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
897 sel == v->index) {
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
898 ShowVehicleViewWindow(v);
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
899 }
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
900 } break;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
901
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
902 case DEPOT_WIDGET_SELL: case DEPOT_WIDGET_SELL_CHAIN:
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
903 if (!this->IsWidgetDisabled(DEPOT_WIDGET_SELL) &&
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
904 this->sel != INVALID_VEHICLE) {
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
905
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
906 if (this->IsWidgetDisabled(widget)) return;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
907 if (this->sel == INVALID_VEHICLE) return;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
908
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
909 this->HandleButtonClick(widget);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
910
11922
0a4b63f3f3c3 (svn r16325) -Codechange: replace GetPoolItem(index) by PoolItem::Get(index)
smatz <smatz@openttd.org>
parents: 11896
diff changeset
911 const Vehicle *v = Vehicle::Get(this->sel);
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
912 this->sel = INVALID_VEHICLE;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
913 this->SetDirty();
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
914
9344
5940dd28c40d (svn r13240) -Codechange: More const-ness for GUI code.
peter1138 <peter1138@openttd.org>
parents: 9343
diff changeset
915 int sell_cmd = (v->type == VEH_TRAIN && (widget == DEPOT_WIDGET_SELL_CHAIN || _ctrl_pressed)) ? 1 : 0;
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
916
12300
7ec79afe8c18 (svn r16717) -Codechange: make IsFrontEngine() member of Train
smatz <smatz@openttd.org>
parents: 12263
diff changeset
917 bool is_engine = (v->type != VEH_TRAIN || Train::From(v)->IsFrontEngine());
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
918
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
919 if (is_engine) {
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
920 _backup_orders_tile = v->tile;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
921 BackupVehicleOrders(v);
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
922 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
923
12485
cf4a59021c9d (svn r16922) -Codechange: unduplicate some vehicle CMD_*s and move the setting of the error message to a single place
rubidium <rubidium@openttd.org>
parents: 12484
diff changeset
924 if (!DoCommandP(v->tile, v->index, sell_cmd, GetCmdSellVeh(v->type)) && is_engine) _backup_orders_tile = 0;
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
925 }
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
926 break;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
927 default:
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
928 this->sel = INVALID_VEHICLE;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
929 this->SetDirty();
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
930 }
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
931 _cursor.vehchain = false;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
932 }
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
933
12729
6a7a8e1b4bde (svn r17194) -Fix (r17175): Depot sell buttons did not raise again.
alberth <alberth@openttd.org>
parents: 12720
diff changeset
934 virtual void OnTimeout()
6a7a8e1b4bde (svn r17194) -Fix (r17175): Depot sell buttons did not raise again.
alberth <alberth@openttd.org>
parents: 12720
diff changeset
935 {
6a7a8e1b4bde (svn r17194) -Fix (r17175): Depot sell buttons did not raise again.
alberth <alberth@openttd.org>
parents: 12720
diff changeset
936 if (!this->IsWidgetDisabled(DEPOT_WIDGET_SELL)) {
6a7a8e1b4bde (svn r17194) -Fix (r17175): Depot sell buttons did not raise again.
alberth <alberth@openttd.org>
parents: 12720
diff changeset
937 this->RaiseWidget(DEPOT_WIDGET_SELL);
13034
6eb3f749890a (svn r17532) -Codechange: Rename several Invalidate functions to SetDirty for more consistency and distinguishability.
frosch <frosch@openttd.org>
parents: 12953
diff changeset
938 this->SetWidgetDirty(DEPOT_WIDGET_SELL);
12729
6a7a8e1b4bde (svn r17194) -Fix (r17175): Depot sell buttons did not raise again.
alberth <alberth@openttd.org>
parents: 12720
diff changeset
939 }
6a7a8e1b4bde (svn r17194) -Fix (r17175): Depot sell buttons did not raise again.
alberth <alberth@openttd.org>
parents: 12720
diff changeset
940 if (!this->IsWidgetDisabled(DEPOT_WIDGET_SELL_CHAIN)) {
6a7a8e1b4bde (svn r17194) -Fix (r17175): Depot sell buttons did not raise again.
alberth <alberth@openttd.org>
parents: 12720
diff changeset
941 this->RaiseWidget(DEPOT_WIDGET_SELL_CHAIN);
13034
6eb3f749890a (svn r17532) -Codechange: Rename several Invalidate functions to SetDirty for more consistency and distinguishability.
frosch <frosch@openttd.org>
parents: 12953
diff changeset
942 this->SetWidgetDirty(DEPOT_WIDGET_SELL_CHAIN);
12729
6a7a8e1b4bde (svn r17194) -Fix (r17175): Depot sell buttons did not raise again.
alberth <alberth@openttd.org>
parents: 12720
diff changeset
943 }
6a7a8e1b4bde (svn r17194) -Fix (r17175): Depot sell buttons did not raise again.
alberth <alberth@openttd.org>
parents: 12720
diff changeset
944 }
6a7a8e1b4bde (svn r17194) -Fix (r17175): Depot sell buttons did not raise again.
alberth <alberth@openttd.org>
parents: 12720
diff changeset
945
11524
420a4f0b4e0b (svn r15885) -Codechange: Removed new_size parameter of Window::OnResize() callback
alberth <alberth@openttd.org>
parents: 11450
diff changeset
946 virtual void OnResize(Point delta)
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
947 {
12877
e63af9c28034 (svn r17369) -Codechange: make the depot, group and industry GUIs use the scrollbar wrappers
rubidium <rubidium@openttd.org>
parents: 12876
diff changeset
948 this->vscroll.UpdateCapacity(delta.y / (int)this->resize.step_height);
e63af9c28034 (svn r17369) -Codechange: make the depot, group and industry GUIs use the scrollbar wrappers
rubidium <rubidium@openttd.org>
parents: 12876
diff changeset
949 this->hscroll.UpdateCapacity(delta.x / (int)this->resize.step_width);
e63af9c28034 (svn r17369) -Codechange: make the depot, group and industry GUIs use the scrollbar wrappers
rubidium <rubidium@openttd.org>
parents: 12876
diff changeset
950 this->widget[DEPOT_WIDGET_MATRIX].data = (this->vscroll.GetCapacity() << MAT_ROW_START) + ((this->type == VEH_TRAIN ? 1 : this->hscroll.GetCapacity()) << MAT_COL_START);
12876
6f97f7fe9a93 (svn r17368) -Codechange: remove pointless passing of 'this' as parameter
rubidium <rubidium@openttd.org>
parents: 12778
diff changeset
951 this->ResizeDepotButtons();
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
952 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
953
9285
3b3f13cb6db6 (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 <rubidium@openttd.org>
parents: 9274
diff changeset
954 virtual EventState OnCTRLStateChange()
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
955 {
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
956 if (this->sel != INVALID_VEHICLE) {
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
957 _cursor.vehchain = _ctrl_pressed;
13034
6eb3f749890a (svn r17532) -Codechange: Rename several Invalidate functions to SetDirty for more consistency and distinguishability.
frosch <frosch@openttd.org>
parents: 12953
diff changeset
958 this->SetWidgetDirty(DEPOT_WIDGET_MATRIX);
9931
3ed3b1a0c1b3 (svn r14086) -Fix (r13067): rail/road removing by CTRL didn't sometimes work when a depot window was opened
smatz <smatz@openttd.org>
parents: 9921
diff changeset
959 return ES_HANDLED;
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
960 }
8828
f8c143a8cd90 (svn r12576) -Feature(tte) [FS#337]: highlight vehicle chain when dragging in the group and depot GUI if appropriate
smatz <smatz@openttd.org>
parents: 8784
diff changeset
961
9931
3ed3b1a0c1b3 (svn r14086) -Fix (r13067): rail/road removing by CTRL didn't sometimes work when a depot window was opened
smatz <smatz@openttd.org>
parents: 9921
diff changeset
962 return ES_NOT_HANDLED;
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
963 }
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
964 };
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
965
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
966 static void DepotSellAllConfirmationCallback(Window *win, bool confirmed)
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
967 {
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
968 if (confirmed) {
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
969 DepotWindow *w = (DepotWindow*)win;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
970 TileIndex tile = w->window_number;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
971 byte vehtype = w->type;
10499
45ca88a8de7d (svn r14754) -Codechange: get rid of _cmd_text and just pass it as (optional) parameter.
rubidium <rubidium@openttd.org>
parents: 10208
diff changeset
972 DoCommandP(tile, vehtype, 0, CMD_DEPOT_SELL_ALL_VEHICLES);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
973 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
974 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
975
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
976 /** Opens a depot window
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
977 * @param tile The tile where the depot/hangar is located
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
978 * @param type The type of vehicles in the depot
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
979 */
6638
5479975c4e36 (svn r9869) -Codechange: replace some bytes with VehicleType, i.e. more type strictness.
rubidium <rubidium@openttd.org>
parents: 6621
diff changeset
980 void ShowDepotWindow(TileIndex tile, VehicleType type)
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
981 {
10503
60daa84bb001 (svn r14758) -Fix: determine the real size of a depot before trying to place it.
rubidium <rubidium@openttd.org>
parents: 10499
diff changeset
982 if (BringWindowToFrontById(WC_VEHICLE_DEPOT, tile) != NULL) return;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
983
10503
60daa84bb001 (svn r14758) -Fix: determine the real size of a depot before trying to place it.
rubidium <rubidium@openttd.org>
parents: 10499
diff changeset
984 const WindowDesc *desc;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
985 switch (type) {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
986 default: NOT_REACHED();
10503
60daa84bb001 (svn r14758) -Fix: determine the real size of a depot before trying to place it.
rubidium <rubidium@openttd.org>
parents: 10499
diff changeset
987 case VEH_TRAIN: desc = &_train_depot_desc; break;
60daa84bb001 (svn r14758) -Fix: determine the real size of a depot before trying to place it.
rubidium <rubidium@openttd.org>
parents: 10499
diff changeset
988 case VEH_ROAD: desc = &_road_depot_desc; break;
60daa84bb001 (svn r14758) -Fix: determine the real size of a depot before trying to place it.
rubidium <rubidium@openttd.org>
parents: 10499
diff changeset
989 case VEH_SHIP: desc = &_ship_depot_desc; break;
60daa84bb001 (svn r14758) -Fix: determine the real size of a depot before trying to place it.
rubidium <rubidium@openttd.org>
parents: 10499
diff changeset
990 case VEH_AIRCRAFT: desc = &_aircraft_depot_desc; break;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
991 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
992
10503
60daa84bb001 (svn r14758) -Fix: determine the real size of a depot before trying to place it.
rubidium <rubidium@openttd.org>
parents: 10499
diff changeset
993 new DepotWindow(desc, tile, type);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
994 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
995
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
996 /** Removes the highlight of a vehicle in a depot window
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
997 * @param *v Vehicle to remove all highlights from
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
998 */
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
999 void DeleteDepotHighlightOfVehicle(const Vehicle *v)
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1000 {
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
1001 DepotWindow *w;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1002
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1003 /* If we haven't got any vehicles on the mouse pointer, we haven't got any highlighted in any depots either
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
1004 * If that is the case, we can skip looping though the windows and save time
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
1005 */
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1006 if (_special_mouse_mode != WSM_DRAGDROP) return;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1007
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
1008 w = dynamic_cast<DepotWindow*>(FindWindowById(WC_VEHICLE_DEPOT, v->tile));
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1009 if (w != NULL) {
10629
4b43850f2e24 (svn r14924) -Fix (r7403): Do not unnecessarily reset the cursor, when a different vehicle is dragged.
frosch <frosch@openttd.org>
parents: 10582
diff changeset
1010 if (w->sel == v->index) ResetObjectToPlace();
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1011 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1012 }