public List <StoredAsset> GetAssetsList(AseetsConfig config)
        {
            // IF WIN
            //string appdata = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), k_appUnityFolder);

            return(GetAssetsList(config.DefaultSource));
        }
        public override void OnEnable()
        {
            titleContent   = new GUIContent("Assets Manager");
            assetsFilePath = Path.Combine(Environment.CurrentDirectory, ".assets");

            config       = assetManager.LoadConfig(assetsFilePath);
            storedAssets = assetManager.GetAssetsList(config);
        }
        protected override void DrawToolbar()
        {
            DrawToolbarButton(m_GUIRefreshList, () =>
            {
                config       = assetManager.LoadConfig(assetsFilePath);
                storedAssets = assetManager.GetAssetsList(config);
                publishers   = assetManager.GetPublisherList(storedAssets);

                l.og(m_GUIRefreshList.text + " -> Dependencies {0}", config.Dependencies.Count);
                l.og(m_GUIRefreshList.text + " -> Default Source {0}", config.DefaultSource.Location);
                l.og(m_GUIRefreshList.text + " -> Total Sources {0}", config.Sources.Count);
                l.og(m_GUIRefreshList.text + " -> Total Assets {0}", storedAssets.Count);
                l.og(m_GUIRefreshList.text + " -> Total Publishers {0}", publishers.Count);

                publisher_foldout_table = new Hashtable();
                foreach (var item in publishers)
                {
                    publisher_foldout_table[item.publisher] = false;
                }
            });

            m_Group = (Group)EditorGUILayout.EnumPopup(m_Group, EditorStyles.toolbarDropDown);

            if (m_Group == Group.All)
            {
                m_searchFilter = EditorGUILayout.TextField(m_searchFilter, EditorStyles.toolbarTextField);
            }

            GUILayout.FlexibleSpace();

            DrawToolbarButton(m_GUIStoreAssets, () =>
            {
                var selected = GetSelectedItems();
                l.og(m_GUIStoreAssets.text + " -> Selected {0}", selected.Count);

                assetManager.SaveConfig(selected, assetsFilePath);
            });

            DrawToolbarButton(m_GUIImportAssets, () =>
            {
                IList <StoredAsset> imported = assetManager.LoadConfig(assetsFilePath).Dependencies;
                l.og(m_GUIImportAssets.text + " -> Imported {0}", imported.Count);

                assetManager.MarkSelected(storedAssets, imported);
            });

            DrawToolbarButton(m_GUIInstallSelected, () =>
            {
                var selected = GetSelectedItems();
                l.og(m_GUIImportAssets.text + " -> Installing {0}", selected.Count);

                assetManager.InstallPackages(selected);
            });
        }
        public override void OnEnable()
        {
            titleContent   = new GUIContent("Sources");
            assetsFilePath = Path.Combine(Environment.CurrentDirectory, ".assets");
            config         = assetManager.LoadConfig(assetsFilePath);
            sources        = new string[config.Sources.Count];

            for (int i = 0; i < sources.Length; i++)
            {
                sources[i] = config.Sources[i].Location;
            }
        }
        public void SaveConfig(AseetsConfig config, string filePath)
        {
            StringBuilder content = new StringBuilder();

            foreach (AssetSource source in config.Sources)
            {
                /// ~MyPackages://C:\Users\Me\MyUnityPackages\
                content.AppendFormat("~{0}://{1}\r\n", source.Name, source.Location);
            }

            foreach (StoredAsset asset in config.Dependencies)
            {
                /// DefaultUnity://patico/scriptingphysics/CustomGravitationsKit
                content.AppendFormat("{0}://{1}/{2}/{3}\r\n", asset.Storage, asset.publisher, asset.category, asset.name);
            }

            File.WriteAllText(filePath, content.ToString());
        }
        public AseetsConfig LoadConfig(string filePath)
        {
            string[]     lines  = File.ReadAllLines(filePath);
            AseetsConfig config = new AseetsConfig();

            config.DefaultSource = new AssetSource()
            {
                Name = "Default", Location = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), k_appUnityFolder)
            };

            foreach (string data in lines)
            {
                char first = data.Length > 0 ? data[0] : '#';
                switch (first)
                {
                case '#':     /// comment line
                    break;

                case '~':     /// Assets source declaration
                    IParser parser = new AssetSourceParser();
                    parser.Parse(data);
                    config.Sources.Add(new AssetSource()
                    {
                        Name = parser.Parsed[1], Location = parser.Parsed[2]
                    });
                    break;

                default:     /// Asset declaration
                    IParser assetparser = new StoredAssetParser();
                    assetparser.Parse(data);

                    config.Dependencies.Add(new StoredAsset()
                    {
                        Storage   = assetparser.Parsed[0],
                        publisher = assetparser.Parsed[1],
                        category  = assetparser.Parsed[2],
                        name      = assetparser.Parsed[3]
                    });
                    break;
                }
            }

            return(config);
        }
        protected override void DrawToolbar()
        {
            DrawToolbarButton(m_GUIRefreshList, () =>
            {
                config = assetManager.LoadConfig(assetsFilePath);
                storedAssets = assetManager.GetAssetsList(config);
                publishers = assetManager.GetPublisherList(storedAssets);

                l.og(m_GUIRefreshList.text + " -> Dependencies {0}", config.Dependencies.Count);
                l.og(m_GUIRefreshList.text + " -> Default Source {0}", config.DefaultSource.Location);
                l.og(m_GUIRefreshList.text + " -> Total Sources {0}", config.Sources.Count);
                l.og(m_GUIRefreshList.text + " -> Total Assets {0}", storedAssets.Count);
                l.og(m_GUIRefreshList.text + " -> Total Publishers {0}", publishers.Count);

                publisher_foldout_table = new Hashtable();
                foreach (var item in publishers)
                {
                    publisher_foldout_table[item.publisher] = false;
                }
            });

            m_Group = (Group)EditorGUILayout.EnumPopup(m_Group, EditorStyles.toolbarDropDown);

            if (m_Group == Group.All)
            {
                m_searchFilter = EditorGUILayout.TextField(m_searchFilter, EditorStyles.toolbarTextField);
            }

            GUILayout.FlexibleSpace();

            DrawToolbarButton(m_GUIStoreAssets, () =>
            {
                var selected = GetSelectedItems();
                l.og(m_GUIStoreAssets.text + " -> Selected {0}", selected.Count);

                assetManager.SaveConfig(selected, assetsFilePath);
            });

            DrawToolbarButton(m_GUIImportAssets, () =>
            {
                IList<StoredAsset> imported = assetManager.LoadConfig(assetsFilePath).Dependencies;
                l.og(m_GUIImportAssets.text + " -> Imported {0}", imported.Count);

                assetManager.MarkSelected(storedAssets, imported);
            });

            DrawToolbarButton(m_GUIInstallSelected, () =>
            {
                var selected = GetSelectedItems();
                l.og(m_GUIImportAssets.text + " -> Installing {0}", selected.Count);

                assetManager.InstallPackages(selected);
            });
        }
        public override void OnEnable()
        {
            titleContent = new GUIContent("Assets Manager");
            assetsFilePath = Path.Combine(Environment.CurrentDirectory, ".assets");

            config = assetManager.LoadConfig(assetsFilePath);
            storedAssets = assetManager.GetAssetsList(config);
        }
        public override void OnEnable()
        {
            titleContent = new GUIContent("Sources");
            assetsFilePath = Path.Combine(Environment.CurrentDirectory, ".assets");
            config = assetManager.LoadConfig(assetsFilePath);
            sources = new string[config.Sources.Count];

            for (int i = 0; i < sources.Length; i++)
            {
                sources[i] = config.Sources[i].Location;
            }
        }
        public void SaveConfig(AseetsConfig config, string filePath)
        {
            StringBuilder content = new StringBuilder();

            foreach (AssetSource source in config.Sources)
            {
                /// ~MyPackages://C:\Users\Me\MyUnityPackages\
                content.AppendFormat("~{0}://{1}\r\n", source.Name, source.Location);
            }

            foreach (StoredAsset asset in config.Dependencies)
            {
                /// DefaultUnity://patico/scriptingphysics/CustomGravitationsKit
                content.AppendFormat("{0}://{1}/{2}/{3}\r\n", asset.Storage, asset.publisher, asset.category, asset.name);
            }

            File.WriteAllText(filePath, content.ToString());
        }
        public AseetsConfig LoadConfig(string filePath)
        {
            string[] lines = File.ReadAllLines(filePath);
            AseetsConfig config = new AseetsConfig();
            config.DefaultSource = new AssetSource() { Name = "Default", Location = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), k_appUnityFolder) };

            foreach (string data in lines)
            {
                char first = data.Length > 0 ? data[0] : '#';
                switch (first)
                {
                    case '#': /// comment line
                        break;
                    case '~': /// Assets source declaration
                        IParser parser = new AssetSourceParser();
                        parser.Parse(data);
                        config.Sources.Add(new AssetSource() { Name = parser.Parsed[1], Location = parser.Parsed[2] });
                        break;

                    default: /// Asset declaration
                        IParser assetparser = new StoredAssetParser();
                        assetparser.Parse(data);

                        config.Dependencies.Add(new StoredAsset()
                        {
                            Storage = assetparser.Parsed[0],
                            publisher = assetparser.Parsed[1],
                            category = assetparser.Parsed[2],
                            name = assetparser.Parsed[3]
                        });
                        break;
                }
            }

            return config;
        }
        public List<StoredAsset> GetAssetsList(AseetsConfig config)
        {
            // IF WIN
            //string appdata = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), k_appUnityFolder);

            return GetAssetsList(config.DefaultSource);
        }