mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2026-07-21 01:59:44 +00:00
Codechange: make NIType a scoped enum
This commit is contained in:
@@ -81,19 +81,19 @@ static inline uint GetInspectWindowNumber(GrfSpecFeature feature, ConvertibleThr
|
||||
* The type of a property to show. This is used to
|
||||
* provide an appropriate representation in the GUI.
|
||||
*/
|
||||
enum NIType : uint8_t {
|
||||
NIT_INT, ///< The property is a simple integer
|
||||
NIT_CARGO, ///< The property is a cargo
|
||||
enum class NIType : uint8_t {
|
||||
Integer, ///< The property is a simple integer
|
||||
Cargo, ///< The property is a cargo
|
||||
};
|
||||
|
||||
using NIReadProc = uint32_t(const void *b);
|
||||
|
||||
/** Representation of the data from a NewGRF property. */
|
||||
struct NIProperty {
|
||||
std::string_view name; ///< A (human readable) name for the property
|
||||
std::string_view name; ///< A (human readable) name for the property
|
||||
NIReadProc *read_proc; ///< Callback proc to get the actual variable from memory
|
||||
uint8_t prop; ///< The number of the property
|
||||
uint8_t type;
|
||||
uint8_t prop; ///< The number of the property
|
||||
NIType type; ///< Type of property for chosing the appropriate representation.
|
||||
};
|
||||
|
||||
|
||||
@@ -439,8 +439,8 @@ struct NewGRFInspectWindow : Window {
|
||||
std::string GetPropertyString(const NIProperty &nip, uint value) const
|
||||
{
|
||||
switch (nip.type) {
|
||||
case NIT_INT: return GetString(STR_JUST_INT, value);
|
||||
case NIT_CARGO: return GetString(IsValidCargoType(static_cast<CargoType>(value)) ? CargoSpec::Get(value)->name : STR_QUANTITY_N_A);
|
||||
case NIType::Integer: return GetString(STR_JUST_INT, value);
|
||||
case NIType::Cargo: return GetString(IsValidCargoType(static_cast<CargoType>(value)) ? CargoSpec::Get(value)->name : STR_QUANTITY_N_A);
|
||||
default: NOT_REACHED();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -274,38 +274,38 @@ static const NIFeature _nif_industrytile = {
|
||||
#define NIP_ACCEPTED_CARGO(prop, base_class, slot, type, name) { name, [] (const void *b) -> uint32_t { return static_cast<const base_class *>(b)->GetAccepted(slot).cargo; }, prop, type }
|
||||
|
||||
static const NIProperty _nip_industries[] = {
|
||||
NIP_PRODUCED_CARGO(0x25, Industry, 0, NIT_CARGO, "produced cargo 0"),
|
||||
NIP_PRODUCED_CARGO(0x25, Industry, 1, NIT_CARGO, "produced cargo 1"),
|
||||
NIP_PRODUCED_CARGO(0x25, Industry, 2, NIT_CARGO, "produced cargo 2"),
|
||||
NIP_PRODUCED_CARGO(0x25, Industry, 3, NIT_CARGO, "produced cargo 3"),
|
||||
NIP_PRODUCED_CARGO(0x25, Industry, 4, NIT_CARGO, "produced cargo 4"),
|
||||
NIP_PRODUCED_CARGO(0x25, Industry, 5, NIT_CARGO, "produced cargo 5"),
|
||||
NIP_PRODUCED_CARGO(0x25, Industry, 6, NIT_CARGO, "produced cargo 6"),
|
||||
NIP_PRODUCED_CARGO(0x25, Industry, 7, NIT_CARGO, "produced cargo 7"),
|
||||
NIP_PRODUCED_CARGO(0x25, Industry, 8, NIT_CARGO, "produced cargo 8"),
|
||||
NIP_PRODUCED_CARGO(0x25, Industry, 9, NIT_CARGO, "produced cargo 9"),
|
||||
NIP_PRODUCED_CARGO(0x25, Industry, 10, NIT_CARGO, "produced cargo 10"),
|
||||
NIP_PRODUCED_CARGO(0x25, Industry, 11, NIT_CARGO, "produced cargo 11"),
|
||||
NIP_PRODUCED_CARGO(0x25, Industry, 12, NIT_CARGO, "produced cargo 12"),
|
||||
NIP_PRODUCED_CARGO(0x25, Industry, 13, NIT_CARGO, "produced cargo 13"),
|
||||
NIP_PRODUCED_CARGO(0x25, Industry, 14, NIT_CARGO, "produced cargo 14"),
|
||||
NIP_PRODUCED_CARGO(0x25, Industry, 15, NIT_CARGO, "produced cargo 15"),
|
||||
NIP_ACCEPTED_CARGO(0x26, Industry, 0, NIT_CARGO, "accepted cargo 0"),
|
||||
NIP_ACCEPTED_CARGO(0x26, Industry, 1, NIT_CARGO, "accepted cargo 1"),
|
||||
NIP_ACCEPTED_CARGO(0x26, Industry, 2, NIT_CARGO, "accepted cargo 2"),
|
||||
NIP_ACCEPTED_CARGO(0x26, Industry, 3, NIT_CARGO, "accepted cargo 3"),
|
||||
NIP_ACCEPTED_CARGO(0x26, Industry, 4, NIT_CARGO, "accepted cargo 4"),
|
||||
NIP_ACCEPTED_CARGO(0x26, Industry, 5, NIT_CARGO, "accepted cargo 5"),
|
||||
NIP_ACCEPTED_CARGO(0x26, Industry, 6, NIT_CARGO, "accepted cargo 6"),
|
||||
NIP_ACCEPTED_CARGO(0x26, Industry, 7, NIT_CARGO, "accepted cargo 7"),
|
||||
NIP_ACCEPTED_CARGO(0x26, Industry, 8, NIT_CARGO, "accepted cargo 8"),
|
||||
NIP_ACCEPTED_CARGO(0x26, Industry, 9, NIT_CARGO, "accepted cargo 9"),
|
||||
NIP_ACCEPTED_CARGO(0x26, Industry, 10, NIT_CARGO, "accepted cargo 10"),
|
||||
NIP_ACCEPTED_CARGO(0x26, Industry, 11, NIT_CARGO, "accepted cargo 11"),
|
||||
NIP_ACCEPTED_CARGO(0x26, Industry, 12, NIT_CARGO, "accepted cargo 12"),
|
||||
NIP_ACCEPTED_CARGO(0x26, Industry, 13, NIT_CARGO, "accepted cargo 13"),
|
||||
NIP_ACCEPTED_CARGO(0x26, Industry, 14, NIT_CARGO, "accepted cargo 14"),
|
||||
NIP_ACCEPTED_CARGO(0x26, Industry, 15, NIT_CARGO, "accepted cargo 15"),
|
||||
NIP_PRODUCED_CARGO(0x25, Industry, 0, NIType::Cargo, "produced cargo 0"),
|
||||
NIP_PRODUCED_CARGO(0x25, Industry, 1, NIType::Cargo, "produced cargo 1"),
|
||||
NIP_PRODUCED_CARGO(0x25, Industry, 2, NIType::Cargo, "produced cargo 2"),
|
||||
NIP_PRODUCED_CARGO(0x25, Industry, 3, NIType::Cargo, "produced cargo 3"),
|
||||
NIP_PRODUCED_CARGO(0x25, Industry, 4, NIType::Cargo, "produced cargo 4"),
|
||||
NIP_PRODUCED_CARGO(0x25, Industry, 5, NIType::Cargo, "produced cargo 5"),
|
||||
NIP_PRODUCED_CARGO(0x25, Industry, 6, NIType::Cargo, "produced cargo 6"),
|
||||
NIP_PRODUCED_CARGO(0x25, Industry, 7, NIType::Cargo, "produced cargo 7"),
|
||||
NIP_PRODUCED_CARGO(0x25, Industry, 8, NIType::Cargo, "produced cargo 8"),
|
||||
NIP_PRODUCED_CARGO(0x25, Industry, 9, NIType::Cargo, "produced cargo 9"),
|
||||
NIP_PRODUCED_CARGO(0x25, Industry, 10, NIType::Cargo, "produced cargo 10"),
|
||||
NIP_PRODUCED_CARGO(0x25, Industry, 11, NIType::Cargo, "produced cargo 11"),
|
||||
NIP_PRODUCED_CARGO(0x25, Industry, 12, NIType::Cargo, "produced cargo 12"),
|
||||
NIP_PRODUCED_CARGO(0x25, Industry, 13, NIType::Cargo, "produced cargo 13"),
|
||||
NIP_PRODUCED_CARGO(0x25, Industry, 14, NIType::Cargo, "produced cargo 14"),
|
||||
NIP_PRODUCED_CARGO(0x25, Industry, 15, NIType::Cargo, "produced cargo 15"),
|
||||
NIP_ACCEPTED_CARGO(0x26, Industry, 0, NIType::Cargo, "accepted cargo 0"),
|
||||
NIP_ACCEPTED_CARGO(0x26, Industry, 1, NIType::Cargo, "accepted cargo 1"),
|
||||
NIP_ACCEPTED_CARGO(0x26, Industry, 2, NIType::Cargo, "accepted cargo 2"),
|
||||
NIP_ACCEPTED_CARGO(0x26, Industry, 3, NIType::Cargo, "accepted cargo 3"),
|
||||
NIP_ACCEPTED_CARGO(0x26, Industry, 4, NIType::Cargo, "accepted cargo 4"),
|
||||
NIP_ACCEPTED_CARGO(0x26, Industry, 5, NIType::Cargo, "accepted cargo 5"),
|
||||
NIP_ACCEPTED_CARGO(0x26, Industry, 6, NIType::Cargo, "accepted cargo 6"),
|
||||
NIP_ACCEPTED_CARGO(0x26, Industry, 7, NIType::Cargo, "accepted cargo 7"),
|
||||
NIP_ACCEPTED_CARGO(0x26, Industry, 8, NIType::Cargo, "accepted cargo 8"),
|
||||
NIP_ACCEPTED_CARGO(0x26, Industry, 9, NIType::Cargo, "accepted cargo 9"),
|
||||
NIP_ACCEPTED_CARGO(0x26, Industry, 10, NIType::Cargo, "accepted cargo 10"),
|
||||
NIP_ACCEPTED_CARGO(0x26, Industry, 11, NIType::Cargo, "accepted cargo 11"),
|
||||
NIP_ACCEPTED_CARGO(0x26, Industry, 12, NIType::Cargo, "accepted cargo 12"),
|
||||
NIP_ACCEPTED_CARGO(0x26, Industry, 13, NIType::Cargo, "accepted cargo 13"),
|
||||
NIP_ACCEPTED_CARGO(0x26, Industry, 14, NIType::Cargo, "accepted cargo 14"),
|
||||
NIP_ACCEPTED_CARGO(0x26, Industry, 15, NIType::Cargo, "accepted cargo 15"),
|
||||
};
|
||||
|
||||
#undef NIP_PRODUCED_CARGO
|
||||
|
||||
Reference in New Issue
Block a user