761 w->widget[0].right = br.width; |
761 w->widget[0].right = br.width; |
762 w->widget[0].bottom = br.height; |
762 w->widget[0].bottom = br.height; |
763 } |
763 } |
764 |
764 |
765 |
765 |
766 static int DrawStationCoverageText(const AcceptedCargo accepts, |
766 static int DrawStationCoverageText(const AcceptedCargo cargo, |
767 int str_x, int str_y, StationCoverageType sct) |
767 int str_x, int str_y, StationCoverageType sct, bool supplies) |
768 { |
768 { |
769 bool first = true; |
769 bool first = true; |
770 |
770 |
771 char *b = InlineString(_userstring, STR_000D_ACCEPTS); |
771 char *b = InlineString(_userstring, supplies ? STR_SUPPLIES : STR_000D_ACCEPTS); |
772 |
772 |
773 for (CargoID i = 0; i < NUM_CARGO; i++) { |
773 for (CargoID i = 0; i < NUM_CARGO; i++) { |
774 if (b >= lastof(_userstring) - (1 + 2 * 4)) break; // ',' or ' ' and two calls to Utf8Encode() |
774 if (b >= lastof(_userstring) - (1 + 2 * 4)) break; // ',' or ' ' and two calls to Utf8Encode() |
775 switch (sct) { |
775 switch (sct) { |
776 case SCT_PASSENGERS_ONLY: if (!IsCargoInClass(i, CC_PASSENGERS)) continue; break; |
776 case SCT_PASSENGERS_ONLY: if (!IsCargoInClass(i, CC_PASSENGERS)) continue; break; |
777 case SCT_NON_PASSENGERS_ONLY: if (IsCargoInClass(i, CC_PASSENGERS)) continue; break; |
777 case SCT_NON_PASSENGERS_ONLY: if (IsCargoInClass(i, CC_PASSENGERS)) continue; break; |
778 case SCT_ALL: break; |
778 case SCT_ALL: break; |
779 default: NOT_REACHED(); |
779 default: NOT_REACHED(); |
780 } |
780 } |
781 if (accepts[i] >= 8) { |
781 if (cargo[i] >= (supplies ? 1 : 8)) { |
782 if (first) { |
782 if (first) { |
783 first = false; |
783 first = false; |
784 } else { |
784 } else { |
785 /* Add a comma if this is not the first item */ |
785 /* Add a comma if this is not the first item */ |
786 *b++ = ','; |
786 *b++ = ','; |
799 assert(b < endof(_userstring)); |
799 assert(b < endof(_userstring)); |
800 |
800 |
801 return DrawStringMultiLine(str_x, str_y, STR_SPEC_USERSTRING, 144); |
801 return DrawStringMultiLine(str_x, str_y, STR_SPEC_USERSTRING, 144); |
802 } |
802 } |
803 |
803 |
804 int DrawStationCoverageAreaText(int sx, int sy, StationCoverageType sct, int rad) |
804 /** |
|
805 * Calculates and draws the accepted or supplied cargo around the selected tile(s) |
|
806 * @param sx x position where the string is to be drawn |
|
807 * @param sy y position where the string is to be drawn |
|
808 * @param sct which type of cargo is to be displayed (passengers/non-passengers) |
|
809 * @param rad radius around selected tile(s) to be searched |
|
810 * @param supplies if supplied cargos should be drawn, else accepted cargos |
|
811 * @return Returns the y value below the string that was drawn |
|
812 */ |
|
813 int DrawStationCoverageAreaText(int sx, int sy, StationCoverageType sct, int rad, bool supplies) |
805 { |
814 { |
806 TileIndex tile = TileVirtXY(_thd.pos.x, _thd.pos.y); |
815 TileIndex tile = TileVirtXY(_thd.pos.x, _thd.pos.y); |
807 AcceptedCargo accepts; |
816 AcceptedCargo cargo; |
808 if (tile < MapSize()) { |
817 if (tile < MapSize()) { |
809 GetAcceptanceAroundTiles(accepts, tile, _thd.size.x / TILE_SIZE, _thd.size.y / TILE_SIZE , rad); |
818 if (supplies) { |
810 return sy + DrawStationCoverageText(accepts, sx, sy, sct); |
819 GetProductionAroundTiles(cargo, tile, _thd.size.x / TILE_SIZE, _thd.size.y / TILE_SIZE , rad); |
|
820 } else { |
|
821 GetAcceptanceAroundTiles(cargo, tile, _thd.size.x / TILE_SIZE, _thd.size.y / TILE_SIZE , rad); |
|
822 } |
|
823 return sy + DrawStationCoverageText(cargo, sx, sy, sct, supplies); |
811 } |
824 } |
812 |
825 |
813 return sy; |
826 return sy; |
814 } |
827 } |
815 |
828 |