annotate src/station_gui.cpp @ 12946:560c26f15688 draft

(svn r17439) -Fix (r17436): you weren't paid for cargo delivered to houses and headquarters anymore
author smatz <smatz@openttd.org>
date Mon, 07 Sep 2009 07:39:08 +0000
parents 06daf47f0ab2
children 6eb3f749890a
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1 /* $Id$ */
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
2
12778
bc7926153e19 (svn r17248) -Fix: add GPL license notice where appropriate
rubidium <rubidium@openttd.org>
parents: 12632
diff changeset
3 /*
bc7926153e19 (svn r17248) -Fix: add GPL license notice where appropriate
rubidium <rubidium@openttd.org>
parents: 12632
diff changeset
4 * This file is part of OpenTTD.
bc7926153e19 (svn r17248) -Fix: add GPL license notice where appropriate
rubidium <rubidium@openttd.org>
parents: 12632
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: 12632
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: 12632
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: 12632
diff changeset
8 */
bc7926153e19 (svn r17248) -Fix: add GPL license notice where appropriate
rubidium <rubidium@openttd.org>
parents: 12632
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 station_gui.cpp The GUI for stations. */
6420
080aae477331 (svn r9556) -Documentation: doxygen and comment-style changes. 'R', 'S'.. The end of the preliminary work is near
belugas <belugas@openttd.org>
parents: 6365
diff changeset
11
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
12 #include "stdafx.h"
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
13 #include "openttd.h"
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
14 #include "debug.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 "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: 8106
diff changeset
16 #include "window_gui.h"
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: 8106
diff changeset
17 #include "textbuf_gui.h"
10208
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents: 10207
diff changeset
18 #include "company_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
19 #include "command_func.h"
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
20 #include "vehicle_gui.h"
6091
17ebeb5a2c37 (svn r8826) -Codechange: Replace _cargoc's separate arrays with a regular struct array (with accessor) and implement new initialization method using cargo labels.
peter1138 <peter1138@openttd.org>
parents: 5893
diff changeset
21 #include "cargotype.h"
8016
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
22 #include "station_gui.h"
8114
2d6af5d7a142 (svn r11675) -Codechange: split the string types from the string functions.
rubidium <rubidium@openttd.org>
parents: 8109
diff changeset
23 #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: 8130
diff changeset
24 #include "window_func.h"
8224
c45446125bf0 (svn r11787) -Codechange: more header rewrites. This time related to viewport.h.
rubidium <rubidium@openttd.org>
parents: 8179
diff changeset
25 #include "viewport_func.h"
c45446125bf0 (svn r11787) -Codechange: more header rewrites. This time related to viewport.h.
rubidium <rubidium@openttd.org>
parents: 8179
diff changeset
26 #include "gfx_func.h"
8284
dbb7bfe0e95c (svn r11848) -Codechange: New class-based drop down list functionality. Lists are now dynamically generated, and can include parameters, or be extended however needed.
peter1138 <peter1138@openttd.org>
parents: 8268
diff changeset
27 #include "widgets/dropdown_func.h"
8787
ff327b646d49 (svn r12495) -Codechange: reduce the dependency on newgrf_station.h (especially because newgrf_station.h includes a lot of stuff).
rubidium <rubidium@openttd.org>
parents: 8785
diff changeset
28 #include "newgrf_cargo.h"
12228
240adc64d01a (svn r16643) -Codechange: replace GetStationByTile() by Station::GetByTile()
smatz <smatz@openttd.org>
parents: 11924
diff changeset
29 #include "station_base.h"
12564
5add58f1ce2a (svn r17002) -Change: also support distant join for waypoints
rubidium <rubidium@openttd.org>
parents: 12529
diff changeset
30 #include "waypoint_base.h"
10626
3189a053f43a (svn r14919) -Feature: distant joining of stations (Frostregen and PhilSophus)
rubidium <rubidium@openttd.org>
parents: 10565
diff changeset
31 #include "tilehighlight_func.h"
3189a053f43a (svn r14919) -Feature: distant joining of stations (Frostregen and PhilSophus)
rubidium <rubidium@openttd.org>
parents: 10565
diff changeset
32 #include "core/smallmap_type.hpp"
10208
39cf8eebfda5 (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium <rubidium@openttd.org>
parents: 10207
diff changeset
33 #include "company_base.h"
10122
dff578338ffb (svn r14306) -Codechange: unify the code to draw the vehicle list.
rubidium <rubidium@openttd.org>
parents: 10021
diff changeset
34 #include "sortlist_type.h"
10960
a4e5b5d2837c (svn r15299) -Cleanup: remove many redundant includes
smatz <smatz@openttd.org>
parents: 10952
diff changeset
35 #include "settings_type.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
36
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
37 #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
38 #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
39
8016
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
40 /**
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
41 * Draw small boxes of cargo amount and ratings data at the given
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
42 * coordinates. If amount exceeds 576 units, it is shown 'full', same
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
43 * goes for the rating: at above 90% orso (224) it is also 'full'
8016
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
44 *
11455
f339f22c86ff (svn r15813) -Codechange: remove the last remnants of the old text drawing API.
rubidium <rubidium@openttd.org>
parents: 11439
diff changeset
45 * @param left left most coordinate to draw the box at
f339f22c86ff (svn r15813) -Codechange: remove the last remnants of the old text drawing API.
rubidium <rubidium@openttd.org>
parents: 11439
diff changeset
46 * @param right right most coordinate to draw the box at
f339f22c86ff (svn r15813) -Codechange: remove the last remnants of the old text drawing API.
rubidium <rubidium@openttd.org>
parents: 11439
diff changeset
47 * @param y coordinate to draw the box at
f339f22c86ff (svn r15813) -Codechange: remove the last remnants of the old text drawing API.
rubidium <rubidium@openttd.org>
parents: 11439
diff changeset
48 * @param type Cargo 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
49 * @param amount Cargo amount
8016
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
50 * @param rating ratings data for that particular cargo
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
51 *
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
52 * @note Each cargo-bar is 16 pixels wide and 6 pixels high
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
53 * @note Each rating 14 pixels wide and 1 pixel high and is 1 pixel below the cargo-bar
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
54 */
11455
f339f22c86ff (svn r15813) -Codechange: remove the last remnants of the old text drawing API.
rubidium <rubidium@openttd.org>
parents: 11439
diff changeset
55 static void StationsWndShowStationRating(int left, int right, int y, CargoID type, uint amount, byte rating)
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
56 {
8016
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
57 static const uint units_full = 576; ///< number of units to show station as 'full'
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
58 static const uint rating_full = 224; ///< rating needed so it is shown as 'full'
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
59
12415
6a77d1df56e2 (svn r16849) -Codechange: replace GetCargo() by CargoSpec::Get()
smatz <smatz@openttd.org>
parents: 12311
diff changeset
60 const CargoSpec *cs = CargoSpec::Get(type);
6122
7b95b092af6d (svn r8858) -Codechange: Replace magic number test with class method for determining if a cargo is valid/active.
peter1138 <peter1138@openttd.org>
parents: 6091
diff changeset
61 if (!cs->IsValid()) return;
6091
17ebeb5a2c37 (svn r8826) -Codechange: Replace _cargoc's separate arrays with a regular struct array (with accessor) and implement new initialization method using cargo labels.
peter1138 <peter1138@openttd.org>
parents: 5893
diff changeset
62
17ebeb5a2c37 (svn r8826) -Codechange: Replace _cargoc's separate arrays with a regular struct array (with accessor) and implement new initialization method using cargo labels.
peter1138 <peter1138@openttd.org>
parents: 5893
diff changeset
63 int colour = cs->rating_colour;
8016
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
64 uint w = (minu(amount, units_full) + 5) / 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
65
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
66 /* Draw total cargo (limited) on station (fits into 16 pixels) */
11455
f339f22c86ff (svn r15813) -Codechange: remove the last remnants of the old text drawing API.
rubidium <rubidium@openttd.org>
parents: 11439
diff changeset
67 if (w != 0) GfxFillRect(left, y, left + w - 1, y + 6, colour);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
68
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
69 /* Draw a one pixel-wide bar of additional cargo meter, useful
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
70 * for stations with only a small amount (<=30) */
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
71 if (w == 0) {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
72 uint rest = amount / 5;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
73 if (rest != 0) {
11455
f339f22c86ff (svn r15813) -Codechange: remove the last remnants of the old text drawing API.
rubidium <rubidium@openttd.org>
parents: 11439
diff changeset
74 w += left;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
75 GfxFillRect(w, y + 6 - rest, w, y + 6, colour);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
76 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
77 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
78
11455
f339f22c86ff (svn r15813) -Codechange: remove the last remnants of the old text drawing API.
rubidium <rubidium@openttd.org>
parents: 11439
diff changeset
79 DrawString(left + 1, right, y, cs->abbrev, TC_BLACK);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
80
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
81 /* Draw green/red ratings bar (fits into 14 pixels) */
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
82 y += 8;
11455
f339f22c86ff (svn r15813) -Codechange: remove the last remnants of the old text drawing API.
rubidium <rubidium@openttd.org>
parents: 11439
diff changeset
83 GfxFillRect(left + 1, y, left + 14, y, 0xB8);
8016
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
84 rating = minu(rating, rating_full) / 16;
11455
f339f22c86ff (svn r15813) -Codechange: remove the last remnants of the old text drawing API.
rubidium <rubidium@openttd.org>
parents: 11439
diff changeset
85 if (rating != 0) GfxFillRect(left + 1, y, left + rating, y, 0xD0);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
86 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
87
9191
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
88 typedef GUIList<const Station*> GUIStationList;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
89
11821
f57a7afa131f (svn r16211) -Codechange: Moving StationListWidgets out of the window class, completing StationViewWidgets.
alberth <alberth@openttd.org>
parents: 11820
diff changeset
90 /** Enum for CompanyStations, referring to _company_stations_widgets */
f57a7afa131f (svn r16211) -Codechange: Moving StationListWidgets out of the window class, completing StationViewWidgets.
alberth <alberth@openttd.org>
parents: 11820
diff changeset
91 enum StationListWidgets {
f57a7afa131f (svn r16211) -Codechange: Moving StationListWidgets out of the window class, completing StationViewWidgets.
alberth <alberth@openttd.org>
parents: 11820
diff changeset
92 SLW_CLOSEBOX = 0, ///< Close window button
f57a7afa131f (svn r16211) -Codechange: Moving StationListWidgets out of the window class, completing StationViewWidgets.
alberth <alberth@openttd.org>
parents: 11820
diff changeset
93 SLW_CAPTION, ///< Window caption
f57a7afa131f (svn r16211) -Codechange: Moving StationListWidgets out of the window class, completing StationViewWidgets.
alberth <alberth@openttd.org>
parents: 11820
diff changeset
94 SLW_STICKY, ///< Sticky button
f57a7afa131f (svn r16211) -Codechange: Moving StationListWidgets out of the window class, completing StationViewWidgets.
alberth <alberth@openttd.org>
parents: 11820
diff changeset
95 SLW_LIST, ///< The main panel, list of stations
f57a7afa131f (svn r16211) -Codechange: Moving StationListWidgets out of the window class, completing StationViewWidgets.
alberth <alberth@openttd.org>
parents: 11820
diff changeset
96 SLW_SCROLLBAR, ///< Scrollbar next to the main panel
f57a7afa131f (svn r16211) -Codechange: Moving StationListWidgets out of the window class, completing StationViewWidgets.
alberth <alberth@openttd.org>
parents: 11820
diff changeset
97 SLW_RESIZE, ///< Resize button
f57a7afa131f (svn r16211) -Codechange: Moving StationListWidgets out of the window class, completing StationViewWidgets.
alberth <alberth@openttd.org>
parents: 11820
diff changeset
98
f57a7afa131f (svn r16211) -Codechange: Moving StationListWidgets out of the window class, completing StationViewWidgets.
alberth <alberth@openttd.org>
parents: 11820
diff changeset
99 SLW_TRAIN, ///< 'TRAIN' button - list only facilities where is a railroad station
f57a7afa131f (svn r16211) -Codechange: Moving StationListWidgets out of the window class, completing StationViewWidgets.
alberth <alberth@openttd.org>
parents: 11820
diff changeset
100 SLW_TRUCK, ///< 'TRUCK' button - list only facilities where is a truck stop
f57a7afa131f (svn r16211) -Codechange: Moving StationListWidgets out of the window class, completing StationViewWidgets.
alberth <alberth@openttd.org>
parents: 11820
diff changeset
101 SLW_BUS, ///< 'BUS' button - list only facilities where is a bus stop
f57a7afa131f (svn r16211) -Codechange: Moving StationListWidgets out of the window class, completing StationViewWidgets.
alberth <alberth@openttd.org>
parents: 11820
diff changeset
102 SLW_AIRPLANE, ///< 'AIRPLANE' button - list only facilities where is an airport
f57a7afa131f (svn r16211) -Codechange: Moving StationListWidgets out of the window class, completing StationViewWidgets.
alberth <alberth@openttd.org>
parents: 11820
diff changeset
103 SLW_SHIP, ///< 'SHIP' button - list only facilities where is a dock
f57a7afa131f (svn r16211) -Codechange: Moving StationListWidgets out of the window class, completing StationViewWidgets.
alberth <alberth@openttd.org>
parents: 11820
diff changeset
104 SLW_FACILALL, ///< 'ALL' button - list all facilities
f57a7afa131f (svn r16211) -Codechange: Moving StationListWidgets out of the window class, completing StationViewWidgets.
alberth <alberth@openttd.org>
parents: 11820
diff changeset
105
f57a7afa131f (svn r16211) -Codechange: Moving StationListWidgets out of the window class, completing StationViewWidgets.
alberth <alberth@openttd.org>
parents: 11820
diff changeset
106 SLW_PAN_BETWEEN, ///< Small panel between list of types of ficilities and list of cargo types
f57a7afa131f (svn r16211) -Codechange: Moving StationListWidgets out of the window class, completing StationViewWidgets.
alberth <alberth@openttd.org>
parents: 11820
diff changeset
107 SLW_NOCARGOWAITING, ///< 'NO' button - list stations where no cargo is waiting
f57a7afa131f (svn r16211) -Codechange: Moving StationListWidgets out of the window class, completing StationViewWidgets.
alberth <alberth@openttd.org>
parents: 11820
diff changeset
108 SLW_CARGOALL, ///< 'ALL' button - list all stations
f57a7afa131f (svn r16211) -Codechange: Moving StationListWidgets out of the window class, completing StationViewWidgets.
alberth <alberth@openttd.org>
parents: 11820
diff changeset
109 SLW_PAN_RIGHT, ///< Panel right of list of cargo types
f57a7afa131f (svn r16211) -Codechange: Moving StationListWidgets out of the window class, completing StationViewWidgets.
alberth <alberth@openttd.org>
parents: 11820
diff changeset
110
f57a7afa131f (svn r16211) -Codechange: Moving StationListWidgets out of the window class, completing StationViewWidgets.
alberth <alberth@openttd.org>
parents: 11820
diff changeset
111 SLW_SORTBY, ///< 'Sort by' button - reverse sort direction
f57a7afa131f (svn r16211) -Codechange: Moving StationListWidgets out of the window class, completing StationViewWidgets.
alberth <alberth@openttd.org>
parents: 11820
diff changeset
112 SLW_SORTDROPBTN, ///< Dropdown button
f57a7afa131f (svn r16211) -Codechange: Moving StationListWidgets out of the window class, completing StationViewWidgets.
alberth <alberth@openttd.org>
parents: 11820
diff changeset
113 SLW_PAN_SORT_RIGHT, ///< Panel right of sorting options
f57a7afa131f (svn r16211) -Codechange: Moving StationListWidgets out of the window class, completing StationViewWidgets.
alberth <alberth@openttd.org>
parents: 11820
diff changeset
114
f57a7afa131f (svn r16211) -Codechange: Moving StationListWidgets out of the window class, completing StationViewWidgets.
alberth <alberth@openttd.org>
parents: 11820
diff changeset
115 SLW_CARGOSTART, ///< Widget numbers used for list of cargo types (not present in _company_stations_widgets)
f57a7afa131f (svn r16211) -Codechange: Moving StationListWidgets out of the window class, completing StationViewWidgets.
alberth <alberth@openttd.org>
parents: 11820
diff changeset
116 };
f57a7afa131f (svn r16211) -Codechange: Moving StationListWidgets out of the window class, completing StationViewWidgets.
alberth <alberth@openttd.org>
parents: 11820
diff changeset
117
8016
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
118 /**
10207
c54d140df948 (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents: 10180
diff changeset
119 * The list of stations per company.
8016
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
120 */
10207
c54d140df948 (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents: 10180
diff changeset
121 class CompanyStationsWindow : public 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
122 {
9378
cacef2552d9f (svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13 <skidd13@openttd.org>
parents: 9377
diff changeset
123 protected:
cacef2552d9f (svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13 <skidd13@openttd.org>
parents: 9377
diff changeset
124 /* Runtime saved values */
cacef2552d9f (svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13 <skidd13@openttd.org>
parents: 9377
diff changeset
125 static Listing last_sorting;
cacef2552d9f (svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13 <skidd13@openttd.org>
parents: 9377
diff changeset
126 static byte facilities; // types of stations of interest
cacef2552d9f (svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13 <skidd13@openttd.org>
parents: 9377
diff changeset
127 static bool include_empty; // whether we should include stations without waiting cargo
cacef2552d9f (svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13 <skidd13@openttd.org>
parents: 9377
diff changeset
128 static const uint32 cargo_filter_max;
cacef2552d9f (svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13 <skidd13@openttd.org>
parents: 9377
diff changeset
129 static uint32 cargo_filter; // bitmap of cargo types to include
cacef2552d9f (svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13 <skidd13@openttd.org>
parents: 9377
diff changeset
130 static const Station *last_station;
cacef2552d9f (svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13 <skidd13@openttd.org>
parents: 9377
diff changeset
131
cacef2552d9f (svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13 <skidd13@openttd.org>
parents: 9377
diff changeset
132 /* Constants for sorting stations */
cacef2552d9f (svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13 <skidd13@openttd.org>
parents: 9377
diff changeset
133 static const StringID sorter_names[];
11376
b9b2391afd1a (svn r15726) -Codechange: unify coding style for const pointers
smatz <smatz@openttd.org>
parents: 11373
diff changeset
134 static GUIStationList::SortFunction * const sorter_funcs[];
9191
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
135
9377
1d6f7b3bf9af (svn r13283) -Codechange: convert the inheritance of GUIList in PlayerStationsWindow to a member object
skidd13 <skidd13@openttd.org>
parents: 9365
diff changeset
136 GUIStationList stations;
1d6f7b3bf9af (svn r13283) -Codechange: convert the inheritance of GUIList in PlayerStationsWindow to a member object
skidd13 <skidd13@openttd.org>
parents: 9365
diff changeset
137
9378
cacef2552d9f (svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13 <skidd13@openttd.org>
parents: 9377
diff changeset
138
cacef2552d9f (svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13 <skidd13@openttd.org>
parents: 9377
diff changeset
139 /**
cacef2552d9f (svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13 <skidd13@openttd.org>
parents: 9377
diff changeset
140 * (Re)Build station list
cacef2552d9f (svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13 <skidd13@openttd.org>
parents: 9377
diff changeset
141 *
10207
c54d140df948 (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents: 10180
diff changeset
142 * @param owner company whose stations are to be in list
9378
cacef2552d9f (svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13 <skidd13@openttd.org>
parents: 9377
diff changeset
143 */
10207
c54d140df948 (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents: 10180
diff changeset
144 void BuildStationsList(const Owner owner)
9378
cacef2552d9f (svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13 <skidd13@openttd.org>
parents: 9377
diff changeset
145 {
cacef2552d9f (svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13 <skidd13@openttd.org>
parents: 9377
diff changeset
146 if (!this->stations.NeedRebuild()) return;
cacef2552d9f (svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13 <skidd13@openttd.org>
parents: 9377
diff changeset
147
10207
c54d140df948 (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents: 10180
diff changeset
148 DEBUG(misc, 3, "Building station list for company %d", owner);
9378
cacef2552d9f (svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13 <skidd13@openttd.org>
parents: 9377
diff changeset
149
cacef2552d9f (svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13 <skidd13@openttd.org>
parents: 9377
diff changeset
150 this->stations.Clear();
cacef2552d9f (svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13 <skidd13@openttd.org>
parents: 9377
diff changeset
151
cacef2552d9f (svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13 <skidd13@openttd.org>
parents: 9377
diff changeset
152 const Station *st;
cacef2552d9f (svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13 <skidd13@openttd.org>
parents: 9377
diff changeset
153 FOR_ALL_STATIONS(st) {
12472
604a2cfc77ab (svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents: 12452
diff changeset
154 if (st->owner == owner || (st->owner == OWNER_NONE && HasStationInUse(st->index, owner))) {
9378
cacef2552d9f (svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13 <skidd13@openttd.org>
parents: 9377
diff changeset
155 if (this->facilities & st->facilities) { // only stations with selected facilities
cacef2552d9f (svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13 <skidd13@openttd.org>
parents: 9377
diff changeset
156 int num_waiting_cargo = 0;
cacef2552d9f (svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13 <skidd13@openttd.org>
parents: 9377
diff changeset
157 for (CargoID j = 0; j < NUM_CARGO; j++) {
cacef2552d9f (svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13 <skidd13@openttd.org>
parents: 9377
diff changeset
158 if (!st->goods[j].cargo.Empty()) {
cacef2552d9f (svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13 <skidd13@openttd.org>
parents: 9377
diff changeset
159 num_waiting_cargo++; // count number of waiting cargo
cacef2552d9f (svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13 <skidd13@openttd.org>
parents: 9377
diff changeset
160 if (HasBit(this->cargo_filter, j)) {
cacef2552d9f (svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13 <skidd13@openttd.org>
parents: 9377
diff changeset
161 *this->stations.Append() = st;
cacef2552d9f (svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13 <skidd13@openttd.org>
parents: 9377
diff changeset
162 break;
cacef2552d9f (svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13 <skidd13@openttd.org>
parents: 9377
diff changeset
163 }
cacef2552d9f (svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13 <skidd13@openttd.org>
parents: 9377
diff changeset
164 }
cacef2552d9f (svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13 <skidd13@openttd.org>
parents: 9377
diff changeset
165 }
cacef2552d9f (svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13 <skidd13@openttd.org>
parents: 9377
diff changeset
166 /* stations without waiting cargo */
cacef2552d9f (svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13 <skidd13@openttd.org>
parents: 9377
diff changeset
167 if (num_waiting_cargo == 0 && this->include_empty) {
cacef2552d9f (svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13 <skidd13@openttd.org>
parents: 9377
diff changeset
168 *this->stations.Append() = st;
cacef2552d9f (svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13 <skidd13@openttd.org>
parents: 9377
diff changeset
169 }
cacef2552d9f (svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13 <skidd13@openttd.org>
parents: 9377
diff changeset
170 }
cacef2552d9f (svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13 <skidd13@openttd.org>
parents: 9377
diff changeset
171 }
cacef2552d9f (svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13 <skidd13@openttd.org>
parents: 9377
diff changeset
172 }
cacef2552d9f (svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13 <skidd13@openttd.org>
parents: 9377
diff changeset
173
cacef2552d9f (svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13 <skidd13@openttd.org>
parents: 9377
diff changeset
174 this->stations.Compact();
cacef2552d9f (svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13 <skidd13@openttd.org>
parents: 9377
diff changeset
175 this->stations.RebuildDone();
12881
06daf47f0ab2 (svn r17373) -Codechange: make the timetable, station and subsidy GUIs use scrollbar wrappers
rubidium <rubidium@openttd.org>
parents: 12804
diff changeset
176
06daf47f0ab2 (svn r17373) -Codechange: make the timetable, station and subsidy GUIs use scrollbar wrappers
rubidium <rubidium@openttd.org>
parents: 12804
diff changeset
177 this->vscroll.SetCount(this->stations.Length()); // Update the scrollbar
9378
cacef2552d9f (svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13 <skidd13@openttd.org>
parents: 9377
diff changeset
178 }
cacef2552d9f (svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13 <skidd13@openttd.org>
parents: 9377
diff changeset
179
cacef2552d9f (svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13 <skidd13@openttd.org>
parents: 9377
diff changeset
180 /** Sort stations by their name */
10647
592ae9307430 (svn r14949) -Cleanup: pointer coding style
rubidium <rubidium@openttd.org>
parents: 10626
diff changeset
181 static int CDECL StationNameSorter(const Station * const *a, const Station * const *b)
9378
cacef2552d9f (svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13 <skidd13@openttd.org>
parents: 9377
diff changeset
182 {
cacef2552d9f (svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13 <skidd13@openttd.org>
parents: 9377
diff changeset
183 static char buf_cache[64];
cacef2552d9f (svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13 <skidd13@openttd.org>
parents: 9377
diff changeset
184 char buf[64];
cacef2552d9f (svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13 <skidd13@openttd.org>
parents: 9377
diff changeset
185
cacef2552d9f (svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13 <skidd13@openttd.org>
parents: 9377
diff changeset
186 SetDParam(0, (*a)->index);
12452
499dee1c27b6 (svn r16886) -Codechange: unify naming of some string IDs related to string codes and group them logically
rubidium <rubidium@openttd.org>
parents: 12418
diff changeset
187 GetString(buf, STR_STATION_NAME, lastof(buf));
9378
cacef2552d9f (svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13 <skidd13@openttd.org>
parents: 9377
diff changeset
188
cacef2552d9f (svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13 <skidd13@openttd.org>
parents: 9377
diff changeset
189 if (*b != last_station) {
cacef2552d9f (svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13 <skidd13@openttd.org>
parents: 9377
diff changeset
190 last_station = *b;
cacef2552d9f (svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13 <skidd13@openttd.org>
parents: 9377
diff changeset
191 SetDParam(0, (*b)->index);
12452
499dee1c27b6 (svn r16886) -Codechange: unify naming of some string IDs related to string codes and group them logically
rubidium <rubidium@openttd.org>
parents: 12418
diff changeset
192 GetString(buf_cache, STR_STATION_NAME, lastof(buf_cache));
9378
cacef2552d9f (svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13 <skidd13@openttd.org>
parents: 9377
diff changeset
193 }
cacef2552d9f (svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13 <skidd13@openttd.org>
parents: 9377
diff changeset
194
cacef2552d9f (svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13 <skidd13@openttd.org>
parents: 9377
diff changeset
195 return strcmp(buf, buf_cache);
cacef2552d9f (svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13 <skidd13@openttd.org>
parents: 9377
diff changeset
196 }
cacef2552d9f (svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13 <skidd13@openttd.org>
parents: 9377
diff changeset
197
cacef2552d9f (svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13 <skidd13@openttd.org>
parents: 9377
diff changeset
198 /** Sort stations by their type */
10647
592ae9307430 (svn r14949) -Cleanup: pointer coding style
rubidium <rubidium@openttd.org>
parents: 10626
diff changeset
199 static int CDECL StationTypeSorter(const Station * const *a, const Station * const *b)
9378
cacef2552d9f (svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13 <skidd13@openttd.org>
parents: 9377
diff changeset
200 {
cacef2552d9f (svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13 <skidd13@openttd.org>
parents: 9377
diff changeset
201 return (*a)->facilities - (*b)->facilities;
cacef2552d9f (svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13 <skidd13@openttd.org>
parents: 9377
diff changeset
202 }
cacef2552d9f (svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13 <skidd13@openttd.org>
parents: 9377
diff changeset
203
cacef2552d9f (svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13 <skidd13@openttd.org>
parents: 9377
diff changeset
204 /** Sort stations by their waiting cargo */
10647
592ae9307430 (svn r14949) -Cleanup: pointer coding style
rubidium <rubidium@openttd.org>
parents: 10626
diff changeset
205 static int CDECL StationWaitingSorter(const Station * const *a, const Station * const *b)
9378
cacef2552d9f (svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13 <skidd13@openttd.org>
parents: 9377
diff changeset
206 {
9580
5ef52e2f0601 (svn r13617) -Codechange: calculate the diff in StationWaitingSorter directly
skidd13 <skidd13@openttd.org>
parents: 9391
diff changeset
207 Money diff = 0;
9378
cacef2552d9f (svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13 <skidd13@openttd.org>
parents: 9377
diff changeset
208
cacef2552d9f (svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13 <skidd13@openttd.org>
parents: 9377
diff changeset
209 for (CargoID j = 0; j < NUM_CARGO; j++) {
cacef2552d9f (svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13 <skidd13@openttd.org>
parents: 9377
diff changeset
210 if (!HasBit(cargo_filter, j)) continue;
9580
5ef52e2f0601 (svn r13617) -Codechange: calculate the diff in StationWaitingSorter directly
skidd13 <skidd13@openttd.org>
parents: 9391
diff changeset
211 if (!(*a)->goods[j].cargo.Empty()) diff += GetTransportedGoodsIncome((*a)->goods[j].cargo.Count(), 20, 50, j);
5ef52e2f0601 (svn r13617) -Codechange: calculate the diff in StationWaitingSorter directly
skidd13 <skidd13@openttd.org>
parents: 9391
diff changeset
212 if (!(*b)->goods[j].cargo.Empty()) diff -= GetTransportedGoodsIncome((*b)->goods[j].cargo.Count(), 20, 50, j);
9378
cacef2552d9f (svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13 <skidd13@openttd.org>
parents: 9377
diff changeset
213 }
cacef2552d9f (svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13 <skidd13@openttd.org>
parents: 9377
diff changeset
214
9580
5ef52e2f0601 (svn r13617) -Codechange: calculate the diff in StationWaitingSorter directly
skidd13 <skidd13@openttd.org>
parents: 9391
diff changeset
215 return ClampToI32(diff);
9378
cacef2552d9f (svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13 <skidd13@openttd.org>
parents: 9377
diff changeset
216 }
cacef2552d9f (svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13 <skidd13@openttd.org>
parents: 9377
diff changeset
217
cacef2552d9f (svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13 <skidd13@openttd.org>
parents: 9377
diff changeset
218 /** Sort stations by their rating */
10647
592ae9307430 (svn r14949) -Cleanup: pointer coding style
rubidium <rubidium@openttd.org>
parents: 10626
diff changeset
219 static int CDECL StationRatingMaxSorter(const Station * const *a, const Station * const *b)
9378
cacef2552d9f (svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13 <skidd13@openttd.org>
parents: 9377
diff changeset
220 {
cacef2552d9f (svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13 <skidd13@openttd.org>
parents: 9377
diff changeset
221 byte maxr1 = 0;
cacef2552d9f (svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13 <skidd13@openttd.org>
parents: 9377
diff changeset
222 byte maxr2 = 0;
cacef2552d9f (svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13 <skidd13@openttd.org>
parents: 9377
diff changeset
223
cacef2552d9f (svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13 <skidd13@openttd.org>
parents: 9377
diff changeset
224 for (CargoID j = 0; j < NUM_CARGO; j++) {
11666
a19168510f50 (svn r16046) -Change: when sorting on cargo ratings only take a look at the ratings of the cargoes that are 'selected'.
rubidium <rubidium@openttd.org>
parents: 11665
diff changeset
225 if (!HasBit(cargo_filter, j)) continue;
9378
cacef2552d9f (svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13 <skidd13@openttd.org>
parents: 9377
diff changeset
226 if (HasBit((*a)->goods[j].acceptance_pickup, GoodsEntry::PICKUP)) maxr1 = max(maxr1, (*a)->goods[j].rating);
cacef2552d9f (svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13 <skidd13@openttd.org>
parents: 9377
diff changeset
227 if (HasBit((*b)->goods[j].acceptance_pickup, GoodsEntry::PICKUP)) maxr2 = max(maxr2, (*b)->goods[j].rating);
cacef2552d9f (svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13 <skidd13@openttd.org>
parents: 9377
diff changeset
228 }
cacef2552d9f (svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13 <skidd13@openttd.org>
parents: 9377
diff changeset
229
cacef2552d9f (svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13 <skidd13@openttd.org>
parents: 9377
diff changeset
230 return maxr1 - maxr2;
cacef2552d9f (svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13 <skidd13@openttd.org>
parents: 9377
diff changeset
231 }
cacef2552d9f (svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13 <skidd13@openttd.org>
parents: 9377
diff changeset
232
11665
933ac82c9a0b (svn r16045) -Feature [FS#597]: allow sorting stations by the lowest cargo rating instead of only by the highest cargo rating (based on the idea of KeeperOfTheSoul)
rubidium <rubidium@openttd.org>
parents: 11645
diff changeset
233 /** Sort stations by their rating */
933ac82c9a0b (svn r16045) -Feature [FS#597]: allow sorting stations by the lowest cargo rating instead of only by the highest cargo rating (based on the idea of KeeperOfTheSoul)
rubidium <rubidium@openttd.org>
parents: 11645
diff changeset
234 static int CDECL StationRatingMinSorter(const Station * const *a, const Station * const *b)
933ac82c9a0b (svn r16045) -Feature [FS#597]: allow sorting stations by the lowest cargo rating instead of only by the highest cargo rating (based on the idea of KeeperOfTheSoul)
rubidium <rubidium@openttd.org>
parents: 11645
diff changeset
235 {
11666
a19168510f50 (svn r16046) -Change: when sorting on cargo ratings only take a look at the ratings of the cargoes that are 'selected'.
rubidium <rubidium@openttd.org>
parents: 11665
diff changeset
236 byte minr1 = 255;
a19168510f50 (svn r16046) -Change: when sorting on cargo ratings only take a look at the ratings of the cargoes that are 'selected'.
rubidium <rubidium@openttd.org>
parents: 11665
diff changeset
237 byte minr2 = 255;
11665
933ac82c9a0b (svn r16045) -Feature [FS#597]: allow sorting stations by the lowest cargo rating instead of only by the highest cargo rating (based on the idea of KeeperOfTheSoul)
rubidium <rubidium@openttd.org>
parents: 11645
diff changeset
238
933ac82c9a0b (svn r16045) -Feature [FS#597]: allow sorting stations by the lowest cargo rating instead of only by the highest cargo rating (based on the idea of KeeperOfTheSoul)
rubidium <rubidium@openttd.org>
parents: 11645
diff changeset
239 for (CargoID j = 0; j < NUM_CARGO; j++) {
11666
a19168510f50 (svn r16046) -Change: when sorting on cargo ratings only take a look at the ratings of the cargoes that are 'selected'.
rubidium <rubidium@openttd.org>
parents: 11665
diff changeset
240 if (!HasBit(cargo_filter, j)) continue;
11665
933ac82c9a0b (svn r16045) -Feature [FS#597]: allow sorting stations by the lowest cargo rating instead of only by the highest cargo rating (based on the idea of KeeperOfTheSoul)
rubidium <rubidium@openttd.org>
parents: 11645
diff changeset
241 if (HasBit((*a)->goods[j].acceptance_pickup, GoodsEntry::PICKUP)) minr1 = min(minr1, (*a)->goods[j].rating);
933ac82c9a0b (svn r16045) -Feature [FS#597]: allow sorting stations by the lowest cargo rating instead of only by the highest cargo rating (based on the idea of KeeperOfTheSoul)
rubidium <rubidium@openttd.org>
parents: 11645
diff changeset
242 if (HasBit((*b)->goods[j].acceptance_pickup, GoodsEntry::PICKUP)) minr2 = min(minr2, (*b)->goods[j].rating);
933ac82c9a0b (svn r16045) -Feature [FS#597]: allow sorting stations by the lowest cargo rating instead of only by the highest cargo rating (based on the idea of KeeperOfTheSoul)
rubidium <rubidium@openttd.org>
parents: 11645
diff changeset
243 }
933ac82c9a0b (svn r16045) -Feature [FS#597]: allow sorting stations by the lowest cargo rating instead of only by the highest cargo rating (based on the idea of KeeperOfTheSoul)
rubidium <rubidium@openttd.org>
parents: 11645
diff changeset
244
11666
a19168510f50 (svn r16046) -Change: when sorting on cargo ratings only take a look at the ratings of the cargoes that are 'selected'.
rubidium <rubidium@openttd.org>
parents: 11665
diff changeset
245 return -(minr1 - minr2);
11665
933ac82c9a0b (svn r16045) -Feature [FS#597]: allow sorting stations by the lowest cargo rating instead of only by the highest cargo rating (based on the idea of KeeperOfTheSoul)
rubidium <rubidium@openttd.org>
parents: 11645
diff changeset
246 }
933ac82c9a0b (svn r16045) -Feature [FS#597]: allow sorting stations by the lowest cargo rating instead of only by the highest cargo rating (based on the idea of KeeperOfTheSoul)
rubidium <rubidium@openttd.org>
parents: 11645
diff changeset
247
9378
cacef2552d9f (svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13 <skidd13@openttd.org>
parents: 9377
diff changeset
248 /** Sort the stations list */
cacef2552d9f (svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13 <skidd13@openttd.org>
parents: 9377
diff changeset
249 void SortStationsList()
cacef2552d9f (svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13 <skidd13@openttd.org>
parents: 9377
diff changeset
250 {
9379
211a8cd2908e (svn r13286) -Codechange: GUIList Sort returns now if the list sequence has been altered
skidd13 <skidd13@openttd.org>
parents: 9378
diff changeset
251 if (!this->stations.Sort()) return;
9378
cacef2552d9f (svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13 <skidd13@openttd.org>
parents: 9377
diff changeset
252
cacef2552d9f (svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13 <skidd13@openttd.org>
parents: 9377
diff changeset
253 /* Reset name sorter sort cache */
cacef2552d9f (svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13 <skidd13@openttd.org>
parents: 9377
diff changeset
254 this->last_station = NULL;
cacef2552d9f (svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13 <skidd13@openttd.org>
parents: 9377
diff changeset
255
9389
b81a2f5313a9 (svn r13299) -Fix (r13286): Stations sort type isn't updated correctly
skidd13 <skidd13@openttd.org>
parents: 9382
diff changeset
256 /* Set the modified widget dirty */
9378
cacef2552d9f (svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13 <skidd13@openttd.org>
parents: 9377
diff changeset
257 this->InvalidateWidget(SLW_LIST);
cacef2552d9f (svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13 <skidd13@openttd.org>
parents: 9377
diff changeset
258 }
cacef2552d9f (svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13 <skidd13@openttd.org>
parents: 9377
diff changeset
259
cacef2552d9f (svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13 <skidd13@openttd.org>
parents: 9377
diff changeset
260 public:
10207
c54d140df948 (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents: 10180
diff changeset
261 CompanyStationsWindow(const WindowDesc *desc, WindowNumber window_number) : Window(desc, window_number)
9191
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
262 {
11084
e07c7d3925c8 (svn r15427) -Codechange: give w->caption_color a more sensible name as it holds the owner of whatever is shown in the window
rubidium <rubidium@openttd.org>
parents: 11080
diff changeset
263 this->owner = (Owner)this->window_number;
12881
06daf47f0ab2 (svn r17373) -Codechange: make the timetable, station and subsidy GUIs use scrollbar wrappers
rubidium <rubidium@openttd.org>
parents: 12804
diff changeset
264 this->vscroll.SetCapacity(12);
9191
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
265 this->resize.step_height = 10;
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
266 this->resize.height = this->height - 10 * 7; // minimum if 5 in the list
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
267
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
268 /* Add cargo filter buttons */
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
269 uint num_active = 0;
12418
0d8340a4c70e (svn r16852) -Codechange: use FOR_ALL_CARGOSPECS for iterating over all valid CargoSpecs
smatz <smatz@openttd.org>
parents: 12415
diff changeset
270 const CargoSpec *cs;
0d8340a4c70e (svn r16852) -Codechange: use FOR_ALL_CARGOSPECS for iterating over all valid CargoSpecs
smatz <smatz@openttd.org>
parents: 12415
diff changeset
271 FOR_ALL_CARGOSPECS(cs) {
0d8340a4c70e (svn r16852) -Codechange: use FOR_ALL_CARGOSPECS for iterating over all valid CargoSpecs
smatz <smatz@openttd.org>
parents: 12415
diff changeset
272 num_active++;
9191
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
273 }
5608
5dcef0df6a67 (svn r8065) -Feature: The station list does now remember the sort settings
celestar <celestar@openttd.org>
parents: 5587
diff changeset
274
9191
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
275 this->widget_count += num_active;
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
276 this->widget = ReallocT(this->widget, this->widget_count + 1);
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
277 this->widget[this->widget_count].type = WWT_LAST;
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
278
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
279 uint i = 0;
12418
0d8340a4c70e (svn r16852) -Codechange: use FOR_ALL_CARGOSPECS for iterating over all valid CargoSpecs
smatz <smatz@openttd.org>
parents: 12415
diff changeset
280 FOR_ALL_CARGOSPECS(cs) {
9191
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
281 Widget *wi = &this->widget[SLW_CARGOSTART + i];
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
282 wi->type = WWT_PANEL;
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
283 wi->display_flags = RESIZE_NONE;
11080
02d314ea4f63 (svn r15423) -Codechange: split widget related types to their own header and add a bit of type strictness.
rubidium <rubidium@openttd.org>
parents: 11072
diff changeset
284 wi->colour = COLOUR_GREY;
9191
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
285 wi->left = 89 + i * 14;
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
286 wi->right = wi->left + 13;
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
287 wi->top = 14;
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
288 wi->bottom = 24;
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
289 wi->data = 0;
12632
e41943276802 (svn r17075) -Codechange: rename ~750 strings to be more uniform with their relatives
rubidium <rubidium@openttd.org>
parents: 12564
diff changeset
290 wi->tooltips = STR_STATION_LIST_USE_CTRL_TO_SELECT_MORE;
9191
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
291
12418
0d8340a4c70e (svn r16852) -Codechange: use FOR_ALL_CARGOSPECS for iterating over all valid CargoSpecs
smatz <smatz@openttd.org>
parents: 12415
diff changeset
292 if (HasBit(this->cargo_filter, cs->Index())) this->LowerWidget(SLW_CARGOSTART + i);
9191
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
293 i++;
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
294 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
295
9191
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
296 this->widget[SLW_NOCARGOWAITING].left += num_active * 14;
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
297 this->widget[SLW_NOCARGOWAITING].right += num_active * 14;
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
298 this->widget[SLW_CARGOALL].left += num_active * 14;
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
299 this->widget[SLW_CARGOALL].right += num_active * 14;
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
300 this->widget[SLW_PAN_RIGHT].left += num_active * 14;
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
301
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
302 if (num_active > 15) {
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
303 /* Resize and fix the minimum width, if necessary */
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
304 ResizeWindow(this, (num_active - 15) * 14, 0);
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
305 this->resize.width = this->width;
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
306 }
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
307
9378
cacef2552d9f (svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13 <skidd13@openttd.org>
parents: 9377
diff changeset
308 if (this->cargo_filter == this->cargo_filter_max) this->cargo_filter = _cargo_mask;
9191
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
309
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
310 for (uint i = 0; i < 5; i++) {
9378
cacef2552d9f (svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13 <skidd13@openttd.org>
parents: 9377
diff changeset
311 if (HasBit(this->facilities, i)) this->LowerWidget(i + SLW_TRAIN);
9191
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
312 }
9378
cacef2552d9f (svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13 <skidd13@openttd.org>
parents: 9377
diff changeset
313 this->SetWidgetLoweredState(SLW_FACILALL, this->facilities == (FACIL_TRAIN | FACIL_TRUCK_STOP | FACIL_BUS_STOP | FACIL_AIRPORT | FACIL_DOCK));
cacef2552d9f (svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13 <skidd13@openttd.org>
parents: 9377
diff changeset
314 this->SetWidgetLoweredState(SLW_CARGOALL, this->cargo_filter == _cargo_mask && this->include_empty);
cacef2552d9f (svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13 <skidd13@openttd.org>
parents: 9377
diff changeset
315 this->SetWidgetLoweredState(SLW_NOCARGOWAITING, this->include_empty);
6271
56a8bb763a87 (svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138 <peter1138@openttd.org>
parents: 6260
diff changeset
316
9378
cacef2552d9f (svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13 <skidd13@openttd.org>
parents: 9377
diff changeset
317 this->stations.SetListing(this->last_sorting);
cacef2552d9f (svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13 <skidd13@openttd.org>
parents: 9377
diff changeset
318 this->stations.SetSortFuncs(this->sorter_funcs);
9377
1d6f7b3bf9af (svn r13283) -Codechange: convert the inheritance of GUIList in PlayerStationsWindow to a member object
skidd13 <skidd13@openttd.org>
parents: 9365
diff changeset
319 this->stations.ForceRebuild();
1d6f7b3bf9af (svn r13283) -Codechange: convert the inheritance of GUIList in PlayerStationsWindow to a member object
skidd13 <skidd13@openttd.org>
parents: 9365
diff changeset
320 this->stations.NeedResort();
9378
cacef2552d9f (svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13 <skidd13@openttd.org>
parents: 9377
diff changeset
321 this->SortStationsList();
9333
5236ba6c7d54 (svn r13225) -Fix (r13041): Missing calls to FindWindowPlacementAndResize() from lots
peter1138 <peter1138@openttd.org>
parents: 9317
diff changeset
322
9389
b81a2f5313a9 (svn r13299) -Fix (r13286): Stations sort type isn't updated correctly
skidd13 <skidd13@openttd.org>
parents: 9382
diff changeset
323 this->widget[SLW_SORTDROPBTN].data = this->sorter_names[this->stations.SortType()];
b81a2f5313a9 (svn r13299) -Fix (r13286): Stations sort type isn't updated correctly
skidd13 <skidd13@openttd.org>
parents: 9382
diff changeset
324
9333
5236ba6c7d54 (svn r13225) -Fix (r13041): Missing calls to FindWindowPlacementAndResize() from lots
peter1138 <peter1138@openttd.org>
parents: 9317
diff changeset
325 this->FindWindowPlacementAndResize(desc);
9191
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
326 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
327
10207
c54d140df948 (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents: 10180
diff changeset
328 ~CompanyStationsWindow()
9377
1d6f7b3bf9af (svn r13283) -Codechange: convert the inheritance of GUIList in PlayerStationsWindow to a member object
skidd13 <skidd13@openttd.org>
parents: 9365
diff changeset
329 {
9378
cacef2552d9f (svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13 <skidd13@openttd.org>
parents: 9377
diff changeset
330 this->last_sorting = this->stations.GetListing();
9377
1d6f7b3bf9af (svn r13283) -Codechange: convert the inheritance of GUIList in PlayerStationsWindow to a member object
skidd13 <skidd13@openttd.org>
parents: 9365
diff changeset
331 }
1d6f7b3bf9af (svn r13283) -Codechange: convert the inheritance of GUIList in PlayerStationsWindow to a member object
skidd13 <skidd13@openttd.org>
parents: 9365
diff changeset
332
9191
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
333 virtual void OnPaint()
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
334 {
10207
c54d140df948 (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents: 10180
diff changeset
335 const Owner owner = (Owner)this->window_number;
9191
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
336
9378
cacef2552d9f (svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13 <skidd13@openttd.org>
parents: 9377
diff changeset
337 this->BuildStationsList(owner);
cacef2552d9f (svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13 <skidd13@openttd.org>
parents: 9377
diff changeset
338 this->SortStationsList();
8016
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
339
10207
c54d140df948 (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents: 10180
diff changeset
340 /* draw widgets, with company's name in the caption */
9191
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
341 SetDParam(0, owner);
12881
06daf47f0ab2 (svn r17373) -Codechange: make the timetable, station and subsidy GUIs use scrollbar wrappers
rubidium <rubidium@openttd.org>
parents: 12804
diff changeset
342 SetDParam(1, this->vscroll.GetCount());
9191
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
343
9273
72a6d2e60834 (svn r13139) -Codechange: move DrawWindowWidgets and DrawWindowViewport to the Window class and remove Window from their naming.
rubidium <rubidium@openttd.org>
parents: 9214
diff changeset
344 this->DrawWidgets();
9191
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
345
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
346 /* draw arrow pointing up/down for ascending/descending sorting */
9377
1d6f7b3bf9af (svn r13283) -Codechange: convert the inheritance of GUIList in PlayerStationsWindow to a member object
skidd13 <skidd13@openttd.org>
parents: 9365
diff changeset
347 this->DrawSortButtonState(SLW_SORTBY, this->stations.IsDescSortOrder() ? SBS_DOWN : SBS_UP);
9191
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
348
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
349 int cg_ofst;
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
350 int x = 89;
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
351 int y = 14;
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
352 int xb = 2; ///< offset from left of widget
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
353
9191
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
354 uint i = 0;
12418
0d8340a4c70e (svn r16852) -Codechange: use FOR_ALL_CARGOSPECS for iterating over all valid CargoSpecs
smatz <smatz@openttd.org>
parents: 12415
diff changeset
355 const CargoSpec *cs;
0d8340a4c70e (svn r16852) -Codechange: use FOR_ALL_CARGOSPECS for iterating over all valid CargoSpecs
smatz <smatz@openttd.org>
parents: 12415
diff changeset
356 FOR_ALL_CARGOSPECS(cs) {
0d8340a4c70e (svn r16852) -Codechange: use FOR_ALL_CARGOSPECS for iterating over all valid CargoSpecs
smatz <smatz@openttd.org>
parents: 12415
diff changeset
357 cg_ofst = HasBit(this->cargo_filter, cs->Index()) ? 2 : 1;
9191
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
358 GfxFillRect(x + cg_ofst, y + cg_ofst, x + cg_ofst + 10 , y + cg_ofst + 7, cs->rating_colour);
11432
a20dd0000d96 (svn r15790) -Codechange: remove the *Centered part of the old text drawing API.
rubidium <rubidium@openttd.org>
parents: 11427
diff changeset
359 DrawString(x + cg_ofst, x + 12 + cg_ofst, y + cg_ofst, cs->abbrev, TC_BLACK, SA_CENTER);
9191
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
360 x += 14;
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
361 i++;
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
362 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
363
9191
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
364 cg_ofst = this->IsWidgetLowered(SLW_NOCARGOWAITING) ? 2 : 1;
11432
a20dd0000d96 (svn r15790) -Codechange: remove the *Centered part of the old text drawing API.
rubidium <rubidium@openttd.org>
parents: 11427
diff changeset
365 DrawString(x + cg_ofst, x + cg_ofst + 12, y + cg_ofst, STR_ABBREV_NONE, TC_BLACK, SA_CENTER);
9191
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
366 x += 14;
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
367 cg_ofst = this->IsWidgetLowered(SLW_CARGOALL) ? 2 : 1;
11432
a20dd0000d96 (svn r15790) -Codechange: remove the *Centered part of the old text drawing API.
rubidium <rubidium@openttd.org>
parents: 11427
diff changeset
368 DrawString(x + cg_ofst, x + cg_ofst + 12, y + cg_ofst, STR_ABBREV_ALL, TC_BLACK, SA_CENTER);
9191
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
369
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
370 cg_ofst = this->IsWidgetLowered(SLW_FACILALL) ? 2 : 1;
11455
f339f22c86ff (svn r15813) -Codechange: remove the last remnants of the old text drawing API.
rubidium <rubidium@openttd.org>
parents: 11439
diff changeset
371 DrawString(71 + cg_ofst, 71 + cg_ofst + 12, y + cg_ofst, STR_ABBREV_ALL, TC_BLACK);
8338
133b06cabee8 (svn r11904) -Codechange: use dropdown widget in 3 more windows, build vehicle, group vehicle list and station list.
peter1138 <peter1138@openttd.org>
parents: 8284
diff changeset
372
12881
06daf47f0ab2 (svn r17373) -Codechange: make the timetable, station and subsidy GUIs use scrollbar wrappers
rubidium <rubidium@openttd.org>
parents: 12804
diff changeset
373 if (this->vscroll.GetCount() == 0) { // company has no stations
11770
534c3c3167f2 (svn r16160) -Codechange: remove the need for explicit TC_FROMSTRING for DrawString.
rubidium <rubidium@openttd.org>
parents: 11730
diff changeset
374 DrawString(xb, this->width, 40, STR_STATION_LIST_NONE);
9191
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
375 return;
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
376 }
8338
133b06cabee8 (svn r11904) -Codechange: use dropdown widget in 3 more windows, build vehicle, group vehicle list and station list.
peter1138 <peter1138@openttd.org>
parents: 8284
diff changeset
377
12881
06daf47f0ab2 (svn r17373) -Codechange: make the timetable, station and subsidy GUIs use scrollbar wrappers
rubidium <rubidium@openttd.org>
parents: 12804
diff changeset
378 int max = min(this->vscroll.GetPosition() + this->vscroll.GetCapacity(), this->stations.Length());
9191
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
379 y = 40; // start of the list-widget
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
380
12881
06daf47f0ab2 (svn r17373) -Codechange: make the timetable, station and subsidy GUIs use scrollbar wrappers
rubidium <rubidium@openttd.org>
parents: 12804
diff changeset
381 for (int i = this->vscroll.GetPosition(); i < max; ++i) { // do until max number of stations of owner
9377
1d6f7b3bf9af (svn r13283) -Codechange: convert the inheritance of GUIList in PlayerStationsWindow to a member object
skidd13 <skidd13@openttd.org>
parents: 9365
diff changeset
382 const Station *st = this->stations[i];
9191
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
383 int x;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
384
10488
a9ecb9be9814 (svn r14743) -Codechange: use INVALID_TILE to indicate station doesn't have queried facility (or station/roadstop is invalid) instead of 0 (Yexo)
smatz <smatz@openttd.org>
parents: 10208
diff changeset
385 assert(st->xy != INVALID_TILE);
9191
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
386
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
387 /* Do not do the complex check HasStationInUse here, it may be even false
11361
02313cc6114e (svn r15711) -Codechange: lots of whitespace cleanup/fixes
rubidium <rubidium@openttd.org>
parents: 11084
diff changeset
388 * when the order had been removed and the station list hasn't been removed yet */
12472
604a2cfc77ab (svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents: 12452
diff changeset
389 assert(st->owner == owner || st->owner == OWNER_NONE);
9191
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
390
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
391 SetDParam(0, st->index);
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
392 SetDParam(1, st->facilities);
11770
534c3c3167f2 (svn r16160) -Codechange: remove the need for explicit TC_FROMSTRING for DrawString.
rubidium <rubidium@openttd.org>
parents: 11730
diff changeset
393 x = DrawString(xb, this->widget[SLW_LIST].right, y, STR_STATION_LIST_STATION) + 5;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
394
9191
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
395 /* show cargo waiting and station ratings */
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
396 for (CargoID j = 0; j < NUM_CARGO; j++) {
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
397 if (!st->goods[j].cargo.Empty()) {
11455
f339f22c86ff (svn r15813) -Codechange: remove the last remnants of the old text drawing API.
rubidium <rubidium@openttd.org>
parents: 11439
diff changeset
398 StationsWndShowStationRating(x, this->widget[SLW_LIST].right, y, j, st->goods[j].cargo.Count(), st->goods[j].rating);
9191
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
399 x += 20;
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
400 }
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
401 }
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
402 y += 10;
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
403 }
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
404 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
405
9191
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
406 virtual void OnClick(Point pt, int widget)
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
407 {
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
408 switch (widget) {
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
409 case SLW_LIST: {
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
410 uint32 id_v = (pt.y - 41) / 10;
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
411
12881
06daf47f0ab2 (svn r17373) -Codechange: make the timetable, station and subsidy GUIs use scrollbar wrappers
rubidium <rubidium@openttd.org>
parents: 12804
diff changeset
412 if (id_v >= this->vscroll.GetCapacity()) return; // click out of bounds
9191
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
413
12881
06daf47f0ab2 (svn r17373) -Codechange: make the timetable, station and subsidy GUIs use scrollbar wrappers
rubidium <rubidium@openttd.org>
parents: 12804
diff changeset
414 id_v += this->vscroll.GetPosition();
6271
56a8bb763a87 (svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138 <peter1138@openttd.org>
parents: 6260
diff changeset
415
9377
1d6f7b3bf9af (svn r13283) -Codechange: convert the inheritance of GUIList in PlayerStationsWindow to a member object
skidd13 <skidd13@openttd.org>
parents: 9365
diff changeset
416 if (id_v >= this->stations.Length()) return; // click out of list bound
9191
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
417
9377
1d6f7b3bf9af (svn r13283) -Codechange: convert the inheritance of GUIList in PlayerStationsWindow to a member object
skidd13 <skidd13@openttd.org>
parents: 9365
diff changeset
418 const Station *st = this->stations[id_v];
9191
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
419 /* do not check HasStationInUse - it is slow and may be invalid */
12472
604a2cfc77ab (svn r16909) -Fix [FS#2996]: NewGRF stations would be triggering assertions all over the place when using the more advanced station types.
rubidium <rubidium@openttd.org>
parents: 12452
diff changeset
420 assert(st->owner == (Owner)this->window_number || st->owner == OWNER_NONE);
9191
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
421
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
422 if (_ctrl_pressed) {
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
423 ShowExtraViewPortWindow(st->xy);
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
424 } else {
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
425 ScrollMainWindowToTile(st->xy);
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
426 }
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
427 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
428 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
429
9191
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
430 case SLW_TRAIN:
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
431 case SLW_TRUCK:
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
432 case SLW_BUS:
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
433 case SLW_AIRPLANE:
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
434 case SLW_SHIP:
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
435 if (_ctrl_pressed) {
9378
cacef2552d9f (svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13 <skidd13@openttd.org>
parents: 9377
diff changeset
436 ToggleBit(this->facilities, widget - SLW_TRAIN);
9191
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
437 this->ToggleWidgetLoweredState(widget);
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
438 } else {
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
439 uint i;
9378
cacef2552d9f (svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13 <skidd13@openttd.org>
parents: 9377
diff changeset
440 FOR_EACH_SET_BIT(i, this->facilities) {
9191
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
441 this->RaiseWidget(i + SLW_TRAIN);
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
442 }
9378
cacef2552d9f (svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13 <skidd13@openttd.org>
parents: 9377
diff changeset
443 SetBit(this->facilities, widget - SLW_TRAIN);
9191
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
444 this->LowerWidget(widget);
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
445 }
9378
cacef2552d9f (svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13 <skidd13@openttd.org>
parents: 9377
diff changeset
446 this->SetWidgetLoweredState(SLW_FACILALL, this->facilities == (FACIL_TRAIN | FACIL_TRUCK_STOP | FACIL_BUS_STOP | FACIL_AIRPORT | FACIL_DOCK));
9377
1d6f7b3bf9af (svn r13283) -Codechange: convert the inheritance of GUIList in PlayerStationsWindow to a member object
skidd13 <skidd13@openttd.org>
parents: 9365
diff changeset
447 this->stations.ForceRebuild();
9191
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
448 this->SetDirty();
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
449 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
450
9191
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
451 case SLW_FACILALL:
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
452 for (uint i = 0; i < 5; i++) {
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
453 this->LowerWidget(i + SLW_TRAIN);
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
454 }
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
455 this->LowerWidget(SLW_FACILALL);
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
456
9378
cacef2552d9f (svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13 <skidd13@openttd.org>
parents: 9377
diff changeset
457 this->facilities = FACIL_TRAIN | FACIL_TRUCK_STOP | FACIL_BUS_STOP | FACIL_AIRPORT | FACIL_DOCK;
9377
1d6f7b3bf9af (svn r13283) -Codechange: convert the inheritance of GUIList in PlayerStationsWindow to a member object
skidd13 <skidd13@openttd.org>
parents: 9365
diff changeset
458 this->stations.ForceRebuild();
9191
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
459 this->SetDirty();
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
460 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
461
9191
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
462 case SLW_CARGOALL: {
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
463 uint i = 0;
12418
0d8340a4c70e (svn r16852) -Codechange: use FOR_ALL_CARGOSPECS for iterating over all valid CargoSpecs
smatz <smatz@openttd.org>
parents: 12415
diff changeset
464 const CargoSpec *cs;
0d8340a4c70e (svn r16852) -Codechange: use FOR_ALL_CARGOSPECS for iterating over all valid CargoSpecs
smatz <smatz@openttd.org>
parents: 12415
diff changeset
465 FOR_ALL_CARGOSPECS(cs) {
9191
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
466 this->LowerWidget(i + SLW_CARGOSTART);
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
467 i++;
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
468 }
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
469 this->LowerWidget(SLW_NOCARGOWAITING);
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
470 this->LowerWidget(SLW_CARGOALL);
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
471
9378
cacef2552d9f (svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13 <skidd13@openttd.org>
parents: 9377
diff changeset
472 this->cargo_filter = _cargo_mask;
cacef2552d9f (svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13 <skidd13@openttd.org>
parents: 9377
diff changeset
473 this->include_empty = true;
9377
1d6f7b3bf9af (svn r13283) -Codechange: convert the inheritance of GUIList in PlayerStationsWindow to a member object
skidd13 <skidd13@openttd.org>
parents: 9365
diff changeset
474 this->stations.ForceRebuild();
9191
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
475 this->SetDirty();
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
476 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
477 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
478
9191
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
479 case SLW_SORTBY: // flip sorting method asc/desc
9377
1d6f7b3bf9af (svn r13283) -Codechange: convert the inheritance of GUIList in PlayerStationsWindow to a member object
skidd13 <skidd13@openttd.org>
parents: 9365
diff changeset
480 this->stations.ToggleSortOrder();
10180
e024f1d28082 (svn r14390) -Codechange: replace magic constants with symbolic constants.
rubidium <rubidium@openttd.org>
parents: 10148
diff changeset
481 this->flags4 |= WF_TIMEOUT_BEGIN;
9191
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
482 this->LowerWidget(SLW_SORTBY);
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
483 this->SetDirty();
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
484 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
485
9191
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
486 case SLW_SORTDROPBTN: // select sorting criteria dropdown menu
9378
cacef2552d9f (svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13 <skidd13@openttd.org>
parents: 9377
diff changeset
487 ShowDropDownMenu(this, this->sorter_names, this->stations.SortType(), SLW_SORTDROPBTN, 0, 0);
9191
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
488 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
489
9191
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
490 case SLW_NOCARGOWAITING:
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
491 if (_ctrl_pressed) {
9378
cacef2552d9f (svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13 <skidd13@openttd.org>
parents: 9377
diff changeset
492 this->include_empty = !this->include_empty;
9191
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
493 this->ToggleWidgetLoweredState(SLW_NOCARGOWAITING);
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
494 } else {
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
495 for (uint i = SLW_CARGOSTART; i < this->widget_count; i++) {
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
496 this->RaiseWidget(i);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
497 }
9191
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
498
9378
cacef2552d9f (svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13 <skidd13@openttd.org>
parents: 9377
diff changeset
499 this->cargo_filter = 0;
cacef2552d9f (svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13 <skidd13@openttd.org>
parents: 9377
diff changeset
500 this->include_empty = true;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
501
9191
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
502 this->LowerWidget(SLW_NOCARGOWAITING);
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
503 }
9378
cacef2552d9f (svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13 <skidd13@openttd.org>
parents: 9377
diff changeset
504 this->SetWidgetLoweredState(SLW_CARGOALL, this->cargo_filter == _cargo_mask && this->include_empty);
9377
1d6f7b3bf9af (svn r13283) -Codechange: convert the inheritance of GUIList in PlayerStationsWindow to a member object
skidd13 <skidd13@openttd.org>
parents: 9365
diff changeset
505 this->stations.ForceRebuild();
9191
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
506 this->SetDirty();
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
507 break;
6202
eb0fdb88a922 (svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138 <peter1138@openttd.org>
parents: 6122
diff changeset
508
9191
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
509 default:
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
510 if (widget >= SLW_CARGOSTART) { // change cargo_filter
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
511 /* Determine the selected cargo type */
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
512 int i = 0;
12418
0d8340a4c70e (svn r16852) -Codechange: use FOR_ALL_CARGOSPECS for iterating over all valid CargoSpecs
smatz <smatz@openttd.org>
parents: 12415
diff changeset
513 const CargoSpec *cs;
0d8340a4c70e (svn r16852) -Codechange: use FOR_ALL_CARGOSPECS for iterating over all valid CargoSpecs
smatz <smatz@openttd.org>
parents: 12415
diff changeset
514 FOR_ALL_CARGOSPECS(cs) {
9191
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
515 if (widget - SLW_CARGOSTART == i) break;
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
516 i++;
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
517 }
9094
a3f3038e9b9a (svn r12953) -Feature: Open a new viewport when ctrl-clicking on a 'Location' button, a town/station/industry list, or some news items.
peter1138 <peter1138@openttd.org>
parents: 8992
diff changeset
518
a3f3038e9b9a (svn r12953) -Feature: Open a new viewport when ctrl-clicking on a 'Location' button, a town/station/industry list, or some news items.
peter1138 <peter1138@openttd.org>
parents: 8992
diff changeset
519 if (_ctrl_pressed) {
12418
0d8340a4c70e (svn r16852) -Codechange: use FOR_ALL_CARGOSPECS for iterating over all valid CargoSpecs
smatz <smatz@openttd.org>
parents: 12415
diff changeset
520 ToggleBit(this->cargo_filter, cs->Index());
9191
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
521 this->ToggleWidgetLoweredState(widget);
9094
a3f3038e9b9a (svn r12953) -Feature: Open a new viewport when ctrl-clicking on a 'Location' button, a town/station/industry list, or some news items.
peter1138 <peter1138@openttd.org>
parents: 8992
diff changeset
522 } else {
9191
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
523 for (uint i = SLW_CARGOSTART; i < this->widget_count; i++) {
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
524 this->RaiseWidget(i);
6202
eb0fdb88a922 (svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138 <peter1138@openttd.org>
parents: 6122
diff changeset
525 }
9191
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
526 this->RaiseWidget(SLW_NOCARGOWAITING);
6271
56a8bb763a87 (svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138 <peter1138@openttd.org>
parents: 6260
diff changeset
527
9378
cacef2552d9f (svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13 <skidd13@openttd.org>
parents: 9377
diff changeset
528 this->cargo_filter = 0;
cacef2552d9f (svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13 <skidd13@openttd.org>
parents: 9377
diff changeset
529 this->include_empty = false;
6271
56a8bb763a87 (svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138 <peter1138@openttd.org>
parents: 6260
diff changeset
530
12418
0d8340a4c70e (svn r16852) -Codechange: use FOR_ALL_CARGOSPECS for iterating over all valid CargoSpecs
smatz <smatz@openttd.org>
parents: 12415
diff changeset
531 SetBit(this->cargo_filter, cs->Index());
9191
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
532 this->LowerWidget(widget);
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
533 }
9378
cacef2552d9f (svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13 <skidd13@openttd.org>
parents: 9377
diff changeset
534 this->SetWidgetLoweredState(SLW_CARGOALL, this->cargo_filter == _cargo_mask && this->include_empty);
9377
1d6f7b3bf9af (svn r13283) -Codechange: convert the inheritance of GUIList in PlayerStationsWindow to a member object
skidd13 <skidd13@openttd.org>
parents: 9365
diff changeset
535 this->stations.ForceRebuild();
9191
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
536 this->SetDirty();
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
537 }
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
538 break;
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
539 }
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
540 }
6271
56a8bb763a87 (svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138 <peter1138@openttd.org>
parents: 6260
diff changeset
541
9191
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
542 virtual void OnDropdownSelect(int widget, int index)
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
543 {
9377
1d6f7b3bf9af (svn r13283) -Codechange: convert the inheritance of GUIList in PlayerStationsWindow to a member object
skidd13 <skidd13@openttd.org>
parents: 9365
diff changeset
544 if (this->stations.SortType() != index) {
1d6f7b3bf9af (svn r13283) -Codechange: convert the inheritance of GUIList in PlayerStationsWindow to a member object
skidd13 <skidd13@openttd.org>
parents: 9365
diff changeset
545 this->stations.SetSortType(index);
9389
b81a2f5313a9 (svn r13299) -Fix (r13286): Stations sort type isn't updated correctly
skidd13 <skidd13@openttd.org>
parents: 9382
diff changeset
546
b81a2f5313a9 (svn r13299) -Fix (r13286): Stations sort type isn't updated correctly
skidd13 <skidd13@openttd.org>
parents: 9382
diff changeset
547 /* Display the current sort variant */
b81a2f5313a9 (svn r13299) -Fix (r13286): Stations sort type isn't updated correctly
skidd13 <skidd13@openttd.org>
parents: 9382
diff changeset
548 this->widget[SLW_SORTDROPBTN].data = this->sorter_names[this->stations.SortType()];
b81a2f5313a9 (svn r13299) -Fix (r13286): Stations sort type isn't updated correctly
skidd13 <skidd13@openttd.org>
parents: 9382
diff changeset
549
9377
1d6f7b3bf9af (svn r13283) -Codechange: convert the inheritance of GUIList in PlayerStationsWindow to a member object
skidd13 <skidd13@openttd.org>
parents: 9365
diff changeset
550 this->SetDirty();
9191
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
551 }
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
552 }
6271
56a8bb763a87 (svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138 <peter1138@openttd.org>
parents: 6260
diff changeset
553
9191
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
554 virtual void OnTick()
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
555 {
11852
862dd1024fe7 (svn r16242) -Codechange: rework pausing
rubidium <rubidium@openttd.org>
parents: 11822
diff changeset
556 if (_pause_mode != PM_UNPAUSED) return;
9377
1d6f7b3bf9af (svn r13283) -Codechange: convert the inheritance of GUIList in PlayerStationsWindow to a member object
skidd13 <skidd13@openttd.org>
parents: 9365
diff changeset
557 if (this->stations.NeedResort()) {
10207
c54d140df948 (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents: 10180
diff changeset
558 DEBUG(misc, 3, "Periodic rebuild station list company %d", this->window_number);
9191
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
559 this->SetDirty();
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
560 }
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
561 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
562
9191
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
563 virtual void OnTimeout()
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
564 {
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
565 this->RaiseWidget(SLW_SORTBY);
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
566 this->SetDirty();
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
567 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
568
11524
420a4f0b4e0b (svn r15885) -Codechange: Removed new_size parameter of Window::OnResize() callback
alberth <alberth@openttd.org>
parents: 11476
diff changeset
569 virtual void OnResize(Point delta)
9191
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
570 {
12881
06daf47f0ab2 (svn r17373) -Codechange: make the timetable, station and subsidy GUIs use scrollbar wrappers
rubidium <rubidium@openttd.org>
parents: 12804
diff changeset
571 this->vscroll.UpdateCapacity(delta.y / 10);
9191
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
572 }
9297
add307f2e6ea (svn r13165) -Codechange: replace some RebuildXXXList/ResortXXXList+InvalidateWindowXXX with InvalidateWindowXXXData.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
573
add307f2e6ea (svn r13165) -Codechange: replace some RebuildXXXList/ResortXXXList+InvalidateWindowXXX with InvalidateWindowXXXData.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
574 virtual void OnInvalidateData(int data)
add307f2e6ea (svn r13165) -Codechange: replace some RebuildXXXList/ResortXXXList+InvalidateWindowXXX with InvalidateWindowXXXData.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
575 {
9377
1d6f7b3bf9af (svn r13283) -Codechange: convert the inheritance of GUIList in PlayerStationsWindow to a member object
skidd13 <skidd13@openttd.org>
parents: 9365
diff changeset
576 if (data == 0) {
1d6f7b3bf9af (svn r13283) -Codechange: convert the inheritance of GUIList in PlayerStationsWindow to a member object
skidd13 <skidd13@openttd.org>
parents: 9365
diff changeset
577 this->stations.ForceRebuild();
1d6f7b3bf9af (svn r13283) -Codechange: convert the inheritance of GUIList in PlayerStationsWindow to a member object
skidd13 <skidd13@openttd.org>
parents: 9365
diff changeset
578 } else {
1d6f7b3bf9af (svn r13283) -Codechange: convert the inheritance of GUIList in PlayerStationsWindow to a member object
skidd13 <skidd13@openttd.org>
parents: 9365
diff changeset
579 this->stations.ForceResort();
1d6f7b3bf9af (svn r13283) -Codechange: convert the inheritance of GUIList in PlayerStationsWindow to a member object
skidd13 <skidd13@openttd.org>
parents: 9365
diff changeset
580 }
9297
add307f2e6ea (svn r13165) -Codechange: replace some RebuildXXXList/ResortXXXList+InvalidateWindowXXX with InvalidateWindowXXXData.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
581 }
9191
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
582 };
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
583
10207
c54d140df948 (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents: 10180
diff changeset
584 Listing CompanyStationsWindow::last_sorting = {false, 0};
c54d140df948 (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents: 10180
diff changeset
585 byte CompanyStationsWindow::facilities = FACIL_TRAIN | FACIL_TRUCK_STOP | FACIL_BUS_STOP | FACIL_AIRPORT | FACIL_DOCK;
c54d140df948 (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents: 10180
diff changeset
586 bool CompanyStationsWindow::include_empty = true;
c54d140df948 (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents: 10180
diff changeset
587 const uint32 CompanyStationsWindow::cargo_filter_max = UINT32_MAX;
c54d140df948 (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents: 10180
diff changeset
588 uint32 CompanyStationsWindow::cargo_filter = UINT32_MAX;
c54d140df948 (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents: 10180
diff changeset
589 const Station *CompanyStationsWindow::last_station = NULL;
9378
cacef2552d9f (svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13 <skidd13@openttd.org>
parents: 9377
diff changeset
590
cacef2552d9f (svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13 <skidd13@openttd.org>
parents: 9377
diff changeset
591 /* Availible station sorting functions */
11376
b9b2391afd1a (svn r15726) -Codechange: unify coding style for const pointers
smatz <smatz@openttd.org>
parents: 11373
diff changeset
592 GUIStationList::SortFunction * const CompanyStationsWindow::sorter_funcs[] = {
9378
cacef2552d9f (svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13 <skidd13@openttd.org>
parents: 9377
diff changeset
593 &StationNameSorter,
cacef2552d9f (svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13 <skidd13@openttd.org>
parents: 9377
diff changeset
594 &StationTypeSorter,
cacef2552d9f (svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13 <skidd13@openttd.org>
parents: 9377
diff changeset
595 &StationWaitingSorter,
11665
933ac82c9a0b (svn r16045) -Feature [FS#597]: allow sorting stations by the lowest cargo rating instead of only by the highest cargo rating (based on the idea of KeeperOfTheSoul)
rubidium <rubidium@openttd.org>
parents: 11645
diff changeset
596 &StationRatingMaxSorter,
933ac82c9a0b (svn r16045) -Feature [FS#597]: allow sorting stations by the lowest cargo rating instead of only by the highest cargo rating (based on the idea of KeeperOfTheSoul)
rubidium <rubidium@openttd.org>
parents: 11645
diff changeset
597 &StationRatingMinSorter
9378
cacef2552d9f (svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13 <skidd13@openttd.org>
parents: 9377
diff changeset
598 };
cacef2552d9f (svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13 <skidd13@openttd.org>
parents: 9377
diff changeset
599
cacef2552d9f (svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13 <skidd13@openttd.org>
parents: 9377
diff changeset
600 /* Names of the sorting functions */
10207
c54d140df948 (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents: 10180
diff changeset
601 const StringID CompanyStationsWindow::sorter_names[] = {
12493
32e2de3d509a (svn r16930) -Codechange: more StringID name unification and grouping
rubidium <rubidium@openttd.org>
parents: 12472
diff changeset
602 STR_SORT_BY_NAME,
9378
cacef2552d9f (svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13 <skidd13@openttd.org>
parents: 9377
diff changeset
603 STR_SORT_BY_FACILITY,
cacef2552d9f (svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13 <skidd13@openttd.org>
parents: 9377
diff changeset
604 STR_SORT_BY_WAITING,
cacef2552d9f (svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13 <skidd13@openttd.org>
parents: 9377
diff changeset
605 STR_SORT_BY_RATING_MAX,
11665
933ac82c9a0b (svn r16045) -Feature [FS#597]: allow sorting stations by the lowest cargo rating instead of only by the highest cargo rating (based on the idea of KeeperOfTheSoul)
rubidium <rubidium@openttd.org>
parents: 11645
diff changeset
606 STR_SORT_BY_RATING_MIN,
9378
cacef2552d9f (svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13 <skidd13@openttd.org>
parents: 9377
diff changeset
607 INVALID_STRING_ID
cacef2552d9f (svn r13285) -Codechange: station sorting uses GUILists Sort() now
skidd13 <skidd13@openttd.org>
parents: 9377
diff changeset
608 };
9191
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
609
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
610
10207
c54d140df948 (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents: 10180
diff changeset
611 static const Widget _company_stations_widgets[] = {
11730
a39da1e4c1f5 (svn r16118) -Change/cleanup: remove the hexadecimal 'in TTD the string had this ID' from 'some' strings and replace the string name with something more sensible.
rubidium <rubidium@openttd.org>
parents: 11666
diff changeset
612 { WWT_CLOSEBOX, RESIZE_NONE, COLOUR_GREY, 0, 10, 0, 13, STR_BLACK_CROSS, STR_TOOLTIP_CLOSE_WINDOW}, // SLW_CLOSEBOX
a39da1e4c1f5 (svn r16118) -Change/cleanup: remove the hexadecimal 'in TTD the string had this ID' from 'some' strings and replace the string name with something more sensible.
rubidium <rubidium@openttd.org>
parents: 11666
diff changeset
613 { WWT_CAPTION, RESIZE_RIGHT, COLOUR_GREY, 11, 345, 0, 13, STR_STATION_LIST_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS}, // SLW_CAPTION
12632
e41943276802 (svn r17075) -Codechange: rename ~750 strings to be more uniform with their relatives
rubidium <rubidium@openttd.org>
parents: 12564
diff changeset
614 { WWT_STICKYBOX, RESIZE_LR, COLOUR_GREY, 346, 357, 0, 13, 0x0, STR_TOOLTIP_STICKY}, // SLW_STICKY
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: 11666
diff changeset
615 { WWT_PANEL, RESIZE_RB, COLOUR_GREY, 0, 345, 37, 161, 0x0, STR_STATION_LIST_TOOLTIP}, // SLW_LIST
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: 11666
diff changeset
616 { WWT_SCROLLBAR, RESIZE_LRB, COLOUR_GREY, 346, 357, 37, 149, 0x0, STR_TOOLTIP_VSCROLL_BAR_SCROLLS_LIST}, // SLW_SCROLLBAR
12632
e41943276802 (svn r17075) -Codechange: rename ~750 strings to be more uniform with their relatives
rubidium <rubidium@openttd.org>
parents: 12564
diff changeset
617 { WWT_RESIZEBOX, RESIZE_LRTB, COLOUR_GREY, 346, 357, 150, 161, 0x0, STR_TOOLTIP_RESIZE}, // SLW_RESIZE
8016
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
618
12632
e41943276802 (svn r17075) -Codechange: rename ~750 strings to be more uniform with their relatives
rubidium <rubidium@openttd.org>
parents: 12564
diff changeset
619 { WWT_TEXTBTN, RESIZE_NONE, COLOUR_GREY, 0, 13, 14, 24, STR_TRAIN, STR_STATION_LIST_USE_CTRL_TO_SELECT_MORE}, // SLW_TRAIN
e41943276802 (svn r17075) -Codechange: rename ~750 strings to be more uniform with their relatives
rubidium <rubidium@openttd.org>
parents: 12564
diff changeset
620 { WWT_TEXTBTN, RESIZE_NONE, COLOUR_GREY, 14, 27, 14, 24, STR_LORRY, STR_STATION_LIST_USE_CTRL_TO_SELECT_MORE}, // SLW_TRUCK
e41943276802 (svn r17075) -Codechange: rename ~750 strings to be more uniform with their relatives
rubidium <rubidium@openttd.org>
parents: 12564
diff changeset
621 { WWT_TEXTBTN, RESIZE_NONE, COLOUR_GREY, 28, 41, 14, 24, STR_BUS, STR_STATION_LIST_USE_CTRL_TO_SELECT_MORE}, // SLW_BUS
e41943276802 (svn r17075) -Codechange: rename ~750 strings to be more uniform with their relatives
rubidium <rubidium@openttd.org>
parents: 12564
diff changeset
622 { WWT_TEXTBTN, RESIZE_NONE, COLOUR_GREY, 42, 55, 14, 24, STR_PLANE, STR_STATION_LIST_USE_CTRL_TO_SELECT_MORE}, // SLW_AIRPLANE
e41943276802 (svn r17075) -Codechange: rename ~750 strings to be more uniform with their relatives
rubidium <rubidium@openttd.org>
parents: 12564
diff changeset
623 { WWT_TEXTBTN, RESIZE_NONE, COLOUR_GREY, 56, 69, 14, 24, STR_SHIP, STR_STATION_LIST_USE_CTRL_TO_SELECT_MORE}, // SLW_SHIP
e41943276802 (svn r17075) -Codechange: rename ~750 strings to be more uniform with their relatives
rubidium <rubidium@openttd.org>
parents: 12564
diff changeset
624 { WWT_PANEL, RESIZE_NONE, COLOUR_GREY, 70, 83, 14, 24, 0x0, STR_STATION_LIST_SELECT_ALL_FACILITIES}, // SLW_FACILALL
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
625
11820
fc082e9f7169 (svn r16210) -Codechange: Make panels non-overlapping in company stations window.
alberth <alberth@openttd.org>
parents: 11819
diff changeset
626 { WWT_PANEL, RESIZE_NONE, COLOUR_GREY, 84, 88, 14, 24, 0x0, STR_NULL}, // SLW_PAN_BETWEEN
12632
e41943276802 (svn r17075) -Codechange: rename ~750 strings to be more uniform with their relatives
rubidium <rubidium@openttd.org>
parents: 12564
diff changeset
627 { WWT_PANEL, RESIZE_NONE, COLOUR_GREY, 89, 102, 14, 24, 0x0, STR_STATION_LIST_NO_WAITING_CARGO}, // SLW_NOCARGOWAITING
e41943276802 (svn r17075) -Codechange: rename ~750 strings to be more uniform with their relatives
rubidium <rubidium@openttd.org>
parents: 12564
diff changeset
628 { WWT_PANEL, RESIZE_NONE, COLOUR_GREY, 103, 116, 14, 24, 0x0, STR_STATION_LIST_SELECT_ALL_TYPES}, // SLW_CARGOALL
9764
f301b0566657 (svn r13900) -Codechange: Replace numbers with Colours enum on settings, smallmaps, stations and signs guis.
belugas <belugas@openttd.org>
parents: 9659
diff changeset
629 { WWT_PANEL, RESIZE_RIGHT, COLOUR_GREY, 117, 357, 14, 24, 0x0, STR_NULL}, // SLW_PAN_RIGHT
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
630
12632
e41943276802 (svn r17075) -Codechange: rename ~750 strings to be more uniform with their relatives
rubidium <rubidium@openttd.org>
parents: 12564
diff changeset
631 { WWT_TEXTBTN, RESIZE_NONE, COLOUR_GREY, 0, 80, 25, 36, STR_BUTTON_SORT_BY, STR_TOOLTIP_SORT_ORDER}, // SLW_SORTBY
e41943276802 (svn r17075) -Codechange: rename ~750 strings to be more uniform with their relatives
rubidium <rubidium@openttd.org>
parents: 12564
diff changeset
632 { WWT_DROPDOWN, RESIZE_NONE, COLOUR_GREY, 81, 243, 25, 36, 0x0, STR_TOOLTIP_SORT_CRITERIAP}, // SLW_SORTDROPBTN
9764
f301b0566657 (svn r13900) -Codechange: Replace numbers with Colours enum on settings, smallmaps, stations and signs guis.
belugas <belugas@openttd.org>
parents: 9659
diff changeset
633 { WWT_PANEL, RESIZE_RIGHT, COLOUR_GREY, 244, 357, 25, 36, 0x0, STR_NULL}, // SLW_PAN_SORT_RIGHT
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
634 { WIDGETS_END},
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
635 };
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
636
11822
fa3b41302eda (svn r16212) -Codechange: Added nested widgets for all station_gui windows.
alberth <alberth@openttd.org>
parents: 11821
diff changeset
637 static const NWidgetPart _nested_company_stations_widgets[] = {
fa3b41302eda (svn r16212) -Codechange: Added nested widgets for all station_gui windows.
alberth <alberth@openttd.org>
parents: 11821
diff changeset
638 NWidget(NWID_HORIZONTAL),
fa3b41302eda (svn r16212) -Codechange: Added nested widgets for all station_gui windows.
alberth <alberth@openttd.org>
parents: 11821
diff changeset
639 NWidget(WWT_CLOSEBOX, COLOUR_GREY, SLW_CLOSEBOX),
fa3b41302eda (svn r16212) -Codechange: Added nested widgets for all station_gui windows.
alberth <alberth@openttd.org>
parents: 11821
diff changeset
640 NWidget(WWT_CAPTION, COLOUR_GREY, SLW_CAPTION), SetDataTip(STR_STATION_LIST_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
fa3b41302eda (svn r16212) -Codechange: Added nested widgets for all station_gui windows.
alberth <alberth@openttd.org>
parents: 11821
diff changeset
641 NWidget(WWT_STICKYBOX, COLOUR_GREY, SLW_STICKY),
fa3b41302eda (svn r16212) -Codechange: Added nested widgets for all station_gui windows.
alberth <alberth@openttd.org>
parents: 11821
diff changeset
642 EndContainer(),
fa3b41302eda (svn r16212) -Codechange: Added nested widgets for all station_gui windows.
alberth <alberth@openttd.org>
parents: 11821
diff changeset
643 NWidget(NWID_HORIZONTAL),
12632
e41943276802 (svn r17075) -Codechange: rename ~750 strings to be more uniform with their relatives
rubidium <rubidium@openttd.org>
parents: 12564
diff changeset
644 NWidget(WWT_TEXTBTN, COLOUR_GREY, SLW_TRAIN), SetMinimalSize(14, 11), SetDataTip(STR_TRAIN, STR_STATION_LIST_USE_CTRL_TO_SELECT_MORE),
e41943276802 (svn r17075) -Codechange: rename ~750 strings to be more uniform with their relatives
rubidium <rubidium@openttd.org>
parents: 12564
diff changeset
645 NWidget(WWT_TEXTBTN, COLOUR_GREY, SLW_TRUCK), SetMinimalSize(14, 11), SetDataTip(STR_LORRY, STR_STATION_LIST_USE_CTRL_TO_SELECT_MORE),
e41943276802 (svn r17075) -Codechange: rename ~750 strings to be more uniform with their relatives
rubidium <rubidium@openttd.org>
parents: 12564
diff changeset
646 NWidget(WWT_TEXTBTN, COLOUR_GREY, SLW_BUS), SetMinimalSize(14, 11), SetDataTip(STR_BUS, STR_STATION_LIST_USE_CTRL_TO_SELECT_MORE),
e41943276802 (svn r17075) -Codechange: rename ~750 strings to be more uniform with their relatives
rubidium <rubidium@openttd.org>
parents: 12564
diff changeset
647 NWidget(WWT_TEXTBTN, COLOUR_GREY, SLW_AIRPLANE), SetMinimalSize(14, 11), SetDataTip(STR_PLANE, STR_STATION_LIST_USE_CTRL_TO_SELECT_MORE),
e41943276802 (svn r17075) -Codechange: rename ~750 strings to be more uniform with their relatives
rubidium <rubidium@openttd.org>
parents: 12564
diff changeset
648 NWidget(WWT_TEXTBTN, COLOUR_GREY, SLW_SHIP), SetMinimalSize(14, 11), SetDataTip(STR_SHIP, STR_STATION_LIST_USE_CTRL_TO_SELECT_MORE),
e41943276802 (svn r17075) -Codechange: rename ~750 strings to be more uniform with their relatives
rubidium <rubidium@openttd.org>
parents: 12564
diff changeset
649 NWidget(WWT_PANEL, COLOUR_GREY, SLW_FACILALL), SetMinimalSize(14, 11), SetDataTip(0x0, STR_STATION_LIST_SELECT_ALL_FACILITIES), SetFill(false, false), EndContainer(),
11822
fa3b41302eda (svn r16212) -Codechange: Added nested widgets for all station_gui windows.
alberth <alberth@openttd.org>
parents: 11821
diff changeset
650 NWidget(WWT_PANEL, COLOUR_GREY, SLW_PAN_BETWEEN), SetMinimalSize(5, 11), SetDataTip(0x0, STR_NULL), SetFill(false, false), EndContainer(),
12632
e41943276802 (svn r17075) -Codechange: rename ~750 strings to be more uniform with their relatives
rubidium <rubidium@openttd.org>
parents: 12564
diff changeset
651 NWidget(WWT_PANEL, COLOUR_GREY, SLW_NOCARGOWAITING), SetMinimalSize(14, 11), SetDataTip(0x0, STR_STATION_LIST_NO_WAITING_CARGO), SetFill(false, false), EndContainer(),
e41943276802 (svn r17075) -Codechange: rename ~750 strings to be more uniform with their relatives
rubidium <rubidium@openttd.org>
parents: 12564
diff changeset
652 NWidget(WWT_PANEL, COLOUR_GREY, SLW_CARGOALL), SetMinimalSize(14, 11), SetDataTip(0x0, STR_STATION_LIST_SELECT_ALL_TYPES), SetFill(false, false), EndContainer(),
11822
fa3b41302eda (svn r16212) -Codechange: Added nested widgets for all station_gui windows.
alberth <alberth@openttd.org>
parents: 11821
diff changeset
653 NWidget(WWT_PANEL, COLOUR_GREY, SLW_PAN_RIGHT), SetDataTip(0x0, STR_NULL), SetResize(1, 0), SetFill(true, true), EndContainer(),
fa3b41302eda (svn r16212) -Codechange: Added nested widgets for all station_gui windows.
alberth <alberth@openttd.org>
parents: 11821
diff changeset
654 EndContainer(),
fa3b41302eda (svn r16212) -Codechange: Added nested widgets for all station_gui windows.
alberth <alberth@openttd.org>
parents: 11821
diff changeset
655 NWidget(NWID_HORIZONTAL),
12632
e41943276802 (svn r17075) -Codechange: rename ~750 strings to be more uniform with their relatives
rubidium <rubidium@openttd.org>
parents: 12564
diff changeset
656 NWidget(WWT_TEXTBTN, COLOUR_GREY, SLW_SORTBY), SetMinimalSize(81, 12), SetDataTip(STR_BUTTON_SORT_BY, STR_TOOLTIP_SORT_ORDER),
e41943276802 (svn r17075) -Codechange: rename ~750 strings to be more uniform with their relatives
rubidium <rubidium@openttd.org>
parents: 12564
diff changeset
657 NWidget(WWT_DROPDOWN, COLOUR_GREY, SLW_SORTDROPBTN), SetMinimalSize(163, 12), SetDataTip(0x0, STR_TOOLTIP_SORT_CRITERIAP),
11822
fa3b41302eda (svn r16212) -Codechange: Added nested widgets for all station_gui windows.
alberth <alberth@openttd.org>
parents: 11821
diff changeset
658 NWidget(WWT_PANEL, COLOUR_GREY, SLW_PAN_SORT_RIGHT), SetDataTip(0x0, STR_NULL), SetResize(1, 0), SetFill(true, true), EndContainer(),
fa3b41302eda (svn r16212) -Codechange: Added nested widgets for all station_gui windows.
alberth <alberth@openttd.org>
parents: 11821
diff changeset
659 EndContainer(),
fa3b41302eda (svn r16212) -Codechange: Added nested widgets for all station_gui windows.
alberth <alberth@openttd.org>
parents: 11821
diff changeset
660 NWidget(NWID_HORIZONTAL),
fa3b41302eda (svn r16212) -Codechange: Added nested widgets for all station_gui windows.
alberth <alberth@openttd.org>
parents: 11821
diff changeset
661 NWidget(WWT_PANEL, COLOUR_GREY, SLW_LIST), SetMinimalSize(346, 125), SetResize(1, 10), SetDataTip(0x0, STR_STATION_LIST_TOOLTIP), EndContainer(),
fa3b41302eda (svn r16212) -Codechange: Added nested widgets for all station_gui windows.
alberth <alberth@openttd.org>
parents: 11821
diff changeset
662 NWidget(NWID_VERTICAL),
fa3b41302eda (svn r16212) -Codechange: Added nested widgets for all station_gui windows.
alberth <alberth@openttd.org>
parents: 11821
diff changeset
663 NWidget(WWT_SCROLLBAR, COLOUR_GREY, SLW_SCROLLBAR),
fa3b41302eda (svn r16212) -Codechange: Added nested widgets for all station_gui windows.
alberth <alberth@openttd.org>
parents: 11821
diff changeset
664 NWidget(WWT_RESIZEBOX, COLOUR_GREY, SLW_RESIZE),
fa3b41302eda (svn r16212) -Codechange: Added nested widgets for all station_gui windows.
alberth <alberth@openttd.org>
parents: 11821
diff changeset
665 EndContainer(),
fa3b41302eda (svn r16212) -Codechange: Added nested widgets for all station_gui windows.
alberth <alberth@openttd.org>
parents: 11821
diff changeset
666 EndContainer(),
fa3b41302eda (svn r16212) -Codechange: Added nested widgets for all station_gui windows.
alberth <alberth@openttd.org>
parents: 11821
diff changeset
667 };
fa3b41302eda (svn r16212) -Codechange: Added nested widgets for all station_gui windows.
alberth <alberth@openttd.org>
parents: 11821
diff changeset
668
11373
474ba6cc0946 (svn r15723) -Codechange: use a constructor for WindowDescs as that makes expanding them much easier (Alberth)
rubidium <rubidium@openttd.org>
parents: 11361
diff changeset
669 static const WindowDesc _company_stations_desc(
7341
549c757023fc (svn r10704) -Codechange: provide an infrastructure to have resizable windows that are smaller than the default window size.
rubidium <rubidium@openttd.org>
parents: 7058
diff changeset
670 WDP_AUTO, WDP_AUTO, 358, 162, 358, 162,
5893
8547517ef719 (svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium <rubidium@openttd.org>
parents: 5745
diff changeset
671 WC_STATION_LIST, WC_NONE,
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
672 WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_STICKY_BUTTON | WDF_RESIZABLE,
11822
fa3b41302eda (svn r16212) -Codechange: Added nested widgets for all station_gui windows.
alberth <alberth@openttd.org>
parents: 11821
diff changeset
673 _company_stations_widgets, _nested_company_stations_widgets, lengthof(_nested_company_stations_widgets)
11373
474ba6cc0946 (svn r15723) -Codechange: use a constructor for WindowDescs as that makes expanding them much easier (Alberth)
rubidium <rubidium@openttd.org>
parents: 11361
diff changeset
674 );
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
675
8016
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
676 /**
10207
c54d140df948 (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents: 10180
diff changeset
677 * Opens window with list of company's stations
8016
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
678 *
10207
c54d140df948 (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents: 10180
diff changeset
679 * @param company whose stations' list show
8016
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
680 */
10207
c54d140df948 (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents: 10180
diff changeset
681 void ShowCompanyStations(CompanyID company)
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
682 {
11924
fccc9cea27a7 (svn r16327) -Codechange: replace IsValidPoolItemID(index) by PoolItem::IsValidID(index)
smatz <smatz@openttd.org>
parents: 11922
diff changeset
683 if (!Company::IsValidID(company)) 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
684
10207
c54d140df948 (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents: 10180
diff changeset
685 AllocateWindowDescFront<CompanyStationsWindow>(&_company_stations_desc, company);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
686 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
687
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
688 static const Widget _station_view_widgets[] = {
11730
a39da1e4c1f5 (svn r16118) -Change/cleanup: remove the hexadecimal 'in TTD the string had this ID' from 'some' strings and replace the string name with something more sensible.
rubidium <rubidium@openttd.org>
parents: 11666
diff changeset
689 { WWT_CLOSEBOX, RESIZE_NONE, COLOUR_GREY, 0, 10, 0, 13, STR_BLACK_CROSS, STR_TOOLTIP_CLOSE_WINDOW}, // SVW_CLOSEBOX
a39da1e4c1f5 (svn r16118) -Change/cleanup: remove the hexadecimal 'in TTD the string had this ID' from 'some' strings and replace the string name with something more sensible.
rubidium <rubidium@openttd.org>
parents: 11666
diff changeset
690 { WWT_CAPTION, RESIZE_RIGHT, COLOUR_GREY, 11, 236, 0, 13, STR_STATION_VIEW_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS},
12632
e41943276802 (svn r17075) -Codechange: rename ~750 strings to be more uniform with their relatives
rubidium <rubidium@openttd.org>
parents: 12564
diff changeset
691 { WWT_STICKYBOX, RESIZE_LR, COLOUR_GREY, 237, 248, 0, 13, 0x0, STR_TOOLTIP_STICKY},
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: 11666
diff changeset
692 { WWT_PANEL, RESIZE_RB, COLOUR_GREY, 0, 236, 14, 65, 0x0, STR_NULL}, // SVW_WAITING
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: 11666
diff changeset
693 { WWT_SCROLLBAR, RESIZE_LRB, COLOUR_GREY, 237, 248, 14, 65, 0x0, STR_TOOLTIP_VSCROLL_BAR_SCROLLS_LIST},
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: 11666
diff changeset
694 { WWT_PANEL, RESIZE_RTB, COLOUR_GREY, 0, 248, 66, 97, 0x0, STR_NULL}, // SVW_ACCEPTLIST / SVW_RATINGLIST
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: 11666
diff changeset
695 { WWT_PUSHTXTBTN, RESIZE_TB, COLOUR_GREY, 0, 59, 98, 109, STR_BUTTON_LOCATION, STR_STATION_VIEW_CENTER_TOOLTIP}, // SVW_LOCATION
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: 11666
diff changeset
696 { WWT_PUSHTXTBTN, RESIZE_TB, COLOUR_GREY, 60, 120, 98, 109, STR_STATION_VIEW_RATINGS_BUTTON, STR_STATION_VIEW_RATINGS_TOOLTIP}, // SVW_RATINGS / SVW_ACCEPTS
12632
e41943276802 (svn r17075) -Codechange: rename ~750 strings to be more uniform with their relatives
rubidium <rubidium@openttd.org>
parents: 12564
diff changeset
697 { WWT_PUSHTXTBTN, RESIZE_RTB, COLOUR_GREY, 121, 180, 98, 109, STR_BUTTON_RENAME, STR_STATION_VIEW_RENAME_TOOLTIP}, // SVW_RENAME
e41943276802 (svn r17075) -Codechange: rename ~750 strings to be more uniform with their relatives
rubidium <rubidium@openttd.org>
parents: 12564
diff changeset
698 { WWT_PUSHTXTBTN, RESIZE_LRTB, COLOUR_GREY, 181, 194, 98, 109, STR_TRAIN, STR_STATION_VIEW_SCHEDULED_TRAINS_TOOLTIP }, // SVW_TRAINS
e41943276802 (svn r17075) -Codechange: rename ~750 strings to be more uniform with their relatives
rubidium <rubidium@openttd.org>
parents: 12564
diff changeset
699 { WWT_PUSHTXTBTN, RESIZE_LRTB, COLOUR_GREY, 195, 208, 98, 109, STR_LORRY, STR_STATION_VIEW_SCHEDULED_ROAD_VEHICLES_TOOLTIP }, // SVW_ROADVEHS
e41943276802 (svn r17075) -Codechange: rename ~750 strings to be more uniform with their relatives
rubidium <rubidium@openttd.org>
parents: 12564
diff changeset
700 { WWT_PUSHTXTBTN, RESIZE_LRTB, COLOUR_GREY, 209, 222, 98, 109, STR_PLANE, STR_STATION_VIEW_SCHEDULED_AIRCRAFT_TOOLTIP }, // SVW_PLANES
e41943276802 (svn r17075) -Codechange: rename ~750 strings to be more uniform with their relatives
rubidium <rubidium@openttd.org>
parents: 12564
diff changeset
701 { WWT_PUSHTXTBTN, RESIZE_LRTB, COLOUR_GREY, 223, 236, 98, 109, STR_SHIP, STR_STATION_VIEW_SCHEDULED_SHIPS_TOOLTIP }, // SVW_SHIPS
e41943276802 (svn r17075) -Codechange: rename ~750 strings to be more uniform with their relatives
rubidium <rubidium@openttd.org>
parents: 12564
diff changeset
702 { WWT_RESIZEBOX, RESIZE_LRTB, COLOUR_GREY, 237, 248, 98, 109, 0x0, STR_TOOLTIP_RESIZE},
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
703 { WIDGETS_END},
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
704 };
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
705
11822
fa3b41302eda (svn r16212) -Codechange: Added nested widgets for all station_gui windows.
alberth <alberth@openttd.org>
parents: 11821
diff changeset
706 static const NWidgetPart _nested_station_view_widgets[] = {
fa3b41302eda (svn r16212) -Codechange: Added nested widgets for all station_gui windows.
alberth <alberth@openttd.org>
parents: 11821
diff changeset
707 NWidget(NWID_HORIZONTAL),
fa3b41302eda (svn r16212) -Codechange: Added nested widgets for all station_gui windows.
alberth <alberth@openttd.org>
parents: 11821
diff changeset
708 NWidget(WWT_CLOSEBOX, COLOUR_GREY, SVW_CLOSEBOX),
fa3b41302eda (svn r16212) -Codechange: Added nested widgets for all station_gui windows.
alberth <alberth@openttd.org>
parents: 11821
diff changeset
709 NWidget(WWT_CAPTION, COLOUR_GREY, SVW_CAPTION), SetDataTip(STR_STATION_VIEW_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
fa3b41302eda (svn r16212) -Codechange: Added nested widgets for all station_gui windows.
alberth <alberth@openttd.org>
parents: 11821
diff changeset
710 NWidget(WWT_STICKYBOX, COLOUR_GREY, SVW_STICKYBOX),
fa3b41302eda (svn r16212) -Codechange: Added nested widgets for all station_gui windows.
alberth <alberth@openttd.org>
parents: 11821
diff changeset
711 EndContainer(),
fa3b41302eda (svn r16212) -Codechange: Added nested widgets for all station_gui windows.
alberth <alberth@openttd.org>
parents: 11821
diff changeset
712 NWidget(NWID_HORIZONTAL),
fa3b41302eda (svn r16212) -Codechange: Added nested widgets for all station_gui windows.
alberth <alberth@openttd.org>
parents: 11821
diff changeset
713 NWidget(WWT_PANEL, COLOUR_GREY, SVW_WAITING), SetMinimalSize(237, 52), SetResize(1, 10), EndContainer(),
fa3b41302eda (svn r16212) -Codechange: Added nested widgets for all station_gui windows.
alberth <alberth@openttd.org>
parents: 11821
diff changeset
714 NWidget(WWT_SCROLLBAR, COLOUR_GREY, SVW_SCROLLBAR),
fa3b41302eda (svn r16212) -Codechange: Added nested widgets for all station_gui windows.
alberth <alberth@openttd.org>
parents: 11821
diff changeset
715 EndContainer(),
fa3b41302eda (svn r16212) -Codechange: Added nested widgets for all station_gui windows.
alberth <alberth@openttd.org>
parents: 11821
diff changeset
716 NWidget(WWT_PANEL, COLOUR_GREY, SVW_ACCEPTLIST), SetMinimalSize(249, 32), SetResize(1, 0), EndContainer(),
fa3b41302eda (svn r16212) -Codechange: Added nested widgets for all station_gui windows.
alberth <alberth@openttd.org>
parents: 11821
diff changeset
717 NWidget(NWID_HORIZONTAL),
fa3b41302eda (svn r16212) -Codechange: Added nested widgets for all station_gui windows.
alberth <alberth@openttd.org>
parents: 11821
diff changeset
718 NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, SVW_LOCATION), SetMinimalSize(60, 12), SetDataTip(STR_BUTTON_LOCATION, STR_STATION_VIEW_CENTER_TOOLTIP),
fa3b41302eda (svn r16212) -Codechange: Added nested widgets for all station_gui windows.
alberth <alberth@openttd.org>
parents: 11821
diff changeset
719 NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, SVW_ACCEPTS), SetMinimalSize(61, 12), SetDataTip(STR_STATION_VIEW_RATINGS_BUTTON, STR_STATION_VIEW_RATINGS_TOOLTIP),
12632
e41943276802 (svn r17075) -Codechange: rename ~750 strings to be more uniform with their relatives
rubidium <rubidium@openttd.org>
parents: 12564
diff changeset
720 NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, SVW_RENAME), SetMinimalSize(60, 12), SetResize(1, 0), SetDataTip(STR_BUTTON_RENAME, STR_STATION_VIEW_RENAME_TOOLTIP),
e41943276802 (svn r17075) -Codechange: rename ~750 strings to be more uniform with their relatives
rubidium <rubidium@openttd.org>
parents: 12564
diff changeset
721 NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, SVW_TRAINS), SetMinimalSize(14, 12), SetDataTip(STR_TRAIN, STR_STATION_VIEW_SCHEDULED_TRAINS_TOOLTIP),
e41943276802 (svn r17075) -Codechange: rename ~750 strings to be more uniform with their relatives
rubidium <rubidium@openttd.org>
parents: 12564
diff changeset
722 NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, SVW_ROADVEHS), SetMinimalSize(14, 12), SetDataTip(STR_LORRY, STR_STATION_VIEW_SCHEDULED_ROAD_VEHICLES_TOOLTIP),
e41943276802 (svn r17075) -Codechange: rename ~750 strings to be more uniform with their relatives
rubidium <rubidium@openttd.org>
parents: 12564
diff changeset
723 NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, SVW_PLANES), SetMinimalSize(14, 12), SetDataTip(STR_PLANE, STR_STATION_VIEW_SCHEDULED_AIRCRAFT_TOOLTIP),
e41943276802 (svn r17075) -Codechange: rename ~750 strings to be more uniform with their relatives
rubidium <rubidium@openttd.org>
parents: 12564
diff changeset
724 NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, SVW_SHIPS), SetMinimalSize(14, 12), SetDataTip(STR_SHIP, STR_STATION_VIEW_SCHEDULED_SHIPS_TOOLTIP),
11822
fa3b41302eda (svn r16212) -Codechange: Added nested widgets for all station_gui windows.
alberth <alberth@openttd.org>
parents: 11821
diff changeset
725 NWidget(WWT_RESIZEBOX, COLOUR_GREY, SVW_RESIZE),
fa3b41302eda (svn r16212) -Codechange: Added nested widgets for all station_gui windows.
alberth <alberth@openttd.org>
parents: 11821
diff changeset
726 EndContainer(),
fa3b41302eda (svn r16212) -Codechange: Added nested widgets for all station_gui windows.
alberth <alberth@openttd.org>
parents: 11821
diff changeset
727 };
fa3b41302eda (svn r16212) -Codechange: Added nested widgets for all station_gui windows.
alberth <alberth@openttd.org>
parents: 11821
diff changeset
728
8762
dcc2194ac748 (svn r12458) -Codechange: split acquiring the sprite ID for cargos from the actual drawing of them.
rubidium <rubidium@openttd.org>
parents: 8750
diff changeset
729 SpriteID GetCargoSprite(CargoID i)
6364
12ef3186e753 (svn r9417) -Fix (r1): Waiting cargo icons in the station view window were incorrectly drawn if the cargo list was scrolled, resulting in overlapping images
peter1138 <peter1138@openttd.org>
parents: 6350
diff changeset
730 {
12415
6a77d1df56e2 (svn r16849) -Codechange: replace GetCargo() by CargoSpec::Get()
smatz <smatz@openttd.org>
parents: 12311
diff changeset
731 const CargoSpec *cs = CargoSpec::Get(i);
6365
0d8a8ec46519 (svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138 <peter1138@openttd.org>
parents: 6364
diff changeset
732 SpriteID sprite;
0d8a8ec46519 (svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138 <peter1138@openttd.org>
parents: 6364
diff changeset
733
0d8a8ec46519 (svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138 <peter1138@openttd.org>
parents: 6364
diff changeset
734 if (cs->sprite == 0xFFFF) {
0d8a8ec46519 (svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138 <peter1138@openttd.org>
parents: 6364
diff changeset
735 /* A value of 0xFFFF indicates we should draw a custom icon */
0d8a8ec46519 (svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138 <peter1138@openttd.org>
parents: 6364
diff changeset
736 sprite = GetCustomCargoSprite(cs);
0d8a8ec46519 (svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138 <peter1138@openttd.org>
parents: 6364
diff changeset
737 } else {
0d8a8ec46519 (svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138 <peter1138@openttd.org>
parents: 6364
diff changeset
738 sprite = cs->sprite;
0d8a8ec46519 (svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138 <peter1138@openttd.org>
parents: 6364
diff changeset
739 }
0d8a8ec46519 (svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138 <peter1138@openttd.org>
parents: 6364
diff changeset
740
6657
05dc53b3e64a (svn r9888) -Codechange: [NewGRF] allow non-spec cargo action2s to work, and using the goods sprite if really nothing is returned.
peter1138 <peter1138@openttd.org>
parents: 6420
diff changeset
741 if (sprite == 0) sprite = SPR_CARGO_GOODS;
6364
12ef3186e753 (svn r9417) -Fix (r1): Waiting cargo icons in the station view window were incorrectly drawn if the cargo list was scrolled, resulting in overlapping images
peter1138 <peter1138@openttd.org>
parents: 6350
diff changeset
742
8762
dcc2194ac748 (svn r12458) -Codechange: split acquiring the sprite ID for cargos from the actual drawing of them.
rubidium <rubidium@openttd.org>
parents: 8750
diff changeset
743 return sprite;
dcc2194ac748 (svn r12458) -Codechange: split acquiring the sprite ID for cargos from the actual drawing of them.
rubidium <rubidium@openttd.org>
parents: 8750
diff changeset
744 }
dcc2194ac748 (svn r12458) -Codechange: split acquiring the sprite ID for cargos from the actual drawing of them.
rubidium <rubidium@openttd.org>
parents: 8750
diff changeset
745
dcc2194ac748 (svn r12458) -Codechange: split acquiring the sprite ID for cargos from the actual drawing of them.
rubidium <rubidium@openttd.org>
parents: 8750
diff changeset
746 /**
dcc2194ac748 (svn r12458) -Codechange: split acquiring the sprite ID for cargos from the actual drawing of them.
rubidium <rubidium@openttd.org>
parents: 8750
diff changeset
747 * Draws icons of waiting cargo in the StationView window
dcc2194ac748 (svn r12458) -Codechange: split acquiring the sprite ID for cargos from the actual drawing of them.
rubidium <rubidium@openttd.org>
parents: 8750
diff changeset
748 *
dcc2194ac748 (svn r12458) -Codechange: split acquiring the sprite ID for cargos from the actual drawing of them.
rubidium <rubidium@openttd.org>
parents: 8750
diff changeset
749 * @param i type of cargo
dcc2194ac748 (svn r12458) -Codechange: split acquiring the sprite ID for cargos from the actual drawing of them.
rubidium <rubidium@openttd.org>
parents: 8750
diff changeset
750 * @param waiting number of waiting units
dcc2194ac748 (svn r12458) -Codechange: split acquiring the sprite ID for cargos from the actual drawing of them.
rubidium <rubidium@openttd.org>
parents: 8750
diff changeset
751 * @param x x on-screen coordinate where to start with drawing icons
dcc2194ac748 (svn r12458) -Codechange: split acquiring the sprite ID for cargos from the actual drawing of them.
rubidium <rubidium@openttd.org>
parents: 8750
diff changeset
752 * @param y y coordinate
dcc2194ac748 (svn r12458) -Codechange: split acquiring the sprite ID for cargos from the actual drawing of them.
rubidium <rubidium@openttd.org>
parents: 8750
diff changeset
753 */
dcc2194ac748 (svn r12458) -Codechange: split acquiring the sprite ID for cargos from the actual drawing of them.
rubidium <rubidium@openttd.org>
parents: 8750
diff changeset
754 static void DrawCargoIcons(CargoID i, uint waiting, int x, int y, uint width)
dcc2194ac748 (svn r12458) -Codechange: split acquiring the sprite ID for cargos from the actual drawing of them.
rubidium <rubidium@openttd.org>
parents: 8750
diff changeset
755 {
dcc2194ac748 (svn r12458) -Codechange: split acquiring the sprite ID for cargos from the actual drawing of them.
rubidium <rubidium@openttd.org>
parents: 8750
diff changeset
756 uint num = min((waiting + 5) / 10, width / 10); // maximum is width / 10 icons so it won't overflow
dcc2194ac748 (svn r12458) -Codechange: split acquiring the sprite ID for cargos from the actual drawing of them.
rubidium <rubidium@openttd.org>
parents: 8750
diff changeset
757 if (num == 0) return;
dcc2194ac748 (svn r12458) -Codechange: split acquiring the sprite ID for cargos from the actual drawing of them.
rubidium <rubidium@openttd.org>
parents: 8750
diff changeset
758
dcc2194ac748 (svn r12458) -Codechange: split acquiring the sprite ID for cargos from the actual drawing of them.
rubidium <rubidium@openttd.org>
parents: 8750
diff changeset
759 SpriteID sprite = GetCargoSprite(i);
dcc2194ac748 (svn r12458) -Codechange: split acquiring the sprite ID for cargos from the actual drawing of them.
rubidium <rubidium@openttd.org>
parents: 8750
diff changeset
760
6364
12ef3186e753 (svn r9417) -Fix (r1): Waiting cargo icons in the station view window were incorrectly drawn if the cargo list was scrolled, resulting in overlapping images
peter1138 <peter1138@openttd.org>
parents: 6350
diff changeset
761 do {
12ef3186e753 (svn r9417) -Fix (r1): Waiting cargo icons in the station view window were incorrectly drawn if the cargo list was scrolled, resulting in overlapping images
peter1138 <peter1138@openttd.org>
parents: 6350
diff changeset
762 DrawSprite(sprite, PAL_NONE, x, y);
12ef3186e753 (svn r9417) -Fix (r1): Waiting cargo icons in the station view window were incorrectly drawn if the cargo list was scrolled, resulting in overlapping images
peter1138 <peter1138@openttd.org>
parents: 6350
diff changeset
763 x += 10;
12ef3186e753 (svn r9417) -Fix (r1): Waiting cargo icons in the station view window were incorrectly drawn if the cargo list was scrolled, resulting in overlapping images
peter1138 <peter1138@openttd.org>
parents: 6350
diff changeset
764 } while (--num);
12ef3186e753 (svn r9417) -Fix (r1): Waiting cargo icons in the station view window were incorrectly drawn if the cargo list was scrolled, resulting in overlapping images
peter1138 <peter1138@openttd.org>
parents: 6350
diff changeset
765 }
12ef3186e753 (svn r9417) -Fix (r1): Waiting cargo icons in the station view window were incorrectly drawn if the cargo list was scrolled, resulting in overlapping images
peter1138 <peter1138@openttd.org>
parents: 6350
diff changeset
766
8420
370ea805f591 (svn r11990) -Codechange: Show all cargo sources (en-route from) in the station view
peter1138 <peter1138@openttd.org>
parents: 8349
diff changeset
767 struct CargoData {
370ea805f591 (svn r11990) -Codechange: Show all cargo sources (en-route from) in the station view
peter1138 <peter1138@openttd.org>
parents: 8349
diff changeset
768 CargoID cargo;
370ea805f591 (svn r11990) -Codechange: Show all cargo sources (en-route from) in the station view
peter1138 <peter1138@openttd.org>
parents: 8349
diff changeset
769 StationID source;
370ea805f591 (svn r11990) -Codechange: Show all cargo sources (en-route from) in the station view
peter1138 <peter1138@openttd.org>
parents: 8349
diff changeset
770 uint count;
370ea805f591 (svn r11990) -Codechange: Show all cargo sources (en-route from) in the station view
peter1138 <peter1138@openttd.org>
parents: 8349
diff changeset
771
370ea805f591 (svn r11990) -Codechange: Show all cargo sources (en-route from) in the station view
peter1138 <peter1138@openttd.org>
parents: 8349
diff changeset
772 CargoData(CargoID cargo, StationID source, uint count) :
370ea805f591 (svn r11990) -Codechange: Show all cargo sources (en-route from) in the station view
peter1138 <peter1138@openttd.org>
parents: 8349
diff changeset
773 cargo(cargo),
370ea805f591 (svn r11990) -Codechange: Show all cargo sources (en-route from) in the station view
peter1138 <peter1138@openttd.org>
parents: 8349
diff changeset
774 source(source),
370ea805f591 (svn r11990) -Codechange: Show all cargo sources (en-route from) in the station view
peter1138 <peter1138@openttd.org>
parents: 8349
diff changeset
775 count(count)
370ea805f591 (svn r11990) -Codechange: Show all cargo sources (en-route from) in the station view
peter1138 <peter1138@openttd.org>
parents: 8349
diff changeset
776 { }
370ea805f591 (svn r11990) -Codechange: Show all cargo sources (en-route from) in the station view
peter1138 <peter1138@openttd.org>
parents: 8349
diff changeset
777 };
370ea805f591 (svn r11990) -Codechange: Show all cargo sources (en-route from) in the station view
peter1138 <peter1138@openttd.org>
parents: 8349
diff changeset
778
370ea805f591 (svn r11990) -Codechange: Show all cargo sources (en-route from) in the station view
peter1138 <peter1138@openttd.org>
parents: 8349
diff changeset
779 typedef std::list<CargoData> CargoDataList;
370ea805f591 (svn r11990) -Codechange: Show all cargo sources (en-route from) in the station view
peter1138 <peter1138@openttd.org>
parents: 8349
diff changeset
780
8016
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
781 /**
9185
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
782 * The StationView window
8016
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
783 */
9185
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
784 struct StationViewWindow : public Window {
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
785 uint32 cargo; ///< Bitmask of cargo types to expand
9391
2903275601be (svn r13302) -Fix (r13301): GCC doesn't necessarily like what MSVC likes...
rubidium <rubidium@openttd.org>
parents: 9390
diff changeset
786 uint16 cargo_rows[NUM_CARGO]; ///< Header row for each cargo type
9185
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
787
9203
375bae14ff71 (svn r13069) -Codechange: it is no longer needed to pass a void *data pointer with the WE_CREATE message because nothing uses it anymore.
rubidium <rubidium@openttd.org>
parents: 9191
diff changeset
788 StationViewWindow(const WindowDesc *desc, WindowNumber window_number) : Window(desc, window_number)
9185
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
789 {
11922
0a4b63f3f3c3 (svn r16325) -Codechange: replace GetPoolItem(index) by PoolItem::Get(index)
smatz <smatz@openttd.org>
parents: 11852
diff changeset
790 Owner owner = Station::Get(window_number)->owner;
11084
e07c7d3925c8 (svn r15427) -Codechange: give w->caption_color a more sensible name as it holds the owner of whatever is shown in the window
rubidium <rubidium@openttd.org>
parents: 11080
diff changeset
791 if (owner != OWNER_NONE) this->owner = owner;
12881
06daf47f0ab2 (svn r17373) -Codechange: make the timetable, station and subsidy GUIs use scrollbar wrappers
rubidium <rubidium@openttd.org>
parents: 12804
diff changeset
792 this->vscroll.SetCapacity(5);
9185
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
793 this->resize.step_height = 10;
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
794
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
795 this->FindWindowPlacementAndResize(desc);
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
796 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
797
9185
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
798 ~StationViewWindow()
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
799 {
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
800 WindowNumber wno =
11922
0a4b63f3f3c3 (svn r16325) -Codechange: replace GetPoolItem(index) by PoolItem::Get(index)
smatz <smatz@openttd.org>
parents: 11852
diff changeset
801 (this->window_number << 16) | VLW_STATION_LIST | Station::Get(this->window_number)->owner;
8420
370ea805f591 (svn r11990) -Codechange: Show all cargo sources (en-route from) in the station view
peter1138 <peter1138@openttd.org>
parents: 8349
diff changeset
802
10528
faf41b99dbc3 (svn r14785) -Fix [FS#2132]: vehicle list for station gets closed when station view is closed even when the vehicle list is stickied. Other vehicle lists are not deleted when their 'opening' window gets closed so do the same with the station view.
rubidium <rubidium@openttd.org>
parents: 10499
diff changeset
803 DeleteWindowById(WC_TRAINS_LIST, wno | (VEH_TRAIN << 11), false);
faf41b99dbc3 (svn r14785) -Fix [FS#2132]: vehicle list for station gets closed when station view is closed even when the vehicle list is stickied. Other vehicle lists are not deleted when their 'opening' window gets closed so do the same with the station view.
rubidium <rubidium@openttd.org>
parents: 10499
diff changeset
804 DeleteWindowById(WC_ROADVEH_LIST, wno | (VEH_ROAD << 11), false);
faf41b99dbc3 (svn r14785) -Fix [FS#2132]: vehicle list for station gets closed when station view is closed even when the vehicle list is stickied. Other vehicle lists are not deleted when their 'opening' window gets closed so do the same with the station view.
rubidium <rubidium@openttd.org>
parents: 10499
diff changeset
805 DeleteWindowById(WC_SHIPS_LIST, wno | (VEH_SHIP << 11), false);
faf41b99dbc3 (svn r14785) -Fix [FS#2132]: vehicle list for station gets closed when station view is closed even when the vehicle list is stickied. Other vehicle lists are not deleted when their 'opening' window gets closed so do the same with the station view.
rubidium <rubidium@openttd.org>
parents: 10499
diff changeset
806 DeleteWindowById(WC_AIRCRAFT_LIST, wno | (VEH_AIRCRAFT << 11), false);
9185
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
807 }
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
808
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
809 virtual void OnPaint()
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
810 {
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
811 StationID station_id = this->window_number;
11922
0a4b63f3f3c3 (svn r16325) -Codechange: replace GetPoolItem(index) by PoolItem::Get(index)
smatz <smatz@openttd.org>
parents: 11852
diff changeset
812 const Station *st = Station::Get(station_id);
9185
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
813 CargoDataList cargolist;
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
814 uint32 transfers = 0;
8750
495247050dad (svn r12446) -Feature: Add +/- toggle buttons to station cargo waiting list to show/hide the detailed transferred cargo information.
peter1138 <peter1138@openttd.org>
parents: 8719
diff changeset
815
9185
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
816 /* count types of cargos waiting in station */
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
817 for (CargoID i = 0; i < NUM_CARGO; i++) {
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
818 if (st->goods[i].cargo.Empty()) {
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
819 this->cargo_rows[i] = 0;
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
820 } else {
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
821 /* Add an entry for total amount of cargo of this type waiting. */
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
822 cargolist.push_back(CargoData(i, INVALID_STATION, st->goods[i].cargo.Count()));
8420
370ea805f591 (svn r11990) -Codechange: Show all cargo sources (en-route from) in the station view
peter1138 <peter1138@openttd.org>
parents: 8349
diff changeset
823
9185
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
824 /* Set the row for this cargo entry for the expand/hide button */
9391
2903275601be (svn r13302) -Fix (r13301): GCC doesn't necessarily like what MSVC likes...
rubidium <rubidium@openttd.org>
parents: 9390
diff changeset
825 this->cargo_rows[i] = (uint16)cargolist.size();
9185
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
826
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
827 /* Add an entry for each distinct cargo source. */
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
828 const CargoList::List *packets = st->goods[i].cargo.Packets();
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
829 for (CargoList::List::const_iterator it = packets->begin(); it != packets->end(); it++) {
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
830 const CargoPacket *cp = *it;
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
831 if (cp->source != station_id) {
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
832 bool added = false;
8750
495247050dad (svn r12446) -Feature: Add +/- toggle buttons to station cargo waiting list to show/hide the detailed transferred cargo information.
peter1138 <peter1138@openttd.org>
parents: 8719
diff changeset
833
9185
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
834 /* Enable the expand/hide button for this cargo type */
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
835 SetBit(transfers, i);
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
836
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
837 /* Don't add cargo lines if not expanded */
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
838 if (!HasBit(this->cargo, i)) break;
8750
495247050dad (svn r12446) -Feature: Add +/- toggle buttons to station cargo waiting list to show/hide the detailed transferred cargo information.
peter1138 <peter1138@openttd.org>
parents: 8719
diff changeset
839
9185
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
840 /* Check if we already have this source in the list */
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
841 for (CargoDataList::iterator jt = cargolist.begin(); jt != cargolist.end(); jt++) {
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
842 CargoData *cd = &(*jt);
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
843 if (cd->cargo == i && cd->source == cp->source) {
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
844 cd->count += cp->count;
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
845 added = true;
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
846 break;
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
847 }
8420
370ea805f591 (svn r11990) -Codechange: Show all cargo sources (en-route from) in the station view
peter1138 <peter1138@openttd.org>
parents: 8349
diff changeset
848 }
9185
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
849
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
850 if (!added) cargolist.push_back(CargoData(i, cp->source, cp->count));
8420
370ea805f591 (svn r11990) -Codechange: Show all cargo sources (en-route from) in the station view
peter1138 <peter1138@openttd.org>
parents: 8349
diff changeset
851 }
370ea805f591 (svn r11990) -Codechange: Show all cargo sources (en-route from) in the station view
peter1138 <peter1138@openttd.org>
parents: 8349
diff changeset
852 }
370ea805f591 (svn r11990) -Codechange: Show all cargo sources (en-route from) in the station view
peter1138 <peter1138@openttd.org>
parents: 8349
diff changeset
853 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
854 }
12881
06daf47f0ab2 (svn r17373) -Codechange: make the timetable, station and subsidy GUIs use scrollbar wrappers
rubidium <rubidium@openttd.org>
parents: 12804
diff changeset
855 this->vscroll.SetCount((int)cargolist.size() + 1); // update 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
856
9185
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
857 /* disable some buttons */
10207
c54d140df948 (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents: 10180
diff changeset
858 this->SetWidgetDisabledState(SVW_RENAME, st->owner != _local_company);
9185
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
859 this->SetWidgetDisabledState(SVW_TRAINS, !(st->facilities & FACIL_TRAIN));
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
860 this->SetWidgetDisabledState(SVW_ROADVEHS, !(st->facilities & FACIL_TRUCK_STOP) && !(st->facilities & FACIL_BUS_STOP));
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
861 this->SetWidgetDisabledState(SVW_PLANES, !(st->facilities & FACIL_AIRPORT));
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
862 this->SetWidgetDisabledState(SVW_SHIPS, !(st->facilities & FACIL_DOCK));
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
863
9185
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
864 SetDParam(0, st->index);
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
865 SetDParam(1, st->facilities);
9273
72a6d2e60834 (svn r13139) -Codechange: move DrawWindowWidgets and DrawWindowViewport to the Window class and remove Window from their naming.
rubidium <rubidium@openttd.org>
parents: 9214
diff changeset
866 this->DrawWidgets();
8964
ae064b8e200b (svn r12756) -Cleanup: variable scope and coding style in station*
smatz <smatz@openttd.org>
parents: 8857
diff changeset
867
9185
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
868 int x = 2; ///< coordinates used for printing waiting/accepted/rating of cargo
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
869 int y = 15;
12881
06daf47f0ab2 (svn r17373) -Codechange: make the timetable, station and subsidy GUIs use scrollbar wrappers
rubidium <rubidium@openttd.org>
parents: 12804
diff changeset
870 int pos = this->vscroll.GetPosition();
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
9185
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
872 uint width = this->widget[SVW_WAITING].right - this->widget[SVW_WAITING].left - 4;
12881
06daf47f0ab2 (svn r17373) -Codechange: make the timetable, station and subsidy GUIs use scrollbar wrappers
rubidium <rubidium@openttd.org>
parents: 12804
diff changeset
873 int maxrows = this->vscroll.GetCapacity();
9185
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
874
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
875 StringID str;
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
876
8420
370ea805f591 (svn r11990) -Codechange: Show all cargo sources (en-route from) in the station view
peter1138 <peter1138@openttd.org>
parents: 8349
diff changeset
877 if (--pos < 0) {
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: 11666
diff changeset
878 str = STR_JUST_NOTHING;
9185
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
879 for (CargoID i = 0; i < NUM_CARGO; i++) {
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
880 if (!st->goods[i].cargo.Empty()) str = STR_EMPTY;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
881 }
9185
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
882 SetDParam(0, str);
11770
534c3c3167f2 (svn r16160) -Codechange: remove the need for explicit TC_FROMSTRING for DrawString.
rubidium <rubidium@openttd.org>
parents: 11730
diff changeset
883 DrawString(x, this->widget[SVW_WAITING].right - 2, y, STR_STATION_VIEW_WAITING_TITLE);
8420
370ea805f591 (svn r11990) -Codechange: Show all cargo sources (en-route from) in the station view
peter1138 <peter1138@openttd.org>
parents: 8349
diff changeset
884 y += 10;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
885 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
886
9185
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
887 for (CargoDataList::const_iterator it = cargolist.begin(); it != cargolist.end() && pos > -maxrows; ++it) {
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
888 if (--pos < 0) {
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
889 const CargoData *cd = &(*it);
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
890 if (cd->source == INVALID_STATION) {
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
891 /* Heading */
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
892 DrawCargoIcons(cd->cargo, cd->count, x, y, width);
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
893 SetDParam(0, cd->cargo);
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
894 SetDParam(1, cd->count);
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
895 if (HasBit(transfers, cd->cargo)) {
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
896 /* This cargo has transfers waiting so show the expand or shrink 'button' */
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
897 const char *sym = HasBit(this->cargo, cd->cargo) ? "-" : "+";
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: 11666
diff changeset
898 DrawString(this->widget[SVW_WAITING].left, this->widget[SVW_WAITING].right - 12, y, STR_STATION_VIEW_WAITING_CARGO, TC_FROMSTRING, SA_RIGHT);
11433
07857d65c41a (svn r15791) -Codechange: remove the *RightAligned part of the old text drawing API.
rubidium <rubidium@openttd.org>
parents: 11432
diff changeset
899 DrawString(this->widget[SVW_WAITING].right - 10, this->widget[SVW_WAITING].right, y, sym, TC_YELLOW);
9185
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
900 } else {
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: 11666
diff changeset
901 DrawString(this->widget[SVW_WAITING].left, this->widget[SVW_WAITING].right - 4, y, STR_STATION_VIEW_WAITING_CARGO, TC_FROMSTRING, SA_RIGHT);
9185
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
902 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
903 } else {
9185
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
904 SetDParam(0, cd->cargo);
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
905 SetDParam(1, cd->count);
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
906 SetDParam(2, cd->source);
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: 11666
diff changeset
907 DrawString(x, x + width, y, STR_STATION_VIEW_EN_ROUTE_FROM, TC_FROMSTRING, SA_RIGHT);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
908 }
9185
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
909
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
910 y += 10;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
911 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
912 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
913
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: 11666
diff changeset
914 if (this->widget[SVW_ACCEPTS].data == STR_STATION_VIEW_RATINGS_BUTTON) { // small window with list of accepted cargo
9648
b53049484e44 (svn r13715) -Fix [FS#2129]: C-like strings had to be rebound each time they were printed, otherwise the text could change due to the few number of slots that could be used to bind.
rubidium <rubidium@openttd.org>
parents: 9580
diff changeset
915 char string[512];
b53049484e44 (svn r13715) -Fix [FS#2129]: C-like strings had to be rebound each time they were printed, otherwise the text could change due to the few number of slots that could be used to bind.
rubidium <rubidium@openttd.org>
parents: 9580
diff changeset
916 char *b = string;
9185
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
917 bool first = true;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
918
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: 11666
diff changeset
919 b = InlineString(b, STR_STATION_VIEW_ACCEPTS_CARGO);
8041
085c454f158b (svn r11601) -Codechange: more strict break conditions for _userstring, assert when it overflows anyway (eg. code change without proper check change)
smatz <smatz@openttd.org>
parents: 8040
diff changeset
920
9185
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
921 for (CargoID i = 0; i < NUM_CARGO; i++) {
9648
b53049484e44 (svn r13715) -Fix [FS#2129]: C-like strings had to be rebound each time they were printed, otherwise the text could change due to the few number of slots that could be used to bind.
rubidium <rubidium@openttd.org>
parents: 9580
diff changeset
922 if (b >= lastof(string) - (1 + 2 * 4)) break; // ',' or ' ' and two calls to Utf8Encode()
9185
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
923 if (HasBit(st->goods[i].acceptance_pickup, GoodsEntry::ACCEPTANCE)) {
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
924 if (first) {
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
925 first = false;
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
926 } else {
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
927 /* Add a comma if this is not the first item */
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
928 *b++ = ',';
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
929 *b++ = ' ';
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
930 }
12415
6a77d1df56e2 (svn r16849) -Codechange: replace GetCargo() by CargoSpec::Get()
smatz <smatz@openttd.org>
parents: 12311
diff changeset
931 b = InlineString(b, CargoSpec::Get(i)->name);
9185
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
932 }
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
933 }
8041
085c454f158b (svn r11601) -Codechange: more strict break conditions for _userstring, assert when it overflows anyway (eg. code change without proper check change)
smatz <smatz@openttd.org>
parents: 8040
diff changeset
934
9185
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
935 /* If first is still true then no cargo is accepted */
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: 11666
diff changeset
936 if (first) b = InlineString(b, STR_JUST_NOTHING);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
937
9185
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
938 *b = '\0';
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
939
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
940 /* Make sure we detect any buffer overflow */
9648
b53049484e44 (svn r13715) -Fix [FS#2129]: C-like strings had to be rebound each time they were printed, otherwise the text could change due to the few number of slots that could be used to bind.
rubidium <rubidium@openttd.org>
parents: 9580
diff changeset
941 assert(b < endof(string));
8420
370ea805f591 (svn r11990) -Codechange: Show all cargo sources (en-route from) in the station view
peter1138 <peter1138@openttd.org>
parents: 8349
diff changeset
942
9648
b53049484e44 (svn r13715) -Fix [FS#2129]: C-like strings had to be rebound each time they were printed, otherwise the text could change due to the few number of slots that could be used to bind.
rubidium <rubidium@openttd.org>
parents: 9580
diff changeset
943 SetDParamStr(0, string);
11476
8356abea7834 (svn r15837) -Codechange: support SETX(Y) with RTL text, swap alignment for RTL text.
rubidium <rubidium@openttd.org>
parents: 11475
diff changeset
944 DrawStringMultiLine(this->widget[SVW_ACCEPTLIST].left + 2, this->widget[SVW_ACCEPTLIST].right - 2, this->widget[SVW_ACCEPTLIST].top + 1, this->widget[SVW_ACCEPTLIST].bottom - 1, STR_JUST_RAW_STRING);
9185
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
945 } else { // extended window with list of cargo ratings
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
946 y = this->widget[SVW_RATINGLIST].top + 1;
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
947
11770
534c3c3167f2 (svn r16160) -Codechange: remove the need for explicit TC_FROMSTRING for DrawString.
rubidium <rubidium@openttd.org>
parents: 11730
diff changeset
948 DrawString(this->widget[SVW_ACCEPTLIST].left + 2, this->widget[SVW_ACCEPTLIST].right - 2, y, STR_STATION_VIEW_CARGO_RATINGS_TITLE);
9185
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
949 y += 10;
6297
e7e15e4d1367 (svn r9127) -Codechange: Check if a cargo is valid before displaying it in a station's cargo rating list. (And duff up the block a little)
peter1138 <peter1138@openttd.org>
parents: 6285
diff changeset
950
12418
0d8340a4c70e (svn r16852) -Codechange: use FOR_ALL_CARGOSPECS for iterating over all valid CargoSpecs
smatz <smatz@openttd.org>
parents: 12415
diff changeset
951 const CargoSpec *cs;
0d8340a4c70e (svn r16852) -Codechange: use FOR_ALL_CARGOSPECS for iterating over all valid CargoSpecs
smatz <smatz@openttd.org>
parents: 12415
diff changeset
952 FOR_ALL_CARGOSPECS(cs) {
0d8340a4c70e (svn r16852) -Codechange: use FOR_ALL_CARGOSPECS for iterating over all valid CargoSpecs
smatz <smatz@openttd.org>
parents: 12415
diff changeset
953 const GoodsEntry *ge = &st->goods[cs->Index()];
9185
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
954 if (!HasBit(ge->acceptance_pickup, GoodsEntry::PICKUP)) continue;
6297
e7e15e4d1367 (svn r9127) -Codechange: Check if a cargo is valid before displaying it in a station's cargo rating list. (And duff up the block a little)
peter1138 <peter1138@openttd.org>
parents: 6285
diff changeset
955
9185
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
956 SetDParam(0, cs->name);
12804
bcc8ad6501c5 (svn r17292) -Codechange: use unified ToPercent() function to convert fract numbers to percents
smatz <smatz@openttd.org>
parents: 12778
diff changeset
957 SetDParam(2, ToPercent8(ge->rating));
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: 11666
diff changeset
958 SetDParam(1, STR_CARGO_RATING_APPALLING + (ge->rating >> 5));
11770
534c3c3167f2 (svn r16160) -Codechange: remove the need for explicit TC_FROMSTRING for DrawString.
rubidium <rubidium@openttd.org>
parents: 11730
diff changeset
959 DrawString(this->widget[SVW_ACCEPTLIST].left + 8, this->widget[SVW_ACCEPTLIST].right - 2, y, STR_STATION_VIEW_CARGO_RATING);
9185
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
960 y += 10;
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
961 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
962 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
963 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
964
9185
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
965 void HandleCargoWaitingClick(int row)
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
966 {
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
967 if (row == 0) return;
8750
495247050dad (svn r12446) -Feature: Add +/- toggle buttons to station cargo waiting list to show/hide the detailed transferred cargo information.
peter1138 <peter1138@openttd.org>
parents: 8719
diff changeset
968
9185
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
969 for (CargoID c = 0; c < NUM_CARGO; c++) {
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
970 if (this->cargo_rows[c] == row) {
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
971 ToggleBit(this->cargo, c);
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
972 this->InvalidateWidget(SVW_WAITING);
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
973 break;
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
974 }
8750
495247050dad (svn r12446) -Feature: Add +/- toggle buttons to station cargo waiting list to show/hide the detailed transferred cargo information.
peter1138 <peter1138@openttd.org>
parents: 8719
diff changeset
975 }
495247050dad (svn r12446) -Feature: Add +/- toggle buttons to station cargo waiting list to show/hide the detailed transferred cargo information.
peter1138 <peter1138@openttd.org>
parents: 8719
diff changeset
976 }
495247050dad (svn r12446) -Feature: Add +/- toggle buttons to station cargo waiting list to show/hide the detailed transferred cargo information.
peter1138 <peter1138@openttd.org>
parents: 8719
diff changeset
977
9185
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
978 virtual void OnClick(Point pt, int widget)
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
979 {
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
980 switch (widget) {
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
981 case SVW_WAITING:
12881
06daf47f0ab2 (svn r17373) -Codechange: make the timetable, station and subsidy GUIs use scrollbar wrappers
rubidium <rubidium@openttd.org>
parents: 12804
diff changeset
982 this->HandleCargoWaitingClick((pt.y - this->widget[SVW_WAITING].top) / 10 + this->vscroll.GetPosition());
9185
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
983 break;
8750
495247050dad (svn r12446) -Feature: Add +/- toggle buttons to station cargo waiting list to show/hide the detailed transferred cargo information.
peter1138 <peter1138@openttd.org>
parents: 8719
diff changeset
984
9185
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
985 case SVW_LOCATION:
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
986 if (_ctrl_pressed) {
11922
0a4b63f3f3c3 (svn r16325) -Codechange: replace GetPoolItem(index) by PoolItem::Get(index)
smatz <smatz@openttd.org>
parents: 11852
diff changeset
987 ShowExtraViewPortWindow(Station::Get(this->window_number)->xy);
9185
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
988 } else {
11922
0a4b63f3f3c3 (svn r16325) -Codechange: replace GetPoolItem(index) by PoolItem::Get(index)
smatz <smatz@openttd.org>
parents: 11852
diff changeset
989 ScrollMainWindowToTile(Station::Get(this->window_number)->xy);
9185
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
990 }
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
991 break;
6202
eb0fdb88a922 (svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138 <peter1138@openttd.org>
parents: 6122
diff changeset
992
9185
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
993 case SVW_RATINGS:
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
994 this->SetDirty();
6202
eb0fdb88a922 (svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138 <peter1138@openttd.org>
parents: 6122
diff changeset
995
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: 11666
diff changeset
996 if (this->widget[SVW_RATINGS].data == STR_STATION_VIEW_RATINGS_BUTTON) {
9185
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
997 /* Switch to ratings view */
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: 11666
diff changeset
998 this->widget[SVW_RATINGS].data = STR_STATION_VIEW_ACCEPTS_BUTTON;
a39da1e4c1f5 (svn r16118) -Change/cleanup: remove the hexadecimal 'in TTD the string had this ID' from 'some' strings and replace the string name with something more sensible.
rubidium <rubidium@openttd.org>
parents: 11666
diff changeset
999 this->widget[SVW_RATINGS].tooltips = STR_STATION_VIEW_ACCEPTS_TOOLTIP;
9185
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
1000 ResizeWindowForWidget(this, SVW_ACCEPTLIST, 0, 100);
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
1001 } else {
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
1002 /* Switch to accepts view */
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: 11666
diff changeset
1003 this->widget[SVW_RATINGS].data = STR_STATION_VIEW_RATINGS_BUTTON;
a39da1e4c1f5 (svn r16118) -Change/cleanup: remove the hexadecimal 'in TTD the string had this ID' from 'some' strings and replace the string name with something more sensible.
rubidium <rubidium@openttd.org>
parents: 11666
diff changeset
1004 this->widget[SVW_RATINGS].tooltips = STR_STATION_VIEW_RATINGS_TOOLTIP;
9185
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
1005 ResizeWindowForWidget(this, SVW_ACCEPTLIST, 0, -100);
6202
eb0fdb88a922 (svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138 <peter1138@openttd.org>
parents: 6122
diff changeset
1006 }
eb0fdb88a922 (svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138 <peter1138@openttd.org>
parents: 6122
diff changeset
1007
9185
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
1008 this->SetDirty();
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
1009 break;
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
1010
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
1011 case SVW_RENAME:
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
1012 SetDParam(0, this->window_number);
12632
e41943276802 (svn r17075) -Codechange: rename ~750 strings to be more uniform with their relatives
rubidium <rubidium@openttd.org>
parents: 12564
diff changeset
1013 ShowQueryString(STR_STATION_NAME, STR_STATION_VIEW_RENAME_STATION_CAPTION, MAX_LENGTH_STATION_NAME_BYTES, MAX_LENGTH_STATION_NAME_PIXELS, this, CS_ALPHANUMERAL, QSF_ENABLE_DEFAULT);
9185
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
1014 break;
6202
eb0fdb88a922 (svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138 <peter1138@openttd.org>
parents: 6122
diff changeset
1015
9185
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
1016 case SVW_TRAINS: { // Show a list of scheduled trains to this station
11922
0a4b63f3f3c3 (svn r16325) -Codechange: replace GetPoolItem(index) by PoolItem::Get(index)
smatz <smatz@openttd.org>
parents: 11852
diff changeset
1017 const Station *st = Station::Get(this->window_number);
9185
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
1018 ShowVehicleListWindow(st->owner, VEH_TRAIN, (StationID)this->window_number);
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
1019 break;
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
1020 }
6202
eb0fdb88a922 (svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138 <peter1138@openttd.org>
parents: 6122
diff changeset
1021
9185
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
1022 case SVW_ROADVEHS: { // Show a list of scheduled road-vehicles to this station
11922
0a4b63f3f3c3 (svn r16325) -Codechange: replace GetPoolItem(index) by PoolItem::Get(index)
smatz <smatz@openttd.org>
parents: 11852
diff changeset
1023 const Station *st = Station::Get(this->window_number);
9185
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
1024 ShowVehicleListWindow(st->owner, VEH_ROAD, (StationID)this->window_number);
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
1025 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
1026 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1027
9185
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
1028 case SVW_PLANES: { // Show a list of scheduled aircraft to this station
11922
0a4b63f3f3c3 (svn r16325) -Codechange: replace GetPoolItem(index) by PoolItem::Get(index)
smatz <smatz@openttd.org>
parents: 11852
diff changeset
1029 const Station *st = Station::Get(this->window_number);
10996
ce54bfd52120 (svn r15336) -Fix: do not use _current_company in the GUI as there are no guarantees that _current_company is the same as _local_company.
rubidium <rubidium@openttd.org>
parents: 10960
diff changeset
1030 /* Since oilrigs have no owners, show the scheduled aircraft of local company */
ce54bfd52120 (svn r15336) -Fix: do not use _current_company in the GUI as there are no guarantees that _current_company is the same as _local_company.
rubidium <rubidium@openttd.org>
parents: 10960
diff changeset
1031 Owner owner = (st->owner == OWNER_NONE) ? _local_company : st->owner;
9185
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
1032 ShowVehicleListWindow(owner, VEH_AIRCRAFT, (StationID)this->window_number);
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
1033 break;
6202
eb0fdb88a922 (svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138 <peter1138@openttd.org>
parents: 6122
diff changeset
1034 }
eb0fdb88a922 (svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138 <peter1138@openttd.org>
parents: 6122
diff changeset
1035
9185
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
1036 case SVW_SHIPS: { // Show a list of scheduled ships to this station
11922
0a4b63f3f3c3 (svn r16325) -Codechange: replace GetPoolItem(index) by PoolItem::Get(index)
smatz <smatz@openttd.org>
parents: 11852
diff changeset
1037 const Station *st = Station::Get(this->window_number);
10996
ce54bfd52120 (svn r15336) -Fix: do not use _current_company in the GUI as there are no guarantees that _current_company is the same as _local_company.
rubidium <rubidium@openttd.org>
parents: 10960
diff changeset
1038 /* Since oilrigs/bouys have no owners, show the scheduled ships of local company */
ce54bfd52120 (svn r15336) -Fix: do not use _current_company in the GUI as there are no guarantees that _current_company is the same as _local_company.
rubidium <rubidium@openttd.org>
parents: 10960
diff changeset
1039 Owner owner = (st->owner == OWNER_NONE) ? _local_company : st->owner;
9185
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
1040 ShowVehicleListWindow(owner, VEH_SHIP, (StationID)this->window_number);
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
1041 break;
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
1042 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1043 }
9185
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
1044 }
8420
370ea805f591 (svn r11990) -Codechange: Show all cargo sources (en-route from) in the station view
peter1138 <peter1138@openttd.org>
parents: 8349
diff changeset
1045
9185
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
1046 virtual void OnQueryTextFinished(char *str)
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
1047 {
10148
81642658c8be (svn r14334) -Feature: ability to reset name to default/automatic value (for vehicles, engines, towns, groups, stations, waypoints, managers and companies)
smatz <smatz@openttd.org>
parents: 10145
diff changeset
1048 if (str == NULL) return;
81642658c8be (svn r14334) -Feature: ability to reset name to default/automatic value (for vehicles, engines, towns, groups, stations, waypoints, managers and companies)
smatz <smatz@openttd.org>
parents: 10145
diff changeset
1049
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: 11666
diff changeset
1050 DoCommandP(0, this->window_number, 0, CMD_RENAME_STATION | CMD_MSG(STR_ERROR_CAN_T_RENAME_STATION), NULL, str);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1051 }
9185
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
1052
11524
420a4f0b4e0b (svn r15885) -Codechange: Removed new_size parameter of Window::OnResize() callback
alberth <alberth@openttd.org>
parents: 11476
diff changeset
1053 virtual void OnResize(Point delta)
9185
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
1054 {
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
1055 if (delta.x != 0) ResizeButtons(this, SVW_LOCATION, SVW_RENAME);
12881
06daf47f0ab2 (svn r17373) -Codechange: make the timetable, station and subsidy GUIs use scrollbar wrappers
rubidium <rubidium@openttd.org>
parents: 12804
diff changeset
1056 this->vscroll.UpdateCapacity(delta.y / (int)this->resize.step_height);
9185
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
1057 }
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
1058 };
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1059
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1060
11373
474ba6cc0946 (svn r15723) -Codechange: use a constructor for WindowDescs as that makes expanding them much easier (Alberth)
rubidium <rubidium@openttd.org>
parents: 11361
diff changeset
1061 static const WindowDesc _station_view_desc(
7341
549c757023fc (svn r10704) -Codechange: provide an infrastructure to have resizable windows that are smaller than the default window size.
rubidium <rubidium@openttd.org>
parents: 7058
diff changeset
1062 WDP_AUTO, WDP_AUTO, 249, 110, 249, 110,
5893
8547517ef719 (svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium <rubidium@openttd.org>
parents: 5745
diff changeset
1063 WC_STATION_VIEW, WC_NONE,
8420
370ea805f591 (svn r11990) -Codechange: Show all cargo sources (en-route from) in the station view
peter1138 <peter1138@openttd.org>
parents: 8349
diff changeset
1064 WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_STICKY_BUTTON | WDF_RESIZABLE,
11822
fa3b41302eda (svn r16212) -Codechange: Added nested widgets for all station_gui windows.
alberth <alberth@openttd.org>
parents: 11821
diff changeset
1065 _station_view_widgets, _nested_station_view_widgets, lengthof(_nested_station_view_widgets)
11373
474ba6cc0946 (svn r15723) -Codechange: use a constructor for WindowDescs as that makes expanding them much easier (Alberth)
rubidium <rubidium@openttd.org>
parents: 11361
diff changeset
1066 );
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1067
8016
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
1068 /**
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
1069 * Opens StationViewWindow for given station
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
1070 *
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
1071 * @param station station which window should be opened
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
1072 */
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 void ShowStationViewWindow(StationID station)
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1074 {
9185
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
1075 AllocateWindowDescFront<StationViewWindow>(&_station_view_desc, station);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1076 }
10626
3189a053f43a (svn r14919) -Feature: distant joining of stations (Frostregen and PhilSophus)
rubidium <rubidium@openttd.org>
parents: 10565
diff changeset
1077
12311
b55d6d8e8851 (svn r16728) -Fix (r14919): the Join station window didn't show all stations nearby in some cases
smatz <smatz@openttd.org>
parents: 12228
diff changeset
1078 /** Struct containing TileIndex and StationID */
b55d6d8e8851 (svn r16728) -Fix (r14919): the Join station window didn't show all stations nearby in some cases
smatz <smatz@openttd.org>
parents: 12228
diff changeset
1079 struct TileAndStation {
b55d6d8e8851 (svn r16728) -Fix (r14919): the Join station window didn't show all stations nearby in some cases
smatz <smatz@openttd.org>
parents: 12228
diff changeset
1080 TileIndex tile; ///< TileIndex
b55d6d8e8851 (svn r16728) -Fix (r14919): the Join station window didn't show all stations nearby in some cases
smatz <smatz@openttd.org>
parents: 12228
diff changeset
1081 StationID station; ///< StationID
b55d6d8e8851 (svn r16728) -Fix (r14919): the Join station window didn't show all stations nearby in some cases
smatz <smatz@openttd.org>
parents: 12228
diff changeset
1082 };
b55d6d8e8851 (svn r16728) -Fix (r14919): the Join station window didn't show all stations nearby in some cases
smatz <smatz@openttd.org>
parents: 12228
diff changeset
1083
b55d6d8e8851 (svn r16728) -Fix (r14919): the Join station window didn't show all stations nearby in some cases
smatz <smatz@openttd.org>
parents: 12228
diff changeset
1084 static SmallVector<TileAndStation, 8> _deleted_stations_nearby;
10626
3189a053f43a (svn r14919) -Feature: distant joining of stations (Frostregen and PhilSophus)
rubidium <rubidium@openttd.org>
parents: 10565
diff changeset
1085 static SmallVector<StationID, 8> _stations_nearby_list;
3189a053f43a (svn r14919) -Feature: distant joining of stations (Frostregen and PhilSophus)
rubidium <rubidium@openttd.org>
parents: 10565
diff changeset
1086
3189a053f43a (svn r14919) -Feature: distant joining of stations (Frostregen and PhilSophus)
rubidium <rubidium@openttd.org>
parents: 10565
diff changeset
1087 /**
3189a053f43a (svn r14919) -Feature: distant joining of stations (Frostregen and PhilSophus)
rubidium <rubidium@openttd.org>
parents: 10565
diff changeset
1088 * Add station on this tile to _stations_nearby_list if it's fully within the
3189a053f43a (svn r14919) -Feature: distant joining of stations (Frostregen and PhilSophus)
rubidium <rubidium@openttd.org>
parents: 10565
diff changeset
1089 * station spread.
3189a053f43a (svn r14919) -Feature: distant joining of stations (Frostregen and PhilSophus)
rubidium <rubidium@openttd.org>
parents: 10565
diff changeset
1090 * @param tile Tile just being checked
12522
becf2d0cf3d2 (svn r16959) -Codechange: make the station joiner a bit more aware of the difference between waypoints and stations.
rubidium <rubidium@openttd.org>
parents: 12493
diff changeset
1091 * @param user_data Pointer to TileArea context
12564
5add58f1ce2a (svn r17002) -Change: also support distant join for waypoints
rubidium <rubidium@openttd.org>
parents: 12529
diff changeset
1092 * @tparam T the type of station to look for
10626
3189a053f43a (svn r14919) -Feature: distant joining of stations (Frostregen and PhilSophus)
rubidium <rubidium@openttd.org>
parents: 10565
diff changeset
1093 */
12564
5add58f1ce2a (svn r17002) -Change: also support distant join for waypoints
rubidium <rubidium@openttd.org>
parents: 12529
diff changeset
1094 template <class T>
10626
3189a053f43a (svn r14919) -Feature: distant joining of stations (Frostregen and PhilSophus)
rubidium <rubidium@openttd.org>
parents: 10565
diff changeset
1095 static bool AddNearbyStation(TileIndex tile, void *user_data)
3189a053f43a (svn r14919) -Feature: distant joining of stations (Frostregen and PhilSophus)
rubidium <rubidium@openttd.org>
parents: 10565
diff changeset
1096 {
12522
becf2d0cf3d2 (svn r16959) -Codechange: make the station joiner a bit more aware of the difference between waypoints and stations.
rubidium <rubidium@openttd.org>
parents: 12493
diff changeset
1097 TileArea *ctx = (TileArea *)user_data;
10626
3189a053f43a (svn r14919) -Feature: distant joining of stations (Frostregen and PhilSophus)
rubidium <rubidium@openttd.org>
parents: 10565
diff changeset
1098
12311
b55d6d8e8851 (svn r16728) -Fix (r14919): the Join station window didn't show all stations nearby in some cases
smatz <smatz@openttd.org>
parents: 12228
diff changeset
1099 /* First check if there were deleted stations here */
b55d6d8e8851 (svn r16728) -Fix (r14919): the Join station window didn't show all stations nearby in some cases
smatz <smatz@openttd.org>
parents: 12228
diff changeset
1100 for (uint i = 0; i < _deleted_stations_nearby.Length(); i++) {
b55d6d8e8851 (svn r16728) -Fix (r14919): the Join station window didn't show all stations nearby in some cases
smatz <smatz@openttd.org>
parents: 12228
diff changeset
1101 TileAndStation *ts = _deleted_stations_nearby.Get(i);
b55d6d8e8851 (svn r16728) -Fix (r14919): the Join station window didn't show all stations nearby in some cases
smatz <smatz@openttd.org>
parents: 12228
diff changeset
1102 if (ts->tile == tile) {
b55d6d8e8851 (svn r16728) -Fix (r14919): the Join station window didn't show all stations nearby in some cases
smatz <smatz@openttd.org>
parents: 12228
diff changeset
1103 *_stations_nearby_list.Append() = _deleted_stations_nearby[i].station;
b55d6d8e8851 (svn r16728) -Fix (r14919): the Join station window didn't show all stations nearby in some cases
smatz <smatz@openttd.org>
parents: 12228
diff changeset
1104 _deleted_stations_nearby.Erase(ts);
b55d6d8e8851 (svn r16728) -Fix (r14919): the Join station window didn't show all stations nearby in some cases
smatz <smatz@openttd.org>
parents: 12228
diff changeset
1105 i--;
b55d6d8e8851 (svn r16728) -Fix (r14919): the Join station window didn't show all stations nearby in some cases
smatz <smatz@openttd.org>
parents: 12228
diff changeset
1106 }
10626
3189a053f43a (svn r14919) -Feature: distant joining of stations (Frostregen and PhilSophus)
rubidium <rubidium@openttd.org>
parents: 10565
diff changeset
1107 }
3189a053f43a (svn r14919) -Feature: distant joining of stations (Frostregen and PhilSophus)
rubidium <rubidium@openttd.org>
parents: 10565
diff changeset
1108
3189a053f43a (svn r14919) -Feature: distant joining of stations (Frostregen and PhilSophus)
rubidium <rubidium@openttd.org>
parents: 10565
diff changeset
1109 /* Check if own station and if we stay within station spread */
3189a053f43a (svn r14919) -Feature: distant joining of stations (Frostregen and PhilSophus)
rubidium <rubidium@openttd.org>
parents: 10565
diff changeset
1110 if (!IsTileType(tile, MP_STATION)) return false;
3189a053f43a (svn r14919) -Feature: distant joining of stations (Frostregen and PhilSophus)
rubidium <rubidium@openttd.org>
parents: 10565
diff changeset
1111
3189a053f43a (svn r14919) -Feature: distant joining of stations (Frostregen and PhilSophus)
rubidium <rubidium@openttd.org>
parents: 10565
diff changeset
1112 StationID sid = GetStationIndex(tile);
12522
becf2d0cf3d2 (svn r16959) -Codechange: make the station joiner a bit more aware of the difference between waypoints and stations.
rubidium <rubidium@openttd.org>
parents: 12493
diff changeset
1113
becf2d0cf3d2 (svn r16959) -Codechange: make the station joiner a bit more aware of the difference between waypoints and stations.
rubidium <rubidium@openttd.org>
parents: 12493
diff changeset
1114 /* This station is (likely) a waypoint */
12564
5add58f1ce2a (svn r17002) -Change: also support distant join for waypoints
rubidium <rubidium@openttd.org>
parents: 12529
diff changeset
1115 if (!T::IsValidID(sid)) return false;
12522
becf2d0cf3d2 (svn r16959) -Codechange: make the station joiner a bit more aware of the difference between waypoints and stations.
rubidium <rubidium@openttd.org>
parents: 12493
diff changeset
1116
12564
5add58f1ce2a (svn r17002) -Change: also support distant join for waypoints
rubidium <rubidium@openttd.org>
parents: 12529
diff changeset
1117 T *st = T::Get(sid);
10626
3189a053f43a (svn r14919) -Feature: distant joining of stations (Frostregen and PhilSophus)
rubidium <rubidium@openttd.org>
parents: 10565
diff changeset
1118 if (st->owner != _local_company || _stations_nearby_list.Contains(sid)) return false;
3189a053f43a (svn r14919) -Feature: distant joining of stations (Frostregen and PhilSophus)
rubidium <rubidium@openttd.org>
parents: 10565
diff changeset
1119
3189a053f43a (svn r14919) -Feature: distant joining of stations (Frostregen and PhilSophus)
rubidium <rubidium@openttd.org>
parents: 10565
diff changeset
1120 if (st->rect.BeforeAddRect(ctx->tile, ctx->w, ctx->h, StationRect::ADD_TEST)) {
3189a053f43a (svn r14919) -Feature: distant joining of stations (Frostregen and PhilSophus)
rubidium <rubidium@openttd.org>
parents: 10565
diff changeset
1121 *_stations_nearby_list.Append() = sid;
3189a053f43a (svn r14919) -Feature: distant joining of stations (Frostregen and PhilSophus)
rubidium <rubidium@openttd.org>
parents: 10565
diff changeset
1122 }
3189a053f43a (svn r14919) -Feature: distant joining of stations (Frostregen and PhilSophus)
rubidium <rubidium@openttd.org>
parents: 10565
diff changeset
1123
3189a053f43a (svn r14919) -Feature: distant joining of stations (Frostregen and PhilSophus)
rubidium <rubidium@openttd.org>
parents: 10565
diff changeset
1124 return false; // We want to include *all* nearby stations
3189a053f43a (svn r14919) -Feature: distant joining of stations (Frostregen and PhilSophus)
rubidium <rubidium@openttd.org>
parents: 10565
diff changeset
1125 }
3189a053f43a (svn r14919) -Feature: distant joining of stations (Frostregen and PhilSophus)
rubidium <rubidium@openttd.org>
parents: 10565
diff changeset
1126
3189a053f43a (svn r14919) -Feature: distant joining of stations (Frostregen and PhilSophus)
rubidium <rubidium@openttd.org>
parents: 10565
diff changeset
1127 /**
3189a053f43a (svn r14919) -Feature: distant joining of stations (Frostregen and PhilSophus)
rubidium <rubidium@openttd.org>
parents: 10565
diff changeset
1128 * Circulate around the to-be-built station to find stations we could join.
3189a053f43a (svn r14919) -Feature: distant joining of stations (Frostregen and PhilSophus)
rubidium <rubidium@openttd.org>
parents: 10565
diff changeset
1129 * Make sure that only stations are returned where joining wouldn't exceed
3189a053f43a (svn r14919) -Feature: distant joining of stations (Frostregen and PhilSophus)
rubidium <rubidium@openttd.org>
parents: 10565
diff changeset
1130 * station spread and are our own station.
3189a053f43a (svn r14919) -Feature: distant joining of stations (Frostregen and PhilSophus)
rubidium <rubidium@openttd.org>
parents: 10565
diff changeset
1131 * @param tile Base tile of the to-be-built station
3189a053f43a (svn r14919) -Feature: distant joining of stations (Frostregen and PhilSophus)
rubidium <rubidium@openttd.org>
parents: 10565
diff changeset
1132 * @param w Width of the to-be-built station
3189a053f43a (svn r14919) -Feature: distant joining of stations (Frostregen and PhilSophus)
rubidium <rubidium@openttd.org>
parents: 10565
diff changeset
1133 * @param h Height of the to-be-built station
3189a053f43a (svn r14919) -Feature: distant joining of stations (Frostregen and PhilSophus)
rubidium <rubidium@openttd.org>
parents: 10565
diff changeset
1134 * @param distant_join Search for adjacent stations (false) or stations fully
3189a053f43a (svn r14919) -Feature: distant joining of stations (Frostregen and PhilSophus)
rubidium <rubidium@openttd.org>
parents: 10565
diff changeset
1135 * within station spread
12564
5add58f1ce2a (svn r17002) -Change: also support distant join for waypoints
rubidium <rubidium@openttd.org>
parents: 12529
diff changeset
1136 * @tparam T the type of station to look for
10626
3189a053f43a (svn r14919) -Feature: distant joining of stations (Frostregen and PhilSophus)
rubidium <rubidium@openttd.org>
parents: 10565
diff changeset
1137 **/
12564
5add58f1ce2a (svn r17002) -Change: also support distant join for waypoints
rubidium <rubidium@openttd.org>
parents: 12529
diff changeset
1138 template <class T>
5add58f1ce2a (svn r17002) -Change: also support distant join for waypoints
rubidium <rubidium@openttd.org>
parents: 12529
diff changeset
1139 static const T *FindStationsNearby(TileArea ta, bool distant_join)
10626
3189a053f43a (svn r14919) -Feature: distant joining of stations (Frostregen and PhilSophus)
rubidium <rubidium@openttd.org>
parents: 10565
diff changeset
1140 {
12528
a8b8bcd7f03d (svn r16965) -Codechange: use tile area instead of sets of variables for the station joiner code.
rubidium <rubidium@openttd.org>
parents: 12522
diff changeset
1141 TileArea ctx = ta;
10626
3189a053f43a (svn r14919) -Feature: distant joining of stations (Frostregen and PhilSophus)
rubidium <rubidium@openttd.org>
parents: 10565
diff changeset
1142
3189a053f43a (svn r14919) -Feature: distant joining of stations (Frostregen and PhilSophus)
rubidium <rubidium@openttd.org>
parents: 10565
diff changeset
1143 _stations_nearby_list.Clear();
3189a053f43a (svn r14919) -Feature: distant joining of stations (Frostregen and PhilSophus)
rubidium <rubidium@openttd.org>
parents: 10565
diff changeset
1144 _deleted_stations_nearby.Clear();
3189a053f43a (svn r14919) -Feature: distant joining of stations (Frostregen and PhilSophus)
rubidium <rubidium@openttd.org>
parents: 10565
diff changeset
1145
3189a053f43a (svn r14919) -Feature: distant joining of stations (Frostregen and PhilSophus)
rubidium <rubidium@openttd.org>
parents: 10565
diff changeset
1146 /* Check the inside, to return, if we sit on another station */
12529
f24901a2ad84 (svn r16966) -Codechange: BEGIN_TILE_LOOP and END_TILE_LOOP reworked into TILE_LOOP, which means no more duplication of parameters between BEGIN_TILE_LOOP and END_TILE_LOOP
rubidium <rubidium@openttd.org>
parents: 12528
diff changeset
1147 TILE_LOOP(t, ta.w, ta.h, ta.tile) {
12564
5add58f1ce2a (svn r17002) -Change: also support distant join for waypoints
rubidium <rubidium@openttd.org>
parents: 12529
diff changeset
1148 if (t < MapSize() && IsTileType(t, MP_STATION) && T::IsValidID(GetStationIndex(t))) return T::GetByTile(t);
12529
f24901a2ad84 (svn r16966) -Codechange: BEGIN_TILE_LOOP and END_TILE_LOOP reworked into TILE_LOOP, which means no more duplication of parameters between BEGIN_TILE_LOOP and END_TILE_LOOP
rubidium <rubidium@openttd.org>
parents: 12528
diff changeset
1149 }
10626
3189a053f43a (svn r14919) -Feature: distant joining of stations (Frostregen and PhilSophus)
rubidium <rubidium@openttd.org>
parents: 10565
diff changeset
1150
3189a053f43a (svn r14919) -Feature: distant joining of stations (Frostregen and PhilSophus)
rubidium <rubidium@openttd.org>
parents: 10565
diff changeset
1151 /* Look for deleted stations */
12522
becf2d0cf3d2 (svn r16959) -Codechange: make the station joiner a bit more aware of the difference between waypoints and stations.
rubidium <rubidium@openttd.org>
parents: 12493
diff changeset
1152 const BaseStation *st;
becf2d0cf3d2 (svn r16959) -Codechange: make the station joiner a bit more aware of the difference between waypoints and stations.
rubidium <rubidium@openttd.org>
parents: 12493
diff changeset
1153 FOR_ALL_BASE_STATIONS(st) {
12564
5add58f1ce2a (svn r17002) -Change: also support distant join for waypoints
rubidium <rubidium@openttd.org>
parents: 12529
diff changeset
1154 if (T::IsExpected(st) && !st->IsInUse() && st->owner == _local_company) {
10626
3189a053f43a (svn r14919) -Feature: distant joining of stations (Frostregen and PhilSophus)
rubidium <rubidium@openttd.org>
parents: 10565
diff changeset
1155 /* Include only within station spread (yes, it is strictly less than) */
12528
a8b8bcd7f03d (svn r16965) -Codechange: use tile area instead of sets of variables for the station joiner code.
rubidium <rubidium@openttd.org>
parents: 12522
diff changeset
1156 if (max(DistanceMax(ta.tile, st->xy), DistanceMax(TILE_ADDXY(ta.tile, ta.w - 1, ta.h - 1), st->xy)) < _settings_game.station.station_spread) {
12311
b55d6d8e8851 (svn r16728) -Fix (r14919): the Join station window didn't show all stations nearby in some cases
smatz <smatz@openttd.org>
parents: 12228
diff changeset
1157 TileAndStation *ts = _deleted_stations_nearby.Append();
b55d6d8e8851 (svn r16728) -Fix (r14919): the Join station window didn't show all stations nearby in some cases
smatz <smatz@openttd.org>
parents: 12228
diff changeset
1158 ts->tile = st->xy;
b55d6d8e8851 (svn r16728) -Fix (r14919): the Join station window didn't show all stations nearby in some cases
smatz <smatz@openttd.org>
parents: 12228
diff changeset
1159 ts->station = st->index;
10626
3189a053f43a (svn r14919) -Feature: distant joining of stations (Frostregen and PhilSophus)
rubidium <rubidium@openttd.org>
parents: 10565
diff changeset
1160
3189a053f43a (svn r14919) -Feature: distant joining of stations (Frostregen and PhilSophus)
rubidium <rubidium@openttd.org>
parents: 10565
diff changeset
1161 /* Add the station when it's within where we're going to build */
3189a053f43a (svn r14919) -Feature: distant joining of stations (Frostregen and PhilSophus)
rubidium <rubidium@openttd.org>
parents: 10565
diff changeset
1162 if (IsInsideBS(TileX(st->xy), TileX(ctx.tile), ctx.w) &&
3189a053f43a (svn r14919) -Feature: distant joining of stations (Frostregen and PhilSophus)
rubidium <rubidium@openttd.org>
parents: 10565
diff changeset
1163 IsInsideBS(TileY(st->xy), TileY(ctx.tile), ctx.h)) {
12564
5add58f1ce2a (svn r17002) -Change: also support distant join for waypoints
rubidium <rubidium@openttd.org>
parents: 12529
diff changeset
1164 AddNearbyStation<T>(st->xy, &ctx);
10626
3189a053f43a (svn r14919) -Feature: distant joining of stations (Frostregen and PhilSophus)
rubidium <rubidium@openttd.org>
parents: 10565
diff changeset
1165 }
3189a053f43a (svn r14919) -Feature: distant joining of stations (Frostregen and PhilSophus)
rubidium <rubidium@openttd.org>
parents: 10565
diff changeset
1166 }
3189a053f43a (svn r14919) -Feature: distant joining of stations (Frostregen and PhilSophus)
rubidium <rubidium@openttd.org>
parents: 10565
diff changeset
1167 }
3189a053f43a (svn r14919) -Feature: distant joining of stations (Frostregen and PhilSophus)
rubidium <rubidium@openttd.org>
parents: 10565
diff changeset
1168 }
3189a053f43a (svn r14919) -Feature: distant joining of stations (Frostregen and PhilSophus)
rubidium <rubidium@openttd.org>
parents: 10565
diff changeset
1169
3189a053f43a (svn r14919) -Feature: distant joining of stations (Frostregen and PhilSophus)
rubidium <rubidium@openttd.org>
parents: 10565
diff changeset
1170 /* Only search tiles where we have a chance to stay within the station spread.
3189a053f43a (svn r14919) -Feature: distant joining of stations (Frostregen and PhilSophus)
rubidium <rubidium@openttd.org>
parents: 10565
diff changeset
1171 * The complete check needs to be done in the callback as we don't know the
3189a053f43a (svn r14919) -Feature: distant joining of stations (Frostregen and PhilSophus)
rubidium <rubidium@openttd.org>
parents: 10565
diff changeset
1172 * extent of the found station, yet. */
12528
a8b8bcd7f03d (svn r16965) -Codechange: use tile area instead of sets of variables for the station joiner code.
rubidium <rubidium@openttd.org>
parents: 12522
diff changeset
1173 if (distant_join && min(ta.w, ta.h) >= _settings_game.station.station_spread) return NULL;
a8b8bcd7f03d (svn r16965) -Codechange: use tile area instead of sets of variables for the station joiner code.
rubidium <rubidium@openttd.org>
parents: 12522
diff changeset
1174 uint max_dist = distant_join ? _settings_game.station.station_spread - min(ta.w, ta.h) : 1;
10626
3189a053f43a (svn r14919) -Feature: distant joining of stations (Frostregen and PhilSophus)
rubidium <rubidium@openttd.org>
parents: 10565
diff changeset
1175
12528
a8b8bcd7f03d (svn r16965) -Codechange: use tile area instead of sets of variables for the station joiner code.
rubidium <rubidium@openttd.org>
parents: 12522
diff changeset
1176 TileIndex tile = TILE_ADD(ctx.tile, TileOffsByDir(DIR_N));
12564
5add58f1ce2a (svn r17002) -Change: also support distant join for waypoints
rubidium <rubidium@openttd.org>
parents: 12529
diff changeset
1177 CircularTileSearch(&tile, max_dist, ta.w, ta.h, AddNearbyStation<T>, &ctx);
10626
3189a053f43a (svn r14919) -Feature: distant joining of stations (Frostregen and PhilSophus)
rubidium <rubidium@openttd.org>
parents: 10565
diff changeset
1178
3189a053f43a (svn r14919) -Feature: distant joining of stations (Frostregen and PhilSophus)
rubidium <rubidium@openttd.org>
parents: 10565
diff changeset
1179 return NULL;
3189a053f43a (svn r14919) -Feature: distant joining of stations (Frostregen and PhilSophus)
rubidium <rubidium@openttd.org>
parents: 10565
diff changeset
1180 }
3189a053f43a (svn r14919) -Feature: distant joining of stations (Frostregen and PhilSophus)
rubidium <rubidium@openttd.org>
parents: 10565
diff changeset
1181
3189a053f43a (svn r14919) -Feature: distant joining of stations (Frostregen and PhilSophus)
rubidium <rubidium@openttd.org>
parents: 10565
diff changeset
1182 enum JoinStationWidgets {
3189a053f43a (svn r14919) -Feature: distant joining of stations (Frostregen and PhilSophus)
rubidium <rubidium@openttd.org>
parents: 10565
diff changeset
1183 JSW_WIDGET_CLOSEBOX = 0,
3189a053f43a (svn r14919) -Feature: distant joining of stations (Frostregen and PhilSophus)
rubidium <rubidium@openttd.org>
parents: 10565
diff changeset
1184 JSW_WIDGET_CAPTION,
3189a053f43a (svn r14919) -Feature: distant joining of stations (Frostregen and PhilSophus)
rubidium <rubidium@openttd.org>
parents: 10565
diff changeset
1185 JSW_PANEL,
3189a053f43a (svn r14919) -Feature: distant joining of stations (Frostregen and PhilSophus)
rubidium <rubidium@openttd.org>
parents: 10565
diff changeset
1186 JSW_SCROLLBAR,
3189a053f43a (svn r14919) -Feature: distant joining of stations (Frostregen and PhilSophus)
rubidium <rubidium@openttd.org>
parents: 10565
diff changeset
1187 JSW_RESIZEBOX,
3189a053f43a (svn r14919) -Feature: distant joining of stations (Frostregen and PhilSophus)
rubidium <rubidium@openttd.org>
parents: 10565
diff changeset
1188 };
3189a053f43a (svn r14919) -Feature: distant joining of stations (Frostregen and PhilSophus)
rubidium <rubidium@openttd.org>
parents: 10565
diff changeset
1189
3189a053f43a (svn r14919) -Feature: distant joining of stations (Frostregen and PhilSophus)
rubidium <rubidium@openttd.org>
parents: 10565
diff changeset
1190 static const Widget _select_station_widgets[] = {
11730
a39da1e4c1f5 (svn r16118) -Change/cleanup: remove the hexadecimal 'in TTD the string had this ID' from 'some' strings and replace the string name with something more sensible.
rubidium <rubidium@openttd.org>
parents: 11666
diff changeset
1191 { WWT_CLOSEBOX, RESIZE_NONE, COLOUR_DARK_GREEN, 0, 10, 0, 13, STR_BLACK_CROSS, STR_TOOLTIP_CLOSE_WINDOW},
12632
e41943276802 (svn r17075) -Codechange: rename ~750 strings to be more uniform with their relatives
rubidium <rubidium@openttd.org>
parents: 12564
diff changeset
1192 { WWT_CAPTION, RESIZE_RIGHT, COLOUR_DARK_GREEN, 11, 199, 0, 13, STR_JOIN_STATION_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS},
10626
3189a053f43a (svn r14919) -Feature: distant joining of stations (Frostregen and PhilSophus)
rubidium <rubidium@openttd.org>
parents: 10565
diff changeset
1193 { WWT_PANEL, RESIZE_RB, COLOUR_DARK_GREEN, 0, 187, 14, 79, 0x0, STR_NULL},
11819
189b05cff5cd (svn r16209) -Codechange: Removed bottom panel from join station window.
alberth <alberth@openttd.org>
parents: 11770
diff changeset
1194 { WWT_SCROLLBAR, RESIZE_LRB, COLOUR_DARK_GREEN, 188, 199, 14, 67, 0x0, STR_TOOLTIP_VSCROLL_BAR_SCROLLS_LIST},
12632
e41943276802 (svn r17075) -Codechange: rename ~750 strings to be more uniform with their relatives
rubidium <rubidium@openttd.org>
parents: 12564
diff changeset
1195 { WWT_RESIZEBOX, RESIZE_LRTB, COLOUR_DARK_GREEN, 188, 199, 68, 79, 0x0, STR_TOOLTIP_RESIZE},
10626
3189a053f43a (svn r14919) -Feature: distant joining of stations (Frostregen and PhilSophus)
rubidium <rubidium@openttd.org>
parents: 10565
diff changeset
1196 { WIDGETS_END},
3189a053f43a (svn r14919) -Feature: distant joining of stations (Frostregen and PhilSophus)
rubidium <rubidium@openttd.org>
parents: 10565
diff changeset
1197 };
3189a053f43a (svn r14919) -Feature: distant joining of stations (Frostregen and PhilSophus)
rubidium <rubidium@openttd.org>
parents: 10565
diff changeset
1198
11822
fa3b41302eda (svn r16212) -Codechange: Added nested widgets for all station_gui windows.
alberth <alberth@openttd.org>
parents: 11821
diff changeset
1199 static const NWidgetPart _nested_select_station_widgets[] = {
fa3b41302eda (svn r16212) -Codechange: Added nested widgets for all station_gui windows.
alberth <alberth@openttd.org>
parents: 11821
diff changeset
1200 NWidget(NWID_HORIZONTAL),
fa3b41302eda (svn r16212) -Codechange: Added nested widgets for all station_gui windows.
alberth <alberth@openttd.org>
parents: 11821
diff changeset
1201 NWidget(WWT_CLOSEBOX, COLOUR_DARK_GREEN, JSW_WIDGET_CLOSEBOX),
12632
e41943276802 (svn r17075) -Codechange: rename ~750 strings to be more uniform with their relatives
rubidium <rubidium@openttd.org>
parents: 12564
diff changeset
1202 NWidget(WWT_CAPTION, COLOUR_DARK_GREEN, JSW_WIDGET_CAPTION), SetDataTip(STR_JOIN_STATION_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
11822
fa3b41302eda (svn r16212) -Codechange: Added nested widgets for all station_gui windows.
alberth <alberth@openttd.org>
parents: 11821
diff changeset
1203 EndContainer(),
fa3b41302eda (svn r16212) -Codechange: Added nested widgets for all station_gui windows.
alberth <alberth@openttd.org>
parents: 11821
diff changeset
1204 NWidget(NWID_HORIZONTAL),
fa3b41302eda (svn r16212) -Codechange: Added nested widgets for all station_gui windows.
alberth <alberth@openttd.org>
parents: 11821
diff changeset
1205 NWidget(WWT_PANEL, COLOUR_DARK_GREEN, JSW_PANEL), SetMinimalSize(188, 66), SetResize(1, 10), EndContainer(),
fa3b41302eda (svn r16212) -Codechange: Added nested widgets for all station_gui windows.
alberth <alberth@openttd.org>
parents: 11821
diff changeset
1206 NWidget(NWID_VERTICAL),
fa3b41302eda (svn r16212) -Codechange: Added nested widgets for all station_gui windows.
alberth <alberth@openttd.org>
parents: 11821
diff changeset
1207 NWidget(WWT_SCROLLBAR, COLOUR_DARK_GREEN, JSW_SCROLLBAR),
fa3b41302eda (svn r16212) -Codechange: Added nested widgets for all station_gui windows.
alberth <alberth@openttd.org>
parents: 11821
diff changeset
1208 NWidget(WWT_RESIZEBOX, COLOUR_DARK_GREEN, JSW_RESIZEBOX),
fa3b41302eda (svn r16212) -Codechange: Added nested widgets for all station_gui windows.
alberth <alberth@openttd.org>
parents: 11821
diff changeset
1209 EndContainer(),
fa3b41302eda (svn r16212) -Codechange: Added nested widgets for all station_gui windows.
alberth <alberth@openttd.org>
parents: 11821
diff changeset
1210 EndContainer(),
fa3b41302eda (svn r16212) -Codechange: Added nested widgets for all station_gui windows.
alberth <alberth@openttd.org>
parents: 11821
diff changeset
1211 };
fa3b41302eda (svn r16212) -Codechange: Added nested widgets for all station_gui windows.
alberth <alberth@openttd.org>
parents: 11821
diff changeset
1212
12564
5add58f1ce2a (svn r17002) -Change: also support distant join for waypoints
rubidium <rubidium@openttd.org>
parents: 12529
diff changeset
1213 /**
5add58f1ce2a (svn r17002) -Change: also support distant join for waypoints
rubidium <rubidium@openttd.org>
parents: 12529
diff changeset
1214 * Window for selecting stations/waypoints to (distant) join to.
5add58f1ce2a (svn r17002) -Change: also support distant join for waypoints
rubidium <rubidium@openttd.org>
parents: 12529
diff changeset
1215 * @tparam T The type of station to join with
5add58f1ce2a (svn r17002) -Change: also support distant join for waypoints
rubidium <rubidium@openttd.org>
parents: 12529
diff changeset
1216 */
5add58f1ce2a (svn r17002) -Change: also support distant join for waypoints
rubidium <rubidium@openttd.org>
parents: 12529
diff changeset
1217 template <class T>
10626
3189a053f43a (svn r14919) -Feature: distant joining of stations (Frostregen and PhilSophus)
rubidium <rubidium@openttd.org>
parents: 10565
diff changeset
1218 struct SelectStationWindow : Window {
3189a053f43a (svn r14919) -Feature: distant joining of stations (Frostregen and PhilSophus)
rubidium <rubidium@openttd.org>
parents: 10565
diff changeset
1219 CommandContainer select_station_cmd; ///< Command to build new station
12528
a8b8bcd7f03d (svn r16965) -Codechange: use tile area instead of sets of variables for the station joiner code.
rubidium <rubidium@openttd.org>
parents: 12522
diff changeset
1220 TileArea area; ///< Location of new station
10626
3189a053f43a (svn r14919) -Feature: distant joining of stations (Frostregen and PhilSophus)
rubidium <rubidium@openttd.org>
parents: 10565
diff changeset
1221
12528
a8b8bcd7f03d (svn r16965) -Codechange: use tile area instead of sets of variables for the station joiner code.
rubidium <rubidium@openttd.org>
parents: 12522
diff changeset
1222 SelectStationWindow(const WindowDesc *desc, CommandContainer cmd, TileArea ta) :
10626
3189a053f43a (svn r14919) -Feature: distant joining of stations (Frostregen and PhilSophus)
rubidium <rubidium@openttd.org>
parents: 10565
diff changeset
1223 Window(desc, 0),
3189a053f43a (svn r14919) -Feature: distant joining of stations (Frostregen and PhilSophus)
rubidium <rubidium@openttd.org>
parents: 10565
diff changeset
1224 select_station_cmd(cmd),
12528
a8b8bcd7f03d (svn r16965) -Codechange: use tile area instead of sets of variables for the station joiner code.
rubidium <rubidium@openttd.org>
parents: 12522
diff changeset
1225 area(ta)
10626
3189a053f43a (svn r14919) -Feature: distant joining of stations (Frostregen and PhilSophus)
rubidium <rubidium@openttd.org>
parents: 10565
diff changeset
1226 {
12881
06daf47f0ab2 (svn r17373) -Codechange: make the timetable, station and subsidy GUIs use scrollbar wrappers
rubidium <rubidium@openttd.org>
parents: 12804
diff changeset
1227 this->vscroll.SetCapacity(6);
10626
3189a053f43a (svn r14919) -Feature: distant joining of stations (Frostregen and PhilSophus)
rubidium <rubidium@openttd.org>
parents: 10565
diff changeset
1228 this->resize.step_height = 10;
3189a053f43a (svn r14919) -Feature: distant joining of stations (Frostregen and PhilSophus)
rubidium <rubidium@openttd.org>
parents: 10565
diff changeset
1229
12564
5add58f1ce2a (svn r17002) -Change: also support distant join for waypoints
rubidium <rubidium@openttd.org>
parents: 12529
diff changeset
1230 FindStationsNearby<T>(this->area, true);
10626
3189a053f43a (svn r14919) -Feature: distant joining of stations (Frostregen and PhilSophus)
rubidium <rubidium@openttd.org>
parents: 10565
diff changeset
1231
12632
e41943276802 (svn r17075) -Codechange: rename ~750 strings to be more uniform with their relatives
rubidium <rubidium@openttd.org>
parents: 12564
diff changeset
1232 this->widget[JSW_WIDGET_CAPTION].data = T::EXPECTED_FACIL == FACIL_WAYPOINT ? STR_JOIN_WAYPOINT_CAPTION : STR_JOIN_STATION_CAPTION;
10626
3189a053f43a (svn r14919) -Feature: distant joining of stations (Frostregen and PhilSophus)
rubidium <rubidium@openttd.org>
parents: 10565
diff changeset
1233 this->FindWindowPlacementAndResize(desc);
3189a053f43a (svn r14919) -Feature: distant joining of stations (Frostregen and PhilSophus)
rubidium <rubidium@openttd.org>
parents: 10565
diff changeset
1234 }
3189a053f43a (svn r14919) -Feature: distant joining of stations (Frostregen and PhilSophus)
rubidium <rubidium@openttd.org>
parents: 10565
diff changeset
1235
3189a053f43a (svn r14919) -Feature: distant joining of stations (Frostregen and PhilSophus)
rubidium <rubidium@openttd.org>
parents: 10565
diff changeset
1236 virtual void OnPaint()
3189a053f43a (svn r14919) -Feature: distant joining of stations (Frostregen and PhilSophus)
rubidium <rubidium@openttd.org>
parents: 10565
diff changeset
1237 {
12881
06daf47f0ab2 (svn r17373) -Codechange: make the timetable, station and subsidy GUIs use scrollbar wrappers
rubidium <rubidium@openttd.org>
parents: 12804
diff changeset
1238 this->vscroll.SetCount(_stations_nearby_list.Length() + 1);
10626
3189a053f43a (svn r14919) -Feature: distant joining of stations (Frostregen and PhilSophus)
rubidium <rubidium@openttd.org>
parents: 10565
diff changeset
1239
3189a053f43a (svn r14919) -Feature: distant joining of stations (Frostregen and PhilSophus)
rubidium <rubidium@openttd.org>
parents: 10565
diff changeset
1240 this->DrawWidgets();
3189a053f43a (svn r14919) -Feature: distant joining of stations (Frostregen and PhilSophus)
rubidium <rubidium@openttd.org>
parents: 10565
diff changeset
1241
3189a053f43a (svn r14919) -Feature: distant joining of stations (Frostregen and PhilSophus)
rubidium <rubidium@openttd.org>
parents: 10565
diff changeset
1242 uint y = 17;
12881
06daf47f0ab2 (svn r17373) -Codechange: make the timetable, station and subsidy GUIs use scrollbar wrappers
rubidium <rubidium@openttd.org>
parents: 12804
diff changeset
1243 if (this->vscroll.GetPosition() == 0) {
12632
e41943276802 (svn r17075) -Codechange: rename ~750 strings to be more uniform with their relatives
rubidium <rubidium@openttd.org>
parents: 12564
diff changeset
1244 DrawString(3, this->widget[JSW_PANEL].right - 2, y, T::EXPECTED_FACIL == FACIL_WAYPOINT ? STR_JOIN_WAYPOINT_CREATE_SPLITTED_WAYPOINT : STR_JOIN_STATION_CREATE_SPLITTED_STATION);
10626
3189a053f43a (svn r14919) -Feature: distant joining of stations (Frostregen and PhilSophus)
rubidium <rubidium@openttd.org>
parents: 10565
diff changeset
1245 y += 10;
3189a053f43a (svn r14919) -Feature: distant joining of stations (Frostregen and PhilSophus)
rubidium <rubidium@openttd.org>
parents: 10565
diff changeset
1246 }
3189a053f43a (svn r14919) -Feature: distant joining of stations (Frostregen and PhilSophus)
rubidium <rubidium@openttd.org>
parents: 10565
diff changeset
1247
12881
06daf47f0ab2 (svn r17373) -Codechange: make the timetable, station and subsidy GUIs use scrollbar wrappers
rubidium <rubidium@openttd.org>
parents: 12804
diff changeset
1248 for (uint i = max<uint>(1, this->vscroll.GetPosition()); i <= _stations_nearby_list.Length(); ++i, y += 10) {
10626
3189a053f43a (svn r14919) -Feature: distant joining of stations (Frostregen and PhilSophus)
rubidium <rubidium@openttd.org>
parents: 10565
diff changeset
1249 /* Don't draw anything if it extends past the end of the window. */
12881
06daf47f0ab2 (svn r17373) -Codechange: make the timetable, station and subsidy GUIs use scrollbar wrappers
rubidium <rubidium@openttd.org>
parents: 12804
diff changeset
1250 if (i - this->vscroll.GetPosition() >= this->vscroll.GetCapacity()) break;
10626
3189a053f43a (svn r14919) -Feature: distant joining of stations (Frostregen and PhilSophus)
rubidium <rubidium@openttd.org>
parents: 10565
diff changeset
1251
12564
5add58f1ce2a (svn r17002) -Change: also support distant join for waypoints
rubidium <rubidium@openttd.org>
parents: 12529
diff changeset
1252 const T *st = T::Get(_stations_nearby_list[i - 1]);
10626
3189a053f43a (svn r14919) -Feature: distant joining of stations (Frostregen and PhilSophus)
rubidium <rubidium@openttd.org>
parents: 10565
diff changeset
1253 SetDParam(0, st->index);
3189a053f43a (svn r14919) -Feature: distant joining of stations (Frostregen and PhilSophus)
rubidium <rubidium@openttd.org>
parents: 10565
diff changeset
1254 SetDParam(1, st->facilities);
12564
5add58f1ce2a (svn r17002) -Change: also support distant join for waypoints
rubidium <rubidium@openttd.org>
parents: 12529
diff changeset
1255 DrawString(3, this->widget[JSW_PANEL].right - 2, y, T::EXPECTED_FACIL == FACIL_WAYPOINT ? STR_STATION_LIST_WAYPOINT : STR_STATION_LIST_STATION);
10626
3189a053f43a (svn r14919) -Feature: distant joining of stations (Frostregen and PhilSophus)
rubidium <rubidium@openttd.org>
parents: 10565
diff changeset
1256 }
3189a053f43a (svn r14919) -Feature: distant joining of stations (Frostregen and PhilSophus)
rubidium <rubidium@openttd.org>
parents: 10565
diff changeset
1257 }
3189a053f43a (svn r14919) -Feature: distant joining of stations (Frostregen and PhilSophus)
rubidium <rubidium@openttd.org>
parents: 10565
diff changeset
1258
3189a053f43a (svn r14919) -Feature: distant joining of stations (Frostregen and PhilSophus)
rubidium <rubidium@openttd.org>
parents: 10565
diff changeset
1259 virtual void OnClick(Point pt, int widget)
3189a053f43a (svn r14919) -Feature: distant joining of stations (Frostregen and PhilSophus)
rubidium <rubidium@openttd.org>
parents: 10565
diff changeset
1260 {
3189a053f43a (svn r14919) -Feature: distant joining of stations (Frostregen and PhilSophus)
rubidium <rubidium@openttd.org>
parents: 10565
diff changeset
1261 if (widget != JSW_PANEL) return;
3189a053f43a (svn r14919) -Feature: distant joining of stations (Frostregen and PhilSophus)
rubidium <rubidium@openttd.org>
parents: 10565
diff changeset
1262
12881
06daf47f0ab2 (svn r17373) -Codechange: make the timetable, station and subsidy GUIs use scrollbar wrappers
rubidium <rubidium@openttd.org>
parents: 12804
diff changeset
1263 uint32 st_index = (pt.y - 16) / 10 + this->vscroll.GetPosition();
10626
3189a053f43a (svn r14919) -Feature: distant joining of stations (Frostregen and PhilSophus)
rubidium <rubidium@openttd.org>
parents: 10565
diff changeset
1264 bool distant_join = (st_index > 0);
3189a053f43a (svn r14919) -Feature: distant joining of stations (Frostregen and PhilSophus)
rubidium <rubidium@openttd.org>
parents: 10565
diff changeset
1265 if (distant_join) st_index--;
3189a053f43a (svn r14919) -Feature: distant joining of stations (Frostregen and PhilSophus)
rubidium <rubidium@openttd.org>
parents: 10565
diff changeset
1266
3189a053f43a (svn r14919) -Feature: distant joining of stations (Frostregen and PhilSophus)
rubidium <rubidium@openttd.org>
parents: 10565
diff changeset
1267 if (distant_join && st_index >= _stations_nearby_list.Length()) return;
3189a053f43a (svn r14919) -Feature: distant joining of stations (Frostregen and PhilSophus)
rubidium <rubidium@openttd.org>
parents: 10565
diff changeset
1268
3189a053f43a (svn r14919) -Feature: distant joining of stations (Frostregen and PhilSophus)
rubidium <rubidium@openttd.org>
parents: 10565
diff changeset
1269 /* Insert station to be joined into stored command */
3189a053f43a (svn r14919) -Feature: distant joining of stations (Frostregen and PhilSophus)
rubidium <rubidium@openttd.org>
parents: 10565
diff changeset
1270 SB(this->select_station_cmd.p2, 16, 16,
11645
9e4f1f8c74ac (svn r16025) -Fix [FS#2818]: "build separate station" in the station picker would reuse deleted stations.
rubidium <rubidium@openttd.org>
parents: 11524
diff changeset
1271 (distant_join ? _stations_nearby_list[st_index] : NEW_STATION));
10626
3189a053f43a (svn r14919) -Feature: distant joining of stations (Frostregen and PhilSophus)
rubidium <rubidium@openttd.org>
parents: 10565
diff changeset
1272
3189a053f43a (svn r14919) -Feature: distant joining of stations (Frostregen and PhilSophus)
rubidium <rubidium@openttd.org>
parents: 10565
diff changeset
1273 /* Execute stored Command */
3189a053f43a (svn r14919) -Feature: distant joining of stations (Frostregen and PhilSophus)
rubidium <rubidium@openttd.org>
parents: 10565
diff changeset
1274 DoCommandP(&this->select_station_cmd);
3189a053f43a (svn r14919) -Feature: distant joining of stations (Frostregen and PhilSophus)
rubidium <rubidium@openttd.org>
parents: 10565
diff changeset
1275
3189a053f43a (svn r14919) -Feature: distant joining of stations (Frostregen and PhilSophus)
rubidium <rubidium@openttd.org>
parents: 10565
diff changeset
1276 /* Close Window; this might cause double frees! */
3189a053f43a (svn r14919) -Feature: distant joining of stations (Frostregen and PhilSophus)
rubidium <rubidium@openttd.org>
parents: 10565
diff changeset
1277 DeleteWindowById(WC_SELECT_STATION, 0);
3189a053f43a (svn r14919) -Feature: distant joining of stations (Frostregen and PhilSophus)
rubidium <rubidium@openttd.org>
parents: 10565
diff changeset
1278 }
3189a053f43a (svn r14919) -Feature: distant joining of stations (Frostregen and PhilSophus)
rubidium <rubidium@openttd.org>
parents: 10565
diff changeset
1279
3189a053f43a (svn r14919) -Feature: distant joining of stations (Frostregen and PhilSophus)
rubidium <rubidium@openttd.org>
parents: 10565
diff changeset
1280 virtual void OnTick()
3189a053f43a (svn r14919) -Feature: distant joining of stations (Frostregen and PhilSophus)
rubidium <rubidium@openttd.org>
parents: 10565
diff changeset
1281 {
3189a053f43a (svn r14919) -Feature: distant joining of stations (Frostregen and PhilSophus)
rubidium <rubidium@openttd.org>
parents: 10565
diff changeset
1282 if (_thd.dirty & 2) {
3189a053f43a (svn r14919) -Feature: distant joining of stations (Frostregen and PhilSophus)
rubidium <rubidium@openttd.org>
parents: 10565
diff changeset
1283 _thd.dirty &= ~2;
3189a053f43a (svn r14919) -Feature: distant joining of stations (Frostregen and PhilSophus)
rubidium <rubidium@openttd.org>
parents: 10565
diff changeset
1284 this->SetDirty();
3189a053f43a (svn r14919) -Feature: distant joining of stations (Frostregen and PhilSophus)
rubidium <rubidium@openttd.org>
parents: 10565
diff changeset
1285 }
3189a053f43a (svn r14919) -Feature: distant joining of stations (Frostregen and PhilSophus)
rubidium <rubidium@openttd.org>
parents: 10565
diff changeset
1286 }
3189a053f43a (svn r14919) -Feature: distant joining of stations (Frostregen and PhilSophus)
rubidium <rubidium@openttd.org>
parents: 10565
diff changeset
1287
11524
420a4f0b4e0b (svn r15885) -Codechange: Removed new_size parameter of Window::OnResize() callback
alberth <alberth@openttd.org>
parents: 11476
diff changeset
1288 virtual void OnResize(Point delta)
10626
3189a053f43a (svn r14919) -Feature: distant joining of stations (Frostregen and PhilSophus)
rubidium <rubidium@openttd.org>
parents: 10565
diff changeset
1289 {
12881
06daf47f0ab2 (svn r17373) -Codechange: make the timetable, station and subsidy GUIs use scrollbar wrappers
rubidium <rubidium@openttd.org>
parents: 12804
diff changeset
1290 this->vscroll.UpdateCapacity((this->widget[JSW_PANEL].bottom - this->widget[JSW_PANEL].top) / 10);
10626
3189a053f43a (svn r14919) -Feature: distant joining of stations (Frostregen and PhilSophus)
rubidium <rubidium@openttd.org>
parents: 10565
diff changeset
1291 }
3189a053f43a (svn r14919) -Feature: distant joining of stations (Frostregen and PhilSophus)
rubidium <rubidium@openttd.org>
parents: 10565
diff changeset
1292
3189a053f43a (svn r14919) -Feature: distant joining of stations (Frostregen and PhilSophus)
rubidium <rubidium@openttd.org>
parents: 10565
diff changeset
1293 virtual void OnInvalidateData(int data)
3189a053f43a (svn r14919) -Feature: distant joining of stations (Frostregen and PhilSophus)
rubidium <rubidium@openttd.org>
parents: 10565
diff changeset
1294 {
12564
5add58f1ce2a (svn r17002) -Change: also support distant join for waypoints
rubidium <rubidium@openttd.org>
parents: 12529
diff changeset
1295 FindStationsNearby<T>(this->area, true);
10626
3189a053f43a (svn r14919) -Feature: distant joining of stations (Frostregen and PhilSophus)
rubidium <rubidium@openttd.org>
parents: 10565
diff changeset
1296 this->SetDirty();
3189a053f43a (svn r14919) -Feature: distant joining of stations (Frostregen and PhilSophus)
rubidium <rubidium@openttd.org>
parents: 10565
diff changeset
1297 }
3189a053f43a (svn r14919) -Feature: distant joining of stations (Frostregen and PhilSophus)
rubidium <rubidium@openttd.org>
parents: 10565
diff changeset
1298 };
3189a053f43a (svn r14919) -Feature: distant joining of stations (Frostregen and PhilSophus)
rubidium <rubidium@openttd.org>
parents: 10565
diff changeset
1299
11373
474ba6cc0946 (svn r15723) -Codechange: use a constructor for WindowDescs as that makes expanding them much easier (Alberth)
rubidium <rubidium@openttd.org>
parents: 11361
diff changeset
1300 static const WindowDesc _select_station_desc(
11819
189b05cff5cd (svn r16209) -Codechange: Removed bottom panel from join station window.
alberth <alberth@openttd.org>
parents: 11770
diff changeset
1301 WDP_AUTO, WDP_AUTO, 200, 80, 200, 180,
10626
3189a053f43a (svn r14919) -Feature: distant joining of stations (Frostregen and PhilSophus)
rubidium <rubidium@openttd.org>
parents: 10565
diff changeset
1302 WC_SELECT_STATION, WC_NONE,
10998
a1d256bf72e0 (svn r15338) -Fix [FS#2598]: close all construction related windows whenever changing company.
rubidium <rubidium@openttd.org>
parents: 10996
diff changeset
1303 WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_RESIZABLE | WDF_CONSTRUCTION,
11822
fa3b41302eda (svn r16212) -Codechange: Added nested widgets for all station_gui windows.
alberth <alberth@openttd.org>
parents: 11821
diff changeset
1304 _select_station_widgets, _nested_select_station_widgets, lengthof(_nested_select_station_widgets)
11373
474ba6cc0946 (svn r15723) -Codechange: use a constructor for WindowDescs as that makes expanding them much easier (Alberth)
rubidium <rubidium@openttd.org>
parents: 11361
diff changeset
1305 );
10626
3189a053f43a (svn r14919) -Feature: distant joining of stations (Frostregen and PhilSophus)
rubidium <rubidium@openttd.org>
parents: 10565
diff changeset
1306
3189a053f43a (svn r14919) -Feature: distant joining of stations (Frostregen and PhilSophus)
rubidium <rubidium@openttd.org>
parents: 10565
diff changeset
1307
3189a053f43a (svn r14919) -Feature: distant joining of stations (Frostregen and PhilSophus)
rubidium <rubidium@openttd.org>
parents: 10565
diff changeset
1308 /**
3189a053f43a (svn r14919) -Feature: distant joining of stations (Frostregen and PhilSophus)
rubidium <rubidium@openttd.org>
parents: 10565
diff changeset
1309 * Check whether we need to show the station selection window.
3189a053f43a (svn r14919) -Feature: distant joining of stations (Frostregen and PhilSophus)
rubidium <rubidium@openttd.org>
parents: 10565
diff changeset
1310 * @param cmd Command to build the station.
3189a053f43a (svn r14919) -Feature: distant joining of stations (Frostregen and PhilSophus)
rubidium <rubidium@openttd.org>
parents: 10565
diff changeset
1311 * @param w Width of the to-be-built station
3189a053f43a (svn r14919) -Feature: distant joining of stations (Frostregen and PhilSophus)
rubidium <rubidium@openttd.org>
parents: 10565
diff changeset
1312 * @param h Height of the to-be-built station
12564
5add58f1ce2a (svn r17002) -Change: also support distant join for waypoints
rubidium <rubidium@openttd.org>
parents: 12529
diff changeset
1313 * @tparam T the type of station
10626
3189a053f43a (svn r14919) -Feature: distant joining of stations (Frostregen and PhilSophus)
rubidium <rubidium@openttd.org>
parents: 10565
diff changeset
1314 * @return whether we need to show the station selection window.
3189a053f43a (svn r14919) -Feature: distant joining of stations (Frostregen and PhilSophus)
rubidium <rubidium@openttd.org>
parents: 10565
diff changeset
1315 */
12564
5add58f1ce2a (svn r17002) -Change: also support distant join for waypoints
rubidium <rubidium@openttd.org>
parents: 12529
diff changeset
1316 template <class T>
12528
a8b8bcd7f03d (svn r16965) -Codechange: use tile area instead of sets of variables for the station joiner code.
rubidium <rubidium@openttd.org>
parents: 12522
diff changeset
1317 static bool StationJoinerNeeded(CommandContainer cmd, TileArea ta)
10626
3189a053f43a (svn r14919) -Feature: distant joining of stations (Frostregen and PhilSophus)
rubidium <rubidium@openttd.org>
parents: 10565
diff changeset
1318 {
3189a053f43a (svn r14919) -Feature: distant joining of stations (Frostregen and PhilSophus)
rubidium <rubidium@openttd.org>
parents: 10565
diff changeset
1319 /* Only show selection if distant join is enabled in the settings */
3189a053f43a (svn r14919) -Feature: distant joining of stations (Frostregen and PhilSophus)
rubidium <rubidium@openttd.org>
parents: 10565
diff changeset
1320 if (!_settings_game.station.distant_join_stations) return false;
3189a053f43a (svn r14919) -Feature: distant joining of stations (Frostregen and PhilSophus)
rubidium <rubidium@openttd.org>
parents: 10565
diff changeset
1321
10732
cb1b114429c8 (svn r15065) -Change (r14919): Allow to select a new station location by ctrl-clicking while distant-join window is open. (PhilSophus)
frosch <frosch@openttd.org>
parents: 10693
diff changeset
1322 /* If a window is already opened and we didn't ctrl-click,
cb1b114429c8 (svn r15065) -Change (r14919): Allow to select a new station location by ctrl-clicking while distant-join window is open. (PhilSophus)
frosch <frosch@openttd.org>
parents: 10693
diff changeset
1323 * return true (i.e. just flash the old window) */
cb1b114429c8 (svn r15065) -Change (r14919): Allow to select a new station location by ctrl-clicking while distant-join window is open. (PhilSophus)
frosch <frosch@openttd.org>
parents: 10693
diff changeset
1324 Window *selection_window = FindWindowById(WC_SELECT_STATION, 0);
cb1b114429c8 (svn r15065) -Change (r14919): Allow to select a new station location by ctrl-clicking while distant-join window is open. (PhilSophus)
frosch <frosch@openttd.org>
parents: 10693
diff changeset
1325 if (selection_window != NULL) {
cb1b114429c8 (svn r15065) -Change (r14919): Allow to select a new station location by ctrl-clicking while distant-join window is open. (PhilSophus)
frosch <frosch@openttd.org>
parents: 10693
diff changeset
1326 if (!_ctrl_pressed) return true;
cb1b114429c8 (svn r15065) -Change (r14919): Allow to select a new station location by ctrl-clicking while distant-join window is open. (PhilSophus)
frosch <frosch@openttd.org>
parents: 10693
diff changeset
1327
cb1b114429c8 (svn r15065) -Change (r14919): Allow to select a new station location by ctrl-clicking while distant-join window is open. (PhilSophus)
frosch <frosch@openttd.org>
parents: 10693
diff changeset
1328 /* Abort current distant-join and start new one */
cb1b114429c8 (svn r15065) -Change (r14919): Allow to select a new station location by ctrl-clicking while distant-join window is open. (PhilSophus)
frosch <frosch@openttd.org>
parents: 10693
diff changeset
1329 delete selection_window;
cb1b114429c8 (svn r15065) -Change (r14919): Allow to select a new station location by ctrl-clicking while distant-join window is open. (PhilSophus)
frosch <frosch@openttd.org>
parents: 10693
diff changeset
1330 UpdateTileSelection();
cb1b114429c8 (svn r15065) -Change (r14919): Allow to select a new station location by ctrl-clicking while distant-join window is open. (PhilSophus)
frosch <frosch@openttd.org>
parents: 10693
diff changeset
1331 }
10626
3189a053f43a (svn r14919) -Feature: distant joining of stations (Frostregen and PhilSophus)
rubidium <rubidium@openttd.org>
parents: 10565
diff changeset
1332
3189a053f43a (svn r14919) -Feature: distant joining of stations (Frostregen and PhilSophus)
rubidium <rubidium@openttd.org>
parents: 10565
diff changeset
1333 /* only show the popup, if we press ctrl */
3189a053f43a (svn r14919) -Feature: distant joining of stations (Frostregen and PhilSophus)
rubidium <rubidium@openttd.org>
parents: 10565
diff changeset
1334 if (!_ctrl_pressed) return false;
3189a053f43a (svn r14919) -Feature: distant joining of stations (Frostregen and PhilSophus)
rubidium <rubidium@openttd.org>
parents: 10565
diff changeset
1335
10732
cb1b114429c8 (svn r15065) -Change (r14919): Allow to select a new station location by ctrl-clicking while distant-join window is open. (PhilSophus)
frosch <frosch@openttd.org>
parents: 10693
diff changeset
1336 /* Now check if we could build there */
cb1b114429c8 (svn r15065) -Change (r14919): Allow to select a new station location by ctrl-clicking while distant-join window is open. (PhilSophus)
frosch <frosch@openttd.org>
parents: 10693
diff changeset
1337 if (CmdFailed(DoCommand(&cmd, CommandFlagsToDCFlags(GetCommandFlags(cmd.cmd))))) return false;
cb1b114429c8 (svn r15065) -Change (r14919): Allow to select a new station location by ctrl-clicking while distant-join window is open. (PhilSophus)
frosch <frosch@openttd.org>
parents: 10693
diff changeset
1338
10736
6f72f80df252 (svn r15069) -Change (r14919): Make distant-join less intelligent but more transparent to the user by always showing the selection window, even if there is only one option to choose from. (PhilSophus)
frosch <frosch@openttd.org>
parents: 10732
diff changeset
1339 /* Test for adjacent station or station below selection.
6f72f80df252 (svn r15069) -Change (r14919): Make distant-join less intelligent but more transparent to the user by always showing the selection window, even if there is only one option to choose from. (PhilSophus)
frosch <frosch@openttd.org>
parents: 10732
diff changeset
1340 * If adjacent-stations is disabled and we are building next to a station, do not show the selection window.
6f72f80df252 (svn r15069) -Change (r14919): Make distant-join less intelligent but more transparent to the user by always showing the selection window, even if there is only one option to choose from. (PhilSophus)
frosch <frosch@openttd.org>
parents: 10732
diff changeset
1341 * but join the other station immediatelly. */
12564
5add58f1ce2a (svn r17002) -Change: also support distant join for waypoints
rubidium <rubidium@openttd.org>
parents: 12529
diff changeset
1342 const T *st = FindStationsNearby<T>(ta, false);
10736
6f72f80df252 (svn r15069) -Change (r14919): Make distant-join less intelligent but more transparent to the user by always showing the selection window, even if there is only one option to choose from. (PhilSophus)
frosch <frosch@openttd.org>
parents: 10732
diff changeset
1343 return st == NULL && (_settings_game.station.adjacent_stations || _stations_nearby_list.Length() == 0);
10626
3189a053f43a (svn r14919) -Feature: distant joining of stations (Frostregen and PhilSophus)
rubidium <rubidium@openttd.org>
parents: 10565
diff changeset
1344 }
3189a053f43a (svn r14919) -Feature: distant joining of stations (Frostregen and PhilSophus)
rubidium <rubidium@openttd.org>
parents: 10565
diff changeset
1345
3189a053f43a (svn r14919) -Feature: distant joining of stations (Frostregen and PhilSophus)
rubidium <rubidium@openttd.org>
parents: 10565
diff changeset
1346 /**
3189a053f43a (svn r14919) -Feature: distant joining of stations (Frostregen and PhilSophus)
rubidium <rubidium@openttd.org>
parents: 10565
diff changeset
1347 * Show the station selection window when needed. If not, build the station.
3189a053f43a (svn r14919) -Feature: distant joining of stations (Frostregen and PhilSophus)
rubidium <rubidium@openttd.org>
parents: 10565
diff changeset
1348 * @param cmd Command to build the station.
12564
5add58f1ce2a (svn r17002) -Change: also support distant join for waypoints
rubidium <rubidium@openttd.org>
parents: 12529
diff changeset
1349 * @param ta Area to build the station in
5add58f1ce2a (svn r17002) -Change: also support distant join for waypoints
rubidium <rubidium@openttd.org>
parents: 12529
diff changeset
1350 * @tparam the class to find stations for
10626
3189a053f43a (svn r14919) -Feature: distant joining of stations (Frostregen and PhilSophus)
rubidium <rubidium@openttd.org>
parents: 10565
diff changeset
1351 */
12564
5add58f1ce2a (svn r17002) -Change: also support distant join for waypoints
rubidium <rubidium@openttd.org>
parents: 12529
diff changeset
1352 template <class T>
5add58f1ce2a (svn r17002) -Change: also support distant join for waypoints
rubidium <rubidium@openttd.org>
parents: 12529
diff changeset
1353 void ShowSelectBaseStationIfNeeded(CommandContainer cmd, TileArea ta)
10626
3189a053f43a (svn r14919) -Feature: distant joining of stations (Frostregen and PhilSophus)
rubidium <rubidium@openttd.org>
parents: 10565
diff changeset
1354 {
12564
5add58f1ce2a (svn r17002) -Change: also support distant join for waypoints
rubidium <rubidium@openttd.org>
parents: 12529
diff changeset
1355 if (StationJoinerNeeded<T>(cmd, ta)) {
11072
19fd43d5975d (svn r15413) -Fix [FS#2529/2533]: inconsistencies between station and bridge building w.r.t. tile selection and when the window should be closed.
rubidium <rubidium@openttd.org>
parents: 10998
diff changeset
1356 if (!_settings_client.gui.persistent_buildingtools) ResetObjectToPlace();
10626
3189a053f43a (svn r14919) -Feature: distant joining of stations (Frostregen and PhilSophus)
rubidium <rubidium@openttd.org>
parents: 10565
diff changeset
1357 if (BringWindowToFrontById(WC_SELECT_STATION, 0)) return;
12564
5add58f1ce2a (svn r17002) -Change: also support distant join for waypoints
rubidium <rubidium@openttd.org>
parents: 12529
diff changeset
1358 new SelectStationWindow<T>(&_select_station_desc, cmd, ta);
10626
3189a053f43a (svn r14919) -Feature: distant joining of stations (Frostregen and PhilSophus)
rubidium <rubidium@openttd.org>
parents: 10565
diff changeset
1359 } else {
3189a053f43a (svn r14919) -Feature: distant joining of stations (Frostregen and PhilSophus)
rubidium <rubidium@openttd.org>
parents: 10565
diff changeset
1360 DoCommandP(&cmd);
3189a053f43a (svn r14919) -Feature: distant joining of stations (Frostregen and PhilSophus)
rubidium <rubidium@openttd.org>
parents: 10565
diff changeset
1361 }
3189a053f43a (svn r14919) -Feature: distant joining of stations (Frostregen and PhilSophus)
rubidium <rubidium@openttd.org>
parents: 10565
diff changeset
1362 }
12564
5add58f1ce2a (svn r17002) -Change: also support distant join for waypoints
rubidium <rubidium@openttd.org>
parents: 12529
diff changeset
1363
5add58f1ce2a (svn r17002) -Change: also support distant join for waypoints
rubidium <rubidium@openttd.org>
parents: 12529
diff changeset
1364 /**
5add58f1ce2a (svn r17002) -Change: also support distant join for waypoints
rubidium <rubidium@openttd.org>
parents: 12529
diff changeset
1365 * Show the station selection window when needed. If not, build the station.
5add58f1ce2a (svn r17002) -Change: also support distant join for waypoints
rubidium <rubidium@openttd.org>
parents: 12529
diff changeset
1366 * @param cmd Command to build the station.
5add58f1ce2a (svn r17002) -Change: also support distant join for waypoints
rubidium <rubidium@openttd.org>
parents: 12529
diff changeset
1367 * @param ta Area to build the station in
5add58f1ce2a (svn r17002) -Change: also support distant join for waypoints
rubidium <rubidium@openttd.org>
parents: 12529
diff changeset
1368 */
5add58f1ce2a (svn r17002) -Change: also support distant join for waypoints
rubidium <rubidium@openttd.org>
parents: 12529
diff changeset
1369 void ShowSelectStationIfNeeded(CommandContainer cmd, TileArea ta)
5add58f1ce2a (svn r17002) -Change: also support distant join for waypoints
rubidium <rubidium@openttd.org>
parents: 12529
diff changeset
1370 {
5add58f1ce2a (svn r17002) -Change: also support distant join for waypoints
rubidium <rubidium@openttd.org>
parents: 12529
diff changeset
1371 ShowSelectBaseStationIfNeeded<Station>(cmd, ta);
5add58f1ce2a (svn r17002) -Change: also support distant join for waypoints
rubidium <rubidium@openttd.org>
parents: 12529
diff changeset
1372 }
5add58f1ce2a (svn r17002) -Change: also support distant join for waypoints
rubidium <rubidium@openttd.org>
parents: 12529
diff changeset
1373
5add58f1ce2a (svn r17002) -Change: also support distant join for waypoints
rubidium <rubidium@openttd.org>
parents: 12529
diff changeset
1374 /**
5add58f1ce2a (svn r17002) -Change: also support distant join for waypoints
rubidium <rubidium@openttd.org>
parents: 12529
diff changeset
1375 * Show the waypoint selection window when needed. If not, build the waypoint.
5add58f1ce2a (svn r17002) -Change: also support distant join for waypoints
rubidium <rubidium@openttd.org>
parents: 12529
diff changeset
1376 * @param cmd Command to build the waypoint.
5add58f1ce2a (svn r17002) -Change: also support distant join for waypoints
rubidium <rubidium@openttd.org>
parents: 12529
diff changeset
1377 * @param ta Area to build the waypoint in
5add58f1ce2a (svn r17002) -Change: also support distant join for waypoints
rubidium <rubidium@openttd.org>
parents: 12529
diff changeset
1378 */
5add58f1ce2a (svn r17002) -Change: also support distant join for waypoints
rubidium <rubidium@openttd.org>
parents: 12529
diff changeset
1379 void ShowSelectWaypointIfNeeded(CommandContainer cmd, TileArea ta)
5add58f1ce2a (svn r17002) -Change: also support distant join for waypoints
rubidium <rubidium@openttd.org>
parents: 12529
diff changeset
1380 {
5add58f1ce2a (svn r17002) -Change: also support distant join for waypoints
rubidium <rubidium@openttd.org>
parents: 12529
diff changeset
1381 ShowSelectBaseStationIfNeeded<Waypoint>(cmd, ta);
5add58f1ce2a (svn r17002) -Change: also support distant join for waypoints
rubidium <rubidium@openttd.org>
parents: 12529
diff changeset
1382 }