private UITabstrip BeautificationTabstrip(UITabstrip s) { UIButton button = this.FindButton(s, "Beautification"); if (button == null) { return(null); } Type groupPanelType = typeof(BeautificationGroupPanel); GeneratedGroupPanel groupPanel = (GeneratedGroupPanel)s.GetComponentInContainer(button, groupPanelType); if (groupPanel == null) { return(null); } UITabstrip strip = groupPanel.Find <UITabstrip>("GroupToolstrip"); if (strip == null) { return(null); } return(strip); }
private static UITabstrip BeautificationTabstrip(UITabstrip s) { var button = FindButton(s, "Landscaping"); if (button == null) { return(null); } var groupPanelType = typeof(LandscapingGroupPanel); var groupPanel = (GeneratedGroupPanel)s.GetComponentInContainer(button, groupPanelType); var strip = groupPanel?.Find <UITabstrip>("GroupToolstrip"); return(strip); }
private UIButton OwnSpawnButtonEntry(UITabstrip strip, string name, string category, bool isDefaultCategory, string localeID, string unlockText, string spriteBase, bool enabled, bool forceFillContainer) { Debug.Print("SpawnButtonEntry"); System.Type type = System.Type.GetType(name + "Panel"); type = typeof(SearchPanel); if (type != null && !type.IsSubclassOf(typeof(GeneratedScrollPanel))) type = (System.Type)null; UIButton uiButton; if (strip.childCount > GetObjectIndex(this)) { uiButton = strip.components[GetObjectIndex(this)] as UIButton; } else { GameObject asGameObject1 = UITemplateManager.GetAsGameObject("SubbarButtonTemplate"); GameObject asGameObject2 = UITemplateManager.GetAsGameObject("SubbarPanelTemplate"); uiButton = strip.AddTab(category, asGameObject1, asGameObject2, type) as UIButton; } uiButton.isEnabled = enabled; uiButton.gameObject.GetComponent<TutorialUITag>().tutorialTag = category; SearchPanel generatedScrollPanel = strip.GetComponentInContainer(uiButton, type) as SearchPanel; Debug.Print(generatedScrollPanel); if ((UnityEngine.Object)generatedScrollPanel != (UnityEngine.Object)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(); } } string str = spriteBase + category; uiButton.normalFgSprite = str; uiButton.focusedFgSprite = str + "Focused"; uiButton.hoveredFgSprite = str + "Hovered"; uiButton.pressedFgSprite = str + "Pressed"; uiButton.disabledFgSprite = str + "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); IncObjectIndex(this); return uiButton; }
private static UIButton AddButton(Type type, UITabstrip strip, string category, string[] editorCategories, string tooltip, bool enabled) { if (GameObject.Find($"{category}Panel") != null) { return(null); } var subbarButtonTemplate = UITemplateManager.GetAsGameObject("SubbarButtonTemplate"); var subbarPanelTemplate = UITemplateManager.GetAsGameObject("SubbarPanelTemplate"); var button = (UIButton)strip.AddTab(category, subbarButtonTemplate, subbarPanelTemplate, type); button.isEnabled = enabled; var 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; var panel = generatedScrollPanel as EditorPropsPanel; if (panel != null) { panel.m_editorCategories = editorCategories; panel.category = category; } if (enabled) { generatedScrollPanel.RefreshPanel(); } } button.tooltip = tooltip; return(button); }
protected UIButton SpawnSubEntry(MainToolbar tb, UITabstrip strip, string name, string localeID, string unlockText, string spriteBase, bool enabled) { System.Type type = System.Type.GetType(name + "Group" + "Panel"); type = typeof(SearchGroupPanel); if (type != null && !type.IsSubclassOf(typeof(GeneratedGroupPanel))) type = (System.Type)null; if (type == null) return (UIButton)null; UIButton button; GameObject asGameObject1 = UITemplateManager.GetAsGameObject("MainToolbarButtonTemplate"); GameObject asGameObject2 = UITemplateManager.GetAsGameObject("ScrollableSubPanelTemplate"); button = strip.AddTab(name, asGameObject1, asGameObject2, type) as UIButton; button.isEnabled = enabled; //button.gameObject.GetComponent<TutorialUITag>().tutorialTag = name; //GeneratedGroupPanel generatedGroupPanel = strip.tabContainer.Find<UIPanel>("SearchPanel").GetComponent<GeneratedGroupPanel>() as GeneratedGroupPanel; SearchGroupPanel generatedGroupPanel = strip.GetComponentInContainer(button, type) as SearchGroupPanel; generatedGroupPanel.enabled = true; if ((UnityEngine.Object)generatedGroupPanel != (UnityEngine.Object)null) { generatedGroupPanel.component.isInteractive = true; generatedGroupPanel.m_OptionsBar = this.GetOptionsBar(tb); generatedGroupPanel.m_DefaultInfoTooltipAtlas = this.GetDefaultInfoTooltipAtlas(tb); if (enabled) { generatedGroupPanel.RefreshPanel(); } } /* button.normalBgSprite = this.GetBackgroundSprite(button, spriteBase, name, "Normal"); button.focusedBgSprite = this.GetBackgroundSprite(button, spriteBase, name, "Focused"); button.hoveredBgSprite = this.GetBackgroundSprite(button, spriteBase, name, "Hovered"); button.pressedBgSprite = this.GetBackgroundSprite(button, spriteBase, name, "Pressed"); button.disabledBgSprite = this.GetBackgroundSprite(button, spriteBase, name, "Disabled");*/ this.IncObjectIndex(tb); return button; }
#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); }
public void Start() { try { GameObject gameObject = GameObject.Find("FindItMainButton"); if (gameObject != null) { return; } isRicoEnabled = IsRicoEnabled(); isPOEnabled = IsPOEnabled(); isTVPPatchEnabled = IsTVPPatchEnabled(); if (isPOEnabled) { POTool = new ProceduralObjectsTool(); } list = AssetTagList.instance; UITabstrip tabstrip = ToolsModifierControl.mainToolbar.component as UITabstrip; m_defaultXPos = tabstrip.relativePosition.x; UpdateMainToolbar(); GameObject asGameObject = UITemplateManager.GetAsGameObject("MainToolbarButtonTemplate"); GameObject asGameObject2 = UITemplateManager.GetAsGameObject("ScrollableSubPanelTemplate"); mainButton = tabstrip.AddTab("FindItMainButton", asGameObject, asGameObject2, new Type[] { typeof(UIGroupPanel) }) as UIButton; mainButton.atlas = atlas; mainButton.normalBgSprite = "ToolbarIconGroup6Normal"; mainButton.focusedBgSprite = "ToolbarIconGroup6Focused"; mainButton.hoveredBgSprite = "ToolbarIconGroup6Hovered"; mainButton.pressedBgSprite = "ToolbarIconGroup6ressed"; mainButton.disabledBgSprite = "ToolbarIconGroup6Disabled"; mainButton.normalFgSprite = "FindIt"; mainButton.focusedFgSprite = "FindItFocused"; mainButton.hoveredFgSprite = "FindItHovered"; mainButton.pressedFgSprite = "FindItPressed"; mainButton.disabledFgSprite = "FindItDisabled"; mainButton.tooltip = "Find It! " + (ModInfo.isBeta ? "[BETA] " : "") + ModInfo.version; Locale locale = (Locale)typeof(LocaleManager).GetField("m_Locale", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(LocaleManager.instance); Locale.Key key = new Locale.Key { m_Identifier = "TUTORIAL_ADVISER_TITLE", m_Key = mainButton.name }; if (!locale.Exists(key)) { locale.AddLocalizedString(key, "Find It! " + ModInfo.version); } key = new Locale.Key { m_Identifier = "TUTORIAL_ADVISER", m_Key = mainButton.name }; if (!locale.Exists(key)) { locale.AddLocalizedString(key, "Thanks for subscribing to Find It! 2.\n\nStart typing some keywords into the input field to find the desired asset.\n\nCheck the workshop page occasionally for new features or bug reports."); } FieldInfo m_ObjectIndex = typeof(MainToolbar).GetField("m_ObjectIndex", BindingFlags.Instance | BindingFlags.NonPublic); m_ObjectIndex.SetValue(ToolsModifierControl.mainToolbar, (int)m_ObjectIndex.GetValue(ToolsModifierControl.mainToolbar) + 1); mainButton.gameObject.GetComponent <TutorialUITag>().tutorialTag = name; m_groupPanel = tabstrip.GetComponentInContainer(mainButton, typeof(UIGroupPanel)) as UIGroupPanel; if (m_groupPanel != null) { m_groupPanel.name = "FindItGroupPanel"; m_groupPanel.enabled = true; m_groupPanel.component.isInteractive = true; m_groupPanel.m_OptionsBar = ToolsModifierControl.mainToolbar.m_OptionsBar; m_groupPanel.m_DefaultInfoTooltipAtlas = ToolsModifierControl.mainToolbar.m_DefaultInfoTooltipAtlas; if (ToolsModifierControl.mainToolbar.enabled) { m_groupPanel.RefreshPanel(); } scrollPanel = UIScrollPanel.Create(m_groupPanel.GetComponentInChildren <UIScrollablePanel>()); scrollPanel.eventClicked += OnButtonClicked; scrollPanel.eventVisibilityChanged += (c, p) => { HideAllOptionPanels(); if (p && scrollPanel.selectedItem != null) { // Simulate item click UIScrollPanelItem.ItemData item = scrollPanel.selectedItem; UIScrollPanelItem panelItem = scrollPanel.GetItem(0); panelItem.Display(scrollPanel.selectedItem, 0); panelItem.component.SimulateClick(); scrollPanel.selectedItem = item; scrollPanel.Refresh(); } }; scrollPanel.eventTooltipEnter += (c, p) => { UIScrollPanelItem.RefreshTooltipAltas(p.source); }; searchBox = scrollPanel.parent.AddUIComponent <UISearchBox>(); searchBox.scrollPanel = scrollPanel; searchBox.relativePosition = new Vector3(0, 0); searchBox.Search(); } else { Debugging.Message("GroupPanel not found"); } m_roadsPanel = FindObjectOfType <RoadsPanel>(); m_beautificationPanel = FindObjectOfType <BeautificationPanel>(); defaultPanel = GameObject.Find("FindItDefaultPanel").GetComponent <UIPanel>(); defaultPanelAtlas = defaultPanel.atlas; defaultPanelBackgroundSprite = defaultPanel.backgroundSprite; UpdateDefaultPanelBackground(); Debugging.Message("Initialized"); } catch (Exception e) { Debugging.Message("Start failed"); Debugging.LogException(e); enabled = false; } }
public void Start() { try { isRicoEnabled = IsRicoEnabled(); GameObject gameObject = GameObject.Find("FindItMainButton"); if (gameObject != null) { return; } list = AssetTagList.instance; UITabstrip tabstrip = ToolsModifierControl.mainToolbar.component as UITabstrip; // TODO: temporary /*tabstrip.eventComponentAdded += (c, p) => * { * foreach (UIComponent tab in tabstrip.tabPages.components) * { * DebugUtils.Log(tab.name); * * if(tab.name == "LandscapingPanel") * { * tab.components[0].relativePosition = new Vector3(0, -134); * tab.components[1].relativePosition = new Vector3(0, -109); * tab.components[1].height = 218; * foreach(UIScrollablePanel panel in tab.components[1].GetComponentsInChildren<UIScrollablePanel>()) * { * panel.autoLayoutStart = LayoutStart.TopLeft; * panel.scrollWheelDirection = UIOrientation.Vertical; * panel.scrollWheelAmount = 104; * panel.wrapLayout = true; * panel.width = 764; * } * } * } * };*/ m_defaultXPos = tabstrip.relativePosition.x; UpdateMainToolbar(); GameObject asGameObject = UITemplateManager.GetAsGameObject("MainToolbarButtonTemplate"); GameObject asGameObject2 = UITemplateManager.GetAsGameObject("ScrollableSubPanelTemplate"); mainButton = tabstrip.AddTab("FindItMainButton", asGameObject, asGameObject2, new Type[] { typeof(UIGroupPanel) }) as UIButton; mainButton.atlas = atlas; Locale locale = (Locale)typeof(LocaleManager).GetField("m_Locale", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(LocaleManager.instance); Locale.Key key = new Locale.Key { m_Identifier = "TUTORIAL_ADVISER_TITLE", m_Key = mainButton.name }; if (!locale.Exists(key)) { locale.AddLocalizedString(key, "Find It! " + ModInfo.version); } key = new Locale.Key { m_Identifier = "TUTORIAL_ADVISER", m_Key = mainButton.name }; if (!locale.Exists(key)) { locale.AddLocalizedString(key, "Thanks for subscribing to Find It!\n\nStart typing some keywords into the input field to find the desired asset.\n\nIf you like the mod please consider leaving a rating on the steam workshop."); } FieldInfo m_ObjectIndex = typeof(MainToolbar).GetField("m_ObjectIndex", BindingFlags.Instance | BindingFlags.NonPublic); m_ObjectIndex.SetValue(ToolsModifierControl.mainToolbar, (int)m_ObjectIndex.GetValue(ToolsModifierControl.mainToolbar) + 1); mainButton.gameObject.GetComponent <TutorialUITag>().tutorialTag = name; m_groupPanel = tabstrip.GetComponentInContainer(mainButton, typeof(UIGroupPanel)) as UIGroupPanel; if (m_groupPanel != null) { m_groupPanel.name = "FindItGroupPanel"; m_groupPanel.enabled = true; m_groupPanel.component.isInteractive = true; m_groupPanel.m_OptionsBar = ToolsModifierControl.mainToolbar.m_OptionsBar; m_groupPanel.m_DefaultInfoTooltipAtlas = ToolsModifierControl.mainToolbar.m_DefaultInfoTooltipAtlas; if (ToolsModifierControl.mainToolbar.enabled) { m_groupPanel.RefreshPanel(); } scrollPanel = UIScrollPanel.Create(m_groupPanel.GetComponentInChildren <UIScrollablePanel>()); scrollPanel.eventClicked += OnButtonClicked; scrollPanel.eventVisibilityChanged += (c, p) => { HideAllOptionPanels(); if (p && scrollPanel.selectedItem != null) { // Simulate item click UIScrollPanelItem.ItemData item = scrollPanel.selectedItem; UIScrollPanelItem panelItem = scrollPanel.GetItem(0); panelItem.Display(scrollPanel.selectedItem, 0); panelItem.component.SimulateClick(); scrollPanel.selectedItem = item; scrollPanel.Refresh(); } }; scrollPanel.eventTooltipEnter += (c, p) => { UIScrollPanelItem.RefreshTooltipAltas(p.source); }; searchBox = scrollPanel.parent.AddUIComponent <UISearchBox>(); searchBox.scrollPanel = scrollPanel; searchBox.relativePosition = new Vector3(0, 0); searchBox.Search(); } else { DebugUtils.Warning("GroupPanel not found"); } mainButton.normalBgSprite = "ToolbarIconGroup6Normal"; mainButton.focusedBgSprite = "ToolbarIconGroup6Focused"; mainButton.hoveredBgSprite = "ToolbarIconGroup6Hovered"; mainButton.pressedBgSprite = "ToolbarIconGroup6ressed"; mainButton.disabledBgSprite = "ToolbarIconGroup6Disabled"; mainButton.normalFgSprite = "FindIt"; mainButton.focusedFgSprite = "FindItFocused"; mainButton.hoveredFgSprite = "FindItHovered"; mainButton.pressedFgSprite = "FindItPressed"; mainButton.disabledFgSprite = "FindItDisabled"; mainButton.tooltip = "Find It! " + ModInfo.version; m_beautificationPanel = FindObjectOfType <BeautificationPanel>(); DebugUtils.Log("Initialized"); } catch (Exception e) { DebugUtils.Log("Start failed"); DebugUtils.LogException(e); enabled = false; } }
private static UITabstrip BeautificationTabstrip(UITabstrip s) { var button = FindButton(s, "Landscaping"); if (button == null) { return null; } var groupPanelType = typeof(LandscapingGroupPanel); var groupPanel = (GeneratedGroupPanel)s.GetComponentInContainer(button, groupPanelType); var strip = groupPanel?.Find<UITabstrip>("GroupToolstrip"); return strip; }
private static UIButton AddButton(Type type, UITabstrip strip, string category, string[] editorCategories, string tooltip, bool enabled) { if (GameObject.Find($"{category}Panel") != null) { return null; } var subbarButtonTemplate = UITemplateManager.GetAsGameObject("SubbarButtonTemplate"); var subbarPanelTemplate = UITemplateManager.GetAsGameObject("SubbarPanelTemplate"); var button = (UIButton)strip.AddTab(category, subbarButtonTemplate, subbarPanelTemplate, type); button.isEnabled = enabled; var 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; var panel = generatedScrollPanel as EditorPropsPanel; if (panel != null) { panel.m_editorCategories = editorCategories; panel.category = category; } if (enabled) { generatedScrollPanel.RefreshPanel(); } } button.tooltip = tooltip; return button; }
#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; }