author | dominik |
Fri, 21 Jan 2005 18:36:17 +0000 | |
changeset 1081 | 0d79fc43fae2 |
parent 919 | 544f374ee392 |
child 1093 | 4fdc46eaf423 |
permissions | -rw-r--r-- |
0 | 1 |
#include "stdafx.h" |
2 |
#include "ttd.h" |
|
507
04b5403aaf6b
(svn r815) Include strings.h only in the files which need it.
tron
parents:
487
diff
changeset
|
3 |
#include "table/strings.h" |
0 | 4 |
#include "window.h" |
5 |
#include "gui.h" |
|
6 |
#include "station.h" |
|
7 |
#include "gfx.h" |
|
8 |
#include "player.h" |
|
9 |
#include "town.h" |
|
10 |
#include "command.h" |
|
11 |
||
12 |
static void StationsWndShowStationRating(int x, int y, int type, uint acceptance, int rating) |
|
13 |
{ |
|
14 |
static const byte _rating_colors[NUM_CARGO] = {152,32,15,174,208,194,191,55,184,10,191,48}; |
|
15 |
int color = _rating_colors[type]; |
|
16 |
uint w; |
|
17 |
||
18 |
if (acceptance > 575) |
|
19 |
acceptance = 575; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
20 |
|
0 | 21 |
acceptance = (acceptance + 7) >> 3; |
22 |
||
23 |
/* draw cargo */ |
|
24 |
if ( (w=acceptance>>3) != 0) { |
|
25 |
GfxFillRect(x, y, x+w-1, y+6, color); |
|
26 |
x += w; |
|
27 |
} |
|
28 |
||
29 |
if ( (w=acceptance&7) != 0) { |
|
30 |
if (w==7) w--; |
|
31 |
GfxFillRect(x, y+(w-1), x, y+6, color); |
|
32 |
} |
|
33 |
||
34 |
x -= (acceptance>>3); |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
35 |
|
0 | 36 |
DrawString(x+1, y, _cargoc.names_short[type], 0x10); |
37 |
||
38 |
/* draw green/red ratings bar */ |
|
39 |
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
|
40 |
|
0 | 41 |
rating = (rating >> 5); |
42 |
||
43 |
if (rating != 0) { |
|
44 |
GfxFillRect(x+1, y+8, x+rating, y+8, 0xD0); |
|
45 |
} |
|
46 |
} |
|
47 |
||
48 |
static uint16 _num_station_sort[MAX_PLAYERS]; |
|
49 |
||
50 |
static char _bufcache[64]; |
|
51 |
static uint16 _last_station_idx; |
|
52 |
||
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
|
53 |
static int CDECL StationNameSorter(const void *a, const void *b) |
0 | 54 |
{ |
55 |
char buf1[64]; |
|
56 |
Station *st; |
|
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
|
57 |
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
|
58 |
const SortStruct *cmp2 = (const SortStruct*)b; |
0 | 59 |
|
919
544f374ee392
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
893
diff
changeset
|
60 |
st = GetStation(cmp1->index); |
534
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
61 |
SetDParam(0, st->town->townnametype); |
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
62 |
SetDParam(1, st->town->townnameparts); |
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
|
63 |
GetString(buf1, st->string_id); |
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; |
919
544f374ee392
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
893
diff
changeset
|
67 |
st = GetStation(cmp2->index); |
534
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
68 |
SetDParam(0, st->town->townnametype); |
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
69 |
SetDParam(1, st->town->townnameparts); |
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
|
70 |
GetString(_bufcache, st->string_id); |
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
|
71 |
} |
0 | 72 |
|
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
|
73 |
return strcmp(buf1, _bufcache); // sort by name |
0 | 74 |
} |
75 |
||
243
9a40daa560ae
(svn r244) -Fix: Stations were not sorted for non-player-0 players
darkvater
parents:
222
diff
changeset
|
76 |
static void GlobalSortStationList() |
0 | 77 |
{ |
243
9a40daa560ae
(svn r244) -Fix: Stations were not sorted for non-player-0 players
darkvater
parents:
222
diff
changeset
|
78 |
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
|
79 |
uint32 n = 0; |
0 | 80 |
uint16 *i; |
243
9a40daa560ae
(svn r244) -Fix: Stations were not sorted for non-player-0 players
darkvater
parents:
222
diff
changeset
|
81 |
|
9a40daa560ae
(svn r244) -Fix: Stations were not sorted for non-player-0 players
darkvater
parents:
222
diff
changeset
|
82 |
// reset #-of stations to 0 because ++ is used for value-assignment |
919
544f374ee392
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
893
diff
changeset
|
83 |
for (i = _num_station_sort; i != endof(_num_station_sort); i++) |
544f374ee392
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
893
diff
changeset
|
84 |
*i = 0; |
544f374ee392
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
893
diff
changeset
|
85 |
|
544f374ee392
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
893
diff
changeset
|
86 |
/* Create array for sorting */ |
544f374ee392
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
893
diff
changeset
|
87 |
_station_sort = realloc(_station_sort, _stations_size * sizeof(_station_sort[0])); |
544f374ee392
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
893
diff
changeset
|
88 |
if (_station_sort == NULL) |
544f374ee392
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
893
diff
changeset
|
89 |
error("Could not allocate memory for the station-sorting-list"); |
0 | 90 |
|
91 |
FOR_ALL_STATIONS(st) { |
|
92 |
if(st->xy && st->owner != OWNER_NONE) { |
|
93 |
_station_sort[n].index = st->index; |
|
94 |
_station_sort[n++].owner = st->owner; |
|
95 |
_num_station_sort[st->owner]++; // add number of stations of player |
|
96 |
} |
|
97 |
} |
|
98 |
||
243
9a40daa560ae
(svn r244) -Fix: Stations were not sorted for non-player-0 players
darkvater
parents:
222
diff
changeset
|
99 |
// create cumulative station-ownership |
0 | 100 |
// stations are stored as a cummulative index, eg 25, 41, 43. This means |
101 |
// Player0: 25; Player1: (41-25) 16; Player2: (43-41) 2 |
|
102 |
for (i = &_num_station_sort[1]; i != endof(_num_station_sort); i++) {*i += *(i-1);} |
|
103 |
||
243
9a40daa560ae
(svn r244) -Fix: Stations were not sorted for non-player-0 players
darkvater
parents:
222
diff
changeset
|
104 |
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
|
105 |
|
243
9a40daa560ae
(svn r244) -Fix: Stations were not sorted for non-player-0 players
darkvater
parents:
222
diff
changeset
|
106 |
// 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
|
107 |
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
|
108 |
_global_station_sort_dirty = false; |
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 |
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
|
111 |
} |
9a40daa560ae
(svn r244) -Fix: Stations were not sorted for non-player-0 players
darkvater
parents:
222
diff
changeset
|
112 |
|
9a40daa560ae
(svn r244) -Fix: Stations were not sorted for non-player-0 players
darkvater
parents:
222
diff
changeset
|
113 |
static void MakeSortedStationList(byte owner) |
9a40daa560ae
(svn r244) -Fix: Stations were not sorted for non-player-0 players
darkvater
parents:
222
diff
changeset
|
114 |
{ |
9a40daa560ae
(svn r244) -Fix: Stations were not sorted for non-player-0 players
darkvater
parents:
222
diff
changeset
|
115 |
SortStruct *firstelement; |
9a40daa560ae
(svn r244) -Fix: Stations were not sorted for non-player-0 players
darkvater
parents:
222
diff
changeset
|
116 |
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
|
117 |
|
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
|
118 |
if (owner == 0) { // first element starts at 0th element and has n elements as described above |
bd79fb899824
(svn r175) -Fix: [1023771] inconsistent/missing stations in station list. Forgot to change owner-sort after changing function.
darkvater
parents:
164
diff
changeset
|
119 |
firstelement = &_station_sort[0]; |
bd79fb899824
(svn r175) -Fix: [1023771] inconsistent/missing stations in station list. Forgot to change owner-sort after changing function.
darkvater
parents:
164
diff
changeset
|
120 |
n = _num_station_sort[0]; |
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 |
} else { // nth element starts at the end of the previous one, and has n elements as described above |
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 |
firstelement = &_station_sort[_num_station_sort[owner-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
|
123 |
n = _num_station_sort[owner] - _num_station_sort[owner-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
|
124 |
} |
bd79fb899824
(svn r175) -Fix: [1023771] inconsistent/missing stations in station list. Forgot to change owner-sort after changing function.
darkvater
parents:
164
diff
changeset
|
125 |
|
243
9a40daa560ae
(svn r244) -Fix: Stations were not sorted for non-player-0 players
darkvater
parents:
222
diff
changeset
|
126 |
_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
|
127 |
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
|
128 |
|
243
9a40daa560ae
(svn r244) -Fix: Stations were not sorted for non-player-0 players
darkvater
parents:
222
diff
changeset
|
129 |
_station_sort_dirty[owner] = false; |
9a40daa560ae
(svn r244) -Fix: Stations were not sorted for non-player-0 players
darkvater
parents:
222
diff
changeset
|
130 |
|
9a40daa560ae
(svn r244) -Fix: Stations were not sorted for non-player-0 players
darkvater
parents:
222
diff
changeset
|
131 |
DEBUG(misc, 1) ("Resorting Stations list player %d...", owner+1); |
0 | 132 |
} |
133 |
||
134 |
static void PlayerStationsWndProc(Window *w, WindowEvent *e) |
|
135 |
{ |
|
136 |
switch(e->event) { |
|
137 |
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
|
138 |
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
|
139 |
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
|
140 |
|
243
9a40daa560ae
(svn r244) -Fix: Stations were not sorted for non-player-0 players
darkvater
parents:
222
diff
changeset
|
141 |
// 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
|
142 |
if (_global_station_sort_dirty) |
9a40daa560ae
(svn r244) -Fix: Stations were not sorted for non-player-0 players
darkvater
parents:
222
diff
changeset
|
143 |
GlobalSortStationList(); |
9a40daa560ae
(svn r244) -Fix: Stations were not sorted for non-player-0 players
darkvater
parents:
222
diff
changeset
|
144 |
|
9a40daa560ae
(svn r244) -Fix: Stations were not sorted for non-player-0 players
darkvater
parents:
222
diff
changeset
|
145 |
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
|
146 |
MakeSortedStationList(window_number); |
0 | 147 |
} |
148 |
||
149 |
// stations are stored as a cummulative index, eg 25, 41, 43. This means |
|
150 |
// 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
|
151 |
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
|
152 |
SetVScrollCount(w, _num_station_sort[window_number] - i); |
0 | 153 |
|
154 |
/* draw widgets, with player's name in the caption */ |
|
155 |
{ |
|
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
|
156 |
Player *p = DEREF_PLAYER(window_number); |
534
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
157 |
SetDParam(0, p->name_1); |
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
158 |
SetDParam(1, p->name_2); |
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
159 |
SetDParam(2, w->vscroll.count); |
0 | 160 |
DrawWindowWidgets(w); |
161 |
} |
|
162 |
||
163 |
{ |
|
164 |
byte p = 0; |
|
165 |
Station *st; |
|
166 |
int x,xb = 2; |
|
167 |
int y = 16; // offset from top of widget |
|
168 |
int j; |
|
169 |
||
170 |
if (w->vscroll.count == 0) { // player has no stations |
|
171 |
DrawString(xb, y, STR_304A_NONE, 0); |
|
172 |
return; |
|
173 |
} |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
174 |
|
0 | 175 |
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
|
176 |
assert(i < _num_station_sort[window_number]); // at least one station must exist |
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 |
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
|
179 |
st = GetStation(_station_sort[i].index); |
0 | 180 |
|
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
|
181 |
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
|
182 |
|
534
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
183 |
SetDParam(0, st->index); |
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
184 |
SetDParam(1, st->facilities); |
0 | 185 |
x = DrawString(xb, y, STR_3049_0, 0) + 5; |
186 |
||
187 |
// show cargo waiting and station ratings |
|
188 |
for(j=0; j!=NUM_CARGO; j++) { |
|
189 |
int acc = (st->goods[j].waiting_acceptance & 0xFFF); |
|
190 |
if (acc != 0) { |
|
191 |
StationsWndShowStationRating(x, y, j, acc, st->goods[j].rating); |
|
192 |
x += 10; |
|
193 |
} |
|
194 |
} |
|
195 |
y += 10; |
|
196 |
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
|
197 |
if (++p == w->vscroll.cap) { break;} // max number of stations in 1 window |
0 | 198 |
} |
199 |
} |
|
200 |
} break; |
|
201 |
case WE_CLICK: { |
|
202 |
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
|
203 |
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
|
204 |
uint32 id_v = (e->click.pt.y - 15) / 10; |
0 | 205 |
|
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
|
206 |
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
|
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 |
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
|
209 |
|
bd79fb899824
(svn r175) -Fix: [1023771] inconsistent/missing stations in station list. Forgot to change owner-sort after changing function.
darkvater
parents:
164
diff
changeset
|
210 |
{ |
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 |
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
|
212 |
Station *st; |
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 |
id_v += (owner == 0) ? 0 : _num_station_sort[owner - 1]; // first element in list |
bd79fb899824
(svn r175) -Fix: [1023771] inconsistent/missing stations in station list. Forgot to change owner-sort after changing function.
darkvater
parents:
164
diff
changeset
|
214 |
|
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 |
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
|
216 |
|
919
544f374ee392
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
893
diff
changeset
|
217 |
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
|
218 |
|
bd79fb899824
(svn r175) -Fix: [1023771] inconsistent/missing stations in station list. Forgot to change owner-sort after changing function.
darkvater
parents:
164
diff
changeset
|
219 |
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
|
220 |
|
bd79fb899824
(svn r175) -Fix: [1023771] inconsistent/missing stations in station list. Forgot to change owner-sort after changing function.
darkvater
parents:
164
diff
changeset
|
221 |
ScrollMainWindowToTile(st->xy); |
0 | 222 |
} |
223 |
} break; |
|
224 |
} |
|
225 |
} break; |
|
226 |
||
227 |
case WE_4: |
|
228 |
WP(w,plstations_d).refresh_counter++; |
|
229 |
if (WP(w,plstations_d).refresh_counter==5) { |
|
230 |
WP(w,plstations_d).refresh_counter = 0; |
|
231 |
SetWindowDirty(w); |
|
232 |
} |
|
233 |
break; |
|
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
817
diff
changeset
|
234 |
|
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
817
diff
changeset
|
235 |
case WE_RESIZE: |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
817
diff
changeset
|
236 |
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
|
237 |
break; |
0 | 238 |
} |
239 |
} |
|
240 |
||
241 |
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
|
242 |
{ 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
|
243 |
{ 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
|
244 |
{ 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
|
245 |
{ 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
|
246 |
{ 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
|
247 |
{ 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
|
248 |
{ WIDGETS_END}, |
0 | 249 |
}; |
250 |
||
251 |
static const WindowDesc _player_stations_desc = { |
|
252 |
-1, -1, 358, 138, |
|
253 |
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
|
254 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_STICKY_BUTTON | WDF_RESIZABLE, |
0 | 255 |
_player_stations_widgets, |
256 |
PlayerStationsWndProc |
|
257 |
}; |
|
258 |
||
259 |
||
260 |
void ShowPlayerStations(int player) |
|
261 |
{ |
|
262 |
Window *w; |
|
263 |
||
264 |
w = AllocateWindowDescFront(&_player_stations_desc, player); |
|
265 |
if (w) { |
|
266 |
w->caption_color = (byte)w->window_number; |
|
267 |
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
|
268 |
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
|
269 |
w->resize.height = w->height - 10 * 7; // minimum if 5 in the list |
0 | 270 |
} |
271 |
} |
|
272 |
||
273 |
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
|
274 |
{ 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
|
275 |
{ 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
|
276 |
{ 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
|
277 |
{ 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
|
278 |
{ 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
|
279 |
{ 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
|
280 |
{ 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
|
281 |
{ 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
|
282 |
{ 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
|
283 |
{ 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
|
284 |
{ 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
|
285 |
{ 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
|
286 |
{ 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
|
287 |
{ 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
|
288 |
{ WIDGETS_END}, |
0 | 289 |
}; |
290 |
||
291 |
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
|
292 |
{ 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
|
293 |
{ 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
|
294 |
{ 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
|
295 |
{ 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
|
296 |
{ 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
|
297 |
{ 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
|
298 |
{ 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
|
299 |
{ 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
|
300 |
{ 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
|
301 |
{ 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
|
302 |
{ 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
|
303 |
{ 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
|
304 |
{ 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
|
305 |
{ 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
|
306 |
{ WIDGETS_END}, |
0 | 307 |
}; |
308 |
||
309 |
static void DrawStationViewWindow(Window *w) |
|
310 |
{ |
|
311 |
Station *st; |
|
312 |
int i; |
|
313 |
int num; |
|
314 |
int x,y; |
|
315 |
int pos; |
|
316 |
StringID str; |
|
817
238bbdaa228b
(svn r1288) -Codechange: changed _map2 to an uint16. It is still saved and loaded as
truelight
parents:
758
diff
changeset
|
317 |
uint16 station_id; |
0 | 318 |
byte *b; |
319 |
||
320 |
||
321 |
station_id = (byte)w->window_number; |
|
322 |
||
919
544f374ee392
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
893
diff
changeset
|
323 |
st = GetStation(w->window_number); |
0 | 324 |
|
325 |
num = 1; |
|
326 |
for(i=0; i!=NUM_CARGO; i++) { |
|
327 |
if ((st->goods[i].waiting_acceptance & 0xFFF) != 0) { |
|
328 |
num++; |
|
329 |
if (st->goods[i].enroute_from != station_id) |
|
330 |
num++; |
|
331 |
} |
|
332 |
} |
|
333 |
SetVScrollCount(w, num); |
|
334 |
||
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
|
335 |
w->disabled_state = st->owner == _local_player ? 0 : (1 << 9); |
588 | 336 |
|
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
|
337 |
if (!(st->facilities & FACIL_TRAIN)) SETBIT(w->disabled_state, 10); |
588 | 338 |
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
|
339 |
!(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
|
340 |
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
|
341 |
if (!(st->facilities & FACIL_DOCK)) SETBIT(w->disabled_state, 13); |
588 | 342 |
|
534
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
343 |
SetDParam(0, st->index); |
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
344 |
SetDParam(1, st->facilities); |
0 | 345 |
DrawWindowWidgets(w); |
346 |
||
347 |
x = 2; |
|
348 |
y = 15; |
|
349 |
pos = w->vscroll.pos; |
|
350 |
||
351 |
if (--pos < 0) { |
|
352 |
str = STR_00D0_NOTHING; |
|
353 |
for(i=0; i!=NUM_CARGO; i++) |
|
354 |
if (st->goods[i].waiting_acceptance & 0xFFF) |
|
355 |
str = STR_EMPTY; |
|
534
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
356 |
SetDParam(0, str); |
0 | 357 |
DrawString(x, y, STR_0008_WAITING, 0); |
358 |
y += 10; |
|
359 |
} |
|
360 |
||
361 |
i = 0; |
|
362 |
do { |
|
363 |
uint waiting = (st->goods[i].waiting_acceptance & 0xFFF); |
|
364 |
if (waiting == 0) |
|
365 |
continue; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
366 |
|
0 | 367 |
num = (waiting + 5) / 10; |
368 |
if (num != 0) { |
|
369 |
int cur_x = x; |
|
370 |
num = min(num, 23); |
|
371 |
do { |
|
372 |
DrawSprite(_cargoc.sprites[i], cur_x, y); |
|
373 |
cur_x += 10; |
|
374 |
} while (--num); |
|
375 |
} |
|
376 |
||
377 |
if ( st->goods[i].enroute_from == station_id) { |
|
378 |
if (--pos < 0) { |
|
534
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
379 |
SetDParam(1, waiting); |
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
380 |
SetDParam(0, _cargoc.names_long_s[i] + (waiting==1 ? 0 : 32)); |
0 | 381 |
DrawStringRightAligned(x + 234, y, STR_0009, 0); |
382 |
y += 10; |
|
383 |
} |
|
384 |
} else { |
|
385 |
/* enroute */ |
|
386 |
if (--pos < 0) { |
|
534
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
387 |
SetDParam(1, waiting); |
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
388 |
SetDParam(0, _cargoc.names_long_s[i] + (waiting==1 ? 0 : 32)); |
0 | 389 |
DrawStringRightAligned(x + 234, y, STR_000A_EN_ROUTE_FROM, 0); |
390 |
y += 10; |
|
391 |
} |
|
392 |
||
393 |
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
|
394 |
SetDParam(0, st->goods[i].enroute_from); |
0 | 395 |
DrawStringRightAligned(x + 234, y, STR_000B, 0); |
396 |
y += 10; |
|
397 |
} |
|
398 |
} |
|
399 |
} while (pos > -5 && ++i != 12); |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
400 |
|
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
817
diff
changeset
|
401 |
if (IsWindowOfPrototype(w, _station_view_widgets)) { |
0 | 402 |
b = _userstring; |
403 |
b[0] = 0x81; |
|
404 |
b[1] = STR_000C_ACCEPTS; |
|
405 |
b[2] = STR_000C_ACCEPTS >> 8; |
|
406 |
b += 3; |
|
407 |
||
408 |
for(i=0; i!=NUM_CARGO; i++) { |
|
487
53248ab68645
(svn r769) Fixed a tiny mistake in the _userstring boundary check. Let's hope I got it right this time.
pasky
parents:
485
diff
changeset
|
409 |
if ((b - (byte *) &_userstring) + 5 > USERSTRING_LEN - 1) |
485
7a7484b85037
(svn r767) Introduce USERSTRING_LEN (128) and try to make sure we don't overflow it anywhere (as long as we keep USERSTRING_LEN above 7 or so).
pasky
parents:
243
diff
changeset
|
410 |
break; |
0 | 411 |
if (st->goods[i].waiting_acceptance & 0x8000) { |
412 |
b[0] = 0x81; |
|
413 |
WRITE_LE_UINT16(b+1, _cargoc.names_s[i]); |
|
414 |
WRITE_LE_UINT16(b+3, 0x202C); |
|
415 |
b += 5; |
|
416 |
} |
|
417 |
} |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
418 |
|
0 | 419 |
if (b == (byte*)&_userstring[3]) { |
420 |
b[0] = 0x81; |
|
421 |
b[1] = STR_00D0_NOTHING; |
|
422 |
b[2] = STR_00D0_NOTHING >> 8; |
|
423 |
b[3] = 0; |
|
424 |
} else { |
|
425 |
b[-2] = 0; |
|
426 |
} |
|
427 |
||
428 |
DrawStringMultiLine(2, 67, STR_SPEC_USERSTRING, 245); |
|
429 |
} else { |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
430 |
|
0 | 431 |
DrawString(2, 67, STR_3034_LOCAL_RATING_OF_TRANSPORT, 0); |
432 |
||
433 |
y = 77; |
|
434 |
for(i=0; i!=NUM_CARGO; i++) { |
|
435 |
if (st->goods[i].enroute_from != 0xFF) { |
|
534
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
436 |
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
|
437 |
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
|
438 |
SetDParam(1, STR_3035_APPALLING + (st->goods[i].rating >> 5)); |
0 | 439 |
DrawString(8, y, STR_303D, 0); |
440 |
y += 10; |
|
441 |
} |
|
442 |
} |
|
443 |
} |
|
444 |
} |
|
445 |
||
446 |
||
447 |
static void StationViewWndProc(Window *w, WindowEvent *e) |
|
448 |
{ |
|
449 |
switch(e->event) { |
|
450 |
case WE_PAINT: |
|
451 |
DrawStationViewWindow(w); |
|
452 |
break; |
|
453 |
||
454 |
case WE_CLICK: |
|
455 |
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
|
456 |
case 7: |
919
544f374ee392
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
893
diff
changeset
|
457 |
ScrollMainWindowToTile(GetStation(w->window_number)->xy); |
0 | 458 |
break; |
459 |
||
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
|
460 |
case 8: |
0 | 461 |
SetWindowDirty(w); |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
462 |
|
0 | 463 |
/* 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
|
464 |
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
|
465 |
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
|
466 |
w->height = 110; |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
817
diff
changeset
|
467 |
} else { |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
817
diff
changeset
|
468 |
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
|
469 |
w->height = 210; |
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
817
diff
changeset
|
470 |
} |
0 | 471 |
|
472 |
SetWindowDirty(w); |
|
473 |
break; |
|
474 |
||
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
|
475 |
case 9: { |
919
544f374ee392
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
893
diff
changeset
|
476 |
Station *st = GetStation(w->window_number); |
534
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
477 |
SetDParam(0, st->town->townnametype); |
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
478 |
SetDParam(1, st->town->townnameparts); |
0 | 479 |
ShowQueryString(st->string_id, STR_3030_RENAME_STATION_LOADING, 31, 180, w->window_class, w->window_number); |
480 |
} break; |
|
588 | 481 |
|
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
|
482 |
case 10: { |
919
544f374ee392
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
893
diff
changeset
|
483 |
const Station *st = GetStation(w->window_number); |
588 | 484 |
ShowPlayerTrains(st->owner, w->window_number); |
485 |
break; |
|
486 |
} |
|
487 |
||
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
|
488 |
case 11: { |
919
544f374ee392
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
893
diff
changeset
|
489 |
const Station *st = GetStation(w->window_number); |
588 | 490 |
ShowPlayerRoadVehicles(st->owner, w->window_number); |
491 |
break; |
|
492 |
} |
|
493 |
||
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
|
494 |
case 12: { |
919
544f374ee392
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
893
diff
changeset
|
495 |
const Station *st = GetStation(w->window_number); |
588 | 496 |
ShowPlayerAircraft(st->owner, w->window_number); |
497 |
break; |
|
498 |
} |
|
499 |
||
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
|
500 |
case 13: { |
919
544f374ee392
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
893
diff
changeset
|
501 |
const Station *st = GetStation(w->window_number); |
588 | 502 |
ShowPlayerShips(st->owner, w->window_number); |
503 |
break; |
|
504 |
} |
|
0 | 505 |
} |
506 |
break; |
|
507 |
||
508 |
case WE_ON_EDIT_TEXT: { |
|
509 |
Station *st; |
|
510 |
byte *b = e->edittext.str; |
|
511 |
if (*b == 0) |
|
512 |
return; |
|
513 |
memcpy(_decode_parameters, b, 32); |
|
514 |
||
919
544f374ee392
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
893
diff
changeset
|
515 |
st = GetStation(w->window_number); |
0 | 516 |
DoCommandP(st->xy, w->window_number, 0, NULL, CMD_RENAME_STATION | CMD_MSG(STR_3031_CAN_T_RENAME_STATION)); |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
517 |
} break; |
588 | 518 |
|
519 |
case WE_DESTROY: { |
|
520 |
WindowNumber wno = |
|
919
544f374ee392
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
893
diff
changeset
|
521 |
(w->window_number << 16) | GetStation(w->window_number)->owner; |
588 | 522 |
|
523 |
DeleteWindowById(WC_TRAINS_LIST, wno); |
|
524 |
DeleteWindowById(WC_ROADVEH_LIST, wno); |
|
525 |
DeleteWindowById(WC_SHIPS_LIST, wno); |
|
526 |
DeleteWindowById(WC_AIRCRAFT_LIST, wno); |
|
527 |
break; |
|
528 |
} |
|
0 | 529 |
} |
530 |
} |
|
531 |
||
532 |
||
533 |
static const WindowDesc _station_view_desc = { |
|
534 |
-1, -1, 249, 110, |
|
535 |
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
|
536 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_STICKY_BUTTON, |
0 | 537 |
_station_view_widgets, |
538 |
StationViewWndProc |
|
539 |
}; |
|
540 |
||
541 |
void ShowStationViewWindow(int station) |
|
542 |
{ |
|
543 |
Window *w; |
|
544 |
byte color; |
|
545 |
||
546 |
w = AllocateWindowDescFront(&_station_view_desc, station); |
|
547 |
if (w) { |
|
919
544f374ee392
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
893
diff
changeset
|
548 |
color = GetStation(w->window_number)->owner; |
0 | 549 |
if (color != 0x10) |
550 |
w->caption_color = color; |
|
551 |
w->vscroll.cap = 5; |
|
552 |
} |
|
553 |
} |