コード例 #1
0
ファイル: EnumSelector.cs プロジェクト: treert/om.unity.xx
        /// <summary>
        /// Populates the tree with all enum values.
        /// </summary>
        protected override void BuildSelectionTree(OdinMenuTree tree)
        {
            tree.Selection.SupportsMultiSelect = isFlagEnum;
            tree.Config.DrawSearchToolbar      = DrawSearchToolbar;
            foreach (var item in enumVals)
            {
                tree.Add(item.niceName, item);
            }

            //tree.AddRange(enumValues, x => Enum.GetName(typeof(T), x).SplitPascalCase());

            if (isFlagEnum)
            {
                tree.DefaultMenuStyle.Offset += 15;
                if (!enumVals.Where(x => x.value != null).Select(x => Convert.ToInt64(x.value)).Contains(0))
                {
                    tree.MenuItems.Insert(0, new OdinMenuItem(tree, GetNoneValueString(), new EnumMember()
                    {
                        value = 0, name = "None", niceName = "None", isObsolete = false, message = ""
                    }));
                }
                tree.EnumerateTree().ForEach(x => x.OnDrawItem += DrawEnumFlagItem);
                this.DrawConfirmSelectionButton = false;
            }
            else
            {
                tree.EnumerateTree().ForEach(x => x.OnDrawItem += DrawEnumItem);
            }

            tree.EnumerateTree().ForEach(x => x.OnDrawItem += DrawEnumInfo);
        }
コード例 #2
0
ファイル: TypeSelector.cs プロジェクト: B-CK/P-Lua
        /// <summary>
        /// Builds the selection tree.
        /// </summary>
        protected override void BuildSelectionTree(OdinMenuTree tree)
        {
            tree.DefaultMenuStyle.NotSelectedIconAlpha = 1f;
            if (types == null)
            {
                List <OdinMenuItem> items;
                if (cachedAllTypesMenuItems.TryGetValue(this.assemblyTypeFlags, out items))
                {
                    AddRecursive(tree, items, tree.MenuItems);
                }
                else
                {
                    var assemblyTypes = OrderTypes(AssemblyUtilities.GetTypes(this.assemblyTypeFlags).Where(x => char.IsLetter(x.Name.Trim()[0])));
                    foreach (var t in assemblyTypes)
                    {
                        string path = string.IsNullOrEmpty(t.Namespace) ? t.GetNiceName() : t.Namespace + "/" + t.GetNiceName();
                        tree.AddObjectAtPath(path, t).AddThumbnailIcons();
                    }

                    cachedAllTypesMenuItems[this.assemblyTypeFlags] = tree.MenuItems;
                }
            }
            else
            {
                foreach (var t in this.types)
                {
                    string path = string.IsNullOrEmpty(t.Namespace) ? t.GetNiceName() : t.Namespace + "/" + t.GetNiceName();
                    tree.AddObjectAtPath(path, t);
                }

                tree.EnumerateTree(x => x.ObjectInstance != null, false).AddThumbnailIcons();
            }

            tree.EnumerateTree().ForEach(i =>
            {
                var t = i.ObjectInstance as Type;
                if (t != null)
                {
                    i.SearchString = t.GetNiceFullName();
                }
            });

            tree.Selection.SupportsMultiSelect = this.supportsMultiSelect;
            tree.Selection.SelectionChanged   += (t) =>
            {
                lastType = this.SelectionTree.Selection.Select(x => x.ObjectInstance).OfType <Type>().LastOrDefault() ?? lastType;
            };
        }
コード例 #3
0
        /// <summary>
        /// Sorts the entire tree of menu items recursively by name with respects to numbers.
        /// </summary>
        public static IEnumerable <OdinMenuItem> SortMenuItemsByName(this OdinMenuTree tree, bool placeFoldersFirst = true)
        {
            var result = SortMenuItemsByName(tree.EnumerateTree(true), placeFoldersFirst);

            tree.MarkDirty();
            return(result);
        }
コード例 #4
0
ファイル: TypeSelector.cs プロジェクト: treert/om.unity.xx
        /// <summary>
        /// Builds the selection tree.
        /// </summary>
        protected override void BuildSelectionTree(OdinMenuTree tree)
        {
            tree.Config.UseCachedExpandedStates        = false;
            tree.DefaultMenuStyle.NotSelectedIconAlpha = 1f;
            if (types == null)
            {
                List <OdinMenuItem> items;
                if (cachedAllTypesMenuItems.TryGetValue(this.assemblyTypeFlags, out items))
                {
                    AddRecursive(tree, items, tree.MenuItems);
                }
                else
                {
                    var assemblyTypes = OrderTypes(AssemblyUtilities.GetTypes(this.assemblyTypeFlags).Where(x => char.IsLetter(x.Name.Trim()[0])));
                    foreach (var t in assemblyTypes)
                    {
                        var    niceName = t.GetNiceName();
                        string path     = this.GetTypeNamePath(t, niceName);
                        var    last     = tree.AddObjectAtPath(path, t).AddThumbnailIcons().Last();
                        last.SearchString = niceName == path ? path : niceName + "|" + path;
                    }

                    cachedAllTypesMenuItems[this.assemblyTypeFlags] = tree.MenuItems;
                }
            }
            else
            {
                foreach (var t in this.types)
                {
                    var    niceName = t.GetNiceName();
                    string path     = this.GetTypeNamePath(t, niceName);
                    var    last     = tree.AddObjectAtPath(path, t).Last();
                    last.SearchString = niceName == path ? path : niceName + "|" + path;

                    if (this.FlattenTree && t.Namespace != null)
                    {
                        last.OnDrawItem += x => GUI.Label(x.Rect.Padding(10, 0).AlignCenterY(16), t.Namespace, SirenixGUIStyles.RightAlignedGreyMiniLabel);
                    }
                }

                tree.EnumerateTree(x => x.Value != null, false).AddThumbnailIcons();
            }

            //tree.EnumerateTree().ForEach(i =>
            //{
            //    var t = i.Value as Type;
            //    if (t != null) { i.SearchString = t.GetNiceFullName(); }
            //});

            tree.Selection.SupportsMultiSelect = this.supportsMultiSelect;
            tree.Selection.SelectionChanged   += (t) =>
            {
                lastType = this.SelectionTree.Selection.Select(x => x.Value).OfType <Type>().LastOrDefault() ?? lastType;
            };
        }
コード例 #5
0
        /// <summary>
        /// Populates the tree with all enum values.
        /// </summary>
        protected override void BuildSelectionTree(OdinMenuTree tree)
        {
            tree.Selection.SupportsMultiSelect = isFlagEnum;
            tree.Config.DrawSearchToolbar      = true;
            tree.AddRange(enumValues, x => Enum.GetName(typeof(T), x).SplitPascalCase());

            if (isFlagEnum)
            {
                tree.DefaultMenuStyle.Offset += 15;
                if (!enumValues.Select(x => Convert.ToInt64(x)).Contains(0))
                {
                    tree.MenuItems.Insert(0, new OdinMenuItem(tree, "None", 0));
                }
                tree.EnumerateTree().ForEach(x => x.OnDrawItem += DrawEnumFlagItem);
                this.DrawConfirmSelectionButton = false;
            }
            else
            {
                tree.EnumerateTree().ForEach(x => x.OnDrawItem += DrawEnumItem);
            }
        }
コード例 #6
0
        /// <summary>
        /// Builds the selection tree.
        /// </summary>
        protected override void BuildSelectionTree(OdinMenuTree tree)
        {
            tree.Selection.SupportsMultiSelect = this.supportsMultiSelect;
            tree.DefaultMenuStyle = OdinMenuStyle.TreeViewStyle;
            this.getMenuItemName  = this.getMenuItemName ?? (x => x == null ? "" : x.ToString());

            if (this.FlattenedTree)
            {
                if (this.genericSelectorCollection != null)
                {
                    foreach (var item in this.genericSelectorCollection)
                    {
                        tree.MenuItems.Add(new OdinMenuItem(tree, item.GetNiceName(), item.Value));
                    }
                }
                else
                {
                    foreach (var item in this.collection)
                    {
                        tree.MenuItems.Add(new OdinMenuItem(tree, this.getMenuItemName(item), item));
                    }
                }
            }
            else
            {
                if (this.genericSelectorCollection != null)
                {
                    foreach (var item in this.genericSelectorCollection)
                    {
                        tree.AddObjectAtPath(item.GetNiceName(), item.Value);
                    }
                }
                else
                {
                    tree.AddRange(this.collection, this.getMenuItemName);
                }
            }

            if (this.CheckboxToggle)
            {
                tree.EnumerateTree().ForEach(DrawCheckboxMenuItems);
                tree.DefaultMenuStyle.TrianglePadding       -= 17;
                tree.DefaultMenuStyle.Offset                += 18;
                tree.DefaultMenuStyle.SelectedColorDarkSkin  = new Color(1, 1, 1, 0.05f);
                tree.DefaultMenuStyle.SelectedColorLightSkin = new Color(1, 1, 1, 0.05f);
                tree.DefaultMenuStyle.SelectedLabelStyle     = tree.DefaultMenuStyle.DefaultLabelStyle;
                tree.Config.ConfirmSelectionOnDoubleClick    = false;
            }
        }
コード例 #7
0
ファイル: OdinMenuTreeExtensions.cs プロジェクト: B-CK/P-Lua
 /// <summary>
 /// Sorts the entire tree of menu items recursively by name with respects to numbers.
 /// </summary>
 public static IEnumerable <OdinMenuItem> SortMenuItemsByName(this OdinMenuTree tree, bool placeFoldersFirst = true)
 {
     return(SortMenuItemsByName(tree.EnumerateTree(true), placeFoldersFirst));
 }
コード例 #8
0
 /// <summary>
 /// Sorts the entire tree of menu items recursively by name with respects to numbers.
 /// </summary>
 public static IEnumerable <OdinMenuItem> SortMenuItemsByName(this OdinMenuTree tree)
 {
     return(SortMenuItemsByName(tree.EnumerateTree(true)));
 }