mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-02-06 22:37:22 +00:00
(svn r12458) -Codechange: split acquiring the sprite ID for cargos from the actual drawing of them.
This commit is contained in:
parent
79f033c78f
commit
d8cfb4f064
@ -59,6 +59,8 @@ extern CargoSpec _cargo[NUM_CARGO];
|
|||||||
void SetupCargoForClimate(LandscapeID l);
|
void SetupCargoForClimate(LandscapeID l);
|
||||||
/* Retrieve cargo details for the given cargo ID */
|
/* Retrieve cargo details for the given cargo ID */
|
||||||
const CargoSpec *GetCargo(CargoID c);
|
const CargoSpec *GetCargo(CargoID c);
|
||||||
|
/* Get the cargo icon for a given cargo ID */
|
||||||
|
SpriteID GetCargoSprite(CargoID i);
|
||||||
/* Get the cargo ID with the cargo label */
|
/* Get the cargo ID with the cargo label */
|
||||||
CargoID GetCargoIDByLabel(CargoLabel cl);
|
CargoID GetCargoIDByLabel(CargoLabel cl);
|
||||||
CargoID GetCargoIDByBitnum(uint8 bitnum);
|
CargoID GetCargoIDByBitnum(uint8 bitnum);
|
||||||
|
@ -682,19 +682,8 @@ static const Widget _station_view_widgets[] = {
|
|||||||
{ WIDGETS_END},
|
{ WIDGETS_END},
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
SpriteID GetCargoSprite(CargoID i)
|
||||||
* Draws icons of wainting cargo in the StationView window
|
|
||||||
*
|
|
||||||
* @param i type of cargo
|
|
||||||
* @param waiting number of wainting units
|
|
||||||
* @param x x on-screen coordinate where to start with drawing icons
|
|
||||||
* @param y y coordinate
|
|
||||||
*/
|
|
||||||
static void DrawCargoIcons(CargoID i, uint waiting, int x, int y, uint width)
|
|
||||||
{
|
{
|
||||||
uint num = min((waiting + 5) / 10, width / 10); // maximum is width / 10 icons so it won't overflow
|
|
||||||
if (num == 0) return;
|
|
||||||
|
|
||||||
const CargoSpec *cs = GetCargo(i);
|
const CargoSpec *cs = GetCargo(i);
|
||||||
SpriteID sprite;
|
SpriteID sprite;
|
||||||
|
|
||||||
@ -707,6 +696,24 @@ static void DrawCargoIcons(CargoID i, uint waiting, int x, int y, uint width)
|
|||||||
|
|
||||||
if (sprite == 0) sprite = SPR_CARGO_GOODS;
|
if (sprite == 0) sprite = SPR_CARGO_GOODS;
|
||||||
|
|
||||||
|
return sprite;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Draws icons of waiting cargo in the StationView window
|
||||||
|
*
|
||||||
|
* @param i type of cargo
|
||||||
|
* @param waiting number of waiting units
|
||||||
|
* @param x x on-screen coordinate where to start with drawing icons
|
||||||
|
* @param y y coordinate
|
||||||
|
*/
|
||||||
|
static void DrawCargoIcons(CargoID i, uint waiting, int x, int y, uint width)
|
||||||
|
{
|
||||||
|
uint num = min((waiting + 5) / 10, width / 10); // maximum is width / 10 icons so it won't overflow
|
||||||
|
if (num == 0) return;
|
||||||
|
|
||||||
|
SpriteID sprite = GetCargoSprite(i);
|
||||||
|
|
||||||
do {
|
do {
|
||||||
DrawSprite(sprite, PAL_NONE, x, y);
|
DrawSprite(sprite, PAL_NONE, x, y);
|
||||||
x += 10;
|
x += 10;
|
||||||
|
Loading…
Reference in New Issue
Block a user