示例#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);
        }
 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));
 }
 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;
                });