mirror of https://github.com/OpenTTD/OpenTTD
Add: Function to get largest cargo icon size.
parent
8db7c79e79
commit
76701c4622
|
@ -9,6 +9,7 @@
|
||||||
|
|
||||||
#include "stdafx.h"
|
#include "stdafx.h"
|
||||||
#include "cargotype.h"
|
#include "cargotype.h"
|
||||||
|
#include "core/geometry_func.hpp"
|
||||||
#include "newgrf_cargo.h"
|
#include "newgrf_cargo.h"
|
||||||
#include "string_func.h"
|
#include "string_func.h"
|
||||||
#include "strings_func.h"
|
#include "strings_func.h"
|
||||||
|
@ -70,6 +71,19 @@ void SetupCargoForClimate(LandscapeID l)
|
||||||
std::fill(insert, std::end(CargoSpec::array), CargoSpec{});
|
std::fill(insert, std::end(CargoSpec::array), CargoSpec{});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get dimensions of largest cargo icon.
|
||||||
|
* @return Dimensions of largest cargo icon.
|
||||||
|
*/
|
||||||
|
Dimension GetLargestCargoIconSize()
|
||||||
|
{
|
||||||
|
Dimension size = {0, 0};
|
||||||
|
for (const CargoSpec *cs : _sorted_cargo_specs) {
|
||||||
|
size = maxdim(size, GetSpriteSize(cs->GetCargoIcon()));
|
||||||
|
}
|
||||||
|
return size;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the cargo ID of a default cargo, if present.
|
* Get the cargo ID of a default cargo, if present.
|
||||||
* @param l Landscape
|
* @param l Landscape
|
||||||
|
@ -179,7 +193,7 @@ static bool CargoSpecClassSorter(const CargoSpec * const &a, const CargoSpec * c
|
||||||
void InitializeSortedCargoSpecs()
|
void InitializeSortedCargoSpecs()
|
||||||
{
|
{
|
||||||
_sorted_cargo_specs.clear();
|
_sorted_cargo_specs.clear();
|
||||||
/* Add each cargo spec to the list. */
|
/* Add each cargo spec to the list, and determine the largest cargo icon size. */
|
||||||
for (const CargoSpec *cargo : CargoSpec::Iterate()) {
|
for (const CargoSpec *cargo : CargoSpec::Iterate()) {
|
||||||
_sorted_cargo_specs.push_back(cargo);
|
_sorted_cargo_specs.push_back(cargo);
|
||||||
}
|
}
|
||||||
|
|
|
@ -185,6 +185,7 @@ void SetupCargoForClimate(LandscapeID l);
|
||||||
CargoID GetCargoIDByLabel(CargoLabel cl);
|
CargoID GetCargoIDByLabel(CargoLabel cl);
|
||||||
CargoID GetCargoIDByBitnum(uint8_t bitnum);
|
CargoID GetCargoIDByBitnum(uint8_t bitnum);
|
||||||
CargoID GetDefaultCargoID(LandscapeID l, CargoType ct);
|
CargoID GetDefaultCargoID(LandscapeID l, CargoType ct);
|
||||||
|
Dimension GetLargestCargoIconSize();
|
||||||
|
|
||||||
void InitializeSortedCargoSpecs();
|
void InitializeSortedCargoSpecs();
|
||||||
extern std::array<uint8_t, NUM_CARGO> _sorted_cargo_types;
|
extern std::array<uint8_t, NUM_CARGO> _sorted_cargo_types;
|
||||||
|
|
Loading…
Reference in New Issue