//---------------------------------------------------------------------
        // Ctors
        //---------------------------------------------------------------------

        public RainbowFolder(RainbowFolder value)
        {
            Type      = value.Type;
            Key       = value.Key;
            SmallIcon = value.SmallIcon;
            LargeIcon = value.LargeIcon;
        }
        //---------------------------------------------------------------------
        // Public
        //---------------------------------------------------------------------

        public void CopyFrom(RainbowFolder target)
        {
            Type      = target.Type;
            Key       = target.Key;
            SmallIcon = target.SmallIcon;
            LargeIcon = target.LargeIcon;
        }
 //---------------------------------------------------------------------
 // Ctors
 //---------------------------------------------------------------------
 public RainbowFolder(RainbowFolder value)
 {
     Type = value.Type;
     Key = value.Key;
     SmallIcon = value.SmallIcon;
     LargeIcon = value.LargeIcon;
 }
        /// <summary>
        /// Searches for a folder config that has the same type and key, and updates
        /// its other fields with provided value, if found; creates new folder config otherwise.
        /// </summary>
        public void UpdateFolder(RainbowFolder match, RainbowFolder value)
        {
            Undo.RecordObject(this, "Modify Rainbow Folder Settings");

            var existingFolder = GetFolder(match);

            if (existingFolder != null)
            {
                if (value.HasAtLeastOneIcon())
                {
                    existingFolder.CopyFrom(value);
                }
                else
                {
                    RemoveAll(match);
                }
            }
            else
            {
                if (value.HasAtLeastOneIcon())
                {
                    AddFolder(value);
                }
            }

            EditorUtility.SetDirty(this);
        }
 //---------------------------------------------------------------------
 // Public
 //---------------------------------------------------------------------
 public void CopyFrom(RainbowFolder target)
 {
     Type = target.Type;
     Key = target.Key;
     SmallIcon = target.SmallIcon;
     LargeIcon = target.LargeIcon;
 }
        //---------------------------------------------------------------------
        // Public
        //---------------------------------------------------------------------

        /// <summary>
        /// Searches for a folder config that has the same type and key values.
        /// Returns the first occurrence within the settings, if found; null otherwise.
        /// </summary>
        public RainbowFolder GetFolder(RainbowFolder match)
        {
            if (IsNullOrEmpty(Folders) || match == null)
            {
                return(null);
            }
            return(Folders.Find(x => x.Type == match.Type && x.Key == match.Key));
        }
 public void RemoveAll(RainbowFolder match)
 {
     if (match == null)
     {
         return;
     }
     Undo.RecordObject(this, "Modify Rainbow Folder Settings");
     Folders.RemoveAll(x => x.Type == match.Type && x.Key == match.Key);
     EditorUtility.SetDirty(this);
 }
Beispiel #8
0
        //---------------------------------------------------------------------
        // Public
        //---------------------------------------------------------------------

        public void CopyFrom(RainbowFolder target)
        {
            Type = target.Type;
            Key  = target.Key;

            SmallIcon       = target.SmallIcon;
            LargeIcon       = target.LargeIcon;
            IsIconRecursive = target.IsIconRecursive;
            IsIconCustom    = target.IsIconCustom;

            Background            = target.Background;
            IsBackgroundRecursive = target.IsBackgroundRecursive;
            IsBackgroundCustom    = target.IsBackgroundCustom;
        }
Beispiel #9
0
        //---------------------------------------------------------------------
        // Ctors
        //---------------------------------------------------------------------

        public RainbowFolder(RainbowFolder value)
        {
            Type = value.Type;
            Key  = value.Key;

            SmallIcon       = value.SmallIcon;
            LargeIcon       = value.LargeIcon;
            IsIconRecursive = value.IsIconRecursive;
            IsIconCustom    = value.IsIconCustom;

            Background            = value.Background;
            IsBackgroundRecursive = value.IsBackgroundRecursive;
            IsBackgroundCustom    = value.IsBackgroundCustom;
        }
        public void ChangeFolderBackground(RainbowFolder value)
        {
            Undo.RecordObject(this, "Modify Rainbow Folder Settings");

            var folder = Folders.SingleOrDefault(x => x.Type == value.Type && x.Key == value.Key);

            if (folder == null)
            {
                AddFolder(new RainbowFolder(value));
            }
            else
            {
                folder.Background = value.Background;
            }

            EditorUtility.SetDirty(this);
        }
        public void ChangeFolderIcons(RainbowFolder value)
        {
            Undo.RecordObject(this, "Modify Rainbow Folder Settings");

            var folder = Folders.SingleOrDefault(x => x.Type == value.Type && x.Key == value.Key);
            if (folder == null)
            {
                AddFolder(new RainbowFolder(value));
            }
            else
            {
                folder.SmallIcon = value.SmallIcon;
                folder.LargeIcon = value.LargeIcon;
            }

            EditorUtility.SetDirty(this);
        }
Beispiel #12
0
        public void ChangeFolderIcons(RainbowFolder value)
        {
            Undo.RecordObject(this, "Modify Rainbow Folder Settings");

            RainbowFolder folder = Folders.SingleOrDefault(x => x.Type == value.Type && x.Key == value.Key);

            if (folder == null)
            {
                AddFolder(new RainbowFolder(value));
            }
            else
            {
                folder.SmallIcon = value.SmallIcon;
                folder.LargeIcon = value.LargeIcon;
            }

            EditorUtility.SetDirty(this);
        }
 public void AddFolder(RainbowFolder value)
 {
     Folders.Add(new RainbowFolder(value));
 }
        /// <summary>  
        /// Searches for a folder config that has the same type and key, and updates
        /// its other fields with provided value, if found; creates new folder config otherwise.
        /// </summary>  
        public void UpdateFolder(RainbowFolder match, RainbowFolder value)
        {
            Undo.RecordObject(this, "Modify Rainbow Folder Settings");

            var existingFolder = GetFolder(match);
            if (existingFolder != null)
            {
                if (value.HasAtLeastOneIcon())
                {
                    existingFolder.CopyFrom(value);
                }
                else
                {
                    RemoveAll(match);
                }
            }
            else
            {
                if (value.HasAtLeastOneIcon()) AddFolder(value);
            }

            EditorUtility.SetDirty(this);
        }
        public void ShowWithParams(Vector2 position, string[] paths, int pathIndex)
        {
            _paths = paths;
            _settings = RainbowFoldersSettings.Instance;

            var size = paths.Length;
            _existingFolders = new RainbowFolder[size];
            _currentFolder = new RainbowFolder(KeyType.Path, paths[pathIndex]);

            for (var i = 0; i < size; i++)
                _existingFolders[i] = _settings.GetFolderByPath(paths[i]);

            if (_existingFolders[pathIndex] != null)
                _currentFolder.CopyFrom(_existingFolders[pathIndex]);

            var rect = new Rect(position, WINDOW_SIZE);
            Show<RainbowFoldersPopup>(rect);
        }
 public void AddFolder(RainbowFolder value)
 {
     Folders.Add(new RainbowFolder(value));
 }
 //---------------------------------------------------------------------
 // Helpers
 //---------------------------------------------------------------------
 private static void Colorize(FolderColorName color, RainbowFolder folder)
 {
     var icons = FolderColorsStorage.Instance.GetIconsByColor(color);
     folder.SmallIcon = icons.SmallIcon;
     folder.LargeIcon = icons.LargeIcon;
 }
        /// <summary>
        /// Searches for a folder config that should be applied for the specified path (regardless of
        /// the key type). Returns the last occurrence within the settings, if found; null otherwise.
        /// </summary>
        public RainbowFolder GetFolderByPath(string folderPath, bool allowRecursive = false)
        {
            if (IsNullOrEmpty(Folders))
            {
                return(null);
            }

            for (var index = Folders.Count - 1; index >= 0; index--)
            {
                var folder = Folders[index];
                switch (folder.Type)
                {
                case KeyType.Name:
                    var folderName = Path.GetFileName(folderPath);
                    if (allowRecursive && (folder.IsIconRecursive || folder.IsBackgroundRecursive))
                    {
                        if (folderPath.Contains(string.Format("/{0}", folder.Key)))
                        {
                            // Check if this is the root folder
                            if (folder.Key.Equals(folderName))
                            {
                                return(folder);
                            }

                            var folderCopy = new RainbowFolder(folder);

                            if (!folder.IsIconRecursive)
                            {
                                folderCopy.LargeIcon = null;
                                folderCopy.SmallIcon = null;
                            }

                            if (!folder.IsBackgroundRecursive)
                            {
                                folderCopy.Background = null;
                            }

                            return(folderCopy);
                        }
                    }
                    else
                    {
                        if (folder.Key.Equals(folderName))
                        {
                            return(folder);
                        }
                    }
                    break;

                case KeyType.Path:
                    if (allowRecursive && (folder.IsIconRecursive || folder.IsBackgroundRecursive))
                    {
                        if (folderPath.StartsWith(folder.Key))
                        {
                            // Check if this is the root folder
                            if (folder.Key.Equals(folderPath))
                            {
                                return(folder);
                            }

                            var folderCopy = new RainbowFolder(folder);

                            if (!folder.IsIconRecursive)
                            {
                                folderCopy.LargeIcon = null;
                                folderCopy.SmallIcon = null;
                            }

                            if (!folder.IsBackgroundRecursive)
                            {
                                folderCopy.Background = null;
                            }

                            return(folderCopy);
                        }
                    }
                    else
                    {
                        if (folder.Key.Equals(folderPath))
                        {
                            return(folder);
                        }
                    }
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }
            }

            return(null);
        }
 public void RemoveAll(RainbowFolder match)
 {
     if (match == null) return;
     Undo.RecordObject(this, "Modify Rainbow Folder Settings");
     Folders.RemoveAll(x => x.Type == match.Type && x.Key == match.Key);
     EditorUtility.SetDirty(this);
 }
 private static void AssignTag(FolderTagName tag, RainbowFolder folder)
 {
     var icons = FolderTagsStorage.Instance.GetIconsByTag(tag);
     folder.SmallIcon = icons.SmallIcon;
     folder.LargeIcon = icons.LargeIcon;
 }
Beispiel #21
0
        public void RemoveAllByPath(string path)
        {
            RainbowFolder match = GetFolderByPath(path);

            RemoveAll(match);
        }
        //---------------------------------------------------------------------
        // Public
        //---------------------------------------------------------------------
        public static void ShowDropDown(Rect position, RainbowFolder folder)
        {
            var menu = new GenericMenu();

            // Colors
            menu.AddItem(COLOR_RED,           false, RedCallback,          folder);
            menu.AddItem(COLOR_VERMILION,     false, VermilionCallback,    folder);
            menu.AddItem(COLOR_ORANGE,        false, OrangeCallback,       folder);
            menu.AddItem(COLOR_YELLOW_ORANGE, false, YellowOrangeCallback, folder);
            menu.AddItem(COLOR_YELLOW,        false, YellowCallback,       folder);
            menu.AddItem(COLOR_LIME,          false, LimeCallback,         folder);
            menu.AddItem(COLOR_GREEN,         false, GreenCallback,        folder);
            menu.AddItem(COLOR_BONDI_BLUE,    false, BondiBlueCallback,    folder);
            menu.AddItem(COLOR_BLUE,          false, BlueCallback,         folder);
            menu.AddItem(COLOR_INDIGO,        false, IndigoCallback,       folder);
            menu.AddItem(COLOR_VIOLET,        false, VioletCallback,       folder);
            menu.AddItem(COLOR_MAGENTA,       false, MagentaCallback,      folder);

            // Tags
            menu.AddItem(TAG_RED,           false, TagRedCallback,          folder);
            menu.AddItem(TAG_VERMILION,     false, TagVermilionCallback,    folder);
            menu.AddItem(TAG_ORANGE,        false, TagOrangeCallback,       folder);
            menu.AddItem(TAG_YELLOW_ORANGE, false, TagYellowOrangeCallback, folder);
            menu.AddItem(TAG_YELLOW,        false, TagYellowCallback,       folder);
            menu.AddItem(TAG_LIME,          false, TagLimeCallback,         folder);
            menu.AddItem(TAG_GREEN,         false, TagGreenCallback,        folder);
            menu.AddItem(TAG_CYAN,          false, TagCyanCallback,         folder);
            menu.AddItem(TAG_BLUE,          false, TagBlueCallback,         folder);
            menu.AddItem(TAG_DARK_BLUE,     false, TagDarkBlueCallback,     folder);
            menu.AddItem(TAG_VIOLET,        false, TagVioletCallback,       folder);
            menu.AddItem(TAG_MAGENTA,       false, TagMagentaCallback,      folder);

            //Types
            menu.AddItem(TYPE_AUDIO,      false, AudioCallback,      folder);
            menu.AddItem(TYPE_BRACKETS,   false, BracketsCallback,   folder);
            menu.AddItem(TYPE_EDITOR,     false, EditorCallback,     folder);
            menu.AddItem(TYPE_EXTENSIONS, false, ExtensionsCallback, folder);
            menu.AddItem(TYPE_FONTS,      false, FontsCallback,      folder);
            menu.AddItem(TYPE_MATERIALS,  false, MaterialsCallback,  folder);
            menu.AddItem(TYPE_MESHES,     false, MeshesCallback,     folder);
            menu.AddItem(TYPE_PLUGINS,    false, PluginsCallback,    folder);
            menu.AddItem(TYPE_PREFABS,    false, PrefabsCallback,    folder);
            menu.AddItem(TYPE_RAINBOW,    false, RainbowCallback,    folder);
            menu.AddItem(TYPE_RESOURCES,  false, ResourcesCallback,  folder);
            menu.AddItem(TYPE_SCENES,     false, ScenesCallback,     folder);
            menu.AddItem(TYPE_SCRIPTS,    false, ScriptsCallback,    folder);
            menu.AddItem(TYPE_SHADERS,    false, ShadersCallback,    folder);
            menu.AddItem(TYPE_TERRAINS,   false, TerrainsCallback,   folder);
            menu.AddItem(TYPE_TEXTURES,   false, TexturesCallback,   folder);

            menu.DropDown(position);
        }
 //---------------------------------------------------------------------
 // Public
 //---------------------------------------------------------------------
 /// <summary>  
 /// Searches for a folder config that has the same type and key values.
 /// Returns the first occurrence within the settings, if found; null otherwise.
 /// </summary>  
 public RainbowFolder GetFolder(RainbowFolder match)
 {
     if (IsNullOrEmpty(Folders) || match == null) return null;
     return Folders.Find(x => x.Type == match.Type && x.Key == match.Key);
 }
 private static void AssingType(FolderTypeName type, RainbowFolder folder)
 {
     var icons = FolderTypesStorage.Instance.GetIconsByType(type);
     folder.SmallIcon = icons.SmallIcon;
     folder.LargeIcon = icons.LargeIcon;
 }