<commit_before>﻿using System.Text.RegularExpressions;
using System.Globalization;

using UnityEngine;
using ColossalFramework;
using ColossalFramework.Globalization;

namespace BuildingThemes.GUI
{
    public class BuildingItem
    {
        private string m_name;
        private string m_displayName;
        private string m_steamID;
        private int m_level = -1;
        private Vector2 m_size;

        public BuildingInfo prefab;
        public Configuration.Building building;

        public bool included
        {
            get { return building != null && building.include; }
        }

        public string name
        {
            get
            {
                if (m_name == null)
                {
                    if (prefab != null) m_name = prefab.name;
                    else if (building != null) m_name = building.name;
                    else m_name = string.Empty;
                }
                return m_name;
            }
        }

        public string displayName
        {
            get
            {
                if (m_displayName != null) return m_displayName;

                m_displayName = Locale.GetUnchecked("BUILDING_TITLE", name);
                if (m_displayName.StartsWith("BUILDING_TITLE"))
                {
                    m_displayName = name.Substring(name.IndexOf('.') + 1).Replace("_Data", "");
                }
                m_displayName = CleanName(m_displayName, !name.Contains("."));

                return m_displayName;
            }
        }

        public Category category
        {
            get
            {
                if (prefab == null) return Category.None;

                ItemClass itemClass = prefab.m_class;
                if (itemClass.m_subService == ItemClass.SubService.ResidentialLow) return Category.ResidentialLow;
                if (itemClass.m_subService == ItemClass.SubService.ResidentialHigh) return Category.ResidentialHigh;
                if (itemClass.m_subService == ItemClass.SubService.CommercialLow) return Category.CommercialLow;
                if (itemClass.m_subService == ItemClass.SubService.CommercialHigh) return Category.CommercialHigh;
                if (itemClass.m_subService == ItemClass.SubService.CommercialLeisure) return Category.CommercialLeisure;
                if (itemClass.m_subService == ItemClass.SubService.CommercialTourist) return Category.CommercialTourism;
                if (itemClass.m_subService == ItemClass.SubService.IndustrialGeneric) return Category.Industrial;
                if (itemClass.m_subService == ItemClass.SubService.IndustrialFarming) return Category.Farming;
                if (itemClass.m_subService == ItemClass.SubService.IndustrialForestry) return Category.Forestry;
                if (itemClass.m_subService == ItemClass.SubService.IndustrialOil) return Category.Oil;
                if (itemClass.m_subService == ItemClass.SubService.IndustrialOre) return Category.Ore;
                if (itemClass.m_service == ItemClass.Service.Office) return Category.Office;

                return Category.None;
            }
        }

        public int level
        {
            get
            {
                if(m_level == -1)
                {
                    m_level = 0;
                    if (prefab != null)
                    {
                        if ((prefab.m_class.m_subService >= ItemClass.SubService.IndustrialForestry && prefab.m_class.m_subService <= ItemClass.SubService.IndustrialOre) ||
                            (prefab.m_class.m_subService >= ItemClass.SubService.CommercialLeisure && prefab.m_class.m_subService <= ItemClass.SubService.CommercialTourist))
                            m_level = 1;
                        else
                            m_level = (int)prefab.m_class.m_level + 1;
                    }
                    else
                    {
                        string cleanName = Regex.Replace(name, @"^{{.*?}}\.", "");
                        int.TryParse(Regex.Match(cleanName, @"(?<=[HL])\d").Value, out m_level);
                    }
                }
                return m_level;
            }
        }

        public int maxLevel
        {
            get
            {
                switch (category)
                {
                    case Category.None:
                    case Category.ResidentialHigh:
                    case Category.ResidentialLow:
                        return 5;
                    case Category.Farming:
                    case Category.Forestry:
                    case Category.Oil:
                    case Category.Ore:
                    case Category.CommercialLeisure:
                    case Category.CommercialTourism:<commit_msg>show levels for specializations in theme manager<commit_after>﻿using System.Text.RegularExpressions;
using System.Globalization;

using UnityEngine;
using ColossalFramework;
using ColossalFramework.Globalization;

namespace BuildingThemes.GUI
{
    public class BuildingItem
    {
        private string m_name;
        private string m_displayName;
        private string m_steamID;
        private int m_level = -1;
        private Vector2 m_size;

        public BuildingInfo prefab;
        public Configuration.Building building;

        public bool included
        {
            get { return building != null && building.include; }
        }

        public string name
        {
            get
            {
                if (m_name == null)
                {
                    if (prefab != null) m_name = prefab.name;
                    else if (building != null) m_name = building.name;
                    else m_name = string.Empty;
                }
                return m_name;
            }
        }

        public string displayName
        {
            get
            {
                if (m_displayName != null) return m_displayName;

                m_displayName = Locale.GetUnchecked("BUILDING_TITLE", name);
                if (m_displayName.StartsWith("BUILDING_TITLE"))
                {
                    m_displayName = name.Substring(name.IndexOf('.') + 1).Replace("_Data", "");
                }
                m_displayName = CleanName(m_displayName, !name.Contains("."));

                return m_displayName;
            }
        }

        public Category category
        {
            get
            {
                if (prefab == null) return Category.None;

                ItemClass itemClass = prefab.m_class;
                if (itemClass.m_subService == ItemClass.SubService.ResidentialLow) return Category.ResidentialLow;
                if (itemClass.m_subService == ItemClass.SubService.ResidentialHigh) return Category.ResidentialHigh;
                if (itemClass.m_subService == ItemClass.SubService.CommercialLow) return Category.CommercialLow;
                if (itemClass.m_subService == ItemClass.SubService.CommercialHigh) return Category.CommercialHigh;
                if (itemClass.m_subService == ItemClass.SubService.CommercialLeisure) return Category.CommercialLeisure;
                if (itemClass.m_subService == ItemClass.SubService.CommercialTourist) return Category.CommercialTourism;
                if (itemClass.m_subService == ItemClass.SubService.IndustrialGeneric) return Category.Industrial;
                if (itemClass.m_subService == ItemClass.SubService.IndustrialFarming) return Category.Farming;
                if (itemClass.m_subService == ItemClass.SubService.IndustrialForestry) return Category.Forestry;
                if (itemClass.m_subService == ItemClass.SubService.IndustrialOil) return Category.Oil;
                if (itemClass.m_subService == ItemClass.SubService.IndustrialOre) return Category.Ore;
                if (itemClass.m_service == ItemClass.Service.Office) return Category.Office;

                return Category.None;
            }
        }

        public int level
        {
            get
            {
                if(m_level == -1)
                {
                    m_level = 0;
                    if (prefab != null)
                    {
                        m_level = (int)prefab.m_class.m_level + 1;
                    }
                    else
                    {
                        string cleanName = Regex.Replace(name, @"^{{.*?}}\.", "");
                        int.TryParse(Regex.Match(cleanName, @"(?<=[HL])\d").Value, out m_level);
                    }
                }
                return m_level;
            }
        }

        public int maxLevel
        {
            get
            {
                switch (category)
                {
                    case Category.None:
                    case Category.ResidentialHigh:
                    case Category.ResidentialLow:
                        return 5;
                    case Category.Farming:
                    case Category.Forestry:
                    case Category.Oil:
                    case Category.Ore:
                    case Category.CommercialLeisure:
                    case Category.CommercialTourism:
{'fraction_non_alphanumeric': 0.07925356750823272, 'fraction_numerical': 0.001646542261251372, 'mean_word_length': 1.4604374831217932, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6952308', 'n_tokens_mistral': 2396, 'n_tokens_neox': 2216, 'n_words': 445}