Ejemplo n.º 1
0
        private void Awake()
        {
            SVMServiceBuildingDetailPanel.eventOnDistrictSelectionChanged += onDistrictChanged;


            mainPanel            = GetComponentInChildren <UIScrollablePanel>();
            mainPanel.autoLayout = false;
            m_uiHelper           = new UIHelperExtension(mainPanel);

            SVMUtils.createUIElement(out UILabel lbl, mainPanel.transform, "DistrictColorLabel", new Vector4(5, 5, 250, 40));

            allowColorChange = SVMConfigWarehouse.allowColorChanging(extension.ConfigIndexKey);
            if (allowColorChange)
            {
                SVMUtils.LimitWidth(lbl, 250);
                lbl.autoSize = true;
                lbl.localeID = "SVM_DISTRICT_COLOR_LABEL";

                m_districtColor = KlyteUtils.CreateColorField(mainPanel);
                m_districtColor.eventSelectedColorChanged += onChangeDistrictColor;

                SVMUtils.createUIElement(out UIButton resetColor, mainPanel.transform, "DistrictColorReset", new Vector4(290, 0, 0, 0));
                SVMUtils.initButton(resetColor, false, "ButtonMenu");
                SVMUtils.LimitWidth(resetColor, 200);
                resetColor.textPadding = new RectOffset(5, 5, 5, 2);
                resetColor.autoSize    = true;
                resetColor.localeID    = "SVM_RESET_COLOR";
                resetColor.eventClick += onResetColor;
            }


            SVMUtils.createElement(out m_assetSelectorWindow, mainPanel.transform);
            m_assetSelectorWindow.setTabContent(this);
        }
        public void openInfo(ushort buildingID)
        {
            WorldInfoPanel.HideAllWorldInfoPanels();

            var ssds = ServiceSystemDefinition.from(Singleton <BuildingManager> .instance.m_buildings.m_buffer[buildingID].Info);
            var ext  = ssds.First().GetTransportExtension();

            m_buildingIdSelecionado          = default(InstanceID);
            m_ignoreDistrict.isChecked       = ext.GetIgnoreDistrict(buildingID);
            m_buildingIdSelecionado.Building = buildingID;
            buildingNameField.text           = Singleton <BuildingManager> .instance.GetBuildingName(buildingID, default(InstanceID));


            var configIdx = ssds.First().toConfigIndex();


            String bgIcon = SVMConfigWarehouse.getIconServiceSystem(configIdx);
            String fgIcon = SVMConfigWarehouse.getFgIconServiceSystem(configIdx);

            buildingTypeIcon.normalFgSprite = bgIcon;
            buildingTypeIconFg.spriteName   = fgIcon;

            SVMController.instance.CloseSVMPanel();
            Show();
            EventOnBuildingSelChanged?.Invoke(buildingID);
        }
 private void CleanColor(uint codedId)
 {
     if (!SVMConfigWarehouse.allowColorChanging(ConfigIndexKey))
     {
         return;
     }
     checkId(codedId);
     SafeCleanProperty(codedId, BuildingConfig.COLOR);
 }
 private Color32 GetColor(uint codedId)
 {
     if (SVMConfigWarehouse.allowColorChanging(ConfigIndexKey))
     {
         checkId(codedId);
         string value = SafeGet(codedId, BuildingConfig.COLOR);
         return(SVMUtils.DeserializeColor(value, ItSepLvl3));
     }
     return(new Color32(0, 0, 0, 1));
 }
Ejemplo n.º 5
0
 internal void OpenAt(ServiceSystemDefinition ssd)
 {
     m_StripMain.selectedIndex = 0;
     if (ssd != null)
     {
         var catIdx = SVMConfigWarehouse.getCategory(ssd.toConfigIndex());
         m_StripBuilings.selectedIndex = (int)catIdx;
         m_StripBuilingsStrips[catIdx].selectedIndex = m_StripBuilingsStrips[catIdx].Find <UIComponent>(ssd.GetDefType().Name)?.zOrder ?? 0;
     }
     ServiceVehiclesManagerMod.instance.controller.OpenSVMPanel();
 }
 private void SetColor(uint codedId, Color32 value)
 {
     if (!SVMConfigWarehouse.allowColorChanging(ConfigIndexKey))
     {
         return;
     }
     checkId(codedId);
     if (value == Color.clear)
     {
         CleanColor(codedId);
     }
     else
     {
         SafeSet(codedId, BuildingConfig.COLOR, SVMUtils.SerializeColor(value, ItSepLvl3));
     }
 }
 private void SetColor(uint codedId, Color32 value)
 {
     if (!SVMConfigWarehouse.allowColorChanging(ConfigIndexKey))
     {
         return;
     }
     checkId(codedId);
     if (value == Color.clear)
     {
         CleanColor(codedId);
     }
     else
     {
         SafeSet(codedId, BuildingConfig.COLOR, string.Join(ItSepLvl3, new string[] { value.r.ToString(), value.g.ToString(), value.b.ToString() }));
     }
 }
        private void Awake()
        {
            CreateMainPanel();

            CreateScrollPanel();

            SetPreviewWindow();

            BindParentChanges();

            CreateRemoveUndesiredModelsButton();

            PopulateCheckboxes();

            var ssd = Singleton <T> .instance.GetSSD();

            var  extension        = ssd.GetTransportExtension();
            bool allowColorChange = SVMConfigWarehouse.allowColorChanging(extension.ConfigIndexKey);

            if (allowColorChange)
            {
                SVMUtils.createUIElement(out UILabel lbl, m_mainPanel.transform, "DistrictColorLabel", new Vector4(5, m_mainPanel.height - 30, 120, 40));
                SVMUtils.LimitWidth(lbl, 120);
                lbl.autoSize = true;
                lbl.localeID = "SVM_COLOR_LABEL";

                m_color = KlyteUtils.CreateColorField(m_mainPanel);
                m_color.eventSelectedColorChanged += onChangeColor;

                SVMUtils.createUIElement(out UIButton resetColor, m_mainPanel.transform, "DistrictColorReset", new Vector4(m_mainPanel.width - 110, m_mainPanel.height - 35, 0, 0));
                SVMUtils.initButton(resetColor, false, "ButtonMenu");
                SVMUtils.LimitWidth(resetColor, 100);
                resetColor.textPadding = new RectOffset(5, 5, 5, 2);
                resetColor.autoSize    = true;
                resetColor.localeID    = "SVM_RESET_COLOR";
                resetColor.eventClick += onResetColor;
            }
            else
            {
                m_mainPanel.height -= 40;
            }
        }
 private Color32 GetColor(uint codedId)
 {
     if (SVMConfigWarehouse.allowColorChanging(ConfigIndexKey))
     {
         checkId(codedId);
         string value = SafeGet(codedId, BuildingConfig.COLOR);
         if (!string.IsNullOrEmpty(value))
         {
             var list = value.Split(ItSepLvl3.ToCharArray()).ToList();
             if (list.Count == 3 && byte.TryParse(list[0], out byte r) && byte.TryParse(list[1], out byte g) && byte.TryParse(list[2], out byte b))
             {
                 return(new Color32(r, g, b, 255));
             }
             else
             {
                 SVMUtils.doLog($"val = {value}; list = {String.Join(",", list.ToArray())} (Size {list.Count})");
             }
         }
     }
     return(new Color32(0, 0, 0, 1));
 }
        private void Awake()
        {
            SVMTabPanel.eventOnDistrictSelectionChanged += onDistrictChanged;


            mainPanel            = GetComponentInChildren <UIScrollablePanel>();
            mainPanel.autoLayout = false;
            m_uiHelper           = new UIHelperExtension(mainPanel);

            SVMUtils.createUIElement(out UILabel lbl, mainPanel.transform, "DistrictColorLabel", new Vector4(5, 5, 250, 40));

            allowColorChange = SVMConfigWarehouse.allowColorChanging(extension.ConfigIndexKey);
            if (allowColorChange)
            {
                SVMUtils.LimitWidth(lbl, 250);
                lbl.autoSize = true;
                lbl.localeID = "SVM_DISTRICT_COLOR_LABEL";

                m_districtColor = KlyteUtils.CreateColorField(mainPanel);
                m_districtColor.eventSelectedColorChanged += onChangeDistrictColor;

                SVMUtils.createUIElement(out UIButton resetColor, mainPanel.transform, "DistrictColorReset", new Vector4(290, 0, 0, 0));
                SVMUtils.initButton(resetColor, false, "ButtonMenu");
                SVMUtils.LimitWidth(resetColor, 200);
                resetColor.textPadding = new RectOffset(5, 5, 5, 2);
                resetColor.autoSize    = true;
                resetColor.localeID    = "SVM_RESET_COLOR";
                resetColor.eventClick += onResetColor;
            }
            if (extension.GetAllowDistrictServiceRestrictions())
            {
                m_districtAllowOutsiders = m_uiHelper.AddCheckboxLocale("SVM_ALLOW_OUTSIDERS", true, (x) =>
                {
                    if (!getCurrentSelectedId(out int currentDistrict) || isLoading)
                    {
                        return;
                    }
                    extension.SetAllowOutsiders((uint)currentDistrict, x);
                    m_districtAllowOutsiders.GetComponentInChildren <UILabel>().textColor = Color.white;
                });
        private void OnBuildingChange(ushort buildingId)
        {
            SVMUtils.doLog("EventOnBuildingSelChanged");
            m_isLoading = true;
            IEnumerable <ServiceSystemDefinition> ssds = ServiceSystemDefinition.from(Singleton <BuildingManager> .instance.m_buildings.m_buffer[buildingId].Info);

            if (!ssds.Contains(Singleton <T> .instance.GetSSD()))
            {
                m_mainPanel.isVisible = false;
                return;
            }
            m_mainPanel.isVisible = true;
            var ssd = Singleton <T> .instance.GetSSD();

            var  ext            = ssd.GetTransportExtension();
            bool isCustomConfig = ext.GetIgnoreDistrict(buildingId);

            SVMUtils.doLog("ssd = {0}", ssd);

            List <string> selectedAssets;
            Color         selectedColor;

            if (isCustomConfig)
            {
                selectedAssets = ext.GetAssetListBuilding(buildingId);
                selectedColor  = ext.GetColorBuilding(buildingId);
            }
            else
            {
                var districtId = SVMUtils.GetBuildingDistrict(buildingId);
                selectedAssets = ext.GetAssetListDistrict(districtId);
                selectedColor  = ext.GetColorDistrict(districtId);
            }
            foreach (var i in m_checkboxes.Keys)
            {
                m_checkboxes[i].isChecked = selectedAssets.Contains(i);
            }
            if (m_color != null)
            {
                m_color.selectedColor = selectedColor;
            }

            if (isCustomConfig)
            {
                m_title.text = string.Format(Locale.Get("SVM_ASSET_SELECT_WINDOW_TITLE"), Singleton <BuildingManager> .instance.GetBuildingName(buildingId, default(InstanceID)), SVMConfigWarehouse.getNameForServiceSystem(ssd.toConfigIndex()));
            }
            else
            {
                var districtId = SVMUtils.GetBuildingDistrict(buildingId);
                if (districtId > 0)
                {
                    m_title.text = string.Format(Locale.Get("SVM_ASSET_SELECT_WINDOW_TITLE_DISTRICT"), Singleton <DistrictManager> .instance.GetDistrictName(SVMUtils.GetBuildingDistrict(buildingId)), SVMConfigWarehouse.getNameForServiceSystem(ssd.toConfigIndex()));
                }
                else
                {
                    m_title.text = string.Format(Locale.Get("SVM_ASSET_SELECT_WINDOW_TITLE_CITY"), SVMConfigWarehouse.getNameForServiceSystem(ssd.toConfigIndex()));
                }
            }

            m_isLoading = false;
            m_previewPanel.isVisible = false;
        }
Ejemplo n.º 12
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;
            }
        }
        public SVMConfigWarehouse.ConfigIndex toConfigIndex()
        {
            var th = this;

            return(SVMConfigWarehouse.getConfigServiceSystemForDefinition(ref th));
        }
 public SVMConfigWarehouse.ConfigIndex toConfigIndex()
 {
     return(SVMConfigWarehouse.getConfigServiceSystemForDefinition(this));
 }