annotate src/station_gui.cpp @ 9317:c399bf075b2f draft

(svn r13185) -Codechange: remove everything related to the WindowProc callbacks.
author rubidium <rubidium@openttd.org>
date Mon, 19 May 2008 09:48:47 +0000
parents add307f2e6ea
children 5236ba6c7d54
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
1 /* $Id$ */
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
2
9111
d48433370037 (svn r12971) -Documentation: add @file in files that missed them and add something more than whitespace as description of files that don't have a description.
rubidium <rubidium@openttd.org>
parents: 9094
diff changeset
3 /** @file 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
4
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
5 #include "stdafx.h"
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
6 #include "openttd.h"
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
7 #include "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
8 #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
9 #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
10 #include "textbuf_gui.h"
8785
2a8950a812dc (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium <rubidium@openttd.org>
parents: 8762
diff changeset
11 #include "station_base.h"
8254
7d580c9c41fb (svn r11818) -Codechange: split player.h into smaller pieces.
rubidium <rubidium@openttd.org>
parents: 8224
diff changeset
12 #include "player_func.h"
8116
9cc845deddfe (svn r11677) -Codechange: move price and command related types/functions to their respective places.
rubidium <rubidium@openttd.org>
parents: 8114
diff changeset
13 #include "economy_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
14 #include "town.h"
8116
9cc845deddfe (svn r11677) -Codechange: move price and command related types/functions to their respective places.
rubidium <rubidium@openttd.org>
parents: 8114
diff changeset
15 #include "command_func.h"
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
16 #include "variables.h"
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
17 #include "vehicle_gui.h"
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
18 #include "cargotype.h"
8016
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
19 #include "station_gui.h"
8785
2a8950a812dc (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium <rubidium@openttd.org>
parents: 8762
diff changeset
20 #include "station_func.h"
8114
2d6af5d7a142 (svn r11675) -Codechange: split the string types from the string functions.
rubidium <rubidium@openttd.org>
parents: 8109
diff changeset
21 #include "strings_func.h"
8130
0586823afe39 (svn r11691) -Codechange: move+rename helpers.hpp and only include it when it is really needed.
rubidium <rubidium@openttd.org>
parents: 8121
diff changeset
22 #include "core/alloc_func.hpp"
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
23 #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
24 #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
25 #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
26 #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
27 #include "newgrf_cargo.h"
9164
2c75e77b160a (svn r13027) -Codechange: use StrEmpty instead of arr[0] == '\0' and remove the need for WE_ON_EDIT_TEXT_CANCEL.
rubidium <rubidium@openttd.org>
parents: 9143
diff changeset
28 #include "string_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
29
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
30 #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
31 #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
32
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
33 typedef int CDECL StationSortListingTypeFunction(const void*, const void*);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
34
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
35 static StationSortListingTypeFunction StationNameSorter;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
36 static StationSortListingTypeFunction StationTypeSorter;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
37 static StationSortListingTypeFunction StationWaitingSorter;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
38 static StationSortListingTypeFunction StationRatingMaxSorter;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
39
8268
ab53b3bf7100 (svn r11832) -Codechange: get rid of (quite) some VARDEFs.
rubidium <rubidium@openttd.org>
parents: 8264
diff changeset
40 bool _station_show_coverage;
ab53b3bf7100 (svn r11832) -Codechange: get rid of (quite) some VARDEFs.
rubidium <rubidium@openttd.org>
parents: 8264
diff changeset
41
8016
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
42 /**
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
43 * 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
44 * 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
45 * 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
46 *
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
47 * @param x coordinate to draw the box at
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
48 * @param y coordinate to draw the box at
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 type Cargo type
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
50 * @param amount Cargo amount
8016
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
51 * @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
52 *
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
53 * @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
54 * @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
55 */
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 static void StationsWndShowStationRating(int x, int y, CargoID type, uint amount, byte rating)
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
57 {
8016
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
58 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
59 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
60
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
61 const CargoSpec *cs = GetCargo(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
62 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
63
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
64 int colour = cs->rating_colour;
8016
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
65 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
66
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
67 /* Draw total cargo (limited) on station (fits into 16 pixels) */
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
68 if (w != 0) GfxFillRect(x, y, x + w - 1, 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
69
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
70 /* 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
71 * 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
72 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
73 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
74 if (rest != 0) {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
75 w += x;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
76 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
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 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
79
7824
7ae5bda4e8dd (svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas <belugas@openttd.org>
parents: 7474
diff changeset
80 DrawString(x + 1, 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
81
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
82 /* 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
83 y += 8;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
84 GfxFillRect(x + 1, y, x + 14, y, 0xB8);
8016
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
85 rating = minu(rating, rating_full) / 16;
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 if (rating != 0) GfxFillRect(x + 1, y, x + rating, y, 0xD0);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
87 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
88
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
89 const StringID _station_sort_listing[] = {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
90 STR_SORT_BY_DROPDOWN_NAME,
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
91 STR_SORT_BY_FACILITY,
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
92 STR_SORT_BY_WAITING,
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
93 STR_SORT_BY_RATING_MAX,
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
94 INVALID_STRING_ID
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
95 };
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
96
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
97 static char _bufcache[64];
8964
ae064b8e200b (svn r12756) -Cleanup: variable scope and coding style in station*
smatz <smatz@openttd.org>
parents: 8857
diff changeset
98 static const Station *_last_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
99 static int _internal_sort_order;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
100
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
101 static int CDECL StationNameSorter(const void *a, const void *b)
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
102 {
8964
ae064b8e200b (svn r12756) -Cleanup: variable scope and coding style in station*
smatz <smatz@openttd.org>
parents: 8857
diff changeset
103 const Station *st1 = *(const Station**)a;
ae064b8e200b (svn r12756) -Cleanup: variable scope and coding style in station*
smatz <smatz@openttd.org>
parents: 8857
diff changeset
104 const Station *st2 = *(const Station**)b;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
105 char buf1[64];
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
106
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
107 SetDParam(0, st1->index);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
108 GetString(buf1, STR_STATION, lastof(buf1));
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
109
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
110 if (st2 != _last_station) {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
111 _last_station = st2;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
112 SetDParam(0, st2->index);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
113 GetString(_bufcache, STR_STATION, lastof(_bufcache));
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
114 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
115
8964
ae064b8e200b (svn r12756) -Cleanup: variable scope and coding style in station*
smatz <smatz@openttd.org>
parents: 8857
diff changeset
116 int r = strcmp(buf1, _bufcache); // sort by name
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
117 return (_internal_sort_order & 1) ? -r : r;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
118 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
119
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
120 static int CDECL StationTypeSorter(const void *a, const void *b)
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
121 {
8964
ae064b8e200b (svn r12756) -Cleanup: variable scope and coding style in station*
smatz <smatz@openttd.org>
parents: 8857
diff changeset
122 const Station *st1 = *(const Station**)a;
ae064b8e200b (svn r12756) -Cleanup: variable scope and coding style in station*
smatz <smatz@openttd.org>
parents: 8857
diff changeset
123 const Station *st2 = *(const Station**)b;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
124 return (_internal_sort_order & 1) ? st2->facilities - st1->facilities : st1->facilities - st2->facilities;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
125 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
126
8964
ae064b8e200b (svn r12756) -Cleanup: variable scope and coding style in station*
smatz <smatz@openttd.org>
parents: 8857
diff changeset
127 static const uint32 _cargo_filter_max = UINT32_MAX;
7886
6551a3580d2e (svn r11437) -Change: when sorting stations by cargo sum, only sum the cargos that are selected in the filter. Patch by divide.
rubidium <rubidium@openttd.org>
parents: 7842
diff changeset
128 static uint32 _cargo_filter = _cargo_filter_max;
6551a3580d2e (svn r11437) -Change: when sorting stations by cargo sum, only sum the cargos that are selected in the filter. Patch by divide.
rubidium <rubidium@openttd.org>
parents: 7842
diff changeset
129
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
130 static int CDECL StationWaitingSorter(const void *a, const void *b)
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
131 {
8964
ae064b8e200b (svn r12756) -Cleanup: variable scope and coding style in station*
smatz <smatz@openttd.org>
parents: 8857
diff changeset
132 const Station *st1 = *(const Station**)a;
ae064b8e200b (svn r12756) -Cleanup: variable scope and coding style in station*
smatz <smatz@openttd.org>
parents: 8857
diff changeset
133 const Station *st2 = *(const Station**)b;
6990
a19700261804 (svn r10246) -Fix (r10297): some forgotten money conversions and truncation issues. Thanks to benc for providing the patch.
rubidium <rubidium@openttd.org>
parents: 6657
diff changeset
134 Money sum1 = 0, sum2 = 0;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
135
6202
eb0fdb88a922 (svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138 <peter1138@openttd.org>
parents: 6122
diff changeset
136 for (CargoID j = 0; j < NUM_CARGO; j++) {
7928
4e8dfd103163 (svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13 <skidd13@openttd.org>
parents: 7886
diff changeset
137 if (!HasBit(_cargo_filter, j)) continue;
7010
f0f87c5a431e (svn r10266) -Codechange: keep track of the origin, time of travel and accumulated feeder share (transfers) of individual pieces of cargo. This means that cargo isn't thrown on a big pile when it's put in a station or unloaded at a station, however the GUI does not reflect these changes yet so you will not actually see it.
rubidium <rubidium@openttd.org>
parents: 6990
diff changeset
138 if (!st1->goods[j].cargo.Empty()) sum1 += GetTransportedGoodsIncome(st1->goods[j].cargo.Count(), 20, 50, j);
f0f87c5a431e (svn r10266) -Codechange: keep track of the origin, time of travel and accumulated feeder share (transfers) of individual pieces of cargo. This means that cargo isn't thrown on a big pile when it's put in a station or unloaded at a station, however the GUI does not reflect these changes yet so you will not actually see it.
rubidium <rubidium@openttd.org>
parents: 6990
diff changeset
139 if (!st2->goods[j].cargo.Empty()) sum2 += GetTransportedGoodsIncome(st2->goods[j].cargo.Count(), 20, 50, j);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
140 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
141
6990
a19700261804 (svn r10246) -Fix (r10297): some forgotten money conversions and truncation issues. Thanks to benc for providing the patch.
rubidium <rubidium@openttd.org>
parents: 6657
diff changeset
142 return (_internal_sort_order & 1) ? ClampToI32(sum2 - sum1) : ClampToI32(sum1 - sum2);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
143 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
144
6253
28e00ab69663 (svn r9062) -Fix (r4822, FS#595): The station list, sorted by cargo rating, now takes stations into account that have no cargo waiting (KeeperOfTheSoul). While at it, doxygen the function
celestar <celestar@openttd.org>
parents: 6248
diff changeset
145 /**
28e00ab69663 (svn r9062) -Fix (r4822, FS#595): The station list, sorted by cargo rating, now takes stations into account that have no cargo waiting (KeeperOfTheSoul). While at it, doxygen the function
celestar <celestar@openttd.org>
parents: 6248
diff changeset
146 * qsort-compatible version of sorting two stations by maximum rating
28e00ab69663 (svn r9062) -Fix (r4822, FS#595): The station list, sorted by cargo rating, now takes stations into account that have no cargo waiting (KeeperOfTheSoul). While at it, doxygen the function
celestar <celestar@openttd.org>
parents: 6248
diff changeset
147 * @param a First object to be sorted, must be of type (const Station *)
28e00ab69663 (svn r9062) -Fix (r4822, FS#595): The station list, sorted by cargo rating, now takes stations into account that have no cargo waiting (KeeperOfTheSoul). While at it, doxygen the function
celestar <celestar@openttd.org>
parents: 6248
diff changeset
148 * @param b Second object to be sorted, must be of type (const Station *)
28e00ab69663 (svn r9062) -Fix (r4822, FS#595): The station list, sorted by cargo rating, now takes stations into account that have no cargo waiting (KeeperOfTheSoul). While at it, doxygen the function
celestar <celestar@openttd.org>
parents: 6248
diff changeset
149 * @return The sort order
28e00ab69663 (svn r9062) -Fix (r4822, FS#595): The station list, sorted by cargo rating, now takes stations into account that have no cargo waiting (KeeperOfTheSoul). While at it, doxygen the function
celestar <celestar@openttd.org>
parents: 6248
diff changeset
150 * @retval >0 a should come before b in the list
28e00ab69663 (svn r9062) -Fix (r4822, FS#595): The station list, sorted by cargo rating, now takes stations into account that have no cargo waiting (KeeperOfTheSoul). While at it, doxygen the function
celestar <celestar@openttd.org>
parents: 6248
diff changeset
151 * @retval <0 b should come before a in the list
28e00ab69663 (svn r9062) -Fix (r4822, FS#595): The station list, sorted by cargo rating, now takes stations into account that have no cargo waiting (KeeperOfTheSoul). While at it, doxygen the function
celestar <celestar@openttd.org>
parents: 6248
diff changeset
152 */
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
153 static int CDECL StationRatingMaxSorter(const void *a, const void *b)
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
154 {
8964
ae064b8e200b (svn r12756) -Cleanup: variable scope and coding style in station*
smatz <smatz@openttd.org>
parents: 8857
diff changeset
155 const Station *st1 = *(const Station**)a;
ae064b8e200b (svn r12756) -Cleanup: variable scope and coding style in station*
smatz <smatz@openttd.org>
parents: 8857
diff changeset
156 const Station *st2 = *(const Station**)b;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
157 byte maxr1 = 0;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
158 byte maxr2 = 0;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
159
6202
eb0fdb88a922 (svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138 <peter1138@openttd.org>
parents: 6122
diff changeset
160 for (CargoID j = 0; j < NUM_CARGO; j++) {
7928
4e8dfd103163 (svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13 <skidd13@openttd.org>
parents: 7886
diff changeset
161 if (HasBit(st1->goods[j].acceptance_pickup, GoodsEntry::PICKUP)) maxr1 = max(maxr1, st1->goods[j].rating);
4e8dfd103163 (svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13 <skidd13@openttd.org>
parents: 7886
diff changeset
162 if (HasBit(st2->goods[j].acceptance_pickup, GoodsEntry::PICKUP)) maxr2 = max(maxr2, st2->goods[j].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
163 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
164
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
165 return (_internal_sort_order & 1) ? maxr2 - maxr1 : maxr1 - maxr2;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
166 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
167
9191
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
168 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
169
8016
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
170 /**
9190
99b247e82bbe (svn r13053) -Codechange: station sorting used it's own implementation of GUIList and the associated enums, now it doesn't anymore.
rubidium <rubidium@openttd.org>
parents: 9185
diff changeset
171 * Rebuild station list if the VL_REBUILD flag is set
8016
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
172 *
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
173 * @param sl pointer to plstations_d (station list and flags)
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
174 * @param owner player whose stations are to be in list
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
175 * @param facilities types of stations of interest
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
176 * @param cargo_filter bitmap of cargo types to include
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
177 * @param include_empty whether we should include stations without waiting cargo
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
178 */
9191
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
179 static void BuildStationsList(GUIStationList *sl, PlayerID owner, byte facilities, uint32 cargo_filter, bool include_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
180 {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
181 uint n = 0;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
182 const Station *st;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
183
9190
99b247e82bbe (svn r13053) -Codechange: station sorting used it's own implementation of GUIList and the associated enums, now it doesn't anymore.
rubidium <rubidium@openttd.org>
parents: 9185
diff changeset
184 if (!(sl->flags & VL_REBUILD)) 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
185
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
186 /* Create array for sorting */
8964
ae064b8e200b (svn r12756) -Cleanup: variable scope and coding style in station*
smatz <smatz@openttd.org>
parents: 8857
diff changeset
187 const Station **station_sort = MallocT<const Station*>(GetMaxStationIndex() + 1);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
188
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
189 DEBUG(misc, 3, "Building station list for player %d", owner);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
190
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
191 FOR_ALL_STATIONS(st) {
8109
eaab22131e32 (svn r11670) -Feature [FS#1565]: list neutral stations where the player has service in the station list too
smatz <smatz@openttd.org>
parents: 8107
diff changeset
192 if (st->owner == owner || (st->owner == OWNER_NONE && !st->IsBuoy() && HasStationInUse(st->index, owner))) {
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
193 if (facilities & st->facilities) { //only stations with selected facilities
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
194 int num_waiting_cargo = 0;
6202
eb0fdb88a922 (svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138 <peter1138@openttd.org>
parents: 6122
diff changeset
195 for (CargoID j = 0; j < NUM_CARGO; j++) {
7010
f0f87c5a431e (svn r10266) -Codechange: keep track of the origin, time of travel and accumulated feeder share (transfers) of individual pieces of cargo. This means that cargo isn't thrown on a big pile when it's put in a station or unloaded at a station, however the GUI does not reflect these changes yet so you will not actually see it.
rubidium <rubidium@openttd.org>
parents: 6990
diff changeset
196 if (!st->goods[j].cargo.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
197 num_waiting_cargo++; //count number of waiting cargo
7928
4e8dfd103163 (svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13 <skidd13@openttd.org>
parents: 7886
diff changeset
198 if (HasBit(cargo_filter, j)) {
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
199 station_sort[n++] = st;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
200 break;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
201 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
202 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
203 }
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
204 /* stations without waiting cargo */
6271
56a8bb763a87 (svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138 <peter1138@openttd.org>
parents: 6260
diff changeset
205 if (num_waiting_cargo == 0 && include_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
206 station_sort[n++] = st;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
207 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
208 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
209 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
210 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
211
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
212 free((void*)sl->sort_list);
5609
358c07fb3212 (svn r8066) - Codechange: MallocT(), CallocT(), ReallocT() now return the pointer to allocated memory instead of modifying the pointer given as parameter
KUDr <KUDr@openttd.org>
parents: 5608
diff changeset
213 sl->sort_list = MallocT<const Station*>(n);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
214 sl->list_length = n;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
215
6202
eb0fdb88a922 (svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138 <peter1138@openttd.org>
parents: 6122
diff changeset
216 for (uint i = 0; i < n; ++i) sl->sort_list[i] = station_sort[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
217
9190
99b247e82bbe (svn r13053) -Codechange: station sorting used it's own implementation of GUIList and the associated enums, now it doesn't anymore.
rubidium <rubidium@openttd.org>
parents: 9185
diff changeset
218 sl->flags &= ~VL_REBUILD;
99b247e82bbe (svn r13053) -Codechange: station sorting used it's own implementation of GUIList and the associated enums, now it doesn't anymore.
rubidium <rubidium@openttd.org>
parents: 9185
diff changeset
219 sl->flags |= VL_RESORT;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
220 free((void*)station_sort);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
221 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
222
8016
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
223
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
224 /**
9190
99b247e82bbe (svn r13053) -Codechange: station sorting used it's own implementation of GUIList and the associated enums, now it doesn't anymore.
rubidium <rubidium@openttd.org>
parents: 9185
diff changeset
225 * Sort station list if the VL_RESORT flag is set
8016
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
226 *
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
227 * @param sl pointer to plstations_d (station list and flags)
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
228 */
9191
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
229 static void SortStationsList(GUIStationList *sl)
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
230 {
8964
ae064b8e200b (svn r12756) -Cleanup: variable scope and coding style in station*
smatz <smatz@openttd.org>
parents: 8857
diff changeset
231 static StationSortListingTypeFunction *const _station_sorter[] = {
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
232 &StationNameSorter,
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
233 &StationTypeSorter,
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
234 &StationWaitingSorter,
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
235 &StationRatingMaxSorter
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
236 };
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
237
9190
99b247e82bbe (svn r13053) -Codechange: station sorting used it's own implementation of GUIList and the associated enums, now it doesn't anymore.
rubidium <rubidium@openttd.org>
parents: 9185
diff changeset
238 if (!(sl->flags & VL_RESORT)) 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
239
9190
99b247e82bbe (svn r13053) -Codechange: station sorting used it's own implementation of GUIList and the associated enums, now it doesn't anymore.
rubidium <rubidium@openttd.org>
parents: 9185
diff changeset
240 _internal_sort_order = sl->flags & VL_DESC;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
241 _last_station = NULL; // used for "cache" in namesorting
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
242 qsort((void*)sl->sort_list, sl->list_length, sizeof(sl->sort_list[0]), _station_sorter[sl->sort_type]);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
243
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
244 sl->resort_timer = DAY_TICKS * PERIODIC_RESORT_DAYS;
9190
99b247e82bbe (svn r13053) -Codechange: station sorting used it's own implementation of GUIList and the associated enums, now it doesn't anymore.
rubidium <rubidium@openttd.org>
parents: 9185
diff changeset
245 sl->flags &= ~VL_RESORT;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
246 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
247
8016
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
248 /**
9191
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
249 * The list of stations per player.
8016
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
250 */
9191
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
251 struct PlayerStationsWindow : public Window, public 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
252 {
9191
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
253 static Listing station_sort;
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
254 static byte facilities;
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
255 static bool include_empty;
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
256
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
257 PlayerStationsWindow(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
258 {
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
259 this->caption_color = (byte)this->window_number;
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
260 this->vscroll.cap = 12;
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
261 this->resize.step_height = 10;
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
262 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
263
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
264 /* Add cargo filter buttons */
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
265 uint num_active = 0;
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
266 for (CargoID c = 0; c < NUM_CARGO; c++) {
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
267 if (GetCargo(c)->IsValid()) num_active++;
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
268 }
5608
5dcef0df6a67 (svn r8065) -Feature: The station list does now remember the sort settings
celestar <celestar@openttd.org>
parents: 5587
diff changeset
269
9191
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
270 this->widget_count += num_active;
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
271 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
272 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
273
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
274 uint i = 0;
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
275 for (CargoID c = 0; c < NUM_CARGO; c++) {
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
276 if (!GetCargo(c)->IsValid()) continue;
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
277
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
278 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
279 wi->type = WWT_PANEL;
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
280 wi->display_flags = RESIZE_NONE;
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
281 wi->color = 14;
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
282 wi->left = 89 + i * 14;
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
283 wi->right = wi->left + 13;
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
284 wi->top = 14;
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
285 wi->bottom = 24;
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
286 wi->data = 0;
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
287 wi->tooltips = STR_USE_CTRL_TO_SELECT_MORE;
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
288
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
289 if (HasBit(_cargo_filter, c)) this->LowerWidget(SLW_CARGOSTART + i);
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
290 i++;
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
291 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
292
9191
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
293 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
294 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
295 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
296 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
297 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
298
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
299 if (num_active > 15) {
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
300 /* 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
301 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
302 this->resize.width = this->width;
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
303 }
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
304
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
305 if (_cargo_filter == _cargo_filter_max) _cargo_filter = _cargo_mask;
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 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
308 if (HasBit(facilities, i)) this->LowerWidget(i + SLW_TRAIN);
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 this->SetWidgetLoweredState(SLW_FACILALL, facilities == (FACIL_TRAIN | FACIL_TRUCK_STOP | FACIL_BUS_STOP | FACIL_AIRPORT | FACIL_DOCK));
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
311 this->SetWidgetLoweredState(SLW_CARGOALL, _cargo_filter == _cargo_mask && include_empty);
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
312 this->SetWidgetLoweredState(SLW_NOCARGOWAITING, 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
313
9191
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
314 this->sort_list = NULL;
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
315 this->flags = VL_REBUILD;
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
316 this->sort_type = station_sort.criteria;
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
317 if (station_sort.order) this->flags |= VL_DESC;
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
318
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
319 /* set up resort timer */
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
320 this->resort_timer = DAY_TICKS * PERIODIC_RESORT_DAYS;
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
321 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
322
9191
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
323 virtual void OnPaint()
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
324 {
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
325 PlayerID owner = (PlayerID)this->window_number;
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
326
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
327 BuildStationsList(this, owner, facilities, _cargo_filter, include_empty);
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
328 SortStationsList(this);
8016
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
329
9191
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
330 SetVScrollCount(this, this->list_length);
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
331
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
332 /* draw widgets, with player's name in the caption */
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
333 SetDParam(0, owner);
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
334 SetDParam(1, this->vscroll.count);
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
335
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
336 /* Set text of sort by dropdown */
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
337 this->widget[SLW_SORTDROPBTN].data = _station_sort_listing[this->sort_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
338
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
339 this->DrawWidgets();
9191
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
340
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
341 /* draw arrow pointing up/down for ascending/descending sorting */
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
342 this->DrawSortButtonState(SLW_SORTBY, this->flags & VL_DESC ? SBS_DOWN : SBS_UP);
9191
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
343
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
344 int cg_ofst;
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
345 int x = 89;
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
346 int y = 14;
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
347 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
348
9191
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
349 uint i = 0;
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
350 for (CargoID c = 0; c < NUM_CARGO; c++) {
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
351 const CargoSpec *cs = GetCargo(c);
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
352 if (!cs->IsValid()) continue;
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
353
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
354 cg_ofst = HasBit(_cargo_filter, c) ? 2 : 1;
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
355 GfxFillRect(x + cg_ofst, y + cg_ofst, x + cg_ofst + 10 , y + cg_ofst + 7, cs->rating_colour);
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
356 DrawStringCentered(x + 6 + cg_ofst, y + cg_ofst, cs->abbrev, TC_BLACK);
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
357 x += 14;
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
358 i++;
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
359 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
360
9191
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
361 x += 6;
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
362 cg_ofst = this->IsWidgetLowered(SLW_NOCARGOWAITING) ? 2 : 1;
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
363 DrawStringCentered(x + cg_ofst, y + cg_ofst, STR_ABBREV_NONE, TC_BLACK);
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
364 x += 14;
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
365 cg_ofst = this->IsWidgetLowered(SLW_CARGOALL) ? 2 : 1;
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
366 DrawStringCentered(x + cg_ofst, y + cg_ofst, STR_ABBREV_ALL, TC_BLACK);
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
367
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
368 cg_ofst = this->IsWidgetLowered(SLW_FACILALL) ? 2 : 1;
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
369 DrawString(71 + cg_ofst, 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
370
9191
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
371 if (this->vscroll.count == 0) { // player has no stations
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
372 DrawString(xb, 40, STR_304A_NONE, TC_FROMSTRING);
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
373 return;
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
374 }
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
375
9191
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
376 int max = min(this->vscroll.pos + this->vscroll.cap, this->list_length);
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
377 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
378
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
379 for (int i = this->vscroll.pos; i < max; ++i) { // do until max number of stations of owner
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
380 const Station *st = this->sort_list[i];
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
381 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
382
9191
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
383 assert(st->xy != 0);
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
384
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
385 /* Do not do the complex check HasStationInUse here, it may be even false
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
386 * when the order had been removed and the station list hasn't been removed yet */
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
387 assert(st->owner == owner || (st->owner == OWNER_NONE && !st->IsBuoy()));
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
388
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
389 SetDParam(0, st->index);
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
390 SetDParam(1, st->facilities);
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
391 x = DrawString(xb, y, STR_3049_0, TC_FROMSTRING) + 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
392
9191
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
393 /* show cargo waiting and station ratings */
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
394 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
395 if (!st->goods[j].cargo.Empty()) {
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
396 StationsWndShowStationRating(x, y, j, st->goods[j].cargo.Count(), st->goods[j].rating);
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
397 x += 20;
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
398 }
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
399 }
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
400 y += 10;
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 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
403
9191
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
404 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
405 {
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
406 switch (widget) {
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
407 case SLW_LIST: {
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
408 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
409
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
410 if (id_v >= this->vscroll.cap) return; // click out of bounds
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
411
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
412 id_v += this->vscroll.pos;
6271
56a8bb763a87 (svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138 <peter1138@openttd.org>
parents: 6260
diff changeset
413
9191
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
414 if (id_v >= this->list_length) return; // click out of list bound
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
415
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
416 const Station *st = this->sort_list[id_v];
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
417 /* do not check HasStationInUse - it is slow and may be invalid */
9214
f7d71b69b539 (svn r13080) -Fix: warning about unused variable when compiling without asserts
smatz <smatz@openttd.org>
parents: 9203
diff changeset
418 assert(st->owner == (PlayerID)this->window_number || (st->owner == OWNER_NONE && !st->IsBuoy()));
9191
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
419
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
420 if (_ctrl_pressed) {
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
421 ShowExtraViewPortWindow(st->xy);
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
422 } else {
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
423 ScrollMainWindowToTile(st->xy);
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
424 }
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
425 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
426 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
427
9191
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
428 case SLW_TRAIN:
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
429 case SLW_TRUCK:
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
430 case SLW_BUS:
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
431 case SLW_AIRPLANE:
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
432 case SLW_SHIP:
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
433 if (_ctrl_pressed) {
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
434 ToggleBit(facilities, widget - SLW_TRAIN);
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
435 this->ToggleWidgetLoweredState(widget);
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
436 } else {
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
437 uint i;
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
438 FOR_EACH_SET_BIT(i, facilities) {
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
439 this->RaiseWidget(i + SLW_TRAIN);
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
440 }
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
441 SetBit(facilities, widget - SLW_TRAIN);
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
442 this->LowerWidget(widget);
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
443 }
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
444 this->SetWidgetLoweredState(SLW_FACILALL, facilities == (FACIL_TRAIN | FACIL_TRUCK_STOP | FACIL_BUS_STOP | FACIL_AIRPORT | FACIL_DOCK));
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
445 this->flags |= VL_REBUILD;
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
446 this->SetDirty();
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
447 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
448
9191
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
449 case SLW_FACILALL:
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
450 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
451 this->LowerWidget(i + SLW_TRAIN);
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
452 }
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
453 this->LowerWidget(SLW_FACILALL);
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 facilities = FACIL_TRAIN | FACIL_TRUCK_STOP | FACIL_BUS_STOP | FACIL_AIRPORT | FACIL_DOCK;
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
456 this->flags |= VL_REBUILD;
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
457 this->SetDirty();
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
458 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
459
9191
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
460 case SLW_CARGOALL: {
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
461 uint i = 0;
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
462 for (CargoID c = 0; c < NUM_CARGO; c++) {
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
463 if (!GetCargo(c)->IsValid()) continue;
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
464 this->LowerWidget(i + SLW_CARGOSTART);
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
465 i++;
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
466 }
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
467 this->LowerWidget(SLW_NOCARGOWAITING);
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
468 this->LowerWidget(SLW_CARGOALL);
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
469
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
470 _cargo_filter = _cargo_mask;
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
471 include_empty = true;
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
472 this->flags |= VL_REBUILD;
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
473 this->SetDirty();
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
474 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
475 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
476
9191
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
477 case SLW_SORTBY: // flip sorting method asc/desc
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
478 this->flags ^= VL_DESC; //DESC-flag
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
479 station_sort.order = HasBit(this->flags, 0);
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
480 this->flags |= VL_RESORT;
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
481 this->flags4 |= 5 << WF_TIMEOUT_SHL;
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
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
487 ShowDropDownMenu(this, _station_sort_listing, this->sort_type, SLW_SORTDROPBTN, 0, 0);
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) {
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
492 include_empty = !include_empty;
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
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
499 _cargo_filter = 0;
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
500 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 }
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
504 this->flags |= VL_REBUILD;
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
505 this->SetWidgetLoweredState(SLW_CARGOALL, _cargo_filter == _cargo_mask && include_empty);
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 CargoID c;
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
513 int i = 0;
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
514 for (c = 0; c < NUM_CARGO; c++) {
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
515 if (!GetCargo(c)->IsValid()) continue;
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
516 if (widget - SLW_CARGOSTART == i) break;
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
517 i++;
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
518 }
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
519
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
520 if (_ctrl_pressed) {
9191
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
521 ToggleBit(_cargo_filter, c);
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
522 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
523 } else {
9191
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
524 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
525 this->RaiseWidget(i);
6202
eb0fdb88a922 (svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138 <peter1138@openttd.org>
parents: 6122
diff changeset
526 }
9191
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
527 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
528
56a8bb763a87 (svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138 <peter1138@openttd.org>
parents: 6260
diff changeset
529 _cargo_filter = 0;
9191
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
530 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
531
9191
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
532 SetBit(_cargo_filter, c);
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
533 this->LowerWidget(widget);
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
534 }
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
535 this->flags |= VL_REBUILD;
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
536 this->SetWidgetLoweredState(SLW_CARGOALL, _cargo_filter == _cargo_mask && include_empty);
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
537 this->SetDirty();
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
538 }
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
539 break;
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
540 }
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
541 }
6271
56a8bb763a87 (svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138 <peter1138@openttd.org>
parents: 6260
diff changeset
542
9191
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
543 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
544 {
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
545 if (this->sort_type != index) {
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
546 /* value has changed -> resort */
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
547 this->sort_type = index;
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
548 station_sort.criteria = this->sort_type;
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
549 this->flags |= VL_RESORT;
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
550 }
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
551 this->SetDirty();
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 {
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
556 if (_pause_game != 0) return;
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
557 if (--this->resort_timer == 0) {
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
558 DEBUG(misc, 3, "Periodic rebuild station list player %d", this->window_number);
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
559 this->resort_timer = DAY_TICKS * PERIODIC_RESORT_DAYS;
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
560 this->flags |= VL_REBUILD;
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
561 this->SetDirty();
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
562 }
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
563 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
564
9191
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
565 virtual void OnTimeout()
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
566 {
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
567 this->RaiseWidget(SLW_SORTBY);
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
568 this->SetDirty();
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
569 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
570
9191
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
571 virtual void OnResize(Point new_size, Point delta)
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
572 {
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
573 this->vscroll.cap += delta.y / 10;
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
574 }
9297
add307f2e6ea (svn r13165) -Codechange: replace some RebuildXXXList/ResortXXXList+InvalidateWindowXXX with InvalidateWindowXXXData.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
575
add307f2e6ea (svn r13165) -Codechange: replace some RebuildXXXList/ResortXXXList+InvalidateWindowXXX with InvalidateWindowXXXData.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
576 virtual void OnInvalidateData(int data)
add307f2e6ea (svn r13165) -Codechange: replace some RebuildXXXList/ResortXXXList+InvalidateWindowXXX with InvalidateWindowXXXData.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
577 {
add307f2e6ea (svn r13165) -Codechange: replace some RebuildXXXList/ResortXXXList+InvalidateWindowXXX with InvalidateWindowXXXData.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
578 this->flags |= (data == 0 ? VL_REBUILD : VL_RESORT);
add307f2e6ea (svn r13165) -Codechange: replace some RebuildXXXList/ResortXXXList+InvalidateWindowXXX with InvalidateWindowXXXData.
rubidium <rubidium@openttd.org>
parents: 9273
diff changeset
579 }
9191
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
580 };
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
581
9191
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
582 Listing PlayerStationsWindow::station_sort = {0, 0};
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
583 byte PlayerStationsWindow::facilities = FACIL_TRAIN | FACIL_TRUCK_STOP | FACIL_BUS_STOP | FACIL_AIRPORT | FACIL_DOCK;
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
584 bool PlayerStationsWindow::include_empty = true;
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
585
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
586
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
587 static const Widget _player_stations_widgets[] = {
8016
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
588 { WWT_CLOSEBOX, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, // SLW_CLOSEBOX
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
589 { WWT_CAPTION, RESIZE_RIGHT, 14, 11, 345, 0, 13, STR_3048_STATIONS, STR_018C_WINDOW_TITLE_DRAG_THIS},
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
590 { WWT_STICKYBOX, RESIZE_LR, 14, 346, 357, 0, 13, 0x0, STR_STICKY_BUTTON},
8016
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
591 { WWT_PANEL, RESIZE_RB, 14, 0, 345, 37, 161, 0x0, STR_3057_STATION_NAMES_CLICK_ON}, // SLW_LIST
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
592 { WWT_SCROLLBAR, RESIZE_LRB, 14, 346, 357, 37, 149, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST},
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
593 { WWT_RESIZEBOX, RESIZE_LRTB, 14, 346, 357, 150, 161, 0x0, STR_RESIZE_BUTTON},
8016
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
594
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
595 { WWT_TEXTBTN, RESIZE_NONE, 14, 0, 13, 14, 24, STR_TRAIN, STR_USE_CTRL_TO_SELECT_MORE}, // SLW_TRAIN
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
596 { WWT_TEXTBTN, RESIZE_NONE, 14, 14, 27, 14, 24, STR_LORRY, STR_USE_CTRL_TO_SELECT_MORE}, // SLW_TRUCK
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
597 { WWT_TEXTBTN, RESIZE_NONE, 14, 28, 41, 14, 24, STR_BUS, STR_USE_CTRL_TO_SELECT_MORE}, // SLW_BUS
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
598 { WWT_TEXTBTN, RESIZE_NONE, 14, 42, 55, 14, 24, STR_PLANE, STR_USE_CTRL_TO_SELECT_MORE}, // SLW_AIRPLANE
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
599 { WWT_TEXTBTN, RESIZE_NONE, 14, 56, 69, 14, 24, STR_SHIP, STR_USE_CTRL_TO_SELECT_MORE}, // SLW_SHIP
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
600 { WWT_PANEL, RESIZE_NONE, 14, 70, 83, 14, 24, 0x0, STR_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
601
8016
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
602 { WWT_PANEL, RESIZE_NONE, 14, 83, 88, 14, 24, 0x0, STR_NULL}, // SLW_PAN_BETWEEN
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
603 { WWT_PANEL, RESIZE_NONE, 14, 89, 102, 14, 24, 0x0, STR_NO_WAITING_CARGO}, // SLW_NOCARGOWAITING
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
604 { WWT_PANEL, RESIZE_NONE, 14, 103, 116, 14, 24, 0x0, STR_SELECT_ALL_TYPES}, // SLW_CARGOALL
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
605 { WWT_PANEL, RESIZE_RIGHT, 14, 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
606
8016
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
607 { WWT_TEXTBTN, RESIZE_NONE, 14, 0, 80, 25, 36, STR_SORT_BY, STR_SORT_ORDER_TIP}, // SLW_SORTBY
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
608 { WWT_DROPDOWN, RESIZE_NONE, 14, 81, 243, 25, 36, 0x0, STR_SORT_CRITERIA_TIP}, // SLW_SORTDROPBTN
8016
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
609 { WWT_PANEL, RESIZE_RIGHT, 14, 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
610 { 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
611 };
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
612
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
613 static const WindowDesc _player_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
614 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
615 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
616 WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_STICKY_BUTTON | WDF_RESIZABLE,
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
617 _player_stations_widgets,
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
618 };
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
619
8016
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
620 /**
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
621 * Opens window with list of player's stations
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
622 *
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
623 * @param player player whose stations' list show
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
624 */
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 void ShowPlayerStations(PlayerID player)
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
626 {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
627 if (!IsValidPlayer(player)) return;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
628
9191
b61dc40f30a4 (svn r13054) -Codechange: make a class of the PlayerStationsWindow.
rubidium <rubidium@openttd.org>
parents: 9190
diff changeset
629 AllocateWindowDescFront<PlayerStationsWindow>(&_player_stations_desc, player);
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 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
631
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
632 static const Widget _station_view_widgets[] = {
8016
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
633 { WWT_CLOSEBOX, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, // SVW_CLOSEBOX
8420
370ea805f591 (svn r11990) -Codechange: Show all cargo sources (en-route from) in the station view
peter1138 <peter1138@openttd.org>
parents: 8349
diff changeset
634 { WWT_CAPTION, RESIZE_RIGHT, 14, 11, 236, 0, 13, STR_300A_0, STR_018C_WINDOW_TITLE_DRAG_THIS},
370ea805f591 (svn r11990) -Codechange: Show all cargo sources (en-route from) in the station view
peter1138 <peter1138@openttd.org>
parents: 8349
diff changeset
635 { WWT_STICKYBOX, RESIZE_LR, 14, 237, 248, 0, 13, 0x0, STR_STICKY_BUTTON},
370ea805f591 (svn r11990) -Codechange: Show all cargo sources (en-route from) in the station view
peter1138 <peter1138@openttd.org>
parents: 8349
diff changeset
636 { WWT_PANEL, RESIZE_RB, 14, 0, 236, 14, 65, 0x0, STR_NULL}, // SVW_WAITING
370ea805f591 (svn r11990) -Codechange: Show all cargo sources (en-route from) in the station view
peter1138 <peter1138@openttd.org>
parents: 8349
diff changeset
637 { WWT_SCROLLBAR, RESIZE_LRB, 14, 237, 248, 14, 65, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST},
370ea805f591 (svn r11990) -Codechange: Show all cargo sources (en-route from) in the station view
peter1138 <peter1138@openttd.org>
parents: 8349
diff changeset
638 { WWT_PANEL, RESIZE_RTB, 14, 0, 248, 66, 97, 0x0, STR_NULL}, // SVW_ACCEPTLIST / SVW_RATINGLIST
370ea805f591 (svn r11990) -Codechange: Show all cargo sources (en-route from) in the station view
peter1138 <peter1138@openttd.org>
parents: 8349
diff changeset
639 { WWT_PUSHTXTBTN, RESIZE_TB, 14, 0, 59, 98, 109, STR_00E4_LOCATION, STR_3053_CENTER_MAIN_VIEW_ON_STATION}, // SVW_LOCATION
370ea805f591 (svn r11990) -Codechange: Show all cargo sources (en-route from) in the station view
peter1138 <peter1138@openttd.org>
parents: 8349
diff changeset
640 { WWT_PUSHTXTBTN, RESIZE_TB, 14, 60, 120, 98, 109, STR_3032_RATINGS, STR_3054_SHOW_STATION_RATINGS}, // SVW_RATINGS / SVW_ACCEPTS
370ea805f591 (svn r11990) -Codechange: Show all cargo sources (en-route from) in the station view
peter1138 <peter1138@openttd.org>
parents: 8349
diff changeset
641 { WWT_PUSHTXTBTN, RESIZE_RTB, 14, 121, 180, 98, 109, STR_0130_RENAME, STR_3055_CHANGE_NAME_OF_STATION}, // SVW_RENAME
370ea805f591 (svn r11990) -Codechange: Show all cargo sources (en-route from) in the station view
peter1138 <peter1138@openttd.org>
parents: 8349
diff changeset
642 { WWT_PUSHTXTBTN, RESIZE_LRTB, 14, 181, 194, 98, 109, STR_TRAIN, STR_SCHEDULED_TRAINS_TIP }, // SVW_TRAINS
370ea805f591 (svn r11990) -Codechange: Show all cargo sources (en-route from) in the station view
peter1138 <peter1138@openttd.org>
parents: 8349
diff changeset
643 { WWT_PUSHTXTBTN, RESIZE_LRTB, 14, 195, 208, 98, 109, STR_LORRY, STR_SCHEDULED_ROAD_VEHICLES_TIP }, // SVW_ROADVEHS
370ea805f591 (svn r11990) -Codechange: Show all cargo sources (en-route from) in the station view
peter1138 <peter1138@openttd.org>
parents: 8349
diff changeset
644 { WWT_PUSHTXTBTN, RESIZE_LRTB, 14, 209, 222, 98, 109, STR_PLANE, STR_SCHEDULED_AIRCRAFT_TIP }, // SVW_PLANES
370ea805f591 (svn r11990) -Codechange: Show all cargo sources (en-route from) in the station view
peter1138 <peter1138@openttd.org>
parents: 8349
diff changeset
645 { WWT_PUSHTXTBTN, RESIZE_LRTB, 14, 223, 236, 98, 109, STR_SHIP, STR_SCHEDULED_SHIPS_TIP }, // SVW_SHIPS
370ea805f591 (svn r11990) -Codechange: Show all cargo sources (en-route from) in the station view
peter1138 <peter1138@openttd.org>
parents: 8349
diff changeset
646 { WWT_RESIZEBOX, RESIZE_LRTB, 14, 237, 248, 98, 109, 0x0, STR_RESIZE_BUTTON},
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
647 { 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
648 };
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
649
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
650 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
651 {
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
652 const CargoSpec *cs = GetCargo(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
653 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
654
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
655 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
656 /* 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
657 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
658 } 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
659 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
660 }
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
661
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
662 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
663
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
664 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
665 }
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
666
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
667 /**
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
668 * 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
669 *
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
670 * @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
671 * @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
672 * @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
673 * @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
674 */
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
675 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
676 {
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
677 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
678 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
679
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
680 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
681
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
682 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
683 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
684 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
685 } 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
686 }
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
687
8420
370ea805f591 (svn r11990) -Codechange: Show all cargo sources (en-route from) in the station view
peter1138 <peter1138@openttd.org>
parents: 8349
diff changeset
688 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
689 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
690 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
691 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
692
370ea805f591 (svn r11990) -Codechange: Show all cargo sources (en-route from) in the station view
peter1138 <peter1138@openttd.org>
parents: 8349
diff changeset
693 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
694 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
695 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
696 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
697 { }
370ea805f591 (svn r11990) -Codechange: Show all cargo sources (en-route from) in the station view
peter1138 <peter1138@openttd.org>
parents: 8349
diff changeset
698 };
370ea805f591 (svn r11990) -Codechange: Show all cargo sources (en-route from) in the station view
peter1138 <peter1138@openttd.org>
parents: 8349
diff changeset
699
370ea805f591 (svn r11990) -Codechange: Show all cargo sources (en-route from) in the station view
peter1138 <peter1138@openttd.org>
parents: 8349
diff changeset
700 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
701
8016
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
702 /**
9185
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
703 * The StationView window
8016
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
704 */
9185
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
705 struct StationViewWindow : public Window {
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
706 uint32 cargo; ///< Bitmask of cargo types to expand
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
707 uint16 cargo_rows[NUM_CARGO]; ///< Header row for each cargo type
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
708
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
709 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
710 {
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
711 PlayerID owner = GetStation(window_number)->owner;
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
712 if (owner != OWNER_NONE) this->caption_color = owner;
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
713 this->vscroll.cap = 5;
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
714 this->resize.step_height = 10;
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
715
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
716 this->FindWindowPlacementAndResize(desc);
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
717 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
718
9185
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
719 ~StationViewWindow()
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
720 {
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
721 WindowNumber wno =
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
722 (this->window_number << 16) | VLW_STATION_LIST | GetStation(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
723
9185
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
724 DeleteWindowById(WC_TRAINS_LIST, wno);
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
725 DeleteWindowById(WC_ROADVEH_LIST, wno);
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
726 DeleteWindowById(WC_SHIPS_LIST, wno);
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
727 DeleteWindowById(WC_AIRCRAFT_LIST, wno);
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
728 }
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
729
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
730 virtual void OnPaint()
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
731 {
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
732 StationID station_id = this->window_number;
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
733 const Station *st = GetStation(station_id);
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
734 CargoDataList cargolist;
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
735 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
736
9185
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
737 /* 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
738 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
739 if (st->goods[i].cargo.Empty()) {
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
740 this->cargo_rows[i] = 0;
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
741 } else {
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
742 /* 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
743 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
744
9185
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
745 /* Set the row for this cargo entry for the expand/hide button */
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
746 this->cargo_rows[i] = cargolist.size();
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
747
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
748 /* 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
749 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
750 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
751 const CargoPacket *cp = *it;
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
752 if (cp->source != station_id) {
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
753 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
754
9185
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
755 /* 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
756 SetBit(transfers, i);
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
757
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
758 /* 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
759 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
760
9185
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
761 /* 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
762 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
763 CargoData *cd = &(*jt);
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
764 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
765 cd->count += cp->count;
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
766 added = true;
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
767 break;
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
768 }
8420
370ea805f591 (svn r11990) -Codechange: Show all cargo sources (en-route from) in the station view
peter1138 <peter1138@openttd.org>
parents: 8349
diff changeset
769 }
9185
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
770
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
771 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
772 }
370ea805f591 (svn r11990) -Codechange: Show all cargo sources (en-route from) in the station view
peter1138 <peter1138@openttd.org>
parents: 8349
diff changeset
773 }
370ea805f591 (svn r11990) -Codechange: Show all cargo sources (en-route from) in the station view
peter1138 <peter1138@openttd.org>
parents: 8349
diff changeset
774 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
775 }
9185
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
776 SetVScrollCount(this, 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
777
9185
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
778 /* disable some buttons */
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
779 this->SetWidgetDisabledState(SVW_RENAME, st->owner != _local_player);
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
780 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
781 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
782 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
783 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
784
9185
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
785 SetDParam(0, st->index);
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
786 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
787 this->DrawWidgets();
8964
ae064b8e200b (svn r12756) -Cleanup: variable scope and coding style in station*
smatz <smatz@openttd.org>
parents: 8857
diff changeset
788
9185
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
789 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
790 int y = 15;
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
791 int pos = this->vscroll.pos; ///< = this->vscroll.pos
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
792
9185
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
793 uint width = this->widget[SVW_WAITING].right - this->widget[SVW_WAITING].left - 4;
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
794 int maxrows = this->vscroll.cap;
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
795
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
796 StringID str;
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
797
8420
370ea805f591 (svn r11990) -Codechange: Show all cargo sources (en-route from) in the station view
peter1138 <peter1138@openttd.org>
parents: 8349
diff changeset
798 if (--pos < 0) {
9185
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
799 str = STR_00D0_NOTHING;
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
800 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
801 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
802 }
9185
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
803 SetDParam(0, str);
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
804 DrawString(x, y, STR_0008_WAITING, TC_FROMSTRING);
8420
370ea805f591 (svn r11990) -Codechange: Show all cargo sources (en-route from) in the station view
peter1138 <peter1138@openttd.org>
parents: 8349
diff changeset
805 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
806 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
807
9185
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
808 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
809 if (--pos < 0) {
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
810 const CargoData *cd = &(*it);
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
811 if (cd->source == INVALID_STATION) {
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
812 /* Heading */
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
813 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
814 SetDParam(0, cd->cargo);
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
815 SetDParam(1, cd->count);
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
816 if (HasBit(transfers, cd->cargo)) {
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
817 /* 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
818 const char *sym = HasBit(this->cargo, cd->cargo) ? "-" : "+";
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
819 DrawStringRightAligned(x + width - 8, y, STR_0009, TC_FROMSTRING);
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
820 DoDrawString(sym, x + width - 6, y, TC_YELLOW);
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
821 } else {
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
822 DrawStringRightAligned(x + width, y, STR_0009, TC_FROMSTRING);
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
823 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
824 } else {
9185
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
825 SetDParam(0, cd->cargo);
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
826 SetDParam(1, cd->count);
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
827 SetDParam(2, cd->source);
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
828 DrawStringRightAlignedTruncated(x + width, y, STR_EN_ROUTE_FROM, TC_FROMSTRING, width);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
829 }
9185
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
830
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
831 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
832 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
833 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
834
9185
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
835 if (this->widget[SVW_ACCEPTS].data == STR_3032_RATINGS) { // small window with list of accepted cargo
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
836 char *b = _userstring;
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
837 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
838
9185
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
839 b = InlineString(b, STR_000C_ACCEPTS);
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
840
9185
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
841 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
842 if (b >= lastof(_userstring) - (1 + 2 * 4)) break; // ',' or ' ' and two calls to Utf8Encode()
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
843 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
844 if (first) {
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
845 first = false;
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
846 } else {
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
847 /* 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
848 *b++ = ',';
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
849 *b++ = ' ';
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
850 }
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
851 b = InlineString(b, GetCargo(i)->name);
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
852 }
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
853 }
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
854
9185
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
855 /* If first is still true then no cargo is accepted */
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
856 if (first) b = InlineString(b, STR_00D0_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
857
9185
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
858 *b = '\0';
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
859
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
860 /* Make sure we detect any buffer overflow */
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
861 assert(b < endof(_userstring));
8420
370ea805f591 (svn r11990) -Codechange: Show all cargo sources (en-route from) in the station view
peter1138 <peter1138@openttd.org>
parents: 8349
diff changeset
862
9185
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
863 DrawStringMultiLine(2, this->widget[SVW_ACCEPTLIST].top + 1, STR_SPEC_USERSTRING, this->widget[SVW_ACCEPTLIST].right - this->widget[SVW_ACCEPTLIST].left);
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
864 } 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
865 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
866
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
867 DrawString(2, y, STR_3034_LOCAL_RATING_OF_TRANSPORT, TC_FROMSTRING);
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
868 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
869
9185
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
870 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
871 const CargoSpec *cs = GetCargo(i);
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
872 if (!cs->IsValid()) continue;
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
873
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
874 const GoodsEntry *ge = &st->goods[i];
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
875 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
876
9185
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
877 SetDParam(0, cs->name);
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
878 SetDParam(2, ge->rating * 101 >> 8);
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
879 SetDParam(1, STR_3035_APPALLING + (ge->rating >> 5));
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
880 DrawString(8, y, STR_303D, TC_FROMSTRING);
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
881 y += 10;
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
882 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
883 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
884 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
885
9185
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
886 void HandleCargoWaitingClick(int row)
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
887 {
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
888 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
889
9185
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
890 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
891 if (this->cargo_rows[c] == row) {
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
892 ToggleBit(this->cargo, c);
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
893 this->InvalidateWidget(SVW_WAITING);
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
894 break;
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
895 }
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
896 }
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
897 }
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
898
9185
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
899 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
900 {
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
901 switch (widget) {
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
902 case SVW_WAITING:
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
903 this->HandleCargoWaitingClick((pt.y - this->widget[SVW_WAITING].top) / 10 + this->vscroll.pos);
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
904 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
905
9185
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
906 case SVW_LOCATION:
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
907 if (_ctrl_pressed) {
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
908 ShowExtraViewPortWindow(GetStation(this->window_number)->xy);
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
909 } else {
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
910 ScrollMainWindowToTile(GetStation(this->window_number)->xy);
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
911 }
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
912 break;
6202
eb0fdb88a922 (svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138 <peter1138@openttd.org>
parents: 6122
diff changeset
913
9185
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
914 case SVW_RATINGS:
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
915 this->SetDirty();
6202
eb0fdb88a922 (svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138 <peter1138@openttd.org>
parents: 6122
diff changeset
916
9185
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
917 if (this->widget[SVW_RATINGS].data == STR_3032_RATINGS) {
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
918 /* Switch to ratings view */
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
919 this->widget[SVW_RATINGS].data = STR_3033_ACCEPTS;
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
920 this->widget[SVW_RATINGS].tooltips = STR_3056_SHOW_LIST_OF_ACCEPTED_CARGO;
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
921 ResizeWindowForWidget(this, SVW_ACCEPTLIST, 0, 100);
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
922 } else {
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
923 /* Switch to accepts view */
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
924 this->widget[SVW_RATINGS].data = STR_3032_RATINGS;
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
925 this->widget[SVW_RATINGS].tooltips = STR_3054_SHOW_STATION_RATINGS;
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
926 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
927 }
eb0fdb88a922 (svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138 <peter1138@openttd.org>
parents: 6122
diff changeset
928
9185
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
929 this->SetDirty();
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
930 break;
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
931
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
932 case SVW_RENAME:
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
933 SetDParam(0, this->window_number);
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
934 ShowQueryString(STR_STATION, STR_3030_RENAME_STATION_LOADING, 31, 180, this, CS_ALPHANUMERAL);
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
935 break;
6202
eb0fdb88a922 (svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138 <peter1138@openttd.org>
parents: 6122
diff changeset
936
9185
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
937 case SVW_TRAINS: { // Show a list of scheduled trains to this station
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
938 const Station *st = GetStation(this->window_number);
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
939 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
940 break;
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
941 }
6202
eb0fdb88a922 (svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138 <peter1138@openttd.org>
parents: 6122
diff changeset
942
9185
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
943 case SVW_ROADVEHS: { // Show a list of scheduled road-vehicles to this station
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
944 const Station *st = GetStation(this->window_number);
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
945 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
946 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
947 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
948
9185
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
949 case SVW_PLANES: { // Show a list of scheduled aircraft to this station
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
950 const Station *st = GetStation(this->window_number);
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
951 /* Since oilrigs have no owners, show the scheduled aircraft of current player */
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
952 PlayerID owner = (st->owner == OWNER_NONE) ? _current_player : st->owner;
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
953 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
954 break;
6202
eb0fdb88a922 (svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138 <peter1138@openttd.org>
parents: 6122
diff changeset
955 }
eb0fdb88a922 (svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138 <peter1138@openttd.org>
parents: 6122
diff changeset
956
9185
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
957 case SVW_SHIPS: { // Show a list of scheduled ships to this station
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
958 const Station *st = GetStation(this->window_number);
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
959 /* Since oilrigs/bouys have no owners, show the scheduled ships of current player */
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
960 PlayerID owner = (st->owner == OWNER_NONE) ? _current_player : st->owner;
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
961 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
962 break;
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
963 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
964 }
9185
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
965 }
8420
370ea805f591 (svn r11990) -Codechange: Show all cargo sources (en-route from) in the station view
peter1138 <peter1138@openttd.org>
parents: 8349
diff changeset
966
9185
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
967 virtual void OnQueryTextFinished(char *str)
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
968 {
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
969 if (!StrEmpty(str)) {
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
970 _cmd_text = str;
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
971 DoCommandP(0, this->window_number, 0, NULL,
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
972 CMD_RENAME_STATION | CMD_MSG(STR_3031_CAN_T_RENAME_STATION));
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
973 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
974 }
9185
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
975
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
976 virtual void OnResize(Point new_size, Point delta)
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
977 {
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
978 if (delta.x != 0) ResizeButtons(this, SVW_LOCATION, SVW_RENAME);
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
979 this->vscroll.cap += delta.y / (int)this->resize.step_height;
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
980 }
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
981 };
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
982
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
983
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
984 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
985 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
986 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
987 WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_STICKY_BUTTON | WDF_RESIZABLE,
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
988 _station_view_widgets,
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
989 };
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
990
8016
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
991 /**
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
992 * Opens StationViewWindow for given station
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
993 *
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
994 * @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
995 */
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
996 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
997 {
9185
227f376591eb (svn r13048) -Codechange: make a class of the StationViewWindow.
rubidium <rubidium@openttd.org>
parents: 9164
diff changeset
998 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
999 }