Esempio n. 1
0
        protected override bool SpecialKeyboardHandling(Event evt)
        {
            DropdownElement selectedChild = base.CurrentlyRenderedTree.GetSelectedChild();
            bool            result;

            if (selectedChild is NewScriptDropdownElement)
            {
                if (evt.keyCode == KeyCode.Return || evt.keyCode == KeyCode.KeypadEnter)
                {
                    selectedChild.OnAction();
                    evt.Use();
                    GUIUtility.ExitGUI();
                }
                if (evt.keyCode == KeyCode.Escape)
                {
                    base.GoToParent();
                    evt.Use();
                }
                result = true;
            }
            else
            {
                result = false;
            }
            return(result);
        }
        private void DrawDropdown(float anim, DropdownElement group)
        {
            Rect screenRect = new Rect(base.position);

            screenRect.x       = 1f + base.position.width * anim;
            screenRect.y       = 30f;
            screenRect.height -= 30f;
            screenRect.width  -= 2f;
            GUILayout.BeginArea(screenRect);
            Rect   rect = GUILayoutUtility.GetRect(10f, 25f);
            string name = group.name;

            GUI.Label(rect, name, AdvancedDropdownWindow.s_Styles.header);
            if (group.parent != null)
            {
                Rect position = new Rect(rect.x + 4f, rect.y + 7f, 13f, 13f);
                if (Event.current.type == EventType.Repaint)
                {
                    AdvancedDropdownWindow.s_Styles.leftArrow.Draw(position, false, false, false, false);
                }
                if (Event.current.type == EventType.MouseDown && rect.Contains(Event.current.mousePosition))
                {
                    this.GoToParent();
                    Event.current.Use();
                }
            }
            this.DrawList(group);
            GUILayout.EndArea();
        }
        private void DrawList(DropdownElement element)
        {
            element.m_Scroll = GUILayout.BeginScrollView(element.m_Scroll, new GUILayoutOption[0]);
            EditorGUIUtility.SetIconSize(new Vector2(16f, 16f));
            Rect rect = default(Rect);

            for (int i = 0; i < element.children.Count; i++)
            {
                DropdownElement dropdownElement = element.children[i];
                bool            flag            = i == element.m_SelectedItem;
                dropdownElement.Draw(flag, this.hasSearch);
                Rect lastRect = GUILayoutUtility.GetLastRect();
                if (flag)
                {
                    rect = lastRect;
                }
                if (Event.current.type == EventType.MouseMove || Event.current.type == EventType.MouseDown)
                {
                    if (!flag && lastRect.Contains(Event.current.mousePosition))
                    {
                        element.m_SelectedItem = i;
                        Event.current.Use();
                    }
                }
                if (Event.current.type == EventType.MouseDown && lastRect.Contains(Event.current.mousePosition))
                {
                    element.m_SelectedItem = i;
                    if (this.CurrentlyRenderedTree.GetSelectedChild().children.Any <DropdownElement>())
                    {
                        this.GoToChild(this.CurrentlyRenderedTree);
                    }
                    else if (this.CurrentlyRenderedTree.GetSelectedChild().OnAction())
                    {
                        this.CloseWindow();
                        GUIUtility.ExitGUI();
                    }
                    Event.current.Use();
                }
            }
            EditorGUIUtility.SetIconSize(Vector2.zero);
            GUILayout.EndScrollView();
            if (this.m_ScrollToSelected && Event.current.type == EventType.Repaint)
            {
                this.m_ScrollToSelected = false;
                Rect lastRect2 = GUILayoutUtility.GetLastRect();
                if (rect.yMax - lastRect2.height > element.m_Scroll.y)
                {
                    element.m_Scroll.y = rect.yMax - lastRect2.height;
                    base.Repaint();
                }
                if (rect.y < element.m_Scroll.y)
                {
                    element.m_Scroll.y = rect.y;
                    base.Repaint();
                }
            }
        }
 private void OnDirtyList()
 {
     this.m_DirtyList = false;
     this.m_MainTree  = this.RebuildTree();
     if (this.hasSearch)
     {
         this.m_SearchTree = this.RebuildSearch();
     }
 }
Esempio n. 5
0
        protected override DropdownElement RebuildTree()
        {
            GroupDropdownElement groupDropdownElement = new GroupDropdownElement(this.m_Label);

            for (int i = 0; i < this.m_DisplayedOptions.Length; i++)
            {
                string   text  = this.m_DisplayedOptions[i];
                string[] array = text.Split(new char[]
                {
                    '/'
                });
                DropdownElement dropdownElement = groupDropdownElement;
                for (int j = 0; j < array.Length; j++)
                {
                    string name = array[j];
                    if (j == array.Length - 1)
                    {
                        SearchableDropdownElement searchableDropdownElement = new SearchableDropdownElement(name, text, i);
                        searchableDropdownElement.SetParent(dropdownElement);
                        dropdownElement.AddChild(searchableDropdownElement);
                        if (i == AdvancedDropdown.m_SelectedIndex)
                        {
                            DropdownElement dropdownElement2 = dropdownElement;
                            DropdownElement item             = searchableDropdownElement;
                            while (dropdownElement2 != null)
                            {
                                dropdownElement2.selectedItem = dropdownElement2.children.IndexOf(item);
                                item             = dropdownElement2;
                                dropdownElement2 = dropdownElement2.parent;
                            }
                        }
                    }
                    else
                    {
                        string groupPathId = "";
                        for (int k = 0; k <= j; k++)
                        {
                            groupPathId = groupPathId + array[k] + ".";
                        }
                        DropdownElement dropdownElement3 = dropdownElement.children.SingleOrDefault((DropdownElement c) => c.id == groupPathId);
                        if (dropdownElement3 == null)
                        {
                            dropdownElement3 = new GroupDropdownElement(name, groupPathId);
                            dropdownElement3.SetParent(dropdownElement);
                            dropdownElement.AddChild(dropdownElement3);
                        }
                        dropdownElement = dropdownElement3;
                    }
                }
            }
            return(groupDropdownElement);
        }
 private void GoToChild(DropdownElement parent)
 {
     this.m_LastTime = DateTime.Now.Ticks;
     if (this.m_NewAnimTarget < 0f)
     {
         this.m_NewAnimTarget = 1f + this.m_NewAnimTarget;
     }
     else
     {
         this.m_NewAnimTarget = 1f;
     }
     this.CurrentlyRenderedTree = parent.GetSelectedChild();
     this.m_AnimationTree       = parent;
 }
Esempio n. 7
0
        protected override DropdownElement RebuildTree()
        {
            DropdownElement dropdownElement = new DropdownElement("ROOT");

            string[] submenus         = Unsupported.GetSubmenus("Component");
            string[] submenusCommands = Unsupported.GetSubmenusCommands("Component");
            for (int i = 0; i < submenus.Length; i++)
            {
                if (!(submenusCommands[i] == "ADD"))
                {
                    string   text  = submenus[i];
                    string[] array = text.Split(new char[]
                    {
                        '/'
                    });
                    DropdownElement dropdownElement2 = dropdownElement;
                    for (int j = 0; j < array.Length; j++)
                    {
                        string path = array[j];
                        if (j == array.Length - 1)
                        {
                            ComponentDropdownElement componentDropdownElement = new ComponentDropdownElement(LocalizationDatabase.GetLocalizedString(path), text, submenusCommands[i]);
                            componentDropdownElement.SetParent(dropdownElement2);
                            dropdownElement2.AddChild(componentDropdownElement);
                        }
                        else
                        {
                            DropdownElement dropdownElement3 = dropdownElement2.children.SingleOrDefault((DropdownElement c) => c.name == path);
                            if (dropdownElement3 == null)
                            {
                                dropdownElement3 = new GroupDropdownElement(path);
                                dropdownElement3.SetParent(dropdownElement2);
                                dropdownElement2.AddChild(dropdownElement3);
                            }
                            dropdownElement2 = dropdownElement3;
                        }
                    }
                }
            }
            dropdownElement = dropdownElement.children.Single <DropdownElement>();
            dropdownElement.SetParent(null);
            GroupDropdownElement groupDropdownElement = new GroupDropdownElement("New script");

            groupDropdownElement.AddChild(new NewScriptDropdownElement());
            groupDropdownElement.SetParent(dropdownElement);
            dropdownElement.AddChild(groupDropdownElement);
            return(dropdownElement);
        }
Esempio n. 8
0
        protected override DropdownElement RebuildSearch()
        {
            DropdownElement dropdownElement = base.RebuildSearch();

            if (dropdownElement != null)
            {
                GroupDropdownElement     groupDropdownElement     = new GroupDropdownElement("New script");
                NewScriptDropdownElement newScriptDropdownElement = new NewScriptDropdownElement();
                newScriptDropdownElement.className = this.m_Search;
                groupDropdownElement.AddChild(newScriptDropdownElement);
                newScriptDropdownElement.SetParent(groupDropdownElement);
                groupDropdownElement.SetParent(dropdownElement);
                dropdownElement.AddChild(groupDropdownElement);
            }
            return(dropdownElement);
        }
 protected void GoToParent()
 {
     if (this.CurrentlyRenderedTree.parent != null)
     {
         this.m_LastTime = DateTime.Now.Ticks;
         if (this.m_NewAnimTarget > 0f)
         {
             this.m_NewAnimTarget = -1f + this.m_NewAnimTarget;
         }
         else
         {
             this.m_NewAnimTarget = -1f;
         }
         this.m_AnimationTree       = this.CurrentlyRenderedTree;
         this.CurrentlyRenderedTree = this.CurrentlyRenderedTree.parent;
     }
 }
        internal void OnGUI()
        {
            if (AdvancedDropdownWindow.s_Styles == null)
            {
                AdvancedDropdownWindow.s_Styles = new AdvancedDropdownWindow.Styles();
            }
            GUI.Label(new Rect(0f, 0f, base.position.width, base.position.height), GUIContent.none, AdvancedDropdownWindow.s_Styles.background);
            if (this.m_DirtyList)
            {
                this.OnDirtyList();
            }
            this.HandleKeyboard();
            GUILayout.Space(7f);
            this.OnGUISearch();
            if (this.m_NewAnimTarget != 0f && Event.current.type == EventType.Layout)
            {
                long  ticks = DateTime.Now.Ticks;
                float num   = (float)(ticks - this.m_LastTime) / 1E+07f;
                this.m_LastTime      = ticks;
                this.m_NewAnimTarget = Mathf.MoveTowards(this.m_NewAnimTarget, 0f, num * 4f);
                if (this.m_NewAnimTarget == 0f)
                {
                    this.m_AnimationTree = null;
                }
                base.Repaint();
            }
            float num2 = this.m_NewAnimTarget;

            num2 = Mathf.Floor(num2) + Mathf.SmoothStep(0f, 1f, Mathf.Repeat(num2, 1f));
            if (num2 == 0f)
            {
                this.DrawDropdown(0f, this.CurrentlyRenderedTree);
            }
            else if (num2 < 0f)
            {
                this.DrawDropdown(num2, this.CurrentlyRenderedTree);
                this.DrawDropdown(num2 + 1f, this.m_AnimationTree);
            }
            else
            {
                this.DrawDropdown(num2 - 1f, this.m_AnimationTree);
                this.DrawDropdown(num2, this.CurrentlyRenderedTree);
            }
        }
        private void OnGUISearch()
        {
            if (!this.isSearchFieldDisabled)
            {
                EditorGUI.FocusTextInControl("ComponentSearch");
            }
            Rect rect = GUILayoutUtility.GetRect(10f, 20f);

            rect.x     += 8f;
            rect.width -= 16f;
            GUI.SetNextControlName("ComponentSearch");
            using (new EditorGUI.DisabledScope(this.isSearchFieldDisabled))
            {
                string text = EditorGUI.SearchField(rect, this.m_Search);
                if (text != this.m_Search)
                {
                    this.m_Search     = text;
                    this.m_SearchTree = this.RebuildSearch();
                }
            }
        }
Esempio n. 12
0
 public void SetParent(DropdownElement element)
 {
     this.m_Parent = element;
 }
Esempio n. 13
0
 internal void AddChild(DropdownElement element)
 {
     this.children.Add(element);
 }