author | truelight |
Thu, 24 Mar 2005 14:43:40 +0000 | |
changeset 1540 | 6eef12dab5bf |
parent 1363 | 775a7ee52369 |
child 1793 | b9a37c98b468 |
permissions | -rw-r--r-- |
0 | 1 |
#include "stdafx.h" |
2 |
#include "ttd.h" |
|
1299
39c06aba09aa
(svn r1803) Move debugging stuff into files of it's own
tron
parents:
1260
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" |
1363
775a7ee52369
(svn r1867) Include tables/sprites.h only in files which need it
tron
parents:
1323
diff
changeset
|
5 |
#include "table/sprites.h" |
507
04b5403aaf6b
(svn r815) Include strings.h only in the files which need it.
tron
parents:
410
diff
changeset
|
6 |
#include "table/strings.h" |
0 | 7 |
#include "town.h" |
8 |
#include "window.h" |
|
9 |
#include "gfx.h" |
|
10 |
#include "viewport.h" |
|
11 |
#include "gui.h" |
|
12 |
#include "command.h" |
|
13 |
#include "player.h" |
|
891
8f020b87e3c6
(svn r1377) -Fix: only a server can rename a town in a MP game
darkvater
parents:
867
diff
changeset
|
14 |
#include "network.h" |
0 | 15 |
|
16 |
static const Widget _town_authority_widgets[] = { |
|
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
821
diff
changeset
|
17 |
{ WWT_TEXTBTN, RESIZE_NONE, 13, 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:
821
diff
changeset
|
18 |
{ WWT_CAPTION, RESIZE_NONE, 13, 11, 316, 0, 13, STR_2022_LOCAL_AUTHORITY, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
821
diff
changeset
|
19 |
{ WWT_IMGBTN, RESIZE_NONE, 13, 0, 316, 14, 105, 0x0, STR_NULL}, |
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:
891
diff
changeset
|
20 |
{ WWT_IMGBTN, RESIZE_NONE, 13, 0, 306, 106, 157, 0x0, STR_2043_LIST_OF_THINGS_TO_DO_AT}, |
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:
891
diff
changeset
|
21 |
{ WWT_SCROLLBAR, RESIZE_NONE, 13, 305, 316, 106, 157, 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:
821
diff
changeset
|
22 |
{ WWT_IMGBTN, RESIZE_NONE, 13, 0, 316, 158, 209, 0x0, STR_NULL}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
821
diff
changeset
|
23 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 13, 0, 316, 210, 221, STR_2042_DO_IT, STR_2044_CARRY_OUT_THE_HIGHLIGHTED}, |
176
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
174
diff
changeset
|
24 |
{ WIDGETS_END}, |
0 | 25 |
}; |
26 |
||
27 |
extern const byte _town_action_costs[8]; |
|
28 |
extern void DrawPlayerIcon(int p, int x, int y); |
|
29 |
||
30 |
static uint GetMaskOfTownActions(int *nump, Town *t) |
|
31 |
{ |
|
32 |
int32 avail, ref; |
|
33 |
int i, num; |
|
34 |
uint avail_buttons = 0x7F; // by default all buttons except bribe are enabled. |
|
35 |
uint buttons; |
|
36 |
||
1 | 37 |
if (_local_player != OWNER_SPECTATOR) { |
0 | 38 |
// bribe option enabled? |
39 |
if (_patches.bribe) { |
|
40 |
// if unwanted, disable everything. |
|
41 |
if (t->unwanted[_local_player]) { |
|
42 |
avail_buttons = 0; |
|
43 |
} else if (t->ratings[_local_player] < 600) |
|
44 |
avail_buttons |= (1 << 7); // only bribe if less than excellent |
|
45 |
} |
|
46 |
||
47 |
// Things worth more than this are not shown |
|
48 |
avail = DEREF_PLAYER(_local_player)->player_money + _price.station_value * 200; |
|
49 |
ref = _price.build_industry >> 8; |
|
50 |
||
51 |
for(i=0,buttons=0,num=0; i != lengthof(_town_action_costs); i++,avail_buttons>>=1) { |
|
52 |
if (avail_buttons&1 && avail >= _town_action_costs[i] * ref) { |
|
53 |
SETBIT(buttons, i); |
|
54 |
num++; |
|
55 |
} |
|
56 |
} |
|
57 |
||
58 |
// Disable build statue if already built |
|
59 |
if(HASBIT(t->statues, _local_player)) |
|
60 |
{ |
|
61 |
CLRBIT(buttons, 4); |
|
62 |
num--; |
|
63 |
} |
|
64 |
||
65 |
} else { |
|
66 |
// no actions available for spectator |
|
67 |
buttons = 0; |
|
68 |
num = 0; |
|
69 |
} |
|
70 |
||
71 |
if (nump) *nump = num; |
|
72 |
return buttons; |
|
73 |
} |
|
74 |
||
75 |
static int GetNthSetBit(uint32 bits, int n) |
|
76 |
{ |
|
77 |
int i = 0; |
|
78 |
if (n >= 0) { |
|
79 |
do { |
|
80 |
if (bits&1 && --n < 0) return i; |
|
81 |
i++; |
|
82 |
} while (bits>>=1); |
|
83 |
} |
|
84 |
return -1; |
|
85 |
} |
|
86 |
||
87 |
static void TownAuthorityWndProc(Window *w, WindowEvent *e) |
|
88 |
{ |
|
89 |
uint buttons; |
|
90 |
int numact; |
|
919
544f374ee392
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
893
diff
changeset
|
91 |
Town *t = GetTown(w->window_number); |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
92 |
|
0 | 93 |
switch(e->event) { |
94 |
case WE_PAINT: |
|
95 |
buttons = GetMaskOfTownActions(&numact, t); |
|
96 |
SetVScrollCount(w, numact + 1); |
|
97 |
||
98 |
if (WP(w,def_d).data_1 != -1 && !HASBIT(buttons, WP(w,def_d).data_1)) |
|
99 |
WP(w,def_d).data_1 = -1; |
|
100 |
||
101 |
w->disabled_state = (WP(w,def_d).data_1 == -1) ? (1 << 6) : 0; |
|
102 |
||
103 |
{ |
|
104 |
int y; |
|
105 |
Player *p; |
|
106 |
int r; |
|
107 |
StringID str; |
|
108 |
||
534
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
109 |
SetDParam(0, w->window_number); |
0 | 110 |
DrawWindowWidgets(w); |
111 |
||
112 |
DrawString(2, 15, STR_2023_TRANSPORT_COMPANY_RATINGS, 0); |
|
122
6e56237f536c
(svn r123) Fixed some indentions... btw credits for the last commit go to Celestar
dominik
parents:
121
diff
changeset
|
113 |
|
0 | 114 |
// Draw list of players |
115 |
y = 25; |
|
116 |
FOR_ALL_PLAYERS(p) { |
|
121
c2f18f4d8be1
(svn r122) Change: exclusive transport rights are now stored per town instead of per station
dominik
parents:
69
diff
changeset
|
117 |
if (p->is_active && (HASBIT(t->have_ratings, p->index) || t->exclusivity==p->index)) { |
125 | 118 |
DrawPlayerIcon(p->index, 2, y); |
121
c2f18f4d8be1
(svn r122) Change: exclusive transport rights are now stored per town instead of per station
dominik
parents:
69
diff
changeset
|
119 |
|
534
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
120 |
SetDParam(0, p->name_1); |
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
121 |
SetDParam(1, p->name_2); |
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
122 |
SetDParam(2, GetPlayerNameString(p->index, 3)); |
0 | 123 |
|
124 |
r = t->ratings[p->index]; |
|
1005 | 125 |
(str = STR_3035_APPALLING, r <= RATING_APPALLING) || // Apalling |
126 |
(str++, r <= RATING_VERYPOOR) || // Very Poor |
|
127 |
(str++, r <= RATING_POOR) || // Poor |
|
128 |
(str++, r <= RATING_MEDIOCRE) || // Mediocore |
|
129 |
(str++, r <= RATING_GOOD) || // Good |
|
130 |
(str++, r <= RATING_VERYGOOD) || // Very Good |
|
131 |
(str++, r <= RATING_EXCELLENT) || // Excellent |
|
0 | 132 |
(str++, true); // Outstanding |
133 |
||
16
5ee72235b403
(svn r17) -Fix Player window fixes, Getstring id0 fixes, Finances window is now ok
darkvater
parents:
2
diff
changeset
|
134 |
/* WARNING ugly hack! |
5ee72235b403
(svn r17) -Fix Player window fixes, Getstring id0 fixes, Finances window is now ok
darkvater
parents:
2
diff
changeset
|
135 |
GetPlayerNameString sets up (Player #) if the player is human in an extra DPARAM16 |
5ee72235b403
(svn r17) -Fix Player window fixes, Getstring id0 fixes, Finances window is now ok
darkvater
parents:
2
diff
changeset
|
136 |
It seems that if player is non-human, nothing is set up, so param is 0. GetString doesn't like |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
137 |
that because there is another param after it. |
16
5ee72235b403
(svn r17) -Fix Player window fixes, Getstring id0 fixes, Finances window is now ok
darkvater
parents:
2
diff
changeset
|
138 |
So we'll just shift the rating one back if player is AI and all is fine |
5ee72235b403
(svn r17) -Fix Player window fixes, Getstring id0 fixes, Finances window is now ok
darkvater
parents:
2
diff
changeset
|
139 |
*/ |
534
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
140 |
SetDParam((IS_HUMAN_PLAYER(p->index) ? 4 : 3), str); |
246
de179e5f7c3d
(svn r247) -Fix: Town exclusivity was not shown in town-window because stringformat ({YELLOW}) overrode colour-code. Now the exclusive player gets a red icon in front of its name
darkvater
parents:
222
diff
changeset
|
141 |
if (t->exclusivity == p->index) // red icon for player with exclusive rights |
579
e977d17c89b1
(svn r999) New icons for the network interface, newgrf gui and the tiny euro
dominik
parents:
534
diff
changeset
|
142 |
DrawSprite((SPR_BLOT) | 0x30b8000, 18, y); |
246
de179e5f7c3d
(svn r247) -Fix: Town exclusivity was not shown in town-window because stringformat ({YELLOW}) overrode colour-code. Now the exclusive player gets a red icon in front of its name
darkvater
parents:
222
diff
changeset
|
143 |
|
de179e5f7c3d
(svn r247) -Fix: Town exclusivity was not shown in town-window because stringformat ({YELLOW}) overrode colour-code. Now the exclusive player gets a red icon in front of its name
darkvater
parents:
222
diff
changeset
|
144 |
DrawString(28, y, STR_2024, 0); |
0 | 145 |
y+=10; |
146 |
} |
|
147 |
} |
|
148 |
} |
|
149 |
||
150 |
// Draw actions list |
|
151 |
{ |
|
152 |
int y = 107, i; |
|
153 |
int pos = w->vscroll.pos; |
|
154 |
||
155 |
if (--pos < 0) { |
|
156 |
DrawString(2, y, STR_2045_ACTIONS_AVAILABLE, 0); |
|
157 |
y+=10; |
|
158 |
} |
|
159 |
for(i=0; buttons; i++,buttons>>=1) { |
|
160 |
if (pos <= -5) |
|
161 |
break; |
|
162 |
||
163 |
if (buttons&1 && --pos < 0) { |
|
164 |
DrawString(3, y, STR_2046_SMALL_ADVERTISING_CAMPAIGN + i, 6); |
|
165 |
y += 10; |
|
166 |
} |
|
167 |
} |
|
168 |
} |
|
122
6e56237f536c
(svn r123) Fixed some indentions... btw credits for the last commit go to Celestar
dominik
parents:
121
diff
changeset
|
169 |
|
0 | 170 |
{ |
171 |
int i; |
|
172 |
if ((i=WP(w,def_d).data_1) != -1) { |
|
534
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
173 |
SetDParam(1, (_price.build_industry >> 8) * _town_action_costs[i]); |
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
174 |
SetDParam(0, STR_2046_SMALL_ADVERTISING_CAMPAIGN + i); |
0 | 175 |
DrawStringMultiLine(2, 159, STR_204D_INITIATE_A_SMALL_LOCAL + i, 313); |
176 |
} |
|
177 |
} |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
178 |
|
0 | 179 |
break; |
180 |
||
181 |
case WE_CLICK: |
|
182 |
switch(e->click.widget) { |
|
183 |
case 3: { /* listbox */ |
|
184 |
int y = (e->click.pt.y - 0x6B) / 10; |
|
185 |
if (!IS_INT_INSIDE(y, 0, 5)) |
|
186 |
return; |
|
187 |
||
188 |
y = GetNthSetBit(GetMaskOfTownActions(NULL, t), y + w->vscroll.pos - 1); |
|
189 |
if (y >= 0) { |
|
190 |
WP(w,def_d).data_1 = y; |
|
191 |
SetWindowDirty(w); |
|
192 |
} |
|
193 |
break; |
|
194 |
} |
|
195 |
||
196 |
case 6: { /* carry out the action */ |
|
197 |
DoCommandP(t->xy, w->window_number, WP(w,def_d).data_1, NULL, CMD_DO_TOWN_ACTION | CMD_MSG(STR_2054_CAN_T_DO_THIS)); |
|
198 |
break; |
|
199 |
} |
|
200 |
} |
|
201 |
break; |
|
202 |
||
203 |
case WE_4: |
|
204 |
SetWindowDirty(w); |
|
205 |
break; |
|
206 |
} |
|
207 |
} |
|
208 |
||
209 |
static const WindowDesc _town_authority_desc = { |
|
210 |
-1, -1, 317, 222, |
|
211 |
WC_TOWN_AUTHORITY,0, |
|
212 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS, |
|
213 |
_town_authority_widgets, |
|
214 |
TownAuthorityWndProc |
|
215 |
}; |
|
216 |
||
410 | 217 |
static void ShowTownAuthorityWindow(uint town) |
0 | 218 |
{ |
219 |
Window *w; |
|
220 |
||
221 |
w = AllocateWindowDescFront(&_town_authority_desc, town); |
|
222 |
if (w) { |
|
223 |
w->vscroll.cap = 5; |
|
224 |
WP(w,def_d).data_1 = -1; |
|
225 |
} |
|
226 |
} |
|
227 |
||
228 |
static void TownViewWndProc(Window *w, WindowEvent *e) |
|
229 |
{ |
|
919
544f374ee392
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
893
diff
changeset
|
230 |
Town *t = GetTown(w->window_number); |
0 | 231 |
|
232 |
switch(e->event) { |
|
233 |
case WE_PAINT: |
|
891
8f020b87e3c6
(svn r1377) -Fix: only a server can rename a town in a MP game
darkvater
parents:
867
diff
changeset
|
234 |
// disable renaming town in network games if you are not the server |
8f020b87e3c6
(svn r1377) -Fix: only a server can rename a town in a MP game
darkvater
parents:
867
diff
changeset
|
235 |
if (_networking && !_network_server) SETBIT(w->disabled_state, 8); |
8f020b87e3c6
(svn r1377) -Fix: only a server can rename a town in a MP game
darkvater
parents:
867
diff
changeset
|
236 |
|
534
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
237 |
SetDParam(0, t->index); |
0 | 238 |
DrawWindowWidgets(w); |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
239 |
|
534
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
240 |
SetDParam(0, t->population); |
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
241 |
SetDParam(1, t->num_houses); |
0 | 242 |
DrawString(2,107,STR_2006_POPULATION,0); |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
243 |
|
534
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
244 |
SetDParam(0, t->act_pass); |
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
245 |
SetDParam(1, t->max_pass); |
0 | 246 |
DrawString(2,117,STR_200D_PASSENGERS_LAST_MONTH_MAX,0); |
247 |
||
534
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
248 |
SetDParam(0, t->act_mail); |
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
249 |
SetDParam(1, t->max_mail); |
0 | 250 |
DrawString(2,127,STR_200E_MAIL_LAST_MONTH_MAX,0); |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
251 |
|
0 | 252 |
DrawWindowViewport(w); |
253 |
break; |
|
254 |
||
255 |
case WE_CLICK: |
|
256 |
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:
727
diff
changeset
|
257 |
case 6: /* scroll to location */ |
0 | 258 |
ScrollMainWindowToTile(t->xy); |
259 |
break; |
|
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:
727
diff
changeset
|
260 |
case 7: /* town authority */ |
0 | 261 |
ShowTownAuthorityWindow(w->window_number); |
262 |
break; |
|
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:
727
diff
changeset
|
263 |
case 8: /* rename */ |
534
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
264 |
SetDParam(0, t->townnameparts); |
0 | 265 |
ShowQueryString(t->townnametype, STR_2007_RENAME_TOWN, 31, 130, w->window_class, w->window_number); |
266 |
break; |
|
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:
727
diff
changeset
|
267 |
case 9: /* expand town */ |
0 | 268 |
ExpandTown(t); |
269 |
break; |
|
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:
727
diff
changeset
|
270 |
case 10: /* delete town */ |
0 | 271 |
DeleteTown(t); |
272 |
break; |
|
273 |
} |
|
274 |
break; |
|
275 |
||
276 |
case WE_ON_EDIT_TEXT: { |
|
1323
bac2e38e8b60
(svn r1827) Next iteration of the byte -> char transition: some string drawing functions and buffers
tron
parents:
1309
diff
changeset
|
277 |
const char *b = e->edittext.str; |
0 | 278 |
if (*b == 0) |
279 |
return; |
|
280 |
memcpy(_decode_parameters, b, 32); |
|
281 |
DoCommandP(0, w->window_number, 0, NULL, CMD_RENAME_TOWN | CMD_MSG(STR_2008_CAN_T_RENAME_TOWN)); |
|
282 |
} break; |
|
283 |
} |
|
284 |
} |
|
285 |
||
286 |
||
287 |
static const Widget _town_view_widgets[] = { |
|
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
821
diff
changeset
|
288 |
{ WWT_TEXTBTN, RESIZE_NONE, 13, 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:
821
diff
changeset
|
289 |
{ WWT_CAPTION, RESIZE_NONE, 13, 11, 247, 0, 13, STR_2005, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
821
diff
changeset
|
290 |
{ WWT_STICKYBOX, RESIZE_NONE, 13, 248, 259, 0, 13, 0x0, STR_STICKY_BUTTON}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
821
diff
changeset
|
291 |
{ WWT_IMGBTN, RESIZE_NONE, 13, 0, 259, 14, 105, 0x0, STR_NULL}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
821
diff
changeset
|
292 |
{ WWT_6, RESIZE_NONE, 13, 2, 257, 16, 103, 0x0, STR_NULL}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
821
diff
changeset
|
293 |
{ WWT_IMGBTN, RESIZE_NONE, 13, 0, 259, 106, 137, 0x0, STR_NULL}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
821
diff
changeset
|
294 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 13, 0, 85, 138, 149, STR_00E4_LOCATION, STR_200B_CENTER_THE_MAIN_VIEW_ON}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
821
diff
changeset
|
295 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 13, 86, 171, 138, 149, STR_2020_LOCAL_AUTHORITY,STR_2021_SHOW_INFORMATION_ON_LOCAL}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
821
diff
changeset
|
296 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 13, 172, 259, 138, 149, STR_0130_RENAME, STR_200C_CHANGE_TOWN_NAME}, |
176
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
174
diff
changeset
|
297 |
{ WIDGETS_END}, |
0 | 298 |
}; |
299 |
||
300 |
static const WindowDesc _town_view_desc = { |
|
301 |
-1, -1, 260, 150, |
|
302 |
WC_TOWN_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:
727
diff
changeset
|
303 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_STICKY_BUTTON, |
0 | 304 |
_town_view_widgets, |
305 |
TownViewWndProc |
|
306 |
}; |
|
307 |
||
308 |
static const Widget _town_view_scen_widgets[] = { |
|
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
821
diff
changeset
|
309 |
{ WWT_TEXTBTN, RESIZE_NONE, 13, 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:
821
diff
changeset
|
310 |
{ WWT_CAPTION, RESIZE_NONE, 13, 11, 172, 0, 13, STR_2005, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
821
diff
changeset
|
311 |
{ WWT_STICKYBOX, RESIZE_NONE, 13, 248, 259, 0, 13, 0x0, STR_STICKY_BUTTON}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
821
diff
changeset
|
312 |
{ WWT_IMGBTN, RESIZE_NONE, 13, 0, 259, 14, 105, 0x0, STR_NULL}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
821
diff
changeset
|
313 |
{ WWT_6, RESIZE_NONE, 13, 2, 257, 16, 103, 0x0, STR_NULL}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
821
diff
changeset
|
314 |
{ WWT_IMGBTN, RESIZE_NONE, 13, 0, 259, 106, 137, 0x0, STR_NULL}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
821
diff
changeset
|
315 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 13, 0, 85, 138, 149, STR_00E4_LOCATION, STR_200B_CENTER_THE_MAIN_VIEW_ON}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
821
diff
changeset
|
316 |
{ 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:
821
diff
changeset
|
317 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 13, 173, 247, 0, 13, STR_0130_RENAME, STR_200C_CHANGE_TOWN_NAME}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
821
diff
changeset
|
318 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 13, 86, 171, 138, 149, STR_023C_EXPAND, STR_023B_INCREASE_SIZE_OF_TOWN}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
821
diff
changeset
|
319 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 13, 172, 259, 138, 149, STR_0290_DELETE, STR_0291_DELETE_THIS_TOWN_COMPLETELY}, |
176
84990c4b9212
(svn r177) -Fix: padded out Widget code to solve warnings on C99 compiler (Tron)
darkvater
parents:
174
diff
changeset
|
320 |
{ WIDGETS_END}, |
0 | 321 |
}; |
322 |
||
323 |
static const WindowDesc _town_view_scen_desc = { |
|
324 |
-1, -1, 260, 150, |
|
325 |
WC_TOWN_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:
727
diff
changeset
|
326 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_STICKY_BUTTON, |
0 | 327 |
_town_view_scen_widgets, |
328 |
TownViewWndProc |
|
329 |
}; |
|
330 |
||
331 |
void ShowTownViewWindow(uint town) |
|
332 |
{ |
|
333 |
Window *w; |
|
334 |
Town *t; |
|
335 |
||
336 |
if (_game_mode != GM_EDITOR) { |
|
337 |
w = AllocateWindowDescFront(&_town_view_desc, town); |
|
338 |
} else { |
|
339 |
w = AllocateWindowDescFront(&_town_view_scen_desc, town); |
|
340 |
} |
|
341 |
||
342 |
if (w) { |
|
343 |
w->flags4 |= WF_DISABLE_VP_SCROLL; |
|
919
544f374ee392
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
893
diff
changeset
|
344 |
t = GetTown(w->window_number); |
0 | 345 |
AssignWindowViewport(w, 3, 17, 0xFE, 0x56, t->xy, 1); |
346 |
} |
|
347 |
} |
|
348 |
||
349 |
static const Widget _town_directory_widgets[] = { |
|
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
821
diff
changeset
|
350 |
{ WWT_TEXTBTN, RESIZE_NONE, 13, 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:
821
diff
changeset
|
351 |
{ WWT_CAPTION, RESIZE_NONE, 13, 11, 195, 0, 13, STR_2000_TOWNS, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
821
diff
changeset
|
352 |
{ WWT_STICKYBOX, RESIZE_NONE, 13, 196, 207, 0, 13, 0x0, STR_STICKY_BUTTON}, |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
821
diff
changeset
|
353 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 13, 0, 98, 14, 25, STR_SORT_BY_NAME, STR_SORT_ORDER_TIP}, |
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:
891
diff
changeset
|
354 |
{ WWT_PUSHTXTBTN, RESIZE_NONE, 13, 99, 195, 14, 25, STR_SORT_BY_POPULATION, STR_SORT_ORDER_TIP}, |
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:
891
diff
changeset
|
355 |
{ WWT_IMGBTN, RESIZE_BOTTOM, 13, 0, 195, 26, 189, 0x0, STR_200A_TOWN_NAMES_CLICK_ON_NAME}, |
1080
23797dda4792
(svn r1581) Added a display for the total map population to the town display (Jango)
celestar
parents:
1005
diff
changeset
|
356 |
{ WWT_SCROLLBAR, RESIZE_BOTTOM, 13, 196, 207, 14, 189, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST}, |
23797dda4792
(svn r1581) Added a display for the total map population to the town display (Jango)
celestar
parents:
1005
diff
changeset
|
357 |
{ WWT_PANEL, RESIZE_TB, 13, 0, 195, 190, 201, 0x0, STR_NULL}, |
23797dda4792
(svn r1581) Added a display for the total map population to the town display (Jango)
celestar
parents:
1005
diff
changeset
|
358 |
{ WWT_RESIZEBOX, RESIZE_TB, 13, 196, 207, 190, 201, 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
|
359 |
{ WIDGETS_END}, |
0 | 360 |
}; |
361 |
||
362 |
||
363 |
// used to get a sorted list of the towns |
|
364 |
static uint _num_town_sort; |
|
365 |
||
366 |
static char _bufcache[64]; |
|
821
60524daa442c
(svn r1292) -Codechange: also updated the town/industry sort-list to be uint16 compatible
truelight
parents:
758
diff
changeset
|
367 |
static uint16 _last_town_idx; |
0 | 368 |
|
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:
125
diff
changeset
|
369 |
static int CDECL TownNameSorter(const void *a, const void *b) |
0 | 370 |
{ |
371 |
char buf1[64]; |
|
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
|
372 |
const Town *t; |
1260
632f63689178
(svn r1764) -Add: dynamic towns, you can now have up to 64k towns (let me know when
truelight
parents:
1093
diff
changeset
|
373 |
uint16 val; |
0 | 374 |
int r; |
375 |
||
919
544f374ee392
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
893
diff
changeset
|
376 |
t = GetTown(*(const uint16*)a); |
534
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
377 |
SetDParam(0, t->townnameparts); |
0 | 378 |
GetString(buf1, t->townnametype); |
379 |
||
1260
632f63689178
(svn r1764) -Add: dynamic towns, you can now have up to 64k towns (let me know when
truelight
parents:
1093
diff
changeset
|
380 |
/* If 'b' is the same town as in the last round, use the cached value |
632f63689178
(svn r1764) -Add: dynamic towns, you can now have up to 64k towns (let me know when
truelight
parents:
1093
diff
changeset
|
381 |
* We do this to speed stuff up ('b' is called with the same value a lot of |
632f63689178
(svn r1764) -Add: dynamic towns, you can now have up to 64k towns (let me know when
truelight
parents:
1093
diff
changeset
|
382 |
* times after eachother) */ |
632f63689178
(svn r1764) -Add: dynamic towns, you can now have up to 64k towns (let me know when
truelight
parents:
1093
diff
changeset
|
383 |
val = *(const uint16*)b; |
632f63689178
(svn r1764) -Add: dynamic towns, you can now have up to 64k towns (let me know when
truelight
parents:
1093
diff
changeset
|
384 |
if (val != _last_town_idx) { |
0 | 385 |
_last_town_idx = val; |
919
544f374ee392
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
893
diff
changeset
|
386 |
t = GetTown(val); |
534
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
387 |
SetDParam(0, t->townnameparts); |
0 | 388 |
GetString(_bufcache, t->townnametype); |
389 |
} |
|
390 |
||
391 |
r = strcmp(buf1, _bufcache); |
|
392 |
if (_town_sort_order & 1) r = -r; |
|
393 |
return r; |
|
394 |
} |
|
395 |
||
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:
125
diff
changeset
|
396 |
static int CDECL TownPopSorter(const void *a, const void *b) |
0 | 397 |
{ |
919
544f374ee392
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
893
diff
changeset
|
398 |
const Town *ta = GetTown(*(const uint16*)a); |
544f374ee392
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
893
diff
changeset
|
399 |
const Town *tb = GetTown(*(const uint16*)b); |
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:
125
diff
changeset
|
400 |
int r = ta->population - tb->population; |
0 | 401 |
if (_town_sort_order & 1) r = -r; |
402 |
return r; |
|
403 |
} |
|
404 |
||
1093
4fdc46eaf423
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1080
diff
changeset
|
405 |
static void MakeSortedTownList(void) |
0 | 406 |
{ |
407 |
Town *t; |
|
408 |
int n = 0; |
|
919
544f374ee392
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
893
diff
changeset
|
409 |
|
544f374ee392
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
893
diff
changeset
|
410 |
/* Create array for sorting */ |
1260
632f63689178
(svn r1764) -Add: dynamic towns, you can now have up to 64k towns (let me know when
truelight
parents:
1093
diff
changeset
|
411 |
_town_sort = realloc(_town_sort, GetTownPoolSize() * sizeof(_town_sort[0])); |
919
544f374ee392
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
893
diff
changeset
|
412 |
if (_town_sort == NULL) |
544f374ee392
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
893
diff
changeset
|
413 |
error("Could not allocate memory for the town-sorting-list"); |
544f374ee392
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
893
diff
changeset
|
414 |
|
821
60524daa442c
(svn r1292) -Codechange: also updated the town/industry sort-list to be uint16 compatible
truelight
parents:
758
diff
changeset
|
415 |
FOR_ALL_TOWNS(t) |
1260
632f63689178
(svn r1764) -Add: dynamic towns, you can now have up to 64k towns (let me know when
truelight
parents:
1093
diff
changeset
|
416 |
if (t->xy) |
821
60524daa442c
(svn r1292) -Codechange: also updated the town/industry sort-list to be uint16 compatible
truelight
parents:
758
diff
changeset
|
417 |
_town_sort[n++] = t->index; |
60524daa442c
(svn r1292) -Codechange: also updated the town/industry sort-list to be uint16 compatible
truelight
parents:
758
diff
changeset
|
418 |
|
0 | 419 |
_num_town_sort = n; |
420 |
||
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
|
421 |
_last_town_idx = 0; // used for "cache" |
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:
125
diff
changeset
|
422 |
qsort(_town_sort, n, sizeof(_town_sort[0]), _town_sort_order & 2 ? TownPopSorter : TownNameSorter); |
65
f9f866bc609c
(svn r66) -Fix Station list updated on station deletion/station rename
darkvater
parents:
16
diff
changeset
|
423 |
|
69 | 424 |
DEBUG(misc, 1) ("Resorting Towns list..."); |
0 | 425 |
} |
426 |
||
427 |
||
428 |
static void TownDirectoryWndProc(Window *w, WindowEvent *e) |
|
429 |
{ |
|
430 |
switch(e->event) { |
|
431 |
case WE_PAINT: { |
|
432 |
||
433 |
if (_town_sort_dirty) { |
|
434 |
_town_sort_dirty = false; |
|
435 |
MakeSortedTownList(); |
|
436 |
} |
|
437 |
||
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
|
438 |
SetVScrollCount(w, _num_town_sort); |
0 | 439 |
|
440 |
DrawWindowWidgets(w); |
|
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
|
441 |
DoDrawString(_town_sort_order & 1 ? "\xAA" : "\xA0", (_town_sort_order <= 1) ? 88 : 187, 15, 0x10); |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
442 |
|
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
|
443 |
{ |
bd79fb899824
(svn r175) -Fix: [1023771] inconsistent/missing stations in station list. Forgot to change owner-sort after changing function.
darkvater
parents:
164
diff
changeset
|
444 |
Town *t; |
bd79fb899824
(svn r175) -Fix: [1023771] inconsistent/missing stations in station list. Forgot to change owner-sort after changing function.
darkvater
parents:
164
diff
changeset
|
445 |
int n = 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
|
446 |
uint16 i = 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
|
447 |
int y = 28; |
0 | 448 |
|
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
|
449 |
while (i < _num_town_sort) { |
919
544f374ee392
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
893
diff
changeset
|
450 |
t = GetTown(_town_sort[i]); |
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
|
451 |
|
bd79fb899824
(svn r175) -Fix: [1023771] inconsistent/missing stations in station list. Forgot to change owner-sort after changing function.
darkvater
parents:
164
diff
changeset
|
452 |
assert(t->xy); |
bd79fb899824
(svn r175) -Fix: [1023771] inconsistent/missing stations in station list. Forgot to change owner-sort after changing function.
darkvater
parents:
164
diff
changeset
|
453 |
|
534
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
454 |
SetDParam(0, t->index); |
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
455 |
SetDParam(1, t->population); |
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
|
456 |
DrawString(2, y, STR_2057, 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
|
457 |
|
bd79fb899824
(svn r175) -Fix: [1023771] inconsistent/missing stations in station list. Forgot to change owner-sort after changing function.
darkvater
parents:
164
diff
changeset
|
458 |
y += 10; |
bd79fb899824
(svn r175) -Fix: [1023771] inconsistent/missing stations in station list. Forgot to change owner-sort after changing function.
darkvater
parents:
164
diff
changeset
|
459 |
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
|
460 |
if (++n == w->vscroll.cap) { break;} // max number of towns in 1 window |
bd79fb899824
(svn r175) -Fix: [1023771] inconsistent/missing stations in station list. Forgot to change owner-sort after changing function.
darkvater
parents:
164
diff
changeset
|
461 |
} |
1080
23797dda4792
(svn r1581) Added a display for the total map population to the town display (Jango)
celestar
parents:
1005
diff
changeset
|
462 |
SetDParam(0, GetWorldPopulation()); |
23797dda4792
(svn r1581) Added a display for the total map population to the town display (Jango)
celestar
parents:
1005
diff
changeset
|
463 |
DrawString(3, w->height - 12 + 2, STR_TOWN_POPULATION, 0); |
0 | 464 |
} |
465 |
} break; |
|
466 |
||
467 |
case WE_CLICK: |
|
468 |
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:
727
diff
changeset
|
469 |
case 3: { /* Sort by Name ascending/descending */ |
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
|
470 |
_town_sort_order = (_town_sort_order == 0) ? 1 : 0; |
0 | 471 |
_town_sort_dirty = true; |
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:
727
diff
changeset
|
475 |
case 4: { /* Sort by Population ascending/descending */ |
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
|
476 |
_town_sort_order = (_town_sort_order == 2) ? 3 : 2; |
0 | 477 |
_town_sort_dirty = true; |
478 |
SetWindowDirty(w); |
|
479 |
} break; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
480 |
|
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:
727
diff
changeset
|
481 |
case 5: { /* Click on Town Matrix */ |
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
|
482 |
uint16 id_v = (e->click.pt.y - 28) / 10; |
0 | 483 |
|
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
|
484 |
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
|
485 |
|
bd79fb899824
(svn r175) -Fix: [1023771] inconsistent/missing stations in station list. Forgot to change owner-sort after changing function.
darkvater
parents:
164
diff
changeset
|
486 |
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
|
487 |
|
bd79fb899824
(svn r175) -Fix: [1023771] inconsistent/missing stations in station list. Forgot to change owner-sort after changing function.
darkvater
parents:
164
diff
changeset
|
488 |
if (id_v >= _num_town_sort) { return;} // click out of town 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
|
489 |
|
bd79fb899824
(svn r175) -Fix: [1023771] inconsistent/missing stations in station list. Forgot to change owner-sort after changing function.
darkvater
parents:
164
diff
changeset
|
490 |
{ |
919
544f374ee392
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
893
diff
changeset
|
491 |
Town *t = GetTown(_town_sort[id_v]); |
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
|
492 |
assert(t->xy); |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
493 |
|
0 | 494 |
ScrollMainWindowToTile(t->xy); |
495 |
} |
|
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
|
496 |
} break; |
0 | 497 |
} |
498 |
break; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
499 |
|
0 | 500 |
case WE_4: |
501 |
SetWindowDirty(w); |
|
502 |
break; |
|
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
821
diff
changeset
|
503 |
|
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
821
diff
changeset
|
504 |
case WE_RESIZE: |
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
821
diff
changeset
|
505 |
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:
821
diff
changeset
|
506 |
break; |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
176
diff
changeset
|
507 |
} |
0 | 508 |
} |
509 |
||
510 |
static const WindowDesc _town_directory_desc = { |
|
1080
23797dda4792
(svn r1581) Added a display for the total map population to the town display (Jango)
celestar
parents:
1005
diff
changeset
|
511 |
-1, -1, 208, 202, |
0 | 512 |
WC_TOWN_DIRECTORY,0, |
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
821
diff
changeset
|
513 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_STICKY_BUTTON | WDF_RESIZABLE, |
0 | 514 |
_town_directory_widgets, |
515 |
TownDirectoryWndProc |
|
516 |
}; |
|
517 |
||
518 |
||
1093
4fdc46eaf423
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1080
diff
changeset
|
519 |
void ShowTownDirectory(void) |
0 | 520 |
{ |
521 |
Window *w; |
|
522 |
||
523 |
w = AllocateWindowDescFront(&_town_directory_desc, 0); |
|
524 |
if (w) { |
|
525 |
w->vscroll.cap = 16; |
|
867
dffd33233237
(svn r1348) -Feature: resizable windows. Read the comment in window.h to find out
truelight
parents:
821
diff
changeset
|
526 |
w->resize.step_height = 10; |
1080
23797dda4792
(svn r1581) Added a display for the total map population to the town display (Jango)
celestar
parents:
1005
diff
changeset
|
527 |
w->resize.height = w->height - 10 * 6; // minimum of 10 items in the list, each item 10 high |
0 | 528 |
} |
529 |
} |
|
530 |
||
531 |