Esempio n. 1
0
        public static string getCategoryIcon(this CategoryTab tab)
        {
            switch (tab)
            {
            case CategoryTab.EmergencyVehicles:
                return("SubBarFireDepartmentDisaster");

            case CategoryTab.OutsideConnection:
                return("IconRightArrow");

            case CategoryTab.PublicTransport:
                return("ToolbarIconPublicTransport");

            case CategoryTab.SecurityVehicles:
                return("ToolbarIconPolice");

            case CategoryTab.HealthcareVehicles:
                return("ToolbarIconHealthcare");

            case CategoryTab.OtherServices:
                return("ToolbarIconHelp");

            default:
                throw new Exception($"Not supported: {tab}");
            }
        }
Esempio n. 2
0
        public static string getCategoryName(this CategoryTab tab)
        {
            switch (tab)
            {
            case CategoryTab.EmergencyVehicles:
                return(Locale.Get("MAIN_TOOL_ND", "FireDepartment"));

            case CategoryTab.OutsideConnection:
                return(Locale.Get("AREA_CONNECTIONS"));

            case CategoryTab.PublicTransport:
                return(Locale.Get("ASSETIMPORTER_CATEGORY", "PublicTransport"));

            case CategoryTab.SecurityVehicles:
                return(Locale.Get("ASSETIMPORTER_CATEGORY", "Police"));

            case CategoryTab.HealthcareVehicles:
                return(Locale.Get("ASSETIMPORTER_CATEGORY", "Healthcare"));

            case CategoryTab.OtherServices:
                return(Locale.Get("ROUTECHECKBOX6"));

            default:
                throw new Exception($"Not supported: {tab}");
            }
        }
Esempio n. 3
0
        public static string getCategoryName(this CategoryTab tab)
        {
            switch (tab)
            {
            case CategoryTab.EmergencyVehicles:
                return(Locale.Get("MAIN_TOOL_ND", "FireDepartment"));

            case CategoryTab.OutsideConnection:
                return(Locale.Get("AREA_CONNECTIONS"));

            case CategoryTab.PublicTransport:
                return(Locale.Get("ASSETIMPORTER_CATEGORY", "PublicTransport"));

            case CategoryTab.SecurityVehicles:
                return(Locale.Get("ASSETIMPORTER_CATEGORY", "Police"));

            case CategoryTab.HealthcareVehicles:
                return(Locale.Get("ASSETIMPORTER_CATEGORY", "Healthcare"));

            case CategoryTab.OtherServices:
                return(Locale.Get("ROUTECHECKBOX6"));

            case CategoryTab.Fish:
                return(Locale.Get("MAIN_CATEGORY", "IndustryFishing"));

            case CategoryTab.Garbage:
                return(Locale.Get("MAIN_TOOL", "Garbage"));

            case CategoryTab.Industry:
                return(Locale.Get("TUTORIAL_ADVISER_TITLE", "InfoViewIndustry"));

            case CategoryTab.Residential:
                return(Locale.Get("STATS_16"));

            default:
                throw new Exception($"Not supported: {tab}");
            }
        }
Esempio n. 4
0
        private void CreateSsdTabstrip(ref UITabstrip strip, ref Dictionary <CategoryTab, UITabstrip> substrips, UIPanel titleLine, UIComponent parent, bool buildings = false)
        {
            SVMUtils.createUIElement(out strip, parent.transform, "SVMTabstrip", new Vector4(5, 0, parent.width - 10, 40));

            var effectiveOffsetY = strip.height + (titleLine?.height ?? 0);

            SVMUtils.createUIElement(out UITabContainer tabContainer, parent.transform, "SVMTabContainer", new Vector4(0, 40, parent.width, parent.height - 40));
            strip.tabPages = tabContainer;

            UIButton tabTemplate = CreateTabTemplate();

            UIComponent bodyContent = CreateContentTemplate(parent.width - 10, parent.height - effectiveOffsetY - 50);

            SVMUtils.createUIElement(out UIPanel bodySuper, null);
            bodySuper.name = "Container";
            bodySuper.area = new Vector4(0, 40, parent.width, parent.height - 50);

            Dictionary <CategoryTab, UIComponent> tabsCategories = new Dictionary <CategoryTab, UIComponent>();

            foreach (var catTab in Enum.GetValues(typeof(CategoryTab)).Cast <CategoryTab>())
            {
                GameObject tabCategory     = Instantiate(tabTemplate.gameObject);
                GameObject contentCategory = Instantiate(bodySuper.gameObject);
                UIButton   tabButtonSuper  = tabCategory.GetComponent <UIButton>();
                tabButtonSuper.tooltip           = catTab.getCategoryName();
                tabButtonSuper.normalFgSprite    = catTab.getCategoryIcon();
                tabsCategories[catTab]           = strip.AddTab(catTab.ToString(), tabCategory, contentCategory);
                tabsCategories[catTab].isVisible = false;
                SVMUtils.createUIElement(out UITabstrip subStrip, contentCategory.transform, "SVMTabstripCat" + catTab, new Vector4(5, 0, bodySuper.width - 10, 40));
                SVMUtils.createUIElement(out UITabContainer tabSubContainer, contentCategory.transform, "SVMTabContainer" + catTab, new Vector4(5, effectiveOffsetY, bodySuper.width - 10, bodySuper.height - effectiveOffsetY));
                subStrip.tabPages = tabSubContainer;
                substrips[catTab] = subStrip;
            }
            foreach (var kv in ServiceSystemDefinition.sysDefinitions)
            {
                GameObject tab       = Instantiate(tabTemplate.gameObject);
                GameObject body      = Instantiate(bodyContent.gameObject);
                var        configIdx = kv.Key.toConfigIndex();
                String     name      = kv.Value.Name;
                SVMUtils.doLog($"configIdx = {configIdx};kv.Key = {kv.Key}; kv.Value= {kv.Value} ");
                String   bgIcon    = SVMConfigWarehouse.getIconServiceSystem(configIdx);
                String   fgIcon    = SVMConfigWarehouse.getFgIconServiceSystem(configIdx);
                UIButton tabButton = tab.GetComponent <UIButton>();
                tabButton.tooltip        = SVMConfigWarehouse.getNameForServiceSystem(configIdx);
                tabButton.normalFgSprite = bgIcon;
                if (!string.IsNullOrEmpty(fgIcon))
                {
                    SVMUtils.createUIElement(out UISprite sprite, tabButton.transform, "OverSprite", new Vector4(0, 0, 40, 40));
                    sprite.spriteName = fgIcon;
                    sprite.atlas      = SVMController.taSVM;
                }
                Type[] components;
                Type   targetType;
                if (buildings)
                {
                    targetType = KlyteUtils.GetImplementationForGenericType(typeof(SVMTabControllerBuildingList <>), kv.Value);
                    components = new Type[] { targetType };
                }
                else
                {
                    try
                    {
                        targetType = KlyteUtils.GetImplementationForGenericType(typeof(SVMTabControllerDistrictList <>), kv.Value);
                        components = new Type[] { targetType };
                    }
                    catch
                    {
                        continue;
                    }
                }
                CategoryTab catTab = SVMConfigWarehouse.getCategory(configIdx);
                substrips[catTab].AddTab(name, tab, body, components);

                body.GetComponent <UIComponent>().eventVisibilityChanged += (x, y) =>
                {
                    if (y)
                    {
                        m_directionLabel.isVisible = kv.Key.outsideConnection;
                    }
                };
                tabsCategories[catTab].isVisible = true;
            }
        }
Esempio n. 5
0
        private void CreateSsdTabstrip(ref UITabstrip strip, ref Dictionary <CategoryTab, UITabstrip> substrips, UIPanel titleLine, UIComponent parent, bool buildings = false)
        {
            KlyteMonoUtils.CreateUIElement(out strip, parent.transform, "VMCTabstrip", new Vector4(5, 0, parent.width - 10, 40));

            float effectiveOffsetY = strip.height + (titleLine?.height ?? 0);

            KlyteMonoUtils.CreateUIElement(out UITabContainer tabContainer, parent.transform, "VMCTabContainer", new Vector4(0, 40, parent.width, parent.height - 40));
            strip.tabPages = tabContainer;

            UIButton tabTemplate = CreateTabTemplate();

            UIComponent bodyContent = CreateContentTemplate(parent.width - 10, parent.height - effectiveOffsetY - 50);

            KlyteMonoUtils.CreateUIElement(out UIPanel bodySuper, null);
            bodySuper.name = "Container";
            bodySuper.area = new Vector4(0, 40, parent.width, parent.height - 50);

            var tabsCategories = new Dictionary <CategoryTab, UIComponent>();

            foreach (CategoryTab catTab in Enum.GetValues(typeof(CategoryTab)).Cast <CategoryTab>())
            {
                GameObject tabCategory     = Instantiate(tabTemplate.gameObject);
                GameObject contentCategory = Instantiate(bodySuper.gameObject);
                UIButton   tabButtonSuper  = tabCategory.GetComponent <UIButton>();
                tabButtonSuper.tooltip           = catTab.getCategoryName();
                tabButtonSuper.normalFgSprite    = catTab.getCategoryIcon();
                tabsCategories[catTab]           = strip.AddTab(catTab.ToString(), tabCategory, contentCategory);
                tabsCategories[catTab].isVisible = false;
                KlyteMonoUtils.CreateUIElement(out UITabstrip subStrip, contentCategory.transform, "VMCTabstripCat" + catTab, new Vector4(5, 0, bodySuper.width - 10, 40));
                KlyteMonoUtils.CreateUIElement(out UITabContainer tabSubContainer, contentCategory.transform, "VMCTabContainer" + catTab, new Vector4(5, effectiveOffsetY, bodySuper.width - 10, bodySuper.height - effectiveOffsetY));
                subStrip.tabPages = tabSubContainer;
                substrips[catTab] = subStrip;
            }
            foreach (KeyValuePair <ServiceSystemDefinition, IVMCSysDef> kv in ServiceSystemDefinition.sysDefinitions)
            {
                if (kv.Value.GetSSD().GetDistrictExtension().GetAllBasicAssets().Count == 0)
                {
                    continue;
                }

                GameObject tab  = Instantiate(tabTemplate.gameObject);
                GameObject body = Instantiate(bodyContent.gameObject);
                string     name = kv.Value.GetType().Name;
                LogUtils.DoLog($"kv.Key = {kv.Key}; kv.Value= {kv.Value} ");
                string   bgIcon    = kv.Key.IconServiceSystem;
                string   fgIcon    = kv.Key.FgIconServiceSystem;
                UIButton tabButton = tab.GetComponent <UIButton>();
                tabButton.tooltip        = kv.Key.NameForServiceSystem;
                tabButton.normalFgSprite = bgIcon;
                if (!string.IsNullOrEmpty(fgIcon))
                {
                    KlyteMonoUtils.CreateUIElement(out UISprite sprite, tabButton.transform, "OverSprite", new Vector4(0, 0, 40, 40));
                    sprite.spriteName = fgIcon;
                }
                Type[] components;
                Type   targetType;
                if (buildings)
                {
                    try
                    {
                        targetType = ReflectionUtils.GetImplementationForGenericType(typeof(VMCTabControllerBuildingList <>), kv.Value.GetType());
                        components = new Type[] { targetType };
                    }
                    catch
                    {
                        continue;
                    }
                }
                else
                {
                    try
                    {
                        targetType = ReflectionUtils.GetImplementationForGenericType(typeof(VMCTabControllerDistrictList <>), kv.Value.GetType());
                        components = new Type[] { targetType };
                    }
                    catch
                    {
                        continue;
                    }
                }
                CategoryTab catTab = kv.Key.Category;
                substrips[catTab].AddTab(name, tab, body, components);

                body.GetComponent <UIComponent>().eventVisibilityChanged += (x, y) =>
                {
                    if (y)
                    {
                        //   m_directionLabel.isVisible = kv.Key.outsideConnection;
                    }
                };
                tabsCategories[catTab].isVisible = true;
            }
        }