private void GuiPluginDependencies(
            SimplePluginManagerPlugin plugin,
            SimplePluginManagerCollections collections,
            SimplePluginManagerStatusIcons icons
            )
        {
            if (plugin.Dependencies != null && plugin.Dependencies.Count > 0)
            {
                GUILayout.Space(8);
                GUILayout.Label("Required plugins:", EditorStyles.boldLabel);

                foreach (string dependency in plugin.Dependencies)
                {
                    GUILayout.BeginHorizontal();
                    GUILayout.Space(16);
                    GUILayout.Label(
                        icons.GetDependencyStatusIcon(
                            collections.IsInProject(dependency),
                            collections.IsInRepository(dependency)
                            ),
                        GUILayout.Width(20)
                        );
                    GUILayout.Label(collections.GetPluginNameAndVersion(dependency));
                    GUILayout.EndHorizontal();
                }
            }
        }
Esempio n. 2
0
        private void GuiPluginsSection()
        {
            if (m_PluginCollections == null || !m_PluginCollections.IsInitialized)
            {
                return;
            }

            SimplePluginManagerStatusIcons icons = GetOrAllocateIcons();

            List <SimplePluginManagerCollections.CPluginsPair> list_of_plugins = m_PluginCollections.BuildListOfPlugins();

            foreach (var plugin_pair in list_of_plugins)
            {
                GetOrAllocatePluginFoldout(plugin_pair.Id).OnGui(m_Settings, m_PluginCollections, plugin_pair, icons, UpdatePluginCollections);
            }
        }
        public void OnGui(
            SimplePluginManagerSettings settings,
            SimplePluginManagerCollections collections,
            SimplePluginManagerCollections.CPluginsPair plugins_pair,
            SimplePluginManagerStatusIcons icons,
            Action on_collections_changed
            )
        {
            // gather resources
            SimplePluginManagerPlugin repository_plugin = plugins_pair.RepositoryPlugin;
            SimplePluginManagerPlugin project_plugin    = plugins_pair.ProjectPlugin;
            SimplePluginManagerPlugin plugin            = project_plugin ?? repository_plugin;

            string repository_version = repository_plugin == null ? "not available" : repository_plugin.Version;
            string project_version    = project_plugin == null ? "not installed" : project_plugin.Version;

            bool is_any_plugin_dependent_on_this = collections.IsAnyProjectPluginDependentOn(plugin.Id);
            bool is_dependency_error             = collections.IsDependencyError(plugin);
            bool is_version_error = (repository_plugin?.ParseVersion.IsError ?? false) || (project_plugin?.ParseVersion.IsError ?? false);
            bool is_error         = is_dependency_error || is_version_error;

            // layout
            EditorGUILayout.BeginHorizontal();
            {
                EditorGUILayout.BeginHorizontal();
                {
                    GUILayout.Label(icons.GetPluginStatusIcon(repository_plugin, project_plugin), GUILayout.Width(20), GUILayout.Height(20));
                    GUILayout.Label($"{plugin.Name} ({project_version})", EditorStyles.boldLabel);
                }
                EditorGUILayout.EndHorizontal();

                EditorGUILayout.BeginVertical(GUILayout.Width(768));
                {
                    // foldout
                    EditorGUILayout.BeginHorizontal();

                    m_IsExpanded = EditorGUILayout.Foldout(m_IsExpanded, "") || is_error;
                    if (!m_IsExpanded)
                    {
                        GuiButtons(settings, collections, repository_plugin, project_plugin, is_any_plugin_dependent_on_this, is_error, on_collections_changed);
                    }
                    EditorGUILayout.EndHorizontal();

                    if (m_IsExpanded)
                    {
                        // description and info
                        GUIStyle rich_text_style = new GUIStyle(GUI.skin.label);
                        rich_text_style.richText = true;
                        GUILayout.Label(plugin.Description, rich_text_style);

                        GuiPluginDependencies(plugin, collections, icons);
                        GUILayout.Space(8);
                        GUILayout.Label("Id:" + plugin.Id);
                        GUILayout.Label("Repository: " + repository_version);

                        // errors
                        if (repository_plugin != null && !string.IsNullOrEmpty(repository_plugin.Error))
                        {
                            SimplePluginManagerUIUtils.ErrorLabel(repository_plugin.Error);
                        }

                        if (project_plugin != null && !string.IsNullOrEmpty(project_plugin.Error))
                        {
                            SimplePluginManagerUIUtils.ErrorLabel(project_plugin.Error);
                        }

                        if (is_version_error)
                        {
                            SimplePluginManagerUIUtils.ErrorLabel("Plugin has invalid version format!");
                        }

                        if (is_dependency_error)
                        {
                            SimplePluginManagerUIUtils.ErrorLabel("Plugin is dependent on non existing plugin!");
                        }

                        // buttons
                        if (
                            (repository_plugin == null || string.IsNullOrEmpty(repository_plugin.Error))
                            &&
                            (project_plugin == null || string.IsNullOrEmpty(project_plugin.Error))
                            )
                        {
                            EditorGUILayout.BeginHorizontal();
                            {
                                GUILayout.Label("");                                 //formatting
                                GuiButtons(settings, collections, repository_plugin, project_plugin, is_any_plugin_dependent_on_this, is_error, on_collections_changed);
                            }
                            EditorGUILayout.EndHorizontal();
                        }
                    }
                }
                EditorGUILayout.EndVertical();
            }
            EditorGUILayout.EndHorizontal();

            SimplePluginManagerUIUtils.Line();
        }
Esempio n. 4
0
 private SimplePluginManagerStatusIcons GetOrAllocateIcons()
 {
     return(m_Icons ?? (m_Icons = new SimplePluginManagerStatusIcons()));
 }