author | KUDr |
Fri, 20 Apr 2007 19:43:06 +0000 | |
changeset 6513 | 454347ca3dfb |
parent 6420 | 456c275f3313 |
child 6657 | 75f1dccae0dd |
permissions | -rw-r--r-- |
2186 | 1 |
/* $Id$ */ |
2 |
||
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
|
3 |
/** @file station_gui.cpp */ |
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" |
2163
b17b313113a0
(svn r2673) Include functions.h directly, not globally via openttd.h
tron
parents:
2159
diff
changeset
|
8 |
#include "functions.h" |
1309
4403a69da4f8
(svn r1813) Declare functions implemented in strings.c in their own shiny new header (though i think some of these function don't belong into strings.c)
tron
parents:
1299
diff
changeset
|
9 |
#include "strings.h" |
507
04b5403aaf6b
(svn r815) Include strings.h only in the files which need it.
tron
parents:
487
diff
changeset
|
10 |
#include "table/strings.h" |
0 | 11 |
#include "window.h" |
12 |
#include "gui.h" |
|
13 |
#include "station.h" |
|
14 |
#include "gfx.h" |
|
15 |
#include "player.h" |
|
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
|
16 |
#include "economy.h" |
0 | 17 |
#include "town.h" |
18 |
#include "command.h" |
|
2159
f6284cf5fab0
(svn r2669) Shuffle some more stuff around to reduce dependencies
tron
parents:
2084
diff
changeset
|
19 |
#include "variables.h" |
f6284cf5fab0
(svn r2669) Shuffle some more stuff around to reduce dependencies
tron
parents:
2084
diff
changeset
|
20 |
#include "vehicle_gui.h" |
4261
28670f743746
(svn r5887) -Cleanup: move date related functions, defines and variables to date.[ch]
rubidium
parents:
3859
diff
changeset
|
21 |
#include "date.h" |
4668
f7256d0e7682
(svn r6562) -Codechange: merged the vehicle list window widget arrays
bjarni
parents:
4634
diff
changeset
|
22 |
#include "vehicle.h" |
5668
36b39f4a9032
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5609
diff
changeset
|
23 |
#include "table/sprites.h" |
5587
167d9a91ef02
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5584
diff
changeset
|
24 |
#include "helpers.hpp" |
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
|
25 |
#include "cargotype.h" |
0 | 26 |
|
5271
a2e9e1dd7cb2
(svn r7413) -Fix[FS#386,#412]: Station list window NONE button now behaves correctly.
belugas
parents:
5247
diff
changeset
|
27 |
enum StationListWidgets { |
a2e9e1dd7cb2
(svn r7413) -Fix[FS#386,#412]: Station list window NONE button now behaves correctly.
belugas
parents:
5247
diff
changeset
|
28 |
STATIONLIST_WIDGET_CLOSEBOX = 0, |
a2e9e1dd7cb2
(svn r7413) -Fix[FS#386,#412]: Station list window NONE button now behaves correctly.
belugas
parents:
5247
diff
changeset
|
29 |
STATIONLIST_WIDGET_LIST = 3, |
a2e9e1dd7cb2
(svn r7413) -Fix[FS#386,#412]: Station list window NONE button now behaves correctly.
belugas
parents:
5247
diff
changeset
|
30 |
STATIONLIST_WIDGET_TRAIN =6, |
a2e9e1dd7cb2
(svn r7413) -Fix[FS#386,#412]: Station list window NONE button now behaves correctly.
belugas
parents:
5247
diff
changeset
|
31 |
STATIONLIST_WIDGET_TRUCK, |
a2e9e1dd7cb2
(svn r7413) -Fix[FS#386,#412]: Station list window NONE button now behaves correctly.
belugas
parents:
5247
diff
changeset
|
32 |
STATIONLIST_WIDGET_BUS, |
a2e9e1dd7cb2
(svn r7413) -Fix[FS#386,#412]: Station list window NONE button now behaves correctly.
belugas
parents:
5247
diff
changeset
|
33 |
STATIONLIST_WIDGET_AIRPLANE, |
a2e9e1dd7cb2
(svn r7413) -Fix[FS#386,#412]: Station list window NONE button now behaves correctly.
belugas
parents:
5247
diff
changeset
|
34 |
STATIONLIST_WIDGET_SHIP, |
6271
a17b8a4e17e8
(svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138
parents:
6260
diff
changeset
|
35 |
STATIONLIST_WIDGET_CARGOSTART = 20, |
a17b8a4e17e8
(svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138
parents:
6260
diff
changeset
|
36 |
STATIONLIST_WIDGET_NOCARGOWAITING = 12, |
a17b8a4e17e8
(svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138
parents:
6260
diff
changeset
|
37 |
STATIONLIST_WIDGET_FACILALL = 14, |
5271
a2e9e1dd7cb2
(svn r7413) -Fix[FS#386,#412]: Station list window NONE button now behaves correctly.
belugas
parents:
5247
diff
changeset
|
38 |
STATIONLIST_WIDGET_CARGOALL, |
a2e9e1dd7cb2
(svn r7413) -Fix[FS#386,#412]: Station list window NONE button now behaves correctly.
belugas
parents:
5247
diff
changeset
|
39 |
STATIONLIST_WIDGET_SORTBY, |
a2e9e1dd7cb2
(svn r7413) -Fix[FS#386,#412]: Station list window NONE button now behaves correctly.
belugas
parents:
5247
diff
changeset
|
40 |
STATIONLIST_WIDGET_SORTCRITERIA, |
a2e9e1dd7cb2
(svn r7413) -Fix[FS#386,#412]: Station list window NONE button now behaves correctly.
belugas
parents:
5247
diff
changeset
|
41 |
STATIONLIST_WIDGET_SORTDROPBTN, |
a2e9e1dd7cb2
(svn r7413) -Fix[FS#386,#412]: Station list window NONE button now behaves correctly.
belugas
parents:
5247
diff
changeset
|
42 |
}; |
a2e9e1dd7cb2
(svn r7413) -Fix[FS#386,#412]: Station list window NONE button now behaves correctly.
belugas
parents:
5247
diff
changeset
|
43 |
|
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
|
44 |
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
|
45 |
|
e6fc916c17ab
(svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents:
3554
diff
changeset
|
46 |
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
|
47 |
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
|
48 |
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
|
49 |
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
|
50 |
|
5293
4cc0c1f2f95c
(svn r7446) -Feature: Double the length of the cargo and rating indicators in the station list window,
Darkvater
parents:
5292
diff
changeset
|
51 |
/** Draw small boxes of cargo amount and ratings data at the given |
4cc0c1f2f95c
(svn r7446) -Feature: Double the length of the cargo and rating indicators in the station list window,
Darkvater
parents:
5292
diff
changeset
|
52 |
* 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
|
53 |
* goes for the rating: at above 90% orso (224) it is also 'full' |
4cc0c1f2f95c
(svn r7446) -Feature: Double the length of the cargo and rating indicators in the station list window,
Darkvater
parents:
5292
diff
changeset
|
54 |
* Each cargo-bar is 16 pixels wide and 6 pixels high |
4cc0c1f2f95c
(svn r7446) -Feature: Double the length of the cargo and rating indicators in the station list window,
Darkvater
parents:
5292
diff
changeset
|
55 |
* Each rating 14 pixels wide and 1 pixel high and is 1 pixel below the cargo-bar |
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
|
56 |
* @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
|
57 |
* @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
|
58 |
* @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
|
59 |
* @param amount Cargo amount |
4cc0c1f2f95c
(svn r7446) -Feature: Double the length of the cargo and rating indicators in the station list window,
Darkvater
parents:
5292
diff
changeset
|
60 |
* @param rating ratings data for that particular cargo */ |
4cc0c1f2f95c
(svn r7446) -Feature: Double the length of the cargo and rating indicators in the station list window,
Darkvater
parents:
5292
diff
changeset
|
61 |
static void StationsWndShowStationRating(int x, int y, CargoID type, uint amount, byte rating) |
0 | 62 |
{ |
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
|
63 |
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
|
64 |
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
|
65 |
|
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
|
66 |
int colour = cs->rating_colour; |
5293
4cc0c1f2f95c
(svn r7446) -Feature: Double the length of the cargo and rating indicators in the station list window,
Darkvater
parents:
5292
diff
changeset
|
67 |
uint w = (minu(amount, 576) + 5) / 36; |
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 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
|
70 |
if (w != 0) GfxFillRect(x, y, x + w - 1, y + 6, colour); |
0 | 71 |
|
5293
4cc0c1f2f95c
(svn r7446) -Feature: Double the length of the cargo and rating indicators in the station list window,
Darkvater
parents:
5292
diff
changeset
|
72 |
/* 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
|
73 |
* 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
|
74 |
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
|
75 |
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
|
76 |
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
|
77 |
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
|
78 |
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
|
79 |
} |
0 | 80 |
} |
81 |
||
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
|
82 |
DrawString(x + 1, y, cs->abbrev, 0x10); |
0 | 83 |
|
5293
4cc0c1f2f95c
(svn r7446) -Feature: Double the length of the cargo and rating indicators in the station list window,
Darkvater
parents:
5292
diff
changeset
|
84 |
/* 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
|
85 |
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
|
86 |
GfxFillRect(x + 1, y, x + 14, y, 0xB8); |
4cc0c1f2f95c
(svn r7446) -Feature: Double the length of the cargo and rating indicators in the station list window,
Darkvater
parents:
5292
diff
changeset
|
87 |
rating = minu(rating, 224) / 16; |
4cc0c1f2f95c
(svn r7446) -Feature: Double the length of the cargo and rating indicators in the station list window,
Darkvater
parents:
5292
diff
changeset
|
88 |
if (rating != 0) GfxFillRect(x + 1, y, x + rating, y, 0xD0); |
0 | 89 |
} |
90 |
||
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
|
91 |
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
|
92 |
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
|
93 |
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
|
94 |
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
|
95 |
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
|
96 |
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
|
97 |
}; |
0 | 98 |
|
99 |
static char _bufcache[64]; |
|
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
|
100 |
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
|
101 |
static int _internal_sort_order; |
0 | 102 |
|
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
|
103 |
static int CDECL StationNameSorter(const void *a, const void *b) |
0 | 104 |
{ |
4268
87f1c03f1e5a
(svn r5896) Remove pointless indirection similar to r5894 and remove an unnecessary global variable
tron
parents:
4261
diff
changeset
|
105 |
const Station* st1 = *(const Station**)a; |
87f1c03f1e5a
(svn r5896) Remove pointless indirection similar to r5894 and remove an unnecessary global variable
tron
parents:
4261
diff
changeset
|
106 |
const Station* st2 = *(const Station**)b; |
0 | 107 |
char buf1[64]; |
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
|
108 |
int r; |
0 | 109 |
|
4416
442b18840569
(svn r6169) -Codechange: Use GetString() instead of GetStringWithArgs() which should be
Darkvater
parents:
4354
diff
changeset
|
110 |
SetDParam(0, st1->index); |
4912
0f51b47cb983
(svn r6884) -Codechange: Add strict bounds checking in string formatting system.
Darkvater
parents:
4896
diff
changeset
|
111 |
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
|
112 |
|
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
|
113 |
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
|
114 |
_last_station = st2; |
4416
442b18840569
(svn r6169) -Codechange: Use GetString() instead of GetStringWithArgs() which should be
Darkvater
parents:
4354
diff
changeset
|
115 |
SetDParam(0, st2->index); |
4912
0f51b47cb983
(svn r6884) -Codechange: Add strict bounds checking in string formatting system.
Darkvater
parents:
4896
diff
changeset
|
116 |
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
|
117 |
} |
0 | 118 |
|
6202
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
119 |
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
|
120 |
return (_internal_sort_order & 1) ? -r : r; |
0 | 121 |
} |
122 |
||
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 |
static int CDECL StationTypeSorter(const void *a, const void *b) |
0 | 124 |
{ |
4268
87f1c03f1e5a
(svn r5896) Remove pointless indirection similar to r5894 and remove an unnecessary global variable
tron
parents:
4261
diff
changeset
|
125 |
const Station* st1 = *(const Station**)a; |
87f1c03f1e5a
(svn r5896) Remove pointless indirection similar to r5894 and remove an unnecessary global variable
tron
parents:
4261
diff
changeset
|
126 |
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
|
127 |
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
|
128 |
} |
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 |
|
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 |
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
|
131 |
{ |
4268
87f1c03f1e5a
(svn r5896) Remove pointless indirection similar to r5894 and remove an unnecessary global variable
tron
parents:
4261
diff
changeset
|
132 |
const Station* st1 = *(const Station**)a; |
87f1c03f1e5a
(svn r5896) Remove pointless indirection similar to r5894 and remove an unnecessary global variable
tron
parents:
4261
diff
changeset
|
133 |
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
|
134 |
int sum1 = 0, sum2 = 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
|
135 |
|
6202
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
136 |
for (CargoID j = 0; j < NUM_CARGO; 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
|
137 |
if (st1->goods[j].waiting_acceptance & 0xfff) sum1 += GetTransportedGoodsIncome(st1->goods[j].waiting_acceptance & 0xfff, 20, 50, j); |
e6fc916c17ab
(svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents:
3554
diff
changeset
|
138 |
if (st2->goods[j].waiting_acceptance & 0xfff) sum2 += GetTransportedGoodsIncome(st2->goods[j].waiting_acceptance & 0xfff, 20, 50, j); |
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 |
|
e6fc916c17ab
(svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents:
3554
diff
changeset
|
141 |
return (_internal_sort_order & 1) ? sum2 - sum1 : sum1 - sum2; |
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 |
{ |
4268
87f1c03f1e5a
(svn r5896) Remove pointless indirection similar to r5894 and remove an unnecessary global variable
tron
parents:
4261
diff
changeset
|
154 |
const Station* st1 = *(const Station**)a; |
87f1c03f1e5a
(svn r5896) Remove pointless indirection similar to r5894 and remove an unnecessary global variable
tron
parents:
4261
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++) { |
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
|
160 |
if (st1->goods[j].enroute_from != INVALID_STATION) maxr1 = max(maxr1, st1->goods[j].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
|
161 |
if (st2->goods[j].enroute_from != INVALID_STATION) 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 |
|
6248
e4a2ed7e5613
(svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents:
6247
diff
changeset
|
167 |
enum StationListFlags { |
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
|
168 |
SL_ORDER = 0x01, |
e6fc916c17ab
(svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents:
3554
diff
changeset
|
169 |
SL_RESORT = 0x02, |
e6fc916c17ab
(svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents:
3554
diff
changeset
|
170 |
SL_REBUILD = 0x04, |
6248
e4a2ed7e5613
(svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents:
6247
diff
changeset
|
171 |
}; |
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
|
172 |
|
5587
167d9a91ef02
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5584
diff
changeset
|
173 |
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
|
174 |
|
6248
e4a2ed7e5613
(svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents:
6247
diff
changeset
|
175 |
struct plstations_d { |
4268
87f1c03f1e5a
(svn r5896) Remove pointless indirection similar to r5894 and remove an unnecessary global variable
tron
parents:
4261
diff
changeset
|
176 |
const Station** sort_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
|
177 |
uint16 list_length; |
e6fc916c17ab
(svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents:
3554
diff
changeset
|
178 |
byte sort_type; |
e6fc916c17ab
(svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents:
3554
diff
changeset
|
179 |
StationListFlags flags; |
e6fc916c17ab
(svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents:
3554
diff
changeset
|
180 |
uint16 resort_timer; //was byte refresh_counter; |
6248
e4a2ed7e5613
(svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents:
6247
diff
changeset
|
181 |
}; |
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
|
182 |
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
|
183 |
|
6247 | 184 |
void RebuildStationLists() |
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
|
185 |
{ |
5124
2ca62776430e
(svn r7205) -Fix [FS#350, SF#1560913]: Window allocation and deletion messed with the actual window
Darkvater
parents:
5070
diff
changeset
|
186 |
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
|
187 |
|
5124
2ca62776430e
(svn r7205) -Fix [FS#350, SF#1560913]: Window allocation and deletion messed with the actual window
Darkvater
parents:
5070
diff
changeset
|
188 |
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
|
189 |
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
|
190 |
if (w->window_class == WC_STATION_LIST) { |
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 |
WP(w, plstations_d).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
|
192 |
SetWindowDirty(w); |
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 |
} |
e6fc916c17ab
(svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents:
3554
diff
changeset
|
194 |
} |
e6fc916c17ab
(svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents:
3554
diff
changeset
|
195 |
} |
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 |
|
6247 | 197 |
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
|
198 |
{ |
5124
2ca62776430e
(svn r7205) -Fix [FS#350, SF#1560913]: Window allocation and deletion messed with the actual window
Darkvater
parents:
5070
diff
changeset
|
199 |
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
|
200 |
|
5124
2ca62776430e
(svn r7205) -Fix [FS#350, SF#1560913]: Window allocation and deletion messed with the actual window
Darkvater
parents:
5070
diff
changeset
|
201 |
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
|
202 |
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
|
203 |
if (w->window_class == WC_STATION_LIST) { |
e6fc916c17ab
(svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents:
3554
diff
changeset
|
204 |
WP(w, plstations_d).flags |= SL_RESORT; |
e6fc916c17ab
(svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents:
3554
diff
changeset
|
205 |
SetWindowDirty(w); |
e6fc916c17ab
(svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents:
3554
diff
changeset
|
206 |
} |
e6fc916c17ab
(svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents:
3554
diff
changeset
|
207 |
} |
e6fc916c17ab
(svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents:
3554
diff
changeset
|
208 |
} |
e6fc916c17ab
(svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents:
3554
diff
changeset
|
209 |
|
6271
a17b8a4e17e8
(svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138
parents:
6260
diff
changeset
|
210 |
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
|
211 |
{ |
e6fc916c17ab
(svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents:
3554
diff
changeset
|
212 |
uint n = 0; |
243
9a40daa560ae
(svn r244) -Fix: Stations were not sorted for non-player-0 players
darkvater
parents:
222
diff
changeset
|
213 |
const Station *st; |
9a40daa560ae
(svn r244) -Fix: Stations were not sorted for non-player-0 players
darkvater
parents:
222
diff
changeset
|
214 |
|
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 |
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
|
216 |
|
544f374ee392
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
893
diff
changeset
|
217 |
/* Create array for sorting */ |
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
|
218 |
const Station** station_sort = MallocT<const Station*>(GetMaxStationIndex() + 1); |
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5293
diff
changeset
|
219 |
if (station_sort == NULL) error("Could not allocate memory for the station-sorting-list"); |
0 | 220 |
|
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5293
diff
changeset
|
221 |
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
|
222 |
|
0 | 223 |
FOR_ALL_STATIONS(st) { |
4346
66105d4f6e83
(svn r6047) -Codechange: FOR_ALL now _only_ loops valid items, and skips invalid ones
truelight
parents:
4344
diff
changeset
|
224 |
if (st->owner == 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
|
225 |
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
|
226 |
int num_waiting_cargo = 0; |
6202
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
227 |
for (CargoID j = 0; j < NUM_CARGO; 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
|
228 |
if (st->goods[j].waiting_acceptance & 0xFFF) { |
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 |
num_waiting_cargo++; //count number of waiting cargo |
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 |
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
|
231 |
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
|
232 |
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
|
233 |
} |
e6fc916c17ab
(svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents:
3554
diff
changeset
|
234 |
} |
e6fc916c17ab
(svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents:
3554
diff
changeset
|
235 |
} |
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
|
236 |
/* stations without waiting cargo */ |
6271
a17b8a4e17e8
(svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138
parents:
6260
diff
changeset
|
237 |
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
|
238 |
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
|
239 |
} |
e6fc916c17ab
(svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents:
3554
diff
changeset
|
240 |
} |
0 | 241 |
} |
242 |
} |
|
243 |
||
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
|
244 |
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
|
245 |
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
|
246 |
if (n != 0 && sl->sort_list == NULL) error("Could not allocate memory for the station-sorting-list"); |
e6fc916c17ab
(svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents:
3554
diff
changeset
|
247 |
sl->list_length = n; |
0 | 248 |
|
6202
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
249 |
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
|
250 |
|
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
|
251 |
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
|
252 |
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
|
253 |
free((void*)station_sort); |
243
9a40daa560ae
(svn r244) -Fix: Stations were not sorted for non-player-0 players
darkvater
parents:
222
diff
changeset
|
254 |
} |
9a40daa560ae
(svn r244) -Fix: Stations were not sorted for non-player-0 players
darkvater
parents:
222
diff
changeset
|
255 |
|
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 |
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
|
257 |
{ |
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
|
258 |
static StationSortListingTypeFunction* const _station_sorter[] = { |
e6fc916c17ab
(svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents:
3554
diff
changeset
|
259 |
&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
|
260 |
&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
|
261 |
&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
|
262 |
&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
|
263 |
}; |
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
|
264 |
|
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
|
265 |
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
|
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 |
_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
|
268 |
_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
|
269 |
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
|
270 |
|
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
|
271 |
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
|
272 |
sl->flags &= ~SL_RESORT; |
0 | 273 |
} |
274 |
||
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
|
275 |
static const uint32 _cargo_filter_max = ~0; |
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
|
276 |
static uint32 _cargo_filter = _cargo_filter_max; |
6271
a17b8a4e17e8
(svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138
parents:
6260
diff
changeset
|
277 |
|
0 | 278 |
static void PlayerStationsWndProc(Window *w, WindowEvent *e) |
279 |
{ |
|
5587
167d9a91ef02
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5584
diff
changeset
|
280 |
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
|
281 |
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
|
282 |
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
|
283 |
static bool include_empty = true; |
5608
0b0aff054402
(svn r8065) -Feature: The station list does now remember the sort settings
celestar
parents:
5587
diff
changeset
|
284 |
|
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
|
285 |
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
|
286 |
|
2639 | 287 |
switch (e->event) { |
6202
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
288 |
case WE_CREATE: /* set up resort timer */ |
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
|
289 |
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
|
290 |
|
6202
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
291 |
for (uint i = 0; i < 5; i++) { |
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
292 |
if (HASBIT(facilities, i)) LowerWindowWidget(w, i + STATIONLIST_WIDGET_TRAIN); |
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
293 |
} |
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
294 |
SetWindowWidgetLoweredState(w, STATIONLIST_WIDGET_FACILALL, facilities == (FACIL_TRAIN | FACIL_TRUCK_STOP | FACIL_BUS_STOP | FACIL_AIRPORT | FACIL_DOCK)); |
6271
a17b8a4e17e8
(svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138
parents:
6260
diff
changeset
|
295 |
SetWindowWidgetLoweredState(w, STATIONLIST_WIDGET_CARGOALL, _cargo_filter == _cargo_mask && include_empty); |
a17b8a4e17e8
(svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138
parents:
6260
diff
changeset
|
296 |
SetWindowWidgetLoweredState(w, STATIONLIST_WIDGET_NOCARGOWAITING, include_empty); |
5271
a2e9e1dd7cb2
(svn r7413) -Fix[FS#386,#412]: Station list window NONE button now behaves correctly.
belugas
parents:
5247
diff
changeset
|
297 |
|
6202
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
298 |
sl->sort_list = NULL; |
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
299 |
sl->flags = SL_REBUILD; |
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
300 |
sl->sort_type = station_sort.criteria; |
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
301 |
if (station_sort.order) sl->flags |= SL_ORDER; |
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
302 |
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
|
303 |
break; |
5271
a2e9e1dd7cb2
(svn r7413) -Fix[FS#386,#412]: Station list window NONE button now behaves correctly.
belugas
parents:
5247
diff
changeset
|
304 |
|
6202
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
305 |
case WE_PAINT: { |
6271
a17b8a4e17e8
(svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138
parents:
6260
diff
changeset
|
306 |
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
|
307 |
SortStationsList(sl); |
0 | 308 |
|
6202
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
309 |
SetVScrollCount(w, sl->list_length); |
0 | 310 |
|
6202
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
311 |
/* draw widgets, with player's name in the caption */ |
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
|
312 |
const Player* p = GetPlayer(owner); |
534
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
313 |
SetDParam(0, p->name_1); |
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
314 |
SetDParam(1, p->name_2); |
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
315 |
SetDParam(2, w->vscroll.count); |
0 | 316 |
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
|
317 |
|
e6fc916c17ab
(svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents:
3554
diff
changeset
|
318 |
/* draw sorting criteria string */ |
e6fc916c17ab
(svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents:
3554
diff
changeset
|
319 |
DrawString(85, 26, _station_sort_listing[sl->sort_type], 0x10); |
e6fc916c17ab
(svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents:
3554
diff
changeset
|
320 |
/* draw arrow pointing up/down for ascending/descending sorting */ |
e6fc916c17ab
(svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents:
3554
diff
changeset
|
321 |
DoDrawString(sl->flags & SL_ORDER ? DOWNARROW : UPARROW, 69, 26, 0x10); |
e6fc916c17ab
(svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents:
3554
diff
changeset
|
322 |
|
6202
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
323 |
int cg_ofst; |
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
324 |
int x = 89; |
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
325 |
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
|
326 |
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
|
327 |
|
6271
a17b8a4e17e8
(svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138
parents:
6260
diff
changeset
|
328 |
uint i = 0; |
a17b8a4e17e8
(svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138
parents:
6260
diff
changeset
|
329 |
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
|
330 |
const CargoSpec *cs = GetCargo(c); |
a17b8a4e17e8
(svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138
parents:
6260
diff
changeset
|
331 |
if (!cs->IsValid()) continue; |
a17b8a4e17e8
(svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138
parents:
6260
diff
changeset
|
332 |
|
a17b8a4e17e8
(svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138
parents:
6260
diff
changeset
|
333 |
cg_ofst = HASBIT(_cargo_filter, c) ? 2 : 1; |
a17b8a4e17e8
(svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138
parents:
6260
diff
changeset
|
334 |
GfxFillRect(x + cg_ofst, y + cg_ofst, x + cg_ofst + 10 , y + cg_ofst + 7, cs->rating_colour); |
a17b8a4e17e8
(svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138
parents:
6260
diff
changeset
|
335 |
DrawStringCentered(x + 6 + cg_ofst, y + cg_ofst, cs->abbrev, 0x10); |
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
|
336 |
x += 14; |
6271
a17b8a4e17e8
(svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138
parents:
6260
diff
changeset
|
337 |
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
|
338 |
} |
e6fc916c17ab
(svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents:
3554
diff
changeset
|
339 |
|
5292
9ed70e1277db
(svn r7445) -Codechange (r4822): Properly draw the cargo colours in the station list and centre the
Darkvater
parents:
5291
diff
changeset
|
340 |
x += 6; |
9ed70e1277db
(svn r7445) -Codechange (r4822): Properly draw the cargo colours in the station list and centre the
Darkvater
parents:
5291
diff
changeset
|
341 |
cg_ofst = IsWindowWidgetLowered(w, STATIONLIST_WIDGET_NOCARGOWAITING) ? 2 : 1; |
9ed70e1277db
(svn r7445) -Codechange (r4822): Properly draw the cargo colours in the station list and centre the
Darkvater
parents:
5291
diff
changeset
|
342 |
DrawStringCentered(x + cg_ofst, y + cg_ofst, STR_ABBREV_NONE, 16); |
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
|
343 |
x += 14; |
5292
9ed70e1277db
(svn r7445) -Codechange (r4822): Properly draw the cargo colours in the station list and centre the
Darkvater
parents:
5291
diff
changeset
|
344 |
cg_ofst = IsWindowWidgetLowered(w, STATIONLIST_WIDGET_CARGOALL) ? 2 : 1; |
9ed70e1277db
(svn r7445) -Codechange (r4822): Properly draw the cargo colours in the station list and centre the
Darkvater
parents:
5291
diff
changeset
|
345 |
DrawStringCentered(x + cg_ofst, y + cg_ofst, STR_ABBREV_ALL, 16); |
5271
a2e9e1dd7cb2
(svn r7413) -Fix[FS#386,#412]: Station list window NONE button now behaves correctly.
belugas
parents:
5247
diff
changeset
|
346 |
|
5292
9ed70e1277db
(svn r7445) -Codechange (r4822): Properly draw the cargo colours in the station list and centre the
Darkvater
parents:
5291
diff
changeset
|
347 |
cg_ofst = IsWindowWidgetLowered(w, STATIONLIST_WIDGET_FACILALL) ? 2 : 1; |
9ed70e1277db
(svn r7445) -Codechange (r4822): Properly draw the cargo colours in the station list and centre the
Darkvater
parents:
5291
diff
changeset
|
348 |
DrawString(71 + cg_ofst, y + cg_ofst, STR_ABBREV_ALL, 16); |
0 | 349 |
|
2026 | 350 |
if (w->vscroll.count == 0) { // player has no stations |
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
|
351 |
DrawString(xb, 40, STR_304A_NONE, 0); |
0 | 352 |
return; |
353 |
} |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
354 |
|
6202
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
355 |
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
|
356 |
y = 40; // start of the list-widget |
0 | 357 |
|
6202
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
358 |
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
|
359 |
const Station *st = sl->sort_list[i]; |
2630 | 360 |
int x; |
0 | 361 |
|
5293
4cc0c1f2f95c
(svn r7446) -Feature: Double the length of the cargo and rating indicators in the station list window,
Darkvater
parents:
5292
diff
changeset
|
362 |
assert(st->xy != 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
|
363 |
assert(st->owner == owner); |
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
|
364 |
|
534
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
365 |
SetDParam(0, st->index); |
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
366 |
SetDParam(1, st->facilities); |
0 | 367 |
x = DrawString(xb, y, STR_3049_0, 0) + 5; |
368 |
||
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
|
369 |
/* 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
|
370 |
for (CargoID j = 0; j < NUM_CARGO; j++) { |
5293
4cc0c1f2f95c
(svn r7446) -Feature: Double the length of the cargo and rating indicators in the station list window,
Darkvater
parents:
5292
diff
changeset
|
371 |
uint amount = GB(st->goods[j].waiting_acceptance, 0, 12); |
4cc0c1f2f95c
(svn r7446) -Feature: Double the length of the cargo and rating indicators in the station list window,
Darkvater
parents:
5292
diff
changeset
|
372 |
if (amount != 0) { |
4cc0c1f2f95c
(svn r7446) -Feature: Double the length of the cargo and rating indicators in the station list window,
Darkvater
parents:
5292
diff
changeset
|
373 |
StationsWndShowStationRating(x, y, j, amount, st->goods[j].rating); |
4cc0c1f2f95c
(svn r7446) -Feature: Double the length of the cargo and rating indicators in the station list window,
Darkvater
parents:
5292
diff
changeset
|
374 |
x += 20; |
0 | 375 |
} |
376 |
} |
|
377 |
y += 10; |
|
378 |
} |
|
4268
87f1c03f1e5a
(svn r5896) Remove pointless indirection similar to r5894 and remove an unnecessary global variable
tron
parents:
4261
diff
changeset
|
379 |
break; |
87f1c03f1e5a
(svn r5896) Remove pointless indirection similar to r5894 and remove an unnecessary global variable
tron
parents:
4261
diff
changeset
|
380 |
} |
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
|
381 |
|
6202
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
382 |
case WE_CLICK: |
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
383 |
switch (e->we.click.widget) { |
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
384 |
case STATIONLIST_WIDGET_LIST: { |
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
385 |
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
|
386 |
|
6202
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
387 |
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
|
388 |
|
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
389 |
id_v += w->vscroll.pos; |
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
390 |
|
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
391 |
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
|
392 |
|
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
393 |
const Station *st = sl->sort_list[id_v]; |
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
394 |
assert(st->owner == owner); |
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
395 |
ScrollMainWindowToTile(st->xy); |
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
396 |
break; |
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
397 |
} |
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
398 |
|
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
399 |
case STATIONLIST_WIDGET_TRAIN: |
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
400 |
case STATIONLIST_WIDGET_TRUCK: |
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
401 |
case STATIONLIST_WIDGET_BUS: |
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
402 |
case STATIONLIST_WIDGET_AIRPLANE: |
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
403 |
case STATIONLIST_WIDGET_SHIP: |
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
404 |
if (_ctrl_pressed) { |
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
405 |
TOGGLEBIT(facilities, e->we.click.widget - STATIONLIST_WIDGET_TRAIN); |
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
406 |
ToggleWidgetLoweredState(w, e->we.click.widget); |
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
407 |
} else { |
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
408 |
for (uint i = 0; facilities != 0; i++, facilities >>= 1) { |
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
409 |
if (HASBIT(facilities, 0)) RaiseWindowWidget(w, i + STATIONLIST_WIDGET_TRAIN); |
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
410 |
} |
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
411 |
SETBIT(facilities, e->we.click.widget - STATIONLIST_WIDGET_TRAIN); |
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
412 |
LowerWindowWidget(w, e->we.click.widget); |
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
413 |
} |
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
414 |
SetWindowWidgetLoweredState(w, STATIONLIST_WIDGET_FACILALL, 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
|
415 |
sl->flags |= SL_REBUILD; |
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
416 |
SetWindowDirty(w); |
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
417 |
break; |
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
418 |
|
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
419 |
case STATIONLIST_WIDGET_FACILALL: |
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
420 |
for (uint i = 0; i < 5; i++) { |
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
421 |
LowerWindowWidget(w, i + STATIONLIST_WIDGET_TRAIN); |
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
422 |
} |
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
423 |
LowerWindowWidget(w, STATIONLIST_WIDGET_FACILALL); |
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
424 |
|
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
425 |
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
|
426 |
sl->flags |= SL_REBUILD; |
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
427 |
SetWindowDirty(w); |
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
428 |
break; |
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
429 |
|
6271
a17b8a4e17e8
(svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138
parents:
6260
diff
changeset
|
430 |
case STATIONLIST_WIDGET_CARGOALL: { |
a17b8a4e17e8
(svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138
parents:
6260
diff
changeset
|
431 |
uint i = 0; |
a17b8a4e17e8
(svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138
parents:
6260
diff
changeset
|
432 |
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
|
433 |
if (!GetCargo(c)->IsValid()) continue; |
6202
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
434 |
LowerWindowWidget(w, i + STATIONLIST_WIDGET_CARGOSTART); |
6271
a17b8a4e17e8
(svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138
parents:
6260
diff
changeset
|
435 |
i++; |
6202
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
436 |
} |
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
437 |
LowerWindowWidget(w, STATIONLIST_WIDGET_NOCARGOWAITING); |
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
438 |
LowerWindowWidget(w, STATIONLIST_WIDGET_CARGOALL); |
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
439 |
|
6271
a17b8a4e17e8
(svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138
parents:
6260
diff
changeset
|
440 |
_cargo_filter = _cargo_mask; |
a17b8a4e17e8
(svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138
parents:
6260
diff
changeset
|
441 |
include_empty = true; |
6202
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
442 |
sl->flags |= SL_REBUILD; |
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
443 |
SetWindowDirty(w); |
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
444 |
break; |
6271
a17b8a4e17e8
(svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138
parents:
6260
diff
changeset
|
445 |
} |
6202
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
446 |
|
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
447 |
case STATIONLIST_WIDGET_SORTBY: /*flip sorting method asc/desc*/ |
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
448 |
sl->flags ^= SL_ORDER; //DESC-flag |
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
449 |
station_sort.order = GB(sl->flags, 0, 1); |
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
450 |
sl->flags |= SL_RESORT; |
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
451 |
w->flags4 |= 5 << WF_TIMEOUT_SHL; |
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
452 |
LowerWindowWidget(w, STATIONLIST_WIDGET_SORTBY); |
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
453 |
SetWindowDirty(w); |
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
454 |
break; |
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
455 |
|
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
456 |
case STATIONLIST_WIDGET_SORTCRITERIA: |
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
457 |
case STATIONLIST_WIDGET_SORTDROPBTN: /* select sorting criteria dropdown menu */ |
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
458 |
ShowDropDownMenu(w, _station_sort_listing, sl->sort_type, STATIONLIST_WIDGET_SORTDROPBTN, 0, 0); |
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
459 |
break; |
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
460 |
|
6271
a17b8a4e17e8
(svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138
parents:
6260
diff
changeset
|
461 |
case STATIONLIST_WIDGET_NOCARGOWAITING: |
a17b8a4e17e8
(svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138
parents:
6260
diff
changeset
|
462 |
if (_ctrl_pressed) { |
a17b8a4e17e8
(svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138
parents:
6260
diff
changeset
|
463 |
include_empty = !include_empty; |
a17b8a4e17e8
(svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138
parents:
6260
diff
changeset
|
464 |
ToggleWidgetLoweredState(w, STATIONLIST_WIDGET_NOCARGOWAITING); |
a17b8a4e17e8
(svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138
parents:
6260
diff
changeset
|
465 |
} else { |
a17b8a4e17e8
(svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138
parents:
6260
diff
changeset
|
466 |
for (uint i = STATIONLIST_WIDGET_CARGOSTART; i < w->widget_count; i++) { |
a17b8a4e17e8
(svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138
parents:
6260
diff
changeset
|
467 |
RaiseWindowWidget(w, i); |
a17b8a4e17e8
(svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138
parents:
6260
diff
changeset
|
468 |
} |
a17b8a4e17e8
(svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138
parents:
6260
diff
changeset
|
469 |
|
a17b8a4e17e8
(svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138
parents:
6260
diff
changeset
|
470 |
_cargo_filter = 0; |
a17b8a4e17e8
(svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138
parents:
6260
diff
changeset
|
471 |
include_empty = true; |
a17b8a4e17e8
(svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138
parents:
6260
diff
changeset
|
472 |
|
a17b8a4e17e8
(svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138
parents:
6260
diff
changeset
|
473 |
LowerWindowWidget(w, STATIONLIST_WIDGET_NOCARGOWAITING); |
a17b8a4e17e8
(svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138
parents:
6260
diff
changeset
|
474 |
} |
a17b8a4e17e8
(svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138
parents:
6260
diff
changeset
|
475 |
sl->flags |= SL_REBUILD; |
a17b8a4e17e8
(svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138
parents:
6260
diff
changeset
|
476 |
SetWindowWidgetLoweredState(w, STATIONLIST_WIDGET_CARGOALL, _cargo_filter == _cargo_mask && include_empty); |
a17b8a4e17e8
(svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138
parents:
6260
diff
changeset
|
477 |
SetWindowDirty(w); |
a17b8a4e17e8
(svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138
parents:
6260
diff
changeset
|
478 |
break; |
a17b8a4e17e8
(svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138
parents:
6260
diff
changeset
|
479 |
|
6202
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
480 |
default: |
6271
a17b8a4e17e8
(svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138
parents:
6260
diff
changeset
|
481 |
if (e->we.click.widget >= STATIONLIST_WIDGET_CARGOSTART) { //change cargo_filter |
a17b8a4e17e8
(svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138
parents:
6260
diff
changeset
|
482 |
/* Determine the selected cargo type */ |
a17b8a4e17e8
(svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138
parents:
6260
diff
changeset
|
483 |
CargoID c; |
a17b8a4e17e8
(svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138
parents:
6260
diff
changeset
|
484 |
int i = 0; |
a17b8a4e17e8
(svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138
parents:
6260
diff
changeset
|
485 |
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
|
486 |
if (!GetCargo(c)->IsValid()) continue; |
a17b8a4e17e8
(svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138
parents:
6260
diff
changeset
|
487 |
if (e->we.click.widget - STATIONLIST_WIDGET_CARGOSTART == i) break; |
a17b8a4e17e8
(svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138
parents:
6260
diff
changeset
|
488 |
i++; |
a17b8a4e17e8
(svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138
parents:
6260
diff
changeset
|
489 |
} |
a17b8a4e17e8
(svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138
parents:
6260
diff
changeset
|
490 |
|
6202
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
491 |
if (_ctrl_pressed) { |
6271
a17b8a4e17e8
(svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138
parents:
6260
diff
changeset
|
492 |
TOGGLEBIT(_cargo_filter, c); |
6202
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
493 |
ToggleWidgetLoweredState(w, e->we.click.widget); |
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
494 |
} else { |
6271
a17b8a4e17e8
(svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138
parents:
6260
diff
changeset
|
495 |
for (uint i = STATIONLIST_WIDGET_CARGOSTART; i < w->widget_count; i++) { |
a17b8a4e17e8
(svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138
parents:
6260
diff
changeset
|
496 |
RaiseWindowWidget(w, i); |
6202
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
497 |
} |
6271
a17b8a4e17e8
(svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138
parents:
6260
diff
changeset
|
498 |
RaiseWindowWidget(w, STATIONLIST_WIDGET_NOCARGOWAITING); |
a17b8a4e17e8
(svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138
parents:
6260
diff
changeset
|
499 |
|
a17b8a4e17e8
(svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138
parents:
6260
diff
changeset
|
500 |
_cargo_filter = 0; |
a17b8a4e17e8
(svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138
parents:
6260
diff
changeset
|
501 |
include_empty = false; |
a17b8a4e17e8
(svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138
parents:
6260
diff
changeset
|
502 |
|
a17b8a4e17e8
(svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138
parents:
6260
diff
changeset
|
503 |
SETBIT(_cargo_filter, c); |
6202
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
504 |
LowerWindowWidget(w, e->we.click.widget); |
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
505 |
} |
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
506 |
sl->flags |= SL_REBUILD; |
6271
a17b8a4e17e8
(svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138
parents:
6260
diff
changeset
|
507 |
SetWindowWidgetLoweredState(w, STATIONLIST_WIDGET_CARGOALL, _cargo_filter == _cargo_mask && include_empty); |
6202
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
508 |
SetWindowDirty(w); |
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
509 |
} |
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
510 |
break; |
4719
fc6e14219f72
(svn r6631) -Codechange: Use accessors for click_state.
belugas
parents:
4709
diff
changeset
|
511 |
} |
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
|
512 |
break; |
6202
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
513 |
|
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
514 |
case WE_DROPDOWN_SELECT: /* we have selected a dropdown item in the list */ |
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
515 |
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
|
516 |
/* value has changed -> resort */ |
6202
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
517 |
sl->sort_type = e->we.dropdown.index; |
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
518 |
station_sort.criteria = sl->sort_type; |
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
519 |
sl->flags |= SL_RESORT; |
4719
fc6e14219f72
(svn r6631) -Codechange: Use accessors for click_state.
belugas
parents:
4709
diff
changeset
|
520 |
} |
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
|
521 |
SetWindowDirty(w); |
e6fc916c17ab
(svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents:
3554
diff
changeset
|
522 |
break; |
5271
a2e9e1dd7cb2
(svn r7413) -Fix[FS#386,#412]: Station list window NONE button now behaves correctly.
belugas
parents:
5247
diff
changeset
|
523 |
|
6202
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
524 |
case WE_TICK: |
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
525 |
if (--sl->resort_timer == 0) { |
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
526 |
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
|
527 |
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
|
528 |
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
|
529 |
SetWindowDirty(w); |
e6fc916c17ab
(svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents:
3554
diff
changeset
|
530 |
} |
6202
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
531 |
break; |
0 | 532 |
|
6202
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
533 |
case WE_TIMEOUT: |
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
534 |
RaiseWindowWidget(w, STATIONLIST_WIDGET_SORTBY); |
0 | 535 |
SetWindowDirty(w); |
6202
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
536 |
break; |
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
817
diff
changeset
|
537 |
|
6202
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
538 |
case WE_RESIZE: |
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
539 |
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
|
540 |
break; |
0 | 541 |
} |
542 |
} |
|
543 |
||
544 |
static const Widget _player_stations_widgets[] = { |
|
3554
86230061c3e7
(svn r4426) Code Cleaning : replacing tabs with spaces, removing obvious comments, aligning arrays etc...
belugas
parents:
2725
diff
changeset
|
545 |
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
86230061c3e7
(svn r4426) Code Cleaning : replacing tabs with spaces, removing obvious comments, aligning arrays etc...
belugas
parents:
2725
diff
changeset
|
546 |
{ 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
|
547 |
{ WWT_STICKYBOX, RESIZE_LR, 14, 346, 357, 0, 13, 0x0, STR_STICKY_BUTTON}, |
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
|
548 |
{ WWT_PANEL, RESIZE_RB, 14, 0, 345, 37, 161, 0x0, STR_3057_STATION_NAMES_CLICK_ON}, |
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
|
549 |
{ 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
|
550 |
{ 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
|
551 |
//Index 6 |
4344
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4299
diff
changeset
|
552 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 0, 13, 14, 24, STR_TRAIN, STR_USE_CTRL_TO_SELECT_MORE}, |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4299
diff
changeset
|
553 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 14, 27, 14, 24, STR_LORRY, STR_USE_CTRL_TO_SELECT_MORE}, |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4299
diff
changeset
|
554 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 28, 41, 14, 24, STR_BUS, STR_USE_CTRL_TO_SELECT_MORE}, |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4299
diff
changeset
|
555 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 42, 55, 14, 24, STR_PLANE, STR_USE_CTRL_TO_SELECT_MORE}, |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4299
diff
changeset
|
556 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 56, 69, 14, 24, STR_SHIP, STR_USE_CTRL_TO_SELECT_MORE}, |
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 |
//Index 11 |
4344
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4299
diff
changeset
|
558 |
{ WWT_PANEL, RESIZE_NONE, 14, 83, 88, 14, 24, 0x0, STR_USE_CTRL_TO_SELECT_MORE}, |
6271
a17b8a4e17e8
(svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138
parents:
6260
diff
changeset
|
559 |
{ WWT_PANEL, RESIZE_NONE, 14, 89, 102, 14, 24, 0x0, STR_NO_WAITING_CARGO}, |
a17b8a4e17e8
(svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138
parents:
6260
diff
changeset
|
560 |
{ WWT_PANEL, RESIZE_RIGHT, 14, 117, 357, 14, 24, 0x0, STR_NULL}, |
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
|
561 |
|
6271
a17b8a4e17e8
(svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138
parents:
6260
diff
changeset
|
562 |
//14 |
4344
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4299
diff
changeset
|
563 |
{ WWT_PANEL, RESIZE_NONE, 14, 70, 83, 14, 24, 0x0, STR_SELECT_ALL_FACILITIES}, |
6271
a17b8a4e17e8
(svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138
parents:
6260
diff
changeset
|
564 |
{ WWT_PANEL, RESIZE_NONE, 14, 103, 116, 14, 24, 0x0, STR_SELECT_ALL_TYPES}, |
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
|
565 |
|
6271
a17b8a4e17e8
(svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138
parents:
6260
diff
changeset
|
566 |
//16 |
5271
a2e9e1dd7cb2
(svn r7413) -Fix[FS#386,#412]: Station list window NONE button now behaves correctly.
belugas
parents:
5247
diff
changeset
|
567 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 0, 80, 25, 36, STR_SORT_BY, STR_SORT_ORDER_TIP}, |
4344
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4299
diff
changeset
|
568 |
{ WWT_PANEL, RESIZE_NONE, 14, 81, 232, 25, 36, 0x0, STR_SORT_CRITERIA_TIP}, |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4299
diff
changeset
|
569 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 233, 243, 25, 36, STR_0225, STR_SORT_CRITERIA_TIP}, |
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
|
570 |
{ WWT_PANEL, RESIZE_RIGHT, 14, 244, 357, 25, 36, 0x0, STR_NULL}, |
176
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
174
diff
changeset
|
571 |
{ WIDGETS_END}, |
0 | 572 |
}; |
573 |
||
574 |
static const WindowDesc _player_stations_desc = { |
|
5070
7f5b13b7e728
(svn r7128) -Codechange: Replace magic numbers by magic enums (windowdesc positioning WDP_AUTO = -1)
Darkvater
parents:
5038
diff
changeset
|
575 |
WDP_AUTO, WDP_AUTO, 358, 162, |
5893
7e431a4abebb
(svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents:
5745
diff
changeset
|
576 |
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
|
577 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_STICKY_BUTTON | WDF_RESIZABLE, |
0 | 578 |
_player_stations_widgets, |
579 |
PlayerStationsWndProc |
|
580 |
}; |
|
581 |
||
582 |
||
2475 | 583 |
void ShowPlayerStations(PlayerID player) |
0 | 584 |
{ |
5005
f5086bd3945a
(svn r7022) -Fix [FS#292]: Properly guard against viewing company-sensitive information from
Darkvater
parents:
4938
diff
changeset
|
585 |
if (!IsValidPlayer(player)) return; |
f5086bd3945a
(svn r7022) -Fix [FS#292]: Properly guard against viewing company-sensitive information from
Darkvater
parents:
4938
diff
changeset
|
586 |
|
6202
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
587 |
Window *w = AllocateWindowDescFront(&_player_stations_desc, player); |
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
588 |
if (w == NULL) return; |
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
589 |
|
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
590 |
w->caption_color = (byte)w->window_number; |
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
591 |
w->vscroll.cap = 12; |
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
592 |
w->resize.step_height = 10; |
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
593 |
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
|
594 |
|
a17b8a4e17e8
(svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138
parents:
6260
diff
changeset
|
595 |
/* Add cargo filter buttons */ |
a17b8a4e17e8
(svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138
parents:
6260
diff
changeset
|
596 |
uint num_active = 0; |
a17b8a4e17e8
(svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138
parents:
6260
diff
changeset
|
597 |
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
|
598 |
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
|
599 |
} |
a17b8a4e17e8
(svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138
parents:
6260
diff
changeset
|
600 |
|
a17b8a4e17e8
(svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138
parents:
6260
diff
changeset
|
601 |
w->widget_count += num_active; |
a17b8a4e17e8
(svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138
parents:
6260
diff
changeset
|
602 |
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
|
603 |
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
|
604 |
|
a17b8a4e17e8
(svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138
parents:
6260
diff
changeset
|
605 |
uint i = 0; |
a17b8a4e17e8
(svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138
parents:
6260
diff
changeset
|
606 |
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
|
607 |
if (!GetCargo(c)->IsValid()) continue; |
a17b8a4e17e8
(svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138
parents:
6260
diff
changeset
|
608 |
|
a17b8a4e17e8
(svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138
parents:
6260
diff
changeset
|
609 |
Widget *wi = &w->widget[STATIONLIST_WIDGET_CARGOSTART + i]; |
a17b8a4e17e8
(svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138
parents:
6260
diff
changeset
|
610 |
wi->type = WWT_PANEL; |
a17b8a4e17e8
(svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138
parents:
6260
diff
changeset
|
611 |
wi->display_flags = RESIZE_NONE; |
a17b8a4e17e8
(svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138
parents:
6260
diff
changeset
|
612 |
wi->color = 14; |
a17b8a4e17e8
(svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138
parents:
6260
diff
changeset
|
613 |
wi->left = 89 + i * 14; |
a17b8a4e17e8
(svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138
parents:
6260
diff
changeset
|
614 |
wi->right = wi->left + 13; |
a17b8a4e17e8
(svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138
parents:
6260
diff
changeset
|
615 |
wi->top = 14; |
a17b8a4e17e8
(svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138
parents:
6260
diff
changeset
|
616 |
wi->bottom = 24; |
a17b8a4e17e8
(svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138
parents:
6260
diff
changeset
|
617 |
wi->data = 0; |
a17b8a4e17e8
(svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138
parents:
6260
diff
changeset
|
618 |
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
|
619 |
|
a17b8a4e17e8
(svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138
parents:
6260
diff
changeset
|
620 |
if (HASBIT(_cargo_filter, c)) LowerWindowWidget(w, STATIONLIST_WIDGET_CARGOSTART + i); |
a17b8a4e17e8
(svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138
parents:
6260
diff
changeset
|
621 |
i++; |
a17b8a4e17e8
(svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138
parents:
6260
diff
changeset
|
622 |
} |
a17b8a4e17e8
(svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138
parents:
6260
diff
changeset
|
623 |
|
a17b8a4e17e8
(svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138
parents:
6260
diff
changeset
|
624 |
w->widget[STATIONLIST_WIDGET_NOCARGOWAITING].left += num_active * 14; |
a17b8a4e17e8
(svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138
parents:
6260
diff
changeset
|
625 |
w->widget[STATIONLIST_WIDGET_NOCARGOWAITING].right += num_active * 14; |
a17b8a4e17e8
(svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138
parents:
6260
diff
changeset
|
626 |
w->widget[STATIONLIST_WIDGET_CARGOALL].left += num_active * 14; |
a17b8a4e17e8
(svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138
parents:
6260
diff
changeset
|
627 |
w->widget[STATIONLIST_WIDGET_CARGOALL].right += num_active * 14; |
a17b8a4e17e8
(svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138
parents:
6260
diff
changeset
|
628 |
w->widget[13].left += num_active * 14; |
a17b8a4e17e8
(svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138
parents:
6260
diff
changeset
|
629 |
|
a17b8a4e17e8
(svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138
parents:
6260
diff
changeset
|
630 |
if (num_active > 15) { |
a17b8a4e17e8
(svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138
parents:
6260
diff
changeset
|
631 |
/* 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
|
632 |
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
|
633 |
w->resize.width = w->width; |
a17b8a4e17e8
(svn r9080) -Codechange: dynamically build cargo filter buttons in the station list window.
peter1138
parents:
6260
diff
changeset
|
634 |
} |
0 | 635 |
} |
636 |
||
637 |
static const Widget _station_view_expanded_widgets[] = { |
|
3554
86230061c3e7
(svn r4426) Code Cleaning : replacing tabs with spaces, removing obvious comments, aligning arrays etc...
belugas
parents:
2725
diff
changeset
|
638 |
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
86230061c3e7
(svn r4426) Code Cleaning : replacing tabs with spaces, removing obvious comments, aligning arrays etc...
belugas
parents:
2725
diff
changeset
|
639 |
{ WWT_CAPTION, RESIZE_NONE, 14, 11, 236, 0, 13, STR_300A_0, 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
|
640 |
{ WWT_STICKYBOX, RESIZE_NONE, 14, 237, 248, 0, 13, 0x0, STR_STICKY_BUTTON}, |
4938
0447845fd1b3
(svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents:
4912
diff
changeset
|
641 |
{ WWT_PANEL, RESIZE_NONE, 14, 0, 236, 14, 65, 0x0, STR_NULL}, |
3554
86230061c3e7
(svn r4426) Code Cleaning : replacing tabs with spaces, removing obvious comments, aligning arrays etc...
belugas
parents:
2725
diff
changeset
|
642 |
{ WWT_SCROLLBAR, RESIZE_NONE, 14, 237, 248, 14, 65, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST}, |
86230061c3e7
(svn r4426) Code Cleaning : replacing tabs with spaces, removing obvious comments, aligning arrays etc...
belugas
parents:
2725
diff
changeset
|
643 |
{ WWT_EMPTY, RESIZE_NONE, 0, 0, 0, 0, 0, 0x0, STR_NULL}, |
4938
0447845fd1b3
(svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents:
4912
diff
changeset
|
644 |
{ WWT_PANEL, RESIZE_NONE, 14, 0, 248, 66, 197, 0x0, STR_NULL}, |
3554
86230061c3e7
(svn r4426) Code Cleaning : replacing tabs with spaces, removing obvious comments, aligning arrays etc...
belugas
parents:
2725
diff
changeset
|
645 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 14, 0, 63, 198, 209, STR_00E4_LOCATION, STR_3053_CENTER_MAIN_VIEW_ON_STATION}, |
86230061c3e7
(svn r4426) Code Cleaning : replacing tabs with spaces, removing obvious comments, aligning arrays etc...
belugas
parents:
2725
diff
changeset
|
646 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 14, 64, 128, 198, 209, STR_3033_ACCEPTS, STR_3056_SHOW_LIST_OF_ACCEPTED_CARGO}, |
86230061c3e7
(svn r4426) Code Cleaning : replacing tabs with spaces, removing obvious comments, aligning arrays etc...
belugas
parents:
2725
diff
changeset
|
647 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 14, 129, 192, 198, 209, STR_0130_RENAME, STR_3055_CHANGE_NAME_OF_STATION}, |
86230061c3e7
(svn r4426) Code Cleaning : replacing tabs with spaces, removing obvious comments, aligning arrays etc...
belugas
parents:
2725
diff
changeset
|
648 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 14, 193, 206, 198, 209, STR_TRAIN, STR_SCHEDULED_TRAINS_TIP }, |
86230061c3e7
(svn r4426) Code Cleaning : replacing tabs with spaces, removing obvious comments, aligning arrays etc...
belugas
parents:
2725
diff
changeset
|
649 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 14, 207, 220, 198, 209, STR_LORRY, STR_SCHEDULED_ROAD_VEHICLES_TIP }, |
86230061c3e7
(svn r4426) Code Cleaning : replacing tabs with spaces, removing obvious comments, aligning arrays etc...
belugas
parents:
2725
diff
changeset
|
650 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 14, 221, 234, 198, 209, STR_PLANE, STR_SCHEDULED_AIRCRAFT_TIP }, |
86230061c3e7
(svn r4426) Code Cleaning : replacing tabs with spaces, removing obvious comments, aligning arrays etc...
belugas
parents:
2725
diff
changeset
|
651 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 14, 235, 248, 198, 209, STR_SHIP, STR_SCHEDULED_SHIPS_TIP }, |
176
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
174
diff
changeset
|
652 |
{ WIDGETS_END}, |
0 | 653 |
}; |
654 |
||
655 |
static const Widget _station_view_widgets[] = { |
|
3554
86230061c3e7
(svn r4426) Code Cleaning : replacing tabs with spaces, removing obvious comments, aligning arrays etc...
belugas
parents:
2725
diff
changeset
|
656 |
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
86230061c3e7
(svn r4426) Code Cleaning : replacing tabs with spaces, removing obvious comments, aligning arrays etc...
belugas
parents:
2725
diff
changeset
|
657 |
{ WWT_CAPTION, RESIZE_NONE, 14, 11, 236, 0, 13, STR_300A_0, 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
|
658 |
{ WWT_STICKYBOX, RESIZE_NONE, 14, 237, 248, 0, 13, 0x0, STR_STICKY_BUTTON}, |
4938
0447845fd1b3
(svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents:
4912
diff
changeset
|
659 |
{ WWT_PANEL, RESIZE_NONE, 14, 0, 236, 14, 65, 0x0, STR_NULL}, |
3554
86230061c3e7
(svn r4426) Code Cleaning : replacing tabs with spaces, removing obvious comments, aligning arrays etc...
belugas
parents:
2725
diff
changeset
|
660 |
{ WWT_SCROLLBAR, RESIZE_NONE, 14, 237, 248, 14, 65, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST}, |
4938
0447845fd1b3
(svn r6925) -Codechange: Be more strict with widget distinctions. WWT_PANEL is only plain panel,
Darkvater
parents:
4912
diff
changeset
|
661 |
{ WWT_PANEL, RESIZE_NONE, 14, 0, 248, 66, 97, 0x0, STR_NULL}, |
3554
86230061c3e7
(svn r4426) Code Cleaning : replacing tabs with spaces, removing obvious comments, aligning arrays etc...
belugas
parents:
2725
diff
changeset
|
662 |
{ WWT_EMPTY, RESIZE_NONE, 0, 0, 0, 0, 0, 0x0, STR_NULL}, |
86230061c3e7
(svn r4426) Code Cleaning : replacing tabs with spaces, removing obvious comments, aligning arrays etc...
belugas
parents:
2725
diff
changeset
|
663 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 14, 0, 63, 98, 109, STR_00E4_LOCATION, STR_3053_CENTER_MAIN_VIEW_ON_STATION}, |
86230061c3e7
(svn r4426) Code Cleaning : replacing tabs with spaces, removing obvious comments, aligning arrays etc...
belugas
parents:
2725
diff
changeset
|
664 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 14, 64, 128, 98, 109, STR_3032_RATINGS, STR_3054_SHOW_STATION_RATINGS}, |
86230061c3e7
(svn r4426) Code Cleaning : replacing tabs with spaces, removing obvious comments, aligning arrays etc...
belugas
parents:
2725
diff
changeset
|
665 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 14, 129, 192, 98, 109, STR_0130_RENAME, STR_3055_CHANGE_NAME_OF_STATION}, |
86230061c3e7
(svn r4426) Code Cleaning : replacing tabs with spaces, removing obvious comments, aligning arrays etc...
belugas
parents:
2725
diff
changeset
|
666 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 14, 193, 206, 98, 109, STR_TRAIN, STR_SCHEDULED_TRAINS_TIP }, |
86230061c3e7
(svn r4426) Code Cleaning : replacing tabs with spaces, removing obvious comments, aligning arrays etc...
belugas
parents:
2725
diff
changeset
|
667 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 14, 207, 220, 98, 109, STR_LORRY, STR_SCHEDULED_ROAD_VEHICLES_TIP }, |
86230061c3e7
(svn r4426) Code Cleaning : replacing tabs with spaces, removing obvious comments, aligning arrays etc...
belugas
parents:
2725
diff
changeset
|
668 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 14, 221, 234, 98, 109, STR_PLANE, STR_SCHEDULED_AIRCRAFT_TIP }, |
86230061c3e7
(svn r4426) Code Cleaning : replacing tabs with spaces, removing obvious comments, aligning arrays etc...
belugas
parents:
2725
diff
changeset
|
669 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 14, 235, 248, 98, 109, STR_SHIP, STR_SCHEDULED_SHIPS_TIP }, |
176
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
174
diff
changeset
|
670 |
{ WIDGETS_END}, |
0 | 671 |
}; |
672 |
||
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
|
673 |
|
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
|
674 |
static void DrawCargoIcons(CargoID i, uint waiting, int x, int 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
|
675 |
{ |
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
|
676 |
uint num = min((waiting + 5) / 10, 23); |
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
|
677 |
if (num == 0) return; |
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
|
678 |
|
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
|
679 |
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
|
680 |
SpriteID sprite; |
b52bd4ca10b6
(svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents:
6364
diff
changeset
|
681 |
|
b52bd4ca10b6
(svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents:
6364
diff
changeset
|
682 |
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
|
683 |
/* 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
|
684 |
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
|
685 |
} else { |
b52bd4ca10b6
(svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents:
6364
diff
changeset
|
686 |
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
|
687 |
} |
b52bd4ca10b6
(svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents:
6364
diff
changeset
|
688 |
|
b52bd4ca10b6
(svn r9418) -Codechange: Implement actions 1/2/3 for cargos, callback handler and custom icon sprites
peter1138
parents:
6364
diff
changeset
|
689 |
if (sprite == 0) return; |
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
|
690 |
|
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
|
691 |
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
|
692 |
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
|
693 |
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
|
694 |
} 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
|
695 |
} |
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
|
696 |
|
0 | 697 |
static void DrawStationViewWindow(Window *w) |
698 |
{ |
|
2630 | 699 |
StationID station_id = w->window_number; |
700 |
const Station* st = GetStation(station_id); |
|
701 |
uint num; |
|
0 | 702 |
int x,y; |
703 |
int pos; |
|
704 |
StringID str; |
|
705 |
||
706 |
num = 1; |
|
6350
04b19f551aec
(svn r9388) -Codechange: variable scope and type, and standardify all CargoID loops.
peter1138
parents:
6297
diff
changeset
|
707 |
for (CargoID i = 0; i < NUM_CARGO; i++) { |
2504
5ae89f643cdc
(svn r3030) More work for GB/SB, this time concerning the waiting_acceptance attribute of stations
tron
parents:
2498
diff
changeset
|
708 |
if (GB(st->goods[i].waiting_acceptance, 0, 12) != 0) { |
0 | 709 |
num++; |
2639 | 710 |
if (st->goods[i].enroute_from != station_id) num++; |
0 | 711 |
} |
712 |
} |
|
713 |
SetVScrollCount(w, num); |
|
714 |
||
4709
a81ab800c25b
(svn r6619) -Codechange: Use accessors for disabled_state.
belugas
parents:
4668
diff
changeset
|
715 |
SetWindowWidgetDisabledState(w, 9, st->owner != _local_player); |
a81ab800c25b
(svn r6619) -Codechange: Use accessors for disabled_state.
belugas
parents:
4668
diff
changeset
|
716 |
SetWindowWidgetDisabledState(w, 10, !(st->facilities & FACIL_TRAIN)); |
a81ab800c25b
(svn r6619) -Codechange: Use accessors for disabled_state.
belugas
parents:
4668
diff
changeset
|
717 |
SetWindowWidgetDisabledState(w, 11, !(st->facilities & FACIL_TRUCK_STOP) && !(st->facilities & FACIL_BUS_STOP)); |
a81ab800c25b
(svn r6619) -Codechange: Use accessors for disabled_state.
belugas
parents:
4668
diff
changeset
|
718 |
SetWindowWidgetDisabledState(w, 12, !(st->facilities & FACIL_AIRPORT)); |
a81ab800c25b
(svn r6619) -Codechange: Use accessors for disabled_state.
belugas
parents:
4668
diff
changeset
|
719 |
SetWindowWidgetDisabledState(w, 13, !(st->facilities & FACIL_DOCK)); |
588 | 720 |
|
534
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
721 |
SetDParam(0, st->index); |
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
722 |
SetDParam(1, st->facilities); |
0 | 723 |
DrawWindowWidgets(w); |
724 |
||
725 |
x = 2; |
|
726 |
y = 15; |
|
727 |
pos = w->vscroll.pos; |
|
728 |
||
729 |
if (--pos < 0) { |
|
730 |
str = STR_00D0_NOTHING; |
|
6350
04b19f551aec
(svn r9388) -Codechange: variable scope and type, and standardify all CargoID loops.
peter1138
parents:
6297
diff
changeset
|
731 |
for (CargoID i = 0; i < NUM_CARGO; i++) { |
2504
5ae89f643cdc
(svn r3030) More work for GB/SB, this time concerning the waiting_acceptance attribute of stations
tron
parents:
2498
diff
changeset
|
732 |
if (GB(st->goods[i].waiting_acceptance, 0, 12) != 0) str = STR_EMPTY; |
2639 | 733 |
} |
534
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
734 |
SetDParam(0, str); |
0 | 735 |
DrawString(x, y, STR_0008_WAITING, 0); |
736 |
y += 10; |
|
737 |
} |
|
738 |
||
6350
04b19f551aec
(svn r9388) -Codechange: variable scope and type, and standardify all CargoID loops.
peter1138
parents:
6297
diff
changeset
|
739 |
for (CargoID i = 0; i < NUM_CARGO && pos > -5; i++) { |
2504
5ae89f643cdc
(svn r3030) More work for GB/SB, this time concerning the waiting_acceptance attribute of stations
tron
parents:
2498
diff
changeset
|
740 |
uint waiting = GB(st->goods[i].waiting_acceptance, 0, 12); |
2639 | 741 |
if (waiting == 0) continue; |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
742 |
|
6202
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
743 |
if (st->goods[i].enroute_from == station_id) { |
0 | 744 |
if (--pos < 0) { |
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
|
745 |
DrawCargoIcons(i, waiting, x, y); |
534
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
746 |
SetDParam(1, waiting); |
4896
f86350aaaaa5
(svn r6855) - Codechange: When displaying a "quantity of cargo" string, use the {CARGO} command and supply the cargo type and quantity, instead of manually looking up the cargo type's string.
peter1138
parents:
4727
diff
changeset
|
747 |
SetDParam(0, i); |
0 | 748 |
DrawStringRightAligned(x + 234, y, STR_0009, 0); |
749 |
y += 10; |
|
750 |
} |
|
751 |
} else { |
|
752 |
/* enroute */ |
|
753 |
if (--pos < 0) { |
|
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
|
754 |
DrawCargoIcons(i, waiting, x, y); |
534
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
755 |
SetDParam(1, waiting); |
4896
f86350aaaaa5
(svn r6855) - Codechange: When displaying a "quantity of cargo" string, use the {CARGO} command and supply the cargo type and quantity, instead of manually looking up the cargo type's string.
peter1138
parents:
4727
diff
changeset
|
756 |
SetDParam(0, i); |
0 | 757 |
DrawStringRightAligned(x + 234, y, STR_000A_EN_ROUTE_FROM, 0); |
758 |
y += 10; |
|
759 |
} |
|
760 |
||
761 |
if (pos > -5 && --pos < 0) { |
|
534
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
762 |
SetDParam(0, st->goods[i].enroute_from); |
0 | 763 |
DrawStringRightAligned(x + 234, y, STR_000B, 0); |
764 |
y += 10; |
|
765 |
} |
|
766 |
} |
|
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
|
767 |
} |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
768 |
|
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
817
diff
changeset
|
769 |
if (IsWindowOfPrototype(w, _station_view_widgets)) { |
1556
d7c2d5289be9
(svn r2060) Clean up some string construction and remove now unused macro
tron
parents:
1553
diff
changeset
|
770 |
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
|
771 |
bool first = true; |
1329 | 772 |
|
1553
cf513e731bd3
(svn r2057) Add InlineString() to make _userstring construction a bit cleaner.
tron
parents:
1474
diff
changeset
|
773 |
b = InlineString(b, STR_000C_ACCEPTS); |
0 | 774 |
|
6350
04b19f551aec
(svn r9388) -Codechange: variable scope and type, and standardify all CargoID loops.
peter1138
parents:
6297
diff
changeset
|
775 |
for (CargoID i = 0; i < NUM_CARGO; i++) { |
1556
d7c2d5289be9
(svn r2060) Clean up some string construction and remove now unused macro
tron
parents:
1553
diff
changeset
|
776 |
if (b >= endof(_userstring) - 5 - 1) break; |
0 | 777 |
if (st->goods[i].waiting_acceptance & 0x8000) { |
5038
12fd4db0cdb5
(svn r7080) -Codechange: Remove negative array indexes, and only add ", " when needed, when building station acceptance lists.
peter1138
parents:
5005
diff
changeset
|
778 |
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
|
779 |
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
|
780 |
} else { |
12fd4db0cdb5
(svn r7080) -Codechange: Remove negative array indexes, and only add ", " when needed, when building station acceptance lists.
peter1138
parents:
5005
diff
changeset
|
781 |
/* 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
|
782 |
*b++ = ','; |
12fd4db0cdb5
(svn r7080) -Codechange: Remove negative array indexes, and only add ", " when needed, when building station acceptance lists.
peter1138
parents:
5005
diff
changeset
|
783 |
*b++ = ' '; |
12fd4db0cdb5
(svn r7080) -Codechange: Remove negative array indexes, and only add ", " when needed, when building station acceptance lists.
peter1138
parents:
5005
diff
changeset
|
784 |
} |
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
|
785 |
b = InlineString(b, GetCargo(i)->name); |
0 | 786 |
} |
787 |
} |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
788 |
|
5038
12fd4db0cdb5
(svn r7080) -Codechange: Remove negative array indexes, and only add ", " when needed, when building station acceptance lists.
peter1138
parents:
5005
diff
changeset
|
789 |
/* 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
|
790 |
if (first) b = InlineString(b, STR_00D0_NOTHING); |
0 | 791 |
|
5038
12fd4db0cdb5
(svn r7080) -Codechange: Remove negative array indexes, and only add ", " when needed, when building station acceptance lists.
peter1138
parents:
5005
diff
changeset
|
792 |
*b = '\0'; |
0 | 793 |
DrawStringMultiLine(2, 67, STR_SPEC_USERSTRING, 245); |
794 |
} else { |
|
795 |
DrawString(2, 67, STR_3034_LOCAL_RATING_OF_TRANSPORT, 0); |
|
796 |
||
797 |
y = 77; |
|
6350
04b19f551aec
(svn r9388) -Codechange: variable scope and type, and standardify all CargoID loops.
peter1138
parents:
6297
diff
changeset
|
798 |
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
|
799 |
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
|
800 |
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
|
801 |
|
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
|
802 |
const GoodsEntry *ge = &st->goods[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
|
803 |
if (ge->enroute_from == INVALID_STATION) 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
|
804 |
|
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
|
805 |
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
|
806 |
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
|
807 |
SetDParam(1, STR_3035_APPALLING + (ge->rating >> 5)); |
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
|
808 |
DrawString(8, y, STR_303D, 0); |
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
|
809 |
y += 10; |
0 | 810 |
} |
811 |
} |
|
812 |
} |
|
813 |
||
814 |
||
815 |
static void StationViewWndProc(Window *w, WindowEvent *e) |
|
816 |
{ |
|
2639 | 817 |
switch (e->event) { |
6202
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
818 |
case WE_PAINT: |
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
819 |
DrawStationViewWindow(w); |
0 | 820 |
break; |
821 |
||
6202
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
822 |
case WE_CLICK: |
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
823 |
switch (e->we.click.widget) { |
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
824 |
case 7: |
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
825 |
ScrollMainWindowToTile(GetStation(w->window_number)->xy); |
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
826 |
break; |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
827 |
|
6202
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
828 |
case 8: |
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
829 |
SetWindowDirty(w); |
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
830 |
|
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
831 |
/* toggle height/widget set */ |
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
832 |
if (IsWindowOfPrototype(w, _station_view_expanded_widgets)) { |
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
833 |
AssignWidgetToWindow(w, _station_view_widgets); |
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
834 |
w->height = 110; |
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
835 |
} else { |
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
836 |
AssignWidgetToWindow(w, _station_view_expanded_widgets); |
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
837 |
w->height = 210; |
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
838 |
} |
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
839 |
|
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
840 |
SetWindowDirty(w); |
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
841 |
break; |
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
842 |
|
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
843 |
case 9: |
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
844 |
SetDParam(0, w->window_number); |
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
845 |
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
|
846 |
break; |
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
847 |
|
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
848 |
case 10: { /* Show a list of scheduled trains to this station */ |
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
849 |
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
|
850 |
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
|
851 |
break; |
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
852 |
} |
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
853 |
|
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
854 |
case 11: { /* Show a list of scheduled road-vehicles to this station */ |
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
855 |
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
|
856 |
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
|
857 |
break; |
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
858 |
} |
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
859 |
|
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
860 |
case 12: { /* Show a list of scheduled aircraft to this station */ |
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
861 |
const Station *st = GetStation(w->window_number); |
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
862 |
/* 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
|
863 |
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
|
864 |
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
|
865 |
break; |
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
866 |
} |
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
867 |
|
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
868 |
case 13: { /* Show a list of scheduled ships to this station */ |
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
869 |
const Station *st = GetStation(w->window_number); |
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
870 |
/* 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
|
871 |
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
|
872 |
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
|
873 |
break; |
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
874 |
} |
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
817
diff
changeset
|
875 |
} |
0 | 876 |
break; |
877 |
||
6202
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
878 |
case WE_ON_EDIT_TEXT: |
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
879 |
if (e->we.edittext.str[0] != '\0') { |
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
880 |
_cmd_text = e->we.edittext.str; |
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
881 |
DoCommandP(0, w->window_number, 0, NULL, |
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
882 |
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
|
883 |
} |
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
884 |
break; |
588 | 885 |
|
6202
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
886 |
case WE_DESTROY: { |
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
887 |
WindowNumber wno = |
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
888 |
(w->window_number << 16) | GetStation(w->window_number)->owner; |
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
889 |
|
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
890 |
DeleteWindowById(WC_TRAINS_LIST, wno); |
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
891 |
DeleteWindowById(WC_ROADVEH_LIST, wno); |
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
892 |
DeleteWindowById(WC_SHIPS_LIST, wno); |
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
893 |
DeleteWindowById(WC_AIRCRAFT_LIST, wno); |
588 | 894 |
break; |
895 |
} |
|
0 | 896 |
} |
897 |
} |
|
898 |
||
899 |
||
900 |
static const WindowDesc _station_view_desc = { |
|
5070
7f5b13b7e728
(svn r7128) -Codechange: Replace magic numbers by magic enums (windowdesc positioning WDP_AUTO = -1)
Darkvater
parents:
5038
diff
changeset
|
901 |
WDP_AUTO, WDP_AUTO, 249, 110, |
5893
7e431a4abebb
(svn r8511) -Codechange: make WindowClass an enumerated value.
rubidium
parents:
5745
diff
changeset
|
902 |
WC_STATION_VIEW, WC_NONE, |
758
423ae0bcba07
(svn r1214) -Feature: Stickified Industries (list & window), Smallmaps (all three), Stations (list & window) and Towns (list & window). I hope I didn't forget to update a widget somewhere :O
darkvater
parents:
603
diff
changeset
|
903 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_STICKY_BUTTON, |
0 | 904 |
_station_view_widgets, |
905 |
StationViewWndProc |
|
906 |
}; |
|
907 |
||
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
|
908 |
void ShowStationViewWindow(StationID station) |
0 | 909 |
{ |
6202
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
910 |
Window *w = AllocateWindowDescFront(&_station_view_desc, station); |
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
911 |
if (w == NULL) return; |
0 | 912 |
|
6202
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
913 |
PlayerID owner = GetStation(w->window_number)->owner; |
4ec72ee98c7d
(svn r8988) -Fix: Indenting, variable scope, variable type and minor duffage
peter1138
parents:
6122
diff
changeset
|
914 |
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
|
915 |
w->vscroll.cap = 5; |
0 | 916 |
} |