author | rubidium |
Tue, 06 May 2008 22:08:18 +0000 | |
changeset 9116 | f2491d3c321b |
parent 9111 | 48ce04029fe4 |
child 9143 | 029e126e3439 |
permissions | -rw-r--r-- |
2186 | 1 |
/* $Id$ */ |
2 |
||
9111
48ce04029fe4
(svn r12971) -Documentation: add @file in files that missed them and add something more than whitespace as description of files that don't have a description.
rubidium
parents:
9094
diff
changeset
|
3 |
/** @file station_gui.cpp The GUI for stations. */ |
6420
456c275f3313
(svn r9556) -Documentation: doxygen and comment-style changes. 'R', 'S'.. The end of the preliminary work is near
belugas
parents:
6365
diff
changeset
|
4 |
|
0 | 5 |
#include "stdafx.h" |
1891
862800791170
(svn r2397) - CodeChange: rename all "ttd" files to "openttd" files.
Darkvater
parents:
1820
diff
changeset
|
6 |
#include "openttd.h" |
1299
39c06aba09aa
(svn r1803) Move debugging stuff into files of it's own
tron
parents:
1272
diff
changeset
|
7 |
#include "debug.h" |
0 | 8 |
#include "gui.h" |
8107
bb7deea89175
(svn r11668) -Codechange: more refactoring aimed at reducing compile time and making it more logic where function definitions can be found.
rubidium
parents:
8106
diff
changeset
|
9 |
#include "window_gui.h" |
bb7deea89175
(svn r11668) -Codechange: more refactoring aimed at reducing compile time and making it more logic where function definitions can be found.
rubidium
parents:
8106
diff
changeset
|
10 |
#include "textbuf_gui.h" |
8785
871586967963
(svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
8762
diff
changeset
|
11 |
#include "station_base.h" |
8254
1496654ca5e7
(svn r11818) -Codechange: split player.h into smaller pieces.
rubidium
parents:
8224
diff
changeset
|
12 |
#include "player_func.h" |
8116
8da76dcb3287
(svn r11677) -Codechange: move price and command related types/functions to their respective places.
rubidium
parents:
8114
diff
changeset
|
13 |
#include "economy_func.h" |
0 | 14 |
#include "town.h" |
8116
8da76dcb3287
(svn r11677) -Codechange: move price and command related types/functions to their respective places.
rubidium
parents:
8114
diff
changeset
|
15 |
#include "command_func.h" |
2159
f6284cf5fab0
(svn r2669) Shuffle some more stuff around to reduce dependencies
tron
parents:
2084
diff
changeset
|
16 |
#include "variables.h" |
f6284cf5fab0
(svn r2669) Shuffle some more stuff around to reduce dependencies
tron
parents:
2084
diff
changeset
|
17 |
#include "vehicle_gui.h" |
6091
c8827d9ae04a
(svn r8826) -Codechange: Replace _cargoc's separate arrays with a regular struct array (with accessor) and implement new initialization method using cargo labels.
peter1138
parents:
5893
diff
changeset
|
18 |
#include "cargotype.h" |
8016
1c7062ad5f50
(svn r11576) -Codechange: enumerize and comment station GUI
smatz
parents:
8005
diff
changeset
|
19 |
#include "station_gui.h" |
8785
871586967963
(svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
8762
diff
changeset
|
20 |
#include "station_func.h" |
8114
dd6d21dc99c1
(svn r11675) -Codechange: split the string types from the string functions.
rubidium
parents:
8109
diff
changeset
|
21 |
#include "strings_func.h" |
8130
d2eb7d04f6e1
(svn r11691) -Codechange: move+rename helpers.hpp and only include it when it is really needed.
rubidium
parents:
8121
diff
changeset
|
22 |
#include "core/alloc_func.hpp" |
8131
160939e24ed3
(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
parents:
8130
diff
changeset
|
23 |
#include "window_func.h" |
8224
c5a64d87cc54
(svn r11787) -Codechange: more header rewrites. This time related to viewport.h.
rubidium
parents:
8179
diff
changeset
|
24 |
#include "viewport_func.h" |
c5a64d87cc54
(svn r11787) -Codechange: more header rewrites. This time related to viewport.h.
rubidium
parents:
8179
diff
changeset
|
25 |
#include "gfx_func.h" |
8284
ebdc5ba08874
(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
parents:
8268
diff
changeset
|
26 |
#include "widgets/dropdown_func.h" |
8787
41d9d5adbe87
(svn r12495) -Codechange: reduce the dependency on newgrf_station.h (especially because newgrf_station.h includes a lot of stuff).
rubidium
parents:
8785
diff
changeset
|
27 |
#include "newgrf_cargo.h" |
5271
a2e9e1dd7cb2
(svn r7413) -Fix[FS#386,#412]: Station list window NONE button now behaves correctly.
belugas
parents:
5247
diff
changeset
|
28 |
|
8264
b1e85998c7d3
(svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium
parents:
8254
diff
changeset
|
29 |
#include "table/strings.h" |
b1e85998c7d3
(svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium
parents:
8254
diff
changeset
|
30 |
#include "table/sprites.h" |
b1e85998c7d3
(svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium
parents:
8254
diff
changeset
|
31 |
|
3812
e6fc916c17ab
(svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents:
3554
diff
changeset
|
32 |
typedef int CDECL StationSortListingTypeFunction(const void*, const void*); |
e6fc916c17ab
(svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents:
3554
diff
changeset
|
33 |
|
e6fc916c17ab
(svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents:
3554
diff
changeset
|
34 |
static StationSortListingTypeFunction StationNameSorter; |
e6fc916c17ab
(svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents:
3554
diff
changeset
|
35 |
static StationSortListingTypeFunction StationTypeSorter; |
e6fc916c17ab
(svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents:
3554
diff
changeset
|
36 |
static StationSortListingTypeFunction StationWaitingSorter; |
e6fc916c17ab
(svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents:
3554
diff
changeset
|
37 |
static StationSortListingTypeFunction StationRatingMaxSorter; |
e6fc916c17ab
(svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents:
3554
diff
changeset
|
38 |
|
8268
5027ad5e70a0
(svn r11832) -Codechange: get rid of (quite) some VARDEFs.
rubidium
parents:
8264
diff
changeset
|
39 |
bool _station_show_coverage; |
5027ad5e70a0
(svn r11832) -Codechange: get rid of (quite) some VARDEFs.
rubidium
parents:
8264
diff
changeset
|
40 |
|
8016
1c7062ad5f50
(svn r11576) -Codechange: enumerize and comment station GUI
smatz
parents:
8005
diff
changeset
|
41 |
/** |
1c7062ad5f50
(svn r11576) -Codechange: enumerize and comment station GUI
smatz
parents:
8005
diff
changeset
|
42 |
* Draw small boxes of cargo amount and ratings data at the given |
5293
4cc0c1f2f95c
(svn r7446) -Feature: Double the length of the cargo and rating indicators in the station list window,
Darkvater
parents:
5292
diff
changeset
|
43 |
* coordinates. If amount exceeds 576 units, it is shown 'full', same |
4cc0c1f2f95c
(svn r7446) -Feature: Double the length of the cargo and rating indicators in the station list window,
Darkvater
parents:
5292
diff
changeset
|
44 |
* goes for the rating: at above 90% orso (224) it is also 'full' |
8016
1c7062ad5f50
(svn r11576) -Codechange: enumerize and comment station GUI
smatz
parents:
8005
diff
changeset
|
45 |
* |
6420
456c275f3313
(svn r9556) -Documentation: doxygen and comment-style changes. 'R', 'S'.. The end of the preliminary work is near
belugas
parents:
6365
diff
changeset
|
46 |
* @param x coordinate to draw the box at |
456c275f3313
(svn r9556) -Documentation: doxygen and comment-style changes. 'R', 'S'.. The end of the preliminary work is near
belugas
parents:
6365
diff
changeset
|
47 |
* @param y coordinate to draw the box at |
5293
4cc0c1f2f95c
(svn r7446) -Feature: Double the length of the cargo and rating indicators in the station list window,
Darkvater
parents:
5292
diff
changeset
|
48 |
* @param type Cargo type |
4cc0c1f2f95c
(svn r7446) -Feature: Double the length of the cargo and rating indicators in the station list window,
Darkvater
parents:
5292
diff
changeset
|
49 |
* @param amount Cargo amount |
8016
1c7062ad5f50
(svn r11576) -Codechange: enumerize and comment station GUI
smatz
parents:
8005
diff
changeset
|
50 |
* @param rating ratings data for that particular cargo |
1c7062ad5f50
(svn r11576) -Codechange: enumerize and comment station GUI
smatz
parents:
8005
diff
changeset
|
51 |
* |
1c7062ad5f50
(svn r11576) -Codechange: enumerize and comment station GUI
smatz
parents:
8005
diff
changeset
|
52 |
* @note Each cargo-bar is 16 pixels wide and 6 pixels high |
1c7062ad5f50
(svn r11576) -Codechange: enumerize and comment station GUI
smatz
parents:
8005
diff
changeset
|
53 |
* @note Each rating 14 pixels wide and 1 pixel high and is 1 pixel below the cargo-bar |
1c7062ad5f50
(svn r11576) -Codechange: enumerize and comment station GUI
smatz
parents:
8005
diff
changeset
|
54 |
*/ |
5293
4cc0c1f2f95c
(svn r7446) -Feature: Double the length of the cargo and rating indicators in the station list window,
Darkvater
parents:
5292
diff
changeset
|
55 |
static void StationsWndShowStationRating(int x, int y, CargoID type, uint amount, byte rating) |
0 | 56 |
{ |
8016
1c7062ad5f50
(svn r11576) -Codechange: enumerize and comment station GUI
smatz
parents:
8005
diff
changeset
|
57 |
static const uint units_full = 576; ///< number of units to show station as 'full' |
1c7062ad5f50
(svn r11576) -Codechange: enumerize and comment station GUI
smatz
parents:
8005
diff
changeset
|
58 |
static const uint rating_full = 224; ///< rating needed so it is shown as 'full' |
1c7062ad5f50
(svn r11576) -Codechange: enumerize and comment station GUI
smatz
parents:
8005
diff
changeset
|
59 |
|
6091
c8827d9ae04a
(svn r8826) -Codechange: Replace _cargoc's separate arrays with a regular struct array (with accessor) and implement new initialization method using cargo labels.
peter1138
parents:
5893
diff
changeset
|
60 |
const CargoSpec *cs = GetCargo(type); |
6122
3359af5a1f54
(svn r8858) -Codechange: Replace magic number test with class method for determining if a cargo is valid/active.
peter1138
parents:
6091
diff
changeset
|
61 |
if (!cs->IsValid()) return; |
6091
c8827d9ae04a
(svn r8826) -Codechange: Replace _cargoc's separate arrays with a regular struct array (with accessor) and implement new initialization method using cargo labels.
peter1138
parents:
5893
diff
changeset
|
62 |
|
c8827d9ae04a
(svn r8826) -Codechange: Replace _cargoc's separate arrays with a regular struct array (with accessor) and implement new initialization method using cargo labels.
peter1138
parents:
5893
diff
changeset
|
63 |
int colour = cs->rating_colour; |
8016
1c7062ad5f50
(svn r11576) -Codechange: enumerize and comment station GUI
smatz
parents:
8005
diff
changeset
|
64 |
uint w = (minu(amount, units_full) + 5) / 36; |
0 | 65 |
|
5293
4cc0c1f2f95c
(svn r7446) -Feature: Double the length of the cargo and rating indicators in the station list window,
Darkvater
parents:
5292
diff
changeset
|
66 |
/* Draw total cargo (limited) on station (fits into 16 pixels) */ |
4cc0c1f2f95c
(svn r7446) -Feature: Double the length of the cargo and rating indicators in the station list window,
Darkvater
parents:
5292
diff
changeset
|
67 |
if (w != 0) GfxFillRect(x, y, x + w - 1, y + 6, colour); |
0 | 68 |
|
5293
4cc0c1f2f95c
(svn r7446) -Feature: Double the length of the cargo and rating indicators in the station list window,
Darkvater
parents:
5292
diff
changeset
|
69 |
/* Draw a one pixel-wide bar of additional cargo meter, useful |
4cc0c1f2f95c
(svn r7446) -Feature: Double the length of the cargo and rating indicators in the station list window,
Darkvater
parents:
5292
diff
changeset
|
70 |
* for stations with only a small amount (<=30) */ |
4cc0c1f2f95c
(svn r7446) -Feature: Double the length of the cargo and rating indicators in the station list window,
Darkvater
parents:
5292
diff
changeset
|
71 |
if (w == 0) { |
4cc0c1f2f95c
(svn r7446) -Feature: Double the length of the cargo and rating indicators in the station list window,
Darkvater
parents:
5292
diff
changeset
|
72 |
uint rest = amount / 5; |
4cc0c1f2f95c
(svn r7446) -Feature: Double the length of the cargo and rating indicators in the station list window,
Darkvater
parents:
5292
diff
changeset
|
73 |
if (rest != 0) { |
4cc0c1f2f95c
(svn r7446) -Feature: Double the length of the cargo and rating indicators in the station list window,
Darkvater
parents:
5292
diff
changeset
|
74 |
w += x; |
4cc0c1f2f95c
(svn r7446) -Feature: Double the length of the cargo and rating indicators in the station list window,
Darkvater
parents:
5292
diff
changeset
|
75 |
GfxFillRect(w, y + 6 - rest, w, y + 6, colour); |
4cc0c1f2f95c
(svn r7446) -Feature: Double the length of the cargo and rating indicators in the station list window,
Darkvater
parents:
5292
diff
changeset
|
76 |
} |
0 | 77 |
} |
78 |
||
7824
5a63d41b59ea
(svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents:
7474
diff
changeset
|
79 |
DrawString(x + 1, y, cs->abbrev, TC_BLACK); |
0 | 80 |
|
5293
4cc0c1f2f95c
(svn r7446) -Feature: Double the length of the cargo and rating indicators in the station list window,
Darkvater
parents:
5292
diff
changeset
|
81 |
/* Draw green/red ratings bar (fits into 14 pixels) */ |
4cc0c1f2f95c
(svn r7446) -Feature: Double the length of the cargo and rating indicators in the station list window,
Darkvater
parents:
5292
diff
changeset
|
82 |
y += 8; |
4cc0c1f2f95c
(svn r7446) -Feature: Double the length of the cargo and rating indicators in the station list window,
Darkvater
parents:
5292
diff
changeset
|
83 |
GfxFillRect(x + 1, y, x + 14, y, 0xB8); |
8016
1c7062ad5f50
(svn r11576) -Codechange: enumerize and comment station GUI
smatz
parents:
8005
diff
changeset
|
84 |
rating = minu(rating, rating_full) / 16; |
5293
4cc0c1f2f95c
(svn r7446) -Feature: Double the length of the cargo and rating indicators in the station list window,
Darkvater
parents:
5292
diff
changeset
|
85 |
if (rating != 0) GfxFillRect(x + 1, y, x + rating, y, 0xD0); |
0 | 86 |
} |
87 |
||
3812
e6fc916c17ab
(svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents:
3554
diff
changeset
|
88 |
const StringID _station_sort_listing[] = { |
e6fc916c17ab
(svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents:
3554
diff
changeset
|
89 |
STR_SORT_BY_DROPDOWN_NAME, |
e6fc916c17ab
(svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents:
3554
diff
changeset
|
90 |
STR_SORT_BY_FACILITY, |
e6fc916c17ab
(svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents:
3554
diff
changeset
|
91 |
STR_SORT_BY_WAITING, |
e6fc916c17ab
(svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents:
3554
diff
changeset
|
92 |
STR_SORT_BY_RATING_MAX, |
e6fc916c17ab
(svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents:
3554
diff
changeset
|
93 |
INVALID_STRING_ID |
e6fc916c17ab
(svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents:
3554
diff
changeset
|
94 |
}; |
0 | 95 |
|
96 |
static char _bufcache[64]; |
|
8964
84f2e443b7be
(svn r12756) -Cleanup: variable scope and coding style in station*
smatz
parents:
8857
diff
changeset
|
97 |
static const Station *_last_station; |
3812
e6fc916c17ab
(svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents:
3554
diff
changeset
|
98 |
static int _internal_sort_order; |
0 | 99 |
|
164
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
69
diff
changeset
|
100 |
static int CDECL StationNameSorter(const void *a, const void *b) |
0 | 101 |
{ |
8964
84f2e443b7be
(svn r12756) -Cleanup: variable scope and coding style in station*
smatz
parents:
8857
diff
changeset
|
102 |
const Station *st1 = *(const Station**)a; |
84f2e443b7be
(svn r12756) -Cleanup: variable scope and coding style in station*
smatz
parents:
8857
diff
changeset
|
103 |
const Station *st2 = *(const Station**)b; |
0 | 104 |
char buf1[64]; |
105 |
||
4416
442b18840569
(svn r6169) -Codechange: Use GetString() instead of GetStringWithArgs() which should be
Darkvater
parents:
4354
diff
changeset
|
106 |
SetDParam(0, st1->index); |
4912
0f51b47cb983
(svn r6884) -Codechange: Add strict bounds checking in string formatting system.
Darkvater
parents:
4896
diff
changeset
|
107 |
GetString(buf1, STR_STATION, lastof(buf1)); |
164
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
69
diff
changeset
|
108 |
|
4277
345e1bd9525a
(svn r5907) Remove more indirection by using pointers instead of IDs. Also fix some bogus warnings on MSVC by using (void*) casts
tron
parents:
4268
diff
changeset
|
109 |
if (st2 != _last_station) { |
345e1bd9525a
(svn r5907) Remove more indirection by using pointers instead of IDs. Also fix some bogus warnings on MSVC by using (void*) casts
tron
parents:
4268
diff
changeset
|
110 |
_last_station = st2; |
4416
442b18840569
(svn r6169) -Codechange: Use GetString() instead of GetStringWithArgs() which should be
Darkvater
parents:
4354
diff
changeset
|
111 |
SetDParam(0, st2->index); |
4912
0f51b47cb983
(svn r6884) -Codechange: Add strict bounds checking in string formatting system.
Darkvater
parents:
4896
diff
changeset
|
112 |
GetString(_bufcache, STR_STATION, lastof(_bufcache)); |
164
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
69
diff
changeset
|
113 |
} |
0 | 114 |
|
8964
84f2e443b7be
(svn r12756) -Cleanup: variable scope and coding style in station*
smatz
parents:
8857
diff
changeset
|
115 |
int r = strcmp(buf1, _bufcache); // sort by name |
3812
e6fc916c17ab
(svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents:
3554
diff
changeset
|
116 |
return (_internal_sort_order & 1) ? -r : r; |
0 | 117 |
} |
118 |
||
3812
e6fc916c17ab
(svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents:
3554
diff
changeset
|
119 |
static int CDECL StationTypeSorter(const void *a, const void *b) |
0 | 120 |
{ |
8964
84f2e443b7be
(svn r12756) -Cleanup: variable scope and coding style in station*
smatz
parents:
8857
diff
changeset
|
121 |
const Station *st1 = *(const Station**)a; |
84f2e443b7be
(svn r12756) -Cleanup: variable scope and coding style in station*
smatz
parents:
8857
diff
changeset
|
122 |
const Station *st2 = *(const Station**)b; |
3812
e6fc916c17ab
(svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents:
3554
diff
changeset
|
123 |
return (_internal_sort_order & 1) ? st2->facilities - st1->facilities : st1->facilities - st2->facilities; |
e6fc916c17ab
(svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents:
3554
diff
changeset
|
124 |
} |
e6fc916c17ab
(svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents:
3554
diff
changeset
|
125 |
|
8964
84f2e443b7be
(svn r12756) -Cleanup: variable scope and coding style in station*
smatz
parents:
8857
diff
changeset
|
126 |
static const uint32 _cargo_filter_max = UINT32_MAX; |
7886
f0901496b7f1
(svn r11437) -Change: when sorting stations by cargo sum, only sum the cargos that are selected in the filter. Patch by divide.
rubidium
parents:
7842
diff
changeset
|
127 |
static uint32 _cargo_filter = _cargo_filter_max; |
f0901496b7f1
(svn r11437) -Change: when sorting stations by cargo sum, only sum the cargos that are selected in the filter. Patch by divide.
rubidium
parents:
7842
diff
changeset
|
128 |
|
3812
e6fc916c17ab
(svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents:
3554
diff
changeset
|
129 |
static int CDECL StationWaitingSorter(const void *a, const void *b) |
e6fc916c17ab
(svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents:
3554
diff
changeset
|
130 |
{ |
8964
84f2e443b7be
(svn r12756) -Cleanup: variable scope and coding style in station*
smatz
parents:
8857
diff
changeset
|
131 |
const Station *st1 = *(const Station**)a; |
84f2e443b7be
(svn r12756) -Cleanup: variable scope and coding style in station*
smatz
parents:
8857
diff
changeset
|
132 |
const Station *st2 = *(const Station**)b; |
6990
136a08baf0ed
(svn r10246) -Fix (r10297): some forgotten money conversions and truncation issues. Thanks to benc for providing the patch.
rubidium
parents:
6657
diff
changeset
|
133 |
Money sum1 = 0, sum2 = 0; |
3812
e6fc916c17ab
(svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents:
3554
diff
changeset
|
134 |
|
6202
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
135 |
for (CargoID j = 0; j < NUM_CARGO; j++) { |
7928
63e18de69e50
(svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13
parents:
7886
diff
changeset
|
136 |
if (!HasBit(_cargo_filter, j)) continue; |
7010
6f0d9f03180d
(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
parents:
6990
diff
changeset
|
137 |
if (!st1->goods[j].cargo.Empty()) sum1 += GetTransportedGoodsIncome(st1->goods[j].cargo.Count(), 20, 50, j); |
6f0d9f03180d
(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
parents:
6990
diff
changeset
|
138 |
if (!st2->goods[j].cargo.Empty()) sum2 += GetTransportedGoodsIncome(st2->goods[j].cargo.Count(), 20, 50, j); |
3812
e6fc916c17ab
(svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents:
3554
diff
changeset
|
139 |
} |
e6fc916c17ab
(svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents:
3554
diff
changeset
|
140 |
|
6990
136a08baf0ed
(svn r10246) -Fix (r10297): some forgotten money conversions and truncation issues. Thanks to benc for providing the patch.
rubidium
parents:
6657
diff
changeset
|
141 |
return (_internal_sort_order & 1) ? ClampToI32(sum2 - sum1) : ClampToI32(sum1 - sum2); |
3812
e6fc916c17ab
(svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents:
3554
diff
changeset
|
142 |
} |
e6fc916c17ab
(svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents:
3554
diff
changeset
|
143 |
|
6253
efef997fec17
(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
parents:
6248
diff
changeset
|
144 |
/** |
efef997fec17
(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
parents:
6248
diff
changeset
|
145 |
* qsort-compatible version of sorting two stations by maximum rating |
efef997fec17
(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
parents:
6248
diff
changeset
|
146 |
* @param a First object to be sorted, must be of type (const Station *) |
efef997fec17
(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
parents:
6248
diff
changeset
|
147 |
* @param b Second object to be sorted, must be of type (const Station *) |
efef997fec17
(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
parents:
6248
diff
changeset
|
148 |
* @return The sort order |
efef997fec17
(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
parents:
6248
diff
changeset
|
149 |
* @retval >0 a should come before b in the list |
efef997fec17
(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
parents:
6248
diff
changeset
|
150 |
* @retval <0 b should come before a in the list |
efef997fec17
(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
parents:
6248
diff
changeset
|
151 |
*/ |
3812
e6fc916c17ab
(svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents:
3554
diff
changeset
|
152 |
static int CDECL StationRatingMaxSorter(const void *a, const void *b) |
e6fc916c17ab
(svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents:
3554
diff
changeset
|
153 |
{ |
8964
84f2e443b7be
(svn r12756) -Cleanup: variable scope and coding style in station*
smatz
parents:
8857
diff
changeset
|
154 |
const Station *st1 = *(const Station**)a; |
84f2e443b7be
(svn r12756) -Cleanup: variable scope and coding style in station*
smatz
parents:
8857
diff
changeset
|
155 |
const Station *st2 = *(const Station**)b; |
3812
e6fc916c17ab
(svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents:
3554
diff
changeset
|
156 |
byte maxr1 = 0; |
e6fc916c17ab
(svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents:
3554
diff
changeset
|
157 |
byte maxr2 = 0; |
e6fc916c17ab
(svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents:
3554
diff
changeset
|
158 |
|
6202
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
159 |
for (CargoID j = 0; j < NUM_CARGO; j++) { |
7928
63e18de69e50
(svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13
parents:
7886
diff
changeset
|
160 |
if (HasBit(st1->goods[j].acceptance_pickup, GoodsEntry::PICKUP)) maxr1 = max(maxr1, st1->goods[j].rating); |
63e18de69e50
(svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13
parents:
7886
diff
changeset
|
161 |
if (HasBit(st2->goods[j].acceptance_pickup, GoodsEntry::PICKUP)) maxr2 = max(maxr2, st2->goods[j].rating); |
3812
e6fc916c17ab
(svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents:
3554
diff
changeset
|
162 |
} |
e6fc916c17ab
(svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents:
3554
diff
changeset
|
163 |
|
e6fc916c17ab
(svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents:
3554
diff
changeset
|
164 |
return (_internal_sort_order & 1) ? maxr2 - maxr1 : maxr1 - maxr2; |
e6fc916c17ab
(svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents:
3554
diff
changeset
|
165 |
} |
e6fc916c17ab
(svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents:
3554
diff
changeset
|
166 |
|
8016
1c7062ad5f50
(svn r11576) -Codechange: enumerize and comment station GUI
smatz
parents:
8005
diff
changeset
|
167 |
/** Flags for station list */ |
6248
e4a2ed7e5613
(svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents:
6247
diff
changeset
|
168 |
enum StationListFlags { |
8016
1c7062ad5f50
(svn r11576) -Codechange: enumerize and comment station GUI
smatz
parents:
8005
diff
changeset
|
169 |
SL_ORDER = 1 << 0, ///< Order - ascending (=0), descending (=1) |
1c7062ad5f50
(svn r11576) -Codechange: enumerize and comment station GUI
smatz
parents:
8005
diff
changeset
|
170 |
SL_RESORT = 1 << 1, ///< Resort the list |
1c7062ad5f50
(svn r11576) -Codechange: enumerize and comment station GUI
smatz
parents:
8005
diff
changeset
|
171 |
SL_REBUILD = 1 << 2, ///< Rebuild the list |
6248
e4a2ed7e5613
(svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents:
6247
diff
changeset
|
172 |
}; |
3812
e6fc916c17ab
(svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents:
3554
diff
changeset
|
173 |
|
5587
167d9a91ef02
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5584
diff
changeset
|
174 |
DECLARE_ENUM_AS_BIT_SET(StationListFlags); |
167d9a91ef02
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5584
diff
changeset
|
175 |
|
8016
1c7062ad5f50
(svn r11576) -Codechange: enumerize and comment station GUI
smatz
parents:
8005
diff
changeset
|
176 |
/** Information about station list */ |
6248
e4a2ed7e5613
(svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents:
6247
diff
changeset
|
177 |
struct plstations_d { |
8964
84f2e443b7be
(svn r12756) -Cleanup: variable scope and coding style in station*
smatz
parents:
8857
diff
changeset
|
178 |
const Station **sort_list; ///< Pointer to list of stations |
8016
1c7062ad5f50
(svn r11576) -Codechange: enumerize and comment station GUI
smatz
parents:
8005
diff
changeset
|
179 |
uint16 list_length; ///< Number of stations in list |
1c7062ad5f50
(svn r11576) -Codechange: enumerize and comment station GUI
smatz
parents:
8005
diff
changeset
|
180 |
uint16 resort_timer; ///< Tick counter to resort the list |
1c7062ad5f50
(svn r11576) -Codechange: enumerize and comment station GUI
smatz
parents:
8005
diff
changeset
|
181 |
byte sort_type; ///< Sort type - name, waiting, ... |
1c7062ad5f50
(svn r11576) -Codechange: enumerize and comment station GUI
smatz
parents:
8005
diff
changeset
|
182 |
byte flags; ///< Flags - SL_ORDER, SL_RESORT, SL_REBUILD |
6248
e4a2ed7e5613
(svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents:
6247
diff
changeset
|
183 |
}; |
3812
e6fc916c17ab
(svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents:
3554
diff
changeset
|
184 |
assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(plstations_d)); |
e6fc916c17ab
(svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents:
3554
diff
changeset
|
185 |
|
8016
1c7062ad5f50
(svn r11576) -Codechange: enumerize and comment station GUI
smatz
parents:
8005
diff
changeset
|
186 |
/** |
8992
0b2fb43cc875
(svn r12787) -Documentation: add/fix documentation of some functions. Patch by Alberth.
rubidium
parents:
8964
diff
changeset
|
187 |
* Set the station sort flag for all station-list windows. |
0b2fb43cc875
(svn r12787) -Documentation: add/fix documentation of some functions. Patch by Alberth.
rubidium
parents:
8964
diff
changeset
|
188 |
* @param sl_flag Sort list flag to set for all station-list windows |
8016
1c7062ad5f50
(svn r11576) -Codechange: enumerize and comment station GUI
smatz
parents:
8005
diff
changeset
|
189 |
*/ |
8992
0b2fb43cc875
(svn r12787) -Documentation: add/fix documentation of some functions. Patch by Alberth.
rubidium
parents:
8964
diff
changeset
|
190 |
static void SetStationListsFlag(StationListFlags sl_flag) |
3812
e6fc916c17ab
(svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents:
3554
diff
changeset
|
191 |
{ |
8964
84f2e443b7be
(svn r12756) -Cleanup: variable scope and coding style in station*
smatz
parents:
8857
diff
changeset
|
192 |
Window *const *wz; |
3812
e6fc916c17ab
(svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents:
3554
diff
changeset
|
193 |
|
5124
2ca62776430e
(svn r7205) -Fix [FS#350, SF#1560913]: Window allocation and deletion messed with the actual window
Darkvater
parents:
5070
diff
changeset
|
194 |
FOR_ALL_WINDOWS(wz) { |
2ca62776430e
(svn r7205) -Fix [FS#350, SF#1560913]: Window allocation and deletion messed with the actual window
Darkvater
parents:
5070
diff
changeset
|
195 |
Window *w = *wz; |
3812
e6fc916c17ab
(svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents:
3554
diff
changeset
|
196 |
if (w->window_class == WC_STATION_LIST) { |
8992
0b2fb43cc875
(svn r12787) -Documentation: add/fix documentation of some functions. Patch by Alberth.
rubidium
parents:
8964
diff
changeset
|
197 |
WP(w, plstations_d).flags |= sl_flag; |
9116
f2491d3c321b
(svn r12976) -Codechange: use w->SetDirty() instead of SetWindowDirty(w) when it's certain that w != NULL.
rubidium
parents:
9111
diff
changeset
|
198 |
w->SetDirty(); |
3812
e6fc916c17ab
(svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents:
3554
diff
changeset
|
199 |
} |
e6fc916c17ab
(svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents:
3554
diff
changeset
|
200 |
} |
e6fc916c17ab
(svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents:
3554
diff
changeset
|
201 |
} |
e6fc916c17ab
(svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents:
3554
diff
changeset
|
202 |
|
8016
1c7062ad5f50
(svn r11576) -Codechange: enumerize and comment station GUI
smatz
parents:
8005
diff
changeset
|
203 |
/** |
8992
0b2fb43cc875
(svn r12787) -Documentation: add/fix documentation of some functions. Patch by Alberth.
rubidium
parents:
8964
diff
changeset
|
204 |
* Set the 'SL_REBUILD' flag for all station lists |
0b2fb43cc875
(svn r12787) -Documentation: add/fix documentation of some functions. Patch by Alberth.
rubidium
parents:
8964
diff
changeset
|
205 |
*/ |
0b2fb43cc875
(svn r12787) -Documentation: add/fix documentation of some functions. Patch by Alberth.
rubidium
parents:
8964
diff
changeset
|
206 |
void RebuildStationLists() |
0b2fb43cc875
(svn r12787) -Documentation: add/fix documentation of some functions. Patch by Alberth.
rubidium
parents:
8964
diff
changeset
|
207 |
{ |
0b2fb43cc875
(svn r12787) -Documentation: add/fix documentation of some functions. Patch by Alberth.
rubidium
parents:
8964
diff
changeset
|
208 |
SetStationListsFlag(SL_REBUILD); |
0b2fb43cc875
(svn r12787) -Documentation: add/fix documentation of some functions. Patch by Alberth.
rubidium
parents:
8964
diff
changeset
|
209 |
} |
0b2fb43cc875
(svn r12787) -Documentation: add/fix documentation of some functions. Patch by Alberth.
rubidium
parents:
8964
diff
changeset
|
210 |
|
0b2fb43cc875
(svn r12787) -Documentation: add/fix documentation of some functions. Patch by Alberth.
rubidium
parents:
8964
diff
changeset
|
211 |
/** |
8016
1c7062ad5f50
(svn r11576) -Codechange: enumerize and comment station GUI
smatz
parents:
8005
diff
changeset
|
212 |
* Set the 'SL_RESORT' flag for all station lists |
1c7062ad5f50
(svn r11576) -Codechange: enumerize and comment station GUI
smatz
parents:
8005
diff
changeset
|
213 |
*/ |
6247 | 214 |
void ResortStationLists() |
3812
e6fc916c17ab
(svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents:
3554
diff
changeset
|
215 |
{ |
8992
0b2fb43cc875
(svn r12787) -Documentation: add/fix documentation of some functions. Patch by Alberth.
rubidium
parents:
8964
diff
changeset
|
216 |
SetStationListsFlag(SL_RESORT); |
3812
e6fc916c17ab
(svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents:
3554
diff
changeset
|
217 |
} |
e6fc916c17ab
(svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents:
3554
diff
changeset
|
218 |
|
8016
1c7062ad5f50
(svn r11576) -Codechange: enumerize and comment station GUI
smatz
parents:
8005
diff
changeset
|
219 |
/** |
1c7062ad5f50
(svn r11576) -Codechange: enumerize and comment station GUI
smatz
parents:
8005
diff
changeset
|
220 |
* Rebuild station list if the SL_REBUILD flag is set |
1c7062ad5f50
(svn r11576) -Codechange: enumerize and comment station GUI
smatz
parents:
8005
diff
changeset
|
221 |
* |
1c7062ad5f50
(svn r11576) -Codechange: enumerize and comment station GUI
smatz
parents:
8005
diff
changeset
|
222 |
* @param sl pointer to plstations_d (station list and flags) |
1c7062ad5f50
(svn r11576) -Codechange: enumerize and comment station GUI
smatz
parents:
8005
diff
changeset
|
223 |
* @param owner player whose stations are to be in list |
1c7062ad5f50
(svn r11576) -Codechange: enumerize and comment station GUI
smatz
parents:
8005
diff
changeset
|
224 |
* @param facilities types of stations of interest |
1c7062ad5f50
(svn r11576) -Codechange: enumerize and comment station GUI
smatz
parents:
8005
diff
changeset
|
225 |
* @param cargo_filter bitmap of cargo types to include |
1c7062ad5f50
(svn r11576) -Codechange: enumerize and comment station GUI
smatz
parents:
8005
diff
changeset
|
226 |
* @param include_empty whether we should include stations without waiting cargo |
1c7062ad5f50
(svn r11576) -Codechange: enumerize and comment station GUI
smatz
parents:
8005
diff
changeset
|
227 |
*/ |
8964
84f2e443b7be
(svn r12756) -Cleanup: variable scope and coding style in station*
smatz
parents:
8857
diff
changeset
|
228 |
static void BuildStationsList(plstations_d *sl, PlayerID owner, byte facilities, uint32 cargo_filter, bool include_empty) |
3812
e6fc916c17ab
(svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents:
3554
diff
changeset
|
229 |
{ |
e6fc916c17ab
(svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents:
3554
diff
changeset
|
230 |
uint n = 0; |
243
9a40daa560ae
(svn r244) -Fix: Stations were not sorted for non-player-0 players
darkvater
parents:
222
diff
changeset
|
231 |
const Station *st; |
9a40daa560ae
(svn r244) -Fix: Stations were not sorted for non-player-0 players
darkvater
parents:
222
diff
changeset
|
232 |
|
3812
e6fc916c17ab
(svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents:
3554
diff
changeset
|
233 |
if (!(sl->flags & SL_REBUILD)) return; |
919
544f374ee392
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
893
diff
changeset
|
234 |
|
544f374ee392
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
893
diff
changeset
|
235 |
/* Create array for sorting */ |
8964
84f2e443b7be
(svn r12756) -Cleanup: variable scope and coding style in station*
smatz
parents:
8857
diff
changeset
|
236 |
const Station **station_sort = MallocT<const Station*>(GetMaxStationIndex() + 1); |
0 | 237 |
|
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5293
diff
changeset
|
238 |
DEBUG(misc, 3, "Building station list for player %d", owner); |
3812
e6fc916c17ab
(svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents:
3554
diff
changeset
|
239 |
|
0 | 240 |
FOR_ALL_STATIONS(st) { |
8109
a501ce9046c4
(svn r11670) -Feature [FS#1565]: list neutral stations where the player has service in the station list too
smatz
parents:
8107
diff
changeset
|
241 |
if (st->owner == owner || (st->owner == OWNER_NONE && !st->IsBuoy() && HasStationInUse(st->index, owner))) { |
3812
e6fc916c17ab
(svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents:
3554
diff
changeset
|
242 |
if (facilities & st->facilities) { //only stations with selected facilities |
e6fc916c17ab
(svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents:
3554
diff
changeset
|
243 |
int num_waiting_cargo = 0; |
6202
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
244 |
for (CargoID j = 0; j < NUM_CARGO; j++) { |
7010
6f0d9f03180d
(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
parents:
6990
diff
changeset
|
245 |
if (!st->goods[j].cargo.Empty()) { |
3812
e6fc916c17ab
(svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents:
3554
diff
changeset
|
246 |
num_waiting_cargo++; //count number of waiting cargo |
7928
63e18de69e50
(svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13
parents:
7886
diff
changeset
|
247 |
if (HasBit(cargo_filter, j)) { |
4268
87f1c03f1e5a
(svn r5896) Remove pointless indirection similar to r5894 and remove an unnecessary global variable
tron
parents:
4261
diff
changeset
|
248 |
station_sort[n++] = st; |
3812
e6fc916c17ab
(svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents:
3554
diff
changeset
|
249 |
break; |
e6fc916c17ab
(svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents:
3554
diff
changeset
|
250 |
} |
e6fc916c17ab
(svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents:
3554
diff
changeset
|
251 |
} |
e6fc916c17ab
(svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents:
3554
diff
changeset
|
252 |
} |
6420
456c275f3313
(svn r9556) -Documentation: doxygen and comment-style changes. 'R', 'S'.. The end of the preliminary work is near
belugas
parents:
6365
diff
changeset
|
253 |
/* stations without waiting cargo */ |
6271
a17b8a4e17e8
(svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138
parents:
6260
diff
changeset
|
254 |
if (num_waiting_cargo == 0 && include_empty) { |
4268
87f1c03f1e5a
(svn r5896) Remove pointless indirection similar to r5894 and remove an unnecessary global variable
tron
parents:
4261
diff
changeset
|
255 |
station_sort[n++] = st; |
3812
e6fc916c17ab
(svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents:
3554
diff
changeset
|
256 |
} |
e6fc916c17ab
(svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents:
3554
diff
changeset
|
257 |
} |
0 | 258 |
} |
259 |
} |
|
260 |
||
4277
345e1bd9525a
(svn r5907) Remove more indirection by using pointers instead of IDs. Also fix some bogus warnings on MSVC by using (void*) casts
tron
parents:
4268
diff
changeset
|
261 |
free((void*)sl->sort_list); |
5609
dc6a58930ba4
(svn r8066) - Codechange: MallocT(), CallocT(), ReallocT() now return the pointer to allocated memory instead of modifying the pointer given as parameter
KUDr
parents:
5608
diff
changeset
|
262 |
sl->sort_list = MallocT<const Station*>(n); |
3812
e6fc916c17ab
(svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents:
3554
diff
changeset
|
263 |
sl->list_length = n; |
0 | 264 |
|
6202
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
265 |
for (uint i = 0; i < n; ++i) sl->sort_list[i] = station_sort[i]; |
164
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
69
diff
changeset
|
266 |
|
3812
e6fc916c17ab
(svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents:
3554
diff
changeset
|
267 |
sl->flags &= ~SL_REBUILD; |
e6fc916c17ab
(svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents:
3554
diff
changeset
|
268 |
sl->flags |= SL_RESORT; |
4277
345e1bd9525a
(svn r5907) Remove more indirection by using pointers instead of IDs. Also fix some bogus warnings on MSVC by using (void*) casts
tron
parents:
4268
diff
changeset
|
269 |
free((void*)station_sort); |
243
9a40daa560ae
(svn r244) -Fix: Stations were not sorted for non-player-0 players
darkvater
parents:
222
diff
changeset
|
270 |
} |
9a40daa560ae
(svn r244) -Fix: Stations were not sorted for non-player-0 players
darkvater
parents:
222
diff
changeset
|
271 |
|
8016
1c7062ad5f50
(svn r11576) -Codechange: enumerize and comment station GUI
smatz
parents:
8005
diff
changeset
|
272 |
|
1c7062ad5f50
(svn r11576) -Codechange: enumerize and comment station GUI
smatz
parents:
8005
diff
changeset
|
273 |
/** |
1c7062ad5f50
(svn r11576) -Codechange: enumerize and comment station GUI
smatz
parents:
8005
diff
changeset
|
274 |
* Sort station list if the SL_RESORT flag is set |
1c7062ad5f50
(svn r11576) -Codechange: enumerize and comment station GUI
smatz
parents:
8005
diff
changeset
|
275 |
* |
1c7062ad5f50
(svn r11576) -Codechange: enumerize and comment station GUI
smatz
parents:
8005
diff
changeset
|
276 |
* @param sl pointer to plstations_d (station list and flags) |
1c7062ad5f50
(svn r11576) -Codechange: enumerize and comment station GUI
smatz
parents:
8005
diff
changeset
|
277 |
*/ |
3812
e6fc916c17ab
(svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents:
3554
diff
changeset
|
278 |
static void SortStationsList(plstations_d *sl) |
243
9a40daa560ae
(svn r244) -Fix: Stations were not sorted for non-player-0 players
darkvater
parents:
222
diff
changeset
|
279 |
{ |
8964
84f2e443b7be
(svn r12756) -Cleanup: variable scope and coding style in station*
smatz
parents:
8857
diff
changeset
|
280 |
static StationSortListingTypeFunction *const _station_sorter[] = { |
3812
e6fc916c17ab
(svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents:
3554
diff
changeset
|
281 |
&StationNameSorter, |
e6fc916c17ab
(svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents:
3554
diff
changeset
|
282 |
&StationTypeSorter, |
e6fc916c17ab
(svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents:
3554
diff
changeset
|
283 |
&StationWaitingSorter, |
e6fc916c17ab
(svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents:
3554
diff
changeset
|
284 |
&StationRatingMaxSorter |
e6fc916c17ab
(svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents:
3554
diff
changeset
|
285 |
}; |
164
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
69
diff
changeset
|
286 |
|
3812
e6fc916c17ab
(svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents:
3554
diff
changeset
|
287 |
if (!(sl->flags & SL_RESORT)) return; |
174
bd79fb899824
(svn r175) -Fix: [1023771] inconsistent/missing stations in station list. Forgot to change owner-sort after changing function.
darkvater
parents:
164
diff
changeset
|
288 |
|
3812
e6fc916c17ab
(svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents:
3554
diff
changeset
|
289 |
_internal_sort_order = sl->flags & SL_ORDER; |
4277
345e1bd9525a
(svn r5907) Remove more indirection by using pointers instead of IDs. Also fix some bogus warnings on MSVC by using (void*) casts
tron
parents:
4268
diff
changeset
|
290 |
_last_station = NULL; // used for "cache" in namesorting |
4280
90e7b2ea8627
(svn r5910) Fix some more warnings on MSVC by using (void*) casts. Followup of r5907.
Darkvater
parents:
4277
diff
changeset
|
291 |
qsort((void*)sl->sort_list, sl->list_length, sizeof(sl->sort_list[0]), _station_sorter[sl->sort_type]); |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
292 |
|
3812
e6fc916c17ab
(svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents:
3554
diff
changeset
|
293 |
sl->resort_timer = DAY_TICKS * PERIODIC_RESORT_DAYS; |
e6fc916c17ab
(svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents:
3554
diff
changeset
|
294 |
sl->flags &= ~SL_RESORT; |
0 | 295 |
} |
296 |
||
8016
1c7062ad5f50
(svn r11576) -Codechange: enumerize and comment station GUI
smatz
parents:
8005
diff
changeset
|
297 |
/** |
1c7062ad5f50
(svn r11576) -Codechange: enumerize and comment station GUI
smatz
parents:
8005
diff
changeset
|
298 |
* Fuction called when any WindowEvent occurs for PlayerStations window |
1c7062ad5f50
(svn r11576) -Codechange: enumerize and comment station GUI
smatz
parents:
8005
diff
changeset
|
299 |
* |
1c7062ad5f50
(svn r11576) -Codechange: enumerize and comment station GUI
smatz
parents:
8005
diff
changeset
|
300 |
* @param w pointer to the PlayerStations window |
1c7062ad5f50
(svn r11576) -Codechange: enumerize and comment station GUI
smatz
parents:
8005
diff
changeset
|
301 |
* @param e pointer to window event |
1c7062ad5f50
(svn r11576) -Codechange: enumerize and comment station GUI
smatz
parents:
8005
diff
changeset
|
302 |
*/ |
0 | 303 |
static void PlayerStationsWndProc(Window *w, WindowEvent *e) |
304 |
{ |
|
5587
167d9a91ef02
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5584
diff
changeset
|
305 |
const PlayerID owner = (PlayerID)w->window_number; |
3812
e6fc916c17ab
(svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents:
3554
diff
changeset
|
306 |
static byte facilities = FACIL_TRAIN | FACIL_TRUCK_STOP | FACIL_BUS_STOP | FACIL_AIRPORT | FACIL_DOCK; |
5608
0b0aff054402
(svn r8065) -Feature: The station list does now remember the sort settings
celestar
parents:
5587
diff
changeset
|
307 |
static Listing station_sort = {0, 0}; |
6271
a17b8a4e17e8
(svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138
parents:
6260
diff
changeset
|
308 |
static bool include_empty = true; |
5608
0b0aff054402
(svn r8065) -Feature: The station list does now remember the sort settings
celestar
parents:
5587
diff
changeset
|
309 |
|
3812
e6fc916c17ab
(svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents:
3554
diff
changeset
|
310 |
plstations_d *sl = &WP(w, plstations_d); |
3820
952119a1503d
(svn r4830) - Codechange: simplify station sorting a bit by recalculating the clicked-states on drawing the window. This also allows the 'Sort by' button to be visually clickable
Darkvater
parents:
3813
diff
changeset
|
311 |
|
2639 | 312 |
switch (e->event) { |
8016
1c7062ad5f50
(svn r11576) -Codechange: enumerize and comment station GUI
smatz
parents:
8005
diff
changeset
|
313 |
case WE_CREATE: |
6285
de042bb24d41
(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
parents:
6272
diff
changeset
|
314 |
if (_cargo_filter == _cargo_filter_max) _cargo_filter = _cargo_mask; |
6271
a17b8a4e17e8
(svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138
parents:
6260
diff
changeset
|
315 |
|
6202
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
316 |
for (uint i = 0; i < 5; i++) { |
8016
1c7062ad5f50
(svn r11576) -Codechange: enumerize and comment station GUI
smatz
parents:
8005
diff
changeset
|
317 |
if (HasBit(facilities, i)) w->LowerWidget(i + SLW_TRAIN); |
6202
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
318 |
} |
8016
1c7062ad5f50
(svn r11576) -Codechange: enumerize and comment station GUI
smatz
parents:
8005
diff
changeset
|
319 |
w->SetWidgetLoweredState(SLW_FACILALL, facilities == (FACIL_TRAIN | FACIL_TRUCK_STOP | FACIL_BUS_STOP | FACIL_AIRPORT | FACIL_DOCK)); |
1c7062ad5f50
(svn r11576) -Codechange: enumerize and comment station GUI
smatz
parents:
8005
diff
changeset
|
320 |
w->SetWidgetLoweredState(SLW_CARGOALL, _cargo_filter == _cargo_mask && include_empty); |
1c7062ad5f50
(svn r11576) -Codechange: enumerize and comment station GUI
smatz
parents:
8005
diff
changeset
|
321 |
w->SetWidgetLoweredState(SLW_NOCARGOWAITING, include_empty); |
5271
a2e9e1dd7cb2
(svn r7413) -Fix[FS#386,#412]: Station list window NONE button now behaves correctly.
belugas
parents:
5247
diff
changeset
|
322 |
|
6202
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
323 |
sl->sort_list = NULL; |
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
324 |
sl->flags = SL_REBUILD; |
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
325 |
sl->sort_type = station_sort.criteria; |
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
326 |
if (station_sort.order) sl->flags |= SL_ORDER; |
8016
1c7062ad5f50
(svn r11576) -Codechange: enumerize and comment station GUI
smatz
parents:
8005
diff
changeset
|
327 |
|
1c7062ad5f50
(svn r11576) -Codechange: enumerize and comment station GUI
smatz
parents:
8005
diff
changeset
|
328 |
/* set up resort timer */ |
6202
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
329 |
sl->resort_timer = DAY_TICKS * PERIODIC_RESORT_DAYS; |
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
330 |
break; |
5271
a2e9e1dd7cb2
(svn r7413) -Fix[FS#386,#412]: Station list window NONE button now behaves correctly.
belugas
parents:
5247
diff
changeset
|
331 |
|
6202
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
332 |
case WE_PAINT: { |
6271
a17b8a4e17e8
(svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138
parents:
6260
diff
changeset
|
333 |
BuildStationsList(sl, owner, facilities, _cargo_filter, include_empty); |
6202
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
334 |
SortStationsList(sl); |
0 | 335 |
|
6202
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
336 |
SetVScrollCount(w, sl->list_length); |
0 | 337 |
|
6202
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
338 |
/* draw widgets, with player's name in the caption */ |
7058
8105bb13ce3d
(svn r10323) -Codechange: reference company name, number and player (president) name
peter1138
parents:
7010
diff
changeset
|
339 |
SetDParam(0, owner); |
8105bb13ce3d
(svn r10323) -Codechange: reference company name, number and player (president) name
peter1138
parents:
7010
diff
changeset
|
340 |
SetDParam(1, w->vscroll.count); |
8338
598af8119b97
(svn r11904) -Codechange: use dropdown widget in 3 more windows, build vehicle, group vehicle list and station list.
peter1138
parents:
8284
diff
changeset
|
341 |
|
598af8119b97
(svn r11904) -Codechange: use dropdown widget in 3 more windows, build vehicle, group vehicle list and station list.
peter1138
parents:
8284
diff
changeset
|
342 |
/* Set text of sort by dropdown */ |
598af8119b97
(svn r11904) -Codechange: use dropdown widget in 3 more windows, build vehicle, group vehicle list and station list.
peter1138
parents:
8284
diff
changeset
|
343 |
w->widget[SLW_SORTDROPBTN].data = _station_sort_listing[sl->sort_type]; |
598af8119b97
(svn r11904) -Codechange: use dropdown widget in 3 more windows, build vehicle, group vehicle list and station list.
peter1138
parents:
8284
diff
changeset
|
344 |
|
0 | 345 |
DrawWindowWidgets(w); |
3812
e6fc916c17ab
(svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents:
3554
diff
changeset
|
346 |
|
e6fc916c17ab
(svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents:
3554
diff
changeset
|
347 |
/* draw arrow pointing up/down for ascending/descending sorting */ |
8349
e61105cb1f87
(svn r11915) -Codechange: Add a function to draw a sort button's up/down arrow. Arrows are now drawn in a consistent position based on the widget, instead of randomly positioned by pixel.
peter1138
parents:
8338
diff
changeset
|
348 |
DrawSortButtonState(w, SLW_SORTBY, sl->flags & SL_ORDER ? SBS_DOWN : SBS_UP); |
3812
e6fc916c17ab
(svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents:
3554
diff
changeset
|
349 |
|
6202
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
350 |
int cg_ofst; |
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
351 |
int x = 89; |
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
352 |
int y = 14; |
6420
456c275f3313
(svn r9556) -Documentation: doxygen and comment-style changes. 'R', 'S'.. The end of the preliminary work is near
belugas
parents:
6365
diff
changeset
|
353 |
int xb = 2; ///< offset from left of widget |
3812
e6fc916c17ab
(svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents:
3554
diff
changeset
|
354 |
|
6271
a17b8a4e17e8
(svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138
parents:
6260
diff
changeset
|
355 |
uint i = 0; |
a17b8a4e17e8
(svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138
parents:
6260
diff
changeset
|
356 |
for (CargoID c = 0; c < NUM_CARGO; c++) { |
a17b8a4e17e8
(svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138
parents:
6260
diff
changeset
|
357 |
const CargoSpec *cs = GetCargo(c); |
a17b8a4e17e8
(svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138
parents:
6260
diff
changeset
|
358 |
if (!cs->IsValid()) continue; |
a17b8a4e17e8
(svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138
parents:
6260
diff
changeset
|
359 |
|
7928
63e18de69e50
(svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13
parents:
7886
diff
changeset
|
360 |
cg_ofst = HasBit(_cargo_filter, c) ? 2 : 1; |
6271
a17b8a4e17e8
(svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138
parents:
6260
diff
changeset
|
361 |
GfxFillRect(x + cg_ofst, y + cg_ofst, x + cg_ofst + 10 , y + cg_ofst + 7, cs->rating_colour); |
7824
5a63d41b59ea
(svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents:
7474
diff
changeset
|
362 |
DrawStringCentered(x + 6 + cg_ofst, y + cg_ofst, cs->abbrev, TC_BLACK); |
3812
e6fc916c17ab
(svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents:
3554
diff
changeset
|
363 |
x += 14; |
6271
a17b8a4e17e8
(svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138
parents:
6260
diff
changeset
|
364 |
i++; |
3812
e6fc916c17ab
(svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents:
3554
diff
changeset
|
365 |
} |
e6fc916c17ab
(svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents:
3554
diff
changeset
|
366 |
|
5292
9ed70e1277db
(svn r7445) -Codechange (r4822): Properly draw the cargo colours in the station list and centre the
Darkvater
parents:
5291
diff
changeset
|
367 |
x += 6; |
8016
1c7062ad5f50
(svn r11576) -Codechange: enumerize and comment station GUI
smatz
parents:
8005
diff
changeset
|
368 |
cg_ofst = w->IsWidgetLowered(SLW_NOCARGOWAITING) ? 2 : 1; |
7824
5a63d41b59ea
(svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents:
7474
diff
changeset
|
369 |
DrawStringCentered(x + cg_ofst, y + cg_ofst, STR_ABBREV_NONE, TC_BLACK); |
3812
e6fc916c17ab
(svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents:
3554
diff
changeset
|
370 |
x += 14; |
8016
1c7062ad5f50
(svn r11576) -Codechange: enumerize and comment station GUI
smatz
parents:
8005
diff
changeset
|
371 |
cg_ofst = w->IsWidgetLowered(SLW_CARGOALL) ? 2 : 1; |
7824
5a63d41b59ea
(svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents:
7474
diff
changeset
|
372 |
DrawStringCentered(x + cg_ofst, y + cg_ofst, STR_ABBREV_ALL, TC_BLACK); |
5271
a2e9e1dd7cb2
(svn r7413) -Fix[FS#386,#412]: Station list window NONE button now behaves correctly.
belugas
parents:
5247
diff
changeset
|
373 |
|
8016
1c7062ad5f50
(svn r11576) -Codechange: enumerize and comment station GUI
smatz
parents:
8005
diff
changeset
|
374 |
cg_ofst = w->IsWidgetLowered(SLW_FACILALL) ? 2 : 1; |
7824
5a63d41b59ea
(svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents:
7474
diff
changeset
|
375 |
DrawString(71 + cg_ofst, y + cg_ofst, STR_ABBREV_ALL, TC_BLACK); |
0 | 376 |
|
2026 | 377 |
if (w->vscroll.count == 0) { // player has no stations |
7824
5a63d41b59ea
(svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents:
7474
diff
changeset
|
378 |
DrawString(xb, 40, STR_304A_NONE, TC_FROMSTRING); |
0 | 379 |
return; |
380 |
} |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
381 |
|
6202
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
382 |
int max = min(w->vscroll.pos + w->vscroll.cap, sl->list_length); |
3812
e6fc916c17ab
(svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents:
3554
diff
changeset
|
383 |
y = 40; // start of the list-widget |
0 | 384 |
|
6202
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
385 |
for (int i = w->vscroll.pos; i < max; ++i) { // do until max number of stations of owner |
5293
4cc0c1f2f95c
(svn r7446) -Feature: Double the length of the cargo and rating indicators in the station list window,
Darkvater
parents:
5292
diff
changeset
|
386 |
const Station *st = sl->sort_list[i]; |
2630 | 387 |
int x; |
0 | 388 |
|
5293
4cc0c1f2f95c
(svn r7446) -Feature: Double the length of the cargo and rating indicators in the station list window,
Darkvater
parents:
5292
diff
changeset
|
389 |
assert(st->xy != 0); |
8109
a501ce9046c4
(svn r11670) -Feature [FS#1565]: list neutral stations where the player has service in the station list too
smatz
parents:
8107
diff
changeset
|
390 |
|
8857
7593af4962e6
(svn r12619) -Codechange: lots of documentation about window related stuff. Patch by Alberth.
rubidium
parents:
8787
diff
changeset
|
391 |
/* Do not do the complex check HasStationInUse here, it may be even false |
8109
a501ce9046c4
(svn r11670) -Feature [FS#1565]: list neutral stations where the player has service in the station list too
smatz
parents:
8107
diff
changeset
|
392 |
* when the order had been removed and the station list hasn't been removed yet */ |
a501ce9046c4
(svn r11670) -Feature [FS#1565]: list neutral stations where the player has service in the station list too
smatz
parents:
8107
diff
changeset
|
393 |
assert(st->owner == owner || (st->owner == OWNER_NONE && !st->IsBuoy())); |
174
bd79fb899824
(svn r175) -Fix: [1023771] inconsistent/missing stations in station list. Forgot to change owner-sort after changing function.
darkvater
parents:
164
diff
changeset
|
394 |
|
534
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
395 |
SetDParam(0, st->index); |
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
396 |
SetDParam(1, st->facilities); |
7824
5a63d41b59ea
(svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents:
7474
diff
changeset
|
397 |
x = DrawString(xb, y, STR_3049_0, TC_FROMSTRING) + 5; |
0 | 398 |
|
6420
456c275f3313
(svn r9556) -Documentation: doxygen and comment-style changes. 'R', 'S'.. The end of the preliminary work is near
belugas
parents:
6365
diff
changeset
|
399 |
/* show cargo waiting and station ratings */ |
6350
04b19f551aec
(svn r9388) -Codechange: variable scope and type, and standardify all CargoID loops.
peter1138
parents:
6297
diff
changeset
|
400 |
for (CargoID j = 0; j < NUM_CARGO; j++) { |
7010
6f0d9f03180d
(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
parents:
6990
diff
changeset
|
401 |
if (!st->goods[j].cargo.Empty()) { |
6f0d9f03180d
(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
parents:
6990
diff
changeset
|
402 |
StationsWndShowStationRating(x, y, j, st->goods[j].cargo.Count(), st->goods[j].rating); |
5293
4cc0c1f2f95c
(svn r7446) -Feature: Double the length of the cargo and rating indicators in the station list window,
Darkvater
parents:
5292
diff
changeset
|
403 |
x += 20; |
0 | 404 |
} |
405 |
} |
|
406 |
y += 10; |
|
407 |
} |
|
4268
87f1c03f1e5a
(svn r5896) Remove pointless indirection similar to r5894 and remove an unnecessary global variable
tron
parents:
4261
diff
changeset
|
408 |
break; |
87f1c03f1e5a
(svn r5896) Remove pointless indirection similar to r5894 and remove an unnecessary global variable
tron
parents:
4261
diff
changeset
|
409 |
} |
174
bd79fb899824
(svn r175) -Fix: [1023771] inconsistent/missing stations in station list. Forgot to change owner-sort after changing function.
darkvater
parents:
164
diff
changeset
|
410 |
|
6202
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
411 |
case WE_CLICK: |
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
412 |
switch (e->we.click.widget) { |
8016
1c7062ad5f50
(svn r11576) -Codechange: enumerize and comment station GUI
smatz
parents:
8005
diff
changeset
|
413 |
case SLW_LIST: { |
6202
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
414 |
uint32 id_v = (e->we.click.pt.y - 41) / 10; |
5271
a2e9e1dd7cb2
(svn r7413) -Fix[FS#386,#412]: Station list window NONE button now behaves correctly.
belugas
parents:
5247
diff
changeset
|
415 |
|
6202
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
416 |
if (id_v >= w->vscroll.cap) return; // click out of bounds |
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
417 |
|
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
418 |
id_v += w->vscroll.pos; |
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
419 |
|
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
420 |
if (id_v >= sl->list_length) return; // click out of list bound |
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
421 |
|
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
422 |
const Station *st = sl->sort_list[id_v]; |
8109
a501ce9046c4
(svn r11670) -Feature [FS#1565]: list neutral stations where the player has service in the station list too
smatz
parents:
8107
diff
changeset
|
423 |
/* do not check HasStationInUse - it is slow and may be invalid */ |
a501ce9046c4
(svn r11670) -Feature [FS#1565]: list neutral stations where the player has service in the station list too
smatz
parents:
8107
diff
changeset
|
424 |
assert(st->owner == owner || (st->owner == OWNER_NONE && !st->IsBuoy())); |
9094
48004fcef409
(svn r12953) -Feature: Open a new viewport when ctrl-clicking on a 'Location' button, a town/station/industry list, or some news items.
peter1138
parents:
8992
diff
changeset
|
425 |
|
48004fcef409
(svn r12953) -Feature: Open a new viewport when ctrl-clicking on a 'Location' button, a town/station/industry list, or some news items.
peter1138
parents:
8992
diff
changeset
|
426 |
if (_ctrl_pressed) { |
48004fcef409
(svn r12953) -Feature: Open a new viewport when ctrl-clicking on a 'Location' button, a town/station/industry list, or some news items.
peter1138
parents:
8992
diff
changeset
|
427 |
ShowExtraViewPortWindow(st->xy); |
48004fcef409
(svn r12953) -Feature: Open a new viewport when ctrl-clicking on a 'Location' button, a town/station/industry list, or some news items.
peter1138
parents:
8992
diff
changeset
|
428 |
} else { |
48004fcef409
(svn r12953) -Feature: Open a new viewport when ctrl-clicking on a 'Location' button, a town/station/industry list, or some news items.
peter1138
parents:
8992
diff
changeset
|
429 |
ScrollMainWindowToTile(st->xy); |
48004fcef409
(svn r12953) -Feature: Open a new viewport when ctrl-clicking on a 'Location' button, a town/station/industry list, or some news items.
peter1138
parents:
8992
diff
changeset
|
430 |
} |
6202
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
431 |
break; |
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
432 |
} |
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
433 |
|
8016
1c7062ad5f50
(svn r11576) -Codechange: enumerize and comment station GUI
smatz
parents:
8005
diff
changeset
|
434 |
case SLW_TRAIN: |
1c7062ad5f50
(svn r11576) -Codechange: enumerize and comment station GUI
smatz
parents:
8005
diff
changeset
|
435 |
case SLW_TRUCK: |
1c7062ad5f50
(svn r11576) -Codechange: enumerize and comment station GUI
smatz
parents:
8005
diff
changeset
|
436 |
case SLW_BUS: |
1c7062ad5f50
(svn r11576) -Codechange: enumerize and comment station GUI
smatz
parents:
8005
diff
changeset
|
437 |
case SLW_AIRPLANE: |
1c7062ad5f50
(svn r11576) -Codechange: enumerize and comment station GUI
smatz
parents:
8005
diff
changeset
|
438 |
case SLW_SHIP: |
6202
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
439 |
if (_ctrl_pressed) { |
8016
1c7062ad5f50
(svn r11576) -Codechange: enumerize and comment station GUI
smatz
parents:
8005
diff
changeset
|
440 |
ToggleBit(facilities, e->we.click.widget - SLW_TRAIN); |
7997
df87ccd00a96
(svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents:
7932
diff
changeset
|
441 |
w->ToggleWidgetLoweredState(e->we.click.widget); |
6202
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
442 |
} else { |
8005
2318a0547719
(svn r11564) -Codechange: Increase the usage of the for_each_bit macro and rename it fitting to the naming style
skidd13
parents:
7997
diff
changeset
|
443 |
uint i; |
2318a0547719
(svn r11564) -Codechange: Increase the usage of the for_each_bit macro and rename it fitting to the naming style
skidd13
parents:
7997
diff
changeset
|
444 |
FOR_EACH_SET_BIT(i, facilities) { |
8016
1c7062ad5f50
(svn r11576) -Codechange: enumerize and comment station GUI
smatz
parents:
8005
diff
changeset
|
445 |
w->RaiseWidget(i + SLW_TRAIN); |
6202
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
446 |
} |
8016
1c7062ad5f50
(svn r11576) -Codechange: enumerize and comment station GUI
smatz
parents:
8005
diff
changeset
|
447 |
SetBit(facilities, e->we.click.widget - SLW_TRAIN); |
7997
df87ccd00a96
(svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents:
7932
diff
changeset
|
448 |
w->LowerWidget(e->we.click.widget); |
6202
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
449 |
} |
8016
1c7062ad5f50
(svn r11576) -Codechange: enumerize and comment station GUI
smatz
parents:
8005
diff
changeset
|
450 |
w->SetWidgetLoweredState(SLW_FACILALL, facilities == (FACIL_TRAIN | FACIL_TRUCK_STOP | FACIL_BUS_STOP | FACIL_AIRPORT | FACIL_DOCK)); |
6202
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
451 |
sl->flags |= SL_REBUILD; |
9116
f2491d3c321b
(svn r12976) -Codechange: use w->SetDirty() instead of SetWindowDirty(w) when it's certain that w != NULL.
rubidium
parents:
9111
diff
changeset
|
452 |
w->SetDirty(); |
6202
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
453 |
break; |
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
454 |
|
8016
1c7062ad5f50
(svn r11576) -Codechange: enumerize and comment station GUI
smatz
parents:
8005
diff
changeset
|
455 |
case SLW_FACILALL: |
6202
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
456 |
for (uint i = 0; i < 5; i++) { |
8016
1c7062ad5f50
(svn r11576) -Codechange: enumerize and comment station GUI
smatz
parents:
8005
diff
changeset
|
457 |
w->LowerWidget(i + SLW_TRAIN); |
6202
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
458 |
} |
8016
1c7062ad5f50
(svn r11576) -Codechange: enumerize and comment station GUI
smatz
parents:
8005
diff
changeset
|
459 |
w->LowerWidget(SLW_FACILALL); |
6202
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
460 |
|
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
461 |
facilities = FACIL_TRAIN | FACIL_TRUCK_STOP | FACIL_BUS_STOP | FACIL_AIRPORT | FACIL_DOCK; |
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
462 |
sl->flags |= SL_REBUILD; |
9116
f2491d3c321b
(svn r12976) -Codechange: use w->SetDirty() instead of SetWindowDirty(w) when it's certain that w != NULL.
rubidium
parents:
9111
diff
changeset
|
463 |
w->SetDirty(); |
6202
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
464 |
break; |
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
465 |
|
8016
1c7062ad5f50
(svn r11576) -Codechange: enumerize and comment station GUI
smatz
parents:
8005
diff
changeset
|
466 |
case SLW_CARGOALL: { |
6271
a17b8a4e17e8
(svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138
parents:
6260
diff
changeset
|
467 |
uint i = 0; |
a17b8a4e17e8
(svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138
parents:
6260
diff
changeset
|
468 |
for (CargoID c = 0; c < NUM_CARGO; c++) { |
a17b8a4e17e8
(svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138
parents:
6260
diff
changeset
|
469 |
if (!GetCargo(c)->IsValid()) continue; |
8016
1c7062ad5f50
(svn r11576) -Codechange: enumerize and comment station GUI
smatz
parents:
8005
diff
changeset
|
470 |
w->LowerWidget(i + SLW_CARGOSTART); |
6271
a17b8a4e17e8
(svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138
parents:
6260
diff
changeset
|
471 |
i++; |
6202
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
472 |
} |
8016
1c7062ad5f50
(svn r11576) -Codechange: enumerize and comment station GUI
smatz
parents:
8005
diff
changeset
|
473 |
w->LowerWidget(SLW_NOCARGOWAITING); |
1c7062ad5f50
(svn r11576) -Codechange: enumerize and comment station GUI
smatz
parents:
8005
diff
changeset
|
474 |
w->LowerWidget(SLW_CARGOALL); |
6202
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
475 |
|
6271
a17b8a4e17e8
(svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138
parents:
6260
diff
changeset
|
476 |
_cargo_filter = _cargo_mask; |
a17b8a4e17e8
(svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138
parents:
6260
diff
changeset
|
477 |
include_empty = true; |
6202
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
478 |
sl->flags |= SL_REBUILD; |
9116
f2491d3c321b
(svn r12976) -Codechange: use w->SetDirty() instead of SetWindowDirty(w) when it's certain that w != NULL.
rubidium
parents:
9111
diff
changeset
|
479 |
w->SetDirty(); |
6202
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
480 |
break; |
6271
a17b8a4e17e8
(svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138
parents:
6260
diff
changeset
|
481 |
} |
6202
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
482 |
|
8016
1c7062ad5f50
(svn r11576) -Codechange: enumerize and comment station GUI
smatz
parents:
8005
diff
changeset
|
483 |
case SLW_SORTBY: // flip sorting method asc/desc |
6202
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
484 |
sl->flags ^= SL_ORDER; //DESC-flag |
7928
63e18de69e50
(svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13
parents:
7886
diff
changeset
|
485 |
station_sort.order = HasBit(sl->flags, 0); |
6202
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
486 |
sl->flags |= SL_RESORT; |
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
487 |
w->flags4 |= 5 << WF_TIMEOUT_SHL; |
8016
1c7062ad5f50
(svn r11576) -Codechange: enumerize and comment station GUI
smatz
parents:
8005
diff
changeset
|
488 |
w->LowerWidget(SLW_SORTBY); |
9116
f2491d3c321b
(svn r12976) -Codechange: use w->SetDirty() instead of SetWindowDirty(w) when it's certain that w != NULL.
rubidium
parents:
9111
diff
changeset
|
489 |
w->SetDirty(); |
6202
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
490 |
break; |
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
491 |
|
8016
1c7062ad5f50
(svn r11576) -Codechange: enumerize and comment station GUI
smatz
parents:
8005
diff
changeset
|
492 |
case SLW_SORTDROPBTN: // select sorting criteria dropdown menu |
1c7062ad5f50
(svn r11576) -Codechange: enumerize and comment station GUI
smatz
parents:
8005
diff
changeset
|
493 |
ShowDropDownMenu(w, _station_sort_listing, sl->sort_type, SLW_SORTDROPBTN, 0, 0); |
6202
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
494 |
break; |
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
495 |
|
8016
1c7062ad5f50
(svn r11576) -Codechange: enumerize and comment station GUI
smatz
parents:
8005
diff
changeset
|
496 |
case SLW_NOCARGOWAITING: |
6271
a17b8a4e17e8
(svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138
parents:
6260
diff
changeset
|
497 |
if (_ctrl_pressed) { |
a17b8a4e17e8
(svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138
parents:
6260
diff
changeset
|
498 |
include_empty = !include_empty; |
8016
1c7062ad5f50
(svn r11576) -Codechange: enumerize and comment station GUI
smatz
parents:
8005
diff
changeset
|
499 |
w->ToggleWidgetLoweredState(SLW_NOCARGOWAITING); |
6271
a17b8a4e17e8
(svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138
parents:
6260
diff
changeset
|
500 |
} else { |
8016
1c7062ad5f50
(svn r11576) -Codechange: enumerize and comment station GUI
smatz
parents:
8005
diff
changeset
|
501 |
for (uint i = SLW_CARGOSTART; i < w->widget_count; i++) { |
7997
df87ccd00a96
(svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents:
7932
diff
changeset
|
502 |
w->RaiseWidget(i); |
6271
a17b8a4e17e8
(svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138
parents:
6260
diff
changeset
|
503 |
} |
a17b8a4e17e8
(svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138
parents:
6260
diff
changeset
|
504 |
|
a17b8a4e17e8
(svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138
parents:
6260
diff
changeset
|
505 |
_cargo_filter = 0; |
a17b8a4e17e8
(svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138
parents:
6260
diff
changeset
|
506 |
include_empty = true; |
a17b8a4e17e8
(svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138
parents:
6260
diff
changeset
|
507 |
|
8016
1c7062ad5f50
(svn r11576) -Codechange: enumerize and comment station GUI
smatz
parents:
8005
diff
changeset
|
508 |
w->LowerWidget(SLW_NOCARGOWAITING); |
6271
a17b8a4e17e8
(svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138
parents:
6260
diff
changeset
|
509 |
} |
a17b8a4e17e8
(svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138
parents:
6260
diff
changeset
|
510 |
sl->flags |= SL_REBUILD; |
8016
1c7062ad5f50
(svn r11576) -Codechange: enumerize and comment station GUI
smatz
parents:
8005
diff
changeset
|
511 |
w->SetWidgetLoweredState(SLW_CARGOALL, _cargo_filter == _cargo_mask && include_empty); |
9116
f2491d3c321b
(svn r12976) -Codechange: use w->SetDirty() instead of SetWindowDirty(w) when it's certain that w != NULL.
rubidium
parents:
9111
diff
changeset
|
512 |
w->SetDirty(); |
6271
a17b8a4e17e8
(svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138
parents:
6260
diff
changeset
|
513 |
break; |
a17b8a4e17e8
(svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138
parents:
6260
diff
changeset
|
514 |
|
6202
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
515 |
default: |
8016
1c7062ad5f50
(svn r11576) -Codechange: enumerize and comment station GUI
smatz
parents:
8005
diff
changeset
|
516 |
if (e->we.click.widget >= SLW_CARGOSTART) { // change cargo_filter |
6271
a17b8a4e17e8
(svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138
parents:
6260
diff
changeset
|
517 |
/* Determine the selected cargo type */ |
a17b8a4e17e8
(svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138
parents:
6260
diff
changeset
|
518 |
CargoID c; |
a17b8a4e17e8
(svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138
parents:
6260
diff
changeset
|
519 |
int i = 0; |
a17b8a4e17e8
(svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138
parents:
6260
diff
changeset
|
520 |
for (c = 0; c < NUM_CARGO; c++) { |
a17b8a4e17e8
(svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138
parents:
6260
diff
changeset
|
521 |
if (!GetCargo(c)->IsValid()) continue; |
8016
1c7062ad5f50
(svn r11576) -Codechange: enumerize and comment station GUI
smatz
parents:
8005
diff
changeset
|
522 |
if (e->we.click.widget - SLW_CARGOSTART == i) break; |
6271
a17b8a4e17e8
(svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138
parents:
6260
diff
changeset
|
523 |
i++; |
a17b8a4e17e8
(svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138
parents:
6260
diff
changeset
|
524 |
} |
a17b8a4e17e8
(svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138
parents:
6260
diff
changeset
|
525 |
|
6202
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
526 |
if (_ctrl_pressed) { |
7932
6c3d71e8a129
(svn r11485) -Codechange: Remove the doubled function ToggleBitT and rename the remaining to fit with the naming style
skidd13
parents:
7931
diff
changeset
|
527 |
ToggleBit(_cargo_filter, c); |
7997
df87ccd00a96
(svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents:
7932
diff
changeset
|
528 |
w->ToggleWidgetLoweredState(e->we.click.widget); |
6202
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
529 |
} else { |
8016
1c7062ad5f50
(svn r11576) -Codechange: enumerize and comment station GUI
smatz
parents:
8005
diff
changeset
|
530 |
for (uint i = SLW_CARGOSTART; i < w->widget_count; i++) { |
7997
df87ccd00a96
(svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents:
7932
diff
changeset
|
531 |
w->RaiseWidget(i); |
6202
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
532 |
} |
8016
1c7062ad5f50
(svn r11576) -Codechange: enumerize and comment station GUI
smatz
parents:
8005
diff
changeset
|
533 |
w->RaiseWidget(SLW_NOCARGOWAITING); |
6271
a17b8a4e17e8
(svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138
parents:
6260
diff
changeset
|
534 |
|
a17b8a4e17e8
(svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138
parents:
6260
diff
changeset
|
535 |
_cargo_filter = 0; |
a17b8a4e17e8
(svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138
parents:
6260
diff
changeset
|
536 |
include_empty = false; |
a17b8a4e17e8
(svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138
parents:
6260
diff
changeset
|
537 |
|
7931
b0a46cd92225
(svn r11484) -Codechange: Remove the doubled function SetBitT and rename the remaining to fit with the naming style
skidd13
parents:
7928
diff
changeset
|
538 |
SetBit(_cargo_filter, c); |
7997
df87ccd00a96
(svn r11555) -Codechange: use the new members introduced in r11551.
rubidium
parents:
7932
diff
changeset
|
539 |
w->LowerWidget(e->we.click.widget); |
6202
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
540 |
} |
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
541 |
sl->flags |= SL_REBUILD; |
8016
1c7062ad5f50
(svn r11576) -Codechange: enumerize and comment station GUI
smatz
parents:
8005
diff
changeset
|
542 |
w->SetWidgetLoweredState(SLW_CARGOALL, _cargo_filter == _cargo_mask && include_empty); |
9116
f2491d3c321b
(svn r12976) -Codechange: use w->SetDirty() instead of SetWindowDirty(w) when it's certain that w != NULL.
rubidium
parents:
9111
diff
changeset
|
543 |
w->SetDirty(); |
6202
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
544 |
} |
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
545 |
break; |
4719
fc6e14219f72
(svn r6631) -Codechange: Use accessors for click_state.
belugas
parents:
4709
diff
changeset
|
546 |
} |
3812
e6fc916c17ab
(svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents:
3554
diff
changeset
|
547 |
break; |
6202
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
548 |
|
8016
1c7062ad5f50
(svn r11576) -Codechange: enumerize and comment station GUI
smatz
parents:
8005
diff
changeset
|
549 |
case WE_DROPDOWN_SELECT: // we have selected a dropdown item in the list |
6202
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
550 |
if (sl->sort_type != e->we.dropdown.index) { |
6420
456c275f3313
(svn r9556) -Documentation: doxygen and comment-style changes. 'R', 'S'.. The end of the preliminary work is near
belugas
parents:
6365
diff
changeset
|
551 |
/* value has changed -> resort */ |
6202
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
552 |
sl->sort_type = e->we.dropdown.index; |
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
553 |
station_sort.criteria = sl->sort_type; |
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
554 |
sl->flags |= SL_RESORT; |
4719
fc6e14219f72
(svn r6631) -Codechange: Use accessors for click_state.
belugas
parents:
4709
diff
changeset
|
555 |
} |
9116
f2491d3c321b
(svn r12976) -Codechange: use w->SetDirty() instead of SetWindowDirty(w) when it's certain that w != NULL.
rubidium
parents:
9111
diff
changeset
|
556 |
w->SetDirty(); |
3812
e6fc916c17ab
(svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents:
3554
diff
changeset
|
557 |
break; |
5271
a2e9e1dd7cb2
(svn r7413) -Fix[FS#386,#412]: Station list window NONE button now behaves correctly.
belugas
parents:
5247
diff
changeset
|
558 |
|
6202
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
559 |
case WE_TICK: |
8179
60c4282e6de6
(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
parents:
8144
diff
changeset
|
560 |
if (_pause_game != 0) break; |
6202
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
561 |
if (--sl->resort_timer == 0) { |
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
562 |
DEBUG(misc, 3, "Periodic rebuild station list player %d", owner); |
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
563 |
sl->resort_timer = DAY_TICKS * PERIODIC_RESORT_DAYS; |
3812
e6fc916c17ab
(svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents:
3554
diff
changeset
|
564 |
sl->flags |= SL_REBUILD; |
9116
f2491d3c321b
(svn r12976) -Codechange: use w->SetDirty() instead of SetWindowDirty(w) when it's certain that w != NULL.
rubidium
parents:
9111
diff
changeset
|
565 |
w->SetDirty(); |
3812
e6fc916c17ab
(svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents:
3554
diff
changeset
|
566 |
} |
6202
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
567 |
break; |
0 | 568 |
|
6202
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
569 |
case WE_TIMEOUT: |
8016
1c7062ad5f50
(svn r11576) -Codechange: enumerize and comment station GUI
smatz
parents:
8005
diff
changeset
|
570 |
w->RaiseWidget(SLW_SORTBY); |
9116
f2491d3c321b
(svn r12976) -Codechange: use w->SetDirty() instead of SetWindowDirty(w) when it's certain that w != NULL.
rubidium
parents:
9111
diff
changeset
|
571 |
w->SetDirty(); |
6202
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
572 |
break; |
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
817
diff
changeset
|
573 |
|
6202
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
574 |
case WE_RESIZE: |
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
575 |
w->vscroll.cap += e->we.sizing.diff.y / 10; |
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
576 |
break; |
0 | 577 |
} |
578 |
} |
|
579 |
||
580 |
static const Widget _player_stations_widgets[] = { |
|
8016
1c7062ad5f50
(svn r11576) -Codechange: enumerize and comment station GUI
smatz
parents:
8005
diff
changeset
|
581 |
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, // SLW_CLOSEBOX |
3554
86230061c3e7
(svn r4426) Code Cleaning : replacing tabs with spaces, removing obvious comments, aligning arrays etc...
belugas
parents:
2725
diff
changeset
|
582 |
{ WWT_CAPTION, RESIZE_RIGHT, 14, 11, 345, 0, 13, STR_3048_STATIONS, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
86230061c3e7
(svn r4426) Code Cleaning : replacing tabs with spaces, removing obvious comments, aligning arrays etc...
belugas
parents:
2725
diff
changeset
|
583 |
{ WWT_STICKYBOX, RESIZE_LR, 14, 346, 357, 0, 13, 0x0, STR_STICKY_BUTTON}, |
8016
1c7062ad5f50
(svn r11576) -Codechange: enumerize and comment station GUI
smatz
parents:
8005
diff
changeset
|
584 |
{ WWT_PANEL, RESIZE_RB, 14, 0, 345, 37, 161, 0x0, STR_3057_STATION_NAMES_CLICK_ON}, // SLW_LIST |
5128
16f5e3981050
(svn r7209) -Codechange: Alter position of scroll bar in the station list; the filter line isn't scrollable...
peter1138
parents:
5124
diff
changeset
|
585 |
{ WWT_SCROLLBAR, RESIZE_LRB, 14, 346, 357, 37, 149, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST}, |
3812
e6fc916c17ab
(svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents:
3554
diff
changeset
|
586 |
{ WWT_RESIZEBOX, RESIZE_LRTB, 14, 346, 357, 150, 161, 0x0, STR_RESIZE_BUTTON}, |
e6fc916c17ab
(svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents:
3554
diff
changeset
|
587 |
|
8016
1c7062ad5f50
(svn r11576) -Codechange: enumerize and comment station GUI
smatz
parents:
8005
diff
changeset
|
588 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 0, 13, 14, 24, STR_TRAIN, STR_USE_CTRL_TO_SELECT_MORE}, // SLW_TRAIN |
1c7062ad5f50
(svn r11576) -Codechange: enumerize and comment station GUI
smatz
parents:
8005
diff
changeset
|
589 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 14, 27, 14, 24, STR_LORRY, STR_USE_CTRL_TO_SELECT_MORE}, // SLW_TRUCK |
1c7062ad5f50
(svn r11576) -Codechange: enumerize and comment station GUI
smatz
parents:
8005
diff
changeset
|
590 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 28, 41, 14, 24, STR_BUS, STR_USE_CTRL_TO_SELECT_MORE}, // SLW_BUS |
1c7062ad5f50
(svn r11576) -Codechange: enumerize and comment station GUI
smatz
parents:
8005
diff
changeset
|
591 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 42, 55, 14, 24, STR_PLANE, STR_USE_CTRL_TO_SELECT_MORE}, // SLW_AIRPLANE |
1c7062ad5f50
(svn r11576) -Codechange: enumerize and comment station GUI
smatz
parents:
8005
diff
changeset
|
592 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 56, 69, 14, 24, STR_SHIP, STR_USE_CTRL_TO_SELECT_MORE}, // SLW_SHIP |
1c7062ad5f50
(svn r11576) -Codechange: enumerize and comment station GUI
smatz
parents:
8005
diff
changeset
|
593 |
{ WWT_PANEL, RESIZE_NONE, 14, 70, 83, 14, 24, 0x0, STR_SELECT_ALL_FACILITIES}, // SLW_FACILALL |
3812
e6fc916c17ab
(svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents:
3554
diff
changeset
|
594 |
|
8016
1c7062ad5f50
(svn r11576) -Codechange: enumerize and comment station GUI
smatz
parents:
8005
diff
changeset
|
595 |
{ WWT_PANEL, RESIZE_NONE, 14, 83, 88, 14, 24, 0x0, STR_NULL}, // SLW_PAN_BETWEEN |
1c7062ad5f50
(svn r11576) -Codechange: enumerize and comment station GUI
smatz
parents:
8005
diff
changeset
|
596 |
{ WWT_PANEL, RESIZE_NONE, 14, 89, 102, 14, 24, 0x0, STR_NO_WAITING_CARGO}, // SLW_NOCARGOWAITING |
1c7062ad5f50
(svn r11576) -Codechange: enumerize and comment station GUI
smatz
parents:
8005
diff
changeset
|
597 |
{ WWT_PANEL, RESIZE_NONE, 14, 103, 116, 14, 24, 0x0, STR_SELECT_ALL_TYPES}, // SLW_CARGOALL |
1c7062ad5f50
(svn r11576) -Codechange: enumerize and comment station GUI
smatz
parents:
8005
diff
changeset
|
598 |
{ WWT_PANEL, RESIZE_RIGHT, 14, 117, 357, 14, 24, 0x0, STR_NULL}, // SLW_PAN_RIGHT |
1c7062ad5f50
(svn r11576) -Codechange: enumerize and comment station GUI
smatz
parents:
8005
diff
changeset
|
599 |
|
1c7062ad5f50
(svn r11576) -Codechange: enumerize and comment station GUI
smatz
parents:
8005
diff
changeset
|
600 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 0, 80, 25, 36, STR_SORT_BY, STR_SORT_ORDER_TIP}, // SLW_SORTBY |
8338
598af8119b97
(svn r11904) -Codechange: use dropdown widget in 3 more windows, build vehicle, group vehicle list and station list.
peter1138
parents:
8284
diff
changeset
|
601 |
{ WWT_DROPDOWN, RESIZE_NONE, 14, 81, 243, 25, 36, 0x0, STR_SORT_CRITERIA_TIP}, // SLW_SORTDROPBTN |
8016
1c7062ad5f50
(svn r11576) -Codechange: enumerize and comment station GUI
smatz
parents:
8005
diff
changeset
|
602 |
{ WWT_PANEL, RESIZE_RIGHT, 14, 244, 357, 25, 36, 0x0, STR_NULL}, // SLW_PAN_SORT_RIGHT |
176
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
174
diff
changeset
|
603 |
{ WIDGETS_END}, |
0 | 604 |
}; |
605 |
||
606 |
static const WindowDesc _player_stations_desc = { |
|
7341
02515d0d4ced
(svn r10704) -Codechange: provide an infrastructure to have resizable windows that are smaller than the default window size.
rubidium
parents:
7058
diff
changeset
|
607 |
WDP_AUTO, WDP_AUTO, 358, 162, 358, 162, |
5893
7e431a4abebb
(svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents:
5745
diff
changeset
|
608 |
WC_STATION_LIST, WC_NONE, |
5271
a2e9e1dd7cb2
(svn r7413) -Fix[FS#386,#412]: Station list window NONE button now behaves correctly.
belugas
parents:
5247
diff
changeset
|
609 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_STICKY_BUTTON | WDF_RESIZABLE, |
0 | 610 |
_player_stations_widgets, |
611 |
PlayerStationsWndProc |
|
612 |
}; |
|
613 |
||
8016
1c7062ad5f50
(svn r11576) -Codechange: enumerize and comment station GUI
smatz
parents:
8005
diff
changeset
|
614 |
/** |
1c7062ad5f50
(svn r11576) -Codechange: enumerize and comment station GUI
smatz
parents:
8005
diff
changeset
|
615 |
* Opens window with list of player's stations |
1c7062ad5f50
(svn r11576) -Codechange: enumerize and comment station GUI
smatz
parents:
8005
diff
changeset
|
616 |
* |
1c7062ad5f50
(svn r11576) -Codechange: enumerize and comment station GUI
smatz
parents:
8005
diff
changeset
|
617 |
* @param player player whose stations' list show |
1c7062ad5f50
(svn r11576) -Codechange: enumerize and comment station GUI
smatz
parents:
8005
diff
changeset
|
618 |
*/ |
2475 | 619 |
void ShowPlayerStations(PlayerID player) |
0 | 620 |
{ |
5005
f5086bd3945a
(svn r7022) -Fix [FS#292]: Properly guard against viewing company-sensitive information from
Darkvater
parents:
4938
diff
changeset
|
621 |
if (!IsValidPlayer(player)) return; |
f5086bd3945a
(svn r7022) -Fix [FS#292]: Properly guard against viewing company-sensitive information from
Darkvater
parents:
4938
diff
changeset
|
622 |
|
6202
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
623 |
Window *w = AllocateWindowDescFront(&_player_stations_desc, player); |
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
624 |
if (w == NULL) return; |
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
625 |
|
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
626 |
w->caption_color = (byte)w->window_number; |
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
627 |
w->vscroll.cap = 12; |
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
628 |
w->resize.step_height = 10; |
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
629 |
w->resize.height = w->height - 10 * 7; // minimum if 5 in the list |
6271
a17b8a4e17e8
(svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138
parents:
6260
diff
changeset
|
630 |
|
a17b8a4e17e8
(svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138
parents:
6260
diff
changeset
|
631 |
/* Add cargo filter buttons */ |
a17b8a4e17e8
(svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138
parents:
6260
diff
changeset
|
632 |
uint num_active = 0; |
a17b8a4e17e8
(svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138
parents:
6260
diff
changeset
|
633 |
for (CargoID c = 0; c < NUM_CARGO; c++) { |
a17b8a4e17e8
(svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138
parents:
6260
diff
changeset
|
634 |
if (GetCargo(c)->IsValid()) num_active++; |
a17b8a4e17e8
(svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138
parents:
6260
diff
changeset
|
635 |
} |
a17b8a4e17e8
(svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138
parents:
6260
diff
changeset
|
636 |
|
a17b8a4e17e8
(svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138
parents:
6260
diff
changeset
|
637 |
w->widget_count += num_active; |
a17b8a4e17e8
(svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138
parents:
6260
diff
changeset
|
638 |
w->widget = ReallocT(w->widget, w->widget_count + 1); |
a17b8a4e17e8
(svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138
parents:
6260
diff
changeset
|
639 |
w->widget[w->widget_count].type = WWT_LAST; |
a17b8a4e17e8
(svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138
parents:
6260
diff
changeset
|
640 |
|
a17b8a4e17e8
(svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138
parents:
6260
diff
changeset
|
641 |
uint i = 0; |
a17b8a4e17e8
(svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138
parents:
6260
diff
changeset
|
642 |
for (CargoID c = 0; c < NUM_CARGO; c++) { |
a17b8a4e17e8
(svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138
parents:
6260
diff
changeset
|
643 |
if (!GetCargo(c)->IsValid()) continue; |
a17b8a4e17e8
(svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138
parents:
6260
diff
changeset
|
644 |
|
8016
1c7062ad5f50
(svn r11576) -Codechange: enumerize and comment station GUI
smatz
parents:
8005
diff
changeset
|
645 |
Widget *wi = &w->widget[SLW_CARGOSTART + i]; |
6271
a17b8a4e17e8
(svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138
parents:
6260
diff
changeset
|
646 |
wi->type = WWT_PANEL; |
a17b8a4e17e8
(svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138
parents:
6260
diff
changeset
|
647 |
wi->display_flags = RESIZE_NONE; |
a17b8a4e17e8
(svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138
parents:
6260
diff
changeset
|
648 |
wi->color = 14; |
a17b8a4e17e8
(svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138
parents:
6260
diff
changeset
|
649 |
wi->left = 89 + i * 14; |
a17b8a4e17e8
(svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138
parents:
6260
diff
changeset
|
650 |
wi->right = wi->left + 13; |
a17b8a4e17e8
(svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138
parents:
6260
diff
changeset
|
651 |
wi->top = 14; |
a17b8a4e17e8
(svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138
parents:
6260
diff
changeset
|
652 |
wi->bottom = 24; |
a17b8a4e17e8
(svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138
parents:
6260
diff
changeset
|
653 |
wi->data = 0; |
a17b8a4e17e8
(svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138
parents:
6260
diff
changeset
|
654 |
wi->tooltips = STR_USE_CTRL_TO_SELECT_MORE; |
a17b8a4e17e8
(svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138
parents:
6260
diff
changeset
|
655 |
|
8016
1c7062ad5f50
(svn r11576) -Codechange: enumerize and comment station GUI
smatz
parents:
8005
diff
changeset
|
656 |
if (HasBit(_cargo_filter, c)) w->LowerWidget(SLW_CARGOSTART + i); |
6271
a17b8a4e17e8
(svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138
parents:
6260
diff
changeset
|
657 |
i++; |
a17b8a4e17e8
(svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138
parents:
6260
diff
changeset
|
658 |
} |
a17b8a4e17e8
(svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138
parents:
6260
diff
changeset
|
659 |
|
8016
1c7062ad5f50
(svn r11576) -Codechange: enumerize and comment station GUI
smatz
parents:
8005
diff
changeset
|
660 |
w->widget[SLW_NOCARGOWAITING].left += num_active * 14; |
1c7062ad5f50
(svn r11576) -Codechange: enumerize and comment station GUI
smatz
parents:
8005
diff
changeset
|
661 |
w->widget[SLW_NOCARGOWAITING].right += num_active * 14; |
1c7062ad5f50
(svn r11576) -Codechange: enumerize and comment station GUI
smatz
parents:
8005
diff
changeset
|
662 |
w->widget[SLW_CARGOALL].left += num_active * 14; |
1c7062ad5f50
(svn r11576) -Codechange: enumerize and comment station GUI
smatz
parents:
8005
diff
changeset
|
663 |
w->widget[SLW_CARGOALL].right += num_active * 14; |
1c7062ad5f50
(svn r11576) -Codechange: enumerize and comment station GUI
smatz
parents:
8005
diff
changeset
|
664 |
w->widget[SLW_PAN_RIGHT].left += num_active * 14; |
6271
a17b8a4e17e8
(svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138
parents:
6260
diff
changeset
|
665 |
|
a17b8a4e17e8
(svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138
parents:
6260
diff
changeset
|
666 |
if (num_active > 15) { |
a17b8a4e17e8
(svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138
parents:
6260
diff
changeset
|
667 |
/* Resize and fix the minimum width, if necessary */ |
a17b8a4e17e8
(svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138
parents:
6260
diff
changeset
|
668 |
ResizeWindow(w, (num_active - 15) * 14, 0); |
a17b8a4e17e8
(svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138
parents:
6260
diff
changeset
|
669 |
w->resize.width = w->width; |
a17b8a4e17e8
(svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138
parents:
6260
diff
changeset
|
670 |
} |
0 | 671 |
} |
672 |
||
673 |
static const Widget _station_view_widgets[] = { |
|
8016
1c7062ad5f50
(svn r11576) -Codechange: enumerize and comment station GUI
smatz
parents:
8005
diff
changeset
|
674 |
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, // SVW_CLOSEBOX |
8420
4ebc9752e7bd
(svn r11990) -Codechange: Show all cargo sources (en-route from) in the station view
peter1138
parents:
8349
diff
changeset
|
675 |
{ WWT_CAPTION, RESIZE_RIGHT, 14, 11, 236, 0, 13, STR_300A_0, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
4ebc9752e7bd
(svn r11990) -Codechange: Show all cargo sources (en-route from) in the station view
peter1138
parents:
8349
diff
changeset
|
676 |
{ WWT_STICKYBOX, RESIZE_LR, 14, 237, 248, 0, 13, 0x0, STR_STICKY_BUTTON}, |
4ebc9752e7bd
(svn r11990) -Codechange: Show all cargo sources (en-route from) in the station view
peter1138
parents:
8349
diff
changeset
|
677 |
{ WWT_PANEL, RESIZE_RB, 14, 0, 236, 14, 65, 0x0, STR_NULL}, // SVW_WAITING |
4ebc9752e7bd
(svn r11990) -Codechange: Show all cargo sources (en-route from) in the station view
peter1138
parents:
8349
diff
changeset
|
678 |
{ WWT_SCROLLBAR, RESIZE_LRB, 14, 237, 248, 14, 65, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST}, |
4ebc9752e7bd
(svn r11990) -Codechange: Show all cargo sources (en-route from) in the station view
peter1138
parents:
8349
diff
changeset
|
679 |
{ WWT_PANEL, RESIZE_RTB, 14, 0, 248, 66, 97, 0x0, STR_NULL}, // SVW_ACCEPTLIST / SVW_RATINGLIST |
4ebc9752e7bd
(svn r11990) -Codechange: Show all cargo sources (en-route from) in the station view
peter1138
parents:
8349
diff
changeset
|
680 |
{ WWT_PUSHTXTBTN, RESIZE_TB, 14, 0, 59, 98, 109, STR_00E4_LOCATION, STR_3053_CENTER_MAIN_VIEW_ON_STATION}, // SVW_LOCATION |
4ebc9752e7bd
(svn r11990) -Codechange: Show all cargo sources (en-route from) in the station view
peter1138
parents:
8349
diff
changeset
|
681 |
{ WWT_PUSHTXTBTN, RESIZE_TB, 14, 60, 120, 98, 109, STR_3032_RATINGS, STR_3054_SHOW_STATION_RATINGS}, // SVW_RATINGS / SVW_ACCEPTS |
4ebc9752e7bd
(svn r11990) -Codechange: Show all cargo sources (en-route from) in the station view
peter1138
parents:
8349
diff
changeset
|
682 |
{ WWT_PUSHTXTBTN, RESIZE_RTB, 14, 121, 180, 98, 109, STR_0130_RENAME, STR_3055_CHANGE_NAME_OF_STATION}, // SVW_RENAME |
4ebc9752e7bd
(svn r11990) -Codechange: Show all cargo sources (en-route from) in the station view
peter1138
parents:
8349
diff
changeset
|
683 |
{ WWT_PUSHTXTBTN, RESIZE_LRTB, 14, 181, 194, 98, 109, STR_TRAIN, STR_SCHEDULED_TRAINS_TIP }, // SVW_TRAINS |
4ebc9752e7bd
(svn r11990) -Codechange: Show all cargo sources (en-route from) in the station view
peter1138
parents:
8349
diff
changeset
|
684 |
{ WWT_PUSHTXTBTN, RESIZE_LRTB, 14, 195, 208, 98, 109, STR_LORRY, STR_SCHEDULED_ROAD_VEHICLES_TIP }, // SVW_ROADVEHS |
4ebc9752e7bd
(svn r11990) -Codechange: Show all cargo sources (en-route from) in the station view
peter1138
parents:
8349
diff
changeset
|
685 |
{ WWT_PUSHTXTBTN, RESIZE_LRTB, 14, 209, 222, 98, 109, STR_PLANE, STR_SCHEDULED_AIRCRAFT_TIP }, // SVW_PLANES |
4ebc9752e7bd
(svn r11990) -Codechange: Show all cargo sources (en-route from) in the station view
peter1138
parents:
8349
diff
changeset
|
686 |
{ WWT_PUSHTXTBTN, RESIZE_LRTB, 14, 223, 236, 98, 109, STR_SHIP, STR_SCHEDULED_SHIPS_TIP }, // SVW_SHIPS |
4ebc9752e7bd
(svn r11990) -Codechange: Show all cargo sources (en-route from) in the station view
peter1138
parents:
8349
diff
changeset
|
687 |
{ WWT_RESIZEBOX, RESIZE_LRTB, 14, 237, 248, 98, 109, 0x0, STR_RESIZE_BUTTON}, |
176
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
174
diff
changeset
|
688 |
{ WIDGETS_END}, |
0 | 689 |
}; |
690 |
||
8762
bbe195577e21
(svn r12458) -Codechange: split acquiring the sprite ID for cargos from the actual drawing of them.
rubidium
parents:
8750
diff
changeset
|
691 |
SpriteID GetCargoSprite(CargoID i) |
6364
ec741938a286
(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
parents:
6350
diff
changeset
|
692 |
{ |
ec741938a286
(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
parents:
6350
diff
changeset
|
693 |
const CargoSpec *cs = GetCargo(i); |
6365
b52bd4ca10b6
(svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents:
6364
diff
changeset
|
694 |
SpriteID sprite; |
b52bd4ca10b6
(svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents:
6364
diff
changeset
|
695 |
|
b52bd4ca10b6
(svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents:
6364
diff
changeset
|
696 |
if (cs->sprite == 0xFFFF) { |
b52bd4ca10b6
(svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents:
6364
diff
changeset
|
697 |
/* A value of 0xFFFF indicates we should draw a custom icon */ |
b52bd4ca10b6
(svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents:
6364
diff
changeset
|
698 |
sprite = GetCustomCargoSprite(cs); |
b52bd4ca10b6
(svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents:
6364
diff
changeset
|
699 |
} else { |
b52bd4ca10b6
(svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents:
6364
diff
changeset
|
700 |
sprite = cs->sprite; |
b52bd4ca10b6
(svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents:
6364
diff
changeset
|
701 |
} |
b52bd4ca10b6
(svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents:
6364
diff
changeset
|
702 |
|
6657
75f1dccae0dd
(svn r9888) -Codechange: [NewGRF] allow non-spec cargo action2s to work, and using the goods sprite if really nothing is returned.
peter1138
parents:
6420
diff
changeset
|
703 |
if (sprite == 0) sprite = SPR_CARGO_GOODS; |
6364
ec741938a286
(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
parents:
6350
diff
changeset
|
704 |
|
8762
bbe195577e21
(svn r12458) -Codechange: split acquiring the sprite ID for cargos from the actual drawing of them.
rubidium
parents:
8750
diff
changeset
|
705 |
return sprite; |
bbe195577e21
(svn r12458) -Codechange: split acquiring the sprite ID for cargos from the actual drawing of them.
rubidium
parents:
8750
diff
changeset
|
706 |
} |
bbe195577e21
(svn r12458) -Codechange: split acquiring the sprite ID for cargos from the actual drawing of them.
rubidium
parents:
8750
diff
changeset
|
707 |
|
bbe195577e21
(svn r12458) -Codechange: split acquiring the sprite ID for cargos from the actual drawing of them.
rubidium
parents:
8750
diff
changeset
|
708 |
/** |
bbe195577e21
(svn r12458) -Codechange: split acquiring the sprite ID for cargos from the actual drawing of them.
rubidium
parents:
8750
diff
changeset
|
709 |
* Draws icons of waiting cargo in the StationView window |
bbe195577e21
(svn r12458) -Codechange: split acquiring the sprite ID for cargos from the actual drawing of them.
rubidium
parents:
8750
diff
changeset
|
710 |
* |
bbe195577e21
(svn r12458) -Codechange: split acquiring the sprite ID for cargos from the actual drawing of them.
rubidium
parents:
8750
diff
changeset
|
711 |
* @param i type of cargo |
bbe195577e21
(svn r12458) -Codechange: split acquiring the sprite ID for cargos from the actual drawing of them.
rubidium
parents:
8750
diff
changeset
|
712 |
* @param waiting number of waiting units |
bbe195577e21
(svn r12458) -Codechange: split acquiring the sprite ID for cargos from the actual drawing of them.
rubidium
parents:
8750
diff
changeset
|
713 |
* @param x x on-screen coordinate where to start with drawing icons |
bbe195577e21
(svn r12458) -Codechange: split acquiring the sprite ID for cargos from the actual drawing of them.
rubidium
parents:
8750
diff
changeset
|
714 |
* @param y y coordinate |
bbe195577e21
(svn r12458) -Codechange: split acquiring the sprite ID for cargos from the actual drawing of them.
rubidium
parents:
8750
diff
changeset
|
715 |
*/ |
bbe195577e21
(svn r12458) -Codechange: split acquiring the sprite ID for cargos from the actual drawing of them.
rubidium
parents:
8750
diff
changeset
|
716 |
static void DrawCargoIcons(CargoID i, uint waiting, int x, int y, uint width) |
bbe195577e21
(svn r12458) -Codechange: split acquiring the sprite ID for cargos from the actual drawing of them.
rubidium
parents:
8750
diff
changeset
|
717 |
{ |
bbe195577e21
(svn r12458) -Codechange: split acquiring the sprite ID for cargos from the actual drawing of them.
rubidium
parents:
8750
diff
changeset
|
718 |
uint num = min((waiting + 5) / 10, width / 10); // maximum is width / 10 icons so it won't overflow |
bbe195577e21
(svn r12458) -Codechange: split acquiring the sprite ID for cargos from the actual drawing of them.
rubidium
parents:
8750
diff
changeset
|
719 |
if (num == 0) return; |
bbe195577e21
(svn r12458) -Codechange: split acquiring the sprite ID for cargos from the actual drawing of them.
rubidium
parents:
8750
diff
changeset
|
720 |
|
bbe195577e21
(svn r12458) -Codechange: split acquiring the sprite ID for cargos from the actual drawing of them.
rubidium
parents:
8750
diff
changeset
|
721 |
SpriteID sprite = GetCargoSprite(i); |
bbe195577e21
(svn r12458) -Codechange: split acquiring the sprite ID for cargos from the actual drawing of them.
rubidium
parents:
8750
diff
changeset
|
722 |
|
6364
ec741938a286
(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
parents:
6350
diff
changeset
|
723 |
do { |
ec741938a286
(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
parents:
6350
diff
changeset
|
724 |
DrawSprite(sprite, PAL_NONE, x, y); |
ec741938a286
(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
parents:
6350
diff
changeset
|
725 |
x += 10; |
ec741938a286
(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
parents:
6350
diff
changeset
|
726 |
} while (--num); |
ec741938a286
(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
parents:
6350
diff
changeset
|
727 |
} |
ec741938a286
(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
parents:
6350
diff
changeset
|
728 |
|
8750
375a8bcd4948
(svn r12446) -Feature: Add +/- toggle buttons to station cargo waiting list to show/hide the detailed transferred cargo information.
peter1138
parents:
8719
diff
changeset
|
729 |
struct stationview_d { |
375a8bcd4948
(svn r12446) -Feature: Add +/- toggle buttons to station cargo waiting list to show/hide the detailed transferred cargo information.
peter1138
parents:
8719
diff
changeset
|
730 |
uint32 cargo; ///< Bitmask of cargo types to expand |
375a8bcd4948
(svn r12446) -Feature: Add +/- toggle buttons to station cargo waiting list to show/hide the detailed transferred cargo information.
peter1138
parents:
8719
diff
changeset
|
731 |
uint16 cargo_rows[NUM_CARGO]; ///< Header row for each cargo type |
375a8bcd4948
(svn r12446) -Feature: Add +/- toggle buttons to station cargo waiting list to show/hide the detailed transferred cargo information.
peter1138
parents:
8719
diff
changeset
|
732 |
}; |
375a8bcd4948
(svn r12446) -Feature: Add +/- toggle buttons to station cargo waiting list to show/hide the detailed transferred cargo information.
peter1138
parents:
8719
diff
changeset
|
733 |
assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(stationview_d)); |
375a8bcd4948
(svn r12446) -Feature: Add +/- toggle buttons to station cargo waiting list to show/hide the detailed transferred cargo information.
peter1138
parents:
8719
diff
changeset
|
734 |
|
8420
4ebc9752e7bd
(svn r11990) -Codechange: Show all cargo sources (en-route from) in the station view
peter1138
parents:
8349
diff
changeset
|
735 |
struct CargoData { |
4ebc9752e7bd
(svn r11990) -Codechange: Show all cargo sources (en-route from) in the station view
peter1138
parents:
8349
diff
changeset
|
736 |
CargoID cargo; |
4ebc9752e7bd
(svn r11990) -Codechange: Show all cargo sources (en-route from) in the station view
peter1138
parents:
8349
diff
changeset
|
737 |
StationID source; |
4ebc9752e7bd
(svn r11990) -Codechange: Show all cargo sources (en-route from) in the station view
peter1138
parents:
8349
diff
changeset
|
738 |
uint count; |
4ebc9752e7bd
(svn r11990) -Codechange: Show all cargo sources (en-route from) in the station view
peter1138
parents:
8349
diff
changeset
|
739 |
|
4ebc9752e7bd
(svn r11990) -Codechange: Show all cargo sources (en-route from) in the station view
peter1138
parents:
8349
diff
changeset
|
740 |
CargoData(CargoID cargo, StationID source, uint count) : |
4ebc9752e7bd
(svn r11990) -Codechange: Show all cargo sources (en-route from) in the station view
peter1138
parents:
8349
diff
changeset
|
741 |
cargo(cargo), |
4ebc9752e7bd
(svn r11990) -Codechange: Show all cargo sources (en-route from) in the station view
peter1138
parents:
8349
diff
changeset
|
742 |
source(source), |
4ebc9752e7bd
(svn r11990) -Codechange: Show all cargo sources (en-route from) in the station view
peter1138
parents:
8349
diff
changeset
|
743 |
count(count) |
4ebc9752e7bd
(svn r11990) -Codechange: Show all cargo sources (en-route from) in the station view
peter1138
parents:
8349
diff
changeset
|
744 |
{ } |
4ebc9752e7bd
(svn r11990) -Codechange: Show all cargo sources (en-route from) in the station view
peter1138
parents:
8349
diff
changeset
|
745 |
}; |
4ebc9752e7bd
(svn r11990) -Codechange: Show all cargo sources (en-route from) in the station view
peter1138
parents:
8349
diff
changeset
|
746 |
|
4ebc9752e7bd
(svn r11990) -Codechange: Show all cargo sources (en-route from) in the station view
peter1138
parents:
8349
diff
changeset
|
747 |
typedef std::list<CargoData> CargoDataList; |
4ebc9752e7bd
(svn r11990) -Codechange: Show all cargo sources (en-route from) in the station view
peter1138
parents:
8349
diff
changeset
|
748 |
|
8016
1c7062ad5f50
(svn r11576) -Codechange: enumerize and comment station GUI
smatz
parents:
8005
diff
changeset
|
749 |
/** |
1c7062ad5f50
(svn r11576) -Codechange: enumerize and comment station GUI
smatz
parents:
8005
diff
changeset
|
750 |
* Redraws whole StationView window |
1c7062ad5f50
(svn r11576) -Codechange: enumerize and comment station GUI
smatz
parents:
8005
diff
changeset
|
751 |
* |
1c7062ad5f50
(svn r11576) -Codechange: enumerize and comment station GUI
smatz
parents:
8005
diff
changeset
|
752 |
* @param w pointer to window |
1c7062ad5f50
(svn r11576) -Codechange: enumerize and comment station GUI
smatz
parents:
8005
diff
changeset
|
753 |
*/ |
0 | 754 |
static void DrawStationViewWindow(Window *w) |
755 |
{ |
|
2630 | 756 |
StationID station_id = w->window_number; |
8964
84f2e443b7be
(svn r12756) -Cleanup: variable scope and coding style in station*
smatz
parents:
8857
diff
changeset
|
757 |
const Station *st = GetStation(station_id); |
8420
4ebc9752e7bd
(svn r11990) -Codechange: Show all cargo sources (en-route from) in the station view
peter1138
parents:
8349
diff
changeset
|
758 |
CargoDataList cargolist; |
8750
375a8bcd4948
(svn r12446) -Feature: Add +/- toggle buttons to station cargo waiting list to show/hide the detailed transferred cargo information.
peter1138
parents:
8719
diff
changeset
|
759 |
uint32 transfers = 0; |
0 | 760 |
|
8016
1c7062ad5f50
(svn r11576) -Codechange: enumerize and comment station GUI
smatz
parents:
8005
diff
changeset
|
761 |
/* count types of cargos waiting in station */ |
6350
04b19f551aec
(svn r9388) -Codechange: variable scope and type, and standardify all CargoID loops.
peter1138
parents:
6297
diff
changeset
|
762 |
for (CargoID i = 0; i < NUM_CARGO; i++) { |
8750
375a8bcd4948
(svn r12446) -Feature: Add +/- toggle buttons to station cargo waiting list to show/hide the detailed transferred cargo information.
peter1138
parents:
8719
diff
changeset
|
763 |
if (st->goods[i].cargo.Empty()) { |
375a8bcd4948
(svn r12446) -Feature: Add +/- toggle buttons to station cargo waiting list to show/hide the detailed transferred cargo information.
peter1138
parents:
8719
diff
changeset
|
764 |
WP(w, stationview_d).cargo_rows[i] = 0; |
375a8bcd4948
(svn r12446) -Feature: Add +/- toggle buttons to station cargo waiting list to show/hide the detailed transferred cargo information.
peter1138
parents:
8719
diff
changeset
|
765 |
} else { |
8420
4ebc9752e7bd
(svn r11990) -Codechange: Show all cargo sources (en-route from) in the station view
peter1138
parents:
8349
diff
changeset
|
766 |
/* Add an entry for total amount of cargo of this type waiting. */ |
4ebc9752e7bd
(svn r11990) -Codechange: Show all cargo sources (en-route from) in the station view
peter1138
parents:
8349
diff
changeset
|
767 |
cargolist.push_back(CargoData(i, INVALID_STATION, st->goods[i].cargo.Count())); |
4ebc9752e7bd
(svn r11990) -Codechange: Show all cargo sources (en-route from) in the station view
peter1138
parents:
8349
diff
changeset
|
768 |
|
8750
375a8bcd4948
(svn r12446) -Feature: Add +/- toggle buttons to station cargo waiting list to show/hide the detailed transferred cargo information.
peter1138
parents:
8719
diff
changeset
|
769 |
/* Set the row for this cargo entry for the expand/hide button */ |
375a8bcd4948
(svn r12446) -Feature: Add +/- toggle buttons to station cargo waiting list to show/hide the detailed transferred cargo information.
peter1138
parents:
8719
diff
changeset
|
770 |
WP(w, stationview_d).cargo_rows[i] = cargolist.size(); |
375a8bcd4948
(svn r12446) -Feature: Add +/- toggle buttons to station cargo waiting list to show/hide the detailed transferred cargo information.
peter1138
parents:
8719
diff
changeset
|
771 |
|
8420
4ebc9752e7bd
(svn r11990) -Codechange: Show all cargo sources (en-route from) in the station view
peter1138
parents:
8349
diff
changeset
|
772 |
/* Add an entry for each distinct cargo source. */ |
4ebc9752e7bd
(svn r11990) -Codechange: Show all cargo sources (en-route from) in the station view
peter1138
parents:
8349
diff
changeset
|
773 |
const CargoList::List *packets = st->goods[i].cargo.Packets(); |
4ebc9752e7bd
(svn r11990) -Codechange: Show all cargo sources (en-route from) in the station view
peter1138
parents:
8349
diff
changeset
|
774 |
for (CargoList::List::const_iterator it = packets->begin(); it != packets->end(); it++) { |
4ebc9752e7bd
(svn r11990) -Codechange: Show all cargo sources (en-route from) in the station view
peter1138
parents:
8349
diff
changeset
|
775 |
const CargoPacket *cp = *it; |
4ebc9752e7bd
(svn r11990) -Codechange: Show all cargo sources (en-route from) in the station view
peter1138
parents:
8349
diff
changeset
|
776 |
if (cp->source != station_id) { |
4ebc9752e7bd
(svn r11990) -Codechange: Show all cargo sources (en-route from) in the station view
peter1138
parents:
8349
diff
changeset
|
777 |
bool added = false; |
4ebc9752e7bd
(svn r11990) -Codechange: Show all cargo sources (en-route from) in the station view
peter1138
parents:
8349
diff
changeset
|
778 |
|
8750
375a8bcd4948
(svn r12446) -Feature: Add +/- toggle buttons to station cargo waiting list to show/hide the detailed transferred cargo information.
peter1138
parents:
8719
diff
changeset
|
779 |
/* Enable the expand/hide button for this cargo type */ |
375a8bcd4948
(svn r12446) -Feature: Add +/- toggle buttons to station cargo waiting list to show/hide the detailed transferred cargo information.
peter1138
parents:
8719
diff
changeset
|
780 |
SetBit(transfers, i); |
375a8bcd4948
(svn r12446) -Feature: Add +/- toggle buttons to station cargo waiting list to show/hide the detailed transferred cargo information.
peter1138
parents:
8719
diff
changeset
|
781 |
|
375a8bcd4948
(svn r12446) -Feature: Add +/- toggle buttons to station cargo waiting list to show/hide the detailed transferred cargo information.
peter1138
parents:
8719
diff
changeset
|
782 |
/* Don't add cargo lines if not expanded */ |
375a8bcd4948
(svn r12446) -Feature: Add +/- toggle buttons to station cargo waiting list to show/hide the detailed transferred cargo information.
peter1138
parents:
8719
diff
changeset
|
783 |
if (!HasBit(WP(w, stationview_d).cargo, i)) break; |
375a8bcd4948
(svn r12446) -Feature: Add +/- toggle buttons to station cargo waiting list to show/hide the detailed transferred cargo information.
peter1138
parents:
8719
diff
changeset
|
784 |
|
8420
4ebc9752e7bd
(svn r11990) -Codechange: Show all cargo sources (en-route from) in the station view
peter1138
parents:
8349
diff
changeset
|
785 |
/* Check if we already have this source in the list */ |
4ebc9752e7bd
(svn r11990) -Codechange: Show all cargo sources (en-route from) in the station view
peter1138
parents:
8349
diff
changeset
|
786 |
for (CargoDataList::iterator jt = cargolist.begin(); jt != cargolist.end(); jt++) { |
4ebc9752e7bd
(svn r11990) -Codechange: Show all cargo sources (en-route from) in the station view
peter1138
parents:
8349
diff
changeset
|
787 |
CargoData *cd = &(*jt); |
4ebc9752e7bd
(svn r11990) -Codechange: Show all cargo sources (en-route from) in the station view
peter1138
parents:
8349
diff
changeset
|
788 |
if (cd->cargo == i && cd->source == cp->source) { |
4ebc9752e7bd
(svn r11990) -Codechange: Show all cargo sources (en-route from) in the station view
peter1138
parents:
8349
diff
changeset
|
789 |
cd->count += cp->count; |
4ebc9752e7bd
(svn r11990) -Codechange: Show all cargo sources (en-route from) in the station view
peter1138
parents:
8349
diff
changeset
|
790 |
added = true; |
4ebc9752e7bd
(svn r11990) -Codechange: Show all cargo sources (en-route from) in the station view
peter1138
parents:
8349
diff
changeset
|
791 |
break; |
4ebc9752e7bd
(svn r11990) -Codechange: Show all cargo sources (en-route from) in the station view
peter1138
parents:
8349
diff
changeset
|
792 |
} |
4ebc9752e7bd
(svn r11990) -Codechange: Show all cargo sources (en-route from) in the station view
peter1138
parents:
8349
diff
changeset
|
793 |
} |
4ebc9752e7bd
(svn r11990) -Codechange: Show all cargo sources (en-route from) in the station view
peter1138
parents:
8349
diff
changeset
|
794 |
|
4ebc9752e7bd
(svn r11990) -Codechange: Show all cargo sources (en-route from) in the station view
peter1138
parents:
8349
diff
changeset
|
795 |
if (!added) cargolist.push_back(CargoData(i, cp->source, cp->count)); |
4ebc9752e7bd
(svn r11990) -Codechange: Show all cargo sources (en-route from) in the station view
peter1138
parents:
8349
diff
changeset
|
796 |
} |
4ebc9752e7bd
(svn r11990) -Codechange: Show all cargo sources (en-route from) in the station view
peter1138
parents:
8349
diff
changeset
|
797 |
} |
0 | 798 |
} |
799 |
} |
|
8420
4ebc9752e7bd
(svn r11990) -Codechange: Show all cargo sources (en-route from) in the station view
peter1138
parents:
8349
diff
changeset
|
800 |
SetVScrollCount(w, cargolist.size() + 1); // update scrollbar |
0 | 801 |
|
8016
1c7062ad5f50
(svn r11576) -Codechange: enumerize and comment station GUI
smatz
parents:
8005
diff
changeset
|
802 |
/* disable some buttons */ |
1c7062ad5f50
(svn r11576) -Codechange: enumerize and comment station GUI
smatz
parents:
8005
diff
changeset
|
803 |
w->SetWidgetDisabledState(SVW_RENAME, st->owner != _local_player); |
1c7062ad5f50
(svn r11576) -Codechange: enumerize and comment station GUI
smatz
parents:
8005
diff
changeset
|
804 |
w->SetWidgetDisabledState(SVW_TRAINS, !(st->facilities & FACIL_TRAIN)); |
1c7062ad5f50
(svn r11576) -Codechange: enumerize and comment station GUI
smatz
parents:
8005
diff
changeset
|
805 |
w->SetWidgetDisabledState(SVW_ROADVEHS, !(st->facilities & FACIL_TRUCK_STOP) && !(st->facilities & FACIL_BUS_STOP)); |
1c7062ad5f50
(svn r11576) -Codechange: enumerize and comment station GUI
smatz
parents:
8005
diff
changeset
|
806 |
w->SetWidgetDisabledState(SVW_PLANES, !(st->facilities & FACIL_AIRPORT)); |
1c7062ad5f50
(svn r11576) -Codechange: enumerize and comment station GUI
smatz
parents:
8005
diff
changeset
|
807 |
w->SetWidgetDisabledState(SVW_SHIPS, !(st->facilities & FACIL_DOCK)); |
588 | 808 |
|
534
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
809 |
SetDParam(0, st->index); |
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
810 |
SetDParam(1, st->facilities); |
0 | 811 |
DrawWindowWidgets(w); |
812 |
||
8964
84f2e443b7be
(svn r12756) -Cleanup: variable scope and coding style in station*
smatz
parents:
8857
diff
changeset
|
813 |
int x = 2; ///< coordinates used for printing waiting/accepted/rating of cargo |
84f2e443b7be
(svn r12756) -Cleanup: variable scope and coding style in station*
smatz
parents:
8857
diff
changeset
|
814 |
int y = 15; |
84f2e443b7be
(svn r12756) -Cleanup: variable scope and coding style in station*
smatz
parents:
8857
diff
changeset
|
815 |
int pos = w->vscroll.pos; ///< = w->vscroll.pos |
0 | 816 |
|
8420
4ebc9752e7bd
(svn r11990) -Codechange: Show all cargo sources (en-route from) in the station view
peter1138
parents:
8349
diff
changeset
|
817 |
uint width = w->widget[SVW_WAITING].right - w->widget[SVW_WAITING].left - 4; |
4ebc9752e7bd
(svn r11990) -Codechange: Show all cargo sources (en-route from) in the station view
peter1138
parents:
8349
diff
changeset
|
818 |
int maxrows = w->vscroll.cap; |
4ebc9752e7bd
(svn r11990) -Codechange: Show all cargo sources (en-route from) in the station view
peter1138
parents:
8349
diff
changeset
|
819 |
|
8964
84f2e443b7be
(svn r12756) -Cleanup: variable scope and coding style in station*
smatz
parents:
8857
diff
changeset
|
820 |
StringID str; |
84f2e443b7be
(svn r12756) -Cleanup: variable scope and coding style in station*
smatz
parents:
8857
diff
changeset
|
821 |
|
0 | 822 |
if (--pos < 0) { |
823 |
str = STR_00D0_NOTHING; |
|
6350
04b19f551aec
(svn r9388) -Codechange: variable scope and type, and standardify all CargoID loops.
peter1138
parents:
6297
diff
changeset
|
824 |
for (CargoID i = 0; i < NUM_CARGO; i++) { |
7010
6f0d9f03180d
(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
parents:
6990
diff
changeset
|
825 |
if (!st->goods[i].cargo.Empty()) str = STR_EMPTY; |
2639 | 826 |
} |
534
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
827 |
SetDParam(0, str); |
7824
5a63d41b59ea
(svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents:
7474
diff
changeset
|
828 |
DrawString(x, y, STR_0008_WAITING, TC_FROMSTRING); |
0 | 829 |
y += 10; |
830 |
} |
|
831 |
||
8420
4ebc9752e7bd
(svn r11990) -Codechange: Show all cargo sources (en-route from) in the station view
peter1138
parents:
8349
diff
changeset
|
832 |
for (CargoDataList::const_iterator it = cargolist.begin(); it != cargolist.end() && pos > -maxrows; ++it) { |
4ebc9752e7bd
(svn r11990) -Codechange: Show all cargo sources (en-route from) in the station view
peter1138
parents:
8349
diff
changeset
|
833 |
if (--pos < 0) { |
4ebc9752e7bd
(svn r11990) -Codechange: Show all cargo sources (en-route from) in the station view
peter1138
parents:
8349
diff
changeset
|
834 |
const CargoData *cd = &(*it); |
4ebc9752e7bd
(svn r11990) -Codechange: Show all cargo sources (en-route from) in the station view
peter1138
parents:
8349
diff
changeset
|
835 |
if (cd->source == INVALID_STATION) { |
4ebc9752e7bd
(svn r11990) -Codechange: Show all cargo sources (en-route from) in the station view
peter1138
parents:
8349
diff
changeset
|
836 |
/* Heading */ |
4ebc9752e7bd
(svn r11990) -Codechange: Show all cargo sources (en-route from) in the station view
peter1138
parents:
8349
diff
changeset
|
837 |
DrawCargoIcons(cd->cargo, cd->count, x, y, width); |
4ebc9752e7bd
(svn r11990) -Codechange: Show all cargo sources (en-route from) in the station view
peter1138
parents:
8349
diff
changeset
|
838 |
SetDParam(0, cd->cargo); |
4ebc9752e7bd
(svn r11990) -Codechange: Show all cargo sources (en-route from) in the station view
peter1138
parents:
8349
diff
changeset
|
839 |
SetDParam(1, cd->count); |
8750
375a8bcd4948
(svn r12446) -Feature: Add +/- toggle buttons to station cargo waiting list to show/hide the detailed transferred cargo information.
peter1138
parents:
8719
diff
changeset
|
840 |
if (HasBit(transfers, cd->cargo)) { |
375a8bcd4948
(svn r12446) -Feature: Add +/- toggle buttons to station cargo waiting list to show/hide the detailed transferred cargo information.
peter1138
parents:
8719
diff
changeset
|
841 |
/* This cargo has transfers waiting so show the expand or shrink 'button' */ |
375a8bcd4948
(svn r12446) -Feature: Add +/- toggle buttons to station cargo waiting list to show/hide the detailed transferred cargo information.
peter1138
parents:
8719
diff
changeset
|
842 |
const char *sym = HasBit(WP(w, stationview_d).cargo, cd->cargo) ? "-" : "+"; |
375a8bcd4948
(svn r12446) -Feature: Add +/- toggle buttons to station cargo waiting list to show/hide the detailed transferred cargo information.
peter1138
parents:
8719
diff
changeset
|
843 |
DrawStringRightAligned(x + width - 8, y, STR_0009, TC_FROMSTRING); |
375a8bcd4948
(svn r12446) -Feature: Add +/- toggle buttons to station cargo waiting list to show/hide the detailed transferred cargo information.
peter1138
parents:
8719
diff
changeset
|
844 |
DoDrawString(sym, x + width - 6, y, TC_YELLOW); |
375a8bcd4948
(svn r12446) -Feature: Add +/- toggle buttons to station cargo waiting list to show/hide the detailed transferred cargo information.
peter1138
parents:
8719
diff
changeset
|
845 |
} else { |
375a8bcd4948
(svn r12446) -Feature: Add +/- toggle buttons to station cargo waiting list to show/hide the detailed transferred cargo information.
peter1138
parents:
8719
diff
changeset
|
846 |
DrawStringRightAligned(x + width, y, STR_0009, TC_FROMSTRING); |
375a8bcd4948
(svn r12446) -Feature: Add +/- toggle buttons to station cargo waiting list to show/hide the detailed transferred cargo information.
peter1138
parents:
8719
diff
changeset
|
847 |
} |
8420
4ebc9752e7bd
(svn r11990) -Codechange: Show all cargo sources (en-route from) in the station view
peter1138
parents:
8349
diff
changeset
|
848 |
} else { |
4ebc9752e7bd
(svn r11990) -Codechange: Show all cargo sources (en-route from) in the station view
peter1138
parents:
8349
diff
changeset
|
849 |
SetDParam(0, cd->cargo); |
4ebc9752e7bd
(svn r11990) -Codechange: Show all cargo sources (en-route from) in the station view
peter1138
parents:
8349
diff
changeset
|
850 |
SetDParam(1, cd->count); |
4ebc9752e7bd
(svn r11990) -Codechange: Show all cargo sources (en-route from) in the station view
peter1138
parents:
8349
diff
changeset
|
851 |
SetDParam(2, cd->source); |
4ebc9752e7bd
(svn r11990) -Codechange: Show all cargo sources (en-route from) in the station view
peter1138
parents:
8349
diff
changeset
|
852 |
DrawStringRightAlignedTruncated(x + width, y, STR_EN_ROUTE_FROM, TC_FROMSTRING, width); |
0 | 853 |
} |
854 |
||
8420
4ebc9752e7bd
(svn r11990) -Codechange: Show all cargo sources (en-route from) in the station view
peter1138
parents:
8349
diff
changeset
|
855 |
y += 10; |
0 | 856 |
} |
6260
c93c01f78fcf
(svn r9069) -Codechange: Change a do ... while loop with a for loop. This fixes some warning that I never got anyway...
peter1138
parents:
6259
diff
changeset
|
857 |
} |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
858 |
|
8420
4ebc9752e7bd
(svn r11990) -Codechange: Show all cargo sources (en-route from) in the station view
peter1138
parents:
8349
diff
changeset
|
859 |
if (w->widget[SVW_ACCEPTS].data == STR_3032_RATINGS) { // small window with list of accepted cargo |
1556
d7c2d5289be9
(svn r2060) Clean up some string construction and remove now unused macro
tron
parents:
1553
diff
changeset
|
860 |
char *b = _userstring; |
5038
12fd4db0cdb5
(svn r7080) -Codechange: Remove negative array indexes, and only add ", " when needed, when building station acceptance lists.
peter1138
parents:
5005
diff
changeset
|
861 |
bool first = true; |
1329 | 862 |
|
1553
cf513e731bd3
(svn r2057) Add InlineString() to make _userstring construction a bit cleaner.
tron
parents:
1474
diff
changeset
|
863 |
b = InlineString(b, STR_000C_ACCEPTS); |
0 | 864 |
|
6350
04b19f551aec
(svn r9388) -Codechange: variable scope and type, and standardify all CargoID loops.
peter1138
parents:
6297
diff
changeset
|
865 |
for (CargoID i = 0; i < NUM_CARGO; i++) { |
8041
9483d3e46b3e
(svn r11601) -Codechange: more strict break conditions for _userstring, assert when it overflows anyway (eg. code change without proper check change)
smatz
parents:
8040
diff
changeset
|
866 |
if (b >= lastof(_userstring) - (1 + 2 * 4)) break; // ',' or ' ' and two calls to Utf8Encode() |
7928
63e18de69e50
(svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13
parents:
7886
diff
changeset
|
867 |
if (HasBit(st->goods[i].acceptance_pickup, GoodsEntry::ACCEPTANCE)) { |
5038
12fd4db0cdb5
(svn r7080) -Codechange: Remove negative array indexes, and only add ", " when needed, when building station acceptance lists.
peter1138
parents:
5005
diff
changeset
|
868 |
if (first) { |
12fd4db0cdb5
(svn r7080) -Codechange: Remove negative array indexes, and only add ", " when needed, when building station acceptance lists.
peter1138
parents:
5005
diff
changeset
|
869 |
first = false; |
12fd4db0cdb5
(svn r7080) -Codechange: Remove negative array indexes, and only add ", " when needed, when building station acceptance lists.
peter1138
parents:
5005
diff
changeset
|
870 |
} else { |
12fd4db0cdb5
(svn r7080) -Codechange: Remove negative array indexes, and only add ", " when needed, when building station acceptance lists.
peter1138
parents:
5005
diff
changeset
|
871 |
/* Add a comma if this is not the first item */ |
12fd4db0cdb5
(svn r7080) -Codechange: Remove negative array indexes, and only add ", " when needed, when building station acceptance lists.
peter1138
parents:
5005
diff
changeset
|
872 |
*b++ = ','; |
12fd4db0cdb5
(svn r7080) -Codechange: Remove negative array indexes, and only add ", " when needed, when building station acceptance lists.
peter1138
parents:
5005
diff
changeset
|
873 |
*b++ = ' '; |
12fd4db0cdb5
(svn r7080) -Codechange: Remove negative array indexes, and only add ", " when needed, when building station acceptance lists.
peter1138
parents:
5005
diff
changeset
|
874 |
} |
6091
c8827d9ae04a
(svn r8826) -Codechange: Replace _cargoc's separate arrays with a regular struct array (with accessor) and implement new initialization method using cargo labels.
peter1138
parents:
5893
diff
changeset
|
875 |
b = InlineString(b, GetCargo(i)->name); |
0 | 876 |
} |
877 |
} |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
878 |
|
5038
12fd4db0cdb5
(svn r7080) -Codechange: Remove negative array indexes, and only add ", " when needed, when building station acceptance lists.
peter1138
parents:
5005
diff
changeset
|
879 |
/* If first is still true then no cargo is accepted */ |
12fd4db0cdb5
(svn r7080) -Codechange: Remove negative array indexes, and only add ", " when needed, when building station acceptance lists.
peter1138
parents:
5005
diff
changeset
|
880 |
if (first) b = InlineString(b, STR_00D0_NOTHING); |
0 | 881 |
|
5038
12fd4db0cdb5
(svn r7080) -Codechange: Remove negative array indexes, and only add ", " when needed, when building station acceptance lists.
peter1138
parents:
5005
diff
changeset
|
882 |
*b = '\0'; |
8041
9483d3e46b3e
(svn r11601) -Codechange: more strict break conditions for _userstring, assert when it overflows anyway (eg. code change without proper check change)
smatz
parents:
8040
diff
changeset
|
883 |
|
9483d3e46b3e
(svn r11601) -Codechange: more strict break conditions for _userstring, assert when it overflows anyway (eg. code change without proper check change)
smatz
parents:
8040
diff
changeset
|
884 |
/* Make sure we detect any buffer overflow */ |
9483d3e46b3e
(svn r11601) -Codechange: more strict break conditions for _userstring, assert when it overflows anyway (eg. code change without proper check change)
smatz
parents:
8040
diff
changeset
|
885 |
assert(b < endof(_userstring)); |
9483d3e46b3e
(svn r11601) -Codechange: more strict break conditions for _userstring, assert when it overflows anyway (eg. code change without proper check change)
smatz
parents:
8040
diff
changeset
|
886 |
|
8420
4ebc9752e7bd
(svn r11990) -Codechange: Show all cargo sources (en-route from) in the station view
peter1138
parents:
8349
diff
changeset
|
887 |
DrawStringMultiLine(2, w->widget[SVW_ACCEPTLIST].top + 1, STR_SPEC_USERSTRING, w->widget[SVW_ACCEPTLIST].right - w->widget[SVW_ACCEPTLIST].left); |
8016
1c7062ad5f50
(svn r11576) -Codechange: enumerize and comment station GUI
smatz
parents:
8005
diff
changeset
|
888 |
} else { // extended window with list of cargo ratings |
8420
4ebc9752e7bd
(svn r11990) -Codechange: Show all cargo sources (en-route from) in the station view
peter1138
parents:
8349
diff
changeset
|
889 |
y = w->widget[SVW_RATINGLIST].top + 1; |
0 | 890 |
|
8420
4ebc9752e7bd
(svn r11990) -Codechange: Show all cargo sources (en-route from) in the station view
peter1138
parents:
8349
diff
changeset
|
891 |
DrawString(2, y, STR_3034_LOCAL_RATING_OF_TRANSPORT, TC_FROMSTRING); |
4ebc9752e7bd
(svn r11990) -Codechange: Show all cargo sources (en-route from) in the station view
peter1138
parents:
8349
diff
changeset
|
892 |
y += 10; |
4ebc9752e7bd
(svn r11990) -Codechange: Show all cargo sources (en-route from) in the station view
peter1138
parents:
8349
diff
changeset
|
893 |
|
6350
04b19f551aec
(svn r9388) -Codechange: variable scope and type, and standardify all CargoID loops.
peter1138
parents:
6297
diff
changeset
|
894 |
for (CargoID i = 0; i < NUM_CARGO; i++) { |
6297
3ff4d685839e
(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
parents:
6285
diff
changeset
|
895 |
const CargoSpec *cs = GetCargo(i); |
3ff4d685839e
(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
parents:
6285
diff
changeset
|
896 |
if (!cs->IsValid()) continue; |
3ff4d685839e
(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
parents:
6285
diff
changeset
|
897 |
|
3ff4d685839e
(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
parents:
6285
diff
changeset
|
898 |
const GoodsEntry *ge = &st->goods[i]; |
7928
63e18de69e50
(svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13
parents:
7886
diff
changeset
|
899 |
if (!HasBit(ge->acceptance_pickup, GoodsEntry::PICKUP)) continue; |
6297
3ff4d685839e
(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
parents:
6285
diff
changeset
|
900 |
|
3ff4d685839e
(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
parents:
6285
diff
changeset
|
901 |
SetDParam(0, cs->name); |
3ff4d685839e
(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
parents:
6285
diff
changeset
|
902 |
SetDParam(2, ge->rating * 101 >> 8); |
3ff4d685839e
(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
parents:
6285
diff
changeset
|
903 |
SetDParam(1, STR_3035_APPALLING + (ge->rating >> 5)); |
7824
5a63d41b59ea
(svn r11374) -Codechange: Give meaning to the magical number that specifies the color of the text in a DrawString call.
belugas
parents:
7474
diff
changeset
|
904 |
DrawString(8, y, STR_303D, TC_FROMSTRING); |
6297
3ff4d685839e
(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
parents:
6285
diff
changeset
|
905 |
y += 10; |
0 | 906 |
} |
907 |
} |
|
908 |
} |
|
909 |
||
8750
375a8bcd4948
(svn r12446) -Feature: Add +/- toggle buttons to station cargo waiting list to show/hide the detailed transferred cargo information.
peter1138
parents:
8719
diff
changeset
|
910 |
static void HandleCargoWaitingClick(Window *w, int row) |
375a8bcd4948
(svn r12446) -Feature: Add +/- toggle buttons to station cargo waiting list to show/hide the detailed transferred cargo information.
peter1138
parents:
8719
diff
changeset
|
911 |
{ |
375a8bcd4948
(svn r12446) -Feature: Add +/- toggle buttons to station cargo waiting list to show/hide the detailed transferred cargo information.
peter1138
parents:
8719
diff
changeset
|
912 |
if (row == 0) return; |
375a8bcd4948
(svn r12446) -Feature: Add +/- toggle buttons to station cargo waiting list to show/hide the detailed transferred cargo information.
peter1138
parents:
8719
diff
changeset
|
913 |
|
375a8bcd4948
(svn r12446) -Feature: Add +/- toggle buttons to station cargo waiting list to show/hide the detailed transferred cargo information.
peter1138
parents:
8719
diff
changeset
|
914 |
for (CargoID c = 0; c < NUM_CARGO; c++) { |
375a8bcd4948
(svn r12446) -Feature: Add +/- toggle buttons to station cargo waiting list to show/hide the detailed transferred cargo information.
peter1138
parents:
8719
diff
changeset
|
915 |
if (WP(w, stationview_d).cargo_rows[c] == row) { |
375a8bcd4948
(svn r12446) -Feature: Add +/- toggle buttons to station cargo waiting list to show/hide the detailed transferred cargo information.
peter1138
parents:
8719
diff
changeset
|
916 |
ToggleBit(WP(w, stationview_d).cargo, c); |
375a8bcd4948
(svn r12446) -Feature: Add +/- toggle buttons to station cargo waiting list to show/hide the detailed transferred cargo information.
peter1138
parents:
8719
diff
changeset
|
917 |
w->InvalidateWidget(SVW_WAITING); |
375a8bcd4948
(svn r12446) -Feature: Add +/- toggle buttons to station cargo waiting list to show/hide the detailed transferred cargo information.
peter1138
parents:
8719
diff
changeset
|
918 |
break; |
375a8bcd4948
(svn r12446) -Feature: Add +/- toggle buttons to station cargo waiting list to show/hide the detailed transferred cargo information.
peter1138
parents:
8719
diff
changeset
|
919 |
} |
375a8bcd4948
(svn r12446) -Feature: Add +/- toggle buttons to station cargo waiting list to show/hide the detailed transferred cargo information.
peter1138
parents:
8719
diff
changeset
|
920 |
} |
375a8bcd4948
(svn r12446) -Feature: Add +/- toggle buttons to station cargo waiting list to show/hide the detailed transferred cargo information.
peter1138
parents:
8719
diff
changeset
|
921 |
} |
375a8bcd4948
(svn r12446) -Feature: Add +/- toggle buttons to station cargo waiting list to show/hide the detailed transferred cargo information.
peter1138
parents:
8719
diff
changeset
|
922 |
|
0 | 923 |
|
8016
1c7062ad5f50
(svn r11576) -Codechange: enumerize and comment station GUI
smatz
parents:
8005
diff
changeset
|
924 |
/** |
1c7062ad5f50
(svn r11576) -Codechange: enumerize and comment station GUI
smatz
parents:
8005
diff
changeset
|
925 |
* Fuction called when any WindowEvent occurs for any StationView window |
1c7062ad5f50
(svn r11576) -Codechange: enumerize and comment station GUI
smatz
parents:
8005
diff
changeset
|
926 |
* |
1c7062ad5f50
(svn r11576) -Codechange: enumerize and comment station GUI
smatz
parents:
8005
diff
changeset
|
927 |
* @param w pointer to the StationView window |
1c7062ad5f50
(svn r11576) -Codechange: enumerize and comment station GUI
smatz
parents:
8005
diff
changeset
|
928 |
* @param e pointer to window event |
1c7062ad5f50
(svn r11576) -Codechange: enumerize and comment station GUI
smatz
parents:
8005
diff
changeset
|
929 |
*/ |
0 | 930 |
static void StationViewWndProc(Window *w, WindowEvent *e) |
931 |
{ |
|
2639 | 932 |
switch (e->event) { |
6202
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
933 |
case WE_PAINT: |
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
934 |
DrawStationViewWindow(w); |
0 | 935 |
break; |
936 |
||
6202
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
937 |
case WE_CLICK: |
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
938 |
switch (e->we.click.widget) { |
8750
375a8bcd4948
(svn r12446) -Feature: Add +/- toggle buttons to station cargo waiting list to show/hide the detailed transferred cargo information.
peter1138
parents:
8719
diff
changeset
|
939 |
case SVW_WAITING: |
375a8bcd4948
(svn r12446) -Feature: Add +/- toggle buttons to station cargo waiting list to show/hide the detailed transferred cargo information.
peter1138
parents:
8719
diff
changeset
|
940 |
HandleCargoWaitingClick(w, (e->we.click.pt.y - w->widget[SVW_WAITING].top) / 10 + w->vscroll.pos); |
375a8bcd4948
(svn r12446) -Feature: Add +/- toggle buttons to station cargo waiting list to show/hide the detailed transferred cargo information.
peter1138
parents:
8719
diff
changeset
|
941 |
break; |
375a8bcd4948
(svn r12446) -Feature: Add +/- toggle buttons to station cargo waiting list to show/hide the detailed transferred cargo information.
peter1138
parents:
8719
diff
changeset
|
942 |
|
8016
1c7062ad5f50
(svn r11576) -Codechange: enumerize and comment station GUI
smatz
parents:
8005
diff
changeset
|
943 |
case SVW_LOCATION: |
9094
48004fcef409
(svn r12953) -Feature: Open a new viewport when ctrl-clicking on a 'Location' button, a town/station/industry list, or some news items.
peter1138
parents:
8992
diff
changeset
|
944 |
if (_ctrl_pressed) { |
48004fcef409
(svn r12953) -Feature: Open a new viewport when ctrl-clicking on a 'Location' button, a town/station/industry list, or some news items.
peter1138
parents:
8992
diff
changeset
|
945 |
ShowExtraViewPortWindow(GetStation(w->window_number)->xy); |
48004fcef409
(svn r12953) -Feature: Open a new viewport when ctrl-clicking on a 'Location' button, a town/station/industry list, or some news items.
peter1138
parents:
8992
diff
changeset
|
946 |
} else { |
48004fcef409
(svn r12953) -Feature: Open a new viewport when ctrl-clicking on a 'Location' button, a town/station/industry list, or some news items.
peter1138
parents:
8992
diff
changeset
|
947 |
ScrollMainWindowToTile(GetStation(w->window_number)->xy); |
48004fcef409
(svn r12953) -Feature: Open a new viewport when ctrl-clicking on a 'Location' button, a town/station/industry list, or some news items.
peter1138
parents:
8992
diff
changeset
|
948 |
} |
6202
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
949 |
break; |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
950 |
|
8016
1c7062ad5f50
(svn r11576) -Codechange: enumerize and comment station GUI
smatz
parents:
8005
diff
changeset
|
951 |
case SVW_RATINGS: |
9116
f2491d3c321b
(svn r12976) -Codechange: use w->SetDirty() instead of SetWindowDirty(w) when it's certain that w != NULL.
rubidium
parents:
9111
diff
changeset
|
952 |
w->SetDirty(); |
6202
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
953 |
|
8420
4ebc9752e7bd
(svn r11990) -Codechange: Show all cargo sources (en-route from) in the station view
peter1138
parents:
8349
diff
changeset
|
954 |
if (w->widget[SVW_RATINGS].data == STR_3032_RATINGS) { |
4ebc9752e7bd
(svn r11990) -Codechange: Show all cargo sources (en-route from) in the station view
peter1138
parents:
8349
diff
changeset
|
955 |
/* Switch to ratings view */ |
4ebc9752e7bd
(svn r11990) -Codechange: Show all cargo sources (en-route from) in the station view
peter1138
parents:
8349
diff
changeset
|
956 |
w->widget[SVW_RATINGS].data = STR_3033_ACCEPTS; |
4ebc9752e7bd
(svn r11990) -Codechange: Show all cargo sources (en-route from) in the station view
peter1138
parents:
8349
diff
changeset
|
957 |
w->widget[SVW_RATINGS].tooltips = STR_3056_SHOW_LIST_OF_ACCEPTED_CARGO; |
4ebc9752e7bd
(svn r11990) -Codechange: Show all cargo sources (en-route from) in the station view
peter1138
parents:
8349
diff
changeset
|
958 |
ResizeWindowForWidget(w, SVW_ACCEPTLIST, 0, 100); |
6202
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
959 |
} else { |
8420
4ebc9752e7bd
(svn r11990) -Codechange: Show all cargo sources (en-route from) in the station view
peter1138
parents:
8349
diff
changeset
|
960 |
/* Switch to accepts view */ |
4ebc9752e7bd
(svn r11990) -Codechange: Show all cargo sources (en-route from) in the station view
peter1138
parents:
8349
diff
changeset
|
961 |
w->widget[SVW_RATINGS].data = STR_3032_RATINGS; |
4ebc9752e7bd
(svn r11990) -Codechange: Show all cargo sources (en-route from) in the station view
peter1138
parents:
8349
diff
changeset
|
962 |
w->widget[SVW_RATINGS].tooltips = STR_3054_SHOW_STATION_RATINGS; |
4ebc9752e7bd
(svn r11990) -Codechange: Show all cargo sources (en-route from) in the station view
peter1138
parents:
8349
diff
changeset
|
963 |
ResizeWindowForWidget(w, SVW_ACCEPTLIST, 0, -100); |
6202
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
964 |
} |
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
965 |
|
9116
f2491d3c321b
(svn r12976) -Codechange: use w->SetDirty() instead of SetWindowDirty(w) when it's certain that w != NULL.
rubidium
parents:
9111
diff
changeset
|
966 |
w->SetDirty(); |
6202
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
967 |
break; |
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
968 |
|
8016
1c7062ad5f50
(svn r11576) -Codechange: enumerize and comment station GUI
smatz
parents:
8005
diff
changeset
|
969 |
case SVW_RENAME: |
6202
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
970 |
SetDParam(0, w->window_number); |
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
971 |
ShowQueryString(STR_STATION, STR_3030_RENAME_STATION_LOADING, 31, 180, w, CS_ALPHANUMERAL); |
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
972 |
break; |
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
973 |
|
8016
1c7062ad5f50
(svn r11576) -Codechange: enumerize and comment station GUI
smatz
parents:
8005
diff
changeset
|
974 |
case SVW_TRAINS: { // Show a list of scheduled trains to this station |
6202
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
975 |
const Station *st = GetStation(w->window_number); |
6259
471b91a4b1d8
(svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium
parents:
6253
diff
changeset
|
976 |
ShowVehicleListWindow(st->owner, VEH_TRAIN, (StationID)w->window_number); |
6202
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
977 |
break; |
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
978 |
} |
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
979 |
|
8016
1c7062ad5f50
(svn r11576) -Codechange: enumerize and comment station GUI
smatz
parents:
8005
diff
changeset
|
980 |
case SVW_ROADVEHS: { // Show a list of scheduled road-vehicles to this station |
6202
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
981 |
const Station *st = GetStation(w->window_number); |
6259
471b91a4b1d8
(svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium
parents:
6253
diff
changeset
|
982 |
ShowVehicleListWindow(st->owner, VEH_ROAD, (StationID)w->window_number); |
6202
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
983 |
break; |
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
984 |
} |
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
985 |
|
8016
1c7062ad5f50
(svn r11576) -Codechange: enumerize and comment station GUI
smatz
parents:
8005
diff
changeset
|
986 |
case SVW_PLANES: { // Show a list of scheduled aircraft to this station |
6202
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
987 |
const Station *st = GetStation(w->window_number); |
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
988 |
/* Since oilrigs have no owners, show the scheduled aircraft of current player */ |
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
989 |
PlayerID owner = (st->owner == OWNER_NONE) ? _current_player : st->owner; |
6259
471b91a4b1d8
(svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium
parents:
6253
diff
changeset
|
990 |
ShowVehicleListWindow(owner, VEH_AIRCRAFT, (StationID)w->window_number); |
6202
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
991 |
break; |
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
992 |
} |
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
993 |
|
8016
1c7062ad5f50
(svn r11576) -Codechange: enumerize and comment station GUI
smatz
parents:
8005
diff
changeset
|
994 |
case SVW_SHIPS: { // Show a list of scheduled ships to this station |
6202
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
995 |
const Station *st = GetStation(w->window_number); |
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
996 |
/* Since oilrigs/bouys have no owners, show the scheduled ships of current player */ |
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
997 |
PlayerID owner = (st->owner == OWNER_NONE) ? _current_player : st->owner; |
6259
471b91a4b1d8
(svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium
parents:
6253
diff
changeset
|
998 |
ShowVehicleListWindow(owner, VEH_SHIP, (StationID)w->window_number); |
6202
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
999 |
break; |
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
1000 |
} |
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
817
diff
changeset
|
1001 |
} |
0 | 1002 |
break; |
1003 |
||
6202
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
1004 |
case WE_ON_EDIT_TEXT: |
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
1005 |
if (e->we.edittext.str[0] != '\0') { |
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
1006 |
_cmd_text = e->we.edittext.str; |
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
1007 |
DoCommandP(0, w->window_number, 0, NULL, |
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
1008 |
CMD_RENAME_STATION | CMD_MSG(STR_3031_CAN_T_RENAME_STATION)); |
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
1009 |
} |
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
1010 |
break; |
588 | 1011 |
|
6202
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
1012 |
case WE_DESTROY: { |
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
1013 |
WindowNumber wno = |
8719
349c6abab093
(svn r12393) -Fix [FS#1872]: Vehicle lists related to stations not closed when the station is deleted.
rubidium
parents:
8420
diff
changeset
|
1014 |
(w->window_number << 16) | VLW_STATION_LIST | GetStation(w->window_number)->owner; |
6202
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
1015 |
|
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
1016 |
DeleteWindowById(WC_TRAINS_LIST, wno); |
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
1017 |
DeleteWindowById(WC_ROADVEH_LIST, wno); |
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
1018 |
DeleteWindowById(WC_SHIPS_LIST, wno); |
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
1019 |
DeleteWindowById(WC_AIRCRAFT_LIST, wno); |
588 | 1020 |
break; |
1021 |
} |
|
8420
4ebc9752e7bd
(svn r11990) -Codechange: Show all cargo sources (en-route from) in the station view
peter1138
parents:
8349
diff
changeset
|
1022 |
|
4ebc9752e7bd
(svn r11990) -Codechange: Show all cargo sources (en-route from) in the station view
peter1138
parents:
8349
diff
changeset
|
1023 |
case WE_RESIZE: |
4ebc9752e7bd
(svn r11990) -Codechange: Show all cargo sources (en-route from) in the station view
peter1138
parents:
8349
diff
changeset
|
1024 |
if (e->we.sizing.diff.x != 0) ResizeButtons(w, SVW_LOCATION, SVW_RENAME); |
4ebc9752e7bd
(svn r11990) -Codechange: Show all cargo sources (en-route from) in the station view
peter1138
parents:
8349
diff
changeset
|
1025 |
w->vscroll.cap += e->we.sizing.diff.y / (int)w->resize.step_height; |
4ebc9752e7bd
(svn r11990) -Codechange: Show all cargo sources (en-route from) in the station view
peter1138
parents:
8349
diff
changeset
|
1026 |
break; |
0 | 1027 |
} |
1028 |
} |
|
1029 |
||
1030 |
||
1031 |
static const WindowDesc _station_view_desc = { |
|
7341
02515d0d4ced
(svn r10704) -Codechange: provide an infrastructure to have resizable windows that are smaller than the default window size.
rubidium
parents:
7058
diff
changeset
|
1032 |
WDP_AUTO, WDP_AUTO, 249, 110, 249, 110, |
5893
7e431a4abebb
(svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents:
5745
diff
changeset
|
1033 |
WC_STATION_VIEW, WC_NONE, |
8420
4ebc9752e7bd
(svn r11990) -Codechange: Show all cargo sources (en-route from) in the station view
peter1138
parents:
8349
diff
changeset
|
1034 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_STICKY_BUTTON | WDF_RESIZABLE, |
0 | 1035 |
_station_view_widgets, |
1036 |
StationViewWndProc |
|
1037 |
}; |
|
1038 |
||
8016
1c7062ad5f50
(svn r11576) -Codechange: enumerize and comment station GUI
smatz
parents:
8005
diff
changeset
|
1039 |
/** |
1c7062ad5f50
(svn r11576) -Codechange: enumerize and comment station GUI
smatz
parents:
8005
diff
changeset
|
1040 |
* Opens StationViewWindow for given station |
1c7062ad5f50
(svn r11576) -Codechange: enumerize and comment station GUI
smatz
parents:
8005
diff
changeset
|
1041 |
* |
1c7062ad5f50
(svn r11576) -Codechange: enumerize and comment station GUI
smatz
parents:
8005
diff
changeset
|
1042 |
* @param station station which window should be opened |
1c7062ad5f50
(svn r11576) -Codechange: enumerize and comment station GUI
smatz
parents:
8005
diff
changeset
|
1043 |
*/ |
2498
3ed05caa4449
(svn r3024) -Codechange: Another batch of replacements of int/uint/int16/byte/-1 with proper types and constants
tron
parents:
2484
diff
changeset
|
1044 |
void ShowStationViewWindow(StationID station) |
0 | 1045 |
{ |
6202
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
1046 |
Window *w = AllocateWindowDescFront(&_station_view_desc, station); |
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
1047 |
if (w == NULL) return; |
0 | 1048 |
|
6202
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
1049 |
PlayerID owner = GetStation(w->window_number)->owner; |
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
1050 |
if (owner != OWNER_NONE) w->caption_color = owner; |
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
1051 |
w->vscroll.cap = 5; |
8420
4ebc9752e7bd
(svn r11990) -Codechange: Show all cargo sources (en-route from) in the station view
peter1138
parents:
8349
diff
changeset
|
1052 |
w->resize.step_height = 10; |
0 | 1053 |
} |