annotate src/depot_gui.cpp @ 9232:f90272c1b469 draft

(svn r13098) -Fix [FS#2016]: segmentation fault on opening an already opened depot.
author rubidium <rubidium@openttd.org>
date Thu, 15 May 2008 08:01:46 +0000 (2008-05-15)
parents 1e40b8e2533d
children 72a6d2e60834
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 "stdafx.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 "openttd.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 "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
8 #include "roadveh.h"
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 "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
10 #include "aircraft.h"
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
11 #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
12 #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
13 #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
14 #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
15 #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
16 #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
17 #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
18 #include "station_map.h"
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
19 #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
20 #include "spritecache.h"
8114
2d6af5d7a142 (svn r11675) -Codechange: split the string types from the string functions.
rubidium <rubidium@openttd.org>
parents: 8107
diff changeset
21 #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
22 #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
23 #include "vehicle_func.h"
8254
7d580c9c41fb (svn r11818) -Codechange: split player.h into smaller pieces.
rubidium <rubidium@openttd.org>
parents: 8237
diff changeset
24 #include "player_func.h"
8784
6280c0d48a6d (svn r12488) -Codechange: split order.h into order_base.h and order_func.h.
rubidium <rubidium@openttd.org>
parents: 8585
diff changeset
25 #include "order_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
26 #include "depot_base.h"
9127
428852b86d4d (svn r12987) -Codechange: split viewport and tile selection.
rubidium <rubidium@openttd.org>
parents: 9116
diff changeset
27 #include "tilehighlight_func.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
28
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
29 #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
30 #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
31
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
32 /*
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
33 * 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
34 * 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
35 * 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
36 */
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
37
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
38 /* 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
39 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
40 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
41 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
42 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
43 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
44 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
45 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
46 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
47 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
48 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
49 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
50 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
51 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
52 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
53 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
54 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
55 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
56 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
57 };
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
58
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
59 /* 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
60 * 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
61 * 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
62 * 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
63
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
64 /* 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
65 * 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
66 * 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
67 * 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
68 */
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
69
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 /*
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 * 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
72 * 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
73 * 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
74 */
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
75 static const Widget _depot_widgets[] = {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
76 { WWT_CLOSEBOX, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, // DEPOT_WIDGET_CLOSEBOX
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
77 { WWT_CAPTION, RESIZE_RIGHT, 14, 11, 23, 0, 13, 0x0, STR_018C_WINDOW_TITLE_DRAG_THIS}, // DEPOT_WIDGET_CAPTION
6ece78140826 (svn r8661) -Fix: [depot windows] Enlarge the blocks in the depot window if a sprite is too big to fit (ships and aircraft only)
bjarni <bjarni@openttd.org>
parents: 5955
diff changeset
78 { WWT_STICKYBOX, RESIZE_LR, 14, 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
79
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
80 /* Widgets are set up run-time */
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
81 { WWT_IMGBTN, RESIZE_LRB, 14, 1, 23, 14, -32, 0x0, STR_NULL}, // DEPOT_WIDGET_SELL
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
82 { WWT_IMGBTN, RESIZE_LRTB, 14, 1, 23, -55, -32, SPR_SELL_CHAIN_TRAIN,STR_DRAG_WHOLE_TRAIN_TO_SELL_TIP}, // DEPOT_WIDGET_SELL_CHAIN, trains only
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
83 { WWT_PUSHIMGBTN, RESIZE_LRTB, 14, 1, 23, -31, -9, 0x0, STR_NULL}, // DEPOT_WIDGET_SELL_ALL
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
84 { WWT_PUSHIMGBTN, RESIZE_LRTB, 14, 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
85
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
86 { WWT_MATRIX, RESIZE_RB, 14, 0, 0, 14, 14, 0x0, STR_NULL}, // DEPOT_WIDGET_MATRIX
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
87 { WWT_SCROLLBAR, RESIZE_LRB, 14, 24, 35, 14, 14, 0x0, STR_0190_SCROLL_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
88
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
89 { WWT_HSCROLLBAR, RESIZE_RTB, 14, 0, 0, 3, 14, 0x0, STR_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
90
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
91 /* 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
92 * This calculation is based on right in DEPOT_WIDGET_LOCATION and it presumes left of DEPOT_WIDGET_BUILD is 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
93 { WWT_PUSHTXTBTN, RESIZE_TB, 14, 0, 0, 15, 26, 0x0, STR_NULL}, // DEPOT_WIDGET_BUILD
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
94 { WWT_TEXTBTN, RESIZE_TB, 14, 0, 0, 15, 26, 0x0, STR_NULL}, // DEPOT_WIDGET_CLONE
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
95 { WWT_PUSHTXTBTN, RESIZE_RTB, 14, 0, -12, 15, 26, STR_00E4_LOCATION, STR_NULL}, // DEPOT_WIDGET_LOCATION
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
96 { WWT_PUSHTXTBTN, RESIZE_LRTB, 14, -11, 0, 15, 26, 0x0, STR_NULL}, // DEPOT_WIDGET_VEHICLE_LIST
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
97 { WWT_PUSHIMGBTN, RESIZE_LRTB, 14, 1, 11, 15, 26, SPR_FLAG_VEH_STOPPED,STR_NULL}, // DEPOT_WIDGET_STOP_ALL
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
98 { WWT_PUSHIMGBTN, RESIZE_LRTB, 14, 12, 23, 15, 26, SPR_FLAG_VEH_RUNNING,STR_NULL}, // DEPOT_WIDGET_START_ALL
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
99 { WWT_RESIZEBOX, RESIZE_LRTB, 14, 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
100 { 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
101 };
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
102
9188
20be86848948 (svn r13051) -Codechange: depot_d belongs in depot_gui.cpp.
rubidium <rubidium@openttd.org>
parents: 9143
diff changeset
103
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 static const WindowDesc _train_depot_desc = {
7341
549c757023fc (svn r10704) -Codechange: provide an infrastructure to have resizable windows that are smaller than the default window size.
rubidium <rubidium@openttd.org>
parents: 7266
diff changeset
105 WDP_AUTO, WDP_AUTO, 36, 27, 36, 27,
5893
8547517ef719 (svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium <rubidium@openttd.org>
parents: 5824
diff changeset
106 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
107 WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_STICKY_BUTTON | WDF_RESIZABLE,
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
108 _depot_widgets,
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
109 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
110 };
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
111
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
112 static const WindowDesc _road_depot_desc = {
7341
549c757023fc (svn r10704) -Codechange: provide an infrastructure to have resizable windows that are smaller than the default window size.
rubidium <rubidium@openttd.org>
parents: 7266
diff changeset
113 WDP_AUTO, WDP_AUTO, 36, 27, 36, 27,
5893
8547517ef719 (svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium <rubidium@openttd.org>
parents: 5824
diff changeset
114 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
115 WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_STICKY_BUTTON | WDF_RESIZABLE,
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
116 _depot_widgets,
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
117 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
118 };
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
119
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
120 static const WindowDesc _ship_depot_desc = {
7341
549c757023fc (svn r10704) -Codechange: provide an infrastructure to have resizable windows that are smaller than the default window size.
rubidium <rubidium@openttd.org>
parents: 7266
diff changeset
121 WDP_AUTO, WDP_AUTO, 36, 27, 36, 27,
5893
8547517ef719 (svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium <rubidium@openttd.org>
parents: 5824
diff changeset
122 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
123 WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_STICKY_BUTTON | WDF_RESIZABLE,
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
124 _depot_widgets,
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
125 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
126 };
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
127
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
128 static const WindowDesc _aircraft_depot_desc = {
7341
549c757023fc (svn r10704) -Codechange: provide an infrastructure to have resizable windows that are smaller than the default window size.
rubidium <rubidium@openttd.org>
parents: 7266
diff changeset
129 WDP_AUTO, WDP_AUTO, 36, 27, 36, 27,
5893
8547517ef719 (svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium <rubidium@openttd.org>
parents: 5824
diff changeset
130 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
131 WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_STICKY_BUTTON | WDF_RESIZABLE,
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
132 _depot_widgets,
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
133 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
134 };
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
135
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
136 extern int WagonLengthToPixels(int len);
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
137 extern void DepotSortList(Vehicle **v, uint16 length);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
138
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
139 /**
29e4afeffd1e (svn r10985) -Codechange: unify/remove duplicate CcClone(Aircraft|RoadVeh|Ship|Train) in favour of CcCloneVehicle.
rubidium <rubidium@openttd.org>
parents: 7341
diff changeset
140 * 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
141 * @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
142 * @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
143 * @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
144 * @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
145 */
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 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
147 {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
148 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
149
29e4afeffd1e (svn r10985) -Codechange: unify/remove duplicate CcClone(Aircraft|RoadVeh|Ship|Train) in favour of CcCloneVehicle.
rubidium <rubidium@openttd.org>
parents: 7341
diff changeset
150 Vehicle *v = GetVehicle(_new_vehicle_id);
29e4afeffd1e (svn r10985) -Codechange: unify/remove duplicate CcClone(Aircraft|RoadVeh|Ship|Train) in favour of CcCloneVehicle.
rubidium <rubidium@openttd.org>
parents: 7341
diff changeset
151
7486
1af81beda3fb (svn r10997) -Codechange: unify the vehicle view window. Patch by PhilSophus.
rubidium <rubidium@openttd.org>
parents: 7479
diff changeset
152 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
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
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
155 static void TrainDepotMoveVehicle(Vehicle *wagon, VehicleID sel, Vehicle *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 {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
157 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
158
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
159 v = GetVehicle(sel);
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 (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
162
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
163 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
164 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
165 } 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
166 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
167 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
168 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
169
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
170 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
171
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
172 DoCommandP(v->tile, v->index + ((wagon == NULL ? INVALID_VEHICLE : wagon->index) << 16), _ctrl_pressed ? 1 : 0, NULL, CMD_MOVE_RAIL_VEHICLE | CMD_MSG(STR_8837_CAN_T_MOVE_VEHICLE));
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
173 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
174
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
175 /* 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
176 * 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
177 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
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 /* Array to hold the default resize capacities
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 * 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
181 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
182 /* 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
183 /* 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
184 /* 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
185 /* 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
186 };
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
187
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
188 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
189 {
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
190 _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
191 _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
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
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 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
195 {
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
196 _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
197 _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
198 }
6ece78140826 (svn r8661) -Fix: [depot windows] Enlarge the blocks in the depot window if a sprite is too big to fit (ships and aircraft only)
bjarni <bjarni@openttd.org>
parents: 5955
diff changeset
199
6638
5479975c4e36 (svn r9869) -Codechange: replace some bytes with VehicleType, i.e. more type strictness.
rubidium <rubidium@openttd.org>
parents: 6621
diff changeset
200 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
201 {
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 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
203 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
204
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
205 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
206 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
207 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
208 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
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();
9065
d341f7b59228 (svn r12917) -Codechange: standardise variable names called with FOR_ALL_ENGINEIDS_OF_TYPE
peter1138 <peter1138@openttd.org>
parents: 8969
diff changeset
212 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
213 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
214 }
6ece78140826 (svn r8661) -Fix: [depot windows] Enlarge the blocks in the depot window if a sprite is too big to fit (ships and aircraft only)
bjarni <bjarni@openttd.org>
parents: 5955
diff changeset
215 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
216 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
217 }
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 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
220 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
221 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
222 _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
223 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
224 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
225 _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
226 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
227 }
6ece78140826 (svn r8661) -Fix: [depot windows] Enlarge the blocks in the depot window if a sprite is too big to fit (ships and aircraft only)
bjarni <bjarni@openttd.org>
parents: 5955
diff changeset
228 _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
229 }
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 /* 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
232 * 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
233 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
234 {
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
235 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
236 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
237 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
238 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
239 }
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
240
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
241 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
242 const Sprite *GetAircraftSprite(EngineID engine);
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 struct DepotWindow : Window {
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
245 VehicleID sel;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
246 VehicleType type;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
247 bool generate_list;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
248 uint16 engine_list_length;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
249 uint16 wagon_list_length;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
250 uint16 engine_count;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
251 uint16 wagon_count;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
252 Vehicle **vehicle_list;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
253 Vehicle **wagon_list;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
254
9203
375bae14ff71 (svn r13069) -Codechange: it is no longer needed to pass a void *data pointer with the WE_CREATE message because nothing uses it anymore.
rubidium <rubidium@openttd.org>
parents: 9201
diff changeset
255 DepotWindow(const WindowDesc *desc, WindowNumber window_number) : Window(desc, window_number)
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
256 {
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
257 this->sel = INVALID_VEHICLE;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
258 this->vehicle_list = NULL;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
259 this->wagon_list = NULL;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
260 this->engine_count = 0;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
261 this->wagon_count = 0;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
262 this->generate_list = true;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
263
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
264 this->FindWindowPlacementAndResize(desc);
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
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
267 ~DepotWindow()
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
268 {
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
269 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
270 free((void*)this->vehicle_list);
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
271 free((void*)this->wagon_list);
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
272 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
273
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
274 /** Draw a vehicle in the depot window in the box with the top left corner at x,y
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
275 * @param *w Window to draw in
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
276 * @param *v Vehicle to draw
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
277 * @param x Left side of the box to draw in
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
278 * @param y Top of the box to draw in
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
279 */
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
280 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
281 {
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
282 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
283
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
284 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
285
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
286 switch (v->type) {
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
287 case VEH_TRAIN:
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
288 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
289
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
290 /* Number of wagons relative to a standard length wagon (rounded up) */
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
291 SetDParam(0, (v->u.rail.cached_total_length + 7) / 8);
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
292 DrawStringRightAligned(this->widget[DEPOT_WIDGET_MATRIX].right - 1, y + 4, STR_TINY_BLACK, TC_FROMSTRING); // Draw the counter
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
293 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
294
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
295 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
296 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
297 case VEH_AIRCRAFT: {
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
298 const Sprite *spr = GetSprite(v->GetImage(DIR_W));
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
299 DrawAircraftImage(v, x + 12,
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
300 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
301 this->sel);
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
302 } break;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
303 default: NOT_REACHED();
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
304 }
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 if (this->resize.step_height == 14) {
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
307 /* 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
308 diff_x = 15;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
309 } else {
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
310 /* 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
311 diff_y = 12;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
312 }
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 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
315
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
316 SetDParam(0, v->unitnumber);
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
317 DrawString(x, y + 2, (uint16)(v->max_age - 366) >= v->age ? STR_00E2 : STR_00E3, TC_FROMSTRING);
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
318 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
319
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
320 void DrawDepotWindow(Window *w)
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
321 {
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
322 Vehicle **vl = this->vehicle_list;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
323 TileIndex tile = this->window_number;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
324 int x, y, i, maxval;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
325 uint16 hnum;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
326 uint16 num = this->engine_count;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
327
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
328 /* 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
329 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
330 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
331
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
332 /* setup disabled buttons */
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
333 this->SetWidgetsDisabledState(!IsTileOwner(tile, _local_player),
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
334 DEPOT_WIDGET_STOP_ALL,
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
335 DEPOT_WIDGET_START_ALL,
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
336 DEPOT_WIDGET_SELL,
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
337 DEPOT_WIDGET_SELL_CHAIN,
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
338 DEPOT_WIDGET_SELL_ALL,
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
339 DEPOT_WIDGET_BUILD,
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
340 DEPOT_WIDGET_CLONE,
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
341 DEPOT_WIDGET_AUTOREPLACE,
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
342 WIDGET_LIST_END);
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
343
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
344 /* determine amount of items for scroller */
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
345 if (this->type == VEH_TRAIN) {
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
346 hnum = 8;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
347 for (num = 0; num < this->engine_count; num++) {
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
348 const Vehicle *v = vl[num];
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
349 hnum = max(hnum, v->u.rail.cached_total_length);
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
350 }
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
351 /* Always have 1 empty row, so people can change the setting of the train */
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
352 SetVScrollCount(w, this->engine_count + this->wagon_count + 1);
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
353 SetHScrollCount(w, WagonLengthToPixels(hnum));
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
354 } else {
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
355 SetVScrollCount(w, (num + this->hscroll.cap - 1) / this->hscroll.cap);
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
356 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
357
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
358 /* locate the depot struct */
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
359 if (this->type == VEH_AIRCRAFT) {
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
360 SetDParam(0, GetStationIndex(tile)); // Airport name
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
361 } else {
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
362 Depot *depot = GetDepotByTile(tile);
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
363 assert(depot != NULL);
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
364
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
365 SetDParam(0, depot->town_index);
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
366 }
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
367
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
368 DrawWindowWidgets(w);
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
369
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
370 num = this->vscroll.pos * boxes_in_each_row;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
371 maxval = min(this->engine_count, num + (rows_in_display * boxes_in_each_row));
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
372
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
373 for (x = 2, y = 15; num < maxval; y += this->resize.step_height, x = 2) { // Draw the rows
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
374 byte i;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
375
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
376 for (i = 0; i < boxes_in_each_row && num < maxval; i++, num++, x += this->resize.step_width) {
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
377 /* Draw all vehicles in the current row */
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
378 const Vehicle *v = vl[num];
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
379 DrawVehicleInDepot(w, v, x, y);
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
380 }
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
381 }
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
382
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
383 maxval = min(this->engine_count + this->wagon_count, (this->vscroll.pos * boxes_in_each_row) + (rows_in_display * boxes_in_each_row));
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
384
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
385 /* draw the train wagons, that do not have an engine in front */
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
386 for (; num < maxval; num++, y += 14) {
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
387 const Vehicle *v = this->wagon_list[num - this->engine_count];
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
388 const Vehicle *u;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
389
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
390 DrawTrainImage(v, x + 50, y, this->sel, this->hscroll.cap - 29, 0);
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
391 DrawString(x, y + 2, STR_8816, TC_FROMSTRING);
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
392
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
393 /*Draw the train counter */
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
394 i = 0;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
395 u = v;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
396 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
397 SetDParam(0, i); // Set the counter
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
398 DrawStringRightAligned(this->widget[DEPOT_WIDGET_MATRIX].right - 1, y + 4, STR_TINY_BLACK, TC_FROMSTRING); // Draw the counter
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
399 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
400 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
401
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
402 struct GetDepotVehiclePtData {
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
403 Vehicle *head;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
404 Vehicle *wagon;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
405 };
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
406
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
407 enum DepotGUIAction {
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
408 MODE_ERROR,
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
409 MODE_DRAG_VEHICLE,
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
410 MODE_SHOW_VEHICLE,
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
411 MODE_START_STOP,
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
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
414 DepotGUIAction GetVehicleFromDepotWndPt(int x, int y, Vehicle **veh, GetDepotVehiclePtData *d) const
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 Vehicle **vl = this->vehicle_list;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
417 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
418 int pos, skip = 0;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
419 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
420
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
421 if (this->type == VEH_TRAIN) {
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
422 xt = 0;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
423 x -= 23;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
424 } else {
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
425 xt = x / this->resize.step_width;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
426 xm = x % this->resize.step_width;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
427 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
428
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
429 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
430 }
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
431
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
432 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
433 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
434
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
435 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
436
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
437 if (this->engine_count + this->wagon_count <= pos) {
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
438 if (this->type == VEH_TRAIN) {
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
439 d->head = NULL;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
440 d->wagon = NULL;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
441 return MODE_DRAG_VEHICLE;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
442 } else {
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
443 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
444 }
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
445 }
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
446
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
447 if (this->engine_count > pos) {
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
448 *veh = vl[pos];
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
449 skip = this->hscroll.pos;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
450 } else {
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
451 vl = this->wagon_list;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
452 pos -= this->engine_count;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
453 *veh = vl[pos];
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
454 /* 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
455 x -= _traininfo_vehicle_width;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
456 }
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
457
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
458 switch (this->type) {
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
459 case VEH_TRAIN: {
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
460 Vehicle *v = *veh;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
461 d->head = d->wagon = v;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
462
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
463 /* 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
464 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
465
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
466 skip = (skip * 8) / _traininfo_vehicle_width;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
467 x = (x * 8) / _traininfo_vehicle_width;
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 /* 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
470 x += skip;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
471
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
472 /* find the vehicle in this row that was clicked */
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
473 while (v != NULL && (x -= v->u.rail.cached_veh_length) >= 0) v = v->Next();
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
474
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
475 /* 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
476 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
477
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
478 d->wagon = v;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
479
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
480 return MODE_DRAG_VEHICLE;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
481 }
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
482 break;
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 case VEH_ROAD:
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
485 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
486 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
487 break;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
488
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
489 case VEH_SHIP:
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
490 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
491 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
492 break;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
493
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
494 case VEH_AIRCRAFT:
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
495 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
496 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
497 break;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
498
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
499 default: NOT_REACHED();
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
500 }
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
501 return MODE_START_STOP;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
502 }
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
503
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
504 void DepotClick(int x, int y)
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
505 {
9213
d288bb9876c7 (svn r13079) -Fix: certain compilers give false warning about uninitialized variable
smatz <smatz@openttd.org>
parents: 9203
diff changeset
506 GetDepotVehiclePtData gdvp = { NULL, NULL };
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
507 Vehicle *v = NULL;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
508 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
509
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
510 /* share / copy orders */
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
511 if (_thd.place_mode != VHM_NONE && mode != MODE_ERROR) {
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
512 _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
513 return;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
514 }
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
515
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
516 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
517
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
518 switch (mode) {
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
519 case MODE_ERROR: // invalid
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
520 return;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
521
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
522 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
523 VehicleID sel = this->sel;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
524
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
525 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
526 this->sel = INVALID_VEHICLE;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
527 TrainDepotMoveVehicle(v, sel, gdvp.head);
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
528 } else if (v != NULL) {
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
529 int image = v->GetImage(DIR_W);
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
530
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
531 this->sel = v->index;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
532 this->SetDirty();
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
533 SetObjectToPlaceWnd(image, GetVehiclePalette(v), VHM_DRAG, this);
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
534 _cursor.vehchain = _ctrl_pressed;
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 } break;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
537
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
538 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
539 ShowVehicleViewWindow(v);
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
540 break;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
541
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
542 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
543 uint command;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
544
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
545 switch (this->type) {
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
546 case VEH_TRAIN: command = CMD_START_STOP_TRAIN | CMD_MSG(STR_883B_CAN_T_STOP_START_TRAIN); break;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
547 case VEH_ROAD: command = CMD_START_STOP_ROADVEH | CMD_MSG(STR_9015_CAN_T_STOP_START_ROAD_VEHICLE); break;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
548 case VEH_SHIP: command = CMD_START_STOP_SHIP | CMD_MSG(STR_9818_CAN_T_STOP_START_SHIP); break;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
549 case VEH_AIRCRAFT: command = CMD_START_STOP_AIRCRAFT | CMD_MSG(STR_A016_CAN_T_STOP_START_AIRCRAFT); break;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
550 default: NOT_REACHED(); command = 0;
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 DoCommandP(v->tile, v->index, 0, NULL, command);
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
553 } break;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
554
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
555 default: NOT_REACHED();
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
556 }
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
557 }
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
558
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
559 /**
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
560 * Clones a vehicle
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
561 * @param *v is the original vehicle to clone
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
562 * @param *w is the window of the depot where the clone is build
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
563 */
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
564 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
565 {
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
566 uint error_str;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
567
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
568 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
569
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
570 if (!v->IsPrimaryVehicle()) {
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
571 v = v->First();
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
572 /* 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
573 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
574 }
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
575
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
576 switch (v->type) {
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
577 case VEH_TRAIN: error_str = CMD_MSG(STR_882B_CAN_T_BUILD_RAILROAD_VEHICLE); break;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
578 case VEH_ROAD: error_str = CMD_MSG(STR_9009_CAN_T_BUILD_ROAD_VEHICLE); break;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
579 case VEH_SHIP: error_str = CMD_MSG(STR_980D_CAN_T_BUILD_SHIP); break;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
580 case VEH_AIRCRAFT: error_str = CMD_MSG(STR_A008_CAN_T_BUILD_AIRCRAFT); break;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
581 default: return;
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
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
584 DoCommandP(this->window_number, v->index, _ctrl_pressed ? 1 : 0, CcCloneVehicle, CMD_CLONE_VEHICLE | error_str);
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
585
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
586 ResetObjectToPlace();
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
587 }
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
588
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
589 void ResizeDepotButtons(Window *w)
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
590 {
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
591 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
592
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
593 if (this->type == VEH_TRAIN) {
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
594 /* 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.
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
595 * This way it will stay the same even if DEPOT_WIDGET_SELL_CHAIN is resized for some reason */
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
596 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
597 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
598 }
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
599 }
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 /* 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
602 * 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
603 * 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
604 */
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
605 void SetupStringsForDepotWindow(VehicleType type)
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
606 {
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
607 switch (type) {
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
608 default: NOT_REACHED();
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
609
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
610 case VEH_TRAIN:
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
611 this->widget[DEPOT_WIDGET_CAPTION].data = STR_8800_TRAIN_DEPOT;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
612 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
613 this->widget[DEPOT_WIDGET_START_ALL].tooltips= STR_MASS_START_DEPOT_TRAIN_TIP;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
614 this->widget[DEPOT_WIDGET_SELL].tooltips = STR_8841_DRAG_TRAIN_VEHICLE_TO_HERE;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
615 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
616 this->widget[DEPOT_WIDGET_MATRIX].tooltips = STR_883F_TRAINS_CLICK_ON_TRAIN_FOR;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
617
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
618 this->widget[DEPOT_WIDGET_BUILD].data = STR_8815_NEW_VEHICLES;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
619 this->widget[DEPOT_WIDGET_BUILD].tooltips = STR_8840_BUILD_NEW_TRAIN_VEHICLE;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
620 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
621 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
622
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
623 this->widget[DEPOT_WIDGET_LOCATION].tooltips = STR_8842_CENTER_MAIN_VIEW_ON_TRAIN;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
624 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
625 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
626 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
627
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
628 /* Sprites */
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
629 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
630 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
631 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
632 break;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
633
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
634 case VEH_ROAD:
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
635 this->widget[DEPOT_WIDGET_CAPTION].data = STR_9003_ROAD_VEHICLE_DEPOT;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
636 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
637 this->widget[DEPOT_WIDGET_START_ALL].tooltips= STR_MASS_START_DEPOT_ROADVEH_TIP;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
638 this->widget[DEPOT_WIDGET_SELL].tooltips = STR_9024_DRAG_ROAD_VEHICLE_TO_HERE;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
639 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
640 this->widget[DEPOT_WIDGET_MATRIX].tooltips = STR_9022_VEHICLES_CLICK_ON_VEHICLE;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
641
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
642 this->widget[DEPOT_WIDGET_BUILD].data = STR_9004_NEW_VEHICLES;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
643 this->widget[DEPOT_WIDGET_BUILD].tooltips = STR_9023_BUILD_NEW_ROAD_VEHICLE;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
644 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
645 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
646
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
647 this->widget[DEPOT_WIDGET_LOCATION].tooltips = STR_9025_CENTER_MAIN_VIEW_ON_ROAD;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
648 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
649 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
650 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
651
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
652 /* Sprites */
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
653 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
654 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
655 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
656 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
657
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
658 case VEH_SHIP:
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
659 this->widget[DEPOT_WIDGET_CAPTION].data = STR_9803_SHIP_DEPOT;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
660 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
661 this->widget[DEPOT_WIDGET_START_ALL].tooltips= STR_MASS_START_DEPOT_SHIP_TIP;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
662 this->widget[DEPOT_WIDGET_SELL].tooltips = STR_9821_DRAG_SHIP_TO_HERE_TO_SELL;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
663 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
664 this->widget[DEPOT_WIDGET_MATRIX].tooltips = STR_981F_SHIPS_CLICK_ON_SHIP_FOR;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
665
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
666 this->widget[DEPOT_WIDGET_BUILD].data = STR_9804_NEW_SHIPS;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
667 this->widget[DEPOT_WIDGET_BUILD].tooltips = STR_9820_BUILD_NEW_SHIP;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
668 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
669 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
670
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
671 this->widget[DEPOT_WIDGET_LOCATION].tooltips = STR_9822_CENTER_MAIN_VIEW_ON_SHIP;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
672 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
673 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
674 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
675
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
676 /* Sprites */
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
677 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
678 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
679 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
680 break;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
681
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
682 case VEH_AIRCRAFT:
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
683 this->widget[DEPOT_WIDGET_CAPTION].data = STR_A002_AIRCRAFT_HANGAR;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
684 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
685 this->widget[DEPOT_WIDGET_START_ALL].tooltips= STR_MASS_START_HANGAR_TIP;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
686 this->widget[DEPOT_WIDGET_SELL].tooltips = STR_A023_DRAG_AIRCRAFT_TO_HERE_TO;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
687 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
688 this->widget[DEPOT_WIDGET_MATRIX].tooltips = STR_A021_AIRCRAFT_CLICK_ON_AIRCRAFT;
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 this->widget[DEPOT_WIDGET_BUILD].data = STR_A003_NEW_AIRCRAFT;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
691 this->widget[DEPOT_WIDGET_BUILD].tooltips = STR_A022_BUILD_NEW_AIRCRAFT;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
692 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
693 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
694
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
695 this->widget[DEPOT_WIDGET_LOCATION].tooltips = STR_A024_CENTER_MAIN_VIEW_ON_HANGAR;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
696 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
697 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
698 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
699
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
700 /* Sprites */
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
701 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
702 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
703 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
704 break;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
705 }
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
706 }
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
707
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
708 void CreateDepotListWindow(VehicleType type)
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
709 {
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
710 this->type = type;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
711 _backup_orders_tile = 0;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
712
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
713 assert(IsPlayerBuildableVehicleType(type)); // ensure that we make the call with a valid type
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 /* 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
716
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
717 /* 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
718 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
719 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
720
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
721 /* Set the block size */
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
722 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
723 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
724
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
725 /* 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
726 ResizeWindow(this,
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
727 _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
728 _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
729
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
730 if (type == VEH_TRAIN) {
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
731 /* 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
732 * number, flag, and length counter horizontally. */
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
733 ResizeWindow(this, 36, 12);
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
734 /* 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
735 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
736 }
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
737
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
738 /* 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
739 this->resize.width = this->width;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
740 this->resize.height = this->height;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
741
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
742 this->SetupStringsForDepotWindow(type);
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
743
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
744 this->widget[DEPOT_WIDGET_MATRIX].data =
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
745 (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
746 + (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
747
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
748
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
749 this->SetWidgetsHiddenState(type != VEH_TRAIN,
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
750 DEPOT_WIDGET_H_SCROLL,
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
751 DEPOT_WIDGET_SELL_CHAIN,
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
752 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
753
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
754 ResizeDepotButtons(this);
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
755 }
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
756
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
757 virtual void OnInvalidateData(int data)
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
758 {
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
759 this->generate_list = true;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
760 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
761
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
762 virtual void OnPaint()
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
763 {
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
764 if (this->generate_list) {
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
765 /* Generate the vehicle list
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
766 * It's ok to use the wagon pointers for non-trains as they will be ignored */
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
767 BuildDepotVehicleList(this->type, this->window_number,
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
768 &this->vehicle_list, &this->engine_list_length, &this->engine_count,
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
769 &this->wagon_list, &this->wagon_list_length, &this->wagon_count);
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
770 this->generate_list = false;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
771 DepotSortList(this->vehicle_list, this->engine_count);
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
772 }
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
773 DrawDepotWindow(this);
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
774 }
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 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
777 {
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
778 switch (widget) {
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
779 case DEPOT_WIDGET_MATRIX: // List
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
780 this->DepotClick(pt.x, pt.y);
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
781 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
782
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
783 case DEPOT_WIDGET_BUILD: // Build vehicle
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
784 ResetObjectToPlace();
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
785 ShowBuildVehicleWindow(this->window_number, this->type);
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
786 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
787
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
788 case DEPOT_WIDGET_CLONE: // Clone button
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
789 this->InvalidateWidget(DEPOT_WIDGET_CLONE);
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
790 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
791
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
792 if (this->IsWidgetLowered(DEPOT_WIDGET_CLONE)) {
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
793 static const CursorID clone_icons[] = {
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
794 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
795 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
796 };
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
797
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
798 _place_clicked_vehicle = NULL;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
799 SetObjectToPlaceWnd(clone_icons[this->type], PAL_NONE, VHM_RECT, this);
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
800 } else {
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
801 ResetObjectToPlace();
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
802 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
803 break;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
804
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
805 case DEPOT_WIDGET_LOCATION:
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
806 if (_ctrl_pressed) {
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
807 ShowExtraViewPortWindow(this->window_number);
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
808 } else {
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
809 ScrollMainWindowToTile(this->window_number);
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
810 }
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
811 break;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
812
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
813 case DEPOT_WIDGET_STOP_ALL:
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
814 case DEPOT_WIDGET_START_ALL:
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
815 DoCommandP(this->window_number, 0, this->type | (widget == DEPOT_WIDGET_START_ALL ? (1 << 5) : 0), NULL, CMD_MASS_START_STOP);
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
816 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
817
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
818 case DEPOT_WIDGET_SELL_ALL:
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
819 /* Only open the confimation window if there are anything to sell */
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
820 if (this->engine_count != 0 || this->wagon_count != 0) {
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
821 static const StringID confirm_captions[] = {
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
822 STR_8800_TRAIN_DEPOT,
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
823 STR_9003_ROAD_VEHICLE_DEPOT,
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
824 STR_9803_SHIP_DEPOT,
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
825 STR_A002_AIRCRAFT_HANGAR
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
826 };
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
827 TileIndex tile = this->window_number;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
828 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
829
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
830 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
831 ShowQuery(
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
832 confirm_captions[vehtype],
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
833 STR_DEPOT_SELL_CONFIRMATION_TEXT,
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
834 this,
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
835 DepotSellAllConfirmationCallback
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 }
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
838 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
839
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
840 case DEPOT_WIDGET_VEHICLE_LIST:
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
841 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
842 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
843
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
844 case DEPOT_WIDGET_AUTOREPLACE:
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
845 DoCommandP(this->window_number, this->type, 0, NULL, CMD_DEPOT_MASS_AUTOREPLACE);
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
846 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
847
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
848 }
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
849 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
850
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
851 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
852 {
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
853 const Vehicle *v = CheckMouseOverVehicle();
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
854
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
855 if (v != NULL) HandleCloneVehClick(v, this);
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
856 }
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
857
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
858 virtual void OnPlaceObjectAbort()
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
859 {
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
860 /* abort clone */
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
861 this->RaiseWidget(DEPOT_WIDGET_CLONE);
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
862 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
863
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
864 /* abort drag & drop */
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
865 this->sel = INVALID_VEHICLE;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
866 this->InvalidateWidget(DEPOT_WIDGET_MATRIX);
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
867 };
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
868
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
869 /* 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
870 virtual void OnMouseLoop()
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
871 {
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
872 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
873
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
874 /* 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
875 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
876 _place_clicked_vehicle = NULL;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
877 HandleCloneVehClick(v, this);
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
878 }
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
879 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
880
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
881 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
882 {
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
883 switch (widget) {
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
884 case DEPOT_WIDGET_MATRIX: {
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
885 Vehicle *v;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
886 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
887
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
888 this->sel = INVALID_VEHICLE;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
889 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
890
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
891 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
892 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
893
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
894 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
895 sel != INVALID_VEHICLE) {
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
896 if (gdvp.wagon != NULL && gdvp.wagon->index == sel && _ctrl_pressed) {
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
897 DoCommandP(GetVehicle(sel)->tile, GetVehicle(sel)->index, true, NULL, CMD_REVERSE_TRAIN_DIRECTION | CMD_MSG(STR_9033_CAN_T_MAKE_VEHICLE_TURN));
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
898 } 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
899 TrainDepotMoveVehicle(gdvp.wagon, sel, gdvp.head);
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
900 } 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
901 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
902 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
903 }
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
904 } 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
905 v != NULL &&
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
906 sel == v->index) {
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
907 ShowVehicleViewWindow(v);
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
908 }
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
909 } 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
910
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
911 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
912 if (!this->IsWidgetDisabled(DEPOT_WIDGET_SELL) &&
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
913 this->sel != INVALID_VEHICLE) {
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
914 Vehicle *v;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
915 uint command;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
916 int sell_cmd;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
917 bool is_engine;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
918
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
919 if (this->IsWidgetDisabled(widget)) return;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
920 if (this->sel == INVALID_VEHICLE) return;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
921
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
922 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
923
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
924 v = GetVehicle(this->sel);
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
925 this->sel = INVALID_VEHICLE;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
926 this->SetDirty();
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
927
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
928 sell_cmd = (v->type == VEH_TRAIN && (widget == DEPOT_WIDGET_SELL_CHAIN || _ctrl_pressed)) ? 1 : 0;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
929
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
930 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
931
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
932 if (is_engine) {
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
933 _backup_orders_tile = v->tile;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
934 BackupVehicleOrders(v);
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
935 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
936
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
937 switch (v->type) {
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
938 case VEH_TRAIN: command = CMD_SELL_RAIL_WAGON | CMD_MSG(STR_8839_CAN_T_SELL_RAILROAD_VEHICLE); break;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
939 case VEH_ROAD: command = CMD_SELL_ROAD_VEH | CMD_MSG(STR_9014_CAN_T_SELL_ROAD_VEHICLE); break;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
940 case VEH_SHIP: command = CMD_SELL_SHIP | CMD_MSG(STR_980C_CAN_T_SELL_SHIP); break;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
941 case VEH_AIRCRAFT: command = CMD_SELL_AIRCRAFT | CMD_MSG(STR_A01C_CAN_T_SELL_AIRCRAFT); break;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
942 default: NOT_REACHED(); command = 0;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
943 }
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
944
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
945 if (!DoCommandP(v->tile, v->index, sell_cmd, NULL, command) && is_engine) _backup_orders_tile = 0;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
946 }
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
947 break;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
948 default:
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
949 this->sel = INVALID_VEHICLE;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
950 this->SetDirty();
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
951 }
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
952 _cursor.vehchain = false;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
953 }
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
954
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
955 virtual void OnResize(Point new_size, Point delta)
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
956 {
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
957 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
958 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
959 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
960 ResizeDepotButtons(this);
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
961 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
962
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
963 virtual bool OnCTRLStateChange()
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
964 {
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
965 if (this->sel != INVALID_VEHICLE) {
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
966 _cursor.vehchain = _ctrl_pressed;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
967 this->InvalidateWidget(DEPOT_WIDGET_MATRIX);
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
968 }
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
969
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
970 return true;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
971 }
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
972 };
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 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
975 {
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
976 if (confirmed) {
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
977 DepotWindow *w = (DepotWindow*)win;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
978 TileIndex tile = w->window_number;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
979 byte vehtype = w->type;
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
980 DoCommandP(tile, vehtype, 0, NULL, 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
981 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
982 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
983
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
984 /** 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
985 * @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
986 * @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
987 */
6638
5479975c4e36 (svn r9869) -Codechange: replace some bytes with VehicleType, i.e. more type strictness.
rubidium <rubidium@openttd.org>
parents: 6621
diff changeset
988 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
989 {
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
990 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
991
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
992 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
993 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
994 case VEH_TRAIN:
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
995 w = AllocateWindowDescFront<DepotWindow>(&_train_depot_desc, tile); 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
996 case VEH_ROAD:
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
997 w = AllocateWindowDescFront<DepotWindow>(&_road_depot_desc, tile); 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
998 case VEH_SHIP:
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
999 w = AllocateWindowDescFront<DepotWindow>(&_ship_depot_desc, tile); 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
1000 case VEH_AIRCRAFT:
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
1001 w = AllocateWindowDescFront<DepotWindow>(&_aircraft_depot_desc, tile); 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
1002 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1003
9232
f90272c1b469 (svn r13098) -Fix [FS#2016]: segmentation fault on opening an already opened depot.
rubidium <rubidium@openttd.org>
parents: 9225
diff changeset
1004 if (w == NULL) return;
f90272c1b469 (svn r13098) -Fix [FS#2016]: segmentation fault on opening an already opened depot.
rubidium <rubidium@openttd.org>
parents: 9225
diff changeset
1005
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
1006 w->caption_color = GetTileOwner(tile);
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
1007 w->CreateDepotListWindow(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
1008 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1009
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1010 /** 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
1011 * @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
1012 */
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1013 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
1014 {
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
1015 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
1016
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1017 /* 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
1018 * 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
1019 */
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1020 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
1021
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
1022 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
1023 if (w != NULL) {
9201
cbf6bd9b9c33 (svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents: 9188
diff changeset
1024 w->sel = INVALID_VEHICLE;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1025 ResetObjectToPlace();
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1026 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1027 }