82 static void TownAuthorityWndProc(Window *w, WindowEvent *e) |
82 static void TownAuthorityWndProc(Window *w, WindowEvent *e) |
83 { |
83 { |
84 uint buttons; |
84 uint buttons; |
85 int numact; |
85 int numact; |
86 Town *t = DEREF_TOWN(w->window_number); |
86 Town *t = DEREF_TOWN(w->window_number); |
87 |
87 |
88 switch(e->event) { |
88 switch(e->event) { |
89 case WE_PAINT: |
89 case WE_PAINT: |
90 buttons = GetMaskOfTownActions(&numact, t); |
90 buttons = GetMaskOfTownActions(&numact, t); |
91 SetVScrollCount(w, numact + 1); |
91 SetVScrollCount(w, numact + 1); |
92 |
92 |
127 (str++, true); // Outstanding |
127 (str++, true); // Outstanding |
128 |
128 |
129 /* WARNING ugly hack! |
129 /* WARNING ugly hack! |
130 GetPlayerNameString sets up (Player #) if the player is human in an extra DPARAM16 |
130 GetPlayerNameString sets up (Player #) if the player is human in an extra DPARAM16 |
131 It seems that if player is non-human, nothing is set up, so param is 0. GetString doesn't like |
131 It seems that if player is non-human, nothing is set up, so param is 0. GetString doesn't like |
132 that because there is another param after it. |
132 that because there is another param after it. |
133 So we'll just shift the rating one back if player is AI and all is fine |
133 So we'll just shift the rating one back if player is AI and all is fine |
134 */ |
134 */ |
135 SET_DPARAM16((IS_HUMAN_PLAYER(p->index) ? 4 : 3), str); |
135 SET_DPARAM16((IS_HUMAN_PLAYER(p->index) ? 4 : 3), str); |
136 DrawString(19, y, STR_2024, (t->exclusivity==p->index)?3:0); |
136 DrawString(19, y, STR_2024, (t->exclusivity==p->index)?3:0); |
137 y+=10; |
137 y+=10; |
165 SET_DPARAM32(1, (_price.build_industry >> 8) * _town_action_costs[i]); |
165 SET_DPARAM32(1, (_price.build_industry >> 8) * _town_action_costs[i]); |
166 SET_DPARAM16(0, STR_2046_SMALL_ADVERTISING_CAMPAIGN + i); |
166 SET_DPARAM16(0, STR_2046_SMALL_ADVERTISING_CAMPAIGN + i); |
167 DrawStringMultiLine(2, 159, STR_204D_INITIATE_A_SMALL_LOCAL + i, 313); |
167 DrawStringMultiLine(2, 159, STR_204D_INITIATE_A_SMALL_LOCAL + i, 313); |
168 } |
168 } |
169 } |
169 } |
170 |
170 |
171 break; |
171 break; |
172 |
172 |
173 case WE_CLICK: |
173 case WE_CLICK: |
174 switch(e->click.widget) { |
174 switch(e->click.widget) { |
175 case 3: { /* listbox */ |
175 case 3: { /* listbox */ |
223 |
223 |
224 switch(e->event) { |
224 switch(e->event) { |
225 case WE_PAINT: |
225 case WE_PAINT: |
226 SET_DPARAM16(0, t->index); |
226 SET_DPARAM16(0, t->index); |
227 DrawWindowWidgets(w); |
227 DrawWindowWidgets(w); |
228 |
228 |
229 SET_DPARAM32(0, t->population); |
229 SET_DPARAM32(0, t->population); |
230 SET_DPARAM32(1, t->num_houses); |
230 SET_DPARAM32(1, t->num_houses); |
231 DrawString(2,107,STR_2006_POPULATION,0); |
231 DrawString(2,107,STR_2006_POPULATION,0); |
232 |
232 |
233 SET_DPARAM16(0, t->act_pass); |
233 SET_DPARAM16(0, t->act_pass); |
234 SET_DPARAM16(1, t->max_pass); |
234 SET_DPARAM16(1, t->max_pass); |
235 DrawString(2,117,STR_200D_PASSENGERS_LAST_MONTH_MAX,0); |
235 DrawString(2,117,STR_200D_PASSENGERS_LAST_MONTH_MAX,0); |
236 |
236 |
237 SET_DPARAM16(0, t->act_mail); |
237 SET_DPARAM16(0, t->act_mail); |
238 SET_DPARAM16(1, t->max_mail); |
238 SET_DPARAM16(1, t->max_mail); |
239 DrawString(2,127,STR_200E_MAIL_LAST_MONTH_MAX,0); |
239 DrawString(2,127,STR_200E_MAIL_LAST_MONTH_MAX,0); |
240 |
240 |
241 DrawWindowViewport(w); |
241 DrawWindowViewport(w); |
242 break; |
242 break; |
243 |
243 |
244 case WE_CLICK: |
244 case WE_CLICK: |
245 switch(e->click.widget) { |
245 switch(e->click.widget) { |
409 |
409 |
410 SetVScrollCount(w, _num_town_sort); |
410 SetVScrollCount(w, _num_town_sort); |
411 |
411 |
412 DrawWindowWidgets(w); |
412 DrawWindowWidgets(w); |
413 DoDrawString(_town_sort_order & 1 ? "\xAA" : "\xA0", (_town_sort_order <= 1) ? 88 : 187, 15, 0x10); |
413 DoDrawString(_town_sort_order & 1 ? "\xAA" : "\xA0", (_town_sort_order <= 1) ? 88 : 187, 15, 0x10); |
414 |
414 |
415 { |
415 { |
416 Town *t; |
416 Town *t; |
417 int n = 0; |
417 int n = 0; |
418 uint16 i = w->vscroll.pos; |
418 uint16 i = w->vscroll.pos; |
419 int y = 28; |
419 int y = 28; |
445 case 3: { /* Sort by Population ascending/descending */ |
445 case 3: { /* Sort by Population ascending/descending */ |
446 _town_sort_order = (_town_sort_order == 2) ? 3 : 2; |
446 _town_sort_order = (_town_sort_order == 2) ? 3 : 2; |
447 _town_sort_dirty = true; |
447 _town_sort_dirty = true; |
448 SetWindowDirty(w); |
448 SetWindowDirty(w); |
449 } break; |
449 } break; |
450 |
450 |
451 case 4: { /* Click on Town Matrix */ |
451 case 4: { /* Click on Town Matrix */ |
452 uint16 id_v = (e->click.pt.y - 28) / 10; |
452 uint16 id_v = (e->click.pt.y - 28) / 10; |
453 |
453 |
454 if (id_v >= w->vscroll.cap) { return;} // click out of bounds |
454 if (id_v >= w->vscroll.cap) { return;} // click out of bounds |
455 |
455 |