annotate src/depot_gui.cpp @ 12027:54dbb2d04329 draft

(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)
author rubidium <rubidium@openttd.org>
date Tue, 26 May 2009 15:46:24 +0000
parents f51061a22830
children f020ec6be498
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
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
3 /** @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
4
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
5 #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
6 #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
7 #include "aircraft.h"
11984
b6d3e583be86 (svn r16390) -Codechange: move u.road to RoadVehicle.
rubidium <rubidium@openttd.org>
parents: 11922
diff changeset
8 #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
9 #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
10 #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
11 #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
12 #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
13 #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
14 #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
15 #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
16 #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
17 #include "spritecache.h"
8114
2d6af5d7a142 (svn r11675) -Codechange: split the string types from the string functions.
rubidium <rubidium@openttd.org>
parents: 8107
diff changeset
18 #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
19 #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
20 #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
21 #include "company_func.h"
9127
428852b86d4d (svn r12987) -Codechange: split viewport and tile selection.
rubidium <rubidium@openttd.org>
parents: 9116
diff changeset
22 #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
23 #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
24 #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
25
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
26 #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
27 #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
28
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
29 /*
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
30 * 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
31 * 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
32 * 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
33 */
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
34
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
35 /* 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
36 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
37 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
38 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
39 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
40 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
41 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
42 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
43 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
44 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
45 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
46 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
47 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
48 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
49 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
50 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
51 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
52 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
53 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
54 };
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
55
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
56 /* 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
57 * 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
58 * 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
59 * 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
60
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
61 /* 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
62 * 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
63 * 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
64 * 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
65 */
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
66
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
67 /*
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
68 * 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
69 * 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
70 * 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
71 */
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
72 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
73 { 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
74 { WWT_CAPTION, RESIZE_RIGHT, COLOUR_GREY, 11, 23, 0, 13, 0x0, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS}, // DEPOT_WIDGET_CAPTION
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
75 { WWT_STICKYBOX, RESIZE_LR, COLOUR_GREY, 24, 35, 0, 13, 0x0, STR_STICKY_BUTTON}, // 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
76
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
77 /* 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
78 { WWT_IMGBTN, RESIZE_LRB, COLOUR_GREY, 1, 23, 14, -32, 0x0, STR_NULL}, // DEPOT_WIDGET_SELL
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
79 { WWT_IMGBTN, RESIZE_LRTB, COLOUR_GREY, 1, 23, -55, -32, SPR_SELL_CHAIN_TRAIN,STR_DRAG_WHOLE_TRAIN_TO_SELL_TIP}, // DEPOT_WIDGET_SELL_CHAIN, trains only
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
80 { 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
81 { 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
82
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
83 { 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
84 { 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
85
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
86 { 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
87
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
88 /* 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
89 * 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
90 { 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
91 { 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
92 { 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
93 { 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
94 { 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
95 { WWT_PUSHIMGBTN, RESIZE_LRTB, COLOUR_GREY, 12, 23, 15, 26, SPR_FLAG_VEH_RUNNING,STR_NULL}, // DEPOT_WIDGET_START_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
96 { WWT_RESIZEBOX, RESIZE_LRTB, COLOUR_GREY, 24, 35, 15, 26, 0x0, STR_RESIZE_BUTTON}, // 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
97 { 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
98 };
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
99
9188
20be86848948 (svn r13051) -Codechange: depot_d belongs in depot_gui.cpp.
rubidium <rubidium@openttd.org>
parents: 9143
diff changeset
100
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
101 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
102 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
103 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
104 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
105 _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
106 );
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
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 _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
109 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
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 _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
116 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
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 _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
123 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
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
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
129 extern int WagonLengthToPixels(int len);
9351
feaf9bae7580 (svn r13248) -Codechange: Use VehicleList for depot GUI.
peter1138 <peter1138@openttd.org>
parents: 9344
diff changeset
130 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
131
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
132 /**
29e4afeffd1e (svn r10985) -Codechange: unify/remove duplicate CcClone(Aircraft|RoadVeh|Ship|Train) in favour of CcCloneVehicle.
rubidium <rubidium@openttd.org>
parents: 7341
diff changeset
133 * 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
134 * @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
135 * @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
136 * @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
137 * @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
138 */
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
139 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
140 {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
141 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
142
11922
0a4b63f3f3c3 (svn r16325) -Codechange: replace GetPoolItem(index) by PoolItem::Get(index)
smatz <smatz@openttd.org>
parents: 11896
diff changeset
143 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
144
7486
1af81beda3fb (svn r10997) -Codechange: unify the vehicle view window. Patch by PhilSophus.
rubidium <rubidium@openttd.org>
parents: 7479
diff changeset
145 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
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
9344
5940dd28c40d (svn r13240) -Codechange: More const-ness for GUI code.
peter1138 <peter1138@openttd.org>
parents: 9343
diff changeset
148 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
149 {
11922
0a4b63f3f3c3 (svn r16325) -Codechange: replace GetPoolItem(index) by PoolItem::Get(index)
smatz <smatz@openttd.org>
parents: 11896
diff changeset
150 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
151
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
152 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
153
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
154 if (wagon == NULL) {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
155 if (head != NULL) wagon = GetLastVehicleInChain(head);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
156 } 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
157 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
158 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
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
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
161 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
162
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
163 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
164 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
165
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
166 /* 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
167 * 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
168 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
169
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
170 /* 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
171 * 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
172 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
173 /* 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
174 /* 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
175 /* 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
176 /* 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
177 };
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
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
179 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
180 {
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
181 _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
182 _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
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 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
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_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
188 _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
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
6638
5479975c4e36 (svn r9869) -Codechange: replace some bytes with VehicleType, i.e. more type strictness.
rubidium <rubidium@openttd.org>
parents: 6621
diff changeset
191 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
192 {
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
193 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
194 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
195
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
196 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
197 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
198 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
199 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
200
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 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
202 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
203 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
204 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
205 }
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 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
207 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
208 }
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
209
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
210 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
211 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
212 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
213 _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
214 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
215 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
216 _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
217 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
218 }
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
219 _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
220 }
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
221
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
222 /* 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
223 * 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
224 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
225 {
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 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
227 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
228 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
229 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
230 }
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
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
232 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
233 const Sprite *GetAircraftSprite(EngineID engine);
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
234
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
235 struct DepotWindow : Window {
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
236 VehicleID sel;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
237 VehicleType type;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
238 bool generate_list;
9351
feaf9bae7580 (svn r13248) -Codechange: Use VehicleList for depot GUI.
peter1138 <peter1138@openttd.org>
parents: 9344
diff changeset
239 VehicleList vehicle_list;
feaf9bae7580 (svn r13248) -Codechange: Use VehicleList for depot GUI.
peter1138 <peter1138@openttd.org>
parents: 9344
diff changeset
240 VehicleList wagon_list;
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
241
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
242 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
243 {
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
244 this->sel = INVALID_VEHICLE;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
245 this->generate_list = true;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
246
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
247 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
248 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
249
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
250 this->FindWindowPlacementAndResize(desc);
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
251 }
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
252
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
253 ~DepotWindow()
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
254 {
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
255 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
256 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
257
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
258 /** 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
259 * @param *w Window to draw in
02313cc6114e (svn r15711) -Codechange: lots of whitespace cleanup/fixes
rubidium <rubidium@openttd.org>
parents: 11084
diff changeset
260 * @param *v Vehicle to draw
02313cc6114e (svn r15711) -Codechange: lots of whitespace cleanup/fixes
rubidium <rubidium@openttd.org>
parents: 11084
diff changeset
261 * @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
262 * @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
263 */
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
264 void DrawVehicleInDepot(Window *w, const Vehicle *v, int x, int y)
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
265 {
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
266 byte diff_x = 0, diff_y = 0;
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
267
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
268 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
269
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
270 switch (v->type) {
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
271 case VEH_TRAIN:
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
272 DrawTrainImage(v, x + 21, sprite_y, this->sel, this->hscroll.cap + 4, this->hscroll.pos);
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
273
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
274 /* Number of wagons relative to a standard length wagon (rounded up) */
12015
f51061a22830 (svn r16421) -Codechange: do not unnecessarily remove constness or unnecessarily add it.
rubidium <rubidium@openttd.org>
parents: 11988
diff changeset
275 SetDParam(0, (((const Train *)v)->tcache.cached_total_length + 7) / 8);
11433
07857d65c41a (svn r15791) -Codechange: remove the *RightAligned part of the old text drawing API.
rubidium <rubidium@openttd.org>
parents: 11373
diff changeset
276 DrawString(this->widget[DEPOT_WIDGET_MATRIX].left, this->widget[DEPOT_WIDGET_MATRIX].right - 1, y + 4, STR_TINY_BLACK, 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
277 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
278
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
279 case VEH_ROAD: DrawRoadVehImage( v, x + 24, sprite_y, this->sel, 1); break;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
280 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
281 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
282 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
283 DrawAircraftImage(v, x + 12,
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
284 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
285 this->sel);
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
286 } break;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
287 default: NOT_REACHED();
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
288 }
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
289
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
290 if (this->resize.step_height == 14) {
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
291 /* VEH_TRAIN and VEH_ROAD, which are low */
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
292 diff_x = 15;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
293 } else {
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
294 /* VEH_SHIP and VEH_AIRCRAFT, which are tall */
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
295 diff_y = 12;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
296 }
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
297
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
298 DrawSprite((v->vehstatus & VS_STOPPED) ? SPR_FLAG_VEH_STOPPED : SPR_FLAG_VEH_RUNNING, PAL_NONE, x + diff_x, y + diff_y);
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
299
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
300 SetDParam(0, v->unitnumber);
11770
534c3c3167f2 (svn r16160) -Codechange: remove the need for explicit TC_FROMSTRING for DrawString.
rubidium <rubidium@openttd.org>
parents: 11730
diff changeset
301 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);
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
302 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
303
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
304 void DrawDepotWindow(Window *w)
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
305 {
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
306 TileIndex tile = this->window_number;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
307 int x, y, i, maxval;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
308 uint16 hnum;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
309
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
310 /* Set the row and number of boxes in each row based on the number of boxes drawn in the matrix */
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
311 uint16 rows_in_display = this->widget[DEPOT_WIDGET_MATRIX].data >> 8;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
312 uint16 boxes_in_each_row = this->widget[DEPOT_WIDGET_MATRIX].data & 0xFF;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
313
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
314 /* 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
315 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
316 DEPOT_WIDGET_STOP_ALL,
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
317 DEPOT_WIDGET_START_ALL,
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
318 DEPOT_WIDGET_SELL,
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
319 DEPOT_WIDGET_SELL_CHAIN,
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
320 DEPOT_WIDGET_SELL_ALL,
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
321 DEPOT_WIDGET_BUILD,
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
322 DEPOT_WIDGET_CLONE,
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
323 DEPOT_WIDGET_AUTOREPLACE,
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
324 WIDGET_LIST_END);
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
325
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
326 /* determine amount of items for scroller */
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
327 if (this->type == VEH_TRAIN) {
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
328 hnum = 8;
9351
feaf9bae7580 (svn r13248) -Codechange: Use VehicleList for depot GUI.
peter1138 <peter1138@openttd.org>
parents: 9344
diff changeset
329 for (uint num = 0; num < this->vehicle_list.Length(); num++) {
feaf9bae7580 (svn r13248) -Codechange: Use VehicleList for depot GUI.
peter1138 <peter1138@openttd.org>
parents: 9344
diff changeset
330 const Vehicle *v = this->vehicle_list[num];
12015
f51061a22830 (svn r16421) -Codechange: do not unnecessarily remove constness or unnecessarily add it.
rubidium <rubidium@openttd.org>
parents: 11988
diff changeset
331 hnum = max(hnum, ((const Train *)v)->tcache.cached_total_length);
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
332 }
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
333 /* Always have 1 empty row, so people can change the setting of the train */
9351
feaf9bae7580 (svn r13248) -Codechange: Use VehicleList for depot GUI.
peter1138 <peter1138@openttd.org>
parents: 9344
diff changeset
334 SetVScrollCount(w, this->vehicle_list.Length() + this->wagon_list.Length() + 1);
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
335 SetHScrollCount(w, WagonLengthToPixels(hnum));
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
336 } else {
9351
feaf9bae7580 (svn r13248) -Codechange: Use VehicleList for depot GUI.
peter1138 <peter1138@openttd.org>
parents: 9344
diff changeset
337 SetVScrollCount(w, (this->vehicle_list.Length() + this->hscroll.cap - 1) / this->hscroll.cap);
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
338 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
339
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
340 /* locate the depot struct */
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
341 if (this->type == VEH_AIRCRAFT) {
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
342 SetDParam(0, GetStationIndex(tile)); // Airport name
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
343 } else {
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
344 Depot *depot = GetDepotByTile(tile);
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
345 assert(depot != NULL);
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
346
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
347 SetDParam(0, depot->town_index);
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
348 }
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
349
9273
72a6d2e60834 (svn r13139) -Codechange: move DrawWindowWidgets and DrawWindowViewport to the Window class and remove Window from their naming.
rubidium <rubidium@openttd.org>
parents: 9232
diff changeset
350 w->DrawWidgets();
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
351
9351
feaf9bae7580 (svn r13248) -Codechange: Use VehicleList for depot GUI.
peter1138 <peter1138@openttd.org>
parents: 9344
diff changeset
352 uint16 num = this->vscroll.pos * boxes_in_each_row;
feaf9bae7580 (svn r13248) -Codechange: Use VehicleList for depot GUI.
peter1138 <peter1138@openttd.org>
parents: 9344
diff changeset
353 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
354
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
355 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
356 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
357
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
358 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
359 /* 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
360 const Vehicle *v = this->vehicle_list[num];
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
361 DrawVehicleInDepot(w, v, x, y);
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
362 }
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
363 }
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
364
9351
feaf9bae7580 (svn r13248) -Codechange: Use VehicleList for depot GUI.
peter1138 <peter1138@openttd.org>
parents: 9344
diff changeset
365 maxval = min(this->vehicle_list.Length() + this->wagon_list.Length(), (this->vscroll.pos * boxes_in_each_row) + (rows_in_display * boxes_in_each_row));
9201
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 /* 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
368 for (; num < maxval; num++, y += 14) {
9351
feaf9bae7580 (svn r13248) -Codechange: Use VehicleList for depot GUI.
peter1138 <peter1138@openttd.org>
parents: 9344
diff changeset
369 const Vehicle *v = this->wagon_list[num - this->vehicle_list.Length()];
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
370 const Vehicle *u;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
371
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
372 DrawTrainImage(v, x + 50, y, this->sel, this->hscroll.cap - 29, 0);
11770
534c3c3167f2 (svn r16160) -Codechange: remove the need for explicit TC_FROMSTRING for DrawString.
rubidium <rubidium@openttd.org>
parents: 11730
diff changeset
373 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
374
11368
82c90cd591ab (svn r15718) -Cleanup: apply some comment coding style on the rest of the sources too
rubidium <rubidium@openttd.org>
parents: 11361
diff changeset
375 /* Draw the train counter */
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
376 i = 0;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
377 u = v;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
378 do i++; while ((u = u->Next()) != NULL); // Determine length of train
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
379 SetDParam(0, i); // Set the counter
11433
07857d65c41a (svn r15791) -Codechange: remove the *RightAligned part of the old text drawing API.
rubidium <rubidium@openttd.org>
parents: 11373
diff changeset
380 DrawString(this->widget[DEPOT_WIDGET_MATRIX].left, this->widget[DEPOT_WIDGET_MATRIX].right - 1, y + 4, STR_TINY_BLACK, 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
381 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
382 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
383
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
384 struct GetDepotVehiclePtData {
9344
5940dd28c40d (svn r13240) -Codechange: More const-ness for GUI code.
peter1138 <peter1138@openttd.org>
parents: 9343
diff changeset
385 const Vehicle *head;
5940dd28c40d (svn r13240) -Codechange: More const-ness for GUI code.
peter1138 <peter1138@openttd.org>
parents: 9343
diff changeset
386 const Vehicle *wagon;
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
387 };
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
388
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
389 enum DepotGUIAction {
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
390 MODE_ERROR,
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
391 MODE_DRAG_VEHICLE,
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
392 MODE_SHOW_VEHICLE,
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
393 MODE_START_STOP,
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
394 };
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
395
9344
5940dd28c40d (svn r13240) -Codechange: More const-ness for GUI code.
peter1138 <peter1138@openttd.org>
parents: 9343
diff changeset
396 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
397 {
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
398 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
399 int pos, skip = 0;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
400 uint16 boxes_in_each_row = this->widget[DEPOT_WIDGET_MATRIX].data & 0xFF;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
401
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
402 if (this->type == VEH_TRAIN) {
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
403 xt = 0;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
404 x -= 23;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
405 } else {
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
406 xt = x / this->resize.step_width;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
407 xm = x % this->resize.step_width;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
408 if (xt >= this->hscroll.cap) return MODE_ERROR;
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 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
411 }
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
412
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
413 row = (y - 14) / this->resize.step_height;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
414 if (row >= this->vscroll.cap) return MODE_ERROR;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
415
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
416 pos = ((row + this->vscroll.pos) * boxes_in_each_row) + xt;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
417
9351
feaf9bae7580 (svn r13248) -Codechange: Use VehicleList for depot GUI.
peter1138 <peter1138@openttd.org>
parents: 9344
diff changeset
418 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
419 if (this->type == VEH_TRAIN) {
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
420 d->head = NULL;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
421 d->wagon = NULL;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
422 return MODE_DRAG_VEHICLE;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
423 } else {
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
424 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
425 }
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
426 }
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
427
9351
feaf9bae7580 (svn r13248) -Codechange: Use VehicleList for depot GUI.
peter1138 <peter1138@openttd.org>
parents: 9344
diff changeset
428 if ((int)this->vehicle_list.Length() > pos) {
feaf9bae7580 (svn r13248) -Codechange: Use VehicleList for depot GUI.
peter1138 <peter1138@openttd.org>
parents: 9344
diff changeset
429 *veh = this->vehicle_list[pos];
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
430 skip = this->hscroll.pos;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
431 } else {
9351
feaf9bae7580 (svn r13248) -Codechange: Use VehicleList for depot GUI.
peter1138 <peter1138@openttd.org>
parents: 9344
diff changeset
432 pos -= this->vehicle_list.Length();
feaf9bae7580 (svn r13248) -Codechange: Use VehicleList for depot GUI.
peter1138 <peter1138@openttd.org>
parents: 9344
diff changeset
433 *veh = this->wagon_list[pos];
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
434 /* free wagons don't have an initial loco. */
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
435 x -= _traininfo_vehicle_width;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
436 }
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
437
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
438 switch (this->type) {
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
439 case VEH_TRAIN: {
9344
5940dd28c40d (svn r13240) -Codechange: More const-ness for GUI code.
peter1138 <peter1138@openttd.org>
parents: 9343
diff changeset
440 const Vehicle *v = *veh;
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
441 d->head = d->wagon = v;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
442
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
443 /* either pressed the flag or the number, but only when it's a loco */
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
444 if (x < 0 && IsFrontEngine(v)) return (x >= -10) ? MODE_START_STOP : MODE_SHOW_VEHICLE;
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 skip = (skip * 8) / _traininfo_vehicle_width;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
447 x = (x * 8) / _traininfo_vehicle_width;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
448
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
449 /* 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
450 x += skip;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
451
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
452 /* find the vehicle in this row that was clicked */
12015
f51061a22830 (svn r16421) -Codechange: do not unnecessarily remove constness or unnecessarily add it.
rubidium <rubidium@openttd.org>
parents: 11988
diff changeset
453 while (v != NULL && (x -= ((const Train *)v)->tcache.cached_veh_length) >= 0) v = v->Next();
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
454
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
455 /* if an articulated part was selected, find its parent */
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
456 while (v != NULL && IsArticulatedPart(v)) v = v->Previous();
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
457
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
458 d->wagon = v;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
459
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
460 return MODE_DRAG_VEHICLE;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
461 }
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
462 break;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
463
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
464 case VEH_ROAD:
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
465 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
466 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
467 break;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
468
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
469 case VEH_SHIP:
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
470 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
471 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
472 break;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
473
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
474 case VEH_AIRCRAFT:
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
475 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
476 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
477 break;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
478
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
479 default: NOT_REACHED();
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
480 }
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
481 return MODE_START_STOP;
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
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
484 void DepotClick(int x, int y)
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
485 {
9213
d288bb9876c7 (svn r13079) -Fix: certain compilers give false warning about uninitialized variable
smatz <smatz@openttd.org>
parents: 9203
diff changeset
486 GetDepotVehiclePtData gdvp = { NULL, NULL };
9344
5940dd28c40d (svn r13240) -Codechange: More const-ness for GUI code.
peter1138 <peter1138@openttd.org>
parents: 9343
diff changeset
487 const Vehicle *v = NULL;
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
488 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
489
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
490 /* 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
491 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
492 _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
493 return;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
494 }
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
495
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
496 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
497
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
498 switch (mode) {
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
499 case MODE_ERROR: // invalid
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
500 return;
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 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
503 VehicleID sel = this->sel;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
504
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
505 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
506 this->sel = INVALID_VEHICLE;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
507 TrainDepotMoveVehicle(v, sel, gdvp.head);
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
508 } else if (v != NULL) {
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
509 int image = v->GetImage(DIR_W);
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
510
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
511 this->sel = v->index;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
512 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
513 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
514
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
515 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
516 case VEH_TRAIN:
12015
f51061a22830 (svn r16421) -Codechange: do not unnecessarily remove constness or unnecessarily add it.
rubidium <rubidium@openttd.org>
parents: 11988
diff changeset
517 _cursor.short_vehicle_offset = 16 - ((const Train *)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
518 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
519
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_ROAD:
12015
f51061a22830 (svn r16421) -Codechange: do not unnecessarily remove constness or unnecessarily add it.
rubidium <rubidium@openttd.org>
parents: 11988
diff changeset
521 _cursor.short_vehicle_offset = 16 - ((const RoadVehicle *)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
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 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
525 _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
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 }
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
528 _cursor.vehchain = _ctrl_pressed;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
529 }
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
530 } break;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
531
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
532 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
533 ShowVehicleViewWindow(v);
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_START_STOP: { // click start/stop flag
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
537 uint command;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
538
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
539 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
540 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
541 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
542 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
543 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
544 default: NOT_REACHED();
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
545 }
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
546 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
547 } break;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
548
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
549 default: NOT_REACHED();
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
550 }
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
551 }
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 /**
11361
02313cc6114e (svn r15711) -Codechange: lots of whitespace cleanup/fixes
rubidium <rubidium@openttd.org>
parents: 11084
diff changeset
554 * Clones a vehicle
02313cc6114e (svn r15711) -Codechange: lots of whitespace cleanup/fixes
rubidium <rubidium@openttd.org>
parents: 11084
diff changeset
555 * @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
556 * @param *w is the window of the depot where the clone is build
02313cc6114e (svn r15711) -Codechange: lots of whitespace cleanup/fixes
rubidium <rubidium@openttd.org>
parents: 11084
diff changeset
557 */
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
558 void HandleCloneVehClick(const Vehicle *v, const Window *w)
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
559 {
11896
710a538863de (svn r16296) -Codechange: silence some ICC warnings
rubidium <rubidium@openttd.org>
parents: 11770
diff changeset
560 StringID error_str;
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
561
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
562 if (v == 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
563
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
564 if (!v->IsPrimaryVehicle()) {
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
565 v = v->First();
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
566 /* Do nothing when clicking on a train in depot with no loc attached */
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
567 if (v->type == VEH_TRAIN && !IsFrontEngine(v)) return;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
568 }
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 switch (v->type) {
11896
710a538863de (svn r16296) -Codechange: silence some ICC warnings
rubidium <rubidium@openttd.org>
parents: 11770
diff changeset
571 case VEH_TRAIN: error_str = STR_ERROR_CAN_T_BUILD_RAILROAD_VEHICLE; break;
710a538863de (svn r16296) -Codechange: silence some ICC warnings
rubidium <rubidium@openttd.org>
parents: 11770
diff changeset
572 case VEH_ROAD: error_str = STR_ERROR_CAN_T_BUILD_ROAD_VEHICLE; break;
710a538863de (svn r16296) -Codechange: silence some ICC warnings
rubidium <rubidium@openttd.org>
parents: 11770
diff changeset
573 case VEH_SHIP: error_str = STR_ERROR_CAN_T_BUILD_SHIP; break;
710a538863de (svn r16296) -Codechange: silence some ICC warnings
rubidium <rubidium@openttd.org>
parents: 11770
diff changeset
574 case VEH_AIRCRAFT: error_str = STR_ERROR_CAN_T_BUILD_AIRCRAFT; break;
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
575 default: return;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
576 }
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
577
11896
710a538863de (svn r16296) -Codechange: silence some ICC warnings
rubidium <rubidium@openttd.org>
parents: 11770
diff changeset
578 DoCommandP(this->window_number, v->index, _ctrl_pressed ? 1 : 0, CMD_CLONE_VEHICLE | CMD_MSG(error_str), CcCloneVehicle);
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 ResetObjectToPlace();
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
581 }
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
582
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
583 void ResizeDepotButtons(Window *w)
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
584 {
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
585 ResizeButtons(w, DEPOT_WIDGET_BUILD, DEPOT_WIDGET_LOCATION);
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 if (this->type == VEH_TRAIN) {
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
588 /* 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
589 * This way it will stay the same even if DEPOT_WIDGET_SELL_CHAIN is resized for some reason */
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
590 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;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
591 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
592 }
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
593 }
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
594
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
595 /* 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
596 * 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
597 * 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
598 */
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
599 void SetupStringsForDepotWindow(VehicleType type)
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
600 {
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
601 switch (type) {
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
602 default: NOT_REACHED();
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
603
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
604 case VEH_TRAIN:
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
605 this->widget[DEPOT_WIDGET_CAPTION].data = STR_DEPOT_TRAIN_CAPTION;
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
606 this->widget[DEPOT_WIDGET_STOP_ALL].tooltips = STR_MASS_STOP_DEPOT_TRAIN_TIP;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
607 this->widget[DEPOT_WIDGET_START_ALL].tooltips= STR_MASS_START_DEPOT_TRAIN_TIP;
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
608 this->widget[DEPOT_WIDGET_SELL].tooltips = STR_DEPOT_TRAIN_SELL_TOOLTIP;
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
609 this->widget[DEPOT_WIDGET_SELL_ALL].tooltips = STR_DEPOT_SELL_ALL_BUTTON_TRAIN_TIP;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
610
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
611 this->widget[DEPOT_WIDGET_BUILD].data = STR_DEPOT_TRAIN_NEW_VEHICLES_BUTTON;
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
612 this->widget[DEPOT_WIDGET_BUILD].tooltips = STR_DEPOT_TRAIN_NEW_VEHICLES_TOOLTIP;
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
613 this->widget[DEPOT_WIDGET_CLONE].data = STR_CLONE_TRAIN;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
614 this->widget[DEPOT_WIDGET_CLONE].tooltips = STR_CLONE_TRAIN_DEPOT_INFO;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
615
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
616 this->widget[DEPOT_WIDGET_LOCATION].tooltips = STR_DEPOT_TRAIN_LOCATION_TOOLTIP;
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
617 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
618 this->widget[DEPOT_WIDGET_VEHICLE_LIST].tooltips = STR_DEPOT_VEHICLE_ORDER_LIST_TRAIN_TIP;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
619 this->widget[DEPOT_WIDGET_AUTOREPLACE].tooltips = STR_DEPOT_AUTOREPLACE_TRAIN_TIP;
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 /* Sprites */
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
622 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
623 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
624 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
625 break;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
626
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
627 case VEH_ROAD:
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
628 this->widget[DEPOT_WIDGET_CAPTION].data = STR_DEPOT_ROAD_CAPTION;
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
629 this->widget[DEPOT_WIDGET_STOP_ALL].tooltips = STR_MASS_STOP_DEPOT_ROADVEH_TIP;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
630 this->widget[DEPOT_WIDGET_START_ALL].tooltips= STR_MASS_START_DEPOT_ROADVEH_TIP;
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
631 this->widget[DEPOT_WIDGET_SELL].tooltips = STR_DEPOT_ROAD_SELL_TOOLTIP;
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
632 this->widget[DEPOT_WIDGET_SELL_ALL].tooltips = STR_DEPOT_SELL_ALL_BUTTON_ROADVEH_TIP;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
633
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
634 this->widget[DEPOT_WIDGET_BUILD].data = STR_DEPOT_ROAD_NEW_VEHICLES_BUTTON;
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
635 this->widget[DEPOT_WIDGET_BUILD].tooltips = STR_DEPOT_ROAD_NEW_VEHICLES_TOOLTIP;
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
636 this->widget[DEPOT_WIDGET_CLONE].data = STR_CLONE_ROAD_VEHICLE;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
637 this->widget[DEPOT_WIDGET_CLONE].tooltips = STR_CLONE_ROAD_VEHICLE_DEPOT_INFO;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
638
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
639 this->widget[DEPOT_WIDGET_LOCATION].tooltips = STR_DEPOT_ROAD_LOCATION_TOOLTIP;
9201
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_LORRY;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
641 this->widget[DEPOT_WIDGET_VEHICLE_LIST].tooltips = STR_DEPOT_VEHICLE_ORDER_LIST_ROADVEH_TIP;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
642 this->widget[DEPOT_WIDGET_AUTOREPLACE].tooltips = STR_DEPOT_AUTOREPLACE_ROADVEH_TIP;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
643
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
644 /* Sprites */
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
645 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
646 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
647 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
648 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
649
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
650 case VEH_SHIP:
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
651 this->widget[DEPOT_WIDGET_CAPTION].data = STR_DEPOT_SHIP_CAPTION;
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
652 this->widget[DEPOT_WIDGET_STOP_ALL].tooltips = STR_MASS_STOP_DEPOT_SHIP_TIP;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
653 this->widget[DEPOT_WIDGET_START_ALL].tooltips= STR_MASS_START_DEPOT_SHIP_TIP;
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
654 this->widget[DEPOT_WIDGET_SELL].tooltips = STR_DEPOT_SHIP_SELL_TOOLTIP;
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
655 this->widget[DEPOT_WIDGET_SELL_ALL].tooltips = STR_DEPOT_SELL_ALL_BUTTON_SHIP_TIP;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
656
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
657 this->widget[DEPOT_WIDGET_BUILD].data = STR_DEPOT_SHIP_NEW_VEHICLES_BUTTON;
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
658 this->widget[DEPOT_WIDGET_BUILD].tooltips = STR_DEPOT_SHIP_NEW_VEHICLES_TOOLTIP;
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
659 this->widget[DEPOT_WIDGET_CLONE].data = STR_CLONE_SHIP;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
660 this->widget[DEPOT_WIDGET_CLONE].tooltips = STR_CLONE_SHIP_DEPOT_INFO;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
661
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
662 this->widget[DEPOT_WIDGET_LOCATION].tooltips = STR_DEPOT_SHIP_LOCATION_TOOLTIP;
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
663 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
664 this->widget[DEPOT_WIDGET_VEHICLE_LIST].tooltips = STR_DEPOT_VEHICLE_ORDER_LIST_SHIP_TIP;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
665 this->widget[DEPOT_WIDGET_AUTOREPLACE].tooltips = STR_DEPOT_AUTOREPLACE_SHIP_TIP;
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 /* Sprites */
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
668 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
669 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
670 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
671 break;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
672
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
673 case VEH_AIRCRAFT:
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
674 this->widget[DEPOT_WIDGET_CAPTION].data = STR_DEPOT_AIRCRAFT_CAPTION;
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
675 this->widget[DEPOT_WIDGET_STOP_ALL].tooltips = STR_MASS_STOP_HANGAR_TIP;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
676 this->widget[DEPOT_WIDGET_START_ALL].tooltips= STR_MASS_START_HANGAR_TIP;
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
677 this->widget[DEPOT_WIDGET_SELL].tooltips = STR_DEPOT_AIRCRAFT_SELL_TOOLTIP;
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
678 this->widget[DEPOT_WIDGET_SELL_ALL].tooltips = STR_DEPOT_SELL_ALL_BUTTON_AIRCRAFT_TIP;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
679
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
680 this->widget[DEPOT_WIDGET_BUILD].data = STR_DEPOT_AIRCRAFT_NEW_VEHICLES_BUTTON;
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
681 this->widget[DEPOT_WIDGET_BUILD].tooltips = STR_DEPOT_AIRCRAFT_NEW_VEHICLES_TOOLTIP;
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
682 this->widget[DEPOT_WIDGET_CLONE].data = STR_CLONE_AIRCRAFT;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
683 this->widget[DEPOT_WIDGET_CLONE].tooltips = STR_CLONE_AIRCRAFT_INFO_HANGAR_WINDOW;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
684
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
685 this->widget[DEPOT_WIDGET_LOCATION].tooltips = STR_DEPOT_AIRCRAFT_LOCATION_TOOLTIP;
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
686 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
687 this->widget[DEPOT_WIDGET_VEHICLE_LIST].tooltips = STR_DEPOT_VEHICLE_ORDER_LIST_AIRCRAFT_TIP;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
688 this->widget[DEPOT_WIDGET_AUTOREPLACE].tooltips = STR_DEPOT_AUTOREPLACE_AIRCRAFT_TIP;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
689
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
690 /* Sprites */
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
691 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
692 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
693 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
694 break;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
695 }
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
696 }
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 void CreateDepotListWindow(VehicleType type)
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
699 {
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
700 this->type = type;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
701 _backup_orders_tile = 0;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
702
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
703 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
704
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
705 /* 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
706
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
707 /* Set the number of blocks in each direction */
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
708 this->vscroll.cap = _resize_cap[type][0];
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
709 this->hscroll.cap = _resize_cap[type][1];
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
710
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
711 /* Set the block size */
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
712 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
713 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
714
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
715 /* 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
716 ResizeWindow(this,
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
717 _block_sizes[type][0] * this->hscroll.cap,
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
718 _block_sizes[type][1] * this->vscroll.cap);
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
719
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
720 if (type == VEH_TRAIN) {
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
721 /* 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
722 * number, flag, and length counter horizontally. */
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
723 ResizeWindow(this, 36, 12);
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
724 /* 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
725 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
726 }
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
727
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
728 /* 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
729 this->resize.width = this->width;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
730 this->resize.height = this->height;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
731
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
732 this->SetupStringsForDepotWindow(type);
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
733
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
734 this->widget[DEPOT_WIDGET_MATRIX].data =
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
735 (this->vscroll.cap * 0x100) // number of rows to draw on the background
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
736 + (type == VEH_TRAIN ? 1 : this->hscroll.cap); // 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
737
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
738
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
739 this->SetWidgetsHiddenState(type != VEH_TRAIN,
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
740 DEPOT_WIDGET_H_SCROLL,
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
741 DEPOT_WIDGET_SELL_CHAIN,
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
742 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
743
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
744 ResizeDepotButtons(this);
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
745 }
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
746
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
747 virtual void OnInvalidateData(int data)
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
748 {
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
749 this->generate_list = true;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
750 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
751
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
752 virtual void OnPaint()
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
753 {
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
754 if (this->generate_list) {
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
755 /* Generate the vehicle list
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
756 * 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
757 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
758 this->generate_list = false;
9351
feaf9bae7580 (svn r13248) -Codechange: Use VehicleList for depot GUI.
peter1138 <peter1138@openttd.org>
parents: 9344
diff changeset
759 DepotSortList(&this->vehicle_list);
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
760 }
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
761 DrawDepotWindow(this);
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
762 }
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
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
764 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
765 {
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
766 switch (widget) {
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
767 case DEPOT_WIDGET_MATRIX: // List
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
768 this->DepotClick(pt.x, pt.y);
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
769 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
770
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
771 case DEPOT_WIDGET_BUILD: // Build vehicle
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
772 ResetObjectToPlace();
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
773 ShowBuildVehicleWindow(this->window_number, this->type);
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
774 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
775
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
776 case DEPOT_WIDGET_CLONE: // Clone button
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
777 this->InvalidateWidget(DEPOT_WIDGET_CLONE);
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
778 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
779
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
780 if (this->IsWidgetLowered(DEPOT_WIDGET_CLONE)) {
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
781 static const CursorID clone_icons[] = {
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
782 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
783 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
784 };
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
785
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
786 _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
787 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
788 } else {
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
789 ResetObjectToPlace();
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
790 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
791 break;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
792
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
793 case DEPOT_WIDGET_LOCATION:
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
794 if (_ctrl_pressed) {
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
795 ShowExtraViewPortWindow(this->window_number);
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
796 } else {
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
797 ScrollMainWindowToTile(this->window_number);
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
798 }
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
799 break;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
800
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
801 case DEPOT_WIDGET_STOP_ALL:
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
802 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
803 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
804 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
805
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
806 case DEPOT_WIDGET_SELL_ALL:
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
807 /* 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
808 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
809 static const StringID confirm_captions[] = {
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
810 STR_DEPOT_TRAIN_CAPTION,
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
811 STR_DEPOT_ROAD_CAPTION,
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
812 STR_DEPOT_SHIP_CAPTION,
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
813 STR_DEPOT_AIRCRAFT_CAPTION
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
814 };
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
815 TileIndex tile = this->window_number;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
816 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
817
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
818 SetDParam(0, (vehtype == VEH_AIRCRAFT) ? GetStationIndex(tile) : GetDepotByTile(tile)->town_index);
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
819 ShowQuery(
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
820 confirm_captions[vehtype],
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
821 STR_DEPOT_SELL_CONFIRMATION_TEXT,
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
822 this,
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
823 DepotSellAllConfirmationCallback
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
824 );
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
825 }
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
826 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
827
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
828 case DEPOT_WIDGET_VEHICLE_LIST:
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
829 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
830 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
831
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
832 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
833 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
834 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
835
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
836 }
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
837 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
838
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
839 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
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 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
842
93d9386b56ac (svn r13923) -Feature: Show [total-]cargo info in depot when [ctrl-]right-clicking on vehicle.
frosch <frosch@openttd.org>
parents: 9751
diff changeset
843 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
844 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
845 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
846
93d9386b56ac (svn r13923) -Feature: Show [total-]cargo info in depot when [ctrl-]right-clicking on vehicle.
frosch <frosch@openttd.org>
parents: 9751
diff changeset
847 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
848
93d9386b56ac (svn r13923) -Feature: Show [total-]cargo info in depot when [ctrl-]right-clicking on vehicle.
frosch <frosch@openttd.org>
parents: 9751
diff changeset
849 if (v != NULL && mode == MODE_DRAG_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
850 AcceptedCargo capacity, loaded;
93d9386b56ac (svn r13923) -Feature: Show [total-]cargo info in depot when [ctrl-]right-clicking on vehicle.
frosch <frosch@openttd.org>
parents: 9751
diff changeset
851 memset(capacity, 0, sizeof(capacity));
93d9386b56ac (svn r13923) -Feature: Show [total-]cargo info in depot when [ctrl-]right-clicking on vehicle.
frosch <frosch@openttd.org>
parents: 9751
diff changeset
852 memset(loaded, 0, sizeof(loaded));
93d9386b56ac (svn r13923) -Feature: Show [total-]cargo info in depot when [ctrl-]right-clicking on vehicle.
frosch <frosch@openttd.org>
parents: 9751
diff changeset
853
93d9386b56ac (svn r13923) -Feature: Show [total-]cargo info in depot when [ctrl-]right-clicking on vehicle.
frosch <frosch@openttd.org>
parents: 9751
diff changeset
854 /* 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
855 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
856
93d9386b56ac (svn r13923) -Feature: Show [total-]cargo info in depot when [ctrl-]right-clicking on vehicle.
frosch <frosch@openttd.org>
parents: 9751
diff changeset
857 /* 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
858 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
859 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
860 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
861 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
862 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
863 }
93d9386b56ac (svn r13923) -Feature: Show [total-]cargo info in depot when [ctrl-]right-clicking on vehicle.
frosch <frosch@openttd.org>
parents: 9751
diff changeset
864
93d9386b56ac (svn r13923) -Feature: Show [total-]cargo info in depot when [ctrl-]right-clicking on vehicle.
frosch <frosch@openttd.org>
parents: 9751
diff changeset
865 if (w->type == VEH_TRAIN && !EngineHasArticPart(w)) {
93d9386b56ac (svn r13923) -Feature: Show [total-]cargo info in depot when [ctrl-]right-clicking on vehicle.
frosch <frosch@openttd.org>
parents: 9751
diff changeset
866 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
867 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
868 }
93d9386b56ac (svn r13923) -Feature: Show [total-]cargo info in depot when [ctrl-]right-clicking on vehicle.
frosch <frosch@openttd.org>
parents: 9751
diff changeset
869 }
93d9386b56ac (svn r13923) -Feature: Show [total-]cargo info in depot when [ctrl-]right-clicking on vehicle.
frosch <frosch@openttd.org>
parents: 9751
diff changeset
870
93d9386b56ac (svn r13923) -Feature: Show [total-]cargo info in depot when [ctrl-]right-clicking on vehicle.
frosch <frosch@openttd.org>
parents: 9751
diff changeset
871 /* 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
872 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
873 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
874 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
875
93d9386b56ac (svn r13923) -Feature: Show [total-]cargo info in depot when [ctrl-]right-clicking on vehicle.
frosch <frosch@openttd.org>
parents: 9751
diff changeset
876 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
877 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
878
93d9386b56ac (svn r13923) -Feature: Show [total-]cargo info in depot when [ctrl-]right-clicking on vehicle.
frosch <frosch@openttd.org>
parents: 9751
diff changeset
879 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
880 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
881 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
882 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
883 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
884 }
93d9386b56ac (svn r13923) -Feature: Show [total-]cargo info in depot when [ctrl-]right-clicking on vehicle.
frosch <frosch@openttd.org>
parents: 9751
diff changeset
885
93d9386b56ac (svn r13923) -Feature: Show [total-]cargo info in depot when [ctrl-]right-clicking on vehicle.
frosch <frosch@openttd.org>
parents: 9751
diff changeset
886 /* 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
887 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
888 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
889 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
890 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
891 } 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
892 /* Show tooltip help */
93d9386b56ac (svn r13923) -Feature: Show [total-]cargo info in depot when [ctrl-]right-clicking on vehicle.
frosch <frosch@openttd.org>
parents: 9751
diff changeset
893 StringID tooltip = INVALID_STRING_ID;
93d9386b56ac (svn r13923) -Feature: Show [total-]cargo info in depot when [ctrl-]right-clicking on vehicle.
frosch <frosch@openttd.org>
parents: 9751
diff changeset
894 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
895 case VEH_TRAIN: tooltip = STR_DEPOT_TRAIN_LIST_TOOLTIP; 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
896 case VEH_ROAD: tooltip = STR_DEPOT_ROAD_LIST_TOOLTIP; 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
897 case VEH_SHIP: tooltip = STR_DEPOT_SHIP_LIST_TOOLTIP; 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
898 case VEH_AIRCRAFT: tooltip = STR_DEPOT_AIRCRAFT_LIST_TOOLTIP;break;
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
899 default: NOT_REACHED();
93d9386b56ac (svn r13923) -Feature: Show [total-]cargo info in depot when [ctrl-]right-clicking on vehicle.
frosch <frosch@openttd.org>
parents: 9751
diff changeset
900 }
93d9386b56ac (svn r13923) -Feature: Show [total-]cargo info in depot when [ctrl-]right-clicking on vehicle.
frosch <frosch@openttd.org>
parents: 9751
diff changeset
901 GuiShowTooltips(tooltip);
93d9386b56ac (svn r13923) -Feature: Show [total-]cargo info in depot when [ctrl-]right-clicking on vehicle.
frosch <frosch@openttd.org>
parents: 9751
diff changeset
902 }
93d9386b56ac (svn r13923) -Feature: Show [total-]cargo info in depot when [ctrl-]right-clicking on vehicle.
frosch <frosch@openttd.org>
parents: 9751
diff changeset
903 }
93d9386b56ac (svn r13923) -Feature: Show [total-]cargo info in depot when [ctrl-]right-clicking on vehicle.
frosch <frosch@openttd.org>
parents: 9751
diff changeset
904
93d9386b56ac (svn r13923) -Feature: Show [total-]cargo info in depot when [ctrl-]right-clicking on vehicle.
frosch <frosch@openttd.org>
parents: 9751
diff changeset
905
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
906 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
907 {
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
908 const Vehicle *v = CheckMouseOverVehicle();
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
909
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
910 if (v != NULL) HandleCloneVehClick(v, this);
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
911 }
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
912
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
913 virtual void OnPlaceObjectAbort()
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
914 {
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
915 /* abort clone */
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
916 this->RaiseWidget(DEPOT_WIDGET_CLONE);
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
917 this->InvalidateWidget(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
918
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
919 /* abort drag & drop */
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
920 this->sel = INVALID_VEHICLE;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
921 this->InvalidateWidget(DEPOT_WIDGET_MATRIX);
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
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
924 /* 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
925 virtual void OnMouseLoop()
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
926 {
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
927 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
928
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
929 /* 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
930 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
931 _place_clicked_vehicle = NULL;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
932 HandleCloneVehClick(v, this);
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
933 }
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
934 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
935
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
936 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
937 {
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
938 switch (widget) {
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
939 case DEPOT_WIDGET_MATRIX: {
9344
5940dd28c40d (svn r13240) -Codechange: More const-ness for GUI code.
peter1138 <peter1138@openttd.org>
parents: 9343
diff changeset
940 const Vehicle *v = NULL;
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
941 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
942
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
943 this->sel = INVALID_VEHICLE;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
944 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
945
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
946 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
947 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
948
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
949 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
950 sel != INVALID_VEHICLE) {
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
951 if (gdvp.wagon != NULL && gdvp.wagon->index == sel && _ctrl_pressed) {
11922
0a4b63f3f3c3 (svn r16325) -Codechange: replace GetPoolItem(index) by PoolItem::Get(index)
smatz <smatz@openttd.org>
parents: 11896
diff changeset
952 DoCommandP(Vehicle::Get(sel)->tile, Vehicle::Get(sel)->index, true, CMD_REVERSE_TRAIN_DIRECTION | CMD_MSG(STR_ERROR_CAN_T_MAKE_VEHICLE_TURN));
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
953 } 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
954 TrainDepotMoveVehicle(gdvp.wagon, sel, gdvp.head);
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
955 } else if (gdvp.head != NULL && IsFrontEngine(gdvp.head)) {
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
956 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
957 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
958 }
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
959 } 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
960 v != NULL &&
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
961 sel == v->index) {
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
962 ShowVehicleViewWindow(v);
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 } 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
965
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
966 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
967 if (!this->IsWidgetDisabled(DEPOT_WIDGET_SELL) &&
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
968 this->sel != INVALID_VEHICLE) {
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
969 uint command;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
970
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
971 if (this->IsWidgetDisabled(widget)) return;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
972 if (this->sel == INVALID_VEHICLE) return;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
973
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
974 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
975
11922
0a4b63f3f3c3 (svn r16325) -Codechange: replace GetPoolItem(index) by PoolItem::Get(index)
smatz <smatz@openttd.org>
parents: 11896
diff changeset
976 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
977 this->sel = INVALID_VEHICLE;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
978 this->SetDirty();
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
979
9344
5940dd28c40d (svn r13240) -Codechange: More const-ness for GUI code.
peter1138 <peter1138@openttd.org>
parents: 9343
diff changeset
980 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
981
9344
5940dd28c40d (svn r13240) -Codechange: More const-ness for GUI code.
peter1138 <peter1138@openttd.org>
parents: 9343
diff changeset
982 bool is_engine = (!(v->type == VEH_TRAIN && !IsFrontEngine(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
983
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
984 if (is_engine) {
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
985 _backup_orders_tile = v->tile;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
986 BackupVehicleOrders(v);
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
987 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
988
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
989 switch (v->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
990 case VEH_TRAIN: command = CMD_SELL_RAIL_WAGON | CMD_MSG(STR_ERROR_CAN_T_SELL_RAILROAD_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
991 case VEH_ROAD: command = CMD_SELL_ROAD_VEH | CMD_MSG(STR_ERROR_CAN_T_SELL_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
992 case VEH_SHIP: command = CMD_SELL_SHIP | CMD_MSG(STR_ERROR_CAN_T_SELL_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
993 case VEH_AIRCRAFT: command = CMD_SELL_AIRCRAFT | CMD_MSG(STR_ERROR_CAN_T_SELL_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
994 default: NOT_REACHED();
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
995 }
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
996
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
997 if (!DoCommandP(v->tile, v->index, sell_cmd, command) && 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
998 }
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
999 break;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
1000 default:
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
1001 this->sel = INVALID_VEHICLE;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
1002 this->SetDirty();
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
1003 }
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
1004 _cursor.vehchain = false;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
1005 }
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
1006
11524
420a4f0b4e0b (svn r15885) -Codechange: Removed new_size parameter of Window::OnResize() callback
alberth <alberth@openttd.org>
parents: 11450
diff changeset
1007 virtual void OnResize(Point delta)
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
1008 {
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
1009 this->vscroll.cap += delta.y / (int)this->resize.step_height;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
1010 this->hscroll.cap += delta.x / (int)this->resize.step_width;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
1011 this->widget[DEPOT_WIDGET_MATRIX].data = (this->vscroll.cap << 8) + (this->type == VEH_TRAIN ? 1 : this->hscroll.cap);
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
1012 ResizeDepotButtons(this);
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
1013 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1014
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
1015 virtual EventState OnCTRLStateChange()
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
1016 {
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
1017 if (this->sel != INVALID_VEHICLE) {
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
1018 _cursor.vehchain = _ctrl_pressed;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
1019 this->InvalidateWidget(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
1020 return ES_HANDLED;
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
1021 }
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
1022
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
1023 return ES_NOT_HANDLED;
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
1024 }
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
1025 };
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
1026
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
1027 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
1028 {
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
1029 if (confirmed) {
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
1030 DepotWindow *w = (DepotWindow*)win;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
1031 TileIndex tile = w->window_number;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
1032 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
1033 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
1034 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1035 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1036
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1037 /** 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
1038 * @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
1039 * @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
1040 */
6638
5479975c4e36 (svn r9869) -Codechange: replace some bytes with VehicleType, i.e. more type strictness.
rubidium <rubidium@openttd.org>
parents: 6621
diff changeset
1041 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
1042 {
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
1043 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
1044
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
1045 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
1046 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
1047 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
1048 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
1049 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
1050 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
1051 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
1052 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1053
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
1054 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
1055 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1056
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1057 /** 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
1058 * @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
1059 */
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1060 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
1061 {
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
1062 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
1063
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1064 /* 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
1065 * 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
1066 */
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1067 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
1068
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
1069 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
1070 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
1071 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
1072 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1073 }