comparison src/station_gui.cpp @ 6364:12ef3186e753 draft

(svn r9417) -Fix (r1): Waiting cargo icons in the station view window were incorrectly drawn if the cargo list was scrolled, resulting in overlapping images
author peter1138 <peter1138@openttd.org>
date Fri, 23 Mar 2007 20:51:42 +0000
parents 8132258640be
children 0d8a8ec46519
comparison
equal deleted inserted replaced
6363:5512886dea5e 6364:12ef3186e753
665 { WWT_PUSHTXTBTN, RESIZE_NONE, 14, 221, 234, 98, 109, STR_PLANE, STR_SCHEDULED_AIRCRAFT_TIP }, 665 { WWT_PUSHTXTBTN, RESIZE_NONE, 14, 221, 234, 98, 109, STR_PLANE, STR_SCHEDULED_AIRCRAFT_TIP },
666 { WWT_PUSHTXTBTN, RESIZE_NONE, 14, 235, 248, 98, 109, STR_SHIP, STR_SCHEDULED_SHIPS_TIP }, 666 { WWT_PUSHTXTBTN, RESIZE_NONE, 14, 235, 248, 98, 109, STR_SHIP, STR_SCHEDULED_SHIPS_TIP },
667 { WIDGETS_END}, 667 { WIDGETS_END},
668 }; 668 };
669 669
670
671 static void DrawCargoIcons(CargoID i, uint waiting, int x, int y)
672 {
673 uint num = min((waiting + 5) / 10, 23);
674 if (num == 0) return;
675
676 const CargoSpec *cs = GetCargo(i);
677 SpriteID sprite = cs->sprite;
678
679 do {
680 DrawSprite(sprite, PAL_NONE, x, y);
681 x += 10;
682 } while (--num);
683 }
684
670 static void DrawStationViewWindow(Window *w) 685 static void DrawStationViewWindow(Window *w)
671 { 686 {
672 StationID station_id = w->window_number; 687 StationID station_id = w->window_number;
673 const Station* st = GetStation(station_id); 688 const Station* st = GetStation(station_id);
674 uint num; 689 uint num;
711 726
712 for (CargoID i = 0; i < NUM_CARGO && pos > -5; i++) { 727 for (CargoID i = 0; i < NUM_CARGO && pos > -5; i++) {
713 uint waiting = GB(st->goods[i].waiting_acceptance, 0, 12); 728 uint waiting = GB(st->goods[i].waiting_acceptance, 0, 12);
714 if (waiting == 0) continue; 729 if (waiting == 0) continue;
715 730
716 num = (waiting + 5) / 10;
717 if (num != 0) {
718 int cur_x = x;
719 num = min(num, 23);
720 do {
721 DrawSprite(GetCargo(i)->sprite, PAL_NONE, cur_x, y);
722 cur_x += 10;
723 } while (--num);
724 }
725
726 if (st->goods[i].enroute_from == station_id) { 731 if (st->goods[i].enroute_from == station_id) {
727 if (--pos < 0) { 732 if (--pos < 0) {
733 DrawCargoIcons(i, waiting, x, y);
728 SetDParam(1, waiting); 734 SetDParam(1, waiting);
729 SetDParam(0, i); 735 SetDParam(0, i);
730 DrawStringRightAligned(x + 234, y, STR_0009, 0); 736 DrawStringRightAligned(x + 234, y, STR_0009, 0);
731 y += 10; 737 y += 10;
732 } 738 }
733 } else { 739 } else {
734 /* enroute */ 740 /* enroute */
735 if (--pos < 0) { 741 if (--pos < 0) {
742 DrawCargoIcons(i, waiting, x, y);
736 SetDParam(1, waiting); 743 SetDParam(1, waiting);
737 SetDParam(0, i); 744 SetDParam(0, i);
738 DrawStringRightAligned(x + 234, y, STR_000A_EN_ROUTE_FROM, 0); 745 DrawStringRightAligned(x + 234, y, STR_000A_EN_ROUTE_FROM, 0);
739 y += 10; 746 y += 10;
740 } 747 }