branch | NewGRF_ports |
changeset 6719 | 4cc327ad39d5 |
parent 6573 | 7624f942237f |
child 6720 | 35756db7e577 |
6718:5a8b295aa345 | 6719:4cc327ad39d5 |
---|---|
1 /* $Id$ */ |
1 /* $Id$ */ |
2 |
|
3 /** @file town_gui.cpp */ |
|
2 |
4 |
3 #include "stdafx.h" |
5 #include "stdafx.h" |
4 #include "openttd.h" |
6 #include "openttd.h" |
5 #include "debug.h" |
7 #include "debug.h" |
6 #include "functions.h" |
8 #include "functions.h" |
30 }; |
32 }; |
31 |
33 |
32 extern const byte _town_action_costs[8]; |
34 extern const byte _town_action_costs[8]; |
33 |
35 |
34 /** Get a list of available actions to do at a town. |
36 /** Get a list of available actions to do at a town. |
35 * @param *nump if not NULL add put the number of available actions in it |
37 * @param nump if not NULL add put the number of available actions in it |
36 * @param pid the player that is querying the town |
38 * @param pid the player that is querying the town |
37 * @param *t the town that is queried |
39 * @param t the town that is queried |
38 * @return bitmasked value of enabled actions |
40 * @return bitmasked value of enabled actions |
39 */ |
41 */ |
40 uint GetMaskOfTownActions(int *nump, PlayerID pid, const Town *t) |
42 uint GetMaskOfTownActions(int *nump, PlayerID pid, const Town *t) |
41 { |
43 { |
42 int32 avail, ref; |
44 int32 avail, ref; |
45 uint buttons = 0; |
47 uint buttons = 0; |
46 |
48 |
47 if (pid != PLAYER_SPECTATOR) { |
49 if (pid != PLAYER_SPECTATOR) { |
48 uint i; |
50 uint i; |
49 |
51 |
50 // bribe option enabled? |
52 /* bribe option enabled? */ |
51 if (_patches.bribe) { |
53 if (_patches.bribe) { |
52 // if unwanted, disable everything. |
54 /* if unwanted, disable everything. */ |
53 if (t->unwanted[pid]) { |
55 if (t->unwanted[pid]) { |
54 avail_buttons = 0; |
56 avail_buttons = 0; |
55 } else if (t->ratings[pid] < RATING_BRIBE_MAXIMUM) { |
57 } else if (t->ratings[pid] < RATING_BRIBE_MAXIMUM) { |
56 SETBIT(avail_buttons, 7); // Allow bribing |
58 SETBIT(avail_buttons, 7); // Allow bribing |
57 } |
59 } |
58 } |
60 } |
59 |
61 |
60 // Things worth more than this are not shown |
62 /* Things worth more than this are not shown */ |
61 avail = GetPlayer(pid)->player_money + _price.station_value * 200; |
63 avail = GetPlayer(pid)->player_money + _price.station_value * 200; |
62 ref = _price.build_industry >> 8; |
64 ref = _price.build_industry >> 8; |
63 |
65 |
64 for (i = 0; i != lengthof(_town_action_costs); i++, avail_buttons >>= 1) { |
66 for (i = 0; i != lengthof(_town_action_costs); i++, avail_buttons >>= 1) { |
65 if (HASBIT(avail_buttons, 0) && avail >= _town_action_costs[i] * ref) { |
67 if (HASBIT(avail_buttons, 0) && avail >= _town_action_costs[i] * ref) { |
117 SetDParam(0, w->window_number); |
119 SetDParam(0, w->window_number); |
118 DrawWindowWidgets(w); |
120 DrawWindowWidgets(w); |
119 |
121 |
120 DrawString(2, 15, STR_2023_TRANSPORT_COMPANY_RATINGS, 0); |
122 DrawString(2, 15, STR_2023_TRANSPORT_COMPANY_RATINGS, 0); |
121 |
123 |
122 // Draw list of players |
124 /* Draw list of players */ |
123 y = 25; |
125 y = 25; |
124 FOR_ALL_PLAYERS(p) { |
126 FOR_ALL_PLAYERS(p) { |
125 if (p->is_active && (HASBIT(t->have_ratings, p->index) || t->exclusivity == p->index)) { |
127 if (p->is_active && (HASBIT(t->have_ratings, p->index) || t->exclusivity == p->index)) { |
126 DrawPlayerIcon(p->index, 2, y); |
128 DrawPlayerIcon(p->index, 2, y); |
127 |
129 |
148 y += 10; |
150 y += 10; |
149 } |
151 } |
150 } |
152 } |
151 } |
153 } |
152 |
154 |
153 // Draw actions list |
155 /* Draw actions list */ |
154 { |
156 { |
155 int y = 107, i; |
157 int y = 107, i; |
156 int pos = w->vscroll.pos; |
158 int pos = w->vscroll.pos; |
157 |
159 |
158 if (--pos < 0) { |
160 if (--pos < 0) { |
232 { |
234 { |
233 Town *t = GetTown(w->window_number); |
235 Town *t = GetTown(w->window_number); |
234 |
236 |
235 switch (e->event) { |
237 switch (e->event) { |
236 case WE_PAINT: |
238 case WE_PAINT: |
237 // disable renaming town in network games if you are not the server |
239 /* disable renaming town in network games if you are not the server */ |
238 SetWindowWidgetDisabledState(w, 8, _networking && !_network_server); |
240 SetWindowWidgetDisabledState(w, 8, _networking && !_network_server); |
239 |
241 |
240 SetDParam(0, t->index); |
242 SetDParam(0, t->index); |
241 DrawWindowWidgets(w); |
243 DrawWindowWidgets(w); |
242 |
244 |
345 w = AllocateWindowDescFront(&_town_view_scen_desc, town); |
347 w = AllocateWindowDescFront(&_town_view_scen_desc, town); |
346 } |
348 } |
347 |
349 |
348 if (w != NULL) { |
350 if (w != NULL) { |
349 w->flags4 |= WF_DISABLE_VP_SCROLL; |
351 w->flags4 |= WF_DISABLE_VP_SCROLL; |
350 AssignWindowViewport(w, 3, 17, 0xFE, 0x56, GetTown(town)->xy, 1); |
352 AssignWindowViewport(w, 3, 17, 0xFE, 0x56, GetTown(town)->xy, ZOOM_LVL_TOWN); |
351 } |
353 } |
352 } |
354 } |
353 |
355 |
354 static const Widget _town_directory_widgets[] = { |
356 static const Widget _town_directory_widgets[] = { |
355 { WWT_CLOSEBOX, RESIZE_NONE, 13, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
357 { WWT_CLOSEBOX, RESIZE_NONE, 13, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
363 { WWT_RESIZEBOX, RESIZE_TB, 13, 196, 207, 190, 201, 0x0, STR_RESIZE_BUTTON}, |
365 { WWT_RESIZEBOX, RESIZE_TB, 13, 196, 207, 190, 201, 0x0, STR_RESIZE_BUTTON}, |
364 { WIDGETS_END}, |
366 { WIDGETS_END}, |
365 }; |
367 }; |
366 |
368 |
367 |
369 |
368 // used to get a sorted list of the towns |
370 /* used to get a sorted list of the towns */ |
369 static uint _num_town_sort; |
371 static uint _num_town_sort; |
370 |
372 |
371 static char _bufcache[64]; |
373 static char _bufcache[64]; |
372 static const Town* _last_town; |
374 static const Town* _last_town; |
373 |
375 |