diff --git a/src/town.h b/src/town.h --- a/src/town.h +++ b/src/town.h @@ -13,6 +13,9 @@ #include "viewport_type.h" #include "town_map.h" #include "subsidy_type.h" +#include "openttd.h" +#include "table/strings.h" +#include "company_func.h" #include "newgrf_storage.h" #include "cargotype.h" #include @@ -71,6 +74,7 @@ struct Town : TownPool::PoolItem<&_town_ CompanyID exclusivity; ///< which company has exclusivity uint8 exclusive_counter; ///< months till the exclusivity expires int16 ratings[MAX_COMPANIES]; ///< ratings of each company for this town + StringID town_label; TransportedCargoStat supplied[NUM_CARGO]; ///< Cargo statistics about supplied cargo. TransportedCargoStat received[NUM_TE]; ///< Cargo statistics about received cargotypes. @@ -108,8 +112,31 @@ struct Town : TownPool::PoolItem<&_town_ void InitializeLayout(TownLayout layout); + void UpdateLabel(); + /** - * Calculate the max town noise. + * Returns the correct town label, based on rating and population display settings. + */ + __forceinline StringID Label() const{ + if ((!(_game_mode == GM_EDITOR) && (_local_company < MAX_COMPANIES)) && _settings_client.gui.colour_based_on_town_rating) { + return _settings_client.gui.population_in_label ? STR_VIEWPORT_TOWN_POP_VERY_POOR_RATING + this->town_label : STR_VIEWPORT_TOWN_VERY_POOR_RATING + this->town_label; + } else { + return _settings_client.gui.population_in_label ? STR_VIEWPORT_TOWN_POP : STR_VIEWPORT_TOWN; + } + } + + /** + * Returns the correct town small label, based on rating and population display settings. + */ + __forceinline StringID SmallLabel() const{ + if ((!(_game_mode == GM_EDITOR) && (_local_company < MAX_COMPANIES)) && _settings_client.gui.colour_based_on_town_rating) { + return STR_VIEWPORT_TOWN_TINY_VERY_POOR_RATING + this->town_label; + } else { + return STR_VIEWPORT_TOWN_TINY_WHITE; + } + } + + /** Calculate the max town noise * The value is counted using the population divided by the content of the * entry in town_noise_population corresponding to the town's tolerance. * @return the maximum noise level the town will tolerate.