示例#1
0
        private bool internalRefreshPanel(bool refreshCustoms)
        {
            Logger.logInfo(PanelHelper.LOG_CUSTOM_PANELS, "CustomEducationGroupPanel.CustomRefreshPanel");
            if (Interlocked.CompareExchange(ref this.refreshing, 1, 0) == 1)
            {
                Logger.logInfo(PanelHelper.LOG_CUSTOM_PANELS, "CustomEducationGroupPanel.CustomRefreshPanel -- Can't refresh, already refreshing");
                return(true);
            }


            // Refresh the Custom Panels only when specified -- Can't refresh these panels before completing the init process
            if (refreshCustoms)
            {
                try {
                    // Refresh the Education Panel
                    UIComponent          healthcareDefault = this.m_Strip.Find(EDUCATION_COMPONENT_NAME);
                    GeneratedScrollPanel healthcarePanel   = this.m_Strip.GetComponentInContainer(healthcareDefault, typeof(CustomEducationPanel)) as GeneratedScrollPanel;
                    if (healthcarePanel != null)
                    {
                        Logger.logInfo(PanelHelper.LOG_CUSTOM_PANELS, "CustomEducationGroupPanel.CustomRefreshPanel -- Refreshing the Education Panel");
                        healthcarePanel.RefreshPanel();
                    }

                    // Refresh the Dormitory Panel
                    UIComponent          dormitoryDefault = this.m_Strip.Find(DORMITORY_COMPONENT_NAME);
                    GeneratedScrollPanel dormitoryPanel   = this.m_Strip.GetComponentInContainer(dormitoryDefault, typeof(DormitoryPanel)) as GeneratedScrollPanel;
                    if (dormitoryPanel != null)
                    {
                        Logger.logInfo(PanelHelper.LOG_CUSTOM_PANELS, "CustomEducationGroupPanel.CustomRefreshPanel -- Refreshing the Dormitory Panel");
                        dormitoryPanel.RefreshPanel();
                    }
                } catch (Exception e) {
                    Logger.logError(PanelHelper.LOG_CUSTOM_PANELS, "CustomEducationGroupPanel.CustomRefreshPanel -- Exception refreshing the Custom Panels: {0} -- {1}", e, e.StackTrace);
                    this.refreshing = 0;
                    return(true);
                }
            }

            // Proceed with the existing logic
            if (this.groupFilter != GeneratedGroupPanel.GroupFilter.None)
            {
                this.PopulateGroups(this.groupFilter, this.sortingMethod);
            }
            else if (!string.IsNullOrEmpty(this.serviceName))
            {
                this.DefaultGroup(this.serviceName);
            }
            else
            {
                this.DefaultGroup(EnumExtensions.Name <ItemClass.Service>(this.service));
            }

            this.refreshing = 0;
            return(true);
        }
示例#2
0
        private UIButton AddButton(Type type, UITabstrip strip, string category, string[] editorCategories, string tooltip, bool enabled)
        {
            if (GameObject.Find(String.Format("{0}Panel", category)) != null)
            {
                return(null);
            }

            GameObject subbarButtonTemplate = UITemplateManager.GetAsGameObject("SubbarButtonTemplate");
            GameObject subbarPanelTemplate  = UITemplateManager.GetAsGameObject("SubbarPanelTemplate");


            UIButton button = (UIButton)strip.AddTab(category, subbarButtonTemplate, subbarPanelTemplate, type);

            button.isEnabled = enabled;

            GeneratedScrollPanel generatedScrollPanel = (GeneratedScrollPanel)strip.GetComponentInContainer(button, type);

            if (generatedScrollPanel != null)
            {
                generatedScrollPanel.component.isInteractive   = true;
                generatedScrollPanel.m_OptionsBar              = ToolsModifierControl.mainToolbar.m_OptionsBar;
                generatedScrollPanel.m_DefaultInfoTooltipAtlas = ToolsModifierControl.mainToolbar.m_DefaultInfoTooltipAtlas;

                if (generatedScrollPanel is EditorPropsPanel)
                {
                    ((EditorPropsPanel)generatedScrollPanel).m_editorCategories = editorCategories;
                    ((EditorPropsPanel)generatedScrollPanel).category           = category;
                }

                if (enabled)
                {
                    generatedScrollPanel.RefreshPanel();
                }
            }

            button.tooltip = tooltip;
            return(button);
        }
示例#3
0
#pragma warning disable 108,114
        protected UIButton SpawnButtonEntry(UITabstrip strip, string name, string category, bool isDefaultCategory,
#pragma warning restore 108,114
                                            string localeID, string unlockText, string spriteBase, bool enabled, bool forceFillContainer)
        {
            int objectIndex = (int)typeof(GeneratedGroupPanel).GetField("m_ObjectIndex", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(this);

            // TAM Edit Start
            Type type = typeof(GeneratedScrollPanel)
                        .Assembly
                        .GetTypes()
                        .FirstOrDefault(t => string.Equals(t.Name, name + "Panel", StringComparison.InvariantCultureIgnoreCase));

            // TAM Edit End

            if (type != null && !type.IsSubclassOf(typeof(GeneratedScrollPanel)))
            {
                type = null;
            }

            UIButton uIButton;

            if (strip.childCount > objectIndex)
            {
                uIButton = (strip.components[objectIndex] as UIButton);
            }
            else
            {
                GameObject asGameObject  = UITemplateManager.GetAsGameObject(kSubbarButtonTemplate);
                GameObject asGameObject2 = UITemplateManager.GetAsGameObject(kSubbarPanelTemplate);
                uIButton = (strip.AddTab(category, asGameObject, asGameObject2, type) as UIButton);
            }

            uIButton.isEnabled = enabled;
            uIButton.gameObject.GetComponent <TutorialUITag>().tutorialTag = category;
            GeneratedScrollPanel generatedScrollPanel = strip.GetComponentInContainer(uIButton, type) as GeneratedScrollPanel;

            if (generatedScrollPanel != null)
            {
                generatedScrollPanel.component.isInteractive   = true;
                generatedScrollPanel.m_OptionsBar              = this.m_OptionsBar;
                generatedScrollPanel.m_DefaultInfoTooltipAtlas = this.m_DefaultInfoTooltipAtlas;
                if (forceFillContainer || enabled)
                {
                    generatedScrollPanel.category = ((!isDefaultCategory) ? category : string.Empty);
                    generatedScrollPanel.RefreshPanel();
                }
            }

            // TAM Edit Start
            var customAtlas = AtlasManager.instance.GetAtlas(category);

            if (customAtlas != null)
            {
                uIButton.atlas = customAtlas;
            }
            // TAM Edit End

            string text = spriteBase + category;

            uIButton.normalFgSprite   = text;
            uIButton.focusedFgSprite  = text + "Focused";
            uIButton.hoveredFgSprite  = text + "Hovered";
            uIButton.pressedFgSprite  = text + "Pressed";
            uIButton.disabledFgSprite = text + "Disabled";

            if (!string.IsNullOrEmpty(localeID) && !string.IsNullOrEmpty(unlockText))
            {
                uIButton.tooltip = Locale.Get(localeID, category) + " - " + unlockText;
            }
            else if (!string.IsNullOrEmpty(localeID))
            {
                uIButton.tooltip = Locale.Get(localeID, category);
            }

            typeof(GeneratedGroupPanel).GetField("m_ObjectIndex", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(this, objectIndex + 1);
            return(uIButton);
        }