author | tron |
Sun, 17 Jul 2005 20:14:58 +0000 | |
changeset 2116 | 23031555ff54 |
parent 2084 | 65639f898a50 |
child 2159 | f6284cf5fab0 |
permissions | -rw-r--r-- |
0 | 1 |
#include "stdafx.h" |
1891
862800791170
(svn r2397) - CodeChange: rename all "ttd" files to "openttd" files.
Darkvater
parents:
1820
diff
changeset
|
2 |
#include "openttd.h" |
1299
39c06aba09aa
(svn r1803) Move debugging stuff into files of it's own
tron
parents:
1272
diff
changeset
|
3 |
#include "debug.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
|
4 |
#include "strings.h" |
507
04b5403aaf6b
(svn r815) Include strings.h only in the files which need it.
tron
parents:
487
diff
changeset
|
5 |
#include "table/strings.h" |
0 | 6 |
#include "window.h" |
7 |
#include "gui.h" |
|
8 |
#include "station.h" |
|
9 |
#include "gfx.h" |
|
10 |
#include "player.h" |
|
11 |
#include "town.h" |
|
12 |
#include "command.h" |
|
13 |
||
14 |
static void StationsWndShowStationRating(int x, int y, int type, uint acceptance, int rating) |
|
15 |
{ |
|
16 |
static const byte _rating_colors[NUM_CARGO] = {152,32,15,174,208,194,191,55,184,10,191,48}; |
|
17 |
int color = _rating_colors[type]; |
|
18 |
uint w; |
|
19 |
||
20 |
if (acceptance > 575) |
|
21 |
acceptance = 575; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
22 |
|
0 | 23 |
acceptance = (acceptance + 7) >> 3; |
24 |
||
25 |
/* draw cargo */ |
|
26 |
if ( (w=acceptance>>3) != 0) { |
|
27 |
GfxFillRect(x, y, x+w-1, y+6, color); |
|
28 |
x += w; |
|
29 |
} |
|
30 |
||
31 |
if ( (w=acceptance&7) != 0) { |
|
32 |
if (w==7) w--; |
|
33 |
GfxFillRect(x, y+(w-1), x, y+6, color); |
|
34 |
} |
|
35 |
||
36 |
x -= (acceptance>>3); |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
37 |
|
0 | 38 |
DrawString(x+1, y, _cargoc.names_short[type], 0x10); |
39 |
||
40 |
/* draw green/red ratings bar */ |
|
41 |
GfxFillRect(x+1, y+8, x+7, y+8, 0xB8); |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
42 |
|
0 | 43 |
rating = (rating >> 5); |
44 |
||
45 |
if (rating != 0) { |
|
46 |
GfxFillRect(x+1, y+8, x+rating, y+8, 0xD0); |
|
47 |
} |
|
48 |
} |
|
49 |
||
50 |
static uint16 _num_station_sort[MAX_PLAYERS]; |
|
51 |
||
52 |
static char _bufcache[64]; |
|
53 |
static uint16 _last_station_idx; |
|
54 |
||
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
|
55 |
static int CDECL StationNameSorter(const void *a, const void *b) |
0 | 56 |
{ |
57 |
char buf1[64]; |
|
2070
47b1f29d4671
(svn r2580) Change: Added {INDUSTRY} command for printing industry names instead of the old {TOWN} {STRING} way.
ludde
parents:
2026
diff
changeset
|
58 |
int32 argv[1]; |
222
b88456001397
(svn r223) -Fix: Const correctness and miscellaneous fixes. Thank you Tron for your diligent fixing of warnings (and some possibly bugs) (Tron)
darkvater
parents:
193
diff
changeset
|
59 |
const SortStruct *cmp1 = (const SortStruct*)a; |
b88456001397
(svn r223) -Fix: Const correctness and miscellaneous fixes. Thank you Tron for your diligent fixing of warnings (and some possibly bugs) (Tron)
darkvater
parents:
193
diff
changeset
|
60 |
const SortStruct *cmp2 = (const SortStruct*)b; |
0 | 61 |
|
2070
47b1f29d4671
(svn r2580) Change: Added {INDUSTRY} command for printing industry names instead of the old {TOWN} {STRING} way.
ludde
parents:
2026
diff
changeset
|
62 |
argv[0] = cmp1->index; |
47b1f29d4671
(svn r2580) Change: Added {INDUSTRY} command for printing industry names instead of the old {TOWN} {STRING} way.
ludde
parents:
2026
diff
changeset
|
63 |
GetStringWithArgs(buf1, STR_STATION, argv); |
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
|
64 |
|
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
|
65 |
if ( cmp2->index != _last_station_idx) { |
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
|
66 |
_last_station_idx = cmp2->index; |
2070
47b1f29d4671
(svn r2580) Change: Added {INDUSTRY} command for printing industry names instead of the old {TOWN} {STRING} way.
ludde
parents:
2026
diff
changeset
|
67 |
argv[0] = cmp2->index; |
47b1f29d4671
(svn r2580) Change: Added {INDUSTRY} command for printing industry names instead of the old {TOWN} {STRING} way.
ludde
parents:
2026
diff
changeset
|
68 |
GetStringWithArgs(_bufcache, STR_STATION, argv); |
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
|
69 |
} |
0 | 70 |
|
2026 | 71 |
return strcmp(buf1, _bufcache); // sort by name |
0 | 72 |
} |
73 |
||
1093
4fdc46eaf423
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
919
diff
changeset
|
74 |
static void GlobalSortStationList(void) |
0 | 75 |
{ |
243
9a40daa560ae
(svn r244) -Fix: Stations were not sorted for non-player-0 players
darkvater
parents:
222
diff
changeset
|
76 |
const Station *st; |
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
|
77 |
uint32 n = 0; |
0 | 78 |
uint16 *i; |
243
9a40daa560ae
(svn r244) -Fix: Stations were not sorted for non-player-0 players
darkvater
parents:
222
diff
changeset
|
79 |
|
9a40daa560ae
(svn r244) -Fix: Stations were not sorted for non-player-0 players
darkvater
parents:
222
diff
changeset
|
80 |
// reset #-of stations to 0 because ++ is used for value-assignment |
1474
a26a21fa10ef
(svn r1978) - Fix: Plug some memleaks; thanks Valgrind
Darkvater
parents:
1341
diff
changeset
|
81 |
memset(_num_station_sort, 0, sizeof(_num_station_sort)); |
919
544f374ee392
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
893
diff
changeset
|
82 |
|
544f374ee392
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
893
diff
changeset
|
83 |
/* Create array for sorting */ |
1272
9aa073c64fc7
(svn r1776) -Add: Dynamic stations. You can now have up to 64k of stations
truelight
parents:
1266
diff
changeset
|
84 |
_station_sort = realloc(_station_sort, GetStationPoolSize() * sizeof(_station_sort[0])); |
919
544f374ee392
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
893
diff
changeset
|
85 |
if (_station_sort == NULL) |
544f374ee392
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
893
diff
changeset
|
86 |
error("Could not allocate memory for the station-sorting-list"); |
0 | 87 |
|
88 |
FOR_ALL_STATIONS(st) { |
|
89 |
if(st->xy && st->owner != OWNER_NONE) { |
|
90 |
_station_sort[n].index = st->index; |
|
91 |
_station_sort[n++].owner = st->owner; |
|
2026 | 92 |
_num_station_sort[st->owner]++; // add number of stations of player |
0 | 93 |
} |
94 |
} |
|
95 |
||
243
9a40daa560ae
(svn r244) -Fix: Stations were not sorted for non-player-0 players
darkvater
parents:
222
diff
changeset
|
96 |
// create cumulative station-ownership |
0 | 97 |
// stations are stored as a cummulative index, eg 25, 41, 43. This means |
98 |
// Player0: 25; Player1: (41-25) 16; Player2: (43-41) 2 |
|
99 |
for (i = &_num_station_sort[1]; i != endof(_num_station_sort); i++) {*i += *(i-1);} |
|
100 |
||
243
9a40daa560ae
(svn r244) -Fix: Stations were not sorted for non-player-0 players
darkvater
parents:
222
diff
changeset
|
101 |
qsort(_station_sort, n, sizeof(_station_sort[0]), GeneralOwnerSorter); // sort by owner |
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
|
102 |
|
243
9a40daa560ae
(svn r244) -Fix: Stations were not sorted for non-player-0 players
darkvater
parents:
222
diff
changeset
|
103 |
// since indexes are messed up after adding/removing a station, mark all lists dirty |
9a40daa560ae
(svn r244) -Fix: Stations were not sorted for non-player-0 players
darkvater
parents:
222
diff
changeset
|
104 |
memset(_station_sort_dirty, true, sizeof(_station_sort_dirty)); |
9a40daa560ae
(svn r244) -Fix: Stations were not sorted for non-player-0 players
darkvater
parents:
222
diff
changeset
|
105 |
_global_station_sort_dirty = false; |
9a40daa560ae
(svn r244) -Fix: Stations were not sorted for non-player-0 players
darkvater
parents:
222
diff
changeset
|
106 |
|
9a40daa560ae
(svn r244) -Fix: Stations were not sorted for non-player-0 players
darkvater
parents:
222
diff
changeset
|
107 |
DEBUG(misc, 1) ("Resorting global station list..."); |
9a40daa560ae
(svn r244) -Fix: Stations were not sorted for non-player-0 players
darkvater
parents:
222
diff
changeset
|
108 |
} |
9a40daa560ae
(svn r244) -Fix: Stations were not sorted for non-player-0 players
darkvater
parents:
222
diff
changeset
|
109 |
|
9a40daa560ae
(svn r244) -Fix: Stations were not sorted for non-player-0 players
darkvater
parents:
222
diff
changeset
|
110 |
static void MakeSortedStationList(byte owner) |
9a40daa560ae
(svn r244) -Fix: Stations were not sorted for non-player-0 players
darkvater
parents:
222
diff
changeset
|
111 |
{ |
9a40daa560ae
(svn r244) -Fix: Stations were not sorted for non-player-0 players
darkvater
parents:
222
diff
changeset
|
112 |
SortStruct *firstelement; |
9a40daa560ae
(svn r244) -Fix: Stations were not sorted for non-player-0 players
darkvater
parents:
222
diff
changeset
|
113 |
uint32 n = 0; |
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
|
114 |
|
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
|
115 |
if (owner == 0) { // first element starts at 0th element and has n elements as described above |
2026 | 116 |
firstelement = &_station_sort[0]; |
117 |
n = _num_station_sort[0]; |
|
118 |
} else { // nth element starts at the end of the previous one, and has n elements as described above |
|
119 |
firstelement = &_station_sort[_num_station_sort[owner - 1]]; |
|
120 |
n = _num_station_sort[owner] - _num_station_sort[owner - 1]; |
|
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
|
121 |
} |
bd79fb899824
(svn r175) -Fix: [1023771] inconsistent/missing stations in station list. Forgot to change owner-sort after changing function.
darkvater
parents:
164
diff
changeset
|
122 |
|
243
9a40daa560ae
(svn r244) -Fix: Stations were not sorted for non-player-0 players
darkvater
parents:
222
diff
changeset
|
123 |
_last_station_idx = 0; // used for "cache" in namesorting |
9a40daa560ae
(svn r244) -Fix: Stations were not sorted for non-player-0 players
darkvater
parents:
222
diff
changeset
|
124 |
qsort(firstelement, n, sizeof(_station_sort[0]), StationNameSorter); // sort by name |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
125 |
|
243
9a40daa560ae
(svn r244) -Fix: Stations were not sorted for non-player-0 players
darkvater
parents:
222
diff
changeset
|
126 |
_station_sort_dirty[owner] = false; |
9a40daa560ae
(svn r244) -Fix: Stations were not sorted for non-player-0 players
darkvater
parents:
222
diff
changeset
|
127 |
|
9a40daa560ae
(svn r244) -Fix: Stations were not sorted for non-player-0 players
darkvater
parents:
222
diff
changeset
|
128 |
DEBUG(misc, 1) ("Resorting Stations list player %d...", owner+1); |
0 | 129 |
} |
130 |
||
131 |
static void PlayerStationsWndProc(Window *w, WindowEvent *e) |
|
132 |
{ |
|
133 |
switch(e->event) { |
|
134 |
case WE_PAINT: { |
|
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
|
135 |
uint32 i; |
bd79fb899824
(svn r175) -Fix: [1023771] inconsistent/missing stations in station list. Forgot to change owner-sort after changing function.
darkvater
parents:
164
diff
changeset
|
136 |
const byte window_number = (byte)w->window_number; |
bd79fb899824
(svn r175) -Fix: [1023771] inconsistent/missing stations in station list. Forgot to change owner-sort after changing function.
darkvater
parents:
164
diff
changeset
|
137 |
|
243
9a40daa560ae
(svn r244) -Fix: Stations were not sorted for non-player-0 players
darkvater
parents:
222
diff
changeset
|
138 |
// resort station window if stations have been added/removed |
9a40daa560ae
(svn r244) -Fix: Stations were not sorted for non-player-0 players
darkvater
parents:
222
diff
changeset
|
139 |
if (_global_station_sort_dirty) |
9a40daa560ae
(svn r244) -Fix: Stations were not sorted for non-player-0 players
darkvater
parents:
222
diff
changeset
|
140 |
GlobalSortStationList(); |
9a40daa560ae
(svn r244) -Fix: Stations were not sorted for non-player-0 players
darkvater
parents:
222
diff
changeset
|
141 |
|
9a40daa560ae
(svn r244) -Fix: Stations were not sorted for non-player-0 players
darkvater
parents:
222
diff
changeset
|
142 |
if (_station_sort_dirty[window_number]) { // resort in case of a station rename. |
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
|
143 |
MakeSortedStationList(window_number); |
0 | 144 |
} |
145 |
||
146 |
// stations are stored as a cummulative index, eg 25, 41, 43. This means |
|
147 |
// Player0: 25; Player1: (41-25) 16; Player2: (43-41) 2 stations |
|
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
|
148 |
i = (window_number == 0) ? 0 : _num_station_sort[window_number-1]; |
bd79fb899824
(svn r175) -Fix: [1023771] inconsistent/missing stations in station list. Forgot to change owner-sort after changing function.
darkvater
parents:
164
diff
changeset
|
149 |
SetVScrollCount(w, _num_station_sort[window_number] - i); |
0 | 150 |
|
151 |
/* draw widgets, with player's name in the caption */ |
|
152 |
{ |
|
1962
8254df1b359b
(svn r2468) -Codechange: Got rid of DEREF_PLAYER and replaced it by GetPlayer
celestar
parents:
1891
diff
changeset
|
153 |
Player *p = GetPlayer(window_number); |
534
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
154 |
SetDParam(0, p->name_1); |
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
155 |
SetDParam(1, p->name_2); |
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
156 |
SetDParam(2, w->vscroll.count); |
0 | 157 |
DrawWindowWidgets(w); |
158 |
} |
|
159 |
||
160 |
{ |
|
161 |
byte p = 0; |
|
162 |
Station *st; |
|
163 |
int x,xb = 2; |
|
2026 | 164 |
int y = 16; // offset from top of widget |
0 | 165 |
int j; |
166 |
||
2026 | 167 |
if (w->vscroll.count == 0) { // player has no stations |
0 | 168 |
DrawString(xb, y, STR_304A_NONE, 0); |
169 |
return; |
|
170 |
} |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
171 |
|
2026 | 172 |
i += w->vscroll.pos; // offset from sorted station list of current player |
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
|
173 |
assert(i < _num_station_sort[window_number]); // at least one station must exist |
0 | 174 |
|
2026 | 175 |
while (i < _num_station_sort[window_number]) { // do until max number of stations of owner |
919
544f374ee392
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
893
diff
changeset
|
176 |
st = GetStation(_station_sort[i].index); |
0 | 177 |
|
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
|
178 |
assert(st->xy && st->owner == window_number); |
bd79fb899824
(svn r175) -Fix: [1023771] inconsistent/missing stations in station list. Forgot to change owner-sort after changing function.
darkvater
parents:
164
diff
changeset
|
179 |
|
534
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
180 |
SetDParam(0, st->index); |
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
181 |
SetDParam(1, st->facilities); |
0 | 182 |
x = DrawString(xb, y, STR_3049_0, 0) + 5; |
183 |
||
184 |
// show cargo waiting and station ratings |
|
185 |
for(j=0; j!=NUM_CARGO; j++) { |
|
186 |
int acc = (st->goods[j].waiting_acceptance & 0xFFF); |
|
187 |
if (acc != 0) { |
|
188 |
StationsWndShowStationRating(x, y, j, acc, st->goods[j].rating); |
|
189 |
x += 10; |
|
190 |
} |
|
191 |
} |
|
192 |
y += 10; |
|
2026 | 193 |
i++; // next station |
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
|
194 |
if (++p == w->vscroll.cap) { break;} // max number of stations in 1 window |
0 | 195 |
} |
196 |
} |
|
197 |
} break; |
|
198 |
case WE_CLICK: { |
|
199 |
switch(e->click.widget) { |
|
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
|
200 |
case 3: { |
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
|
201 |
uint32 id_v = (e->click.pt.y - 15) / 10; |
0 | 202 |
|
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
|
203 |
if (id_v >= w->vscroll.cap) { return;} // click out of bounds |
bd79fb899824
(svn r175) -Fix: [1023771] inconsistent/missing stations in station list. Forgot to change owner-sort after changing function.
darkvater
parents:
164
diff
changeset
|
204 |
|
bd79fb899824
(svn r175) -Fix: [1023771] inconsistent/missing stations in station list. Forgot to change owner-sort after changing function.
darkvater
parents:
164
diff
changeset
|
205 |
id_v += w->vscroll.pos; |
bd79fb899824
(svn r175) -Fix: [1023771] inconsistent/missing stations in station list. Forgot to change owner-sort after changing function.
darkvater
parents:
164
diff
changeset
|
206 |
|
bd79fb899824
(svn r175) -Fix: [1023771] inconsistent/missing stations in station list. Forgot to change owner-sort after changing function.
darkvater
parents:
164
diff
changeset
|
207 |
{ |
bd79fb899824
(svn r175) -Fix: [1023771] inconsistent/missing stations in station list. Forgot to change owner-sort after changing function.
darkvater
parents:
164
diff
changeset
|
208 |
const byte owner = (byte)w->window_number; |
bd79fb899824
(svn r175) -Fix: [1023771] inconsistent/missing stations in station list. Forgot to change owner-sort after changing function.
darkvater
parents:
164
diff
changeset
|
209 |
Station *st; |
2026 | 210 |
id_v += (owner == 0) ? 0 : _num_station_sort[owner - 1]; // first element in list |
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
|
211 |
|
bd79fb899824
(svn r175) -Fix: [1023771] inconsistent/missing stations in station list. Forgot to change owner-sort after changing function.
darkvater
parents:
164
diff
changeset
|
212 |
if (id_v >= _num_station_sort[owner]) { return;} // click out of station bound |
bd79fb899824
(svn r175) -Fix: [1023771] inconsistent/missing stations in station list. Forgot to change owner-sort after changing function.
darkvater
parents:
164
diff
changeset
|
213 |
|
919
544f374ee392
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
893
diff
changeset
|
214 |
st = GetStation(_station_sort[id_v].index); |
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
|
215 |
|
bd79fb899824
(svn r175) -Fix: [1023771] inconsistent/missing stations in station list. Forgot to change owner-sort after changing function.
darkvater
parents:
164
diff
changeset
|
216 |
assert(st->xy && st->owner == owner); |
bd79fb899824
(svn r175) -Fix: [1023771] inconsistent/missing stations in station list. Forgot to change owner-sort after changing function.
darkvater
parents:
164
diff
changeset
|
217 |
|
bd79fb899824
(svn r175) -Fix: [1023771] inconsistent/missing stations in station list. Forgot to change owner-sort after changing function.
darkvater
parents:
164
diff
changeset
|
218 |
ScrollMainWindowToTile(st->xy); |
0 | 219 |
} |
220 |
} break; |
|
221 |
} |
|
222 |
} break; |
|
223 |
||
224 |
case WE_4: |
|
225 |
WP(w,plstations_d).refresh_counter++; |
|
226 |
if (WP(w,plstations_d).refresh_counter==5) { |
|
227 |
WP(w,plstations_d).refresh_counter = 0; |
|
228 |
SetWindowDirty(w); |
|
229 |
} |
|
230 |
break; |
|
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
817
diff
changeset
|
231 |
|
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
817
diff
changeset
|
232 |
case WE_RESIZE: |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
817
diff
changeset
|
233 |
w->vscroll.cap += e->sizing.diff.y / 10; |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
817
diff
changeset
|
234 |
break; |
0 | 235 |
} |
236 |
} |
|
237 |
||
238 |
static const Widget _player_stations_widgets[] = { |
|
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
817
diff
changeset
|
239 |
{ WWT_CLOSEBOX, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
817
diff
changeset
|
240 |
{ WWT_CAPTION, RESIZE_RIGHT, 14, 11, 345, 0, 13, STR_3048_STATIONS, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
817
diff
changeset
|
241 |
{ WWT_STICKYBOX, RESIZE_LR, 14, 346, 357, 0, 13, 0x0, STR_STICKY_BUTTON}, |
893
f4698309dec7
(svn r1379) -Fix: various GUI glitches. Added default sizes to various widgets. Sticky/Resize- and Scrollbar must be 11 pixels wide, Horizontal scrollbar 11 pixels high, caption must be 13 pixels. I hope I didn't forget any widgets, the game will assert for that so report them to me!
darkvater
parents:
867
diff
changeset
|
242 |
{ WWT_PANEL, RESIZE_RB, 14, 0, 345, 14, 137, 0x0, STR_3057_STATION_NAMES_CLICK_ON}, |
f4698309dec7
(svn r1379) -Fix: various GUI glitches. Added default sizes to various widgets. Sticky/Resize- and Scrollbar must be 11 pixels wide, Horizontal scrollbar 11 pixels high, caption must be 13 pixels. I hope I didn't forget any widgets, the game will assert for that so report them to me!
darkvater
parents:
867
diff
changeset
|
243 |
{ WWT_SCROLLBAR, RESIZE_LRB, 14, 346, 357, 14, 125, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST}, |
f4698309dec7
(svn r1379) -Fix: various GUI glitches. Added default sizes to various widgets. Sticky/Resize- and Scrollbar must be 11 pixels wide, Horizontal scrollbar 11 pixels high, caption must be 13 pixels. I hope I didn't forget any widgets, the game will assert for that so report them to me!
darkvater
parents:
867
diff
changeset
|
244 |
{ WWT_RESIZEBOX, RESIZE_LRTB, 14, 346, 357, 126, 137, 0x0, STR_RESIZE_BUTTON}, |
176
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
174
diff
changeset
|
245 |
{ WIDGETS_END}, |
0 | 246 |
}; |
247 |
||
248 |
static const WindowDesc _player_stations_desc = { |
|
249 |
-1, -1, 358, 138, |
|
250 |
WC_STATION_LIST,0, |
|
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
817
diff
changeset
|
251 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_STICKY_BUTTON | WDF_RESIZABLE, |
0 | 252 |
_player_stations_widgets, |
253 |
PlayerStationsWndProc |
|
254 |
}; |
|
255 |
||
256 |
||
257 |
void ShowPlayerStations(int player) |
|
258 |
{ |
|
259 |
Window *w; |
|
260 |
||
261 |
w = AllocateWindowDescFront(&_player_stations_desc, player); |
|
262 |
if (w) { |
|
263 |
w->caption_color = (byte)w->window_number; |
|
264 |
w->vscroll.cap = 12; |
|
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
817
diff
changeset
|
265 |
w->resize.step_height = 10; |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
817
diff
changeset
|
266 |
w->resize.height = w->height - 10 * 7; // minimum if 5 in the list |
0 | 267 |
} |
268 |
} |
|
269 |
||
270 |
static const Widget _station_view_expanded_widgets[] = { |
|
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
817
diff
changeset
|
271 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
817
diff
changeset
|
272 |
{ WWT_CAPTION, RESIZE_NONE, 14, 11, 236, 0, 13, STR_300A_0, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
817
diff
changeset
|
273 |
{ WWT_STICKYBOX, RESIZE_NONE, 14, 237, 248, 0, 13, 0x0, STR_STICKY_BUTTON}, |
893
f4698309dec7
(svn r1379) -Fix: various GUI glitches. Added default sizes to various widgets. Sticky/Resize- and Scrollbar must be 11 pixels wide, Horizontal scrollbar 11 pixels high, caption must be 13 pixels. I hope I didn't forget any widgets, the game will assert for that so report them to me!
darkvater
parents:
867
diff
changeset
|
274 |
{ WWT_IMGBTN, RESIZE_NONE, 14, 0, 236, 14, 65, 0x0, STR_NULL}, |
f4698309dec7
(svn r1379) -Fix: various GUI glitches. Added default sizes to various widgets. Sticky/Resize- and Scrollbar must be 11 pixels wide, Horizontal scrollbar 11 pixels high, caption must be 13 pixels. I hope I didn't forget any widgets, the game will assert for that so report them to me!
darkvater
parents:
867
diff
changeset
|
275 |
{ WWT_SCROLLBAR, RESIZE_NONE, 14, 237, 248, 14, 65, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST}, |
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
817
diff
changeset
|
276 |
{ WWT_EMPTY, RESIZE_NONE, 0, 0, 0, 0, 0, 0x0, STR_NULL}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
817
diff
changeset
|
277 |
{ WWT_IMGBTN, RESIZE_NONE, 14, 0, 248, 66, 197, 0x0, STR_NULL}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
817
diff
changeset
|
278 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 14, 0, 63, 198, 209, STR_00E4_LOCATION, STR_3053_CENTER_MAIN_VIEW_ON_STATION}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
817
diff
changeset
|
279 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 14, 64, 128, 198, 209, STR_3033_ACCEPTS, STR_3056_SHOW_LIST_OF_ACCEPTED_CARGO}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
817
diff
changeset
|
280 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 14, 129, 192, 198, 209, STR_0130_RENAME, STR_3055_CHANGE_NAME_OF_STATION}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
817
diff
changeset
|
281 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 14, 193, 206, 198, 209, STR_TRAIN, STR_SCHEDULED_TRAINS_TIP }, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
817
diff
changeset
|
282 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 14, 207, 220, 198, 209, STR_LORRY, STR_SCHEDULED_ROAD_VEHICLES_TIP }, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
817
diff
changeset
|
283 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 14, 221, 234, 198, 209, STR_PLANE, STR_SCHEDULED_AIRCRAFT_TIP }, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
817
diff
changeset
|
284 |
{ 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
|
285 |
{ WIDGETS_END}, |
0 | 286 |
}; |
287 |
||
288 |
static const Widget _station_view_widgets[] = { |
|
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
817
diff
changeset
|
289 |
{ WWT_TEXTBTN, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
817
diff
changeset
|
290 |
{ WWT_CAPTION, RESIZE_NONE, 14, 11, 236, 0, 13, STR_300A_0, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
817
diff
changeset
|
291 |
{ WWT_STICKYBOX, RESIZE_NONE, 14, 237, 248, 0, 13, 0x0, STR_STICKY_BUTTON}, |
893
f4698309dec7
(svn r1379) -Fix: various GUI glitches. Added default sizes to various widgets. Sticky/Resize- and Scrollbar must be 11 pixels wide, Horizontal scrollbar 11 pixels high, caption must be 13 pixels. I hope I didn't forget any widgets, the game will assert for that so report them to me!
darkvater
parents:
867
diff
changeset
|
292 |
{ WWT_IMGBTN, RESIZE_NONE, 14, 0, 236, 14, 65, 0x0, STR_NULL}, |
f4698309dec7
(svn r1379) -Fix: various GUI glitches. Added default sizes to various widgets. Sticky/Resize- and Scrollbar must be 11 pixels wide, Horizontal scrollbar 11 pixels high, caption must be 13 pixels. I hope I didn't forget any widgets, the game will assert for that so report them to me!
darkvater
parents:
867
diff
changeset
|
293 |
{ WWT_SCROLLBAR, RESIZE_NONE, 14, 237, 248, 14, 65, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST}, |
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
817
diff
changeset
|
294 |
{ WWT_IMGBTN, RESIZE_NONE, 14, 0, 248, 66, 97, 0x0, STR_NULL}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
817
diff
changeset
|
295 |
{ WWT_EMPTY, RESIZE_NONE, 0, 0, 0, 0, 0, 0x0, STR_NULL}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
817
diff
changeset
|
296 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 14, 0, 63, 98, 109, STR_00E4_LOCATION, STR_3053_CENTER_MAIN_VIEW_ON_STATION}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
817
diff
changeset
|
297 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 14, 64, 128, 98, 109, STR_3032_RATINGS, STR_3054_SHOW_STATION_RATINGS}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
817
diff
changeset
|
298 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 14, 129, 192, 98, 109, STR_0130_RENAME, STR_3055_CHANGE_NAME_OF_STATION}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
817
diff
changeset
|
299 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 14, 193, 206, 98, 109, STR_TRAIN, STR_SCHEDULED_TRAINS_TIP }, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
817
diff
changeset
|
300 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 14, 207, 220, 98, 109, STR_LORRY, STR_SCHEDULED_ROAD_VEHICLES_TIP }, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
817
diff
changeset
|
301 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 14, 221, 234, 98, 109, STR_PLANE, STR_SCHEDULED_AIRCRAFT_TIP }, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
817
diff
changeset
|
302 |
{ 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
|
303 |
{ WIDGETS_END}, |
0 | 304 |
}; |
305 |
||
306 |
static void DrawStationViewWindow(Window *w) |
|
307 |
{ |
|
308 |
Station *st; |
|
309 |
int i; |
|
310 |
int num; |
|
311 |
int x,y; |
|
312 |
int pos; |
|
313 |
StringID str; |
|
817
238bbdaa228b
(svn r1288) -Codechange: changed _map2 to an uint16. It is still saved and loaded as
truelight
parents:
758
diff
changeset
|
314 |
uint16 station_id; |
0 | 315 |
|
1272
9aa073c64fc7
(svn r1776) -Add: Dynamic stations. You can now have up to 64k of stations
truelight
parents:
1266
diff
changeset
|
316 |
station_id = (uint16)w->window_number; |
0 | 317 |
|
919
544f374ee392
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
893
diff
changeset
|
318 |
st = GetStation(w->window_number); |
0 | 319 |
|
320 |
num = 1; |
|
321 |
for(i=0; i!=NUM_CARGO; i++) { |
|
322 |
if ((st->goods[i].waiting_acceptance & 0xFFF) != 0) { |
|
323 |
num++; |
|
324 |
if (st->goods[i].enroute_from != station_id) |
|
325 |
num++; |
|
326 |
} |
|
327 |
} |
|
328 |
SetVScrollCount(w, num); |
|
329 |
||
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
|
330 |
w->disabled_state = st->owner == _local_player ? 0 : (1 << 9); |
588 | 331 |
|
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
|
332 |
if (!(st->facilities & FACIL_TRAIN)) SETBIT(w->disabled_state, 10); |
588 | 333 |
if (!(st->facilities & FACIL_TRUCK_STOP) && |
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
|
334 |
!(st->facilities & FACIL_BUS_STOP)) SETBIT(w->disabled_state, 11); |
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
|
335 |
if (!(st->facilities & FACIL_AIRPORT)) SETBIT(w->disabled_state, 12); |
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
|
336 |
if (!(st->facilities & FACIL_DOCK)) SETBIT(w->disabled_state, 13); |
588 | 337 |
|
534
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
338 |
SetDParam(0, st->index); |
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
339 |
SetDParam(1, st->facilities); |
0 | 340 |
DrawWindowWidgets(w); |
341 |
||
342 |
x = 2; |
|
343 |
y = 15; |
|
344 |
pos = w->vscroll.pos; |
|
345 |
||
346 |
if (--pos < 0) { |
|
347 |
str = STR_00D0_NOTHING; |
|
348 |
for(i=0; i!=NUM_CARGO; i++) |
|
349 |
if (st->goods[i].waiting_acceptance & 0xFFF) |
|
350 |
str = STR_EMPTY; |
|
534
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
351 |
SetDParam(0, str); |
0 | 352 |
DrawString(x, y, STR_0008_WAITING, 0); |
353 |
y += 10; |
|
354 |
} |
|
355 |
||
356 |
i = 0; |
|
357 |
do { |
|
358 |
uint waiting = (st->goods[i].waiting_acceptance & 0xFFF); |
|
359 |
if (waiting == 0) |
|
360 |
continue; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
361 |
|
0 | 362 |
num = (waiting + 5) / 10; |
363 |
if (num != 0) { |
|
364 |
int cur_x = x; |
|
365 |
num = min(num, 23); |
|
366 |
do { |
|
367 |
DrawSprite(_cargoc.sprites[i], cur_x, y); |
|
368 |
cur_x += 10; |
|
369 |
} while (--num); |
|
370 |
} |
|
371 |
||
372 |
if ( st->goods[i].enroute_from == station_id) { |
|
373 |
if (--pos < 0) { |
|
534
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
374 |
SetDParam(1, waiting); |
2084
65639f898a50
(svn r2594) Fix: [strgen] Misc updates to the string system.
ludde
parents:
2070
diff
changeset
|
375 |
SetDParam(0, _cargoc.names_long[i]); |
0 | 376 |
DrawStringRightAligned(x + 234, y, STR_0009, 0); |
377 |
y += 10; |
|
378 |
} |
|
379 |
} else { |
|
380 |
/* enroute */ |
|
381 |
if (--pos < 0) { |
|
534
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
382 |
SetDParam(1, waiting); |
2084
65639f898a50
(svn r2594) Fix: [strgen] Misc updates to the string system.
ludde
parents:
2070
diff
changeset
|
383 |
SetDParam(0, _cargoc.names_long[i]); |
0 | 384 |
DrawStringRightAligned(x + 234, y, STR_000A_EN_ROUTE_FROM, 0); |
385 |
y += 10; |
|
386 |
} |
|
387 |
||
388 |
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
|
389 |
SetDParam(0, st->goods[i].enroute_from); |
0 | 390 |
DrawStringRightAligned(x + 234, y, STR_000B, 0); |
391 |
y += 10; |
|
392 |
} |
|
393 |
} |
|
394 |
} while (pos > -5 && ++i != 12); |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
395 |
|
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
817
diff
changeset
|
396 |
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
|
397 |
char *b = _userstring; |
1329 | 398 |
|
1553
cf513e731bd3
(svn r2057) Add InlineString() to make _userstring construction a bit cleaner.
tron
parents:
1474
diff
changeset
|
399 |
b = InlineString(b, STR_000C_ACCEPTS); |
0 | 400 |
|
1556
d7c2d5289be9
(svn r2060) Clean up some string construction and remove now unused macro
tron
parents:
1553
diff
changeset
|
401 |
for (i = 0; i != NUM_CARGO; i++) { |
d7c2d5289be9
(svn r2060) Clean up some string construction and remove now unused macro
tron
parents:
1553
diff
changeset
|
402 |
if (b >= endof(_userstring) - 5 - 1) break; |
0 | 403 |
if (st->goods[i].waiting_acceptance & 0x8000) { |
1553
cf513e731bd3
(svn r2057) Add InlineString() to make _userstring construction a bit cleaner.
tron
parents:
1474
diff
changeset
|
404 |
b = InlineString(b, _cargoc.names_s[i]); |
1556
d7c2d5289be9
(svn r2060) Clean up some string construction and remove now unused macro
tron
parents:
1553
diff
changeset
|
405 |
*b++ = ','; |
d7c2d5289be9
(svn r2060) Clean up some string construction and remove now unused macro
tron
parents:
1553
diff
changeset
|
406 |
*b++ = ' '; |
0 | 407 |
} |
408 |
} |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
409 |
|
1329 | 410 |
if (b == &_userstring[3]) { |
1553
cf513e731bd3
(svn r2057) Add InlineString() to make _userstring construction a bit cleaner.
tron
parents:
1474
diff
changeset
|
411 |
b = InlineString(b, STR_00D0_NOTHING); |
cf513e731bd3
(svn r2057) Add InlineString() to make _userstring construction a bit cleaner.
tron
parents:
1474
diff
changeset
|
412 |
*b++ = '\0'; |
0 | 413 |
} else { |
1556
d7c2d5289be9
(svn r2060) Clean up some string construction and remove now unused macro
tron
parents:
1553
diff
changeset
|
414 |
b[-2] = '\0'; |
0 | 415 |
} |
416 |
||
417 |
DrawStringMultiLine(2, 67, STR_SPEC_USERSTRING, 245); |
|
418 |
} else { |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
419 |
|
0 | 420 |
DrawString(2, 67, STR_3034_LOCAL_RATING_OF_TRANSPORT, 0); |
421 |
||
422 |
y = 77; |
|
423 |
for(i=0; i!=NUM_CARGO; i++) { |
|
1266
eccd576e322f
(svn r1770) -Fix: Hopefully last pieces of code that are containing a station-id
truelight
parents:
1093
diff
changeset
|
424 |
if (st->goods[i].enroute_from != INVALID_STATION) { |
534
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
425 |
SetDParam(0, _cargoc.names_s[i]); |
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
426 |
SetDParam(2, st->goods[i].rating * 101 >> 8); |
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
427 |
SetDParam(1, STR_3035_APPALLING + (st->goods[i].rating >> 5)); |
0 | 428 |
DrawString(8, y, STR_303D, 0); |
429 |
y += 10; |
|
430 |
} |
|
431 |
} |
|
432 |
} |
|
433 |
} |
|
434 |
||
435 |
||
436 |
static void StationViewWndProc(Window *w, WindowEvent *e) |
|
437 |
{ |
|
438 |
switch(e->event) { |
|
439 |
case WE_PAINT: |
|
440 |
DrawStationViewWindow(w); |
|
441 |
break; |
|
442 |
||
443 |
case WE_CLICK: |
|
444 |
switch(e->click.widget) { |
|
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
|
445 |
case 7: |
919
544f374ee392
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
893
diff
changeset
|
446 |
ScrollMainWindowToTile(GetStation(w->window_number)->xy); |
0 | 447 |
break; |
448 |
||
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
|
449 |
case 8: |
0 | 450 |
SetWindowDirty(w); |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
451 |
|
0 | 452 |
/* toggle height/widget set */ |
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
817
diff
changeset
|
453 |
if (IsWindowOfPrototype(w, _station_view_expanded_widgets)) { |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
817
diff
changeset
|
454 |
AssignWidgetToWindow(w, _station_view_widgets); |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
817
diff
changeset
|
455 |
w->height = 110; |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
817
diff
changeset
|
456 |
} else { |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
817
diff
changeset
|
457 |
AssignWidgetToWindow(w, _station_view_expanded_widgets); |
893
f4698309dec7
(svn r1379) -Fix: various GUI glitches. Added default sizes to various widgets. Sticky/Resize- and Scrollbar must be 11 pixels wide, Horizontal scrollbar 11 pixels high, caption must be 13 pixels. I hope I didn't forget any widgets, the game will assert for that so report them to me!
darkvater
parents:
867
diff
changeset
|
458 |
w->height = 210; |
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
817
diff
changeset
|
459 |
} |
0 | 460 |
|
461 |
SetWindowDirty(w); |
|
462 |
break; |
|
463 |
||
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
|
464 |
case 9: { |
2070
47b1f29d4671
(svn r2580) Change: Added {INDUSTRY} command for printing industry names instead of the old {TOWN} {STRING} way.
ludde
parents:
2026
diff
changeset
|
465 |
SetDParam(0, w->window_number); |
47b1f29d4671
(svn r2580) Change: Added {INDUSTRY} command for printing industry names instead of the old {TOWN} {STRING} way.
ludde
parents:
2026
diff
changeset
|
466 |
ShowQueryString(STR_STATION, STR_3030_RENAME_STATION_LOADING, 31, 180, w->window_class, w->window_number); |
2026 | 467 |
} break; |
588 | 468 |
|
1809
d54f7f8050f6
(svn r2313) - Fix: [ 1202115 ] Clicking shipslist on bouy asserts GetPlayer(). Bouys and oilrigs don't have owners, so it cannot get the vehicle-list of the station-owner. Just use _current_player
Darkvater
parents:
1556
diff
changeset
|
469 |
case 10: { /* Show a list of scheduled trains to this station */ |
919
544f374ee392
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
893
diff
changeset
|
470 |
const Station *st = GetStation(w->window_number); |
588 | 471 |
ShowPlayerTrains(st->owner, w->window_number); |
472 |
break; |
|
473 |
} |
|
474 |
||
1809
d54f7f8050f6
(svn r2313) - Fix: [ 1202115 ] Clicking shipslist on bouy asserts GetPlayer(). Bouys and oilrigs don't have owners, so it cannot get the vehicle-list of the station-owner. Just use _current_player
Darkvater
parents:
1556
diff
changeset
|
475 |
case 11: { /* Show a list of scheduled road-vehicles to this station */ |
919
544f374ee392
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
893
diff
changeset
|
476 |
const Station *st = GetStation(w->window_number); |
588 | 477 |
ShowPlayerRoadVehicles(st->owner, w->window_number); |
478 |
break; |
|
479 |
} |
|
480 |
||
1809
d54f7f8050f6
(svn r2313) - Fix: [ 1202115 ] Clicking shipslist on bouy asserts GetPlayer(). Bouys and oilrigs don't have owners, so it cannot get the vehicle-list of the station-owner. Just use _current_player
Darkvater
parents:
1556
diff
changeset
|
481 |
case 12: { /* Show a list of scheduled aircraft to this station */ |
919
544f374ee392
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
893
diff
changeset
|
482 |
const Station *st = GetStation(w->window_number); |
1809
d54f7f8050f6
(svn r2313) - Fix: [ 1202115 ] Clicking shipslist on bouy asserts GetPlayer(). Bouys and oilrigs don't have owners, so it cannot get the vehicle-list of the station-owner. Just use _current_player
Darkvater
parents:
1556
diff
changeset
|
483 |
/* Since oilrigs have no owners, show the scheduled aircraft of current player */ |
d54f7f8050f6
(svn r2313) - Fix: [ 1202115 ] Clicking shipslist on bouy asserts GetPlayer(). Bouys and oilrigs don't have owners, so it cannot get the vehicle-list of the station-owner. Just use _current_player
Darkvater
parents:
1556
diff
changeset
|
484 |
PlayerID owner = (st->owner == OWNER_NONE) ? _current_player : st->owner; |
d54f7f8050f6
(svn r2313) - Fix: [ 1202115 ] Clicking shipslist on bouy asserts GetPlayer(). Bouys and oilrigs don't have owners, so it cannot get the vehicle-list of the station-owner. Just use _current_player
Darkvater
parents:
1556
diff
changeset
|
485 |
ShowPlayerAircraft(owner, w->window_number); |
588 | 486 |
break; |
487 |
} |
|
488 |
||
1809
d54f7f8050f6
(svn r2313) - Fix: [ 1202115 ] Clicking shipslist on bouy asserts GetPlayer(). Bouys and oilrigs don't have owners, so it cannot get the vehicle-list of the station-owner. Just use _current_player
Darkvater
parents:
1556
diff
changeset
|
489 |
case 13: { /* Show a list of scheduled ships to this station */ |
919
544f374ee392
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
893
diff
changeset
|
490 |
const Station *st = GetStation(w->window_number); |
1809
d54f7f8050f6
(svn r2313) - Fix: [ 1202115 ] Clicking shipslist on bouy asserts GetPlayer(). Bouys and oilrigs don't have owners, so it cannot get the vehicle-list of the station-owner. Just use _current_player
Darkvater
parents:
1556
diff
changeset
|
491 |
/* Since oilrigs/bouys have no owners, show the scheduled ships of current player */ |
d54f7f8050f6
(svn r2313) - Fix: [ 1202115 ] Clicking shipslist on bouy asserts GetPlayer(). Bouys and oilrigs don't have owners, so it cannot get the vehicle-list of the station-owner. Just use _current_player
Darkvater
parents:
1556
diff
changeset
|
492 |
PlayerID owner = (st->owner == OWNER_NONE) ? _current_player : st->owner; |
d54f7f8050f6
(svn r2313) - Fix: [ 1202115 ] Clicking shipslist on bouy asserts GetPlayer(). Bouys and oilrigs don't have owners, so it cannot get the vehicle-list of the station-owner. Just use _current_player
Darkvater
parents:
1556
diff
changeset
|
493 |
ShowPlayerShips(owner, w->window_number); |
588 | 494 |
break; |
495 |
} |
|
0 | 496 |
} |
497 |
break; |
|
498 |
||
499 |
case WE_ON_EDIT_TEXT: { |
|
1820
d03c56850dc2
(svn r2324) Introduce _cmd_text for passing strings with a command instead of abusing _decode_parameters as text buffer. This should prevent several possible buffer overruns and is a bit cleaner to use. As bonus it reduces the size of most command packets by 79 bytes.
tron
parents:
1809
diff
changeset
|
500 |
if (e->edittext.str[0] != '\0') { |
d03c56850dc2
(svn r2324) Introduce _cmd_text for passing strings with a command instead of abusing _decode_parameters as text buffer. This should prevent several possible buffer overruns and is a bit cleaner to use. As bonus it reduces the size of most command packets by 79 bytes.
tron
parents:
1809
diff
changeset
|
501 |
Station* st = GetStation(w->window_number); |
0 | 502 |
|
1820
d03c56850dc2
(svn r2324) Introduce _cmd_text for passing strings with a command instead of abusing _decode_parameters as text buffer. This should prevent several possible buffer overruns and is a bit cleaner to use. As bonus it reduces the size of most command packets by 79 bytes.
tron
parents:
1809
diff
changeset
|
503 |
_cmd_text = e->edittext.str; |
d03c56850dc2
(svn r2324) Introduce _cmd_text for passing strings with a command instead of abusing _decode_parameters as text buffer. This should prevent several possible buffer overruns and is a bit cleaner to use. As bonus it reduces the size of most command packets by 79 bytes.
tron
parents:
1809
diff
changeset
|
504 |
DoCommandP(st->xy, w->window_number, 0, NULL, |
d03c56850dc2
(svn r2324) Introduce _cmd_text for passing strings with a command instead of abusing _decode_parameters as text buffer. This should prevent several possible buffer overruns and is a bit cleaner to use. As bonus it reduces the size of most command packets by 79 bytes.
tron
parents:
1809
diff
changeset
|
505 |
CMD_RENAME_STATION | CMD_MSG(STR_3031_CAN_T_RENAME_STATION)); |
d03c56850dc2
(svn r2324) Introduce _cmd_text for passing strings with a command instead of abusing _decode_parameters as text buffer. This should prevent several possible buffer overruns and is a bit cleaner to use. As bonus it reduces the size of most command packets by 79 bytes.
tron
parents:
1809
diff
changeset
|
506 |
} |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
507 |
} break; |
588 | 508 |
|
509 |
case WE_DESTROY: { |
|
510 |
WindowNumber wno = |
|
919
544f374ee392
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
893
diff
changeset
|
511 |
(w->window_number << 16) | GetStation(w->window_number)->owner; |
588 | 512 |
|
513 |
DeleteWindowById(WC_TRAINS_LIST, wno); |
|
514 |
DeleteWindowById(WC_ROADVEH_LIST, wno); |
|
515 |
DeleteWindowById(WC_SHIPS_LIST, wno); |
|
516 |
DeleteWindowById(WC_AIRCRAFT_LIST, wno); |
|
517 |
break; |
|
518 |
} |
|
0 | 519 |
} |
520 |
} |
|
521 |
||
522 |
||
523 |
static const WindowDesc _station_view_desc = { |
|
524 |
-1, -1, 249, 110, |
|
525 |
WC_STATION_VIEW,0, |
|
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
|
526 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_STICKY_BUTTON, |
0 | 527 |
_station_view_widgets, |
528 |
StationViewWndProc |
|
529 |
}; |
|
530 |
||
531 |
void ShowStationViewWindow(int station) |
|
532 |
{ |
|
533 |
Window *w; |
|
534 |
byte color; |
|
535 |
||
536 |
w = AllocateWindowDescFront(&_station_view_desc, station); |
|
537 |
if (w) { |
|
919
544f374ee392
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
893
diff
changeset
|
538 |
color = GetStation(w->window_number)->owner; |
0 | 539 |
if (color != 0x10) |
540 |
w->caption_color = color; |
|
541 |
w->vscroll.cap = 5; |
|
542 |
} |
|
543 |
} |