Example #1
0
        /// <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);
        }
Example #2
0
        //---------------------------------------------------------------------
        // 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
        //---------------------------------------------------------------------

        public void CopyFrom(RainbowFolder target)
        {
            Type        = target.Type;
            Key         = target.Key;
            IsRecursive = target.IsRecursive;
            SmallIcon   = target.SmallIcon;
            LargeIcon   = target.LargeIcon;
        }
        //---------------------------------------------------------------------
        // Ctors
        //---------------------------------------------------------------------

        public RainbowFolder(RainbowFolder value)
        {
            Type        = value.Type;
            Key         = value.Key;
            IsRecursive = value.IsRecursive;
            SmallIcon   = value.SmallIcon;
            LargeIcon   = value.LargeIcon;
        }
Example #5
0
 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);
 }
Example #6
0
        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);
        }
Example #7
0
 public void AddFolder(RainbowFolder value)
 {
     Folders.Add(new RainbowFolder(value));
 }