annotate src/station_gui.cpp @ 8338:133b06cabee8 draft

(svn r11904) -Codechange: use dropdown widget in 3 more windows, build vehicle, group vehicle list and station list.
author peter1138 <peter1138@openttd.org>
date Thu, 17 Jan 2008 18:49:39 +0000
parents dbb7bfe0e95c
children cbb2e614bcfa
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
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
3 /** @file station_gui.cpp */
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"
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
11 #include "station.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"
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
20 #include "station.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"
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
27
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
28 #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
29 #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
30
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
31 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
32
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
33 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
34 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
35 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
36 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
37
8268
ab53b3bf7100 (svn r11832) -Codechange: get rid of (quite) some VARDEFs.
rubidium <rubidium@openttd.org>
parents: 8264
diff changeset
38 bool _station_show_coverage;
ab53b3bf7100 (svn r11832) -Codechange: get rid of (quite) some VARDEFs.
rubidium <rubidium@openttd.org>
parents: 8264
diff changeset
39
8016
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
40 /**
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
41 * Draw small boxes of cargo amount and ratings data at the given
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
42 * coordinates. If amount exceeds 576 units, it is shown 'full', same
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
43 * goes for the rating: at above 90% orso (224) it is also 'full'
8016
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
44 *
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
45 * @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
46 * @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
47 * @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
48 * @param amount Cargo amount
8016
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
49 * @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
50 *
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
51 * @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
52 * @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
53 */
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
54 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
55 {
8016
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
56 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
57 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
58
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
59 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
60 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
61
17ebeb5a2c37 (svn r8826) -Codechange: Replace _cargoc's separate arrays with a regular struct array (with accessor) and implement new initialization method using cargo labels.
peter1138 <peter1138@openttd.org>
parents: 5893
diff changeset
62 int colour = cs->rating_colour;
8016
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
63 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
64
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
65 /* 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
66 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
67
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
68 /* 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
69 * 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
70 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
71 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
72 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
73 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
74 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
75 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
76 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
77
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
78 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
79
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
80 /* 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
81 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
82 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
83 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
84 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
85 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
86
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
87 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
88 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
89 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
90 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
91 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
92 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
93 };
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
94
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
95 static char _bufcache[64];
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
96 static const Station* _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
97 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
98
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
99 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
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 const Station* st1 = *(const Station**)a;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
102 const Station* st2 = *(const Station**)b;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
103 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
104 int r;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
105
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
106 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
107 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
108
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
109 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
110 _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
111 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
112 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
113 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
114
6202
eb0fdb88a922 (svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138 <peter1138@openttd.org>
parents: 6122
diff changeset
115 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
116 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
117 }
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 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
120 {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
121 const Station* st1 = *(const Station**)a;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
122 const Station* st2 = *(const Station**)b;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
123 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
124 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
125
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
126 static const uint32 _cargo_filter_max = ~0;
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
127 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
128
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
129 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
130 {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
131 const Station* st1 = *(const Station**)a;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
132 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
133 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
134
6202
eb0fdb88a922 (svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138 <peter1138@openttd.org>
parents: 6122
diff changeset
135 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
136 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
137 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
138 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
139 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
140
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
141 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
142 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
143
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
144 /**
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 * 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
146 * @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
147 * @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
148 * @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
149 * @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
150 * @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
151 */
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
152 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
153 {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
154 const Station* st1 = *(const Station**)a;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
155 const Station* st2 = *(const Station**)b;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
156 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
157 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
158
6202
eb0fdb88a922 (svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138 <peter1138@openttd.org>
parents: 6122
diff changeset
159 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
160 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
161 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
162 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
163
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
164 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
165 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
166
8016
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
167 /** Flags for station list */
6248
0789677a15a0 (svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium <rubidium@openttd.org>
parents: 6247
diff changeset
168 enum StationListFlags {
8016
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
169 SL_ORDER = 1 << 0, ///< Order - ascending (=0), descending (=1)
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
170 SL_RESORT = 1 << 1, ///< Resort the list
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
171 SL_REBUILD = 1 << 2, ///< Rebuild the list
6248
0789677a15a0 (svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium <rubidium@openttd.org>
parents: 6247
diff changeset
172 };
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
173
5587
c44c070c5032 (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium <rubidium@openttd.org>
parents: 5584
diff changeset
174 DECLARE_ENUM_AS_BIT_SET(StationListFlags);
c44c070c5032 (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium <rubidium@openttd.org>
parents: 5584
diff changeset
175
8016
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
176 /** Information about station list */
6248
0789677a15a0 (svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium <rubidium@openttd.org>
parents: 6247
diff changeset
177 struct plstations_d {
8016
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
178 const Station** sort_list; ///< Pointer to list of stations
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
179 uint16 list_length; ///< Number of stations in list
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
180 uint16 resort_timer; ///< Tick counter to resort the list
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
181 byte sort_type; ///< Sort type - name, waiting, ...
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
182 byte flags; ///< Flags - SL_ORDER, SL_RESORT, SL_REBUILD
6248
0789677a15a0 (svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium <rubidium@openttd.org>
parents: 6247
diff changeset
183 };
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
184 assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(plstations_d));
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
185
8016
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
186 /**
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
187 * Set the 'SL_REBUILD' flag for all station lists
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
188 */
6247
57363e064324 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium <rubidium@openttd.org>
parents: 6202
diff changeset
189 void RebuildStationLists()
5584
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 Window* const *wz;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
192
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
193 FOR_ALL_WINDOWS(wz) {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
194 Window *w = *wz;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
195 if (w->window_class == WC_STATION_LIST) {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
196 WP(w, plstations_d).flags |= SL_REBUILD;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
197 SetWindowDirty(w);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
198 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
199 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
200 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
201
8016
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
202 /**
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
203 * Set the 'SL_RESORT' flag for all station lists
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
204 */
6247
57363e064324 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium <rubidium@openttd.org>
parents: 6202
diff changeset
205 void ResortStationLists()
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 {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
207 Window* const *wz;
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 FOR_ALL_WINDOWS(wz) {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
210 Window *w = *wz;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
211 if (w->window_class == WC_STATION_LIST) {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
212 WP(w, plstations_d).flags |= SL_RESORT;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
213 SetWindowDirty(w);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
214 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
215 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
216 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
217
8016
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
218 /**
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
219 * Rebuild station list if the SL_REBUILD flag is set
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
220 *
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
221 * @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
222 * @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
223 * @param facilities types of stations of interest
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
224 * @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
225 * @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
226 */
6271
56a8bb763a87 (svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138 <peter1138@openttd.org>
parents: 6260
diff changeset
227 static void BuildStationsList(plstations_d* 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
228 {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
229 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
230 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
231
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
232 if (!(sl->flags & SL_REBUILD)) return;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
233
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
234 /* Create array for sorting */
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
235 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
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 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
238
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
239 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
240 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
241 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
242 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
243 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
244 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
245 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
246 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
247 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
248 break;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
249 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
250 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
251 }
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
252 /* 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
253 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
254 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
255 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
256 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
257 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
258 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
259
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
260 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
261 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
262 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
263
6202
eb0fdb88a922 (svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138 <peter1138@openttd.org>
parents: 6122
diff changeset
264 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
265
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
266 sl->flags &= ~SL_REBUILD;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
267 sl->flags |= SL_RESORT;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
268 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
269 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
270
8016
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
271
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
272 /**
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
273 * Sort station list if the SL_RESORT flag is set
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
274 *
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
275 * @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
276 */
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
277 static void SortStationsList(plstations_d *sl)
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
278 {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
279 static StationSortListingTypeFunction* const _station_sorter[] = {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
280 &StationNameSorter,
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
281 &StationTypeSorter,
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
282 &StationWaitingSorter,
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
283 &StationRatingMaxSorter
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
284 };
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
285
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
286 if (!(sl->flags & SL_RESORT)) return;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
287
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
288 _internal_sort_order = sl->flags & SL_ORDER;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
289 _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
290 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
291
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
292 sl->resort_timer = DAY_TICKS * PERIODIC_RESORT_DAYS;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
293 sl->flags &= ~SL_RESORT;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
294 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
295
8016
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
296 /**
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
297 * Fuction called when any WindowEvent occurs for PlayerStations window
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
298 *
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
299 * @param w pointer to the PlayerStations window
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
300 * @param e pointer to window event
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
301 */
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
302 static void PlayerStationsWndProc(Window *w, WindowEvent *e)
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
303 {
5587
c44c070c5032 (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium <rubidium@openttd.org>
parents: 5584
diff changeset
304 const PlayerID owner = (PlayerID)w->window_number;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
305 static byte facilities = FACIL_TRAIN | FACIL_TRUCK_STOP | FACIL_BUS_STOP | FACIL_AIRPORT | FACIL_DOCK;
5608
5dcef0df6a67 (svn r8065) -Feature: The station list does now remember the sort settings
celestar <celestar@openttd.org>
parents: 5587
diff changeset
306 static Listing station_sort = {0, 0};
6271
56a8bb763a87 (svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138 <peter1138@openttd.org>
parents: 6260
diff changeset
307 static bool include_empty = true;
5608
5dcef0df6a67 (svn r8065) -Feature: The station list does now remember the sort settings
celestar <celestar@openttd.org>
parents: 5587
diff changeset
308
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
309 plstations_d *sl = &WP(w, plstations_d);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
310
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
311 switch (e->event) {
8016
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
312 case WE_CREATE:
6285
3e2faa1f190c (svn r9104) -Fix(r9080, r9081): UINT32_MAX is undefined on MSVC, std::numeric_limits doesn't exist in gcc 2.95 (MorphOS), so back to tree and use ~0 instead (peter1138)
KUDr <KUDr@openttd.org>
parents: 6272
diff changeset
313 if (_cargo_filter == _cargo_filter_max) _cargo_filter = _cargo_mask;
6271
56a8bb763a87 (svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138 <peter1138@openttd.org>
parents: 6260
diff changeset
314
6202
eb0fdb88a922 (svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138 <peter1138@openttd.org>
parents: 6122
diff changeset
315 for (uint i = 0; i < 5; i++) {
8016
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
316 if (HasBit(facilities, i)) w->LowerWidget(i + SLW_TRAIN);
6202
eb0fdb88a922 (svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138 <peter1138@openttd.org>
parents: 6122
diff changeset
317 }
8016
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
318 w->SetWidgetLoweredState(SLW_FACILALL, facilities == (FACIL_TRAIN | FACIL_TRUCK_STOP | FACIL_BUS_STOP | FACIL_AIRPORT | FACIL_DOCK));
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
319 w->SetWidgetLoweredState(SLW_CARGOALL, _cargo_filter == _cargo_mask && include_empty);
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
320 w->SetWidgetLoweredState(SLW_NOCARGOWAITING, 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
321
6202
eb0fdb88a922 (svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138 <peter1138@openttd.org>
parents: 6122
diff changeset
322 sl->sort_list = NULL;
eb0fdb88a922 (svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138 <peter1138@openttd.org>
parents: 6122
diff changeset
323 sl->flags = SL_REBUILD;
eb0fdb88a922 (svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138 <peter1138@openttd.org>
parents: 6122
diff changeset
324 sl->sort_type = station_sort.criteria;
eb0fdb88a922 (svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138 <peter1138@openttd.org>
parents: 6122
diff changeset
325 if (station_sort.order) sl->flags |= SL_ORDER;
8016
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
326
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
327 /* set up resort timer */
6202
eb0fdb88a922 (svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138 <peter1138@openttd.org>
parents: 6122
diff changeset
328 sl->resort_timer = DAY_TICKS * PERIODIC_RESORT_DAYS;
eb0fdb88a922 (svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138 <peter1138@openttd.org>
parents: 6122
diff changeset
329 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
330
6202
eb0fdb88a922 (svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138 <peter1138@openttd.org>
parents: 6122
diff changeset
331 case WE_PAINT: {
6271
56a8bb763a87 (svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138 <peter1138@openttd.org>
parents: 6260
diff changeset
332 BuildStationsList(sl, owner, facilities, _cargo_filter, include_empty);
6202
eb0fdb88a922 (svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138 <peter1138@openttd.org>
parents: 6122
diff changeset
333 SortStationsList(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
334
6202
eb0fdb88a922 (svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138 <peter1138@openttd.org>
parents: 6122
diff changeset
335 SetVScrollCount(w, sl->list_length);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
336
6202
eb0fdb88a922 (svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138 <peter1138@openttd.org>
parents: 6122
diff changeset
337 /* draw widgets, with player's name in the caption */
7058
74d401c66902 (svn r10323) -Codechange: reference company name, number and player (president) name
peter1138 <peter1138@openttd.org>
parents: 7010
diff changeset
338 SetDParam(0, owner);
74d401c66902 (svn r10323) -Codechange: reference company name, number and player (president) name
peter1138 <peter1138@openttd.org>
parents: 7010
diff changeset
339 SetDParam(1, w->vscroll.count);
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
340
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
341 /* Set text of sort by dropdown */
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
342 w->widget[SLW_SORTDROPBTN].data = _station_sort_listing[sl->sort_type];
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
343
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
344 DrawWindowWidgets(w);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
345
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
346 /* draw arrow pointing up/down for ascending/descending sorting */
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
347 DoDrawString(sl->flags & SL_ORDER ? DOWNARROW : UPARROW, 69, 26, 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
348
6202
eb0fdb88a922 (svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138 <peter1138@openttd.org>
parents: 6122
diff changeset
349 int cg_ofst;
eb0fdb88a922 (svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138 <peter1138@openttd.org>
parents: 6122
diff changeset
350 int x = 89;
eb0fdb88a922 (svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138 <peter1138@openttd.org>
parents: 6122
diff changeset
351 int y = 14;
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
352 int xb = 2; ///< offset from left of widget
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
353
6271
56a8bb763a87 (svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138 <peter1138@openttd.org>
parents: 6260
diff changeset
354 uint i = 0;
56a8bb763a87 (svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138 <peter1138@openttd.org>
parents: 6260
diff changeset
355 for (CargoID c = 0; c < NUM_CARGO; c++) {
56a8bb763a87 (svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138 <peter1138@openttd.org>
parents: 6260
diff changeset
356 const CargoSpec *cs = GetCargo(c);
56a8bb763a87 (svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138 <peter1138@openttd.org>
parents: 6260
diff changeset
357 if (!cs->IsValid()) continue;
56a8bb763a87 (svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138 <peter1138@openttd.org>
parents: 6260
diff changeset
358
7928
4e8dfd103163 (svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13 <skidd13@openttd.org>
parents: 7886
diff changeset
359 cg_ofst = HasBit(_cargo_filter, c) ? 2 : 1;
6271
56a8bb763a87 (svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138 <peter1138@openttd.org>
parents: 6260
diff changeset
360 GfxFillRect(x + cg_ofst, y + cg_ofst, x + cg_ofst + 10 , y + cg_ofst + 7, cs->rating_colour);
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
361 DrawStringCentered(x + 6 + cg_ofst, y + cg_ofst, 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
362 x += 14;
6271
56a8bb763a87 (svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138 <peter1138@openttd.org>
parents: 6260
diff changeset
363 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
364 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
365
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
366 x += 6;
8016
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
367 cg_ofst = w->IsWidgetLowered(SLW_NOCARGOWAITING) ? 2 : 1;
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
368 DrawStringCentered(x + cg_ofst, y + cg_ofst, STR_ABBREV_NONE, 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
369 x += 14;
8016
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
370 cg_ofst = w->IsWidgetLowered(SLW_CARGOALL) ? 2 : 1;
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
371 DrawStringCentered(x + cg_ofst, y + cg_ofst, STR_ABBREV_ALL, 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
372
8016
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
373 cg_ofst = w->IsWidgetLowered(SLW_FACILALL) ? 2 : 1;
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
374 DrawString(71 + cg_ofst, y + cg_ofst, STR_ABBREV_ALL, 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
375
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
376 if (w->vscroll.count == 0) { // player has no stations
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
377 DrawString(xb, 40, STR_304A_NONE, TC_FROMSTRING);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
378 return;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
379 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
380
6202
eb0fdb88a922 (svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138 <peter1138@openttd.org>
parents: 6122
diff changeset
381 int max = min(w->vscroll.pos + w->vscroll.cap, sl->list_length);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
382 y = 40; // start of the list-widget
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
383
6202
eb0fdb88a922 (svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138 <peter1138@openttd.org>
parents: 6122
diff changeset
384 for (int i = w->vscroll.pos; i < max; ++i) { // do until max number of stations of 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
385 const Station *st = sl->sort_list[i];
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
386 int x;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
387
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
388 assert(st->xy != 0);
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
389
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
390 /* Do not do the complex check HasStationInUse here, it may be even false
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
391 * when the order had been removed and the station list hasn't been removed yet */
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
392 assert(st->owner == owner || (st->owner == OWNER_NONE && !st->IsBuoy()));
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
393
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
394 SetDParam(0, st->index);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
395 SetDParam(1, st->facilities);
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
396 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
397
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
398 /* show cargo waiting and station ratings */
6350
8132258640be (svn r9388) -Codechange: variable scope and type, and standardify all CargoID loops.
peter1138 <peter1138@openttd.org>
parents: 6297
diff changeset
399 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
400 if (!st->goods[j].cargo.Empty()) {
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
401 StationsWndShowStationRating(x, y, j, st->goods[j].cargo.Count(), st->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
402 x += 20;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
403 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
404 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
405 y += 10;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
406 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
407 break;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
408 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
409
6202
eb0fdb88a922 (svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138 <peter1138@openttd.org>
parents: 6122
diff changeset
410 case WE_CLICK:
eb0fdb88a922 (svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138 <peter1138@openttd.org>
parents: 6122
diff changeset
411 switch (e->we.click.widget) {
8016
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
412 case SLW_LIST: {
6202
eb0fdb88a922 (svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138 <peter1138@openttd.org>
parents: 6122
diff changeset
413 uint32 id_v = (e->we.click.pt.y - 41) / 10;
eb0fdb88a922 (svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138 <peter1138@openttd.org>
parents: 6122
diff changeset
414
eb0fdb88a922 (svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138 <peter1138@openttd.org>
parents: 6122
diff changeset
415 if (id_v >= w->vscroll.cap) return; // click out of bounds
eb0fdb88a922 (svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138 <peter1138@openttd.org>
parents: 6122
diff changeset
416
eb0fdb88a922 (svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138 <peter1138@openttd.org>
parents: 6122
diff changeset
417 id_v += w->vscroll.pos;
eb0fdb88a922 (svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138 <peter1138@openttd.org>
parents: 6122
diff changeset
418
eb0fdb88a922 (svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138 <peter1138@openttd.org>
parents: 6122
diff changeset
419 if (id_v >= sl->list_length) return; // click out of list bound
eb0fdb88a922 (svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138 <peter1138@openttd.org>
parents: 6122
diff changeset
420
eb0fdb88a922 (svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138 <peter1138@openttd.org>
parents: 6122
diff changeset
421 const Station *st = sl->sort_list[id_v];
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
422 /* do not check HasStationInUse - it is slow and may be invalid */
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
423 assert(st->owner == owner || (st->owner == OWNER_NONE && !st->IsBuoy()));
6202
eb0fdb88a922 (svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138 <peter1138@openttd.org>
parents: 6122
diff changeset
424 ScrollMainWindowToTile(st->xy);
eb0fdb88a922 (svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138 <peter1138@openttd.org>
parents: 6122
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 }
6202
eb0fdb88a922 (svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138 <peter1138@openttd.org>
parents: 6122
diff changeset
427
8016
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
428 case SLW_TRAIN:
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
429 case SLW_TRUCK:
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
430 case SLW_BUS:
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
431 case SLW_AIRPLANE:
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
432 case SLW_SHIP:
6202
eb0fdb88a922 (svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138 <peter1138@openttd.org>
parents: 6122
diff changeset
433 if (_ctrl_pressed) {
8016
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
434 ToggleBit(facilities, e->we.click.widget - SLW_TRAIN);
7997
d109780d515b (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium <rubidium@openttd.org>
parents: 7932
diff changeset
435 w->ToggleWidgetLoweredState(e->we.click.widget);
6202
eb0fdb88a922 (svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138 <peter1138@openttd.org>
parents: 6122
diff changeset
436 } else {
8005
ee6d40f79c32 (svn r11564) -Codechange: Increase the usage of the for_each_bit macro and rename it fitting to the naming style
skidd13 <skidd13@openttd.org>
parents: 7997
diff changeset
437 uint i;
ee6d40f79c32 (svn r11564) -Codechange: Increase the usage of the for_each_bit macro and rename it fitting to the naming style
skidd13 <skidd13@openttd.org>
parents: 7997
diff changeset
438 FOR_EACH_SET_BIT(i, facilities) {
8016
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
439 w->RaiseWidget(i + SLW_TRAIN);
6202
eb0fdb88a922 (svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138 <peter1138@openttd.org>
parents: 6122
diff changeset
440 }
8016
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
441 SetBit(facilities, e->we.click.widget - SLW_TRAIN);
7997
d109780d515b (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium <rubidium@openttd.org>
parents: 7932
diff changeset
442 w->LowerWidget(e->we.click.widget);
6202
eb0fdb88a922 (svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138 <peter1138@openttd.org>
parents: 6122
diff changeset
443 }
8016
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
444 w->SetWidgetLoweredState(SLW_FACILALL, facilities == (FACIL_TRAIN | FACIL_TRUCK_STOP | FACIL_BUS_STOP | FACIL_AIRPORT | FACIL_DOCK));
6202
eb0fdb88a922 (svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138 <peter1138@openttd.org>
parents: 6122
diff changeset
445 sl->flags |= SL_REBUILD;
eb0fdb88a922 (svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138 <peter1138@openttd.org>
parents: 6122
diff changeset
446 SetWindowDirty(w);
eb0fdb88a922 (svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138 <peter1138@openttd.org>
parents: 6122
diff changeset
447 break;
eb0fdb88a922 (svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138 <peter1138@openttd.org>
parents: 6122
diff changeset
448
8016
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
449 case SLW_FACILALL:
6202
eb0fdb88a922 (svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138 <peter1138@openttd.org>
parents: 6122
diff changeset
450 for (uint i = 0; i < 5; i++) {
8016
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
451 w->LowerWidget(i + SLW_TRAIN);
6202
eb0fdb88a922 (svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138 <peter1138@openttd.org>
parents: 6122
diff changeset
452 }
8016
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
453 w->LowerWidget(SLW_FACILALL);
6202
eb0fdb88a922 (svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138 <peter1138@openttd.org>
parents: 6122
diff changeset
454
eb0fdb88a922 (svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138 <peter1138@openttd.org>
parents: 6122
diff changeset
455 facilities = FACIL_TRAIN | FACIL_TRUCK_STOP | FACIL_BUS_STOP | FACIL_AIRPORT | FACIL_DOCK;
eb0fdb88a922 (svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138 <peter1138@openttd.org>
parents: 6122
diff changeset
456 sl->flags |= SL_REBUILD;
eb0fdb88a922 (svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138 <peter1138@openttd.org>
parents: 6122
diff changeset
457 SetWindowDirty(w);
eb0fdb88a922 (svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138 <peter1138@openttd.org>
parents: 6122
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
8016
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
460 case SLW_CARGOALL: {
6271
56a8bb763a87 (svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138 <peter1138@openttd.org>
parents: 6260
diff changeset
461 uint i = 0;
56a8bb763a87 (svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138 <peter1138@openttd.org>
parents: 6260
diff changeset
462 for (CargoID c = 0; c < NUM_CARGO; c++) {
56a8bb763a87 (svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138 <peter1138@openttd.org>
parents: 6260
diff changeset
463 if (!GetCargo(c)->IsValid()) continue;
8016
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
464 w->LowerWidget(i + SLW_CARGOSTART);
6271
56a8bb763a87 (svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138 <peter1138@openttd.org>
parents: 6260
diff changeset
465 i++;
6202
eb0fdb88a922 (svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138 <peter1138@openttd.org>
parents: 6122
diff changeset
466 }
8016
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
467 w->LowerWidget(SLW_NOCARGOWAITING);
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
468 w->LowerWidget(SLW_CARGOALL);
6202
eb0fdb88a922 (svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138 <peter1138@openttd.org>
parents: 6122
diff changeset
469
6271
56a8bb763a87 (svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138 <peter1138@openttd.org>
parents: 6260
diff changeset
470 _cargo_filter = _cargo_mask;
56a8bb763a87 (svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138 <peter1138@openttd.org>
parents: 6260
diff changeset
471 include_empty = true;
6202
eb0fdb88a922 (svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138 <peter1138@openttd.org>
parents: 6122
diff changeset
472 sl->flags |= SL_REBUILD;
eb0fdb88a922 (svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138 <peter1138@openttd.org>
parents: 6122
diff changeset
473 SetWindowDirty(w);
eb0fdb88a922 (svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138 <peter1138@openttd.org>
parents: 6122
diff changeset
474 break;
6271
56a8bb763a87 (svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138 <peter1138@openttd.org>
parents: 6260
diff changeset
475 }
6202
eb0fdb88a922 (svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138 <peter1138@openttd.org>
parents: 6122
diff changeset
476
8016
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
477 case SLW_SORTBY: // flip sorting method asc/desc
6202
eb0fdb88a922 (svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138 <peter1138@openttd.org>
parents: 6122
diff changeset
478 sl->flags ^= SL_ORDER; //DESC-flag
7928
4e8dfd103163 (svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13 <skidd13@openttd.org>
parents: 7886
diff changeset
479 station_sort.order = HasBit(sl->flags, 0);
6202
eb0fdb88a922 (svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138 <peter1138@openttd.org>
parents: 6122
diff changeset
480 sl->flags |= SL_RESORT;
eb0fdb88a922 (svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138 <peter1138@openttd.org>
parents: 6122
diff changeset
481 w->flags4 |= 5 << WF_TIMEOUT_SHL;
8016
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
482 w->LowerWidget(SLW_SORTBY);
6202
eb0fdb88a922 (svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138 <peter1138@openttd.org>
parents: 6122
diff changeset
483 SetWindowDirty(w);
eb0fdb88a922 (svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138 <peter1138@openttd.org>
parents: 6122
diff changeset
484 break;
eb0fdb88a922 (svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138 <peter1138@openttd.org>
parents: 6122
diff changeset
485
8016
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
486 case SLW_SORTDROPBTN: // select sorting criteria dropdown menu
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
487 ShowDropDownMenu(w, _station_sort_listing, sl->sort_type, SLW_SORTDROPBTN, 0, 0);
6202
eb0fdb88a922 (svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138 <peter1138@openttd.org>
parents: 6122
diff changeset
488 break;
eb0fdb88a922 (svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138 <peter1138@openttd.org>
parents: 6122
diff changeset
489
8016
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
490 case 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
491 if (_ctrl_pressed) {
56a8bb763a87 (svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138 <peter1138@openttd.org>
parents: 6260
diff changeset
492 include_empty = !include_empty;
8016
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
493 w->ToggleWidgetLoweredState(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
494 } else {
8016
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
495 for (uint i = SLW_CARGOSTART; i < w->widget_count; i++) {
7997
d109780d515b (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium <rubidium@openttd.org>
parents: 7932
diff changeset
496 w->RaiseWidget(i);
6271
56a8bb763a87 (svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138 <peter1138@openttd.org>
parents: 6260
diff changeset
497 }
56a8bb763a87 (svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138 <peter1138@openttd.org>
parents: 6260
diff changeset
498
56a8bb763a87 (svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138 <peter1138@openttd.org>
parents: 6260
diff changeset
499 _cargo_filter = 0;
56a8bb763a87 (svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138 <peter1138@openttd.org>
parents: 6260
diff changeset
500 include_empty = true;
56a8bb763a87 (svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138 <peter1138@openttd.org>
parents: 6260
diff changeset
501
8016
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
502 w->LowerWidget(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
503 }
56a8bb763a87 (svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138 <peter1138@openttd.org>
parents: 6260
diff changeset
504 sl->flags |= SL_REBUILD;
8016
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
505 w->SetWidgetLoweredState(SLW_CARGOALL, _cargo_filter == _cargo_mask && 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
506 SetWindowDirty(w);
56a8bb763a87 (svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138 <peter1138@openttd.org>
parents: 6260
diff changeset
507 break;
56a8bb763a87 (svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138 <peter1138@openttd.org>
parents: 6260
diff changeset
508
6202
eb0fdb88a922 (svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138 <peter1138@openttd.org>
parents: 6122
diff changeset
509 default:
8016
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
510 if (e->we.click.widget >= SLW_CARGOSTART) { // change cargo_filter
6271
56a8bb763a87 (svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138 <peter1138@openttd.org>
parents: 6260
diff changeset
511 /* Determine the selected cargo type */
56a8bb763a87 (svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138 <peter1138@openttd.org>
parents: 6260
diff changeset
512 CargoID c;
56a8bb763a87 (svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138 <peter1138@openttd.org>
parents: 6260
diff changeset
513 int i = 0;
56a8bb763a87 (svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138 <peter1138@openttd.org>
parents: 6260
diff changeset
514 for (c = 0; c < NUM_CARGO; c++) {
56a8bb763a87 (svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138 <peter1138@openttd.org>
parents: 6260
diff changeset
515 if (!GetCargo(c)->IsValid()) continue;
8016
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
516 if (e->we.click.widget - SLW_CARGOSTART == i) break;
6271
56a8bb763a87 (svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138 <peter1138@openttd.org>
parents: 6260
diff changeset
517 i++;
56a8bb763a87 (svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138 <peter1138@openttd.org>
parents: 6260
diff changeset
518 }
56a8bb763a87 (svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138 <peter1138@openttd.org>
parents: 6260
diff changeset
519
6202
eb0fdb88a922 (svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138 <peter1138@openttd.org>
parents: 6122
diff changeset
520 if (_ctrl_pressed) {
7932
712f252f0d4d (svn r11485) -Codechange: Remove the doubled function ToggleBitT and rename the remaining to fit with the naming style
skidd13 <skidd13@openttd.org>
parents: 7931
diff changeset
521 ToggleBit(_cargo_filter, c);
7997
d109780d515b (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium <rubidium@openttd.org>
parents: 7932
diff changeset
522 w->ToggleWidgetLoweredState(e->we.click.widget);
6202
eb0fdb88a922 (svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138 <peter1138@openttd.org>
parents: 6122
diff changeset
523 } else {
8016
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
524 for (uint i = SLW_CARGOSTART; i < w->widget_count; i++) {
7997
d109780d515b (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium <rubidium@openttd.org>
parents: 7932
diff changeset
525 w->RaiseWidget(i);
6202
eb0fdb88a922 (svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138 <peter1138@openttd.org>
parents: 6122
diff changeset
526 }
8016
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
527 w->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;
56a8bb763a87 (svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138 <peter1138@openttd.org>
parents: 6260
diff changeset
530 include_empty = false;
56a8bb763a87 (svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138 <peter1138@openttd.org>
parents: 6260
diff changeset
531
7931
44ff7a6d801f (svn r11484) -Codechange: Remove the doubled function SetBitT and rename the remaining to fit with the naming style
skidd13 <skidd13@openttd.org>
parents: 7928
diff changeset
532 SetBit(_cargo_filter, c);
7997
d109780d515b (svn r11555) -Codechange: use the new members introduced in r11551.
rubidium <rubidium@openttd.org>
parents: 7932
diff changeset
533 w->LowerWidget(e->we.click.widget);
6202
eb0fdb88a922 (svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138 <peter1138@openttd.org>
parents: 6122
diff changeset
534 }
eb0fdb88a922 (svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138 <peter1138@openttd.org>
parents: 6122
diff changeset
535 sl->flags |= SL_REBUILD;
8016
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
536 w->SetWidgetLoweredState(SLW_CARGOALL, _cargo_filter == _cargo_mask && include_empty);
6202
eb0fdb88a922 (svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138 <peter1138@openttd.org>
parents: 6122
diff changeset
537 SetWindowDirty(w);
eb0fdb88a922 (svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138 <peter1138@openttd.org>
parents: 6122
diff changeset
538 }
eb0fdb88a922 (svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138 <peter1138@openttd.org>
parents: 6122
diff changeset
539 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
540 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
541 break;
6202
eb0fdb88a922 (svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138 <peter1138@openttd.org>
parents: 6122
diff changeset
542
8016
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
543 case WE_DROPDOWN_SELECT: // we have selected a dropdown item in the list
6202
eb0fdb88a922 (svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138 <peter1138@openttd.org>
parents: 6122
diff changeset
544 if (sl->sort_type != e->we.dropdown.index) {
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
545 /* value has changed -> resort */
6202
eb0fdb88a922 (svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138 <peter1138@openttd.org>
parents: 6122
diff changeset
546 sl->sort_type = e->we.dropdown.index;
eb0fdb88a922 (svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138 <peter1138@openttd.org>
parents: 6122
diff changeset
547 station_sort.criteria = sl->sort_type;
eb0fdb88a922 (svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138 <peter1138@openttd.org>
parents: 6122
diff changeset
548 sl->flags |= SL_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
549 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
550 SetWindowDirty(w);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
551 break;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
552
6202
eb0fdb88a922 (svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138 <peter1138@openttd.org>
parents: 6122
diff changeset
553 case WE_TICK:
8179
a0879dc1b54d (svn r11742) -Codechange [FS#1319]: Run window tick events when paused, so that news pop-ups and the about window still progress. For other windows the events are ignored when paused.
peter1138 <peter1138@openttd.org>
parents: 8144
diff changeset
554 if (_pause_game != 0) break;
6202
eb0fdb88a922 (svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138 <peter1138@openttd.org>
parents: 6122
diff changeset
555 if (--sl->resort_timer == 0) {
eb0fdb88a922 (svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138 <peter1138@openttd.org>
parents: 6122
diff changeset
556 DEBUG(misc, 3, "Periodic rebuild station list player %d", owner);
eb0fdb88a922 (svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138 <peter1138@openttd.org>
parents: 6122
diff changeset
557 sl->resort_timer = DAY_TICKS * PERIODIC_RESORT_DAYS;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
558 sl->flags |= SL_REBUILD;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
559 SetWindowDirty(w);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
560 }
6202
eb0fdb88a922 (svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138 <peter1138@openttd.org>
parents: 6122
diff changeset
561 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
562
6202
eb0fdb88a922 (svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138 <peter1138@openttd.org>
parents: 6122
diff changeset
563 case WE_TIMEOUT:
8016
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
564 w->RaiseWidget(SLW_SORTBY);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
565 SetWindowDirty(w);
6202
eb0fdb88a922 (svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138 <peter1138@openttd.org>
parents: 6122
diff changeset
566 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
567
6202
eb0fdb88a922 (svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138 <peter1138@openttd.org>
parents: 6122
diff changeset
568 case WE_RESIZE:
eb0fdb88a922 (svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138 <peter1138@openttd.org>
parents: 6122
diff changeset
569 w->vscroll.cap += e->we.sizing.diff.y / 10;
eb0fdb88a922 (svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138 <peter1138@openttd.org>
parents: 6122
diff changeset
570 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
571 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
572 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
573
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
574 static const Widget _player_stations_widgets[] = {
8016
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
575 { 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
576 { 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
577 { 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
578 { 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
579 { 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
580 { 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
581
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
582 { 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
583 { 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
584 { 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
585 { 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
586 { 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
587 { 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
588
8016
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
589 { 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
590 { 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
591 { 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
592 { 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
593
8016
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
594 { 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
595 { 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
596 { 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
597 { 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
598 };
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
599
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
600 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
601 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
602 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
603 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
604 _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
605 PlayerStationsWndProc
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
606 };
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
607
8016
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
608 /**
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
609 * 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
610 *
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
611 * @param player player whose stations' list show
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
612 */
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
613 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
614 {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
615 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
616
6202
eb0fdb88a922 (svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138 <peter1138@openttd.org>
parents: 6122
diff changeset
617 Window *w = AllocateWindowDescFront(&_player_stations_desc, player);
eb0fdb88a922 (svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138 <peter1138@openttd.org>
parents: 6122
diff changeset
618 if (w == NULL) return;
eb0fdb88a922 (svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138 <peter1138@openttd.org>
parents: 6122
diff changeset
619
eb0fdb88a922 (svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138 <peter1138@openttd.org>
parents: 6122
diff changeset
620 w->caption_color = (byte)w->window_number;
eb0fdb88a922 (svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138 <peter1138@openttd.org>
parents: 6122
diff changeset
621 w->vscroll.cap = 12;
eb0fdb88a922 (svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138 <peter1138@openttd.org>
parents: 6122
diff changeset
622 w->resize.step_height = 10;
eb0fdb88a922 (svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138 <peter1138@openttd.org>
parents: 6122
diff changeset
623 w->resize.height = w->height - 10 * 7; // minimum if 5 in the list
6271
56a8bb763a87 (svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138 <peter1138@openttd.org>
parents: 6260
diff changeset
624
56a8bb763a87 (svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138 <peter1138@openttd.org>
parents: 6260
diff changeset
625 /* Add cargo filter buttons */
56a8bb763a87 (svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138 <peter1138@openttd.org>
parents: 6260
diff changeset
626 uint num_active = 0;
56a8bb763a87 (svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138 <peter1138@openttd.org>
parents: 6260
diff changeset
627 for (CargoID c = 0; c < NUM_CARGO; c++) {
56a8bb763a87 (svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138 <peter1138@openttd.org>
parents: 6260
diff changeset
628 if (GetCargo(c)->IsValid()) num_active++;
56a8bb763a87 (svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138 <peter1138@openttd.org>
parents: 6260
diff changeset
629 }
56a8bb763a87 (svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138 <peter1138@openttd.org>
parents: 6260
diff changeset
630
56a8bb763a87 (svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138 <peter1138@openttd.org>
parents: 6260
diff changeset
631 w->widget_count += num_active;
56a8bb763a87 (svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138 <peter1138@openttd.org>
parents: 6260
diff changeset
632 w->widget = ReallocT(w->widget, w->widget_count + 1);
56a8bb763a87 (svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138 <peter1138@openttd.org>
parents: 6260
diff changeset
633 w->widget[w->widget_count].type = WWT_LAST;
56a8bb763a87 (svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138 <peter1138@openttd.org>
parents: 6260
diff changeset
634
56a8bb763a87 (svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138 <peter1138@openttd.org>
parents: 6260
diff changeset
635 uint i = 0;
56a8bb763a87 (svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138 <peter1138@openttd.org>
parents: 6260
diff changeset
636 for (CargoID c = 0; c < NUM_CARGO; c++) {
56a8bb763a87 (svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138 <peter1138@openttd.org>
parents: 6260
diff changeset
637 if (!GetCargo(c)->IsValid()) continue;
56a8bb763a87 (svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138 <peter1138@openttd.org>
parents: 6260
diff changeset
638
8016
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
639 Widget *wi = &w->widget[SLW_CARGOSTART + i];
6271
56a8bb763a87 (svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138 <peter1138@openttd.org>
parents: 6260
diff changeset
640 wi->type = WWT_PANEL;
56a8bb763a87 (svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138 <peter1138@openttd.org>
parents: 6260
diff changeset
641 wi->display_flags = RESIZE_NONE;
56a8bb763a87 (svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138 <peter1138@openttd.org>
parents: 6260
diff changeset
642 wi->color = 14;
56a8bb763a87 (svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138 <peter1138@openttd.org>
parents: 6260
diff changeset
643 wi->left = 89 + i * 14;
56a8bb763a87 (svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138 <peter1138@openttd.org>
parents: 6260
diff changeset
644 wi->right = wi->left + 13;
56a8bb763a87 (svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138 <peter1138@openttd.org>
parents: 6260
diff changeset
645 wi->top = 14;
56a8bb763a87 (svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138 <peter1138@openttd.org>
parents: 6260
diff changeset
646 wi->bottom = 24;
56a8bb763a87 (svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138 <peter1138@openttd.org>
parents: 6260
diff changeset
647 wi->data = 0;
56a8bb763a87 (svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138 <peter1138@openttd.org>
parents: 6260
diff changeset
648 wi->tooltips = STR_USE_CTRL_TO_SELECT_MORE;
56a8bb763a87 (svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138 <peter1138@openttd.org>
parents: 6260
diff changeset
649
8016
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
650 if (HasBit(_cargo_filter, c)) w->LowerWidget(SLW_CARGOSTART + i);
6271
56a8bb763a87 (svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138 <peter1138@openttd.org>
parents: 6260
diff changeset
651 i++;
56a8bb763a87 (svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138 <peter1138@openttd.org>
parents: 6260
diff changeset
652 }
56a8bb763a87 (svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138 <peter1138@openttd.org>
parents: 6260
diff changeset
653
8016
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
654 w->widget[SLW_NOCARGOWAITING].left += num_active * 14;
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
655 w->widget[SLW_NOCARGOWAITING].right += num_active * 14;
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
656 w->widget[SLW_CARGOALL].left += num_active * 14;
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
657 w->widget[SLW_CARGOALL].right += num_active * 14;
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
658 w->widget[SLW_PAN_RIGHT].left += num_active * 14;
6271
56a8bb763a87 (svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138 <peter1138@openttd.org>
parents: 6260
diff changeset
659
56a8bb763a87 (svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138 <peter1138@openttd.org>
parents: 6260
diff changeset
660 if (num_active > 15) {
56a8bb763a87 (svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138 <peter1138@openttd.org>
parents: 6260
diff changeset
661 /* Resize and fix the minimum width, if necessary */
56a8bb763a87 (svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138 <peter1138@openttd.org>
parents: 6260
diff changeset
662 ResizeWindow(w, (num_active - 15) * 14, 0);
56a8bb763a87 (svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138 <peter1138@openttd.org>
parents: 6260
diff changeset
663 w->resize.width = w->width;
56a8bb763a87 (svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138 <peter1138@openttd.org>
parents: 6260
diff changeset
664 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
665 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
666
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
667 static const Widget _station_view_expanded_widgets[] = {
8016
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
668 { WWT_CLOSEBOX, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, // SVW_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
669 { WWT_CAPTION, RESIZE_NONE, 14, 11, 236, 0, 13, STR_300A_0, 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
670 { WWT_STICKYBOX, RESIZE_NONE, 14, 237, 248, 0, 13, 0x0, STR_STICKY_BUTTON},
8016
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
671 { WWT_PANEL, RESIZE_NONE, 14, 0, 236, 14, 65, 0x0, STR_NULL}, // SVW_WAITING
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
672 { WWT_SCROLLBAR, RESIZE_NONE, 14, 237, 248, 14, 65, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST},
8016
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
673 { WWT_EMPTY, RESIZE_NONE, 0, 0, 0, 0, 0, 0x0, STR_NULL}, // SVW_ACCEPTLIST
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
674 { WWT_PANEL, RESIZE_NONE, 14, 0, 248, 66, 197, 0x0, STR_NULL}, // SVW_RATINGLIST
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
675 { WWT_PUSHTXTBTN, RESIZE_NONE, 14, 0, 63, 198, 209, STR_00E4_LOCATION, STR_3053_CENTER_MAIN_VIEW_ON_STATION}, // SVW_LOCATION
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
676 { WWT_PUSHTXTBTN, RESIZE_NONE, 14, 64, 128, 198, 209, STR_3033_ACCEPTS, STR_3056_SHOW_LIST_OF_ACCEPTED_CARGO}, // SVW_ACCEPTS
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
677 { WWT_PUSHTXTBTN, RESIZE_NONE, 14, 129, 192, 198, 209, STR_0130_RENAME, STR_3055_CHANGE_NAME_OF_STATION}, // SVW_RENAME
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
678 { WWT_PUSHTXTBTN, RESIZE_NONE, 14, 193, 206, 198, 209, STR_TRAIN, STR_SCHEDULED_TRAINS_TIP }, // SVW_TRAINS
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
679 { WWT_PUSHTXTBTN, RESIZE_NONE, 14, 207, 220, 198, 209, STR_LORRY, STR_SCHEDULED_ROAD_VEHICLES_TIP }, // SVW_ROADVEHS
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
680 { WWT_PUSHTXTBTN, RESIZE_NONE, 14, 221, 234, 198, 209, STR_PLANE, STR_SCHEDULED_AIRCRAFT_TIP }, // SVW_PLANES
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
681 { WWT_PUSHTXTBTN, RESIZE_NONE, 14, 235, 248, 198, 209, STR_SHIP, STR_SCHEDULED_SHIPS_TIP }, // SVW_SHIPS
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
682 { 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
683 };
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
684
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
685 static const Widget _station_view_widgets[] = {
8016
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
686 { WWT_CLOSEBOX, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, // SVW_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
687 { WWT_CAPTION, RESIZE_NONE, 14, 11, 236, 0, 13, STR_300A_0, 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
688 { WWT_STICKYBOX, RESIZE_NONE, 14, 237, 248, 0, 13, 0x0, STR_STICKY_BUTTON},
8016
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
689 { WWT_PANEL, RESIZE_NONE, 14, 0, 236, 14, 65, 0x0, STR_NULL}, // SVW_WAITING
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
690 { WWT_SCROLLBAR, RESIZE_NONE, 14, 237, 248, 14, 65, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST},
8016
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
691 { WWT_PANEL, RESIZE_NONE, 14, 0, 248, 66, 97, 0x0, STR_NULL}, // SVW_ACCEPTLIST
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
692 { WWT_EMPTY, RESIZE_NONE, 0, 0, 0, 0, 0, 0x0, STR_NULL}, // SVW_RATINGLIST
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
693 { WWT_PUSHTXTBTN, RESIZE_NONE, 14, 0, 63, 98, 109, STR_00E4_LOCATION, STR_3053_CENTER_MAIN_VIEW_ON_STATION}, // SVW_LOCATION
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
694 { WWT_PUSHTXTBTN, RESIZE_NONE, 14, 64, 128, 98, 109, STR_3032_RATINGS, STR_3054_SHOW_STATION_RATINGS}, // SVW_RATINGS
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
695 { WWT_PUSHTXTBTN, RESIZE_NONE, 14, 129, 192, 98, 109, STR_0130_RENAME, STR_3055_CHANGE_NAME_OF_STATION}, // SVW_RENAME
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
696 { WWT_PUSHTXTBTN, RESIZE_NONE, 14, 193, 206, 98, 109, STR_TRAIN, STR_SCHEDULED_TRAINS_TIP }, // SVW_TRAINS
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
697 { WWT_PUSHTXTBTN, RESIZE_NONE, 14, 207, 220, 98, 109, STR_LORRY, STR_SCHEDULED_ROAD_VEHICLES_TIP }, // SVW_ROADVEHS
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
698 { WWT_PUSHTXTBTN, RESIZE_NONE, 14, 221, 234, 98, 109, STR_PLANE, STR_SCHEDULED_AIRCRAFT_TIP }, // SVW_PLANES
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
699 { WWT_PUSHTXTBTN, RESIZE_NONE, 14, 235, 248, 98, 109, STR_SHIP, STR_SCHEDULED_SHIPS_TIP }, // SVW_SHIPS
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
700 { 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
701 };
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
702
8016
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
703 /**
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
704 * Draws icons of wainting cargo in the StationView window
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
705 *
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
706 * @param i type of cargo
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
707 * @param waiting number of wainting units
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
708 * @param x x on-screen coordinate where to start with drawing icons
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
709 * @param y y coordinate
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
710 */
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
711 static void DrawCargoIcons(CargoID i, uint waiting, int x, int 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
712 {
8016
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
713 uint num = min((waiting + 5) / 10, 23); // maximum is 23 icons so it won't overflow
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
714 if (num == 0) return;
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
715
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
716 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
717 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
718
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
719 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
720 /* 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
721 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
722 } 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
723 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
724 }
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
725
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
726 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
727
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
728 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
729 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
730 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
731 } 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
732 }
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
733
8016
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
734 /**
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
735 * Redraws whole StationView window
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
736 *
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
737 * @param w pointer to window
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
738 */
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
739 static void DrawStationViewWindow(Window *w)
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
740 {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
741 StationID station_id = w->window_number;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
742 const Station* st = GetStation(station_id);
8016
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
743 uint num; ///< number of cargo types waiting at station
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
744 int x, y; ///< coordinates used for printing waiting/accepted/rating of cargo
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
745 int pos; ///< = w->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
746 StringID str;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
747
8016
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
748 /* count types of cargos waiting in 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
749 num = 1;
6350
8132258640be (svn r9388) -Codechange: variable scope and type, and standardify all CargoID loops.
peter1138 <peter1138@openttd.org>
parents: 6297
diff changeset
750 for (CargoID i = 0; i < NUM_CARGO; i++) {
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
751 if (!st->goods[i].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
752 num++;
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
753 if (st->goods[i].cargo.Source() != station_id) num++;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
754 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
755 }
8016
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
756 SetVScrollCount(w, num); // 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
757
8016
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
758 /* disable some buttons */
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
759 w->SetWidgetDisabledState(SVW_RENAME, st->owner != _local_player);
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
760 w->SetWidgetDisabledState(SVW_TRAINS, !(st->facilities & FACIL_TRAIN));
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
761 w->SetWidgetDisabledState(SVW_ROADVEHS, !(st->facilities & FACIL_TRUCK_STOP) && !(st->facilities & FACIL_BUS_STOP));
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
762 w->SetWidgetDisabledState(SVW_PLANES, !(st->facilities & FACIL_AIRPORT));
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
763 w->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
764
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
765 SetDParam(0, st->index);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
766 SetDParam(1, st->facilities);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
767 DrawWindowWidgets(w);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
768
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
769 x = 2;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
770 y = 15;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
771 pos = w->vscroll.pos;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
772
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
773 if (--pos < 0) {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
774 str = STR_00D0_NOTHING;
6350
8132258640be (svn r9388) -Codechange: variable scope and type, and standardify all CargoID loops.
peter1138 <peter1138@openttd.org>
parents: 6297
diff changeset
775 for (CargoID i = 0; i < NUM_CARGO; i++) {
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
776 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
777 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
778 SetDParam(0, str);
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
779 DrawString(x, y, STR_0008_WAITING, TC_FROMSTRING);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
780 y += 10;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
781 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
782
6350
8132258640be (svn r9388) -Codechange: variable scope and type, and standardify all CargoID loops.
peter1138 <peter1138@openttd.org>
parents: 6297
diff changeset
783 for (CargoID i = 0; i < NUM_CARGO && pos > -5; i++) {
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
784 uint waiting = st->goods[i].cargo.Count();
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
785 if (waiting == 0) continue;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
786
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
787 if (st->goods[i].cargo.Source() == station_id) {
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
788 if (--pos < 0) {
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
789 DrawCargoIcons(i, waiting, x, y);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
790 SetDParam(1, waiting);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
791 SetDParam(0, i);
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
792 DrawStringRightAligned(x + 234, y, STR_0009, TC_FROMSTRING);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
793 y += 10;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
794 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
795 } else {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
796 /* enroute */
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
797 if (--pos < 0) {
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
798 DrawCargoIcons(i, waiting, x, y);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
799 SetDParam(1, waiting);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
800 SetDParam(0, i);
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
801 DrawStringRightAligned(x + 234, y, STR_000A_EN_ROUTE_FROM, TC_FROMSTRING);
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 y += 10;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
803 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
804
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
805 if (pos > -5 && --pos < 0) {
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
806 SetDParam(0, st->goods[i].cargo.Source());
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
807 DrawStringRightAligned(x + 234, y, STR_000B, TC_FROMSTRING);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
808 y += 10;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
809 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
810 }
6260
c0de6f270ae9 (svn r9069) -Codechange: Change a do ... while loop with a for loop. This fixes some warning that I never got anyway...
peter1138 <peter1138@openttd.org>
parents: 6259
diff changeset
811 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
812
8016
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
813 if (IsWindowOfPrototype(w, _station_view_widgets)) { // small window with list of accepted cargo
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
814 char *b = _userstring;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
815 bool first = true;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
816
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
817 b = InlineString(b, STR_000C_ACCEPTS);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
818
6350
8132258640be (svn r9388) -Codechange: variable scope and type, and standardify all CargoID loops.
peter1138 <peter1138@openttd.org>
parents: 6297
diff changeset
819 for (CargoID i = 0; i < NUM_CARGO; i++) {
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
820 if (b >= lastof(_userstring) - (1 + 2 * 4)) break; // ',' or ' ' and two calls to Utf8Encode()
7928
4e8dfd103163 (svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13 <skidd13@openttd.org>
parents: 7886
diff changeset
821 if (HasBit(st->goods[i].acceptance_pickup, GoodsEntry::ACCEPTANCE)) {
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
822 if (first) {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
823 first = false;
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 {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
825 /* Add a comma if this is not the first item */
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
826 *b++ = ',';
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
827 *b++ = ' ';
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
828 }
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
829 b = InlineString(b, GetCargo(i)->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
830 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
831 }
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 /* If first is still true then no cargo is accepted */
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
834 if (first) b = InlineString(b, STR_00D0_NOTHING);
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
835
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
836 *b = '\0';
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
837
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
838 /* Make sure we detect any buffer overflow */
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
839 assert(b < endof(_userstring));
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
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
841 DrawStringMultiLine(2, 67, STR_SPEC_USERSTRING, 245);
8016
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
842 } else { // extended window with list of cargo ratings
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
843 DrawString(2, 67, STR_3034_LOCAL_RATING_OF_TRANSPORT, TC_FROMSTRING);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
844
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
845 y = 77;
6350
8132258640be (svn r9388) -Codechange: variable scope and type, and standardify all CargoID loops.
peter1138 <peter1138@openttd.org>
parents: 6297
diff changeset
846 for (CargoID i = 0; i < NUM_CARGO; i++) {
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
847 const CargoSpec *cs = GetCargo(i);
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
848 if (!cs->IsValid()) continue;
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
849
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
850 const GoodsEntry *ge = &st->goods[i];
7928
4e8dfd103163 (svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13 <skidd13@openttd.org>
parents: 7886
diff changeset
851 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
852
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
853 SetDParam(0, cs->name);
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
854 SetDParam(2, ge->rating * 101 >> 8);
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
855 SetDParam(1, STR_3035_APPALLING + (ge->rating >> 5));
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
856 DrawString(8, y, STR_303D, TC_FROMSTRING);
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
857 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
858 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
859 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
860 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
861
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
862
8016
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
863 /**
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
864 * Fuction called when any WindowEvent occurs for any StationView window
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
865 *
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
866 * @param w pointer to the StationView window
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
867 * @param e pointer to window event
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
868 */
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
869 static void StationViewWndProc(Window *w, WindowEvent *e)
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
870 {
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
871 switch (e->event) {
6202
eb0fdb88a922 (svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138 <peter1138@openttd.org>
parents: 6122
diff changeset
872 case WE_PAINT:
eb0fdb88a922 (svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138 <peter1138@openttd.org>
parents: 6122
diff changeset
873 DrawStationViewWindow(w);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
874 break;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
875
6202
eb0fdb88a922 (svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138 <peter1138@openttd.org>
parents: 6122
diff changeset
876 case WE_CLICK:
eb0fdb88a922 (svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138 <peter1138@openttd.org>
parents: 6122
diff changeset
877 switch (e->we.click.widget) {
8016
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
878 case SVW_LOCATION:
6202
eb0fdb88a922 (svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138 <peter1138@openttd.org>
parents: 6122
diff changeset
879 ScrollMainWindowToTile(GetStation(w->window_number)->xy);
eb0fdb88a922 (svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138 <peter1138@openttd.org>
parents: 6122
diff changeset
880 break;
eb0fdb88a922 (svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138 <peter1138@openttd.org>
parents: 6122
diff changeset
881
8016
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
882 case SVW_RATINGS:
6202
eb0fdb88a922 (svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138 <peter1138@openttd.org>
parents: 6122
diff changeset
883 SetWindowDirty(w);
eb0fdb88a922 (svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138 <peter1138@openttd.org>
parents: 6122
diff changeset
884
eb0fdb88a922 (svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138 <peter1138@openttd.org>
parents: 6122
diff changeset
885 /* toggle height/widget set */
eb0fdb88a922 (svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138 <peter1138@openttd.org>
parents: 6122
diff changeset
886 if (IsWindowOfPrototype(w, _station_view_expanded_widgets)) {
eb0fdb88a922 (svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138 <peter1138@openttd.org>
parents: 6122
diff changeset
887 AssignWidgetToWindow(w, _station_view_widgets);
eb0fdb88a922 (svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138 <peter1138@openttd.org>
parents: 6122
diff changeset
888 w->height = 110;
eb0fdb88a922 (svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138 <peter1138@openttd.org>
parents: 6122
diff changeset
889 } else {
eb0fdb88a922 (svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138 <peter1138@openttd.org>
parents: 6122
diff changeset
890 AssignWidgetToWindow(w, _station_view_expanded_widgets);
eb0fdb88a922 (svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138 <peter1138@openttd.org>
parents: 6122
diff changeset
891 w->height = 210;
eb0fdb88a922 (svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138 <peter1138@openttd.org>
parents: 6122
diff changeset
892 }
eb0fdb88a922 (svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138 <peter1138@openttd.org>
parents: 6122
diff changeset
893
eb0fdb88a922 (svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138 <peter1138@openttd.org>
parents: 6122
diff changeset
894 SetWindowDirty(w);
eb0fdb88a922 (svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138 <peter1138@openttd.org>
parents: 6122
diff changeset
895 break;
eb0fdb88a922 (svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138 <peter1138@openttd.org>
parents: 6122
diff changeset
896
8016
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
897 case SVW_RENAME:
6202
eb0fdb88a922 (svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138 <peter1138@openttd.org>
parents: 6122
diff changeset
898 SetDParam(0, w->window_number);
eb0fdb88a922 (svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138 <peter1138@openttd.org>
parents: 6122
diff changeset
899 ShowQueryString(STR_STATION, STR_3030_RENAME_STATION_LOADING, 31, 180, w, CS_ALPHANUMERAL);
eb0fdb88a922 (svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138 <peter1138@openttd.org>
parents: 6122
diff changeset
900 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
901
8016
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
902 case SVW_TRAINS: { // Show a list of scheduled trains to this station
6202
eb0fdb88a922 (svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138 <peter1138@openttd.org>
parents: 6122
diff changeset
903 const Station *st = GetStation(w->window_number);
6259
4a39d6291d58 (svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium <rubidium@openttd.org>
parents: 6253
diff changeset
904 ShowVehicleListWindow(st->owner, VEH_TRAIN, (StationID)w->window_number);
6202
eb0fdb88a922 (svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138 <peter1138@openttd.org>
parents: 6122
diff changeset
905 break;
eb0fdb88a922 (svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138 <peter1138@openttd.org>
parents: 6122
diff changeset
906 }
eb0fdb88a922 (svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138 <peter1138@openttd.org>
parents: 6122
diff changeset
907
8016
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
908 case SVW_ROADVEHS: { // Show a list of scheduled road-vehicles to this station
6202
eb0fdb88a922 (svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138 <peter1138@openttd.org>
parents: 6122
diff changeset
909 const Station *st = GetStation(w->window_number);
6259
4a39d6291d58 (svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium <rubidium@openttd.org>
parents: 6253
diff changeset
910 ShowVehicleListWindow(st->owner, VEH_ROAD, (StationID)w->window_number);
6202
eb0fdb88a922 (svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138 <peter1138@openttd.org>
parents: 6122
diff changeset
911 break;
eb0fdb88a922 (svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138 <peter1138@openttd.org>
parents: 6122
diff changeset
912 }
eb0fdb88a922 (svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138 <peter1138@openttd.org>
parents: 6122
diff changeset
913
8016
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
914 case SVW_PLANES: { // Show a list of scheduled aircraft to this station
6202
eb0fdb88a922 (svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138 <peter1138@openttd.org>
parents: 6122
diff changeset
915 const Station *st = GetStation(w->window_number);
eb0fdb88a922 (svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138 <peter1138@openttd.org>
parents: 6122
diff changeset
916 /* Since oilrigs have no owners, show the scheduled aircraft of current player */
eb0fdb88a922 (svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138 <peter1138@openttd.org>
parents: 6122
diff changeset
917 PlayerID owner = (st->owner == OWNER_NONE) ? _current_player : st->owner;
6259
4a39d6291d58 (svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium <rubidium@openttd.org>
parents: 6253
diff changeset
918 ShowVehicleListWindow(owner, VEH_AIRCRAFT, (StationID)w->window_number);
6202
eb0fdb88a922 (svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138 <peter1138@openttd.org>
parents: 6122
diff changeset
919 break;
eb0fdb88a922 (svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138 <peter1138@openttd.org>
parents: 6122
diff changeset
920 }
eb0fdb88a922 (svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138 <peter1138@openttd.org>
parents: 6122
diff changeset
921
8016
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
922 case SVW_SHIPS: { // Show a list of scheduled ships to this station
6202
eb0fdb88a922 (svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138 <peter1138@openttd.org>
parents: 6122
diff changeset
923 const Station *st = GetStation(w->window_number);
eb0fdb88a922 (svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138 <peter1138@openttd.org>
parents: 6122
diff changeset
924 /* Since oilrigs/bouys have no owners, show the scheduled ships of current player */
eb0fdb88a922 (svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138 <peter1138@openttd.org>
parents: 6122
diff changeset
925 PlayerID owner = (st->owner == OWNER_NONE) ? _current_player : st->owner;
6259
4a39d6291d58 (svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium <rubidium@openttd.org>
parents: 6253
diff changeset
926 ShowVehicleListWindow(owner, VEH_SHIP, (StationID)w->window_number);
6202
eb0fdb88a922 (svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138 <peter1138@openttd.org>
parents: 6122
diff changeset
927 break;
eb0fdb88a922 (svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138 <peter1138@openttd.org>
parents: 6122
diff changeset
928 }
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
929 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
930 break;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
931
6202
eb0fdb88a922 (svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138 <peter1138@openttd.org>
parents: 6122
diff changeset
932 case WE_ON_EDIT_TEXT:
eb0fdb88a922 (svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138 <peter1138@openttd.org>
parents: 6122
diff changeset
933 if (e->we.edittext.str[0] != '\0') {
eb0fdb88a922 (svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138 <peter1138@openttd.org>
parents: 6122
diff changeset
934 _cmd_text = e->we.edittext.str;
eb0fdb88a922 (svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138 <peter1138@openttd.org>
parents: 6122
diff changeset
935 DoCommandP(0, w->window_number, 0, NULL,
eb0fdb88a922 (svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138 <peter1138@openttd.org>
parents: 6122
diff changeset
936 CMD_RENAME_STATION | CMD_MSG(STR_3031_CAN_T_RENAME_STATION));
eb0fdb88a922 (svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138 <peter1138@openttd.org>
parents: 6122
diff changeset
937 }
eb0fdb88a922 (svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138 <peter1138@openttd.org>
parents: 6122
diff changeset
938 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
939
6202
eb0fdb88a922 (svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138 <peter1138@openttd.org>
parents: 6122
diff changeset
940 case WE_DESTROY: {
eb0fdb88a922 (svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138 <peter1138@openttd.org>
parents: 6122
diff changeset
941 WindowNumber wno =
eb0fdb88a922 (svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138 <peter1138@openttd.org>
parents: 6122
diff changeset
942 (w->window_number << 16) | GetStation(w->window_number)->owner;
eb0fdb88a922 (svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138 <peter1138@openttd.org>
parents: 6122
diff changeset
943
eb0fdb88a922 (svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138 <peter1138@openttd.org>
parents: 6122
diff changeset
944 DeleteWindowById(WC_TRAINS_LIST, wno);
eb0fdb88a922 (svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138 <peter1138@openttd.org>
parents: 6122
diff changeset
945 DeleteWindowById(WC_ROADVEH_LIST, wno);
eb0fdb88a922 (svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138 <peter1138@openttd.org>
parents: 6122
diff changeset
946 DeleteWindowById(WC_SHIPS_LIST, wno);
eb0fdb88a922 (svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138 <peter1138@openttd.org>
parents: 6122
diff changeset
947 DeleteWindowById(WC_AIRCRAFT_LIST, wno);
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
948 break;
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
949 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
950 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
951 }
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
952
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
953
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
954 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
955 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
956 WC_STATION_VIEW, 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
957 WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_STICKY_BUTTON,
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
958 _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
959 StationViewWndProc
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
960 };
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
961
8016
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
962 /**
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
963 * Opens StationViewWindow for given station
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
964 *
f60addd19e1a (svn r11576) -Codechange: enumerize and comment station GUI
smatz <smatz@openttd.org>
parents: 8005
diff changeset
965 * @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
966 */
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
967 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
968 {
6202
eb0fdb88a922 (svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138 <peter1138@openttd.org>
parents: 6122
diff changeset
969 Window *w = AllocateWindowDescFront(&_station_view_desc, station);
eb0fdb88a922 (svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138 <peter1138@openttd.org>
parents: 6122
diff changeset
970 if (w == NULL) return;
5584
4b26bd55bd24 (svn r8033) [cpp] - Prepare for merge from branches/cpp (all .c files renamed to .cpp)
KUDr <KUDr@openttd.org>
parents:
diff changeset
971
6202
eb0fdb88a922 (svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138 <peter1138@openttd.org>
parents: 6122
diff changeset
972 PlayerID owner = GetStation(w->window_number)->owner;
eb0fdb88a922 (svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138 <peter1138@openttd.org>
parents: 6122
diff changeset
973 if (owner != OWNER_NONE) w->caption_color = owner;
eb0fdb88a922 (svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138 <peter1138@openttd.org>
parents: 6122
diff changeset
974 w->vscroll.cap = 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
975 }