public void Awake()
        {
            if (instance != null)
            {
                Destroy(this);
                return;
            }
            instance = this;
            GameObject gameObject = GameObject.FindGameObjectWithTag("MainCamera");

            if (gameObject != null)
            {
                m_CameraController = gameObject.GetComponent <CameraController>();
            }
            createInfoView();
            CreateIgnoreDistrictOption();

            SVMUtils.createUIElement(out UIPanel confContainer, panelTransform, "SubConfigContainer", new Vector4(m_buildingInfoPanel.width, 0, 0, m_buildingInfoPanel.height));
            confContainer.autoLayout          = true;
            confContainer.autoLayoutDirection = LayoutDirection.Horizontal;
            confContainer.wrapLayout          = false;
            confContainer.height       = m_buildingInfoPanel.height;
            confContainer.clipChildren = false;

            foreach (var kv in ServiceSystemDefinition.sysDefinitions)
            {
                Type targetType = KlyteUtils.GetImplementationForGenericType(typeof(SVMBuildingSSDConfigWindow <>), kv.Value);
                SVMUtils.createElement(targetType, confContainer.transform);
            }
        }
示例#2
0
        private void CreateTsdTabstrip(out UITabstrip strip, UIComponent parent, UiCategoryTab category)
        {
            TLMUtils.createUIElement(out strip, parent.transform, "TLMTabstrip", new Vector4(5, 0, parent.width - 10, 40));
            var effectiveOffsetY = strip.height;

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

            UIButton tabTemplate = CreateTabSubStripTemplate();

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

            foreach (var kv in TransportSystemDefinition.sysDefinitions)
            {
                Type[] components;
                Type   targetType;
                try
                {
                    targetType = KlyteUtils.GetImplementationForGenericType(category.getTabGenericContentImpl(), kv.Value);
                    components = new Type[] { targetType };
                }
                catch
                {
                    continue;
                }

                GameObject tab       = Instantiate(tabTemplate.gameObject);
                GameObject body      = Instantiate(bodyContent.gameObject);
                var        configIdx = kv.Key.toConfigIndex();
                String     name      = kv.Value.Name;
                TLMUtils.doLog($"configIdx = {configIdx};kv.Key = {kv.Key}; kv.Value= {kv.Value} ");
                String   bgIcon    = TLMConfigWarehouse.getBgIconForIndex(configIdx);
                String   fgIcon    = kv.Key.getTransportTypeIcon();
                UIButton tabButton = tab.GetComponent <UIButton>();
                tabButton.tooltip          = TLMConfigWarehouse.getNameForTransportType(configIdx);
                tabButton.hoveredBgSprite  = bgIcon;
                tabButton.focusedBgSprite  = bgIcon;
                tabButton.normalBgSprite   = bgIcon;
                tabButton.disabledBgSprite = bgIcon;
                tabButton.focusedColor     = Color.green;
                tabButton.hoveredColor     = new Color(0, 0.5f, 0f);
                tabButton.color            = Color.black;
                tabButton.disabledColor    = Color.gray;
                if (!string.IsNullOrEmpty(fgIcon))
                {
                    TLMUtils.createUIElement(out UIButton secSprite, tabButton.transform, "OverSprite", new Vector4(5, 5, 30, 30));
                    secSprite.normalFgSprite       = fgIcon;
                    secSprite.foregroundSpriteMode = UIForegroundSpriteMode.Scale;
                    secSprite.isInteractive        = false;
                    secSprite.disabledColor        = Color.black;
                }
                strip.AddTab(name, tab, body, components);
            }
        }
示例#3
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;
            }
        }