Mercurial > hg > openttd
annotate src/depot_gui.cpp @ 15620:f8e9a3f0c140 draft
(svn r20283) -Codechange: Unify start of doygen comments.
author | frosch <frosch@openttd.org> |
---|---|
date | Sun, 01 Aug 2010 19:22:34 +0000 |
parents | e4640748f223 |
children | c62577640878 |
rev | line source |
---|---|
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1 /* $Id$ */ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
2 |
12778
bc7926153e19
(svn r17248) -Fix: add GPL license notice where appropriate
rubidium <rubidium@openttd.org>
parents:
12762
diff
changeset
|
3 /* |
bc7926153e19
(svn r17248) -Fix: add GPL license notice where appropriate
rubidium <rubidium@openttd.org>
parents:
12762
diff
changeset
|
4 * This file is part of OpenTTD. |
bc7926153e19
(svn r17248) -Fix: add GPL license notice where appropriate
rubidium <rubidium@openttd.org>
parents:
12762
diff
changeset
|
5 * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2. |
bc7926153e19
(svn r17248) -Fix: add GPL license notice where appropriate
rubidium <rubidium@openttd.org>
parents:
12762
diff
changeset
|
6 * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
bc7926153e19
(svn r17248) -Fix: add GPL license notice where appropriate
rubidium <rubidium@openttd.org>
parents:
12762
diff
changeset
|
7 * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>. |
bc7926153e19
(svn r17248) -Fix: add GPL license notice where appropriate
rubidium <rubidium@openttd.org>
parents:
12762
diff
changeset
|
8 */ |
bc7926153e19
(svn r17248) -Fix: add GPL license notice where appropriate
rubidium <rubidium@openttd.org>
parents:
12762
diff
changeset
|
9 |
9111
d48433370037
(svn r12971) -Documentation: add @file in files that missed them and add something more than whitespace as description of files that don't have a description.
rubidium <rubidium@openttd.org>
parents:
9094
diff
changeset
|
10 /** @file depot_gui.cpp The GUI for depots. */ |
6125
46d001ebacf6
(svn r8862) -Cleanup: doxygen changes, again. Mostly @files missing tags and a few comments style.
belugas <belugas@openttd.org>
parents:
6043
diff
changeset
|
11 |
14258
a899d4e5ee1a
(svn r18809) -Codechange/Cleanup: remove unneeded headers from some files, if a header require a header make it include that header
rubidium <rubidium@openttd.org>
parents:
14230
diff
changeset
|
12 #include "stdafx.h" |
a899d4e5ee1a
(svn r18809) -Codechange/Cleanup: remove unneeded headers from some files, if a header require a header make it include that header
rubidium <rubidium@openttd.org>
parents:
14230
diff
changeset
|
13 #include "engine_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
|
14 #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
|
15 #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
|
16 #include "aircraft.h" |
11984
b6d3e583be86
(svn r16390) -Codechange: move u.road to RoadVehicle.
rubidium <rubidium@openttd.org>
parents:
11922
diff
changeset
|
17 #include "roadveh.h" |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
18 #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
|
19 #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
|
20 #include "viewport_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
|
21 #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
|
22 #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
|
23 #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
|
24 #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
|
25 #include "spritecache.h" |
8114
2d6af5d7a142
(svn r11675) -Codechange: split the string types from the string functions.
rubidium <rubidium@openttd.org>
parents:
8107
diff
changeset
|
26 #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
|
27 #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
|
28 #include "vehicle_func.h" |
10208
39cf8eebfda5
(svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents:
10207
diff
changeset
|
29 #include "company_func.h" |
9127
428852b86d4d
(svn r12987) -Codechange: split viewport and tile selection.
rubidium <rubidium@openttd.org>
parents:
9116
diff
changeset
|
30 #include "tilehighlight_func.h" |
9274
85a62fb8608f
(svn r13140) -Codechange: move the gui-list-sorting out of window_gui.h so window_gui.h only needs to be included in *_gui.cpp.
rubidium <rubidium@openttd.org>
parents:
9273
diff
changeset
|
31 #include "window_gui.h" |
9396
bbf7586724f4
(svn r13307) -Codechange: Separate VehicleList and its two functions so only the 3 users include it, reducing dependencies on misc/smallvec.h
peter1138 <peter1138@openttd.org>
parents:
9351
diff
changeset
|
32 #include "vehiclelist.h" |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
33 |
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
|
34 #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
|
35 #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
|
36 |
5584
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 * 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
|
39 * 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
|
40 * 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
|
41 */ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
42 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
43 /* 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
|
44 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
|
45 DEPOT_WIDGET_CAPTION, |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
46 DEPOT_WIDGET_SELL, |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
47 DEPOT_WIDGET_SELL_CHAIN, |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
48 DEPOT_WIDGET_SELL_ALL, |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
49 DEPOT_WIDGET_AUTOREPLACE, |
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_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
|
51 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
|
52 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
|
53 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
|
54 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
|
55 DEPOT_WIDGET_LOCATION, |
15172
e9741bd69a65
(svn r19801) -Add [FS#3691]: custom naming of depots. Based on work by sbr
rubidium <rubidium@openttd.org>
parents:
15167
diff
changeset
|
56 DEPOT_WIDGET_SHOW_RENAME, |
e9741bd69a65
(svn r19801) -Add [FS#3691]: custom naming of depots. Based on work by sbr
rubidium <rubidium@openttd.org>
parents:
15167
diff
changeset
|
57 DEPOT_WIDGET_RENAME, |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
58 DEPOT_WIDGET_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
|
59 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
|
60 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
|
61 }; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
62 |
13144
99a2d7dde8ee
(svn r17649) -Codechange: Depot gui uses pure nested widgets.
alberth <alberth@openttd.org>
parents:
13143
diff
changeset
|
63 /** Nested widget definition for train depots. */ |
99a2d7dde8ee
(svn r17649) -Codechange: Depot gui uses pure nested widgets.
alberth <alberth@openttd.org>
parents:
13143
diff
changeset
|
64 static const NWidgetPart _nested_train_depot_widgets[] = { |
99a2d7dde8ee
(svn r17649) -Codechange: Depot gui uses pure nested widgets.
alberth <alberth@openttd.org>
parents:
13143
diff
changeset
|
65 NWidget(NWID_HORIZONTAL), |
13752
517d77f53919
(svn r18277) -Codechange: remove unneeded widget indices for close, resize and sticky boxes and for window captions
rubidium <rubidium@openttd.org>
parents:
13749
diff
changeset
|
66 NWidget(WWT_CLOSEBOX, COLOUR_GREY), |
15167
2ef5704286b9
(svn r19796) -Codechange: introduce and use a {DEPOT} string command
rubidium <rubidium@openttd.org>
parents:
15088
diff
changeset
|
67 NWidget(WWT_CAPTION, COLOUR_GREY, DEPOT_WIDGET_CAPTION), SetDataTip(STR_DEPOT_CAPTION, STR_NULL), |
14045
68fabdc82f5b
(svn r18588) -Feature [FS#2943]: Add shading and unshading of windows.
alberth <alberth@openttd.org>
parents:
14037
diff
changeset
|
68 NWidget(WWT_SHADEBOX, COLOUR_GREY), |
13752
517d77f53919
(svn r18277) -Codechange: remove unneeded widget indices for close, resize and sticky boxes and for window captions
rubidium <rubidium@openttd.org>
parents:
13749
diff
changeset
|
69 NWidget(WWT_STICKYBOX, COLOUR_GREY), |
13144
99a2d7dde8ee
(svn r17649) -Codechange: Depot gui uses pure nested widgets.
alberth <alberth@openttd.org>
parents:
13143
diff
changeset
|
70 EndContainer(), |
99a2d7dde8ee
(svn r17649) -Codechange: Depot gui uses pure nested widgets.
alberth <alberth@openttd.org>
parents:
13143
diff
changeset
|
71 NWidget(NWID_HORIZONTAL), |
99a2d7dde8ee
(svn r17649) -Codechange: Depot gui uses pure nested widgets.
alberth <alberth@openttd.org>
parents:
13143
diff
changeset
|
72 NWidget(NWID_VERTICAL), |
13633
e809c4dab49d
(svn r18157) -Codechange: some minor tweaks of the boundaries of strings etc. in the depot window
rubidium <rubidium@openttd.org>
parents:
13630
diff
changeset
|
73 NWidget(WWT_MATRIX, COLOUR_GREY, DEPOT_WIDGET_MATRIX), SetDataTip(0x0, STR_NULL), SetResize(1, 1), |
13144
99a2d7dde8ee
(svn r17649) -Codechange: Depot gui uses pure nested widgets.
alberth <alberth@openttd.org>
parents:
13143
diff
changeset
|
74 NWidget(WWT_HSCROLLBAR, COLOUR_GREY, DEPOT_WIDGET_H_SCROLL), |
99a2d7dde8ee
(svn r17649) -Codechange: Depot gui uses pure nested widgets.
alberth <alberth@openttd.org>
parents:
13143
diff
changeset
|
75 EndContainer(), |
99a2d7dde8ee
(svn r17649) -Codechange: Depot gui uses pure nested widgets.
alberth <alberth@openttd.org>
parents:
13143
diff
changeset
|
76 NWidget(NWID_VERTICAL), |
13704
af90d4bf0785
(svn r18229) -Codechange: Make fill_x, fill_y a number instead of a bool.
alberth <alberth@openttd.org>
parents:
13695
diff
changeset
|
77 NWidget(WWT_IMGBTN, COLOUR_GREY, DEPOT_WIDGET_SELL), SetDataTip(0x0, STR_NULL), SetResize(0, 1), SetFill(0, 1), |
af90d4bf0785
(svn r18229) -Codechange: Make fill_x, fill_y a number instead of a bool.
alberth <alberth@openttd.org>
parents:
13695
diff
changeset
|
78 NWidget(WWT_IMGBTN, COLOUR_GREY, DEPOT_WIDGET_SELL_CHAIN), SetDataTip(SPR_SELL_CHAIN_TRAIN, STR_DEPOT_DRAG_WHOLE_TRAIN_TO_SELL_TOOLTIP), SetResize(0, 1), SetFill(0, 1), |
13144
99a2d7dde8ee
(svn r17649) -Codechange: Depot gui uses pure nested widgets.
alberth <alberth@openttd.org>
parents:
13143
diff
changeset
|
79 NWidget(WWT_PUSHIMGBTN, COLOUR_GREY, DEPOT_WIDGET_SELL_ALL), SetDataTip(0x0, STR_NULL), |
99a2d7dde8ee
(svn r17649) -Codechange: Depot gui uses pure nested widgets.
alberth <alberth@openttd.org>
parents:
13143
diff
changeset
|
80 NWidget(WWT_PUSHIMGBTN, COLOUR_GREY, DEPOT_WIDGET_AUTOREPLACE), SetDataTip(0x0, STR_NULL), |
99a2d7dde8ee
(svn r17649) -Codechange: Depot gui uses pure nested widgets.
alberth <alberth@openttd.org>
parents:
13143
diff
changeset
|
81 EndContainer(), |
99a2d7dde8ee
(svn r17649) -Codechange: Depot gui uses pure nested widgets.
alberth <alberth@openttd.org>
parents:
13143
diff
changeset
|
82 NWidget(WWT_SCROLLBAR, COLOUR_GREY, DEPOT_WIDGET_V_SCROLL), |
99a2d7dde8ee
(svn r17649) -Codechange: Depot gui uses pure nested widgets.
alberth <alberth@openttd.org>
parents:
13143
diff
changeset
|
83 EndContainer(), |
99a2d7dde8ee
(svn r17649) -Codechange: Depot gui uses pure nested widgets.
alberth <alberth@openttd.org>
parents:
13143
diff
changeset
|
84 NWidget(NWID_HORIZONTAL, NC_EQUALSIZE), |
13704
af90d4bf0785
(svn r18229) -Codechange: Make fill_x, fill_y a number instead of a bool.
alberth <alberth@openttd.org>
parents:
13695
diff
changeset
|
85 NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, DEPOT_WIDGET_BUILD), SetDataTip(0x0, STR_NULL), SetFill(1, 1), SetResize(1, 0), |
af90d4bf0785
(svn r18229) -Codechange: Make fill_x, fill_y a number instead of a bool.
alberth <alberth@openttd.org>
parents:
13695
diff
changeset
|
86 NWidget(WWT_TEXTBTN, COLOUR_GREY, DEPOT_WIDGET_CLONE), SetDataTip(0x0, STR_NULL), SetFill(1, 1), SetResize(1, 0), |
af90d4bf0785
(svn r18229) -Codechange: Make fill_x, fill_y a number instead of a bool.
alberth <alberth@openttd.org>
parents:
13695
diff
changeset
|
87 NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, DEPOT_WIDGET_LOCATION), SetDataTip(STR_BUTTON_LOCATION, STR_NULL), SetFill(1, 1), SetResize(1, 0), |
15172
e9741bd69a65
(svn r19801) -Add [FS#3691]: custom naming of depots. Based on work by sbr
rubidium <rubidium@openttd.org>
parents:
15167
diff
changeset
|
88 NWidget(NWID_SELECTION, INVALID_COLOUR, DEPOT_WIDGET_SHOW_RENAME), // rename button |
e9741bd69a65
(svn r19801) -Add [FS#3691]: custom naming of depots. Based on work by sbr
rubidium <rubidium@openttd.org>
parents:
15167
diff
changeset
|
89 NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, DEPOT_WIDGET_RENAME), SetDataTip(STR_BUTTON_RENAME, STR_DEPOT_RENAME_TOOLTIP), SetFill(1, 1), SetResize(1, 0), |
e9741bd69a65
(svn r19801) -Add [FS#3691]: custom naming of depots. Based on work by sbr
rubidium <rubidium@openttd.org>
parents:
15167
diff
changeset
|
90 EndContainer(), |
13704
af90d4bf0785
(svn r18229) -Codechange: Make fill_x, fill_y a number instead of a bool.
alberth <alberth@openttd.org>
parents:
13695
diff
changeset
|
91 NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, DEPOT_WIDGET_VEHICLE_LIST), SetDataTip(0x0, STR_NULL), SetFill(0, 1), |
af90d4bf0785
(svn r18229) -Codechange: Make fill_x, fill_y a number instead of a bool.
alberth <alberth@openttd.org>
parents:
13695
diff
changeset
|
92 NWidget(WWT_PUSHIMGBTN, COLOUR_GREY, DEPOT_WIDGET_STOP_ALL), SetDataTip(SPR_FLAG_VEH_STOPPED, STR_NULL), SetFill(0, 1), |
af90d4bf0785
(svn r18229) -Codechange: Make fill_x, fill_y a number instead of a bool.
alberth <alberth@openttd.org>
parents:
13695
diff
changeset
|
93 NWidget(WWT_PUSHIMGBTN, COLOUR_GREY, DEPOT_WIDGET_START_ALL), SetDataTip(SPR_FLAG_VEH_RUNNING, STR_NULL), SetFill(0, 1), |
13752
517d77f53919
(svn r18277) -Codechange: remove unneeded widget indices for close, resize and sticky boxes and for window captions
rubidium <rubidium@openttd.org>
parents:
13749
diff
changeset
|
94 NWidget(WWT_RESIZEBOX, COLOUR_GREY), |
13144
99a2d7dde8ee
(svn r17649) -Codechange: Depot gui uses pure nested widgets.
alberth <alberth@openttd.org>
parents:
13143
diff
changeset
|
95 EndContainer(), |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
96 }; |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
97 |
11373
474ba6cc0946
(svn r15723) -Codechange: use a constructor for WindowDescs as that makes expanding them much easier (Alberth)
rubidium <rubidium@openttd.org>
parents:
11368
diff
changeset
|
98 static const WindowDesc _train_depot_desc( |
13796
3e68f07eb821
(svn r18322) -Codechange: remove the WDP duplication; no need to tell the same twice.
rubidium <rubidium@openttd.org>
parents:
13752
diff
changeset
|
99 WDP_AUTO, 362, 123, |
5893
8547517ef719
(svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium <rubidium@openttd.org>
parents:
5824
diff
changeset
|
100 WC_VEHICLE_DEPOT, WC_NONE, |
13749
fc3ab8256c95
(svn r18274) -Codechange: remove the unused WDF flags
rubidium <rubidium@openttd.org>
parents:
13706
diff
changeset
|
101 WDF_UNCLICK_BUTTONS, |
13564
bae287664b02
(svn r18086) -Codechange: remove 'widget' from WindowDesc
rubidium <rubidium@openttd.org>
parents:
13344
diff
changeset
|
102 _nested_train_depot_widgets, lengthof(_nested_train_depot_widgets) |
11373
474ba6cc0946
(svn r15723) -Codechange: use a constructor for WindowDescs as that makes expanding them much easier (Alberth)
rubidium <rubidium@openttd.org>
parents:
11368
diff
changeset
|
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 |
11373
474ba6cc0946
(svn r15723) -Codechange: use a constructor for WindowDescs as that makes expanding them much easier (Alberth)
rubidium <rubidium@openttd.org>
parents:
11368
diff
changeset
|
105 static const WindowDesc _road_depot_desc( |
13796
3e68f07eb821
(svn r18322) -Codechange: remove the WDP duplication; no need to tell the same twice.
rubidium <rubidium@openttd.org>
parents:
13752
diff
changeset
|
106 WDP_AUTO, 316, 97, |
5893
8547517ef719
(svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium <rubidium@openttd.org>
parents:
5824
diff
changeset
|
107 WC_VEHICLE_DEPOT, WC_NONE, |
13749
fc3ab8256c95
(svn r18274) -Codechange: remove the unused WDF flags
rubidium <rubidium@openttd.org>
parents:
13706
diff
changeset
|
108 WDF_UNCLICK_BUTTONS, |
13564
bae287664b02
(svn r18086) -Codechange: remove 'widget' from WindowDesc
rubidium <rubidium@openttd.org>
parents:
13344
diff
changeset
|
109 _nested_train_depot_widgets, lengthof(_nested_train_depot_widgets) |
11373
474ba6cc0946
(svn r15723) -Codechange: use a constructor for WindowDescs as that makes expanding them much easier (Alberth)
rubidium <rubidium@openttd.org>
parents:
11368
diff
changeset
|
110 ); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
111 |
11373
474ba6cc0946
(svn r15723) -Codechange: use a constructor for WindowDescs as that makes expanding them much easier (Alberth)
rubidium <rubidium@openttd.org>
parents:
11368
diff
changeset
|
112 static const WindowDesc _ship_depot_desc( |
13796
3e68f07eb821
(svn r18322) -Codechange: remove the WDP duplication; no need to tell the same twice.
rubidium <rubidium@openttd.org>
parents:
13752
diff
changeset
|
113 WDP_AUTO, 306, 99, |
5893
8547517ef719
(svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium <rubidium@openttd.org>
parents:
5824
diff
changeset
|
114 WC_VEHICLE_DEPOT, WC_NONE, |
13749
fc3ab8256c95
(svn r18274) -Codechange: remove the unused WDF flags
rubidium <rubidium@openttd.org>
parents:
13706
diff
changeset
|
115 WDF_UNCLICK_BUTTONS, |
13564
bae287664b02
(svn r18086) -Codechange: remove 'widget' from WindowDesc
rubidium <rubidium@openttd.org>
parents:
13344
diff
changeset
|
116 _nested_train_depot_widgets, lengthof(_nested_train_depot_widgets) |
11373
474ba6cc0946
(svn r15723) -Codechange: use a constructor for WindowDescs as that makes expanding them much easier (Alberth)
rubidium <rubidium@openttd.org>
parents:
11368
diff
changeset
|
117 ); |
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 |
11373
474ba6cc0946
(svn r15723) -Codechange: use a constructor for WindowDescs as that makes expanding them much easier (Alberth)
rubidium <rubidium@openttd.org>
parents:
11368
diff
changeset
|
119 static const WindowDesc _aircraft_depot_desc( |
13796
3e68f07eb821
(svn r18322) -Codechange: remove the WDP duplication; no need to tell the same twice.
rubidium <rubidium@openttd.org>
parents:
13752
diff
changeset
|
120 WDP_AUTO, 332, 99, |
5893
8547517ef719
(svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium <rubidium@openttd.org>
parents:
5824
diff
changeset
|
121 WC_VEHICLE_DEPOT, WC_NONE, |
13749
fc3ab8256c95
(svn r18274) -Codechange: remove the unused WDF flags
rubidium <rubidium@openttd.org>
parents:
13706
diff
changeset
|
122 WDF_UNCLICK_BUTTONS, |
13564
bae287664b02
(svn r18086) -Codechange: remove 'widget' from WindowDesc
rubidium <rubidium@openttd.org>
parents:
13344
diff
changeset
|
123 _nested_train_depot_widgets, lengthof(_nested_train_depot_widgets) |
11373
474ba6cc0946
(svn r15723) -Codechange: use a constructor for WindowDescs as that makes expanding them much easier (Alberth)
rubidium <rubidium@openttd.org>
parents:
11368
diff
changeset
|
124 ); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
125 |
9351
feaf9bae7580
(svn r13248) -Codechange: Use VehicleList for depot GUI.
peter1138 <peter1138@openttd.org>
parents:
9344
diff
changeset
|
126 extern void DepotSortList(VehicleList *list); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
127 |
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
|
128 /** |
29e4afeffd1e
(svn r10985) -Codechange: unify/remove duplicate CcClone(Aircraft|RoadVeh|Ship|Train) in favour of CcCloneVehicle.
rubidium <rubidium@openttd.org>
parents:
7341
diff
changeset
|
129 * This is the Callback method after the cloning attempt of a vehicle |
14230
95250f9a5035
(svn r18781) -Codechange: pass the CommandCost to the callback instead of whether it succeeded or not.
rubidium <rubidium@openttd.org>
parents:
14045
diff
changeset
|
130 * @param result the result of the cloning command |
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
|
131 * @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
|
132 * @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
|
133 * @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
|
134 */ |
14230
95250f9a5035
(svn r18781) -Codechange: pass the CommandCost to the callback instead of whether it succeeded or not.
rubidium <rubidium@openttd.org>
parents:
14045
diff
changeset
|
135 void CcCloneVehicle(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2) |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
136 { |
14230
95250f9a5035
(svn r18781) -Codechange: pass the CommandCost to the callback instead of whether it succeeded or not.
rubidium <rubidium@openttd.org>
parents:
14045
diff
changeset
|
137 if (result.Failed()) 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
|
138 |
11922
0a4b63f3f3c3
(svn r16325) -Codechange: replace GetPoolItem(index) by PoolItem::Get(index)
smatz <smatz@openttd.org>
parents:
11896
diff
changeset
|
139 const Vehicle *v = Vehicle::Get(_new_vehicle_id); |
7478
29e4afeffd1e
(svn r10985) -Codechange: unify/remove duplicate CcClone(Aircraft|RoadVeh|Ship|Train) in favour of CcCloneVehicle.
rubidium <rubidium@openttd.org>
parents:
7341
diff
changeset
|
140 |
7486
1af81beda3fb
(svn r10997) -Codechange: unify the vehicle view window. Patch by PhilSophus.
rubidium <rubidium@openttd.org>
parents:
7479
diff
changeset
|
141 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
|
142 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
143 |
9344
5940dd28c40d
(svn r13240) -Codechange: More const-ness for GUI code.
peter1138 <peter1138@openttd.org>
parents:
9343
diff
changeset
|
144 static void TrainDepotMoveVehicle(const Vehicle *wagon, VehicleID sel, const Vehicle *head) |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
145 { |
11922
0a4b63f3f3c3
(svn r16325) -Codechange: replace GetPoolItem(index) by PoolItem::Get(index)
smatz <smatz@openttd.org>
parents:
11896
diff
changeset
|
146 const Vehicle *v = Vehicle::Get(sel); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
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 (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
|
149 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
150 if (wagon == NULL) { |
12460
4acae7d6f5ed
(svn r16894) -Codechange: Add [Specialised]Vehicle::Last().
frosch <frosch@openttd.org>
parents:
12450
diff
changeset
|
151 if (head != NULL) wagon = head->Last(); |
12762
839af08c39fc
(svn r17228) -Codechange: some coding style fixes
rubidium <rubidium@openttd.org>
parents:
12729
diff
changeset
|
152 } 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
|
153 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
|
154 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
|
155 } |
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 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
|
158 |
11730
a39da1e4c1f5
(svn r16118) -Change/cleanup: remove the hexadecimal 'in TTD the string had this ID' from 'some' strings and replace the string name with something more sensible.
rubidium <rubidium@openttd.org>
parents:
11702
diff
changeset
|
159 DoCommandP(v->tile, v->index + ((wagon == NULL ? INVALID_VEHICLE : wagon->index) << 16), _ctrl_pressed ? 1 : 0, CMD_MOVE_RAIL_VEHICLE | CMD_MSG(STR_ERROR_CAN_T_MOVE_VEHICLE)); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
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 |
15620
f8e9a3f0c140
(svn r20283) -Codechange: Unify start of doygen comments.
frosch <frosch@openttd.org>
parents:
15618
diff
changeset
|
162 /** |
f8e9a3f0c140
(svn r20283) -Codechange: Unify start of doygen comments.
frosch <frosch@openttd.org>
parents:
15618
diff
changeset
|
163 * Array containing the cell size in pixels of the #DEPOT_WIDGET_MATRIX widget for each vehicle type. |
13124
91bceb31f3b1
(svn r17626) -Codechange: Use Dimension structs instead of array of length 2 for storing horizontal/vertical information.
alberth <alberth@openttd.org>
parents:
13122
diff
changeset
|
164 * @note The train vehicle type uses the entire row for each train. */ |
13630
40489a4d0822
(svn r18154) -Codechange: let the depot window better scale with bigger fonts
rubidium <rubidium@openttd.org>
parents:
13628
diff
changeset
|
165 static Dimension _base_block_sizes[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
|
166 |
13147
71af1fabcf0f
(svn r17652) -Codechange: Merging/renaming the depot block-size functions.
alberth <alberth@openttd.org>
parents:
13145
diff
changeset
|
167 static void InitBlocksizeForShipAircraft(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
|
168 { |
6ece78140826
(svn r8661) -Fix: [depot windows] Enlarge the blocks in the depot window if a sprite is too big to fit (ships and aircraft only)
bjarni <bjarni@openttd.org>
parents:
5955
diff
changeset
|
169 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
|
170 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
|
171 |
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
|
172 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
|
173 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
|
174 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
|
175 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
|
176 |
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 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
|
178 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
|
179 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
|
180 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
|
181 } |
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
|
182 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
|
183 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
|
184 } |
6ece78140826
(svn r8661) -Fix: [depot windows] Enlarge the blocks in the depot window if a sprite is too big to fit (ships and aircraft only)
bjarni <bjarni@openttd.org>
parents:
5955
diff
changeset
|
185 |
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 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
|
187 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
|
188 case VEH_SHIP: |
13630
40489a4d0822
(svn r18154) -Codechange: let the depot window better scale with bigger fonts
rubidium <rubidium@openttd.org>
parents:
13628
diff
changeset
|
189 _base_block_sizes[VEH_SHIP].width = max(76U, 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
|
190 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
|
191 case VEH_AIRCRAFT: |
13630
40489a4d0822
(svn r18154) -Codechange: let the depot window better scale with bigger fonts
rubidium <rubidium@openttd.org>
parents:
13628
diff
changeset
|
192 _base_block_sizes[VEH_AIRCRAFT].width = max(67U, 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
|
193 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
|
194 } |
13630
40489a4d0822
(svn r18154) -Codechange: let the depot window better scale with bigger fonts
rubidium <rubidium@openttd.org>
parents:
13628
diff
changeset
|
195 _base_block_sizes[type].height = max(GetVehicleHeight(type), max_height); |
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
|
196 } |
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
|
197 |
15620
f8e9a3f0c140
(svn r20283) -Codechange: Unify start of doygen comments.
frosch <frosch@openttd.org>
parents:
15618
diff
changeset
|
198 /** |
f8e9a3f0c140
(svn r20283) -Codechange: Unify start of doygen comments.
frosch <frosch@openttd.org>
parents:
15618
diff
changeset
|
199 * 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. |
13147
71af1fabcf0f
(svn r17652) -Codechange: Merging/renaming the depot block-size functions.
alberth <alberth@openttd.org>
parents:
13145
diff
changeset
|
200 * @note Calling this function once for each game is enough. */ |
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 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
|
202 { |
13630
40489a4d0822
(svn r18154) -Codechange: let the depot window better scale with bigger fonts
rubidium <rubidium@openttd.org>
parents:
13628
diff
changeset
|
203 _base_block_sizes[VEH_TRAIN].width = 0; |
40489a4d0822
(svn r18154) -Codechange: let the depot window better scale with bigger fonts
rubidium <rubidium@openttd.org>
parents:
13628
diff
changeset
|
204 _base_block_sizes[VEH_TRAIN].height = GetVehicleHeight(VEH_TRAIN); |
13147
71af1fabcf0f
(svn r17652) -Codechange: Merging/renaming the depot block-size functions.
alberth <alberth@openttd.org>
parents:
13145
diff
changeset
|
205 |
13630
40489a4d0822
(svn r18154) -Codechange: let the depot window better scale with bigger fonts
rubidium <rubidium@openttd.org>
parents:
13628
diff
changeset
|
206 _base_block_sizes[VEH_ROAD].width = 32; |
40489a4d0822
(svn r18154) -Codechange: let the depot window better scale with bigger fonts
rubidium <rubidium@openttd.org>
parents:
13628
diff
changeset
|
207 _base_block_sizes[VEH_ROAD].height = GetVehicleHeight(VEH_ROAD); |
13147
71af1fabcf0f
(svn r17652) -Codechange: Merging/renaming the depot block-size functions.
alberth <alberth@openttd.org>
parents:
13145
diff
changeset
|
208 |
71af1fabcf0f
(svn r17652) -Codechange: Merging/renaming the depot block-size functions.
alberth <alberth@openttd.org>
parents:
13145
diff
changeset
|
209 InitBlocksizeForShipAircraft(VEH_SHIP); |
71af1fabcf0f
(svn r17652) -Codechange: Merging/renaming the depot block-size functions.
alberth <alberth@openttd.org>
parents:
13145
diff
changeset
|
210 InitBlocksizeForShipAircraft(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
|
211 } |
6ece78140826
(svn r8661) -Fix: [depot windows] Enlarge the blocks in the depot window if a sprite is too big to fit (ships and aircraft only)
bjarni <bjarni@openttd.org>
parents:
5955
diff
changeset
|
212 |
9201
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
213 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
|
214 const Sprite *GetAircraftSprite(EngineID engine); |
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
215 |
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
216 struct DepotWindow : Window { |
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
217 VehicleID sel; |
15253
bd9b4d0ad9fe
(svn r19888) -Add [FS#3705]: Add highlighting of drag destination in depot gui (sbr).
alberth <alberth@openttd.org>
parents:
15172
diff
changeset
|
218 VehicleID vehicle_over; ///< Rail vehicle over which another one is dragged, \c INVALID_VEHICLE if none. |
9201
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
219 VehicleType type; |
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
220 bool generate_list; |
9351
feaf9bae7580
(svn r13248) -Codechange: Use VehicleList for depot GUI.
peter1138 <peter1138@openttd.org>
parents:
9344
diff
changeset
|
221 VehicleList vehicle_list; |
feaf9bae7580
(svn r13248) -Codechange: Use VehicleList for depot GUI.
peter1138 <peter1138@openttd.org>
parents:
9344
diff
changeset
|
222 VehicleList wagon_list; |
9201
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
223 |
13144
99a2d7dde8ee
(svn r17649) -Codechange: Depot gui uses pure nested widgets.
alberth <alberth@openttd.org>
parents:
13143
diff
changeset
|
224 DepotWindow(const WindowDesc *desc, TileIndex tile, VehicleType type) : Window() |
9201
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
225 { |
13602
47a93be74755
(svn r18126) -Codechange: remove duplicate (since r18119) scrollbar capacity/matrix initialisation
rubidium <rubidium@openttd.org>
parents:
13564
diff
changeset
|
226 assert(IsCompanyBuildableVehicleType(type)); // ensure that we make the call with a valid type |
47a93be74755
(svn r18126) -Codechange: remove duplicate (since r18119) scrollbar capacity/matrix initialisation
rubidium <rubidium@openttd.org>
parents:
13564
diff
changeset
|
227 |
9201
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
228 this->sel = INVALID_VEHICLE; |
15253
bd9b4d0ad9fe
(svn r19888) -Add [FS#3705]: Add highlighting of drag destination in depot gui (sbr).
alberth <alberth@openttd.org>
parents:
15172
diff
changeset
|
229 this->vehicle_over = INVALID_VEHICLE; |
9201
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
230 this->generate_list = true; |
13143
dd57dca0d7c7
(svn r17648) -Codechange: Move type initialization and widget disabling to the constructor.
alberth <alberth@openttd.org>
parents:
13142
diff
changeset
|
231 this->type = type; |
9201
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
232 |
13144
99a2d7dde8ee
(svn r17649) -Codechange: Depot gui uses pure nested widgets.
alberth <alberth@openttd.org>
parents:
13143
diff
changeset
|
233 this->CreateNestedTree(desc); |
15172
e9741bd69a65
(svn r19801) -Add [FS#3691]: custom naming of depots. Based on work by sbr
rubidium <rubidium@openttd.org>
parents:
15167
diff
changeset
|
234 /* Don't show 'rename button' of aircraft hangar */ |
e9741bd69a65
(svn r19801) -Add [FS#3691]: custom naming of depots. Based on work by sbr
rubidium <rubidium@openttd.org>
parents:
15167
diff
changeset
|
235 this->GetWidget<NWidgetStacked>(DEPOT_WIDGET_SHOW_RENAME)->SetDisplayedPlane(type == VEH_AIRCRAFT ? SZSP_NONE : 0); |
13321
8f6b37d7f699
(svn r17830) -Fix [FS#3276]: Some windows already need their window_number when setting up smallest size (e.g. for DParams). So assign it earlier in Window::InitializeData instead of dealing with each window separately.
frosch <frosch@openttd.org>
parents:
13277
diff
changeset
|
236 this->SetupWidgetData(type); |
8f6b37d7f699
(svn r17830) -Fix [FS#3276]: Some windows already need their window_number when setting up smallest size (e.g. for DParams). So assign it earlier in Window::InitializeData instead of dealing with each window separately.
frosch <frosch@openttd.org>
parents:
13277
diff
changeset
|
237 this->FinishInitNested(desc, tile); |
10503
60daa84bb001
(svn r14758) -Fix: determine the real size of a depot before trying to place it.
rubidium <rubidium@openttd.org>
parents:
10499
diff
changeset
|
238 |
13144
99a2d7dde8ee
(svn r17649) -Codechange: Depot gui uses pure nested widgets.
alberth <alberth@openttd.org>
parents:
13143
diff
changeset
|
239 this->owner = GetTileOwner(tile); |
13602
47a93be74755
(svn r18126) -Codechange: remove duplicate (since r18119) scrollbar capacity/matrix initialisation
rubidium <rubidium@openttd.org>
parents:
13564
diff
changeset
|
240 _backup_orders_tile = 0; |
47a93be74755
(svn r18126) -Codechange: remove duplicate (since r18119) scrollbar capacity/matrix initialisation
rubidium <rubidium@openttd.org>
parents:
13564
diff
changeset
|
241 |
9201
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
242 } |
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 ~DepotWindow() |
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
245 { |
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
246 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
|
247 } |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
248 |
15620
f8e9a3f0c140
(svn r20283) -Codechange: Unify start of doygen comments.
frosch <frosch@openttd.org>
parents:
15618
diff
changeset
|
249 /** |
f8e9a3f0c140
(svn r20283) -Codechange: Unify start of doygen comments.
frosch <frosch@openttd.org>
parents:
15618
diff
changeset
|
250 * Draw a vehicle in the depot window in the box with the top left corner at x,y. |
13142
a37a85a415ad
(svn r17647) -Codechange: Moving widget array access to outside the function.
alberth <alberth@openttd.org>
parents:
13138
diff
changeset
|
251 * @param v Vehicle to draw. |
13621
495608777888
(svn r18145) -Codechange: pass the 'proper' left and right values to DrawVehicleInDepot
rubidium <rubidium@openttd.org>
parents:
13609
diff
changeset
|
252 * @param left Left side of the box to draw in. |
495608777888
(svn r18145) -Codechange: pass the 'proper' left and right values to DrawVehicleInDepot
rubidium <rubidium@openttd.org>
parents:
13609
diff
changeset
|
253 * @param right Right side of the box to draw in. |
13142
a37a85a415ad
(svn r17647) -Codechange: Moving widget array access to outside the function.
alberth <alberth@openttd.org>
parents:
13138
diff
changeset
|
254 * @param y Top of the box to draw in. |
11361
02313cc6114e
(svn r15711) -Codechange: lots of whitespace cleanup/fixes
rubidium <rubidium@openttd.org>
parents:
11084
diff
changeset
|
255 */ |
13621
495608777888
(svn r18145) -Codechange: pass the 'proper' left and right values to DrawVehicleInDepot
rubidium <rubidium@openttd.org>
parents:
13609
diff
changeset
|
256 void DrawVehicleInDepot(const Vehicle *v, int left, int right, int y) const |
9201
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
257 { |
12440
83a4c35ab350
(svn r16874) -Change: Give the number behind free wagon chains in depots the same meaning as for trains.
frosch <frosch@openttd.org>
parents:
12433
diff
changeset
|
258 bool free_wagon = false; |
13630
40489a4d0822
(svn r18154) -Codechange: let the depot window better scale with bigger fonts
rubidium <rubidium@openttd.org>
parents:
13628
diff
changeset
|
259 int sprite_y = y + (this->resize.step_height - GetVehicleHeight(v->type)) / 2; |
9201
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
260 |
13639
455a6f0ae773
(svn r18163) -Codechange: make the depot GUI RTL aware
rubidium <rubidium@openttd.org>
parents:
13633
diff
changeset
|
261 bool rtl = _dynlang.text_dir == TD_RTL; |
455a6f0ae773
(svn r18163) -Codechange: make the depot GUI RTL aware
rubidium <rubidium@openttd.org>
parents:
13633
diff
changeset
|
262 int image_left = rtl ? left + this->count_width : left + this->header_width; |
455a6f0ae773
(svn r18163) -Codechange: make the depot GUI RTL aware
rubidium <rubidium@openttd.org>
parents:
13633
diff
changeset
|
263 int image_right = rtl ? right - this->header_width : right - this->count_width; |
455a6f0ae773
(svn r18163) -Codechange: make the depot GUI RTL aware
rubidium <rubidium@openttd.org>
parents:
13633
diff
changeset
|
264 |
9201
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
265 switch (v->type) { |
12440
83a4c35ab350
(svn r16874) -Change: Give the number behind free wagon chains in depots the same meaning as for trains.
frosch <frosch@openttd.org>
parents:
12433
diff
changeset
|
266 case VEH_TRAIN: { |
83a4c35ab350
(svn r16874) -Change: Give the number behind free wagon chains in depots the same meaning as for trains.
frosch <frosch@openttd.org>
parents:
12433
diff
changeset
|
267 const Train *u = Train::From(v); |
83a4c35ab350
(svn r16874) -Change: Give the number behind free wagon chains in depots the same meaning as for trains.
frosch <frosch@openttd.org>
parents:
12433
diff
changeset
|
268 free_wagon = u->IsFreeWagon(); |
83a4c35ab350
(svn r16874) -Change: Give the number behind free wagon chains in depots the same meaning as for trains.
frosch <frosch@openttd.org>
parents:
12433
diff
changeset
|
269 |
83a4c35ab350
(svn r16874) -Change: Give the number behind free wagon chains in depots the same meaning as for trains.
frosch <frosch@openttd.org>
parents:
12433
diff
changeset
|
270 uint x_space = free_wagon ? TRAININFO_DEFAULT_VEHICLE_WIDTH : 0; |
15253
bd9b4d0ad9fe
(svn r19888) -Add [FS#3705]: Add highlighting of drag destination in depot gui (sbr).
alberth <alberth@openttd.org>
parents:
15172
diff
changeset
|
271 DrawTrainImage(u, image_left + (rtl ? 0 : x_space), image_right - (rtl ? x_space : 0), sprite_y - 1, |
bd9b4d0ad9fe
(svn r19888) -Add [FS#3705]: Add highlighting of drag destination in depot gui (sbr).
alberth <alberth@openttd.org>
parents:
15172
diff
changeset
|
272 this->sel, free_wagon ? 0 : this->hscroll.GetPosition(), this->vehicle_over); |
9201
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
273 |
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
274 /* Number of wagons relative to a standard length wagon (rounded up) */ |
15050
73f4e0e490b7
(svn r19670) -Codechange: Add CeilDiv() and RoundDiv() to simplify integer divisions with rounding.
frosch <frosch@openttd.org>
parents:
14409
diff
changeset
|
275 SetDParam(0, CeilDiv(u->tcache.cached_total_length, 8)); |
13639
455a6f0ae773
(svn r18163) -Codechange: make the depot GUI RTL aware
rubidium <rubidium@openttd.org>
parents:
13633
diff
changeset
|
276 DrawString(rtl ? left + WD_FRAMERECT_LEFT : right - this->count_width, rtl ? left + this->count_width : right - WD_FRAMERECT_RIGHT, y + (this->resize.step_height - FONT_HEIGHT_SMALL) / 2, STR_TINY_BLACK_COMA, TC_FROMSTRING, SA_RIGHT); // Draw the counter |
9201
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
277 break; |
12440
83a4c35ab350
(svn r16874) -Change: Give the number behind free wagon chains in depots the same meaning as for trains.
frosch <frosch@openttd.org>
parents:
12433
diff
changeset
|
278 } |
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
|
279 |
13639
455a6f0ae773
(svn r18163) -Codechange: make the depot GUI RTL aware
rubidium <rubidium@openttd.org>
parents:
13633
diff
changeset
|
280 case VEH_ROAD: DrawRoadVehImage( v, image_left, image_right, sprite_y, this->sel); break; |
455a6f0ae773
(svn r18163) -Codechange: make the depot GUI RTL aware
rubidium <rubidium@openttd.org>
parents:
13633
diff
changeset
|
281 case VEH_SHIP: DrawShipImage( v, image_left, image_right, sprite_y, this->sel); break; |
9201
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
282 case VEH_AIRCRAFT: { |
10056
7867701f63e4
(svn r14223) -Codechange: make GetSprite aware of the 4 different types of sprites: fonts, recolour, mapgen and normal sprites.
rubidium <rubidium@openttd.org>
parents:
9931
diff
changeset
|
283 const Sprite *spr = GetSprite(v->GetImage(DIR_W), ST_NORMAL); |
13639
455a6f0ae773
(svn r18163) -Codechange: make the depot GUI RTL aware
rubidium <rubidium@openttd.org>
parents:
13633
diff
changeset
|
284 DrawAircraftImage(v, image_left, image_right, |
9201
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
285 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
|
286 this->sel); |
15618
e4640748f223
(svn r20281) -Codechange: unify case scope closure + break coding style
rubidium <rubidium@openttd.org>
parents:
15496
diff
changeset
|
287 break; |
e4640748f223
(svn r20281) -Codechange: unify case scope closure + break coding style
rubidium <rubidium@openttd.org>
parents:
15496
diff
changeset
|
288 } |
9201
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
289 default: NOT_REACHED(); |
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
290 } |
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
291 |
13639
455a6f0ae773
(svn r18163) -Codechange: make the depot GUI RTL aware
rubidium <rubidium@openttd.org>
parents:
13633
diff
changeset
|
292 uint diff_x, diff_y; |
455a6f0ae773
(svn r18163) -Codechange: make the depot GUI RTL aware
rubidium <rubidium@openttd.org>
parents:
13633
diff
changeset
|
293 if (v->type == VEH_TRAIN || v->type == VEH_ROAD) { |
455a6f0ae773
(svn r18163) -Codechange: make the depot GUI RTL aware
rubidium <rubidium@openttd.org>
parents:
13633
diff
changeset
|
294 /* Arrange unitnumber and flag horizontally */ |
455a6f0ae773
(svn r18163) -Codechange: make the depot GUI RTL aware
rubidium <rubidium@openttd.org>
parents:
13633
diff
changeset
|
295 diff_x = this->flag_width + WD_FRAMERECT_LEFT; |
455a6f0ae773
(svn r18163) -Codechange: make the depot GUI RTL aware
rubidium <rubidium@openttd.org>
parents:
13633
diff
changeset
|
296 diff_y = (this->resize.step_height - this->flag_height) / 2 - 2; |
9201
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
297 } else { |
13639
455a6f0ae773
(svn r18163) -Codechange: make the depot GUI RTL aware
rubidium <rubidium@openttd.org>
parents:
13633
diff
changeset
|
298 /* Arrange unitnumber and flag vertically */ |
455a6f0ae773
(svn r18163) -Codechange: make the depot GUI RTL aware
rubidium <rubidium@openttd.org>
parents:
13633
diff
changeset
|
299 diff_x = WD_FRAMERECT_LEFT; |
455a6f0ae773
(svn r18163) -Codechange: make the depot GUI RTL aware
rubidium <rubidium@openttd.org>
parents:
13633
diff
changeset
|
300 diff_y = FONT_HEIGHT_NORMAL + WD_PAR_VSEP_NORMAL; |
455a6f0ae773
(svn r18163) -Codechange: make the depot GUI RTL aware
rubidium <rubidium@openttd.org>
parents:
13633
diff
changeset
|
301 } |
455a6f0ae773
(svn r18163) -Codechange: make the depot GUI RTL aware
rubidium <rubidium@openttd.org>
parents:
13633
diff
changeset
|
302 int text_left = rtl ? right - this->header_width - 1 : left + diff_x; |
455a6f0ae773
(svn r18163) -Codechange: make the depot GUI RTL aware
rubidium <rubidium@openttd.org>
parents:
13633
diff
changeset
|
303 int text_right = rtl ? right - diff_x : left + this->header_width - 1; |
9201
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
304 |
13639
455a6f0ae773
(svn r18163) -Codechange: make the depot GUI RTL aware
rubidium <rubidium@openttd.org>
parents:
13633
diff
changeset
|
305 if (free_wagon) { |
455a6f0ae773
(svn r18163) -Codechange: make the depot GUI RTL aware
rubidium <rubidium@openttd.org>
parents:
13633
diff
changeset
|
306 DrawString(text_left, text_right, y + 2, STR_DEPOT_NO_ENGINE); |
455a6f0ae773
(svn r18163) -Codechange: make the depot GUI RTL aware
rubidium <rubidium@openttd.org>
parents:
13633
diff
changeset
|
307 } else { |
455a6f0ae773
(svn r18163) -Codechange: make the depot GUI RTL aware
rubidium <rubidium@openttd.org>
parents:
13633
diff
changeset
|
308 DrawSprite((v->vehstatus & VS_STOPPED) ? SPR_FLAG_VEH_STOPPED : SPR_FLAG_VEH_RUNNING, PAL_NONE, rtl ? right - this->flag_width : left + WD_FRAMERECT_LEFT, y + diff_y); |
12440
83a4c35ab350
(svn r16874) -Change: Give the number behind free wagon chains in depots the same meaning as for trains.
frosch <frosch@openttd.org>
parents:
12433
diff
changeset
|
309 |
83a4c35ab350
(svn r16874) -Change: Give the number behind free wagon chains in depots the same meaning as for trains.
frosch <frosch@openttd.org>
parents:
12433
diff
changeset
|
310 SetDParam(0, v->unitnumber); |
13639
455a6f0ae773
(svn r18163) -Codechange: make the depot GUI RTL aware
rubidium <rubidium@openttd.org>
parents:
13633
diff
changeset
|
311 DrawString(text_left, text_right, y + 2, (uint16)(v->max_age - DAYS_IN_LEAP_YEAR) >= v->age ? STR_BLACK_COMMA : STR_RED_COMMA); |
12440
83a4c35ab350
(svn r16874) -Change: Give the number behind free wagon chains in depots the same meaning as for trains.
frosch <frosch@openttd.org>
parents:
12433
diff
changeset
|
312 } |
9201
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
313 } |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
314 |
13144
99a2d7dde8ee
(svn r17649) -Codechange: Depot gui uses pure nested widgets.
alberth <alberth@openttd.org>
parents:
13143
diff
changeset
|
315 void DrawWidget(const Rect &r, int widget) const |
9201
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
316 { |
13144
99a2d7dde8ee
(svn r17649) -Codechange: Depot gui uses pure nested widgets.
alberth <alberth@openttd.org>
parents:
13143
diff
changeset
|
317 if (widget != DEPOT_WIDGET_MATRIX) return; |
99a2d7dde8ee
(svn r17649) -Codechange: Depot gui uses pure nested widgets.
alberth <alberth@openttd.org>
parents:
13143
diff
changeset
|
318 |
13639
455a6f0ae773
(svn r18163) -Codechange: make the depot GUI RTL aware
rubidium <rubidium@openttd.org>
parents:
13633
diff
changeset
|
319 bool rtl = _dynlang.text_dir == TD_RTL; |
455a6f0ae773
(svn r18163) -Codechange: make the depot GUI RTL aware
rubidium <rubidium@openttd.org>
parents:
13633
diff
changeset
|
320 |
9201
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
321 /* Set the row and number of boxes in each row based on the number of boxes drawn in the matrix */ |
13144
99a2d7dde8ee
(svn r17649) -Codechange: Depot gui uses pure nested widgets.
alberth <alberth@openttd.org>
parents:
13143
diff
changeset
|
322 uint16 mat_data = this->GetWidget<NWidgetCore>(DEPOT_WIDGET_MATRIX)->widget_data; |
99a2d7dde8ee
(svn r17649) -Codechange: Depot gui uses pure nested widgets.
alberth <alberth@openttd.org>
parents:
13143
diff
changeset
|
323 uint16 rows_in_display = GB(mat_data, MAT_ROW_START, MAT_ROW_BITS); |
99a2d7dde8ee
(svn r17649) -Codechange: Depot gui uses pure nested widgets.
alberth <alberth@openttd.org>
parents:
13143
diff
changeset
|
324 uint16 boxes_in_each_row = GB(mat_data, MAT_COL_START, MAT_COL_BITS); |
9201
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
325 |
13144
99a2d7dde8ee
(svn r17649) -Codechange: Depot gui uses pure nested widgets.
alberth <alberth@openttd.org>
parents:
13143
diff
changeset
|
326 uint16 num = this->vscroll.GetPosition() * boxes_in_each_row; |
99a2d7dde8ee
(svn r17649) -Codechange: Depot gui uses pure nested widgets.
alberth <alberth@openttd.org>
parents:
13143
diff
changeset
|
327 int maxval = min(this->vehicle_list.Length(), num + (rows_in_display * boxes_in_each_row)); |
13621
495608777888
(svn r18145) -Codechange: pass the 'proper' left and right values to DrawVehicleInDepot
rubidium <rubidium@openttd.org>
parents:
13609
diff
changeset
|
328 int y; |
495608777888
(svn r18145) -Codechange: pass the 'proper' left and right values to DrawVehicleInDepot
rubidium <rubidium@openttd.org>
parents:
13609
diff
changeset
|
329 for (y = r.top + 1; num < maxval; y += this->resize.step_height) { // Draw the rows |
13639
455a6f0ae773
(svn r18163) -Codechange: make the depot GUI RTL aware
rubidium <rubidium@openttd.org>
parents:
13633
diff
changeset
|
330 for (byte i = 0; i < boxes_in_each_row && num < maxval; i++, num++) { |
13144
99a2d7dde8ee
(svn r17649) -Codechange: Depot gui uses pure nested widgets.
alberth <alberth@openttd.org>
parents:
13143
diff
changeset
|
331 /* Draw all vehicles in the current row */ |
99a2d7dde8ee
(svn r17649) -Codechange: Depot gui uses pure nested widgets.
alberth <alberth@openttd.org>
parents:
13143
diff
changeset
|
332 const Vehicle *v = this->vehicle_list[num]; |
13639
455a6f0ae773
(svn r18163) -Codechange: make the depot GUI RTL aware
rubidium <rubidium@openttd.org>
parents:
13633
diff
changeset
|
333 if (boxes_in_each_row == 1) { |
455a6f0ae773
(svn r18163) -Codechange: make the depot GUI RTL aware
rubidium <rubidium@openttd.org>
parents:
13633
diff
changeset
|
334 this->DrawVehicleInDepot(v, r.left, r.right, y); |
455a6f0ae773
(svn r18163) -Codechange: make the depot GUI RTL aware
rubidium <rubidium@openttd.org>
parents:
13633
diff
changeset
|
335 } else { |
455a6f0ae773
(svn r18163) -Codechange: make the depot GUI RTL aware
rubidium <rubidium@openttd.org>
parents:
13633
diff
changeset
|
336 int x = r.left + (rtl ? (boxes_in_each_row - i - 1) : i) * this->resize.step_width; |
455a6f0ae773
(svn r18163) -Codechange: make the depot GUI RTL aware
rubidium <rubidium@openttd.org>
parents:
13633
diff
changeset
|
337 this->DrawVehicleInDepot(v, x, x + this->resize.step_width - 1, y); |
455a6f0ae773
(svn r18163) -Codechange: make the depot GUI RTL aware
rubidium <rubidium@openttd.org>
parents:
13633
diff
changeset
|
338 } |
9201
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
339 } |
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
340 } |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
341 |
13144
99a2d7dde8ee
(svn r17649) -Codechange: Depot gui uses pure nested widgets.
alberth <alberth@openttd.org>
parents:
13143
diff
changeset
|
342 maxval = min(this->vehicle_list.Length() + this->wagon_list.Length(), (this->vscroll.GetPosition() * boxes_in_each_row) + (rows_in_display * boxes_in_each_row)); |
99a2d7dde8ee
(svn r17649) -Codechange: Depot gui uses pure nested widgets.
alberth <alberth@openttd.org>
parents:
13143
diff
changeset
|
343 |
99a2d7dde8ee
(svn r17649) -Codechange: Depot gui uses pure nested widgets.
alberth <alberth@openttd.org>
parents:
13143
diff
changeset
|
344 /* draw the train wagons, that do not have an engine in front */ |
13885
22d1d919b00e
(svn r18414) -Fix: In the depot window, 'free' wagons were not drawn resize.step_height apart
peter1138 <peter1138@openttd.org>
parents:
13796
diff
changeset
|
345 for (; num < maxval; num++, y += this->resize.step_height) { |
13144
99a2d7dde8ee
(svn r17649) -Codechange: Depot gui uses pure nested widgets.
alberth <alberth@openttd.org>
parents:
13143
diff
changeset
|
346 const Vehicle *v = this->wagon_list[num - this->vehicle_list.Length()]; |
13621
495608777888
(svn r18145) -Codechange: pass the 'proper' left and right values to DrawVehicleInDepot
rubidium <rubidium@openttd.org>
parents:
13609
diff
changeset
|
347 this->DrawVehicleInDepot(v, r.left, r.right, y); |
13144
99a2d7dde8ee
(svn r17649) -Codechange: Depot gui uses pure nested widgets.
alberth <alberth@openttd.org>
parents:
13143
diff
changeset
|
348 } |
99a2d7dde8ee
(svn r17649) -Codechange: Depot gui uses pure nested widgets.
alberth <alberth@openttd.org>
parents:
13143
diff
changeset
|
349 } |
99a2d7dde8ee
(svn r17649) -Codechange: Depot gui uses pure nested widgets.
alberth <alberth@openttd.org>
parents:
13143
diff
changeset
|
350 |
99a2d7dde8ee
(svn r17649) -Codechange: Depot gui uses pure nested widgets.
alberth <alberth@openttd.org>
parents:
13143
diff
changeset
|
351 void SetStringParameters(int widget) const |
99a2d7dde8ee
(svn r17649) -Codechange: Depot gui uses pure nested widgets.
alberth <alberth@openttd.org>
parents:
13143
diff
changeset
|
352 { |
99a2d7dde8ee
(svn r17649) -Codechange: Depot gui uses pure nested widgets.
alberth <alberth@openttd.org>
parents:
13143
diff
changeset
|
353 if (widget != DEPOT_WIDGET_CAPTION) return; |
99a2d7dde8ee
(svn r17649) -Codechange: Depot gui uses pure nested widgets.
alberth <alberth@openttd.org>
parents:
13143
diff
changeset
|
354 |
9201
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
355 /* locate the depot struct */ |
13143
dd57dca0d7c7
(svn r17648) -Codechange: Move type initialization and widget disabling to the constructor.
alberth <alberth@openttd.org>
parents:
13142
diff
changeset
|
356 TileIndex tile = this->window_number; |
15167
2ef5704286b9
(svn r19796) -Codechange: introduce and use a {DEPOT} string command
rubidium <rubidium@openttd.org>
parents:
15088
diff
changeset
|
357 SetDParam(0, this->type); |
2ef5704286b9
(svn r19796) -Codechange: introduce and use a {DEPOT} string command
rubidium <rubidium@openttd.org>
parents:
15088
diff
changeset
|
358 SetDParam(1, (this->type == VEH_AIRCRAFT) ? GetStationIndex(tile) : GetDepotIndex(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
|
359 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
360 |
9201
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
361 struct GetDepotVehiclePtData { |
9344
5940dd28c40d
(svn r13240) -Codechange: More const-ness for GUI code.
peter1138 <peter1138@openttd.org>
parents:
9343
diff
changeset
|
362 const Vehicle *head; |
5940dd28c40d
(svn r13240) -Codechange: More const-ness for GUI code.
peter1138 <peter1138@openttd.org>
parents:
9343
diff
changeset
|
363 const Vehicle *wagon; |
9201
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 |
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
366 enum DepotGUIAction { |
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
367 MODE_ERROR, |
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
368 MODE_DRAG_VEHICLE, |
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
369 MODE_SHOW_VEHICLE, |
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
370 MODE_START_STOP, |
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
371 }; |
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
372 |
9344
5940dd28c40d
(svn r13240) -Codechange: More const-ness for GUI code.
peter1138 <peter1138@openttd.org>
parents:
9343
diff
changeset
|
373 DepotGUIAction GetVehicleFromDepotWndPt(int x, int y, const Vehicle **veh, GetDepotVehiclePtData *d) const |
9201
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
374 { |
13639
455a6f0ae773
(svn r18163) -Codechange: make the depot GUI RTL aware
rubidium <rubidium@openttd.org>
parents:
13633
diff
changeset
|
375 const NWidgetCore *matrix_widget = this->GetWidget<NWidgetCore>(DEPOT_WIDGET_MATRIX); |
455a6f0ae773
(svn r18163) -Codechange: make the depot GUI RTL aware
rubidium <rubidium@openttd.org>
parents:
13633
diff
changeset
|
376 /* In case of RTL the widgets are swapped as a whole */ |
455a6f0ae773
(svn r18163) -Codechange: make the depot GUI RTL aware
rubidium <rubidium@openttd.org>
parents:
13633
diff
changeset
|
377 if (_dynlang.text_dir == TD_RTL) x = matrix_widget->current_x - x; |
455a6f0ae773
(svn r18163) -Codechange: make the depot GUI RTL aware
rubidium <rubidium@openttd.org>
parents:
13633
diff
changeset
|
378 |
13630
40489a4d0822
(svn r18154) -Codechange: let the depot window better scale with bigger fonts
rubidium <rubidium@openttd.org>
parents:
13628
diff
changeset
|
379 uint xt = 0, xm = 0, ym = 0; |
9201
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
380 if (this->type == VEH_TRAIN) { |
13630
40489a4d0822
(svn r18154) -Codechange: let the depot window better scale with bigger fonts
rubidium <rubidium@openttd.org>
parents:
13628
diff
changeset
|
381 xm = x; |
9201
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
382 } else { |
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
383 xt = x / this->resize.step_width; |
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
384 xm = x % this->resize.step_width; |
12877
e63af9c28034
(svn r17369) -Codechange: make the depot, group and industry GUIs use the scrollbar wrappers
rubidium <rubidium@openttd.org>
parents:
12876
diff
changeset
|
385 if (xt >= this->hscroll.GetCapacity()) return MODE_ERROR; |
9201
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
386 } |
13630
40489a4d0822
(svn r18154) -Codechange: let the depot window better scale with bigger fonts
rubidium <rubidium@openttd.org>
parents:
13628
diff
changeset
|
387 ym = y % this->resize.step_height; |
9201
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
388 |
13324
82e58acd7cec
(svn r17833) -Codechange: Depot gui should use relative widget coordinates for clicking.
alberth <alberth@openttd.org>
parents:
13321
diff
changeset
|
389 uint row = y / this->resize.step_height; |
12877
e63af9c28034
(svn r17369) -Codechange: make the depot, group and industry GUIs use the scrollbar wrappers
rubidium <rubidium@openttd.org>
parents:
12876
diff
changeset
|
390 if (row >= this->vscroll.GetCapacity()) return MODE_ERROR; |
9201
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
391 |
13639
455a6f0ae773
(svn r18163) -Codechange: make the depot GUI RTL aware
rubidium <rubidium@openttd.org>
parents:
13633
diff
changeset
|
392 uint boxes_in_each_row = GB(matrix_widget->widget_data, MAT_COL_START, MAT_COL_BITS); |
13630
40489a4d0822
(svn r18154) -Codechange: let the depot window better scale with bigger fonts
rubidium <rubidium@openttd.org>
parents:
13628
diff
changeset
|
393 uint pos = ((row + this->vscroll.GetPosition()) * boxes_in_each_row) + xt; |
9201
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
394 |
13630
40489a4d0822
(svn r18154) -Codechange: let the depot window better scale with bigger fonts
rubidium <rubidium@openttd.org>
parents:
13628
diff
changeset
|
395 if (this->vehicle_list.Length() + this->wagon_list.Length() <= pos) { |
40489a4d0822
(svn r18154) -Codechange: let the depot window better scale with bigger fonts
rubidium <rubidium@openttd.org>
parents:
13628
diff
changeset
|
396 /* Clicking on 'line' / 'block' without a vehicle */ |
9201
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
397 if (this->type == VEH_TRAIN) { |
13630
40489a4d0822
(svn r18154) -Codechange: let the depot window better scale with bigger fonts
rubidium <rubidium@openttd.org>
parents:
13628
diff
changeset
|
398 /* End the dragging */ |
9201
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
399 d->head = NULL; |
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
400 d->wagon = NULL; |
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
401 return MODE_DRAG_VEHICLE; |
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
402 } else { |
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
403 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
|
404 } |
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 |
13639
455a6f0ae773
(svn r18163) -Codechange: make the depot GUI RTL aware
rubidium <rubidium@openttd.org>
parents:
13633
diff
changeset
|
407 bool wagon = false; |
13630
40489a4d0822
(svn r18154) -Codechange: let the depot window better scale with bigger fonts
rubidium <rubidium@openttd.org>
parents:
13628
diff
changeset
|
408 if (this->vehicle_list.Length() > pos) { |
9351
feaf9bae7580
(svn r13248) -Codechange: Use VehicleList for depot GUI.
peter1138 <peter1138@openttd.org>
parents:
9344
diff
changeset
|
409 *veh = this->vehicle_list[pos]; |
13630
40489a4d0822
(svn r18154) -Codechange: let the depot window better scale with bigger fonts
rubidium <rubidium@openttd.org>
parents:
13628
diff
changeset
|
410 /* Skip vehicles that are scrolled off the list */ |
40489a4d0822
(svn r18154) -Codechange: let the depot window better scale with bigger fonts
rubidium <rubidium@openttd.org>
parents:
13628
diff
changeset
|
411 x += this->hscroll.GetPosition(); |
9201
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
412 } else { |
9351
feaf9bae7580
(svn r13248) -Codechange: Use VehicleList for depot GUI.
peter1138 <peter1138@openttd.org>
parents:
9344
diff
changeset
|
413 pos -= this->vehicle_list.Length(); |
feaf9bae7580
(svn r13248) -Codechange: Use VehicleList for depot GUI.
peter1138 <peter1138@openttd.org>
parents:
9344
diff
changeset
|
414 *veh = this->wagon_list[pos]; |
9201
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
415 /* free wagons don't have an initial loco. */ |
12433
c3588e7cb8f6
(svn r16867) -Feature(ette): Turn variable 0E/8E (vertical offset for trains in depot) and variable 1E/9E bit 3 (wagon width in depot) into grf-local variables.
frosch <frosch@openttd.org>
parents:
12411
diff
changeset
|
416 x -= VEHICLEINFO_FULL_VEHICLE_WIDTH; |
13639
455a6f0ae773
(svn r18163) -Codechange: make the depot GUI RTL aware
rubidium <rubidium@openttd.org>
parents:
13633
diff
changeset
|
417 wagon = true; |
9201
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
418 } |
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
419 |
13630
40489a4d0822
(svn r18154) -Codechange: let the depot window better scale with bigger fonts
rubidium <rubidium@openttd.org>
parents:
13628
diff
changeset
|
420 const Train *v = NULL; |
40489a4d0822
(svn r18154) -Codechange: let the depot window better scale with bigger fonts
rubidium <rubidium@openttd.org>
parents:
13628
diff
changeset
|
421 if (this->type == VEH_TRAIN) { |
40489a4d0822
(svn r18154) -Codechange: let the depot window better scale with bigger fonts
rubidium <rubidium@openttd.org>
parents:
13628
diff
changeset
|
422 v = Train::From(*veh); |
40489a4d0822
(svn r18154) -Codechange: let the depot window better scale with bigger fonts
rubidium <rubidium@openttd.org>
parents:
13628
diff
changeset
|
423 d->head = d->wagon = v; |
40489a4d0822
(svn r18154) -Codechange: let the depot window better scale with bigger fonts
rubidium <rubidium@openttd.org>
parents:
13628
diff
changeset
|
424 } |
9201
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
425 |
13630
40489a4d0822
(svn r18154) -Codechange: let the depot window better scale with bigger fonts
rubidium <rubidium@openttd.org>
parents:
13628
diff
changeset
|
426 if (xm <= this->header_width) { |
40489a4d0822
(svn r18154) -Codechange: let the depot window better scale with bigger fonts
rubidium <rubidium@openttd.org>
parents:
13628
diff
changeset
|
427 switch (this->type) { |
40489a4d0822
(svn r18154) -Codechange: let the depot window better scale with bigger fonts
rubidium <rubidium@openttd.org>
parents:
13628
diff
changeset
|
428 case VEH_TRAIN: |
13639
455a6f0ae773
(svn r18163) -Codechange: make the depot GUI RTL aware
rubidium <rubidium@openttd.org>
parents:
13633
diff
changeset
|
429 if (wagon) return MODE_ERROR; |
13630
40489a4d0822
(svn r18154) -Codechange: let the depot window better scale with bigger fonts
rubidium <rubidium@openttd.org>
parents:
13628
diff
changeset
|
430 case VEH_ROAD: |
40489a4d0822
(svn r18154) -Codechange: let the depot window better scale with bigger fonts
rubidium <rubidium@openttd.org>
parents:
13628
diff
changeset
|
431 if (xm <= this->flag_width) return MODE_START_STOP; |
40489a4d0822
(svn r18154) -Codechange: let the depot window better scale with bigger fonts
rubidium <rubidium@openttd.org>
parents:
13628
diff
changeset
|
432 break; |
9201
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
433 |
13630
40489a4d0822
(svn r18154) -Codechange: let the depot window better scale with bigger fonts
rubidium <rubidium@openttd.org>
parents:
13628
diff
changeset
|
434 case VEH_SHIP: |
40489a4d0822
(svn r18154) -Codechange: let the depot window better scale with bigger fonts
rubidium <rubidium@openttd.org>
parents:
13628
diff
changeset
|
435 case VEH_AIRCRAFT: |
40489a4d0822
(svn r18154) -Codechange: let the depot window better scale with bigger fonts
rubidium <rubidium@openttd.org>
parents:
13628
diff
changeset
|
436 if (xm <= this->flag_width && ym >= (uint)(FONT_HEIGHT_NORMAL + WD_PAR_VSEP_NORMAL)) return MODE_START_STOP; |
40489a4d0822
(svn r18154) -Codechange: let the depot window better scale with bigger fonts
rubidium <rubidium@openttd.org>
parents:
13628
diff
changeset
|
437 break; |
9201
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
438 |
13630
40489a4d0822
(svn r18154) -Codechange: let the depot window better scale with bigger fonts
rubidium <rubidium@openttd.org>
parents:
13628
diff
changeset
|
439 default: NOT_REACHED(); |
12387
ebf5d196267b
(svn r16817) -Codechange: Scroll depots horizontally in pixels instead of 1/8 vehicle length.
frosch <frosch@openttd.org>
parents:
12374
diff
changeset
|
440 } |
13630
40489a4d0822
(svn r18154) -Codechange: let the depot window better scale with bigger fonts
rubidium <rubidium@openttd.org>
parents:
13628
diff
changeset
|
441 return MODE_SHOW_VEHICLE; |
40489a4d0822
(svn r18154) -Codechange: let the depot window better scale with bigger fonts
rubidium <rubidium@openttd.org>
parents:
13628
diff
changeset
|
442 } |
9201
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
443 |
13630
40489a4d0822
(svn r18154) -Codechange: let the depot window better scale with bigger fonts
rubidium <rubidium@openttd.org>
parents:
13628
diff
changeset
|
444 if (this->type != VEH_TRAIN) return MODE_DRAG_VEHICLE; |
40489a4d0822
(svn r18154) -Codechange: let the depot window better scale with bigger fonts
rubidium <rubidium@openttd.org>
parents:
13628
diff
changeset
|
445 |
13639
455a6f0ae773
(svn r18163) -Codechange: make the depot GUI RTL aware
rubidium <rubidium@openttd.org>
parents:
13633
diff
changeset
|
446 /* Clicking on the counter */ |
455a6f0ae773
(svn r18163) -Codechange: make the depot GUI RTL aware
rubidium <rubidium@openttd.org>
parents:
13633
diff
changeset
|
447 if (xm >= matrix_widget->current_x - this->count_width) return wagon ? MODE_ERROR : MODE_SHOW_VEHICLE; |
455a6f0ae773
(svn r18163) -Codechange: make the depot GUI RTL aware
rubidium <rubidium@openttd.org>
parents:
13633
diff
changeset
|
448 |
13630
40489a4d0822
(svn r18154) -Codechange: let the depot window better scale with bigger fonts
rubidium <rubidium@openttd.org>
parents:
13628
diff
changeset
|
449 /* Account for the header */ |
40489a4d0822
(svn r18154) -Codechange: let the depot window better scale with bigger fonts
rubidium <rubidium@openttd.org>
parents:
13628
diff
changeset
|
450 x -= this->header_width; |
9201
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
451 |
13630
40489a4d0822
(svn r18154) -Codechange: let the depot window better scale with bigger fonts
rubidium <rubidium@openttd.org>
parents:
13628
diff
changeset
|
452 /* find the vehicle in this row that was clicked */ |
40489a4d0822
(svn r18154) -Codechange: let the depot window better scale with bigger fonts
rubidium <rubidium@openttd.org>
parents:
13628
diff
changeset
|
453 for (; v != NULL; v = v->Next()) { |
40489a4d0822
(svn r18154) -Codechange: let the depot window better scale with bigger fonts
rubidium <rubidium@openttd.org>
parents:
13628
diff
changeset
|
454 x -= v->GetDisplayImageWidth(); |
40489a4d0822
(svn r18154) -Codechange: let the depot window better scale with bigger fonts
rubidium <rubidium@openttd.org>
parents:
13628
diff
changeset
|
455 if (x < 0) break; |
40489a4d0822
(svn r18154) -Codechange: let the depot window better scale with bigger fonts
rubidium <rubidium@openttd.org>
parents:
13628
diff
changeset
|
456 } |
9201
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
457 |
13630
40489a4d0822
(svn r18154) -Codechange: let the depot window better scale with bigger fonts
rubidium <rubidium@openttd.org>
parents:
13628
diff
changeset
|
458 d->wagon = (v != NULL ? v->GetFirstEnginePart() : NULL); |
9201
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
459 |
13630
40489a4d0822
(svn r18154) -Codechange: let the depot window better scale with bigger fonts
rubidium <rubidium@openttd.org>
parents:
13628
diff
changeset
|
460 return MODE_DRAG_VEHICLE; |
9201
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
461 } |
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
462 |
15620
f8e9a3f0c140
(svn r20283) -Codechange: Unify start of doygen comments.
frosch <frosch@openttd.org>
parents:
15618
diff
changeset
|
463 /** |
f8e9a3f0c140
(svn r20283) -Codechange: Unify start of doygen comments.
frosch <frosch@openttd.org>
parents:
15618
diff
changeset
|
464 * Handle click in the depot matrix. |
13324
82e58acd7cec
(svn r17833) -Codechange: Depot gui should use relative widget coordinates for clicking.
alberth <alberth@openttd.org>
parents:
13321
diff
changeset
|
465 * @param x Horizontal position in the matrix widget in pixels. |
82e58acd7cec
(svn r17833) -Codechange: Depot gui should use relative widget coordinates for clicking.
alberth <alberth@openttd.org>
parents:
13321
diff
changeset
|
466 * @param y Vertical position in the matrix widget in pixels. |
82e58acd7cec
(svn r17833) -Codechange: Depot gui should use relative widget coordinates for clicking.
alberth <alberth@openttd.org>
parents:
13321
diff
changeset
|
467 */ |
9201
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
468 void DepotClick(int x, int y) |
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
469 { |
9213
d288bb9876c7
(svn r13079) -Fix: certain compilers give false warning about uninitialized variable
smatz <smatz@openttd.org>
parents:
9203
diff
changeset
|
470 GetDepotVehiclePtData gdvp = { NULL, NULL }; |
9344
5940dd28c40d
(svn r13240) -Codechange: More const-ness for GUI code.
peter1138 <peter1138@openttd.org>
parents:
9343
diff
changeset
|
471 const Vehicle *v = NULL; |
9201
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
472 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
|
473 |
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
474 /* share / copy orders */ |
11702
cdaad565efe5
(svn r16088) -Codechange: merge HighLightStyle and ViewportHighlightMode as they are basically the same thing
rubidium <rubidium@openttd.org>
parents:
11524
diff
changeset
|
475 if (_thd.place_mode != HT_NONE && mode != MODE_ERROR) { |
9201
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
476 _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
|
477 return; |
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
478 } |
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
479 |
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
480 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
|
481 |
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
482 switch (mode) { |
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
483 case MODE_ERROR: // invalid |
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
484 return; |
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
485 |
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
486 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
|
487 VehicleID sel = this->sel; |
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 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
|
490 this->sel = INVALID_VEHICLE; |
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
491 TrainDepotMoveVehicle(v, sel, gdvp.head); |
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
492 } else if (v != NULL) { |
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
493 int image = v->GetImage(DIR_W); |
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
494 |
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
495 this->sel = v->index; |
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
496 this->SetDirty(); |
11702
cdaad565efe5
(svn r16088) -Codechange: merge HighLightStyle and ViewportHighlightMode as they are basically the same thing
rubidium <rubidium@openttd.org>
parents:
11524
diff
changeset
|
497 SetObjectToPlaceWnd(image, GetVehiclePalette(v), HT_DRAG, this); |
9670
cbf60a2ecf07
(svn r13759) -Fix [FS#2147]: selecting non-full length vehicles in the depot gui would place the "mouse pointer" out of the center of the vehicle making it hard to "aim".
rubidium <rubidium@openttd.org>
parents:
9396
diff
changeset
|
498 |
cbf60a2ecf07
(svn r13759) -Fix [FS#2147]: selecting non-full length vehicles in the depot gui would place the "mouse pointer" out of the center of the vehicle making it hard to "aim".
rubidium <rubidium@openttd.org>
parents:
9396
diff
changeset
|
499 switch (v->type) { |
cbf60a2ecf07
(svn r13759) -Fix [FS#2147]: selecting non-full length vehicles in the depot gui would place the "mouse pointer" out of the center of the vehicle making it hard to "aim".
rubidium <rubidium@openttd.org>
parents:
9396
diff
changeset
|
500 case VEH_TRAIN: |
12114
f020ec6be498
(svn r16527) -Codechange: use static member functions instead of simple casts when converting Vehicle to specialised vehicle types. Includes safety check
smatz <smatz@openttd.org>
parents:
12027
diff
changeset
|
501 _cursor.short_vehicle_offset = 16 - Train::From(v)->tcache.cached_veh_length * 2; |
9670
cbf60a2ecf07
(svn r13759) -Fix [FS#2147]: selecting non-full length vehicles in the depot gui would place the "mouse pointer" out of the center of the vehicle making it hard to "aim".
rubidium <rubidium@openttd.org>
parents:
9396
diff
changeset
|
502 break; |
cbf60a2ecf07
(svn r13759) -Fix [FS#2147]: selecting non-full length vehicles in the depot gui would place the "mouse pointer" out of the center of the vehicle making it hard to "aim".
rubidium <rubidium@openttd.org>
parents:
9396
diff
changeset
|
503 |
cbf60a2ecf07
(svn r13759) -Fix [FS#2147]: selecting non-full length vehicles in the depot gui would place the "mouse pointer" out of the center of the vehicle making it hard to "aim".
rubidium <rubidium@openttd.org>
parents:
9396
diff
changeset
|
504 case VEH_ROAD: |
12114
f020ec6be498
(svn r16527) -Codechange: use static member functions instead of simple casts when converting Vehicle to specialised vehicle types. Includes safety check
smatz <smatz@openttd.org>
parents:
12027
diff
changeset
|
505 _cursor.short_vehicle_offset = 16 - RoadVehicle::From(v)->rcache.cached_veh_length * 2; |
9670
cbf60a2ecf07
(svn r13759) -Fix [FS#2147]: selecting non-full length vehicles in the depot gui would place the "mouse pointer" out of the center of the vehicle making it hard to "aim".
rubidium <rubidium@openttd.org>
parents:
9396
diff
changeset
|
506 break; |
cbf60a2ecf07
(svn r13759) -Fix [FS#2147]: selecting non-full length vehicles in the depot gui would place the "mouse pointer" out of the center of the vehicle making it hard to "aim".
rubidium <rubidium@openttd.org>
parents:
9396
diff
changeset
|
507 |
cbf60a2ecf07
(svn r13759) -Fix [FS#2147]: selecting non-full length vehicles in the depot gui would place the "mouse pointer" out of the center of the vehicle making it hard to "aim".
rubidium <rubidium@openttd.org>
parents:
9396
diff
changeset
|
508 default: |
cbf60a2ecf07
(svn r13759) -Fix [FS#2147]: selecting non-full length vehicles in the depot gui would place the "mouse pointer" out of the center of the vehicle making it hard to "aim".
rubidium <rubidium@openttd.org>
parents:
9396
diff
changeset
|
509 _cursor.short_vehicle_offset = 0; |
cbf60a2ecf07
(svn r13759) -Fix [FS#2147]: selecting non-full length vehicles in the depot gui would place the "mouse pointer" out of the center of the vehicle making it hard to "aim".
rubidium <rubidium@openttd.org>
parents:
9396
diff
changeset
|
510 break; |
cbf60a2ecf07
(svn r13759) -Fix [FS#2147]: selecting non-full length vehicles in the depot gui would place the "mouse pointer" out of the center of the vehicle making it hard to "aim".
rubidium <rubidium@openttd.org>
parents:
9396
diff
changeset
|
511 } |
9201
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
512 _cursor.vehchain = _ctrl_pressed; |
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
513 } |
15618
e4640748f223
(svn r20281) -Codechange: unify case scope closure + break coding style
rubidium <rubidium@openttd.org>
parents:
15496
diff
changeset
|
514 break; |
e4640748f223
(svn r20281) -Codechange: unify case scope closure + break coding style
rubidium <rubidium@openttd.org>
parents:
15496
diff
changeset
|
515 } |
9201
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
516 |
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
517 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
|
518 ShowVehicleViewWindow(v); |
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
519 break; |
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
520 |
15084
d2731cec52ab
(svn r19710) -Codechange: deduplicate GUI code for starting/stopping vehicles
smatz <smatz@openttd.org>
parents:
15050
diff
changeset
|
521 case MODE_START_STOP: // click start/stop flag |
15088
a63b4234140f
(svn r19714) -Feature: ctrl+click on a vehicle to start/stop it
smatz <smatz@openttd.org>
parents:
15084
diff
changeset
|
522 StartStopVehicle(v, false); |
15084
d2731cec52ab
(svn r19710) -Codechange: deduplicate GUI code for starting/stopping vehicles
smatz <smatz@openttd.org>
parents:
15050
diff
changeset
|
523 break; |
9201
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 default: NOT_REACHED(); |
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
526 } |
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
527 } |
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
528 |
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
529 /** |
11361
02313cc6114e
(svn r15711) -Codechange: lots of whitespace cleanup/fixes
rubidium <rubidium@openttd.org>
parents:
11084
diff
changeset
|
530 * Clones a vehicle |
02313cc6114e
(svn r15711) -Codechange: lots of whitespace cleanup/fixes
rubidium <rubidium@openttd.org>
parents:
11084
diff
changeset
|
531 * @param *v is the original vehicle to clone |
02313cc6114e
(svn r15711) -Codechange: lots of whitespace cleanup/fixes
rubidium <rubidium@openttd.org>
parents:
11084
diff
changeset
|
532 */ |
12390
cca34a3de96e
(svn r16820) -Codechange: remove unused parameter in HandleCloneVehClick()
smatz <smatz@openttd.org>
parents:
12387
diff
changeset
|
533 void HandleCloneVehClick(const Vehicle *v) |
9201
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
534 { |
12483
84df0c285bc4
(svn r16920) -Codechange: shuffle some strings around to simplify looking up vehicle type specific strings for a specific message
rubidium <rubidium@openttd.org>
parents:
12482
diff
changeset
|
535 if (v == NULL || !IsCompanyBuildableVehicleType(v)) return; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
536 |
9201
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
537 if (!v->IsPrimaryVehicle()) { |
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
538 v = v->First(); |
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
539 /* Do nothing when clicking on a train in depot with no loc attached */ |
12300
7ec79afe8c18
(svn r16717) -Codechange: make IsFrontEngine() member of Train
smatz <smatz@openttd.org>
parents:
12263
diff
changeset
|
540 if (v->type == VEH_TRAIN && !Train::From(v)->IsFrontEngine()) return; |
9201
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
541 } |
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
542 |
12953
045a6264ea5b
(svn r17446) -Codechange: rename BUILD with BUY for strings that are about building (in the future buying) vehicles.
rubidium <rubidium@openttd.org>
parents:
12877
diff
changeset
|
543 DoCommandP(this->window_number, v->index, _ctrl_pressed ? 1 : 0, CMD_CLONE_VEHICLE | CMD_MSG(STR_ERROR_CAN_T_BUY_TRAIN + v->type), CcCloneVehicle); |
9201
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
544 |
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
545 ResetObjectToPlace(); |
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
546 } |
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
547 |
13144
99a2d7dde8ee
(svn r17649) -Codechange: Depot gui uses pure nested widgets.
alberth <alberth@openttd.org>
parents:
13143
diff
changeset
|
548 /* Function to set up vehicle specific widgets (mainly sprites and strings). |
9201
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
549 * Only use this if it's the same widget, that's used for more than one vehicle type and it needs different text/sprites |
13144
99a2d7dde8ee
(svn r17649) -Codechange: Depot gui uses pure nested widgets.
alberth <alberth@openttd.org>
parents:
13143
diff
changeset
|
550 * 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 nested widget array |
9201
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
551 */ |
13144
99a2d7dde8ee
(svn r17649) -Codechange: Depot gui uses pure nested widgets.
alberth <alberth@openttd.org>
parents:
13143
diff
changeset
|
552 void SetupWidgetData(VehicleType type) |
9201
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
553 { |
13704
af90d4bf0785
(svn r18229) -Codechange: Make fill_x, fill_y a number instead of a bool.
alberth <alberth@openttd.org>
parents:
13695
diff
changeset
|
554 if (type != VEH_TRAIN) this->GetWidget<NWidgetCore>(DEPOT_WIDGET_SELL_CHAIN)->fill_y = 0; // Disable vertical filling of chain-sell widget for non-train windows. |
12483
84df0c285bc4
(svn r16920) -Codechange: shuffle some strings around to simplify looking up vehicle type specific strings for a specific message
rubidium <rubidium@openttd.org>
parents:
12482
diff
changeset
|
555 |
13144
99a2d7dde8ee
(svn r17649) -Codechange: Depot gui uses pure nested widgets.
alberth <alberth@openttd.org>
parents:
13143
diff
changeset
|
556 this->GetWidget<NWidgetCore>(DEPOT_WIDGET_STOP_ALL)->tool_tip = STR_DEPOT_MASS_STOP_DEPOT_TRAIN_TOOLTIP + type; |
99a2d7dde8ee
(svn r17649) -Codechange: Depot gui uses pure nested widgets.
alberth <alberth@openttd.org>
parents:
13143
diff
changeset
|
557 this->GetWidget<NWidgetCore>(DEPOT_WIDGET_START_ALL)->tool_tip = STR_DEPOT_MASS_START_DEPOT_TRAIN_TOOLTIP + type; |
99a2d7dde8ee
(svn r17649) -Codechange: Depot gui uses pure nested widgets.
alberth <alberth@openttd.org>
parents:
13143
diff
changeset
|
558 this->GetWidget<NWidgetCore>(DEPOT_WIDGET_SELL)->tool_tip = STR_DEPOT_TRAIN_SELL_TOOLTIP + type; |
99a2d7dde8ee
(svn r17649) -Codechange: Depot gui uses pure nested widgets.
alberth <alberth@openttd.org>
parents:
13143
diff
changeset
|
559 this->GetWidget<NWidgetCore>(DEPOT_WIDGET_SELL_ALL)->tool_tip = STR_DEPOT_SELL_ALL_BUTTON_TRAIN_TOOLTIP + type; |
12483
84df0c285bc4
(svn r16920) -Codechange: shuffle some strings around to simplify looking up vehicle type specific strings for a specific message
rubidium <rubidium@openttd.org>
parents:
12482
diff
changeset
|
560 |
13144
99a2d7dde8ee
(svn r17649) -Codechange: Depot gui uses pure nested widgets.
alberth <alberth@openttd.org>
parents:
13143
diff
changeset
|
561 this->GetWidget<NWidgetCore>(DEPOT_WIDGET_BUILD)->SetDataTip(STR_DEPOT_TRAIN_NEW_VEHICLES_BUTTON + type, STR_DEPOT_TRAIN_NEW_VEHICLES_TOOLTIP + type); |
99a2d7dde8ee
(svn r17649) -Codechange: Depot gui uses pure nested widgets.
alberth <alberth@openttd.org>
parents:
13143
diff
changeset
|
562 this->GetWidget<NWidgetCore>(DEPOT_WIDGET_CLONE)->SetDataTip(STR_DEPOT_CLONE_TRAIN + type, STR_DEPOT_CLONE_TRAIN_DEPOT_INFO + type); |
99a2d7dde8ee
(svn r17649) -Codechange: Depot gui uses pure nested widgets.
alberth <alberth@openttd.org>
parents:
13143
diff
changeset
|
563 |
99a2d7dde8ee
(svn r17649) -Codechange: Depot gui uses pure nested widgets.
alberth <alberth@openttd.org>
parents:
13143
diff
changeset
|
564 this->GetWidget<NWidgetCore>(DEPOT_WIDGET_LOCATION)->tool_tip = STR_DEPOT_TRAIN_LOCATION_TOOLTIP + type; |
99a2d7dde8ee
(svn r17649) -Codechange: Depot gui uses pure nested widgets.
alberth <alberth@openttd.org>
parents:
13143
diff
changeset
|
565 this->GetWidget<NWidgetCore>(DEPOT_WIDGET_VEHICLE_LIST)->tool_tip = STR_DEPOT_VEHICLE_ORDER_LIST_TRAIN_TOOLTIP + type; |
99a2d7dde8ee
(svn r17649) -Codechange: Depot gui uses pure nested widgets.
alberth <alberth@openttd.org>
parents:
13143
diff
changeset
|
566 this->GetWidget<NWidgetCore>(DEPOT_WIDGET_AUTOREPLACE)->tool_tip = STR_DEPOT_AUTOREPLACE_TRAIN_TOOLTIP + type; |
15472
b3f5f128955e
(svn r20121) -Add: OnHover method for windows.
terkhen <terkhen@openttd.org>
parents:
15471
diff
changeset
|
567 this->GetWidget<NWidgetCore>(DEPOT_WIDGET_MATRIX)->tool_tip = STR_DEPOT_TRAIN_LIST_TOOLTIP + this->type; |
12483
84df0c285bc4
(svn r16920) -Codechange: shuffle some strings around to simplify looking up vehicle type specific strings for a specific message
rubidium <rubidium@openttd.org>
parents:
12482
diff
changeset
|
568 |
9201
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
569 switch (type) { |
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
570 default: NOT_REACHED(); |
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
571 |
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
572 case VEH_TRAIN: |
13144
99a2d7dde8ee
(svn r17649) -Codechange: Depot gui uses pure nested widgets.
alberth <alberth@openttd.org>
parents:
13143
diff
changeset
|
573 this->GetWidget<NWidgetCore>(DEPOT_WIDGET_VEHICLE_LIST)->widget_data = STR_TRAIN; |
9201
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 /* Sprites */ |
13144
99a2d7dde8ee
(svn r17649) -Codechange: Depot gui uses pure nested widgets.
alberth <alberth@openttd.org>
parents:
13143
diff
changeset
|
576 this->GetWidget<NWidgetCore>(DEPOT_WIDGET_SELL)->widget_data = SPR_SELL_TRAIN; |
99a2d7dde8ee
(svn r17649) -Codechange: Depot gui uses pure nested widgets.
alberth <alberth@openttd.org>
parents:
13143
diff
changeset
|
577 this->GetWidget<NWidgetCore>(DEPOT_WIDGET_SELL_ALL)->widget_data = SPR_SELL_ALL_TRAIN; |
99a2d7dde8ee
(svn r17649) -Codechange: Depot gui uses pure nested widgets.
alberth <alberth@openttd.org>
parents:
13143
diff
changeset
|
578 this->GetWidget<NWidgetCore>(DEPOT_WIDGET_AUTOREPLACE)->widget_data = SPR_REPLACE_TRAIN; |
9201
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
579 break; |
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
580 |
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
581 case VEH_ROAD: |
13144
99a2d7dde8ee
(svn r17649) -Codechange: Depot gui uses pure nested widgets.
alberth <alberth@openttd.org>
parents:
13143
diff
changeset
|
582 this->GetWidget<NWidgetCore>(DEPOT_WIDGET_VEHICLE_LIST)->widget_data = STR_LORRY; |
9201
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 /* Sprites */ |
13144
99a2d7dde8ee
(svn r17649) -Codechange: Depot gui uses pure nested widgets.
alberth <alberth@openttd.org>
parents:
13143
diff
changeset
|
585 this->GetWidget<NWidgetCore>(DEPOT_WIDGET_SELL)->widget_data = SPR_SELL_ROADVEH; |
99a2d7dde8ee
(svn r17649) -Codechange: Depot gui uses pure nested widgets.
alberth <alberth@openttd.org>
parents:
13143
diff
changeset
|
586 this->GetWidget<NWidgetCore>(DEPOT_WIDGET_SELL_ALL)->widget_data = SPR_SELL_ALL_ROADVEH; |
99a2d7dde8ee
(svn r17649) -Codechange: Depot gui uses pure nested widgets.
alberth <alberth@openttd.org>
parents:
13143
diff
changeset
|
587 this->GetWidget<NWidgetCore>(DEPOT_WIDGET_AUTOREPLACE)->widget_data = SPR_REPLACE_ROADVEH; |
9201
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
588 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
|
589 |
9201
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
590 case VEH_SHIP: |
13144
99a2d7dde8ee
(svn r17649) -Codechange: Depot gui uses pure nested widgets.
alberth <alberth@openttd.org>
parents:
13143
diff
changeset
|
591 this->GetWidget<NWidgetCore>(DEPOT_WIDGET_VEHICLE_LIST)->widget_data = STR_SHIP; |
9201
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 /* Sprites */ |
13144
99a2d7dde8ee
(svn r17649) -Codechange: Depot gui uses pure nested widgets.
alberth <alberth@openttd.org>
parents:
13143
diff
changeset
|
594 this->GetWidget<NWidgetCore>(DEPOT_WIDGET_SELL)->widget_data = SPR_SELL_SHIP; |
99a2d7dde8ee
(svn r17649) -Codechange: Depot gui uses pure nested widgets.
alberth <alberth@openttd.org>
parents:
13143
diff
changeset
|
595 this->GetWidget<NWidgetCore>(DEPOT_WIDGET_SELL_ALL)->widget_data = SPR_SELL_ALL_SHIP; |
99a2d7dde8ee
(svn r17649) -Codechange: Depot gui uses pure nested widgets.
alberth <alberth@openttd.org>
parents:
13143
diff
changeset
|
596 this->GetWidget<NWidgetCore>(DEPOT_WIDGET_AUTOREPLACE)->widget_data = SPR_REPLACE_SHIP; |
9201
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
597 break; |
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 case VEH_AIRCRAFT: |
13144
99a2d7dde8ee
(svn r17649) -Codechange: Depot gui uses pure nested widgets.
alberth <alberth@openttd.org>
parents:
13143
diff
changeset
|
600 this->GetWidget<NWidgetCore>(DEPOT_WIDGET_VEHICLE_LIST)->widget_data = STR_PLANE; |
9201
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
601 |
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
602 /* Sprites */ |
13144
99a2d7dde8ee
(svn r17649) -Codechange: Depot gui uses pure nested widgets.
alberth <alberth@openttd.org>
parents:
13143
diff
changeset
|
603 this->GetWidget<NWidgetCore>(DEPOT_WIDGET_SELL)->widget_data = SPR_SELL_AIRCRAFT; |
99a2d7dde8ee
(svn r17649) -Codechange: Depot gui uses pure nested widgets.
alberth <alberth@openttd.org>
parents:
13143
diff
changeset
|
604 this->GetWidget<NWidgetCore>(DEPOT_WIDGET_SELL_ALL)->widget_data = SPR_SELL_ALL_AIRCRAFT; |
99a2d7dde8ee
(svn r17649) -Codechange: Depot gui uses pure nested widgets.
alberth <alberth@openttd.org>
parents:
13143
diff
changeset
|
605 this->GetWidget<NWidgetCore>(DEPOT_WIDGET_AUTOREPLACE)->widget_data = SPR_REPLACE_AIRCRAFT; |
9201
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
606 break; |
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
607 } |
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
608 } |
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
609 |
13630
40489a4d0822
(svn r18154) -Codechange: let the depot window better scale with bigger fonts
rubidium <rubidium@openttd.org>
parents:
13628
diff
changeset
|
610 uint count_width; |
40489a4d0822
(svn r18154) -Codechange: let the depot window better scale with bigger fonts
rubidium <rubidium@openttd.org>
parents:
13628
diff
changeset
|
611 uint header_width; |
40489a4d0822
(svn r18154) -Codechange: let the depot window better scale with bigger fonts
rubidium <rubidium@openttd.org>
parents:
13628
diff
changeset
|
612 uint flag_width; |
40489a4d0822
(svn r18154) -Codechange: let the depot window better scale with bigger fonts
rubidium <rubidium@openttd.org>
parents:
13628
diff
changeset
|
613 uint flag_height; |
40489a4d0822
(svn r18154) -Codechange: let the depot window better scale with bigger fonts
rubidium <rubidium@openttd.org>
parents:
13628
diff
changeset
|
614 |
13705
8dee47e001b2
(svn r18230) -Codechange: Allow fill stepsize to be set from Window::UpdateWidgetSize().
alberth <alberth@openttd.org>
parents:
13704
diff
changeset
|
615 virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) |
13144
99a2d7dde8ee
(svn r17649) -Codechange: Depot gui uses pure nested widgets.
alberth <alberth@openttd.org>
parents:
13143
diff
changeset
|
616 { |
99a2d7dde8ee
(svn r17649) -Codechange: Depot gui uses pure nested widgets.
alberth <alberth@openttd.org>
parents:
13143
diff
changeset
|
617 switch (widget) { |
99a2d7dde8ee
(svn r17649) -Codechange: Depot gui uses pure nested widgets.
alberth <alberth@openttd.org>
parents:
13143
diff
changeset
|
618 case DEPOT_WIDGET_SELL_CHAIN: |
99a2d7dde8ee
(svn r17649) -Codechange: Depot gui uses pure nested widgets.
alberth <alberth@openttd.org>
parents:
13143
diff
changeset
|
619 case DEPOT_WIDGET_H_SCROLL: |
99a2d7dde8ee
(svn r17649) -Codechange: Depot gui uses pure nested widgets.
alberth <alberth@openttd.org>
parents:
13143
diff
changeset
|
620 /* Hide the 'sell chain' and the horizontal scrollbar when not a train depot. */ |
99a2d7dde8ee
(svn r17649) -Codechange: Depot gui uses pure nested widgets.
alberth <alberth@openttd.org>
parents:
13143
diff
changeset
|
621 if (this->type != VEH_TRAIN) { |
99a2d7dde8ee
(svn r17649) -Codechange: Depot gui uses pure nested widgets.
alberth <alberth@openttd.org>
parents:
13143
diff
changeset
|
622 size->height = 0; |
99a2d7dde8ee
(svn r17649) -Codechange: Depot gui uses pure nested widgets.
alberth <alberth@openttd.org>
parents:
13143
diff
changeset
|
623 resize->height = 0; |
99a2d7dde8ee
(svn r17649) -Codechange: Depot gui uses pure nested widgets.
alberth <alberth@openttd.org>
parents:
13143
diff
changeset
|
624 } |
99a2d7dde8ee
(svn r17649) -Codechange: Depot gui uses pure nested widgets.
alberth <alberth@openttd.org>
parents:
13143
diff
changeset
|
625 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
|
626 |
13630
40489a4d0822
(svn r18154) -Codechange: let the depot window better scale with bigger fonts
rubidium <rubidium@openttd.org>
parents:
13628
diff
changeset
|
627 case DEPOT_WIDGET_MATRIX: { |
40489a4d0822
(svn r18154) -Codechange: let the depot window better scale with bigger fonts
rubidium <rubidium@openttd.org>
parents:
13628
diff
changeset
|
628 uint min_height = 0; |
40489a4d0822
(svn r18154) -Codechange: let the depot window better scale with bigger fonts
rubidium <rubidium@openttd.org>
parents:
13628
diff
changeset
|
629 |
40489a4d0822
(svn r18154) -Codechange: let the depot window better scale with bigger fonts
rubidium <rubidium@openttd.org>
parents:
13628
diff
changeset
|
630 if (this->type == VEH_TRAIN) { |
40489a4d0822
(svn r18154) -Codechange: let the depot window better scale with bigger fonts
rubidium <rubidium@openttd.org>
parents:
13628
diff
changeset
|
631 SetDParam(0, 100); |
40489a4d0822
(svn r18154) -Codechange: let the depot window better scale with bigger fonts
rubidium <rubidium@openttd.org>
parents:
13628
diff
changeset
|
632 this->count_width = GetStringBoundingBox(STR_TINY_BLACK_COMA).width + WD_FRAMERECT_LEFT + WD_FRAMERECT_RIGHT; |
13639
455a6f0ae773
(svn r18163) -Codechange: make the depot GUI RTL aware
rubidium <rubidium@openttd.org>
parents:
13633
diff
changeset
|
633 } else { |
455a6f0ae773
(svn r18163) -Codechange: make the depot GUI RTL aware
rubidium <rubidium@openttd.org>
parents:
13633
diff
changeset
|
634 this->count_width = 0; |
13630
40489a4d0822
(svn r18154) -Codechange: let the depot window better scale with bigger fonts
rubidium <rubidium@openttd.org>
parents:
13628
diff
changeset
|
635 } |
40489a4d0822
(svn r18154) -Codechange: let the depot window better scale with bigger fonts
rubidium <rubidium@openttd.org>
parents:
13628
diff
changeset
|
636 |
14032
0a874c3b0514
(svn r18575) -Fix [FS#3393]: unit numbers weren't always fully shown in the depot
rubidium <rubidium@openttd.org>
parents:
13885
diff
changeset
|
637 Dimension unumber = { GetDigitWidth() * 4, FONT_HEIGHT_NORMAL }; |
13630
40489a4d0822
(svn r18154) -Codechange: let the depot window better scale with bigger fonts
rubidium <rubidium@openttd.org>
parents:
13628
diff
changeset
|
638 const Sprite *spr = GetSprite(SPR_FLAG_VEH_STOPPED, ST_NORMAL); |
40489a4d0822
(svn r18154) -Codechange: let the depot window better scale with bigger fonts
rubidium <rubidium@openttd.org>
parents:
13628
diff
changeset
|
639 this->flag_width = spr->width + WD_FRAMERECT_RIGHT; |
40489a4d0822
(svn r18154) -Codechange: let the depot window better scale with bigger fonts
rubidium <rubidium@openttd.org>
parents:
13628
diff
changeset
|
640 this->flag_height = spr->height; |
40489a4d0822
(svn r18154) -Codechange: let the depot window better scale with bigger fonts
rubidium <rubidium@openttd.org>
parents:
13628
diff
changeset
|
641 |
40489a4d0822
(svn r18154) -Codechange: let the depot window better scale with bigger fonts
rubidium <rubidium@openttd.org>
parents:
13628
diff
changeset
|
642 if (this->type == VEH_TRAIN || this->type == VEH_ROAD) { |
40489a4d0822
(svn r18154) -Codechange: let the depot window better scale with bigger fonts
rubidium <rubidium@openttd.org>
parents:
13628
diff
changeset
|
643 min_height = max<uint>(unumber.height + WD_MATRIX_TOP, spr->height); |
14032
0a874c3b0514
(svn r18575) -Fix [FS#3393]: unit numbers weren't always fully shown in the depot
rubidium <rubidium@openttd.org>
parents:
13885
diff
changeset
|
644 this->header_width = unumber.width + this->flag_width + WD_FRAMERECT_LEFT; |
13630
40489a4d0822
(svn r18154) -Codechange: let the depot window better scale with bigger fonts
rubidium <rubidium@openttd.org>
parents:
13628
diff
changeset
|
645 } else { |
40489a4d0822
(svn r18154) -Codechange: let the depot window better scale with bigger fonts
rubidium <rubidium@openttd.org>
parents:
13628
diff
changeset
|
646 min_height = unumber.height + spr->height + WD_MATRIX_TOP + WD_PAR_VSEP_NORMAL + WD_MATRIX_BOTTOM; |
40489a4d0822
(svn r18154) -Codechange: let the depot window better scale with bigger fonts
rubidium <rubidium@openttd.org>
parents:
13628
diff
changeset
|
647 this->header_width = max<uint>(unumber.width, this->flag_width) + WD_FRAMERECT_RIGHT; |
40489a4d0822
(svn r18154) -Codechange: let the depot window better scale with bigger fonts
rubidium <rubidium@openttd.org>
parents:
13628
diff
changeset
|
648 } |
13639
455a6f0ae773
(svn r18163) -Codechange: make the depot GUI RTL aware
rubidium <rubidium@openttd.org>
parents:
13633
diff
changeset
|
649 int base_width = this->count_width + this->header_width; |
13630
40489a4d0822
(svn r18154) -Codechange: let the depot window better scale with bigger fonts
rubidium <rubidium@openttd.org>
parents:
13628
diff
changeset
|
650 |
40489a4d0822
(svn r18154) -Codechange: let the depot window better scale with bigger fonts
rubidium <rubidium@openttd.org>
parents:
13628
diff
changeset
|
651 resize->height = max(_base_block_sizes[this->type].height, min_height); |
40489a4d0822
(svn r18154) -Codechange: let the depot window better scale with bigger fonts
rubidium <rubidium@openttd.org>
parents:
13628
diff
changeset
|
652 if (this->type == VEH_TRAIN) { |
40489a4d0822
(svn r18154) -Codechange: let the depot window better scale with bigger fonts
rubidium <rubidium@openttd.org>
parents:
13628
diff
changeset
|
653 resize->width = 1; |
13633
e809c4dab49d
(svn r18157) -Codechange: some minor tweaks of the boundaries of strings etc. in the depot window
rubidium <rubidium@openttd.org>
parents:
13630
diff
changeset
|
654 size->width = base_width + 2 * 29; // about 2 parts |
e809c4dab49d
(svn r18157) -Codechange: some minor tweaks of the boundaries of strings etc. in the depot window
rubidium <rubidium@openttd.org>
parents:
13630
diff
changeset
|
655 size->height = resize->height * 6; |
13630
40489a4d0822
(svn r18154) -Codechange: let the depot window better scale with bigger fonts
rubidium <rubidium@openttd.org>
parents:
13628
diff
changeset
|
656 } else { |
40489a4d0822
(svn r18154) -Codechange: let the depot window better scale with bigger fonts
rubidium <rubidium@openttd.org>
parents:
13628
diff
changeset
|
657 resize->width = base_width + _base_block_sizes[this->type].width; |
40489a4d0822
(svn r18154) -Codechange: let the depot window better scale with bigger fonts
rubidium <rubidium@openttd.org>
parents:
13628
diff
changeset
|
658 size->width = resize->width * (this->type == VEH_ROAD ? 5 : 3); |
40489a4d0822
(svn r18154) -Codechange: let the depot window better scale with bigger fonts
rubidium <rubidium@openttd.org>
parents:
13628
diff
changeset
|
659 size->height = resize->height * (this->type == VEH_ROAD ? 5 : 3); |
40489a4d0822
(svn r18154) -Codechange: let the depot window better scale with bigger fonts
rubidium <rubidium@openttd.org>
parents:
13628
diff
changeset
|
660 } |
13706
a15d8546fedf
(svn r18231) -Fix: Enable filling of matrix widget in the depot gui.
alberth <alberth@openttd.org>
parents:
13705
diff
changeset
|
661 fill->width = resize->width; |
a15d8546fedf
(svn r18231) -Fix: Enable filling of matrix widget in the depot gui.
alberth <alberth@openttd.org>
parents:
13705
diff
changeset
|
662 fill->height = resize->height; |
15618
e4640748f223
(svn r20281) -Codechange: unify case scope closure + break coding style
rubidium <rubidium@openttd.org>
parents:
15496
diff
changeset
|
663 break; |
e4640748f223
(svn r20281) -Codechange: unify case scope closure + break coding style
rubidium <rubidium@openttd.org>
parents:
15496
diff
changeset
|
664 } |
13144
99a2d7dde8ee
(svn r17649) -Codechange: Depot gui uses pure nested widgets.
alberth <alberth@openttd.org>
parents:
13143
diff
changeset
|
665 } |
9201
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
666 } |
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
667 |
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
668 virtual void OnInvalidateData(int data) |
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
669 { |
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
670 this->generate_list = true; |
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
671 } |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
672 |
9201
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
673 virtual void OnPaint() |
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
674 { |
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
675 if (this->generate_list) { |
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
676 /* Generate the vehicle list |
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
677 * It's ok to use the wagon pointers for non-trains as they will be ignored */ |
9351
feaf9bae7580
(svn r13248) -Codechange: Use VehicleList for depot GUI.
peter1138 <peter1138@openttd.org>
parents:
9344
diff
changeset
|
678 BuildDepotVehicleList(this->type, this->window_number, &this->vehicle_list, &this->wagon_list); |
9201
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
679 this->generate_list = false; |
9351
feaf9bae7580
(svn r13248) -Codechange: Use VehicleList for depot GUI.
peter1138 <peter1138@openttd.org>
parents:
9344
diff
changeset
|
680 DepotSortList(&this->vehicle_list); |
9201
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
681 } |
13144
99a2d7dde8ee
(svn r17649) -Codechange: Depot gui uses pure nested widgets.
alberth <alberth@openttd.org>
parents:
13143
diff
changeset
|
682 |
99a2d7dde8ee
(svn r17649) -Codechange: Depot gui uses pure nested widgets.
alberth <alberth@openttd.org>
parents:
13143
diff
changeset
|
683 /* determine amount of items for scroller */ |
99a2d7dde8ee
(svn r17649) -Codechange: Depot gui uses pure nested widgets.
alberth <alberth@openttd.org>
parents:
13143
diff
changeset
|
684 if (this->type == VEH_TRAIN) { |
99a2d7dde8ee
(svn r17649) -Codechange: Depot gui uses pure nested widgets.
alberth <alberth@openttd.org>
parents:
13143
diff
changeset
|
685 uint max_width = VEHICLEINFO_FULL_VEHICLE_WIDTH; |
99a2d7dde8ee
(svn r17649) -Codechange: Depot gui uses pure nested widgets.
alberth <alberth@openttd.org>
parents:
13143
diff
changeset
|
686 for (uint num = 0; num < this->vehicle_list.Length(); num++) { |
99a2d7dde8ee
(svn r17649) -Codechange: Depot gui uses pure nested widgets.
alberth <alberth@openttd.org>
parents:
13143
diff
changeset
|
687 uint width = 0; |
99a2d7dde8ee
(svn r17649) -Codechange: Depot gui uses pure nested widgets.
alberth <alberth@openttd.org>
parents:
13143
diff
changeset
|
688 for (const Train *v = Train::From(this->vehicle_list[num]); v != NULL; v = v->Next()) { |
99a2d7dde8ee
(svn r17649) -Codechange: Depot gui uses pure nested widgets.
alberth <alberth@openttd.org>
parents:
13143
diff
changeset
|
689 width += v->GetDisplayImageWidth(); |
99a2d7dde8ee
(svn r17649) -Codechange: Depot gui uses pure nested widgets.
alberth <alberth@openttd.org>
parents:
13143
diff
changeset
|
690 } |
99a2d7dde8ee
(svn r17649) -Codechange: Depot gui uses pure nested widgets.
alberth <alberth@openttd.org>
parents:
13143
diff
changeset
|
691 max_width = max(max_width, width); |
99a2d7dde8ee
(svn r17649) -Codechange: Depot gui uses pure nested widgets.
alberth <alberth@openttd.org>
parents:
13143
diff
changeset
|
692 } |
99a2d7dde8ee
(svn r17649) -Codechange: Depot gui uses pure nested widgets.
alberth <alberth@openttd.org>
parents:
13143
diff
changeset
|
693 /* Always have 1 empty row, so people can change the setting of the train */ |
99a2d7dde8ee
(svn r17649) -Codechange: Depot gui uses pure nested widgets.
alberth <alberth@openttd.org>
parents:
13143
diff
changeset
|
694 this->vscroll.SetCount(this->vehicle_list.Length() + this->wagon_list.Length() + 1); |
99a2d7dde8ee
(svn r17649) -Codechange: Depot gui uses pure nested widgets.
alberth <alberth@openttd.org>
parents:
13143
diff
changeset
|
695 this->hscroll.SetCount(max_width); |
99a2d7dde8ee
(svn r17649) -Codechange: Depot gui uses pure nested widgets.
alberth <alberth@openttd.org>
parents:
13143
diff
changeset
|
696 } else { |
15050
73f4e0e490b7
(svn r19670) -Codechange: Add CeilDiv() and RoundDiv() to simplify integer divisions with rounding.
frosch <frosch@openttd.org>
parents:
14409
diff
changeset
|
697 this->vscroll.SetCount(CeilDiv(this->vehicle_list.Length(), this->hscroll.GetCapacity())); |
13144
99a2d7dde8ee
(svn r17649) -Codechange: Depot gui uses pure nested widgets.
alberth <alberth@openttd.org>
parents:
13143
diff
changeset
|
698 } |
99a2d7dde8ee
(svn r17649) -Codechange: Depot gui uses pure nested widgets.
alberth <alberth@openttd.org>
parents:
13143
diff
changeset
|
699 |
13251
7c4df1153a65
(svn r17760) -Revert (r17648): _local_company is less constant than you'd expect.
alberth <alberth@openttd.org>
parents:
13148
diff
changeset
|
700 /* Setup disabled buttons. */ |
7c4df1153a65
(svn r17760) -Revert (r17648): _local_company is less constant than you'd expect.
alberth <alberth@openttd.org>
parents:
13148
diff
changeset
|
701 TileIndex tile = this->window_number; |
7c4df1153a65
(svn r17760) -Revert (r17648): _local_company is less constant than you'd expect.
alberth <alberth@openttd.org>
parents:
13148
diff
changeset
|
702 this->SetWidgetsDisabledState(!IsTileOwner(tile, _local_company), |
7c4df1153a65
(svn r17760) -Revert (r17648): _local_company is less constant than you'd expect.
alberth <alberth@openttd.org>
parents:
13148
diff
changeset
|
703 DEPOT_WIDGET_STOP_ALL, |
7c4df1153a65
(svn r17760) -Revert (r17648): _local_company is less constant than you'd expect.
alberth <alberth@openttd.org>
parents:
13148
diff
changeset
|
704 DEPOT_WIDGET_START_ALL, |
7c4df1153a65
(svn r17760) -Revert (r17648): _local_company is less constant than you'd expect.
alberth <alberth@openttd.org>
parents:
13148
diff
changeset
|
705 DEPOT_WIDGET_SELL, |
7c4df1153a65
(svn r17760) -Revert (r17648): _local_company is less constant than you'd expect.
alberth <alberth@openttd.org>
parents:
13148
diff
changeset
|
706 DEPOT_WIDGET_SELL_CHAIN, |
7c4df1153a65
(svn r17760) -Revert (r17648): _local_company is less constant than you'd expect.
alberth <alberth@openttd.org>
parents:
13148
diff
changeset
|
707 DEPOT_WIDGET_SELL_ALL, |
7c4df1153a65
(svn r17760) -Revert (r17648): _local_company is less constant than you'd expect.
alberth <alberth@openttd.org>
parents:
13148
diff
changeset
|
708 DEPOT_WIDGET_BUILD, |
7c4df1153a65
(svn r17760) -Revert (r17648): _local_company is less constant than you'd expect.
alberth <alberth@openttd.org>
parents:
13148
diff
changeset
|
709 DEPOT_WIDGET_CLONE, |
15172
e9741bd69a65
(svn r19801) -Add [FS#3691]: custom naming of depots. Based on work by sbr
rubidium <rubidium@openttd.org>
parents:
15167
diff
changeset
|
710 DEPOT_WIDGET_RENAME, |
13251
7c4df1153a65
(svn r17760) -Revert (r17648): _local_company is less constant than you'd expect.
alberth <alberth@openttd.org>
parents:
13148
diff
changeset
|
711 DEPOT_WIDGET_AUTOREPLACE, |
7c4df1153a65
(svn r17760) -Revert (r17648): _local_company is less constant than you'd expect.
alberth <alberth@openttd.org>
parents:
13148
diff
changeset
|
712 WIDGET_LIST_END); |
7c4df1153a65
(svn r17760) -Revert (r17648): _local_company is less constant than you'd expect.
alberth <alberth@openttd.org>
parents:
13148
diff
changeset
|
713 |
13144
99a2d7dde8ee
(svn r17649) -Codechange: Depot gui uses pure nested widgets.
alberth <alberth@openttd.org>
parents:
13143
diff
changeset
|
714 this->DrawWidgets(); |
9201
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
715 } |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
716 |
14409
1eaefde497fd
(svn r18966) -Codechange: Remove Window::OnDoubleClick() in favour of a parameter for OnClick().
frosch <frosch@openttd.org>
parents:
14258
diff
changeset
|
717 virtual void OnClick(Point pt, int widget, int click_count) |
9201
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
718 { |
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
719 switch (widget) { |
13324
82e58acd7cec
(svn r17833) -Codechange: Depot gui should use relative widget coordinates for clicking.
alberth <alberth@openttd.org>
parents:
13321
diff
changeset
|
720 case DEPOT_WIDGET_MATRIX: { // List |
82e58acd7cec
(svn r17833) -Codechange: Depot gui should use relative widget coordinates for clicking.
alberth <alberth@openttd.org>
parents:
13321
diff
changeset
|
721 NWidgetBase *nwi = this->GetWidget<NWidgetBase>(DEPOT_WIDGET_MATRIX); |
82e58acd7cec
(svn r17833) -Codechange: Depot gui should use relative widget coordinates for clicking.
alberth <alberth@openttd.org>
parents:
13321
diff
changeset
|
722 this->DepotClick(pt.x - nwi->pos_x, pt.y - nwi->pos_y); |
9201
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
723 break; |
13324
82e58acd7cec
(svn r17833) -Codechange: Depot gui should use relative widget coordinates for clicking.
alberth <alberth@openttd.org>
parents:
13321
diff
changeset
|
724 } |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
725 |
9201
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
726 case DEPOT_WIDGET_BUILD: // Build vehicle |
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
727 ResetObjectToPlace(); |
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
728 ShowBuildVehicleWindow(this->window_number, this->type); |
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
729 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
|
730 |
9201
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
731 case DEPOT_WIDGET_CLONE: // Clone button |
13034
6eb3f749890a
(svn r17532) -Codechange: Rename several Invalidate functions to SetDirty for more consistency and distinguishability.
frosch <frosch@openttd.org>
parents:
12953
diff
changeset
|
732 this->SetWidgetDirty(DEPOT_WIDGET_CLONE); |
9201
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
733 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
|
734 |
9201
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
735 if (this->IsWidgetLowered(DEPOT_WIDGET_CLONE)) { |
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
736 static const CursorID clone_icons[] = { |
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
737 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
|
738 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
|
739 }; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
740 |
9201
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
741 _place_clicked_vehicle = NULL; |
11702
cdaad565efe5
(svn r16088) -Codechange: merge HighLightStyle and ViewportHighlightMode as they are basically the same thing
rubidium <rubidium@openttd.org>
parents:
11524
diff
changeset
|
742 SetObjectToPlaceWnd(clone_icons[this->type], PAL_NONE, HT_RECT, this); |
9201
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
743 } else { |
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
744 ResetObjectToPlace(); |
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
745 } |
15618
e4640748f223
(svn r20281) -Codechange: unify case scope closure + break coding style
rubidium <rubidium@openttd.org>
parents:
15496
diff
changeset
|
746 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
|
747 |
9201
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
748 case DEPOT_WIDGET_LOCATION: |
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
749 if (_ctrl_pressed) { |
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
750 ShowExtraViewPortWindow(this->window_number); |
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
751 } else { |
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
752 ScrollMainWindowToTile(this->window_number); |
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
753 } |
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
754 break; |
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
755 |
15172
e9741bd69a65
(svn r19801) -Add [FS#3691]: custom naming of depots. Based on work by sbr
rubidium <rubidium@openttd.org>
parents:
15167
diff
changeset
|
756 case DEPOT_WIDGET_RENAME: // Rename button |
e9741bd69a65
(svn r19801) -Add [FS#3691]: custom naming of depots. Based on work by sbr
rubidium <rubidium@openttd.org>
parents:
15167
diff
changeset
|
757 SetDParam(0, this->type); |
e9741bd69a65
(svn r19801) -Add [FS#3691]: custom naming of depots. Based on work by sbr
rubidium <rubidium@openttd.org>
parents:
15167
diff
changeset
|
758 SetDParam(1, Depot::GetByTile((TileIndex)this->window_number)->index); |
e9741bd69a65
(svn r19801) -Add [FS#3691]: custom naming of depots. Based on work by sbr
rubidium <rubidium@openttd.org>
parents:
15167
diff
changeset
|
759 ShowQueryString(STR_DEPOT_NAME, STR_DEPOT_RENAME_DEPOT_CAPTION, MAX_LENGTH_DEPOT_NAME_BYTES, MAX_LENGTH_DEPOT_NAME_PIXELS, this, CS_ALPHANUMERAL, QSF_ENABLE_DEFAULT); |
e9741bd69a65
(svn r19801) -Add [FS#3691]: custom naming of depots. Based on work by sbr
rubidium <rubidium@openttd.org>
parents:
15167
diff
changeset
|
760 break; |
e9741bd69a65
(svn r19801) -Add [FS#3691]: custom naming of depots. Based on work by sbr
rubidium <rubidium@openttd.org>
parents:
15167
diff
changeset
|
761 |
9201
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
762 case DEPOT_WIDGET_STOP_ALL: |
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
763 case DEPOT_WIDGET_START_ALL: |
10499
45ca88a8de7d
(svn r14754) -Codechange: get rid of _cmd_text and just pass it as (optional) parameter.
rubidium <rubidium@openttd.org>
parents:
10208
diff
changeset
|
764 DoCommandP(this->window_number, 0, this->type | (widget == DEPOT_WIDGET_START_ALL ? (1 << 5) : 0), CMD_MASS_START_STOP); |
9201
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
765 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
|
766 |
9201
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
767 case DEPOT_WIDGET_SELL_ALL: |
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
768 /* Only open the confimation window if there are anything to sell */ |
9351
feaf9bae7580
(svn r13248) -Codechange: Use VehicleList for depot GUI.
peter1138 <peter1138@openttd.org>
parents:
9344
diff
changeset
|
769 if (this->vehicle_list.Length() != 0 || this->wagon_list.Length() != 0) { |
9201
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
770 TileIndex tile = this->window_number; |
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
771 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
|
772 |
15167
2ef5704286b9
(svn r19796) -Codechange: introduce and use a {DEPOT} string command
rubidium <rubidium@openttd.org>
parents:
15088
diff
changeset
|
773 SetDParam(0, vehtype); |
2ef5704286b9
(svn r19796) -Codechange: introduce and use a {DEPOT} string command
rubidium <rubidium@openttd.org>
parents:
15088
diff
changeset
|
774 SetDParam(1, (vehtype == VEH_AIRCRAFT) ? GetStationIndex(tile) : GetDepotIndex(tile)); |
9201
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
775 ShowQuery( |
15167
2ef5704286b9
(svn r19796) -Codechange: introduce and use a {DEPOT} string command
rubidium <rubidium@openttd.org>
parents:
15088
diff
changeset
|
776 STR_DEPOT_CAPTION, |
9201
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
777 STR_DEPOT_SELL_CONFIRMATION_TEXT, |
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
778 this, |
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
779 DepotSellAllConfirmationCallback |
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
780 ); |
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
781 } |
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
782 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
|
783 |
9201
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
784 case DEPOT_WIDGET_VEHICLE_LIST: |
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
785 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
|
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_AUTOREPLACE: |
10499
45ca88a8de7d
(svn r14754) -Codechange: get rid of _cmd_text and just pass it as (optional) parameter.
rubidium <rubidium@openttd.org>
parents:
10208
diff
changeset
|
789 DoCommandP(this->window_number, this->type, 0, CMD_DEPOT_MASS_AUTOREPLACE); |
9201
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
790 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
|
791 |
9201
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
792 } |
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
793 } |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
794 |
15172
e9741bd69a65
(svn r19801) -Add [FS#3691]: custom naming of depots. Based on work by sbr
rubidium <rubidium@openttd.org>
parents:
15167
diff
changeset
|
795 virtual void OnQueryTextFinished(char *str) |
e9741bd69a65
(svn r19801) -Add [FS#3691]: custom naming of depots. Based on work by sbr
rubidium <rubidium@openttd.org>
parents:
15167
diff
changeset
|
796 { |
e9741bd69a65
(svn r19801) -Add [FS#3691]: custom naming of depots. Based on work by sbr
rubidium <rubidium@openttd.org>
parents:
15167
diff
changeset
|
797 if (str == NULL) return; |
e9741bd69a65
(svn r19801) -Add [FS#3691]: custom naming of depots. Based on work by sbr
rubidium <rubidium@openttd.org>
parents:
15167
diff
changeset
|
798 |
e9741bd69a65
(svn r19801) -Add [FS#3691]: custom naming of depots. Based on work by sbr
rubidium <rubidium@openttd.org>
parents:
15167
diff
changeset
|
799 /* Do depot renaming */ |
e9741bd69a65
(svn r19801) -Add [FS#3691]: custom naming of depots. Based on work by sbr
rubidium <rubidium@openttd.org>
parents:
15167
diff
changeset
|
800 DoCommandP(0, GetDepotIndex(this->window_number), 0, CMD_RENAME_DEPOT | CMD_MSG(STR_ERROR_CAN_T_RENAME_DEPOT), NULL, str); |
e9741bd69a65
(svn r19801) -Add [FS#3691]: custom naming of depots. Based on work by sbr
rubidium <rubidium@openttd.org>
parents:
15167
diff
changeset
|
801 } |
e9741bd69a65
(svn r19801) -Add [FS#3691]: custom naming of depots. Based on work by sbr
rubidium <rubidium@openttd.org>
parents:
15167
diff
changeset
|
802 |
15496
9df3018e209b
(svn r20145) -Codechange: keep original RMB->tooltip behaviour when hovering is disabled and there is no handled right click event for the widget, i.e. if a widget would handle the right click you won't see the tooltip anymore by right clicking; by enabling hovering you would get access to that tooltip again.
rubidium <rubidium@openttd.org>
parents:
15472
diff
changeset
|
803 virtual bool OnRightClick(Point pt, int widget) |
9782
93d9386b56ac
(svn r13923) -Feature: Show [total-]cargo info in depot when [ctrl-]right-clicking on vehicle.
frosch <frosch@openttd.org>
parents:
9751
diff
changeset
|
804 { |
15496
9df3018e209b
(svn r20145) -Codechange: keep original RMB->tooltip behaviour when hovering is disabled and there is no handled right click event for the widget, i.e. if a widget would handle the right click you won't see the tooltip anymore by right clicking; by enabling hovering you would get access to that tooltip again.
rubidium <rubidium@openttd.org>
parents:
15472
diff
changeset
|
805 if (widget != DEPOT_WIDGET_MATRIX) return false; |
9782
93d9386b56ac
(svn r13923) -Feature: Show [total-]cargo info in depot when [ctrl-]right-clicking on vehicle.
frosch <frosch@openttd.org>
parents:
9751
diff
changeset
|
806 |
93d9386b56ac
(svn r13923) -Feature: Show [total-]cargo info in depot when [ctrl-]right-clicking on vehicle.
frosch <frosch@openttd.org>
parents:
9751
diff
changeset
|
807 GetDepotVehiclePtData gdvp = { NULL, NULL }; |
93d9386b56ac
(svn r13923) -Feature: Show [total-]cargo info in depot when [ctrl-]right-clicking on vehicle.
frosch <frosch@openttd.org>
parents:
9751
diff
changeset
|
808 const Vehicle *v = NULL; |
13324
82e58acd7cec
(svn r17833) -Codechange: Depot gui should use relative widget coordinates for clicking.
alberth <alberth@openttd.org>
parents:
13321
diff
changeset
|
809 NWidgetBase *nwi = this->GetWidget<NWidgetBase>(DEPOT_WIDGET_MATRIX); |
82e58acd7cec
(svn r17833) -Codechange: Depot gui should use relative widget coordinates for clicking.
alberth <alberth@openttd.org>
parents:
13321
diff
changeset
|
810 DepotGUIAction mode = this->GetVehicleFromDepotWndPt(pt.x - nwi->pos_x, pt.y - nwi->pos_y, &v, &gdvp); |
9782
93d9386b56ac
(svn r13923) -Feature: Show [total-]cargo info in depot when [ctrl-]right-clicking on vehicle.
frosch <frosch@openttd.org>
parents:
9751
diff
changeset
|
811 |
93d9386b56ac
(svn r13923) -Feature: Show [total-]cargo info in depot when [ctrl-]right-clicking on vehicle.
frosch <frosch@openttd.org>
parents:
9751
diff
changeset
|
812 if (this->type == VEH_TRAIN) v = gdvp.wagon; |
93d9386b56ac
(svn r13923) -Feature: Show [total-]cargo info in depot when [ctrl-]right-clicking on vehicle.
frosch <frosch@openttd.org>
parents:
9751
diff
changeset
|
813 |
15496
9df3018e209b
(svn r20145) -Codechange: keep original RMB->tooltip behaviour when hovering is disabled and there is no handled right click event for the widget, i.e. if a widget would handle the right click you won't see the tooltip anymore by right clicking; by enabling hovering you would get access to that tooltip again.
rubidium <rubidium@openttd.org>
parents:
15472
diff
changeset
|
814 if (v == NULL || mode != MODE_DRAG_VEHICLE) return false; |
9782
93d9386b56ac
(svn r13923) -Feature: Show [total-]cargo info in depot when [ctrl-]right-clicking on vehicle.
frosch <frosch@openttd.org>
parents:
9751
diff
changeset
|
815 |
15496
9df3018e209b
(svn r20145) -Codechange: keep original RMB->tooltip behaviour when hovering is disabled and there is no handled right click event for the widget, i.e. if a widget would handle the right click you won't see the tooltip anymore by right clicking; by enabling hovering you would get access to that tooltip again.
rubidium <rubidium@openttd.org>
parents:
15472
diff
changeset
|
816 CargoArray capacity, loaded; |
9df3018e209b
(svn r20145) -Codechange: keep original RMB->tooltip behaviour when hovering is disabled and there is no handled right click event for the widget, i.e. if a widget would handle the right click you won't see the tooltip anymore by right clicking; by enabling hovering you would get access to that tooltip again.
rubidium <rubidium@openttd.org>
parents:
15472
diff
changeset
|
817 |
9df3018e209b
(svn r20145) -Codechange: keep original RMB->tooltip behaviour when hovering is disabled and there is no handled right click event for the widget, i.e. if a widget would handle the right click you won't see the tooltip anymore by right clicking; by enabling hovering you would get access to that tooltip again.
rubidium <rubidium@openttd.org>
parents:
15472
diff
changeset
|
818 /* Display info for single (articulated) vehicle, or for whole chain starting with selected vehicle */ |
9df3018e209b
(svn r20145) -Codechange: keep original RMB->tooltip behaviour when hovering is disabled and there is no handled right click event for the widget, i.e. if a widget would handle the right click you won't see the tooltip anymore by right clicking; by enabling hovering you would get access to that tooltip again.
rubidium <rubidium@openttd.org>
parents:
15472
diff
changeset
|
819 bool whole_chain = (this->type == VEH_TRAIN && _ctrl_pressed); |
9782
93d9386b56ac
(svn r13923) -Feature: Show [total-]cargo info in depot when [ctrl-]right-clicking on vehicle.
frosch <frosch@openttd.org>
parents:
9751
diff
changeset
|
820 |
15496
9df3018e209b
(svn r20145) -Codechange: keep original RMB->tooltip behaviour when hovering is disabled and there is no handled right click event for the widget, i.e. if a widget would handle the right click you won't see the tooltip anymore by right clicking; by enabling hovering you would get access to that tooltip again.
rubidium <rubidium@openttd.org>
parents:
15472
diff
changeset
|
821 /* loop through vehicle chain and collect cargos */ |
9df3018e209b
(svn r20145) -Codechange: keep original RMB->tooltip behaviour when hovering is disabled and there is no handled right click event for the widget, i.e. if a widget would handle the right click you won't see the tooltip anymore by right clicking; by enabling hovering you would get access to that tooltip again.
rubidium <rubidium@openttd.org>
parents:
15472
diff
changeset
|
822 uint num = 0; |
9df3018e209b
(svn r20145) -Codechange: keep original RMB->tooltip behaviour when hovering is disabled and there is no handled right click event for the widget, i.e. if a widget would handle the right click you won't see the tooltip anymore by right clicking; by enabling hovering you would get access to that tooltip again.
rubidium <rubidium@openttd.org>
parents:
15472
diff
changeset
|
823 for (const Vehicle *w = v; w != NULL; w = w->Next()) { |
9df3018e209b
(svn r20145) -Codechange: keep original RMB->tooltip behaviour when hovering is disabled and there is no handled right click event for the widget, i.e. if a widget would handle the right click you won't see the tooltip anymore by right clicking; by enabling hovering you would get access to that tooltip again.
rubidium <rubidium@openttd.org>
parents:
15472
diff
changeset
|
824 if (w->cargo_cap > 0 && w->cargo_type < NUM_CARGO) { |
9df3018e209b
(svn r20145) -Codechange: keep original RMB->tooltip behaviour when hovering is disabled and there is no handled right click event for the widget, i.e. if a widget would handle the right click you won't see the tooltip anymore by right clicking; by enabling hovering you would get access to that tooltip again.
rubidium <rubidium@openttd.org>
parents:
15472
diff
changeset
|
825 capacity[w->cargo_type] += w->cargo_cap; |
9df3018e209b
(svn r20145) -Codechange: keep original RMB->tooltip behaviour when hovering is disabled and there is no handled right click event for the widget, i.e. if a widget would handle the right click you won't see the tooltip anymore by right clicking; by enabling hovering you would get access to that tooltip again.
rubidium <rubidium@openttd.org>
parents:
15472
diff
changeset
|
826 loaded [w->cargo_type] += w->cargo.Count(); |
9782
93d9386b56ac
(svn r13923) -Feature: Show [total-]cargo info in depot when [ctrl-]right-clicking on vehicle.
frosch <frosch@openttd.org>
parents:
9751
diff
changeset
|
827 } |
93d9386b56ac
(svn r13923) -Feature: Show [total-]cargo info in depot when [ctrl-]right-clicking on vehicle.
frosch <frosch@openttd.org>
parents:
9751
diff
changeset
|
828 |
15496
9df3018e209b
(svn r20145) -Codechange: keep original RMB->tooltip behaviour when hovering is disabled and there is no handled right click event for the widget, i.e. if a widget would handle the right click you won't see the tooltip anymore by right clicking; by enabling hovering you would get access to that tooltip again.
rubidium <rubidium@openttd.org>
parents:
15472
diff
changeset
|
829 if (w->type == VEH_TRAIN && !Train::From(w)->HasArticulatedPart()) { |
9df3018e209b
(svn r20145) -Codechange: keep original RMB->tooltip behaviour when hovering is disabled and there is no handled right click event for the widget, i.e. if a widget would handle the right click you won't see the tooltip anymore by right clicking; by enabling hovering you would get access to that tooltip again.
rubidium <rubidium@openttd.org>
parents:
15472
diff
changeset
|
830 num++; |
9df3018e209b
(svn r20145) -Codechange: keep original RMB->tooltip behaviour when hovering is disabled and there is no handled right click event for the widget, i.e. if a widget would handle the right click you won't see the tooltip anymore by right clicking; by enabling hovering you would get access to that tooltip again.
rubidium <rubidium@openttd.org>
parents:
15472
diff
changeset
|
831 if (!whole_chain) break; |
9df3018e209b
(svn r20145) -Codechange: keep original RMB->tooltip behaviour when hovering is disabled and there is no handled right click event for the widget, i.e. if a widget would handle the right click you won't see the tooltip anymore by right clicking; by enabling hovering you would get access to that tooltip again.
rubidium <rubidium@openttd.org>
parents:
15472
diff
changeset
|
832 } |
9df3018e209b
(svn r20145) -Codechange: keep original RMB->tooltip behaviour when hovering is disabled and there is no handled right click event for the widget, i.e. if a widget would handle the right click you won't see the tooltip anymore by right clicking; by enabling hovering you would get access to that tooltip again.
rubidium <rubidium@openttd.org>
parents:
15472
diff
changeset
|
833 } |
9782
93d9386b56ac
(svn r13923) -Feature: Show [total-]cargo info in depot when [ctrl-]right-clicking on vehicle.
frosch <frosch@openttd.org>
parents:
9751
diff
changeset
|
834 |
15496
9df3018e209b
(svn r20145) -Codechange: keep original RMB->tooltip behaviour when hovering is disabled and there is no handled right click event for the widget, i.e. if a widget would handle the right click you won't see the tooltip anymore by right clicking; by enabling hovering you would get access to that tooltip again.
rubidium <rubidium@openttd.org>
parents:
15472
diff
changeset
|
835 /* Build tooltipstring */ |
9df3018e209b
(svn r20145) -Codechange: keep original RMB->tooltip behaviour when hovering is disabled and there is no handled right click event for the widget, i.e. if a widget would handle the right click you won't see the tooltip anymore by right clicking; by enabling hovering you would get access to that tooltip again.
rubidium <rubidium@openttd.org>
parents:
15472
diff
changeset
|
836 static char details[1024]; |
9df3018e209b
(svn r20145) -Codechange: keep original RMB->tooltip behaviour when hovering is disabled and there is no handled right click event for the widget, i.e. if a widget would handle the right click you won't see the tooltip anymore by right clicking; by enabling hovering you would get access to that tooltip again.
rubidium <rubidium@openttd.org>
parents:
15472
diff
changeset
|
837 details[0] = '\0'; |
9df3018e209b
(svn r20145) -Codechange: keep original RMB->tooltip behaviour when hovering is disabled and there is no handled right click event for the widget, i.e. if a widget would handle the right click you won't see the tooltip anymore by right clicking; by enabling hovering you would get access to that tooltip again.
rubidium <rubidium@openttd.org>
parents:
15472
diff
changeset
|
838 char *pos = details; |
9df3018e209b
(svn r20145) -Codechange: keep original RMB->tooltip behaviour when hovering is disabled and there is no handled right click event for the widget, i.e. if a widget would handle the right click you won't see the tooltip anymore by right clicking; by enabling hovering you would get access to that tooltip again.
rubidium <rubidium@openttd.org>
parents:
15472
diff
changeset
|
839 |
9df3018e209b
(svn r20145) -Codechange: keep original RMB->tooltip behaviour when hovering is disabled and there is no handled right click event for the widget, i.e. if a widget would handle the right click you won't see the tooltip anymore by right clicking; by enabling hovering you would get access to that tooltip again.
rubidium <rubidium@openttd.org>
parents:
15472
diff
changeset
|
840 for (CargoID cargo_type = 0; cargo_type < NUM_CARGO; cargo_type++) { |
9df3018e209b
(svn r20145) -Codechange: keep original RMB->tooltip behaviour when hovering is disabled and there is no handled right click event for the widget, i.e. if a widget would handle the right click you won't see the tooltip anymore by right clicking; by enabling hovering you would get access to that tooltip again.
rubidium <rubidium@openttd.org>
parents:
15472
diff
changeset
|
841 if (capacity[cargo_type] == 0) continue; |
9782
93d9386b56ac
(svn r13923) -Feature: Show [total-]cargo info in depot when [ctrl-]right-clicking on vehicle.
frosch <frosch@openttd.org>
parents:
9751
diff
changeset
|
842 |
15496
9df3018e209b
(svn r20145) -Codechange: keep original RMB->tooltip behaviour when hovering is disabled and there is no handled right click event for the widget, i.e. if a widget would handle the right click you won't see the tooltip anymore by right clicking; by enabling hovering you would get access to that tooltip again.
rubidium <rubidium@openttd.org>
parents:
15472
diff
changeset
|
843 SetDParam(0, cargo_type); // {CARGO} #1 |
9df3018e209b
(svn r20145) -Codechange: keep original RMB->tooltip behaviour when hovering is disabled and there is no handled right click event for the widget, i.e. if a widget would handle the right click you won't see the tooltip anymore by right clicking; by enabling hovering you would get access to that tooltip again.
rubidium <rubidium@openttd.org>
parents:
15472
diff
changeset
|
844 SetDParam(1, loaded[cargo_type]); // {CARGO} #2 |
9df3018e209b
(svn r20145) -Codechange: keep original RMB->tooltip behaviour when hovering is disabled and there is no handled right click event for the widget, i.e. if a widget would handle the right click you won't see the tooltip anymore by right clicking; by enabling hovering you would get access to that tooltip again.
rubidium <rubidium@openttd.org>
parents:
15472
diff
changeset
|
845 SetDParam(2, cargo_type); // {SHORTCARGO} #1 |
9df3018e209b
(svn r20145) -Codechange: keep original RMB->tooltip behaviour when hovering is disabled and there is no handled right click event for the widget, i.e. if a widget would handle the right click you won't see the tooltip anymore by right clicking; by enabling hovering you would get access to that tooltip again.
rubidium <rubidium@openttd.org>
parents:
15472
diff
changeset
|
846 SetDParam(3, capacity[cargo_type]); // {SHORTCARGO} #2 |
9df3018e209b
(svn r20145) -Codechange: keep original RMB->tooltip behaviour when hovering is disabled and there is no handled right click event for the widget, i.e. if a widget would handle the right click you won't see the tooltip anymore by right clicking; by enabling hovering you would get access to that tooltip again.
rubidium <rubidium@openttd.org>
parents:
15472
diff
changeset
|
847 pos = GetString(pos, STR_DEPOT_VEHICLE_TOOLTIP_CARGO, lastof(details)); |
9df3018e209b
(svn r20145) -Codechange: keep original RMB->tooltip behaviour when hovering is disabled and there is no handled right click event for the widget, i.e. if a widget would handle the right click you won't see the tooltip anymore by right clicking; by enabling hovering you would get access to that tooltip again.
rubidium <rubidium@openttd.org>
parents:
15472
diff
changeset
|
848 } |
9782
93d9386b56ac
(svn r13923) -Feature: Show [total-]cargo info in depot when [ctrl-]right-clicking on vehicle.
frosch <frosch@openttd.org>
parents:
9751
diff
changeset
|
849 |
15496
9df3018e209b
(svn r20145) -Codechange: keep original RMB->tooltip behaviour when hovering is disabled and there is no handled right click event for the widget, i.e. if a widget would handle the right click you won't see the tooltip anymore by right clicking; by enabling hovering you would get access to that tooltip again.
rubidium <rubidium@openttd.org>
parents:
15472
diff
changeset
|
850 /* Show tooltip window */ |
9df3018e209b
(svn r20145) -Codechange: keep original RMB->tooltip behaviour when hovering is disabled and there is no handled right click event for the widget, i.e. if a widget would handle the right click you won't see the tooltip anymore by right clicking; by enabling hovering you would get access to that tooltip again.
rubidium <rubidium@openttd.org>
parents:
15472
diff
changeset
|
851 uint64 args[2]; |
9df3018e209b
(svn r20145) -Codechange: keep original RMB->tooltip behaviour when hovering is disabled and there is no handled right click event for the widget, i.e. if a widget would handle the right click you won't see the tooltip anymore by right clicking; by enabling hovering you would get access to that tooltip again.
rubidium <rubidium@openttd.org>
parents:
15472
diff
changeset
|
852 args[0] = (whole_chain ? num : v->engine_type); |
9df3018e209b
(svn r20145) -Codechange: keep original RMB->tooltip behaviour when hovering is disabled and there is no handled right click event for the widget, i.e. if a widget would handle the right click you won't see the tooltip anymore by right clicking; by enabling hovering you would get access to that tooltip again.
rubidium <rubidium@openttd.org>
parents:
15472
diff
changeset
|
853 args[1] = (uint64)(size_t)details; |
9df3018e209b
(svn r20145) -Codechange: keep original RMB->tooltip behaviour when hovering is disabled and there is no handled right click event for the widget, i.e. if a widget would handle the right click you won't see the tooltip anymore by right clicking; by enabling hovering you would get access to that tooltip again.
rubidium <rubidium@openttd.org>
parents:
15472
diff
changeset
|
854 GuiShowTooltips(whole_chain ? STR_DEPOT_VEHICLE_TOOLTIP_CHAIN : STR_DEPOT_VEHICLE_TOOLTIP, 2, args, TCC_RIGHT_CLICK); |
9df3018e209b
(svn r20145) -Codechange: keep original RMB->tooltip behaviour when hovering is disabled and there is no handled right click event for the widget, i.e. if a widget would handle the right click you won't see the tooltip anymore by right clicking; by enabling hovering you would get access to that tooltip again.
rubidium <rubidium@openttd.org>
parents:
15472
diff
changeset
|
855 |
9df3018e209b
(svn r20145) -Codechange: keep original RMB->tooltip behaviour when hovering is disabled and there is no handled right click event for the widget, i.e. if a widget would handle the right click you won't see the tooltip anymore by right clicking; by enabling hovering you would get access to that tooltip again.
rubidium <rubidium@openttd.org>
parents:
15472
diff
changeset
|
856 return true; |
9782
93d9386b56ac
(svn r13923) -Feature: Show [total-]cargo info in depot when [ctrl-]right-clicking on vehicle.
frosch <frosch@openttd.org>
parents:
9751
diff
changeset
|
857 } |
93d9386b56ac
(svn r13923) -Feature: Show [total-]cargo info in depot when [ctrl-]right-clicking on vehicle.
frosch <frosch@openttd.org>
parents:
9751
diff
changeset
|
858 |
9201
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
859 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
|
860 { |
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
861 const Vehicle *v = CheckMouseOverVehicle(); |
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
862 |
12390
cca34a3de96e
(svn r16820) -Codechange: remove unused parameter in HandleCloneVehClick()
smatz <smatz@openttd.org>
parents:
12387
diff
changeset
|
863 if (v != NULL) this->HandleCloneVehClick(v); |
9201
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
864 } |
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
|
865 |
9201
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
866 virtual void OnPlaceObjectAbort() |
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
867 { |
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
868 /* abort clone */ |
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
869 this->RaiseWidget(DEPOT_WIDGET_CLONE); |
13034
6eb3f749890a
(svn r17532) -Codechange: Rename several Invalidate functions to SetDirty for more consistency and distinguishability.
frosch <frosch@openttd.org>
parents:
12953
diff
changeset
|
870 this->SetWidgetDirty(DEPOT_WIDGET_CLONE); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
871 |
9201
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
872 /* abort drag & drop */ |
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
873 this->sel = INVALID_VEHICLE; |
15253
bd9b4d0ad9fe
(svn r19888) -Add [FS#3705]: Add highlighting of drag destination in depot gui (sbr).
alberth <alberth@openttd.org>
parents:
15172
diff
changeset
|
874 this->vehicle_over = INVALID_VEHICLE; |
13034
6eb3f749890a
(svn r17532) -Codechange: Rename several Invalidate functions to SetDirty for more consistency and distinguishability.
frosch <frosch@openttd.org>
parents:
12953
diff
changeset
|
875 this->SetWidgetDirty(DEPOT_WIDGET_MATRIX); |
9201
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
876 }; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
877 |
9201
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
878 /* 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
|
879 virtual void OnMouseLoop() |
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
880 { |
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
881 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
|
882 |
9201
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
883 /* 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
|
884 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
|
885 _place_clicked_vehicle = NULL; |
12390
cca34a3de96e
(svn r16820) -Codechange: remove unused parameter in HandleCloneVehClick()
smatz <smatz@openttd.org>
parents:
12387
diff
changeset
|
886 this->HandleCloneVehClick(v); |
9201
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
887 } |
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
888 } |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
889 |
15253
bd9b4d0ad9fe
(svn r19888) -Add [FS#3705]: Add highlighting of drag destination in depot gui (sbr).
alberth <alberth@openttd.org>
parents:
15172
diff
changeset
|
890 virtual void OnMouseDrag(Point pt, int widget) |
bd9b4d0ad9fe
(svn r19888) -Add [FS#3705]: Add highlighting of drag destination in depot gui (sbr).
alberth <alberth@openttd.org>
parents:
15172
diff
changeset
|
891 { |
bd9b4d0ad9fe
(svn r19888) -Add [FS#3705]: Add highlighting of drag destination in depot gui (sbr).
alberth <alberth@openttd.org>
parents:
15172
diff
changeset
|
892 if (this->type != VEH_TRAIN || this->sel == INVALID_VEHICLE) return; |
bd9b4d0ad9fe
(svn r19888) -Add [FS#3705]: Add highlighting of drag destination in depot gui (sbr).
alberth <alberth@openttd.org>
parents:
15172
diff
changeset
|
893 |
bd9b4d0ad9fe
(svn r19888) -Add [FS#3705]: Add highlighting of drag destination in depot gui (sbr).
alberth <alberth@openttd.org>
parents:
15172
diff
changeset
|
894 /* A rail vehicle is dragged.. */ |
bd9b4d0ad9fe
(svn r19888) -Add [FS#3705]: Add highlighting of drag destination in depot gui (sbr).
alberth <alberth@openttd.org>
parents:
15172
diff
changeset
|
895 if (widget != DEPOT_WIDGET_MATRIX) { // ..outside of the depot matrix. |
bd9b4d0ad9fe
(svn r19888) -Add [FS#3705]: Add highlighting of drag destination in depot gui (sbr).
alberth <alberth@openttd.org>
parents:
15172
diff
changeset
|
896 if (this->vehicle_over != INVALID_VEHICLE) { |
bd9b4d0ad9fe
(svn r19888) -Add [FS#3705]: Add highlighting of drag destination in depot gui (sbr).
alberth <alberth@openttd.org>
parents:
15172
diff
changeset
|
897 this->vehicle_over = INVALID_VEHICLE; |
bd9b4d0ad9fe
(svn r19888) -Add [FS#3705]: Add highlighting of drag destination in depot gui (sbr).
alberth <alberth@openttd.org>
parents:
15172
diff
changeset
|
898 this->SetWidgetDirty(DEPOT_WIDGET_MATRIX); |
bd9b4d0ad9fe
(svn r19888) -Add [FS#3705]: Add highlighting of drag destination in depot gui (sbr).
alberth <alberth@openttd.org>
parents:
15172
diff
changeset
|
899 } |
bd9b4d0ad9fe
(svn r19888) -Add [FS#3705]: Add highlighting of drag destination in depot gui (sbr).
alberth <alberth@openttd.org>
parents:
15172
diff
changeset
|
900 return; |
bd9b4d0ad9fe
(svn r19888) -Add [FS#3705]: Add highlighting of drag destination in depot gui (sbr).
alberth <alberth@openttd.org>
parents:
15172
diff
changeset
|
901 } |
bd9b4d0ad9fe
(svn r19888) -Add [FS#3705]: Add highlighting of drag destination in depot gui (sbr).
alberth <alberth@openttd.org>
parents:
15172
diff
changeset
|
902 |
bd9b4d0ad9fe
(svn r19888) -Add [FS#3705]: Add highlighting of drag destination in depot gui (sbr).
alberth <alberth@openttd.org>
parents:
15172
diff
changeset
|
903 NWidgetBase *matrix = this->GetWidget<NWidgetBase>(widget); |
bd9b4d0ad9fe
(svn r19888) -Add [FS#3705]: Add highlighting of drag destination in depot gui (sbr).
alberth <alberth@openttd.org>
parents:
15172
diff
changeset
|
904 const Vehicle *v = NULL; |
bd9b4d0ad9fe
(svn r19888) -Add [FS#3705]: Add highlighting of drag destination in depot gui (sbr).
alberth <alberth@openttd.org>
parents:
15172
diff
changeset
|
905 GetDepotVehiclePtData gdvp = {NULL, NULL}; |
bd9b4d0ad9fe
(svn r19888) -Add [FS#3705]: Add highlighting of drag destination in depot gui (sbr).
alberth <alberth@openttd.org>
parents:
15172
diff
changeset
|
906 |
bd9b4d0ad9fe
(svn r19888) -Add [FS#3705]: Add highlighting of drag destination in depot gui (sbr).
alberth <alberth@openttd.org>
parents:
15172
diff
changeset
|
907 if (this->GetVehicleFromDepotWndPt(pt.x - matrix->pos_x, pt.y - matrix->pos_y, &v, &gdvp) != MODE_DRAG_VEHICLE) return; |
bd9b4d0ad9fe
(svn r19888) -Add [FS#3705]: Add highlighting of drag destination in depot gui (sbr).
alberth <alberth@openttd.org>
parents:
15172
diff
changeset
|
908 |
bd9b4d0ad9fe
(svn r19888) -Add [FS#3705]: Add highlighting of drag destination in depot gui (sbr).
alberth <alberth@openttd.org>
parents:
15172
diff
changeset
|
909 VehicleID new_vehicle_over = INVALID_VEHICLE; |
bd9b4d0ad9fe
(svn r19888) -Add [FS#3705]: Add highlighting of drag destination in depot gui (sbr).
alberth <alberth@openttd.org>
parents:
15172
diff
changeset
|
910 if (gdvp.head != NULL) { |
bd9b4d0ad9fe
(svn r19888) -Add [FS#3705]: Add highlighting of drag destination in depot gui (sbr).
alberth <alberth@openttd.org>
parents:
15172
diff
changeset
|
911 if (gdvp.wagon == NULL && gdvp.head->Last()->index != this->sel) { // ..at the end of the train. |
bd9b4d0ad9fe
(svn r19888) -Add [FS#3705]: Add highlighting of drag destination in depot gui (sbr).
alberth <alberth@openttd.org>
parents:
15172
diff
changeset
|
912 /* NOTE: As a wagon can't be moved at the begin of a train, head index isn't used to mark a drag-and-drop |
bd9b4d0ad9fe
(svn r19888) -Add [FS#3705]: Add highlighting of drag destination in depot gui (sbr).
alberth <alberth@openttd.org>
parents:
15172
diff
changeset
|
913 * destination inside a train. This head index is then used to indicate that a wagon is inserted at |
bd9b4d0ad9fe
(svn r19888) -Add [FS#3705]: Add highlighting of drag destination in depot gui (sbr).
alberth <alberth@openttd.org>
parents:
15172
diff
changeset
|
914 * the end of the train. |
bd9b4d0ad9fe
(svn r19888) -Add [FS#3705]: Add highlighting of drag destination in depot gui (sbr).
alberth <alberth@openttd.org>
parents:
15172
diff
changeset
|
915 */ |
bd9b4d0ad9fe
(svn r19888) -Add [FS#3705]: Add highlighting of drag destination in depot gui (sbr).
alberth <alberth@openttd.org>
parents:
15172
diff
changeset
|
916 new_vehicle_over = gdvp.head->index; |
bd9b4d0ad9fe
(svn r19888) -Add [FS#3705]: Add highlighting of drag destination in depot gui (sbr).
alberth <alberth@openttd.org>
parents:
15172
diff
changeset
|
917 } else if (gdvp.wagon != NULL && gdvp.head != gdvp.wagon && |
bd9b4d0ad9fe
(svn r19888) -Add [FS#3705]: Add highlighting of drag destination in depot gui (sbr).
alberth <alberth@openttd.org>
parents:
15172
diff
changeset
|
918 gdvp.wagon->index != this->sel && |
bd9b4d0ad9fe
(svn r19888) -Add [FS#3705]: Add highlighting of drag destination in depot gui (sbr).
alberth <alberth@openttd.org>
parents:
15172
diff
changeset
|
919 gdvp.wagon->Previous()->index != this->sel) { // ..over an existing wagon. |
bd9b4d0ad9fe
(svn r19888) -Add [FS#3705]: Add highlighting of drag destination in depot gui (sbr).
alberth <alberth@openttd.org>
parents:
15172
diff
changeset
|
920 new_vehicle_over = gdvp.wagon->index; |
bd9b4d0ad9fe
(svn r19888) -Add [FS#3705]: Add highlighting of drag destination in depot gui (sbr).
alberth <alberth@openttd.org>
parents:
15172
diff
changeset
|
921 } |
bd9b4d0ad9fe
(svn r19888) -Add [FS#3705]: Add highlighting of drag destination in depot gui (sbr).
alberth <alberth@openttd.org>
parents:
15172
diff
changeset
|
922 } |
bd9b4d0ad9fe
(svn r19888) -Add [FS#3705]: Add highlighting of drag destination in depot gui (sbr).
alberth <alberth@openttd.org>
parents:
15172
diff
changeset
|
923 |
bd9b4d0ad9fe
(svn r19888) -Add [FS#3705]: Add highlighting of drag destination in depot gui (sbr).
alberth <alberth@openttd.org>
parents:
15172
diff
changeset
|
924 if (this->vehicle_over == new_vehicle_over) return; |
bd9b4d0ad9fe
(svn r19888) -Add [FS#3705]: Add highlighting of drag destination in depot gui (sbr).
alberth <alberth@openttd.org>
parents:
15172
diff
changeset
|
925 |
bd9b4d0ad9fe
(svn r19888) -Add [FS#3705]: Add highlighting of drag destination in depot gui (sbr).
alberth <alberth@openttd.org>
parents:
15172
diff
changeset
|
926 this->vehicle_over = new_vehicle_over; |
bd9b4d0ad9fe
(svn r19888) -Add [FS#3705]: Add highlighting of drag destination in depot gui (sbr).
alberth <alberth@openttd.org>
parents:
15172
diff
changeset
|
927 this->SetWidgetDirty(widget); |
bd9b4d0ad9fe
(svn r19888) -Add [FS#3705]: Add highlighting of drag destination in depot gui (sbr).
alberth <alberth@openttd.org>
parents:
15172
diff
changeset
|
928 } |
bd9b4d0ad9fe
(svn r19888) -Add [FS#3705]: Add highlighting of drag destination in depot gui (sbr).
alberth <alberth@openttd.org>
parents:
15172
diff
changeset
|
929 |
9201
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
930 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
|
931 { |
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
932 switch (widget) { |
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
933 case DEPOT_WIDGET_MATRIX: { |
9344
5940dd28c40d
(svn r13240) -Codechange: More const-ness for GUI code.
peter1138 <peter1138@openttd.org>
parents:
9343
diff
changeset
|
934 const Vehicle *v = NULL; |
9201
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
935 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
|
936 |
9201
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
937 this->sel = INVALID_VEHICLE; |
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
938 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
|
939 |
13324
82e58acd7cec
(svn r17833) -Codechange: Depot gui should use relative widget coordinates for clicking.
alberth <alberth@openttd.org>
parents:
13321
diff
changeset
|
940 NWidgetBase *nwi = this->GetWidget<NWidgetBase>(DEPOT_WIDGET_MATRIX); |
9201
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
941 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
|
942 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
|
943 |
13324
82e58acd7cec
(svn r17833) -Codechange: Depot gui should use relative widget coordinates for clicking.
alberth <alberth@openttd.org>
parents:
13321
diff
changeset
|
944 if (this->GetVehicleFromDepotWndPt(pt.x - nwi->pos_x, pt.y - nwi->pos_y, &v, &gdvp) == MODE_DRAG_VEHICLE && sel != INVALID_VEHICLE) { |
9201
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
945 if (gdvp.wagon != NULL && gdvp.wagon->index == sel && _ctrl_pressed) { |
13143
dd57dca0d7c7
(svn r17648) -Codechange: Move type initialization and widget disabling to the constructor.
alberth <alberth@openttd.org>
parents:
13142
diff
changeset
|
946 DoCommandP(Vehicle::Get(sel)->tile, Vehicle::Get(sel)->index, true, |
13324
82e58acd7cec
(svn r17833) -Codechange: Depot gui should use relative widget coordinates for clicking.
alberth <alberth@openttd.org>
parents:
13321
diff
changeset
|
947 CMD_REVERSE_TRAIN_DIRECTION | CMD_MSG(STR_ERROR_CAN_T_REVERSE_DIRECTION_RAIL_VEHICLE)); |
9201
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
948 } else if (gdvp.wagon == NULL || gdvp.wagon->index != sel) { |
15253
bd9b4d0ad9fe
(svn r19888) -Add [FS#3705]: Add highlighting of drag destination in depot gui (sbr).
alberth <alberth@openttd.org>
parents:
15172
diff
changeset
|
949 this->vehicle_over = INVALID_VEHICLE; |
9201
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
950 TrainDepotMoveVehicle(gdvp.wagon, sel, gdvp.head); |
12300
7ec79afe8c18
(svn r16717) -Codechange: make IsFrontEngine() member of Train
smatz <smatz@openttd.org>
parents:
12263
diff
changeset
|
951 } else if (gdvp.head != NULL && Train::From(gdvp.head)->IsFrontEngine()) { |
9201
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
952 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
|
953 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
954 } |
13324
82e58acd7cec
(svn r17833) -Codechange: Depot gui should use relative widget coordinates for clicking.
alberth <alberth@openttd.org>
parents:
13321
diff
changeset
|
955 } else if (this->GetVehicleFromDepotWndPt(pt.x - nwi->pos_x, pt.y - nwi->pos_y, &v, NULL) == MODE_DRAG_VEHICLE && v != NULL && sel == v->index) { |
9201
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
956 ShowVehicleViewWindow(v); |
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
957 } |
15618
e4640748f223
(svn r20281) -Codechange: unify case scope closure + break coding style
rubidium <rubidium@openttd.org>
parents:
15496
diff
changeset
|
958 break; |
e4640748f223
(svn r20281) -Codechange: unify case scope closure + break coding style
rubidium <rubidium@openttd.org>
parents:
15496
diff
changeset
|
959 } |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
960 |
13145
101b6521230c
(svn r17650) -Codechange: Checking a condition once is enough.
alberth <alberth@openttd.org>
parents:
13144
diff
changeset
|
961 case DEPOT_WIDGET_SELL: case DEPOT_WIDGET_SELL_CHAIN: { |
101b6521230c
(svn r17650) -Codechange: Checking a condition once is enough.
alberth <alberth@openttd.org>
parents:
13144
diff
changeset
|
962 if (this->IsWidgetDisabled(widget)) return; |
101b6521230c
(svn r17650) -Codechange: Checking a condition once is enough.
alberth <alberth@openttd.org>
parents:
13144
diff
changeset
|
963 if (this->sel == INVALID_VEHICLE) 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
|
964 |
13145
101b6521230c
(svn r17650) -Codechange: Checking a condition once is enough.
alberth <alberth@openttd.org>
parents:
13144
diff
changeset
|
965 this->HandleButtonClick(widget); |
9201
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
966 |
13145
101b6521230c
(svn r17650) -Codechange: Checking a condition once is enough.
alberth <alberth@openttd.org>
parents:
13144
diff
changeset
|
967 const Vehicle *v = Vehicle::Get(this->sel); |
101b6521230c
(svn r17650) -Codechange: Checking a condition once is enough.
alberth <alberth@openttd.org>
parents:
13144
diff
changeset
|
968 this->sel = INVALID_VEHICLE; |
101b6521230c
(svn r17650) -Codechange: Checking a condition once is enough.
alberth <alberth@openttd.org>
parents:
13144
diff
changeset
|
969 this->SetDirty(); |
9201
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
970 |
13145
101b6521230c
(svn r17650) -Codechange: Checking a condition once is enough.
alberth <alberth@openttd.org>
parents:
13144
diff
changeset
|
971 int sell_cmd = (v->type == VEH_TRAIN && (widget == DEPOT_WIDGET_SELL_CHAIN || _ctrl_pressed)) ? 1 : 0; |
9201
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
972 |
13145
101b6521230c
(svn r17650) -Codechange: Checking a condition once is enough.
alberth <alberth@openttd.org>
parents:
13144
diff
changeset
|
973 bool is_engine = (v->type != VEH_TRAIN || Train::From(v)->IsFrontEngine()); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
974 |
13145
101b6521230c
(svn r17650) -Codechange: Checking a condition once is enough.
alberth <alberth@openttd.org>
parents:
13144
diff
changeset
|
975 if (is_engine) { |
101b6521230c
(svn r17650) -Codechange: Checking a condition once is enough.
alberth <alberth@openttd.org>
parents:
13144
diff
changeset
|
976 _backup_orders_tile = v->tile; |
101b6521230c
(svn r17650) -Codechange: Checking a condition once is enough.
alberth <alberth@openttd.org>
parents:
13144
diff
changeset
|
977 BackupVehicleOrders(v); |
101b6521230c
(svn r17650) -Codechange: Checking a condition once is enough.
alberth <alberth@openttd.org>
parents:
13144
diff
changeset
|
978 } |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
979 |
13145
101b6521230c
(svn r17650) -Codechange: Checking a condition once is enough.
alberth <alberth@openttd.org>
parents:
13144
diff
changeset
|
980 if (!DoCommandP(v->tile, v->index, sell_cmd, GetCmdSellVeh(v->type)) && is_engine) _backup_orders_tile = 0; |
15618
e4640748f223
(svn r20281) -Codechange: unify case scope closure + break coding style
rubidium <rubidium@openttd.org>
parents:
15496
diff
changeset
|
981 break; |
e4640748f223
(svn r20281) -Codechange: unify case scope closure + break coding style
rubidium <rubidium@openttd.org>
parents:
15496
diff
changeset
|
982 } |
13145
101b6521230c
(svn r17650) -Codechange: Checking a condition once is enough.
alberth <alberth@openttd.org>
parents:
13144
diff
changeset
|
983 |
9201
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
984 default: |
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
985 this->sel = INVALID_VEHICLE; |
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
986 this->SetDirty(); |
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
987 } |
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
988 _cursor.vehchain = false; |
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
989 } |
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
990 |
12729
6a7a8e1b4bde
(svn r17194) -Fix (r17175): Depot sell buttons did not raise again.
alberth <alberth@openttd.org>
parents:
12720
diff
changeset
|
991 virtual void OnTimeout() |
6a7a8e1b4bde
(svn r17194) -Fix (r17175): Depot sell buttons did not raise again.
alberth <alberth@openttd.org>
parents:
12720
diff
changeset
|
992 { |
6a7a8e1b4bde
(svn r17194) -Fix (r17175): Depot sell buttons did not raise again.
alberth <alberth@openttd.org>
parents:
12720
diff
changeset
|
993 if (!this->IsWidgetDisabled(DEPOT_WIDGET_SELL)) { |
6a7a8e1b4bde
(svn r17194) -Fix (r17175): Depot sell buttons did not raise again.
alberth <alberth@openttd.org>
parents:
12720
diff
changeset
|
994 this->RaiseWidget(DEPOT_WIDGET_SELL); |
13034
6eb3f749890a
(svn r17532) -Codechange: Rename several Invalidate functions to SetDirty for more consistency and distinguishability.
frosch <frosch@openttd.org>
parents:
12953
diff
changeset
|
995 this->SetWidgetDirty(DEPOT_WIDGET_SELL); |
12729
6a7a8e1b4bde
(svn r17194) -Fix (r17175): Depot sell buttons did not raise again.
alberth <alberth@openttd.org>
parents:
12720
diff
changeset
|
996 } |
13144
99a2d7dde8ee
(svn r17649) -Codechange: Depot gui uses pure nested widgets.
alberth <alberth@openttd.org>
parents:
13143
diff
changeset
|
997 if (this->nested_array[DEPOT_WIDGET_SELL] != NULL && !this->IsWidgetDisabled(DEPOT_WIDGET_SELL_CHAIN)) { |
12729
6a7a8e1b4bde
(svn r17194) -Fix (r17175): Depot sell buttons did not raise again.
alberth <alberth@openttd.org>
parents:
12720
diff
changeset
|
998 this->RaiseWidget(DEPOT_WIDGET_SELL_CHAIN); |
13034
6eb3f749890a
(svn r17532) -Codechange: Rename several Invalidate functions to SetDirty for more consistency and distinguishability.
frosch <frosch@openttd.org>
parents:
12953
diff
changeset
|
999 this->SetWidgetDirty(DEPOT_WIDGET_SELL_CHAIN); |
12729
6a7a8e1b4bde
(svn r17194) -Fix (r17175): Depot sell buttons did not raise again.
alberth <alberth@openttd.org>
parents:
12720
diff
changeset
|
1000 } |
6a7a8e1b4bde
(svn r17194) -Fix (r17175): Depot sell buttons did not raise again.
alberth <alberth@openttd.org>
parents:
12720
diff
changeset
|
1001 } |
6a7a8e1b4bde
(svn r17194) -Fix (r17175): Depot sell buttons did not raise again.
alberth <alberth@openttd.org>
parents:
12720
diff
changeset
|
1002 |
13344
04b02b2cfa2b
(svn r17853) -Codechange: remove the 'delta' parameter from OnResize; it was used in ways that aren't always wanted, causing bugs and the like. Also with nested widgets most reasons for handling OnResize have gone.
rubidium <rubidium@openttd.org>
parents:
13324
diff
changeset
|
1003 virtual void OnResize() |
9201
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
1004 { |
13695
75560523443c
(svn r18220) -Codechange: Reduce number of nested widget dynamic casts.
alberth <alberth@openttd.org>
parents:
13687
diff
changeset
|
1005 NWidgetCore *nwi = this->GetWidget<NWidgetCore>(DEPOT_WIDGET_MATRIX); |
14037
ca29deba0f1a
(svn r18580) -Codechange: Use widget information only for setting scrollbar capacity.
alberth <alberth@openttd.org>
parents:
14032
diff
changeset
|
1006 this->vscroll.SetCapacityFromWidget(this, DEPOT_WIDGET_MATRIX); |
13621
495608777888
(svn r18145) -Codechange: pass the 'proper' left and right values to DrawVehicleInDepot
rubidium <rubidium@openttd.org>
parents:
13609
diff
changeset
|
1007 if (this->type == VEH_TRAIN) { |
13695
75560523443c
(svn r18220) -Codechange: Reduce number of nested widget dynamic casts.
alberth <alberth@openttd.org>
parents:
13687
diff
changeset
|
1008 this->hscroll.SetCapacity(nwi->current_x - this->header_width - this->count_width); |
75560523443c
(svn r18220) -Codechange: Reduce number of nested widget dynamic casts.
alberth <alberth@openttd.org>
parents:
13687
diff
changeset
|
1009 nwi->widget_data = (this->vscroll.GetCapacity() << MAT_ROW_START) + (1 << MAT_COL_START); |
13621
495608777888
(svn r18145) -Codechange: pass the 'proper' left and right values to DrawVehicleInDepot
rubidium <rubidium@openttd.org>
parents:
13609
diff
changeset
|
1010 } else { |
14037
ca29deba0f1a
(svn r18580) -Codechange: Use widget information only for setting scrollbar capacity.
alberth <alberth@openttd.org>
parents:
14032
diff
changeset
|
1011 this->hscroll.SetCapacityFromWidget(this, DEPOT_WIDGET_MATRIX); |
13695
75560523443c
(svn r18220) -Codechange: Reduce number of nested widget dynamic casts.
alberth <alberth@openttd.org>
parents:
13687
diff
changeset
|
1012 nwi->widget_data = (this->vscroll.GetCapacity() << MAT_ROW_START) + (this->hscroll.GetCapacity() << MAT_COL_START); |
13621
495608777888
(svn r18145) -Codechange: pass the 'proper' left and right values to DrawVehicleInDepot
rubidium <rubidium@openttd.org>
parents:
13609
diff
changeset
|
1013 } |
9201
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
1014 } |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1015 |
9285
3b3f13cb6db6
(svn r13151) -Codechange: use an enum instead of bool as return type of OnKeyPress/OnCTRLStateChange to make it obvious what the return values mean.
rubidium <rubidium@openttd.org>
parents:
9274
diff
changeset
|
1016 virtual EventState OnCTRLStateChange() |
9201
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
1017 { |
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
1018 if (this->sel != INVALID_VEHICLE) { |
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
1019 _cursor.vehchain = _ctrl_pressed; |
13034
6eb3f749890a
(svn r17532) -Codechange: Rename several Invalidate functions to SetDirty for more consistency and distinguishability.
frosch <frosch@openttd.org>
parents:
12953
diff
changeset
|
1020 this->SetWidgetDirty(DEPOT_WIDGET_MATRIX); |
9931
3ed3b1a0c1b3
(svn r14086) -Fix (r13067): rail/road removing by CTRL didn't sometimes work when a depot window was opened
smatz <smatz@openttd.org>
parents:
9921
diff
changeset
|
1021 return ES_HANDLED; |
9201
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
1022 } |
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
|
1023 |
9931
3ed3b1a0c1b3
(svn r14086) -Fix (r13067): rail/road removing by CTRL didn't sometimes work when a depot window was opened
smatz <smatz@openttd.org>
parents:
9921
diff
changeset
|
1024 return ES_NOT_HANDLED; |
9201
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
1025 } |
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
1026 }; |
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
1027 |
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
1028 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
|
1029 { |
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
1030 if (confirmed) { |
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
1031 DepotWindow *w = (DepotWindow*)win; |
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
1032 TileIndex tile = w->window_number; |
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
1033 byte vehtype = w->type; |
10499
45ca88a8de7d
(svn r14754) -Codechange: get rid of _cmd_text and just pass it as (optional) parameter.
rubidium <rubidium@openttd.org>
parents:
10208
diff
changeset
|
1034 DoCommandP(tile, vehtype, 0, CMD_DEPOT_SELL_ALL_VEHICLES); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1035 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1036 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1037 |
15620
f8e9a3f0c140
(svn r20283) -Codechange: Unify start of doygen comments.
frosch <frosch@openttd.org>
parents:
15618
diff
changeset
|
1038 /** |
f8e9a3f0c140
(svn r20283) -Codechange: Unify start of doygen comments.
frosch <frosch@openttd.org>
parents:
15618
diff
changeset
|
1039 * Opens a depot window |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1040 * @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
|
1041 * @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
|
1042 */ |
6638
5479975c4e36
(svn r9869) -Codechange: replace some bytes with VehicleType, i.e. more type strictness.
rubidium <rubidium@openttd.org>
parents:
6621
diff
changeset
|
1043 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
|
1044 { |
10503
60daa84bb001
(svn r14758) -Fix: determine the real size of a depot before trying to place it.
rubidium <rubidium@openttd.org>
parents:
10499
diff
changeset
|
1045 if (BringWindowToFrontById(WC_VEHICLE_DEPOT, tile) != NULL) return; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1046 |
10503
60daa84bb001
(svn r14758) -Fix: determine the real size of a depot before trying to place it.
rubidium <rubidium@openttd.org>
parents:
10499
diff
changeset
|
1047 const WindowDesc *desc; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1048 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
|
1049 default: NOT_REACHED(); |
10503
60daa84bb001
(svn r14758) -Fix: determine the real size of a depot before trying to place it.
rubidium <rubidium@openttd.org>
parents:
10499
diff
changeset
|
1050 case VEH_TRAIN: desc = &_train_depot_desc; break; |
60daa84bb001
(svn r14758) -Fix: determine the real size of a depot before trying to place it.
rubidium <rubidium@openttd.org>
parents:
10499
diff
changeset
|
1051 case VEH_ROAD: desc = &_road_depot_desc; break; |
60daa84bb001
(svn r14758) -Fix: determine the real size of a depot before trying to place it.
rubidium <rubidium@openttd.org>
parents:
10499
diff
changeset
|
1052 case VEH_SHIP: desc = &_ship_depot_desc; break; |
60daa84bb001
(svn r14758) -Fix: determine the real size of a depot before trying to place it.
rubidium <rubidium@openttd.org>
parents:
10499
diff
changeset
|
1053 case VEH_AIRCRAFT: desc = &_aircraft_depot_desc; break; |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1054 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1055 |
10503
60daa84bb001
(svn r14758) -Fix: determine the real size of a depot before trying to place it.
rubidium <rubidium@openttd.org>
parents:
10499
diff
changeset
|
1056 new DepotWindow(desc, tile, type); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1057 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1058 |
15620
f8e9a3f0c140
(svn r20283) -Codechange: Unify start of doygen comments.
frosch <frosch@openttd.org>
parents:
15618
diff
changeset
|
1059 /** |
f8e9a3f0c140
(svn r20283) -Codechange: Unify start of doygen comments.
frosch <frosch@openttd.org>
parents:
15618
diff
changeset
|
1060 * Removes the highlight of a vehicle in a depot window |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1061 * @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
|
1062 */ |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1063 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
|
1064 { |
9201
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
1065 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
|
1066 |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1067 /* If 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
|
1068 * 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
|
1069 */ |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1070 if (_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
|
1071 |
9201
cbf6bd9b9c33
(svn r13067) -Codechange: make a class of the DepotWindow.
rubidium <rubidium@openttd.org>
parents:
9188
diff
changeset
|
1072 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
|
1073 if (w != NULL) { |
10629
4b43850f2e24
(svn r14924) -Fix (r7403): Do not unnecessarily reset the cursor, when a different vehicle is dragged.
frosch <frosch@openttd.org>
parents:
10582
diff
changeset
|
1074 if (w->sel == v->index) ResetObjectToPlace(); |
5584
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1075 } |
4b26bd55bd24
(svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff
changeset
|
1076 } |