265 |
265 |
266 sl->resort_timer = DAY_TICKS * PERIODIC_RESORT_DAYS; |
266 sl->resort_timer = DAY_TICKS * PERIODIC_RESORT_DAYS; |
267 sl->flags &= ~SL_RESORT; |
267 sl->flags &= ~SL_RESORT; |
268 } |
268 } |
269 |
269 |
270 static uint32 _cargo_filter = std::numeric_limits<uint32>::max(); |
270 static const uint32 _cargo_filter_max = ~0; |
|
271 static uint32 _cargo_filter = _cargo_filter_max; |
271 |
272 |
272 static void PlayerStationsWndProc(BaseWindow *w, WindowEvent *e) |
273 static void PlayerStationsWndProc(BaseWindow *w, WindowEvent *e) |
273 { |
274 { |
274 const PlayerID owner = (PlayerID)w->window_number; |
275 const PlayerID owner = (PlayerID)w->window_number; |
275 static byte facilities = FACIL_TRAIN | FACIL_TRUCK_STOP | FACIL_BUS_STOP | FACIL_AIRPORT | FACIL_DOCK; |
276 static byte facilities = FACIL_TRAIN | FACIL_TRUCK_STOP | FACIL_BUS_STOP | FACIL_AIRPORT | FACIL_DOCK; |
278 |
279 |
279 plstations_d *sl = &WP(w, plstations_d); |
280 plstations_d *sl = &WP(w, plstations_d); |
280 |
281 |
281 switch (e->event) { |
282 switch (e->event) { |
282 case WE_CREATE: /* set up resort timer */ |
283 case WE_CREATE: /* set up resort timer */ |
283 if (_cargo_filter == std::numeric_limits<uint32>::max()) _cargo_filter = _cargo_mask; |
284 if (_cargo_filter == _cargo_filter_max) _cargo_filter = _cargo_mask; |
284 |
285 |
285 for (uint i = 0; i < 5; i++) { |
286 for (uint i = 0; i < 5; i++) { |
286 if (HASBIT(facilities, i)) w->LowerWidget(i + STATIONLIST_WIDGET_TRAIN); |
287 if (HASBIT(facilities, i)) w->LowerWidget(i + STATIONLIST_WIDGET_TRAIN); |
287 } |
288 } |
288 |
289 |
360 SetDParam(0, st->index); |
361 SetDParam(0, st->index); |
361 SetDParam(1, st->facilities); |
362 SetDParam(1, st->facilities); |
362 x = DrawString(xb, y, STR_3049_0, 0) + 5; |
363 x = DrawString(xb, y, STR_3049_0, 0) + 5; |
363 |
364 |
364 // show cargo waiting and station ratings |
365 // show cargo waiting and station ratings |
365 for (CargoID j = 0; j != NUM_CARGO; j++) { |
366 for (CargoID j = 0; j < NUM_CARGO; j++) { |
366 uint amount = GB(st->goods[j].waiting_acceptance, 0, 12); |
367 uint amount = GB(st->goods[j].waiting_acceptance, 0, 12); |
367 if (amount != 0) { |
368 if (amount != 0) { |
368 StationsWndShowStationRating(x, y, j, amount, st->goods[j].rating); |
369 StationsWndShowStationRating(x, y, j, amount, st->goods[j].rating); |
369 x += 20; |
370 x += 20; |
370 } |
371 } |
663 { WWT_PUSHTXTBTN, RESIZE_NONE, 14, 221, 234, 98, 109, STR_PLANE, STR_SCHEDULED_AIRCRAFT_TIP }, |
664 { WWT_PUSHTXTBTN, RESIZE_NONE, 14, 221, 234, 98, 109, STR_PLANE, STR_SCHEDULED_AIRCRAFT_TIP }, |
664 { WWT_PUSHTXTBTN, RESIZE_NONE, 14, 235, 248, 98, 109, STR_SHIP, STR_SCHEDULED_SHIPS_TIP }, |
665 { WWT_PUSHTXTBTN, RESIZE_NONE, 14, 235, 248, 98, 109, STR_SHIP, STR_SCHEDULED_SHIPS_TIP }, |
665 { WIDGETS_END}, |
666 { WIDGETS_END}, |
666 }; |
667 }; |
667 |
668 |
|
669 |
|
670 static void DrawCargoIcons(CargoID i, uint waiting, int x, int y) |
|
671 { |
|
672 uint num = min((waiting + 5) / 10, 23); |
|
673 if (num == 0) return; |
|
674 |
|
675 const CargoSpec *cs = GetCargo(i); |
|
676 SpriteID sprite; |
|
677 |
|
678 if (cs->sprite == 0xFFFF) { |
|
679 /* A value of 0xFFFF indicates we should draw a custom icon */ |
|
680 sprite = GetCustomCargoSprite(cs); |
|
681 } else { |
|
682 sprite = cs->sprite; |
|
683 } |
|
684 |
|
685 if (sprite == 0) return; |
|
686 |
|
687 do { |
|
688 DrawSprite(sprite, PAL_NONE, x, y); |
|
689 x += 10; |
|
690 } while (--num); |
|
691 } |
|
692 |
668 static void DrawStationViewWindow(BaseWindow *w) |
693 static void DrawStationViewWindow(BaseWindow *w) |
669 { |
694 { |
670 StationID station_id = w->window_number; |
695 StationID station_id = w->window_number; |
671 const Station* st = GetStation(station_id); |
696 const Station* st = GetStation(station_id); |
672 uint num; |
697 uint num; |
673 int x,y; |
698 int x,y; |
674 int pos; |
699 int pos; |
675 StringID str; |
700 StringID str; |
676 |
701 |
677 num = 1; |
702 num = 1; |
678 for (CargoID i = 0; i != NUM_CARGO; i++) { |
703 for (CargoID i = 0; i < NUM_CARGO; i++) { |
679 if (GB(st->goods[i].waiting_acceptance, 0, 12) != 0) { |
704 if (GB(st->goods[i].waiting_acceptance, 0, 12) != 0) { |
680 num++; |
705 num++; |
681 if (st->goods[i].enroute_from != station_id) num++; |
706 if (st->goods[i].enroute_from != station_id) num++; |
682 } |
707 } |
683 } |
708 } |
697 y = 15; |
722 y = 15; |
698 pos = w->vscroll.pos; |
723 pos = w->vscroll.pos; |
699 |
724 |
700 if (--pos < 0) { |
725 if (--pos < 0) { |
701 str = STR_00D0_NOTHING; |
726 str = STR_00D0_NOTHING; |
702 for (CargoID i = 0; i != NUM_CARGO; i++) { |
727 for (CargoID i = 0; i < NUM_CARGO; i++) { |
703 if (GB(st->goods[i].waiting_acceptance, 0, 12) != 0) str = STR_EMPTY; |
728 if (GB(st->goods[i].waiting_acceptance, 0, 12) != 0) str = STR_EMPTY; |
704 } |
729 } |
705 SetDParam(0, str); |
730 SetDParam(0, str); |
706 DrawString(x, y, STR_0008_WAITING, 0); |
731 DrawString(x, y, STR_0008_WAITING, 0); |
707 y += 10; |
732 y += 10; |
708 } |
733 } |
709 |
734 |
710 for (CargoID i = 0; i != NUM_CARGO && pos > -5; i++) { |
735 for (CargoID i = 0; i < NUM_CARGO && pos > -5; i++) { |
711 uint waiting = GB(st->goods[i].waiting_acceptance, 0, 12); |
736 uint waiting = GB(st->goods[i].waiting_acceptance, 0, 12); |
712 if (waiting == 0) continue; |
737 if (waiting == 0) continue; |
713 |
738 |
714 num = (waiting + 5) / 10; |
|
715 if (num != 0) { |
|
716 int cur_x = x; |
|
717 num = min(num, 23); |
|
718 do { |
|
719 DrawSprite(GetCargo(i)->sprite, PAL_NONE, cur_x, y); |
|
720 cur_x += 10; |
|
721 } while (--num); |
|
722 } |
|
723 |
|
724 if (st->goods[i].enroute_from == station_id) { |
739 if (st->goods[i].enroute_from == station_id) { |
725 if (--pos < 0) { |
740 if (--pos < 0) { |
|
741 DrawCargoIcons(i, waiting, x, y); |
726 SetDParam(1, waiting); |
742 SetDParam(1, waiting); |
727 SetDParam(0, i); |
743 SetDParam(0, i); |
728 DrawStringRightAligned(x + 234, y, STR_0009, 0); |
744 DrawStringRightAligned(x + 234, y, STR_0009, 0); |
729 y += 10; |
745 y += 10; |
730 } |
746 } |
731 } else { |
747 } else { |
732 /* enroute */ |
748 /* enroute */ |
733 if (--pos < 0) { |
749 if (--pos < 0) { |
|
750 DrawCargoIcons(i, waiting, x, y); |
734 SetDParam(1, waiting); |
751 SetDParam(1, waiting); |
735 SetDParam(0, i); |
752 SetDParam(0, i); |
736 DrawStringRightAligned(x + 234, y, STR_000A_EN_ROUTE_FROM, 0); |
753 DrawStringRightAligned(x + 234, y, STR_000A_EN_ROUTE_FROM, 0); |
737 y += 10; |
754 y += 10; |
738 } |
755 } |
749 char *b = _userstring; |
766 char *b = _userstring; |
750 bool first = true; |
767 bool first = true; |
751 |
768 |
752 b = InlineString(b, STR_000C_ACCEPTS); |
769 b = InlineString(b, STR_000C_ACCEPTS); |
753 |
770 |
754 for (CargoID i = 0; i != NUM_CARGO; i++) { |
771 for (CargoID i = 0; i < NUM_CARGO; i++) { |
755 if (b >= endof(_userstring) - 5 - 1) break; |
772 if (b >= endof(_userstring) - 5 - 1) break; |
756 if (st->goods[i].waiting_acceptance & 0x8000) { |
773 if (st->goods[i].waiting_acceptance & 0x8000) { |
757 if (first) { |
774 if (first) { |
758 first = false; |
775 first = false; |
759 } else { |
776 } else { |
772 DrawStringMultiLine(2, 67, STR_SPEC_USERSTRING, 245); |
789 DrawStringMultiLine(2, 67, STR_SPEC_USERSTRING, 245); |
773 } else { |
790 } else { |
774 DrawString(2, 67, STR_3034_LOCAL_RATING_OF_TRANSPORT, 0); |
791 DrawString(2, 67, STR_3034_LOCAL_RATING_OF_TRANSPORT, 0); |
775 |
792 |
776 y = 77; |
793 y = 77; |
777 for (CargoID i = 0; i != NUM_CARGO; i++) { |
794 for (CargoID i = 0; i < NUM_CARGO; i++) { |
778 if (st->goods[i].enroute_from != INVALID_STATION) { |
795 const CargoSpec *cs = GetCargo(i); |
779 SetDParam(0, GetCargo(i)->name); |
796 if (!cs->IsValid()) continue; |
780 SetDParam(2, st->goods[i].rating * 101 >> 8); |
797 |
781 SetDParam(1, STR_3035_APPALLING + (st->goods[i].rating >> 5)); |
798 const GoodsEntry *ge = &st->goods[i]; |
782 DrawString(8, y, STR_303D, 0); |
799 if (ge->enroute_from == INVALID_STATION) continue; |
783 y += 10; |
800 |
784 } |
801 SetDParam(0, cs->name); |
|
802 SetDParam(2, ge->rating * 101 >> 8); |
|
803 SetDParam(1, STR_3035_APPALLING + (ge->rating >> 5)); |
|
804 DrawString(8, y, STR_303D, 0); |
|
805 y += 10; |
785 } |
806 } |
786 } |
807 } |
787 } |
808 } |
788 |
809 |
789 |
810 |