Ejemplo n.º 1
0
        private void ShowInPanel(NetInfo info, List <NetworkSkinModifier> modifiers)
        {
            UIButton networkButton = FindComponentCached <UIButton>(info.name);

            if (networkButton != null)
            {
                TSCloseButton.SimulateClick();

                // apply the skin data in the tool window
                NetworkSkinPanelController.Instance.OnPrefabWithModifiersSelected(info, modifiers);

                UITabstrip        subMenuTabstrip = null;
                UIScrollablePanel scrollablePanel = null;
                UIComponent       current = networkButton, parent = networkButton.parent;
                int subMenuTabstripIndex = -1, menuTabstripIndex = -1;
                while (parent != null)
                {
                    if (current.name == "ScrollablePanel")
                    {
                        subMenuTabstripIndex = parent.zOrder;
                        scrollablePanel      = current as UIScrollablePanel;
                    }
                    if (current.name == "GTSContainer")
                    {
                        menuTabstripIndex = parent.zOrder;
                        subMenuTabstrip   = parent.Find <UITabstrip>("GroupToolstrip");
                    }
                    current = parent;
                    parent  = parent.parent;
                }
                UITabstrip menuTabstrip = current.Find <UITabstrip>("MainToolstrip");
                if (scrollablePanel == null ||
                    subMenuTabstrip == null ||
                    menuTabstrip == null ||
                    menuTabstripIndex == -1 ||
                    subMenuTabstripIndex == -1)
                {
                    return;
                }
                menuTabstrip.selectedIndex = menuTabstripIndex;
                menuTabstrip.ShowTab(menuTabstrip.tabs[menuTabstripIndex].name);
                subMenuTabstrip.selectedIndex = subMenuTabstripIndex;
                subMenuTabstrip.ShowTab(subMenuTabstrip.tabs[subMenuTabstripIndex].name);
                networkButton.SimulateClick();
                scrollablePanel.ScrollIntoView(networkButton);
            }
            SimulationManager.instance.AddAction(() => EventNetInfoPipetted?.Invoke(info));
        }
Ejemplo n.º 2
0
        private void ShowInPanel(PrefabInfo info)
        {
            UIButton button = FindComponentCached <UIButton>(info.name);

            if (button != null)
            {
                UIView.Find("TSCloseButton").SimulateClick();
                UITabstrip        subMenuTabstrip = null;
                UIScrollablePanel scrollablePanel = null;
                UIComponent       current = button, parent = button.parent;
                int subMenuTabstripIndex = -1, menuTabstripIndex = -1;
                while (parent != null)
                {
                    if (current.name == "ScrollablePanel")
                    {
                        subMenuTabstripIndex = parent.zOrder;
                        scrollablePanel      = current as UIScrollablePanel;
                    }
                    if (current.name == "GTSContainer")
                    {
                        menuTabstripIndex = parent.zOrder;
                        subMenuTabstrip   = parent.Find <UITabstrip>("GroupToolstrip");
                    }
                    current = parent;
                    parent  = parent.parent;
                }
                UITabstrip menuTabstrip = current.Find <UITabstrip>("MainToolstrip");
                if (scrollablePanel == null ||
                    subMenuTabstrip == null ||
                    menuTabstrip == null ||
                    menuTabstripIndex == -1 ||
                    subMenuTabstripIndex == -1)
                {
                    return;
                }
                menuTabstrip.selectedIndex = menuTabstripIndex;
                menuTabstrip.ShowTab(menuTabstrip.tabs[menuTabstripIndex].name);
                subMenuTabstrip.selectedIndex = subMenuTabstripIndex;
                subMenuTabstrip.ShowTab(subMenuTabstrip.tabs[subMenuTabstripIndex].name);
                button.SimulateClick();
                scrollablePanel.ScrollIntoView(button);
            }
        }
Ejemplo n.º 3
0
 public void OpenPanelAtModTab()
 {
     OpenPanel();
     m_modsTabstrip.ShowTab(CommonProperties.Acronym);
 }
Ejemplo n.º 4
0
        private void ShowInPanel(PrefabInfo info)
        {
            UIButton button = FindComponentCached <UIButton>(GetButtonName(info));

            //Debug.Log($"Button for {info.name}:{button?.name} <{(button == null ? "null" : button.GetType().ToString())}>");
            if (button != null)
            {
                // NS2 integration will go here when its menu filter bug is fixed

                UIView.Find("TSCloseButton").SimulateClick();
                UITabstrip        subMenuTabstrip = null;
                UIScrollablePanel scrollablePanel = null;
                UIPanel           filterPanel;
                UIComponent       current = button, parent = button.parent;

                int subMenuTabstripIndex = -1, menuTabstripIndex = -1;
                while (parent != null)
                {
                    if (current.name == "ScrollablePanel")
                    {
                        subMenuTabstripIndex = parent.zOrder;
                        scrollablePanel      = current as UIScrollablePanel;
                    }
                    if (current.name == "GTSContainer")
                    {
                        menuTabstripIndex = parent.zOrder;
                        subMenuTabstrip   = parent.Find <UITabstrip>("GroupToolstrip");
                    }
                    current = parent;
                    parent  = parent.parent;
                }

                UITabstrip menuTabstrip = current.Find <UITabstrip>("MainToolstrip");
                if (scrollablePanel == null || subMenuTabstrip == null || menuTabstrip == null || menuTabstripIndex == -1 || subMenuTabstripIndex == -1)
                {
                    Debug.Log($"UI Panel not found");
                    return;
                }

                menuTabstrip.selectedIndex = menuTabstripIndex;
                menuTabstrip.ShowTab(menuTabstrip.tabs[menuTabstripIndex].name);
                subMenuTabstrip.selectedIndex = subMenuTabstripIndex;
                subMenuTabstrip.ShowTab(subMenuTabstrip.tabs[subMenuTabstripIndex].name);

                filterPanel = scrollablePanel.parent.Find <UIPanel>("FilterPanel");
                if (filterPanel != null)
                {
                    foreach (UIMultiStateButton c in filterPanel.GetComponentsInChildren <UIMultiStateButton>())
                    {
                        if (c.isVisible && c.activeStateIndex == 1)
                        {
                            c.activeStateIndex = 0;
                        }
                    }
                }

                StartCoroutine(ShowInPanelProcess(scrollablePanel, button));
            }
            else
            {
                Debug.Log($"Button not found, falling back to FindIt/All");
                FindIt.Find("All", info);
            }
        }
Ejemplo n.º 5
0
        private void ShowInPanel(PrefabInfo info)
        {
            UIButton button = FindComponentCached <UIButton>(info.name);

            if (button != null)
            {
                if (hoveredId.NetSegment > 0 && isNS2Installed())
                {
                    try
                    {
                        ReflectIntoNS2();
                        return;
                    }
                    catch (Exception e)
                    {
                        Debug.Log($"NS2 failed:\n{e}");
                    }
                }

                UIView.Find("TSCloseButton").SimulateClick();
                UITabstrip        subMenuTabstrip = null;
                UIScrollablePanel scrollablePanel = null;
                UIPanel           filterPanel;
                UIComponent       current = button, parent = button.parent;

                int subMenuTabstripIndex = -1, menuTabstripIndex = -1;
                while (parent != null)
                {
                    if (current.name == "ScrollablePanel")
                    {
                        subMenuTabstripIndex = parent.zOrder;
                        scrollablePanel      = current as UIScrollablePanel;
                    }
                    if (current.name == "GTSContainer")
                    {
                        menuTabstripIndex = parent.zOrder;
                        subMenuTabstrip   = parent.Find <UITabstrip>("GroupToolstrip");
                    }
                    current = parent;
                    parent  = parent.parent;
                }
                UITabstrip menuTabstrip = current.Find <UITabstrip>("MainToolstrip");
                if (scrollablePanel == null || subMenuTabstrip == null || menuTabstrip == null || menuTabstripIndex == -1 || subMenuTabstripIndex == -1)
                {
                    Debug.Log($"UI Panel not found");
                    return;
                }

                scrollablePanel.parent.GetComponentInChildren <UIPanel>();
                menuTabstrip.selectedIndex = menuTabstripIndex;
                menuTabstrip.ShowTab(menuTabstrip.tabs[menuTabstripIndex].name);
                subMenuTabstrip.selectedIndex = subMenuTabstripIndex;
                subMenuTabstrip.ShowTab(subMenuTabstrip.tabs[subMenuTabstripIndex].name);

                filterPanel = scrollablePanel.parent.Find <UIPanel>("FilterPanel");
                if (filterPanel != null)
                {
                    foreach (UIMultiStateButton c in filterPanel.GetComponentsInChildren <UIMultiStateButton>())
                    {
                        if (c.isVisible && c.activeStateIndex == 1)
                        {
                            c.activeStateIndex = 0;
                        }
                    }
                }

                StartCoroutine(ShowInPanelProcess(scrollablePanel, button));
            }
            else
            {
                Debug.Log($"Button not found, falling back to FindIt/All");
                FindIt.Find("All", info);
            }
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Shows and populate the panel if NetTool is active, hide if not.
        /// </summary>
        public override void Update()
        {
            base.Update();

            // Fine Road Heights Net Tool support
            var newSelectedPrefab = _netToolWrapper.GetCurrentPrefab();

            if (newSelectedPrefab != null)
            {
                if (_selectedPrefab == newSelectedPrefab)
                {
                    return;
                }
                _selectedPrefab = newSelectedPrefab;

                var newSubPrefabs = NetUtil.GetSubPrefabs(_selectedPrefab);

                if (_subPrefabs != null && _subPrefabs.SequenceEqual(newSubPrefabs))
                {
                    return;
                }
                _subPrefabs = newSubPrefabs;

                var visibleTabCount   = 0;
                var firstVisibleIndex = -1;

                var requiredHeight = 0;

                // Populate tabs and options
                for (var i = 0; i < _subPrefabs.Length; i++)
                {
                    var tabName = NetUtil.NET_TYPE_NAMES[i];

                    if (_subPrefabs[i] != null)
                    {
                        if (firstVisibleIndex < 0)
                        {
                            firstVisibleIndex = i;
                        }

                        var visibleOptionCount = 0;

                        foreach (var component in _netTypePages[i].components)
                        {
                            var option = component as UIOption;
                            if (option == null)
                            {
                                continue;
                            }

                            // Pass the current prefab to the context-sensitive option
                            if (option.Populate(_subPrefabs[i]))
                            {
                                visibleOptionCount++;
                            }
                        }

                        if (visibleOptionCount > 0)
                        {
                            visibleTabCount++;
                            requiredHeight = Math.Max(requiredHeight, visibleOptionCount * (30 + Padding));
                            _tabstrip.ShowTab(tabName);
                        }
                        else
                        {
                            _tabstrip.HideTab(tabName);
                        }
                    }
                    else
                    {
                        // Hide unrelevant tabs
                        _tabstrip.HideTab(tabName);
                    }
                }

                if (_subPrefabs[_tabstrip.selectedIndex] == null)
                {
                    if (_subPrefabs[(int)NetType.Ground] != null)
                    {
                        _tabstrip.selectedIndex = (int)NetType.Ground;
                    }
                    else if (firstVisibleIndex >= 0)
                    {
                        _tabstrip.selectedIndex = firstVisibleIndex;
                    }
                }
                else
                {
                    _tabstrip.selectedIndex = _tabstrip.selectedIndex;
                }

                isVisible = visibleTabCount > 0;

                _tabstrip.tabPages.height = requiredHeight + 2 * PagesPadding;
                this.FitChildren();

                return;
            }

            if (isVisible)
            {
                isVisible       = false;
                _selectedPrefab = null;
                _subPrefabs     = null;
            }
        }
Ejemplo n.º 7
0
        private void ShowInPanel(NetInfo info, List <NetworkSkinModifier> modifiers)
        {
            UIButton networkButton = FindComponentCached <UIButton>(info.name);

            if (networkButton != null)
            {
                TSCloseButton.SimulateClick();

                // apply the skin data in the tool window
                NetworkSkinPanelController.Instance.OnPrefabWithModifiersSelected(info, modifiers);

                UITabstrip        subMenuTabstrip = null;
                UIScrollablePanel scrollablePanel = null;
                UIComponent       current = networkButton, parent = networkButton.parent;
                int subMenuTabstripIndex = -1, menuTabstripIndex = -1;
                while (parent != null)
                {
                    if (current.name == "ScrollablePanel")
                    {
                        subMenuTabstripIndex = parent.zOrder;
                        scrollablePanel      = current as UIScrollablePanel;
                    }
                    if (current.name == "GTSContainer")
                    {
                        menuTabstripIndex = parent.zOrder;
                        subMenuTabstrip   = parent.Find <UITabstrip>("GroupToolstrip");
                    }
                    current = parent;
                    parent  = parent.parent;
                }
                UITabstrip menuTabstrip = current.Find <UITabstrip>("MainToolstrip");
                if (scrollablePanel == null ||
                    subMenuTabstrip == null ||
                    menuTabstrip == null ||
                    menuTabstripIndex == -1 ||
                    subMenuTabstripIndex == -1)
                {
                    return;
                }
                menuTabstrip.selectedIndex = menuTabstripIndex;
                menuTabstrip.ShowTab(menuTabstrip.tabs[menuTabstripIndex].name);
                subMenuTabstrip.selectedIndex = subMenuTabstripIndex;
                subMenuTabstrip.ShowTab(subMenuTabstrip.tabs[subMenuTabstripIndex].name);

                // Clear filters
                UIPanel filterPanel = scrollablePanel.parent.Find <UIPanel>("FilterPanel");
                if (filterPanel != null)
                {
                    foreach (UIMultiStateButton c in filterPanel.GetComponentsInChildren <UIMultiStateButton>())
                    {
                        if (c.isVisible && c.activeStateIndex == 1)
                        {
                            c.activeStateIndex = 0;
                        }
                    }
                }

                StartCoroutine(DoClick(scrollablePanel, networkButton));
            }
            SimulationManager.instance.AddAction(() => EventNetInfoPipetted?.Invoke(info));
        }