31 j = 3; |
31 j = 3; |
32 x = 215; |
32 x = 215; |
33 tbl = p->yearly_expenses + 2; |
33 tbl = p->yearly_expenses + 2; |
34 do { |
34 do { |
35 if (year >= p->inaugurated_year) { |
35 if (year >= p->inaugurated_year) { |
36 SET_DPARAM16(0, year + 1920); |
36 SetDParam(0, year + 1920); |
37 DrawStringCenterUnderline(x-17, 15, STR_7010, 0); |
37 DrawStringCenterUnderline(x-17, 15, STR_7010, 0); |
38 sum = 0; |
38 sum = 0; |
39 for(i=0; i!=13; i++) { |
39 for(i=0; i!=13; i++) { |
40 /* draw one row in the price column */ |
40 /* draw one row in the price column */ |
41 cost = (*tbl)[i]; |
41 cost = (*tbl)[i]; |
42 if (cost != 0) { |
42 if (cost != 0) { |
43 sum += cost; |
43 sum += cost; |
44 |
44 |
45 str = STR_701E; |
45 str = STR_701E; |
46 if (cost < 0) { cost = -cost; str++; } |
46 if (cost < 0) { cost = -cost; str++; } |
47 SET_DPARAM64(0, cost); |
47 SetDParam64(0, cost); |
48 DrawStringRightAligned(x, 27+i*10, str, 0); |
48 DrawStringRightAligned(x, 27+i*10, str, 0); |
49 } |
49 } |
50 } |
50 } |
51 |
51 |
52 str = STR_701E; |
52 str = STR_701E; |
53 if (sum < 0) { sum = -sum; str++; } |
53 if (sum < 0) { sum = -sum; str++; } |
54 SET_DPARAM64(0, sum); |
54 SetDParam64(0, sum); |
55 DrawStringRightAligned(x, 27 + 13*10 + 2, str, 0); |
55 DrawStringRightAligned(x, 27 + 13*10 + 2, str, 0); |
56 |
56 |
57 GfxFillRect(x - 75, 27 + 10*13, x, 27 + 10*13, 215); |
57 GfxFillRect(x - 75, 27 + 10*13, x, 27 + 10*13, 215); |
58 x += 95; |
58 x += 95; |
59 } |
59 } |
62 } while (--j != 0); |
62 } while (--j != 0); |
63 |
63 |
64 y = 171; |
64 y = 171; |
65 |
65 |
66 // draw max loan aligned to loan below (y += 10) |
66 // draw max loan aligned to loan below (y += 10) |
67 SET_DPARAM64(0, (uint64)_economy.max_loan); |
67 SetDParam64(0, (uint64)_economy.max_loan); |
68 DrawString(202, y+10, STR_MAX_LOAN, 0); |
68 DrawString(202, y+10, STR_MAX_LOAN, 0); |
69 |
69 |
70 } else |
70 } else |
71 y = 15; |
71 y = 15; |
72 |
72 |
73 DrawString(2, y, STR_7026_BANK_BALANCE, 0); |
73 DrawString(2, y, STR_7026_BANK_BALANCE, 0); |
74 SET_DPARAM64(0, p->money64); |
74 SetDParam64(0, p->money64); |
75 DrawStringRightAligned(182, y, STR_7028, 0); |
75 DrawStringRightAligned(182, y, STR_7028, 0); |
76 |
76 |
77 y += 10; |
77 y += 10; |
78 |
78 |
79 DrawString(2, y, STR_7027_LOAN, 0); |
79 DrawString(2, y, STR_7027_LOAN, 0); |
80 SET_DPARAM64(0, p->current_loan); |
80 SetDParam64(0, p->current_loan); |
81 DrawStringRightAligned(182, y, STR_7028, 0); |
81 DrawStringRightAligned(182, y, STR_7028, 0); |
82 |
82 |
83 y += 12; |
83 y += 12; |
84 |
84 |
85 GfxFillRect(182 - 75, y-2, 182, y-2, 215); |
85 GfxFillRect(182 - 75, y-2, 182, y-2, 215); |
86 |
86 |
87 SET_DPARAM64(0, p->money64 - p->current_loan); |
87 SetDParam64(0, p->money64 - p->current_loan); |
88 DrawStringRightAligned(182, y, STR_7028, 0); |
88 DrawStringRightAligned(182, y, STR_7028, 0); |
89 } |
89 } |
90 |
90 |
91 static const Widget _player_finances_widgets[] = { |
91 static const Widget _player_finances_widgets[] = { |
92 { WWT_TEXTBTN, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
92 { WWT_TEXTBTN, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
135 case WE_PAINT: { |
135 case WE_PAINT: { |
136 Player *p = DEREF_PLAYER(w->window_number); |
136 Player *p = DEREF_PLAYER(w->window_number); |
137 |
137 |
138 w->disabled_state = p->current_loan != 0 ? 0 : (1 << 6); |
138 w->disabled_state = p->current_loan != 0 ? 0 : (1 << 6); |
139 |
139 |
140 SET_DPARAM16(0, p->name_1); |
140 SetDParam(0, p->name_1); |
141 SET_DPARAM32(1, p->name_2); |
141 SetDParam(1, p->name_2); |
142 SET_DPARAM16(2, GetPlayerNameString((byte)w->window_number, 3)); |
142 SetDParam(2, GetPlayerNameString((byte)w->window_number, 3)); |
143 SET_DPARAM32(4, 10000); |
143 SetDParam(4, 10000); |
144 DrawWindowWidgets(w); |
144 DrawWindowWidgets(w); |
145 |
145 |
146 DrawPlayerEconomyStats(p, (byte)WP(w,def_d).data_1); |
146 DrawPlayerEconomyStats(p, (byte)WP(w,def_d).data_1); |
147 } break; |
147 } break; |
148 |
148 |
417 |
417 |
418 if (train+road+air+ship == 0) { |
418 if (train+road+air+ship == 0) { |
419 DrawString(x+70, y, STR_7042_NONE, 0); |
419 DrawString(x+70, y, STR_7042_NONE, 0); |
420 } else { |
420 } else { |
421 if (train != 0) { |
421 if (train != 0) { |
422 SET_DPARAM16(0, train); |
422 SetDParam(0, train); |
423 DrawString(x + 70, y, train==1 ? STR_703A_TRAIN : STR_703B_TRAINS, 0); |
423 DrawString(x + 70, y, train==1 ? STR_703A_TRAIN : STR_703B_TRAINS, 0); |
424 y += 10; |
424 y += 10; |
425 } |
425 } |
426 |
426 |
427 if (road != 0) { |
427 if (road != 0) { |
428 SET_DPARAM16(0, road); |
428 SetDParam(0, road); |
429 DrawString(x + 70, y, road==1 ? STR_703C_ROAD_VEHICLE : STR_703D_ROAD_VEHICLES, 0); |
429 DrawString(x + 70, y, road==1 ? STR_703C_ROAD_VEHICLE : STR_703D_ROAD_VEHICLES, 0); |
430 y += 10; |
430 y += 10; |
431 } |
431 } |
432 |
432 |
433 if (air != 0) { |
433 if (air != 0) { |
434 SET_DPARAM16(0, air); |
434 SetDParam(0, air); |
435 DrawString(x + 70, y, air==1 ? STR_703E_AIRCRAFT : STR_703F_AIRCRAFT, 0); |
435 DrawString(x + 70, y, air==1 ? STR_703E_AIRCRAFT : STR_703F_AIRCRAFT, 0); |
436 y += 10; |
436 y += 10; |
437 } |
437 } |
438 |
438 |
439 if (ship != 0) { |
439 if (ship != 0) { |
440 SET_DPARAM16(0, ship); |
440 SetDParam(0, ship); |
441 DrawString(x + 70, y, ship==1 ? STR_7040_SHIP : STR_7041_SHIPS, 0); |
441 DrawString(x + 70, y, ship==1 ? STR_7040_SHIP : STR_7041_SHIPS, 0); |
442 } |
442 } |
443 } |
443 } |
444 } |
444 } |
445 |
445 |
482 uint32 dis; |
482 uint32 dis; |
483 |
483 |
484 if (w->widget != _other_player_company_widgets) |
484 if (w->widget != _other_player_company_widgets) |
485 w->widget = (p->location_of_house != 0) ? _my_player_company_bh_widgets : _my_player_company_widgets; |
485 w->widget = (p->location_of_house != 0) ? _my_player_company_bh_widgets : _my_player_company_widgets; |
486 |
486 |
487 SET_DPARAM16(0, p->name_1); |
487 SetDParam(0, p->name_1); |
488 SET_DPARAM32(1, p->name_2); |
488 SetDParam(1, p->name_2); |
489 SET_DPARAM16(2, GetPlayerNameString((byte)w->window_number, 3)); |
489 SetDParam(2, GetPlayerNameString((byte)w->window_number, 3)); |
490 |
490 |
491 dis = 0; |
491 dis = 0; |
492 if (GetAmountOwnedBy(p, 0xFF) == 0) dis |= 1 << 9; |
492 if (GetAmountOwnedBy(p, 0xFF) == 0) dis |= 1 << 9; |
493 if (GetAmountOwnedBy(p, _local_player) == 0) dis |= 1 << 10; |
493 if (GetAmountOwnedBy(p, _local_player) == 0) dis |= 1 << 10; |
494 |
494 |
495 w->disabled_state = dis; |
495 w->disabled_state = dis; |
496 DrawWindowWidgets(w); |
496 DrawWindowWidgets(w); |
497 |
497 |
498 SET_DPARAM16(0, p->inaugurated_year + 1920); |
498 SetDParam(0, p->inaugurated_year + 1920); |
499 DrawString(110, 25, STR_7038_INAUGURATED, 0); |
499 DrawString(110, 25, STR_7038_INAUGURATED, 0); |
500 |
500 |
501 DrawPlayerVehiclesAmount(w->window_number); |
501 DrawPlayerVehiclesAmount(w->window_number); |
502 |
502 |
503 DrawString(110,48, STR_7006_COLOR_SCHEME, 0); |
503 DrawString(110,48, STR_7006_COLOR_SCHEME, 0); |
504 DrawSprite((p->player_color<<16) + 0x3078C19, 215,49); |
504 DrawSprite((p->player_color<<16) + 0x3078C19, 215,49); |
505 |
505 |
506 DrawPlayerFace(p->face, p->player_color, 2, 16); |
506 DrawPlayerFace(p->face, p->player_color, 2, 16); |
507 |
507 |
508 SET_DPARAM16(0, p->president_name_1); |
508 SetDParam(0, p->president_name_1); |
509 SET_DPARAM32(1, p->president_name_2); |
509 SetDParam(1, p->president_name_2); |
510 DrawStringMultiCenter(48, 141, STR_7037_PRESIDENT, 94); |
510 DrawStringMultiCenter(48, 141, STR_7037_PRESIDENT, 94); |
511 |
511 |
512 SET_DPARAM64(0, CalculateCompanyValue(p)); |
512 SetDParam64(0, CalculateCompanyValue(p)); |
513 DrawString(110, 114, STR_7076_COMPANY_VALUE, 0); |
513 DrawString(110, 114, STR_7076_COMPANY_VALUE, 0); |
514 |
514 |
515 DrawCompanyOwnerText(p); |
515 DrawCompanyOwnerText(p); |
516 } break; |
516 } break; |
517 |
517 |
535 } break; |
535 } break; |
536 |
536 |
537 case 5: {/* change president name */ |
537 case 5: {/* change president name */ |
538 Player *p = DEREF_PLAYER(w->window_number); |
538 Player *p = DEREF_PLAYER(w->window_number); |
539 WP(w,def_d).byte_1 = 0; |
539 WP(w,def_d).byte_1 = 0; |
540 SET_DPARAM32(0, p->president_name_2); |
540 SetDParam(0, p->president_name_2); |
541 ShowQueryString(p->president_name_1, STR_700B_PRESIDENT_S_NAME, 31, 94, w->window_class, w->window_number); |
541 ShowQueryString(p->president_name_1, STR_700B_PRESIDENT_S_NAME, 31, 94, w->window_class, w->window_number); |
542 } break; |
542 } break; |
543 |
543 |
544 case 6: {/* change company name */ |
544 case 6: {/* change company name */ |
545 Player *p = DEREF_PLAYER(w->window_number); |
545 Player *p = DEREF_PLAYER(w->window_number); |
546 WP(w,def_d).byte_1 = 1; |
546 WP(w,def_d).byte_1 = 1; |
547 SET_DPARAM32(0, p->name_2); |
547 SetDParam(0, p->name_2); |
548 ShowQueryString(p->name_1, STR_700A_COMPANY_NAME, 31, 150, w->window_class, w->window_number); |
548 ShowQueryString(p->name_1, STR_700A_COMPANY_NAME, 31, 150, w->window_class, w->window_number); |
549 } break; |
549 } break; |
550 |
550 |
551 case 7: {/* build hq */ |
551 case 7: {/* build hq */ |
552 TileIndex tile = DEREF_PLAYER(w->window_number)->location_of_house; |
552 TileIndex tile = DEREF_PLAYER(w->window_number)->location_of_house; |
639 static void BuyCompanyWndProc(Window *w, WindowEvent *e) |
639 static void BuyCompanyWndProc(Window *w, WindowEvent *e) |
640 { |
640 { |
641 switch(e->event) { |
641 switch(e->event) { |
642 case WE_PAINT: { |
642 case WE_PAINT: { |
643 Player *p = DEREF_PLAYER(w->window_number); |
643 Player *p = DEREF_PLAYER(w->window_number); |
644 SET_DPARAM16(0, p->name_1); |
644 SetDParam(0, p->name_1); |
645 SET_DPARAM32(1, p->name_2); |
645 SetDParam(1, p->name_2); |
646 DrawWindowWidgets(w); |
646 DrawWindowWidgets(w); |
647 |
647 |
648 DrawPlayerFace(p->face, p->player_color, 2, 16); |
648 DrawPlayerFace(p->face, p->player_color, 2, 16); |
649 |
649 |
650 SET_DPARAM16(0, p->name_1); |
650 SetDParam(0, p->name_1); |
651 SET_DPARAM32(1, p->name_2); |
651 SetDParam(1, p->name_2); |
652 SET_DPARAM32(2, p->bankrupt_value); |
652 SetDParam(2, p->bankrupt_value); |
653 DrawStringMultiCenter(214, 65, STR_705B_WE_ARE_LOOKING_FOR_A_TRANSPORT, 238); |
653 DrawStringMultiCenter(214, 65, STR_705B_WE_ARE_LOOKING_FOR_A_TRANSPORT, 238); |
654 break; |
654 break; |
655 } |
655 } |
656 |
656 |
657 case WE_CLICK: |
657 case WE_CLICK: |