Esempio n. 1
0
        protected override void OnHeaderGUI()
        {
            if (currentPage == null)
            {
                base.OnHeaderGUI();
                return;
            }

            GUILayout.BeginVertical(LudiqStyles.windowHeaderBackground, GUILayout.ExpandWidth(true));
            GUILayout.BeginHorizontal(GUILayout.ExpandWidth(true));
            LudiqGUI.FlexibleSpace();

            if (currentPage?.icon != null)
            {
                GUILayout.Box(new GUIContent(currentPage.icon?[(int)LudiqStyles.windowHeaderIcon.fixedWidth]), LudiqStyles.windowHeaderIcon);
                LudiqGUI.Space(LudiqStyles.spaceBetweenWindowHeaderIconAndTitle);
            }

            GUILayout.Label(title, LudiqStyles.windowHeaderTitle);
            LudiqGUI.FlexibleSpace();
            LudiqGUI.EndHorizontal();

            LudiqGUI.Space(13);
            OnTabsGUI();
            LudiqGUI.Space(-5);

            LudiqGUI.EndVertical();
        }
        protected override void OnContentGUI()
        {
            GUILayout.BeginVertical(Styles.background, GUILayout.ExpandHeight(true));

            LudiqGUI.FlexibleSpace();
            GUILayout.Label($"Welcome to {product.name}.", LudiqStyles.centeredLabel);
            LudiqGUI.FlexibleSpace();
            GUILayout.Label("This setup wizard will help you get started.", LudiqStyles.centeredLabel);
            LudiqGUI.FlexibleSpace();

            LudiqGUI.BeginHorizontal();
            LudiqGUI.FlexibleSpace();

            if (GUILayout.Button(completeLabel, Styles.nextButton))
            {
                Complete();
            }

            LudiqGUI.FlexibleSpace();
            LudiqGUI.EndHorizontal();

            LudiqGUI.FlexibleSpace();

            LudiqGUI.EndVertical();
        }
Esempio n. 3
0
        protected override void OnHeaderGUI()
        {
            if (mainAboutable == null || mainAboutable.logo == null)
            {
                base.OnHeaderGUI();
                return;
            }

            GUILayout.BeginVertical(LudiqStyles.windowHeaderBackground, GUILayout.ExpandWidth(true));
            LudiqGUI.BeginHorizontal();
            LudiqGUI.FlexibleSpace();

            var logoHeight   = Styles.logoHeight;
            var logoWidth    = (float)mainAboutable.logo.width / mainAboutable.logo.height * logoHeight;
            var logoPosition = GUILayoutUtility.GetRect(logoWidth, logoHeight);

            GUI.DrawTexture(logoPosition, mainAboutable.logo);

            LudiqGUI.FlexibleSpace();
            LudiqGUI.EndHorizontal();

            LudiqGUI.Space(13);
            OnTabsGUI();
            LudiqGUI.Space(-5);

            LudiqGUI.EndVertical();
        }
Esempio n. 4
0
 protected virtual void OnEmptyGUI()
 {
     GUILayout.BeginVertical(Styles.emptyBackground);
     LudiqGUI.FlexibleSpace();
     GUILayout.Label("No item found.", LudiqStyles.centeredLabel);
     LudiqGUI.FlexibleSpace();
     LudiqGUI.EndVertical();
 }
        protected override void OnContentGUI()
        {
            GUILayout.BeginVertical(Styles.background, GUILayout.ExpandHeight(true));

            var label = "Inspectors in Bolt plugins can handle many custom types besides Unity primites and objects. ";

            label += "However, to be compatible with your custom editor drawers, some additional property provider scripts must be generated. ";

            LudiqGUI.FlexibleSpace();
            LudiqGUI.BeginHorizontal();
            LudiqGUI.FlexibleSpace();
            GUILayout.Label(label, LudiqStyles.centeredLabel, GUILayout.MaxWidth(350));
            LudiqGUI.FlexibleSpace();
            LudiqGUI.EndHorizontal();
            LudiqGUI.FlexibleSpace();

            LudiqGUI.BeginHorizontal();
            LudiqGUI.FlexibleSpace();

            if (GUILayout.Button("Generate Inspectors", Styles.nextButton))
            {
                try
                {
                    SerializedPropertyProviderProvider.instance.GenerateProviderScripts();
                    // EditorUtility.DisplayDialog("Custom Inspector Generation", "Custom inspector generation has completed successfully.", "OK");
                    Complete();
                }
                catch (Exception ex)
                {
                    EditorUtility.DisplayDialog("Custom Inspector Error", $"Custom inspector generation has failed: \n{ex.Message}", "OK");
                    Debug.LogException(ex);
                }
            }

            LudiqGUI.FlexibleSpace();
            LudiqGUI.EndHorizontal();

            LudiqGUI.FlexibleSpace();

            LudiqGUI.BeginHorizontal();
            LudiqGUI.FlexibleSpace();

            if (GUILayout.Button(completeLabel, Styles.skipButton))
            {
                Complete();
            }

            LudiqGUI.FlexibleSpace();
            LudiqGUI.EndHorizontal();

            LudiqGUI.FlexibleSpace();
            GUILayout.Label("You can regenerate inspectors at any time from the tools menu.", Styles.regenerateLabel);

            LudiqGUI.FlexibleSpace();

            LudiqGUI.EndVertical();
        }
Esempio n. 6
0
        protected override void OnContentGUI()
        {
            GUILayout.BeginVertical(Styles.background, GUILayout.ExpandHeight(true));

            LudiqGUI.FlexibleSpace();

            EditorGUILayout.LabelField($"Version {aboutable.version}", LudiqStyles.centeredLabel);

            LudiqGUI.FlexibleSpace();

            if (!StringUtility.IsNullOrWhiteSpace(aboutable.description))
            {
                EditorGUILayout.LabelField(aboutable.description.Trim(), LudiqStyles.centeredLabel);
            }

            LudiqGUI.FlexibleSpace();

            if (!StringUtility.IsNullOrWhiteSpace(aboutable.author))
            {
                EditorGUILayout.LabelField($"{aboutable.authorLabel.Trim()} {aboutable.author.Trim()}", LudiqStyles.centeredLabel);
            }

            if (!StringUtility.IsNullOrWhiteSpace(aboutable.copyrightHolder))
            {
                EditorGUILayout.LabelField($"Copyright \u00a9 {aboutable.copyrightYear} {aboutable.copyrightHolder.Trim()}. All Rights Reserved.", LudiqStyles.centeredLabel);
            }

            if (aboutable.authorLogo != null)
            {
                LudiqGUI.FlexibleSpace();

                LudiqGUI.BeginHorizontal();
                LudiqGUI.FlexibleSpace();
                var logoHeight   = Styles.authorLogoHeight;
                var logoWidth    = (float)aboutable.authorLogo.width / aboutable.authorLogo.height * logoHeight;
                var logoPosition = GUILayoutUtility.GetRect(logoWidth, logoHeight);

                if (!string.IsNullOrEmpty(aboutable.authorUrl))
                {
                    if (GUI.Button(logoPosition, aboutable.authorLogo, GUIStyle.none))
                    {
                        Process.Start(aboutable.authorUrl);
                    }
                }
                else if (e.type == EventType.Repaint)
                {
                    GUI.DrawTexture(logoPosition, aboutable.authorLogo);
                }

                LudiqGUI.FlexibleSpace();
                LudiqGUI.EndHorizontal();
            }

            LudiqGUI.FlexibleSpace();
            LudiqGUI.EndVertical();
        }
 protected void DrawHelpIcon()
 {
     LudiqGUI.BeginHorizontal();
     LudiqGUI.FlexibleSpace();
     if (GUILayout.Button("", _editorSkin.GetStyle("CN EntryInfo")))
     {
         EditorUtility.DisplayDialog("Editor Icon Viewer", kUsageString, "Ok");
     }
     LudiqGUI.EndHorizontal();
 }
Esempio n. 8
0
        public static void DrawPluginVersionTable(IEnumerable <Plugin> plugins)
        {
            var savedColumnHeader     = new GUIContent("Saved");
            var installedColumnHeader = new GUIContent("Installed");

            var pluginsColumnWidth   = 0f;
            var savedColumnWidth     = Styles.columnHeader.CalcSize(savedColumnHeader).x;
            var installedColumnWidth = Styles.columnHeader.CalcSize(installedColumnHeader).x;
            var stateColumnWidth     = 0f;

            foreach (var plugin in plugins)
            {
                pluginsColumnWidth   = Mathf.Max(pluginsColumnWidth, Styles.pluginName.CalcSize(new GUIContent(plugin.manifest.name)).x);
                savedColumnWidth     = Mathf.Max(savedColumnWidth, Styles.version.CalcSize(new GUIContent(plugin.manifest.savedVersion.ToString())).x);
                installedColumnWidth = Mathf.Max(installedColumnWidth, Styles.version.CalcSize(new GUIContent(plugin.manifest.currentVersion.ToString())).x);
                stateColumnWidth     = Mathf.Max(stateColumnWidth, Styles.state.CalcSize(VersionStateContent(plugin)).x);
            }

            LudiqGUI.BeginVertical();

            // Header row
            LudiqGUI.BeginHorizontal();
            LudiqGUI.FlexibleSpace();
            GUILayout.Label(GUIContent.none, Styles.columnHeader, GUILayout.Width(pluginsColumnWidth));
            LudiqGUI.Space(Styles.columnSpacing);
            GUILayout.Label(savedColumnHeader, Styles.columnHeader, GUILayout.Width(savedColumnWidth));
            LudiqGUI.Space(Styles.columnSpacing);
            GUILayout.Label(installedColumnHeader, Styles.columnHeader, GUILayout.Width(installedColumnWidth));
            LudiqGUI.Space(Styles.columnSpacing);
            GUILayout.Label(GUIContent.none, Styles.state, GUILayout.Width(stateColumnWidth));
            LudiqGUI.FlexibleSpace();
            LudiqGUI.EndHorizontal();

            // Plugin rows
            foreach (var plugin in plugins)
            {
                LudiqGUI.Space(Styles.rowSpacing);

                LudiqGUI.BeginHorizontal();
                LudiqGUI.FlexibleSpace();
                GUILayout.Label(new GUIContent(plugin.manifest.name), Styles.pluginName, GUILayout.Width(pluginsColumnWidth));
                LudiqGUI.Space(Styles.columnSpacing);
                GUILayout.Label(new GUIContent(plugin.manifest.savedVersion.ToString()), Styles.version, GUILayout.Width(savedColumnWidth));
                LudiqGUI.Space(Styles.columnSpacing);
                GUILayout.Label(new GUIContent(plugin.manifest.currentVersion.ToString()), Styles.version, GUILayout.Width(installedColumnWidth));
                LudiqGUI.Space(Styles.columnSpacing);
                GUILayout.Label(VersionStateContent(plugin), Styles.state, GUILayout.Width(stateColumnWidth));
                LudiqGUI.FlexibleSpace();
                LudiqGUI.EndHorizontal();
            }

            LudiqGUI.EndVertical();
        }
 protected void DrawCenteredMessage(string msg)
 {
     LudiqGUI.BeginHorizontal();
     LudiqGUI.FlexibleSpace();
     LudiqGUI.BeginVertical();
     LudiqGUI.FlexibleSpace();
     GUILayout.Label(msg);
     LudiqGUI.FlexibleSpace();
     LudiqGUI.EndVertical();
     LudiqGUI.FlexibleSpace();
     LudiqGUI.EndHorizontal();
 }
Esempio n. 10
0
        protected override void OnContentGUI()
        {
            if (!plugins.Any())
            {
                Complete();
            }

            GUILayout.BeginVertical(Styles.background, GUILayout.ExpandHeight(true));
            LudiqGUI.FlexibleSpace();
            GUILayout.Label($"The following plugins have been downgraded to a previous version: ", LudiqStyles.centeredLabel);
            LudiqGUI.FlexibleSpace();
            UpdateWizard.DrawPluginVersionTable(plugins);
            LudiqGUI.FlexibleSpace();
            GUILayout.Label("This will likely cause backwards incompatibility issues.", LudiqStyles.centeredLabel);
            GUILayout.Label("We recommend that you re-install their saved version to avoid data corruption.", LudiqStyles.centeredLabel);
            LudiqGUI.FlexibleSpace();

            LudiqGUI.BeginHorizontal();
            LudiqGUI.FlexibleSpace();

            if (GUILayout.Button("Close", Styles.button))
            {
                window.Close();
            }

            LudiqGUI.Space(10);

            if (GUILayout.Button("Force Consolidate", Styles.button))
            {
                var consolidationExplanation = string.Empty;
                consolidationExplanation += $"By forcing consolidation, the saved versions will be set to match the installed versions. ";
                consolidationExplanation += "This does not roll back updates and may lead to data corruption. ";
                consolidationExplanation += "You should only do this if you know what you are doing. ";
                consolidationExplanation += "A backup will be created automatically if you decide to proceed.";

                if (EditorUtility.DisplayDialog("Force Consolidate Version", consolidationExplanation, "Force Consolidate", "Cancel"))
                {
                    foreach (var plugin in plugins)
                    {
                        plugin.manifest.savedVersion = plugin.manifest.currentVersion;
                    }

                    Complete();
                }
            }

            LudiqGUI.FlexibleSpace();
            LudiqGUI.EndHorizontal();

            LudiqGUI.FlexibleSpace();
            LudiqGUI.EndVertical();
        }
        protected override void OnContentGUI()
        {
            GUILayout.BeginVertical(Styles.background, GUILayout.ExpandHeight(true));

            var label = "Every Unity build target except Standalone requires 'ahead of time' (AOT) compilation. ";

            label += "Before building for these platforms, you should always run this step to create AOT stubs for reflection and generics. ";
            label += "Otherwise, there may be runtime errors in your builds.";

            var label2 = "This pre-build step will scan all the assets and scenes in the project to generate the required AOT stubs. ";

            label2 += "Make sure you save the current scene before starting.";

            LudiqGUI.FlexibleSpace();
            GUILayout.Label(label, LudiqStyles.centeredLabel);
            LudiqGUI.FlexibleSpace();
            GUILayout.Label(label2, LudiqStyles.centeredLabel);
            LudiqGUI.FlexibleSpace();

            LudiqGUI.BeginHorizontal();
            LudiqGUI.FlexibleSpace();

            if (GUILayout.Button("Pre-Build", Styles.nextButton))
            {
                try
                {
                    AotPreBuilder.GenerateLinker();
                    AotPreBuilder.GenerateStubScript();
                    EditorUtility.DisplayDialog("AOT Pre-Build", $"AOT pre-build has completed.\n\nThe generated linker file is located at:\n'{PathUtility.FromProject(AotPreBuilder.aotStubsPath)}'\n\nThe generated stubs script is located at:\n'{PathUtility.FromProject(AotPreBuilder.linkerPath)}'", "OK");
                    Complete();
                }
                catch (Exception ex)
                {
                    EditorUtility.DisplayDialog("AOT Pre-Build Error", $"AOT pre-build has failed: \n{ex.Message}", "OK");
                    Debug.LogException(ex);
                    AotPreBuilder.DeleteLinker();
                    AotPreBuilder.DeleteStubScript();
                }
            }

            LudiqGUI.FlexibleSpace();
            LudiqGUI.EndHorizontal();

            LudiqGUI.FlexibleSpace();
            EditorGUILayout.HelpBox("AOT Pre-build is in Beta. Please report any compile-time or runtime error you may encounter.", MessageType.Warning);
            LudiqGUI.FlexibleSpace();

            LudiqGUI.EndVertical();
        }
Esempio n. 12
0
        protected override void OnGUI()
        {
            LudiqGUI.BeginVertical();

            currentPage?.DrawHeader();

            GUILayout.BeginVertical(GUILayout.ExpandHeight(true));
            currentPage?.DrawContent();
            LudiqGUI.EndVertical();

            GUILayout.Box(GUIContent.none, Styles.sectionBorder);
            GUILayout.BeginHorizontal(Styles.footerBackground);
            LudiqGUI.FlexibleSpace();

            for (var i = 0; i < pages.Count; i++)
            {
                GUIStyle breadcrumbStyle;

                if (i == 0)
                {
                    breadcrumbStyle = Styles.breadcrumbStart;
                }
                else if (i == pages.Count - 1)
                {
                    breadcrumbStyle = Styles.breadcrumbEnd;
                }
                else
                {
                    breadcrumbStyle = Styles.breadcrumbMid;
                }

                var page = pages[i];

                EditorGUI.BeginDisabledGroup((!canNavigateForward && i > farthestNavigatedIndex) || (!canNavigateBackward && i < farthestNavigatedIndex));

                if (GUILayout.Toggle(page == currentPage, page.shortTitle ?? page.title, breadcrumbStyle) && page != currentPage)
                {
                    currentPage = page;
                }

                EditorGUI.EndDisabledGroup();
            }

            LudiqGUI.FlexibleSpace();
            LudiqGUI.EndHorizontal();
            LudiqGUI.EndVertical();
        }
        protected override void OnContentGUI()
        {
            GUILayout.BeginVertical(Styles.background, GUILayout.ExpandHeight(true));
            LudiqGUI.FlexibleSpace();

            if (plugins.All(plugin => plugin.manifest.savedVersion == plugin.manifest.currentVersion))
            {
                GUILayout.Label("All your plugins are up to date.", LudiqStyles.centeredLabel);
            }
            else
            {
                GUILayout.Label("Welcome to the plugin update wizard.", LudiqStyles.centeredLabel);
            }

            LudiqGUI.FlexibleSpace();
            UpdateWizard.DrawPluginVersionTable(plugins);
            LudiqGUI.FlexibleSpace();
            LudiqGUI.FlexibleSpace();
            LudiqGUI.BeginHorizontal();
            LudiqGUI.FlexibleSpace();

            if (plugins.Any(plugin => plugin.manifest.savedVersion != plugin.manifest.currentVersion))
            {
                if (GUILayout.Button("Start", Styles.completeButton))
                {
                    Complete();
                }
            }
            else
            {
                if (GUILayout.Button("Close", Styles.completeButton))
                {
                    window.Close();
                }
            }

            LudiqGUI.FlexibleSpace();

            LudiqGUI.EndHorizontal();

            LudiqGUI.FlexibleSpace();
            LudiqGUI.EndVertical();
        }
Esempio n. 14
0
        private void OnHeaderGUI()
        {
            if (e.type == EventType.Layout || e.type == EventType.Repaint)
            {
                headerWidth = 0;
            }

            var previousIconSize = EditorGUIUtility.GetIconSize();

            EditorGUIUtility.SetIconSize(new Vector2(IconSize.Small, IconSize.Small));

            LudiqGUI.BeginHorizontal(Styles.headerBackground);

            foreach (var node in stack)
            {
                node.EnsureDrawable();

                var content   = new GUIContent(node.option.headerLabel, node.option.showHeaderIcon ? node.icon?[IconSize.Small] : null);
                var isCurrent = node == stack[stack.Count - 1];

                var style = node == stack[0] ? Styles.headerBreadcrumbRoot : Styles.headerBreadcrumbElement;
                if (isCurrent)
                {
                    style = node == stack[0] ? Styles.headerBreadcrumbRootCurrent : Styles.headerBreadcrumbElementCurrent;
                }
                var width = style.CalcSize(content).x;

                if (GUILayout.Toggle(isCurrent, content, style) && !isCurrent)
                {
                    SelectAncestor(node);
                }

                if (e.type == EventType.Layout || e.type == EventType.Repaint)
                {
                    headerWidth += width;
                }
            }

            LudiqGUI.FlexibleSpace();
            LudiqGUI.EndHorizontal();

            EditorGUIUtility.SetIconSize(previousIconSize);
        }
Esempio n. 15
0
        protected void DrawIconStyleState(GUIStyleState state, string label)
        {
            if (state == null || state.background == null)
            {
                return;
            }

            LudiqGUI.BeginHorizontal();
            LudiqGUI.FlexibleSpace();
            GUILayout.Label(label);
            LudiqGUI.FlexibleSpace();
            LudiqGUI.EndHorizontal();

            LudiqGUI.BeginHorizontal();
            LudiqGUI.FlexibleSpace();
            GUILayout.Box(state.background);
            LudiqGUI.FlexibleSpace();
            LudiqGUI.EndHorizontal();
        }
Esempio n. 16
0
        protected void OnTabsGUI()
        {
            LudiqGUI.BeginHorizontal();
            LudiqGUI.FlexibleSpace();

            for (var i = 0; i < pageOptions.Count; i++)
            {
                GUIStyle tabStyle;

                if (pageOptions.Count > 1)
                {
                    if (i == 0)
                    {
                        tabStyle = Styles.tabLeft;
                    }
                    else if (i == pageOptions.Count - 1)
                    {
                        tabStyle = Styles.tabRight;
                    }
                    else
                    {
                        tabStyle = Styles.tabMid;
                    }
                }
                else
                {
                    tabStyle = Styles.tabSingle;
                }

                var tabPage  = (Page)pageOptions[i].value;
                var tabLabel = pageOptions[i].label;

                if (GUILayout.Toggle(currentPage == tabPage, tabLabel, tabStyle) && currentPage != tabPage)
                {
                    currentPage = tabPage;
                }
            }

            LudiqGUI.FlexibleSpace();
            LudiqGUI.EndHorizontal();
        }
Esempio n. 17
0
        protected override void OnContentGUI()
        {
            GUILayout.BeginVertical(Styles.background, GUILayout.ExpandHeight(true));

            LudiqGUI.FlexibleSpace();
            GUILayout.Label($"Plugins have been updated.", LudiqStyles.centeredLabel);
            LudiqGUI.FlexibleSpace();

            if (hasChangelogs)
            {
                LudiqGUI.BeginHorizontal();
                LudiqGUI.FlexibleSpace();

                if (GUILayout.Button("Show Changelogs", Styles.button))
                {
                    Complete();
                }

                LudiqGUI.FlexibleSpace();
                LudiqGUI.EndHorizontal();

                LudiqGUI.Space(10);
            }

            LudiqGUI.BeginHorizontal();
            LudiqGUI.FlexibleSpace();

            if (GUILayout.Button("Close", Styles.button))
            {
                throw new WindowClose();
            }

            LudiqGUI.FlexibleSpace();
            LudiqGUI.EndHorizontal();

            LudiqGUI.FlexibleSpace();

            LudiqGUI.EndVertical();
        }
        protected override void OnHeaderGUI()
        {
            if (product.logo == null)
            {
                base.OnHeaderGUI();
                return;
            }

            GUILayout.BeginVertical(LudiqStyles.windowHeaderBackground);

            LudiqGUI.Space(-5);

            // Welcome label
            LudiqGUI.BeginHorizontal();
            LudiqGUI.FlexibleSpace();
            GUILayout.Label("Welcome to", Styles.welcome);
            LudiqGUI.FlexibleSpace();
            LudiqGUI.EndHorizontal();

            // Logo
            LudiqGUI.BeginHorizontal();
            LudiqGUI.FlexibleSpace();

            if (product.logo != null)
            {
                var logoHeight   = Styles.productLogoHeight;
                var logoWidth    = (float)product.logo.width / product.logo.height * logoHeight;
                var logoPosition = GUILayoutUtility.GetRect(logoWidth, logoHeight);
                GUI.DrawTexture(logoPosition, product.logo);
            }

            LudiqGUI.FlexibleSpace();
            LudiqGUI.EndHorizontal();

            LudiqGUI.EndVertical();
        }
Esempio n. 19
0
        private void OnOptionsGUI(FuzzyOptionNode parent, float scrollViewHeight)
        {
            if (parent.isLoading || (tree.showBackgroundWorkerProgress && BackgroundWorker.hasProgress))
            {
                LudiqGUI.BeginVertical();
                LudiqGUI.FlexibleSpace();
                LudiqGUI.BeginHorizontal();
                LudiqGUI.FlexibleSpace();
                LudiqGUI.LoaderLayout();
                LudiqGUI.FlexibleSpace();
                LudiqGUI.EndHorizontal();

                LudiqGUI.Space(16);
                LudiqGUI.BeginHorizontal();
                LudiqGUI.Space(10);
                var progressBarPosition = GUILayoutUtility.GetRect(GUIContent.none, GUIStyle.none, GUILayout.Height(19), GUILayout.ExpandWidth(true));
                if (tree.showBackgroundWorkerProgress && BackgroundWorker.hasProgress)
                {
                    EditorGUI.ProgressBar(progressBarPosition, BackgroundWorker.progressProportion, BackgroundWorker.progressLabel);
                }
                else if (showProgress)
                {
                    EditorGUI.ProgressBar(progressBarPosition, progress, progressText);
                }
                LudiqGUI.Space(10);
                LudiqGUI.EndHorizontal();

                LudiqGUI.FlexibleSpace();
                LudiqGUI.EndVertical();
                Repaint();
                return;
            }

            parent.scroll = GUILayout.BeginScrollView(parent.scroll);

            EditorGUIUtility.SetIconSize(new Vector2(IconSize.Small, IconSize.Small));

            var selectedOptionPosition = default(Rect);

            if (e.type == EventType.Repaint)
            {
                minOptionWidth = 0;
            }

            foreach (var node in parent.children)
            {
                node.EnsureDrawable();

                minOptionWidth = Mathf.Max(minOptionWidth, Mathf.Min(node.width, Styles.maxOptionWidth));
            }

            for (var i = 0; i < parent.children.Count; i++)
            {
                var node = parent.children[i];

                var optionPosition = GUILayoutUtility.GetRect(IconSize.Small, Styles.optionHeight, GUILayout.ExpandWidth(true));

                if (((e.type == EventType.MouseMove && GUIUtility.GUIToScreenPoint(e.mousePosition) != lastMouseMovePosition) || e.type == EventType.MouseDown) &&
                    parent.selectedIndex != i &&
                    optionPosition.Contains(e.mousePosition))
                {
                    parent.selectedIndex = i;
                    Repaint();
                    lastMouseMovePosition = GUIUtility.GUIToScreenPoint(e.mousePosition);
                }

                var optionIsSelected = false;

                if (i == parent.selectedIndex)
                {
                    optionIsSelected       = true;
                    selectedOptionPosition = optionPosition;
                }

                // Clipping
                if (optionPosition.yMax < parent.scroll.y || optionPosition.yMin > parent.scroll.y + scrollViewHeight)
                {
                    continue;
                }

                if (e.type == EventType.Repaint)
                {
                    node.style.Draw(optionPosition, node.label, false, false, optionIsSelected, optionIsSelected);
                }

                var right = optionPosition.xMax;

                if (node.hasChildren)
                {
                    right -= 13;
                    var rightArrowPosition = new Rect(right, optionPosition.y + 4, 13, 13);

                    if (e.type == EventType.Repaint)
                    {
                        Styles.rightArrow.Draw(rightArrowPosition, false, false, false, false);
                    }
                }

                if (!node.hasChildren && tree.selected.Contains(node.option.value))
                {
                    right -= 16;
                    var checkPosition = new Rect(right, optionPosition.y + 4, 12, 12);

                    if (e.type == EventType.Repaint)
                    {
                        Styles.check.Draw(checkPosition, false, false, false, false);
                    }
                }

                if (tree.favorites != null && tree.CanFavorite(node.option.value) && (optionIsSelected || tree.favorites.Contains(node.option.value)))
                {
                    right -= 19;
                    var starPosition = new Rect(right, optionPosition.y + 2, IconSize.Small, IconSize.Small);

                    EditorGUI.BeginChangeCheck();

                    var isFavorite = tree.favorites.Contains(node.option.value);

                    isFavorite = GUI.Toggle(starPosition, isFavorite, GUIContent.none, Styles.star);

                    if (EditorGUI.EndChangeCheck())
                    {
                        if (isFavorite)
                        {
                            tree.favorites.Add(node.option.value);
                        }
                        else
                        {
                            tree.favorites.Remove(node.option.value);
                        }

                        tree.OnFavoritesChange();

                        UpdateFavorites();
                    }
                }

                if (e.type == EventType.MouseDown && e.button == (int)MouseButton.Left && optionPosition.Contains(e.mousePosition))
                {
                    e.Use();
                    parent.selectedIndex = i;
                    SelectChild(node);
                }
            }

            EditorGUIUtility.SetIconSize(default(Vector2));

            GUILayout.EndScrollView();

            if (scrollToSelected && e.type == EventType.Repaint)
            {
                scrollToSelected = false;

                var lastRect = GUILayoutUtility.GetLastRect();

                if (selectedOptionPosition.yMax - lastRect.height > parent.scroll.y)
                {
                    var scroll = parent.scroll;
                    scroll.y      = selectedOptionPosition.yMax - lastRect.height;
                    parent.scroll = scroll;
                    Repaint();
                }

                if (selectedOptionPosition.y < parent.scroll.y)
                {
                    var scroll = parent.scroll;
                    scroll.y      = selectedOptionPosition.y;
                    parent.scroll = scroll;
                    Repaint();
                }
            }
        }
Esempio n. 20
0
        protected void DrawIconDisplay(GUIStyle style)
        {
            if (style == null)
            {
                DrawCenteredMessage("No icon selected");
                LudiqGUI.FlexibleSpace();
                DrawHelpIcon();
                return;
            }

            var iconTexture = style.normal.background;

            LudiqGUI.BeginVertical();

            LudiqGUI.BeginHorizontal();
            LudiqGUI.FlexibleSpace();
            GUILayout.Label(style.name, EditorStyles.whiteLargeLabel);
            LudiqGUI.FlexibleSpace();
            LudiqGUI.EndHorizontal();

            LudiqGUI.BeginHorizontal();
            LudiqGUI.FlexibleSpace();
            GUILayout.Label("Normal");
            LudiqGUI.FlexibleSpace();
            LudiqGUI.EndHorizontal();

            float iconOffset     = 45;
            var   iconWidth      = iconTexture.width * _drawScale;
            var   iconHeight     = iconTexture.height * _drawScale;
            var   sidePanelWidth = CalculateSidePanelWidth();

            GUI.DrawTexture(new Rect((sidePanelWidth - iconWidth) * 0.5f, iconOffset, iconWidth, iconHeight), iconTexture, ScaleMode.StretchToFill);
            LudiqGUI.Space(iconHeight + 10);

            LudiqGUI.BeginHorizontal();
            if (GUILayout.Toggle(_drawScale == 1.0f, "1x", EditorStyles.miniButtonLeft))
            {
                _drawScale = 1.0f;
            }
            if (GUILayout.Toggle(_drawScale == 1.5f, "1.5x", EditorStyles.miniButtonMid))
            {
                _drawScale = 1.5f;
            }
            if (GUILayout.Toggle(_drawScale == 2.0f, "2x", EditorStyles.miniButtonRight))
            {
                _drawScale = 2.0f;
            }
            LudiqGUI.EndHorizontal();

            LudiqGUI.Space(10);

            DrawIconStyleState(style.active, "Active");
            DrawIconStyleState(style.hover, "Hover");
            DrawIconStyleState(style.focused, "Focused");

            DrawIconStyleState(style.onNormal, "On Normal");
            DrawIconStyleState(style.onActive, "On Active");
            DrawIconStyleState(style.onHover, "On Hover");
            DrawIconStyleState(style.onFocused, "On Focused");

            LudiqGUI.Space(10);

            EditorGUILayout.LabelField($"Width:      {iconTexture.width}px");
            EditorGUILayout.LabelField($"Height:    {iconTexture.height}px");

            LudiqGUI.FlexibleSpace();
            DrawHelpIcon();

            LudiqGUI.EndVertical();
        }
Esempio n. 21
0
        protected override void OnContentGUI()
        {
            var previousIconSize = EditorGUIUtility.GetIconSize();

            EditorGUIUtility.SetIconSize(new Vector2(IconSize.Small, IconSize.Small));

            GUILayout.BeginVertical(Styles.background, GUILayout.ExpandHeight(true));

            var question = "How do you want names to be displayed?" + "\n";

            question += "If you're not an experienced programmer, we recommend Human Naming.";

            LudiqGUI.FlexibleSpace();
            GUILayout.Label(question, LudiqStyles.centeredLabel);
            LudiqGUI.FlexibleSpace();
            LudiqGUI.BeginHorizontal();
            LudiqGUI.FlexibleSpace();

            LudiqGUI.BeginVertical();

            if (GUILayout.Button("Human Naming", Styles.modeButton))
            {
                LudiqCore.Configuration.humanNaming = true;
                LudiqCore.Configuration.Save();
                Complete();
            }

            LudiqGUI.Space(-1);
            GUILayout.BeginVertical(Styles.modeBox);
            GUILayout.Label(new GUIContent(" Transform: Get Position", typeof(Transform).Icon()[IconSize.Small]), Styles.example);
            GUILayout.Label(new GUIContent(" Integer", typeof(int).Icon()[IconSize.Small]), Styles.example);
            GUILayout.Label(new GUIContent(" List of Game Object", typeof(List <GameObject>).Icon()[IconSize.Small]), Styles.example);
            GUILayout.Label(new GUIContent(" Rigidbody: Add Force (Force)", typeof(Rigidbody).Icon()[IconSize.Small]), Styles.example);
            LudiqGUI.EndVertical();
            LudiqGUI.EndVertical();

            LudiqGUI.Space(10);

            LudiqGUI.BeginVertical();

            if (GUILayout.Button("Programmer Naming", Styles.modeButton))
            {
                LudiqCore.Configuration.humanNaming = false;
                LudiqCore.Configuration.Save();
                Complete();
            }

            LudiqGUI.Space(-1);
            GUILayout.BeginVertical(Styles.modeBox);
            GUILayout.Label(new GUIContent(" Transform.position (Get)", typeof(Transform).Icon()[IconSize.Small]), Styles.example);
            GUILayout.Label(new GUIContent(" int", typeof(int).Icon()[IconSize.Small]), Styles.example);
            GUILayout.Label(new GUIContent(" List<GameObject>", typeof(List <GameObject>).Icon()[IconSize.Small]), Styles.example);
            GUILayout.Label(new GUIContent(" Rigidbody.AddForce(force)", typeof(Rigidbody).Icon()[IconSize.Small]), Styles.example);
            LudiqGUI.EndVertical();
            LudiqGUI.EndVertical();

            LudiqGUI.FlexibleSpace();
            LudiqGUI.EndHorizontal();
            LudiqGUI.FlexibleSpace();
            GUILayout.Label("You can change this setting at any time from the setup or configuration.", EditorStyles.centeredGreyMiniLabel);
            LudiqGUI.FlexibleSpace();

            LudiqGUI.EndVertical();

            EditorGUIUtility.SetIconSize(previousIconSize);
        }
Esempio n. 22
0
        protected override void OnContentGUI()
        {
            if (!migrations.SelectMany(m => m.requiredActions).Any())
            {
                Complete();
            }

            scroll = GUILayout.BeginScrollView(scroll, Styles.background, GUILayout.ExpandHeight(true));
            LudiqGUI.BeginVertical();

            LudiqGUI.Space(Styles.space);
            LudiqGUI.BeginHorizontal();
            LudiqGUI.FlexibleSpace();
            GUILayout.Label("The following required update actions could not be completed automatically. Please complete them before continuing to use the plugin.", LudiqStyles.centeredLabel, GUILayout.MaxWidth(340));
            LudiqGUI.FlexibleSpace();
            LudiqGUI.EndHorizontal();
            LudiqGUI.Space(Styles.space);

            foreach (var migration in migrations)
            {
                if (!migration.requiredActions.Any())
                {
                    continue;
                }

                LudiqGUI.BeginHorizontal();
                LudiqGUI.FlexibleSpace();
                GUILayout.BeginVertical(GUILayout.MaxWidth(300));

                LudiqGUI.BeginHorizontal();
                GUILayout.Box(BoltCore.Icons.warningMessage?[IconSize.Small], Styles.migrationIcon);
                GUILayout.Label($"{migration.plugin.manifest.name}, v.{migration.@from} to v.{migration.to}: ", Styles.migration);
                LudiqGUI.EndHorizontal();

                foreach (var requiredAction in migration.requiredActions)
                {
                    LudiqGUI.Space(5);
                    LudiqGUI.BeginHorizontal();
                    GUILayout.Box(GUIContent.none, Styles.requiredActionBullet);
                    GUILayout.Label(requiredAction, Styles.requiredAction);
                    LudiqGUI.EndHorizontal();
                }

                LudiqGUI.EndVertical();
                LudiqGUI.FlexibleSpace();
                LudiqGUI.EndHorizontal();

                LudiqGUI.Space(Styles.space);
            }

            LudiqGUI.BeginHorizontal();
            LudiqGUI.FlexibleSpace();

            if (GUILayout.Button(completeLabel, Styles.completeButton))
            {
                Complete();
            }

            LudiqGUI.FlexibleSpace();
            LudiqGUI.EndHorizontal();

            LudiqGUI.Space(Styles.space);
            LudiqGUI.EndVertical();
            GUILayout.EndScrollView();
        }
        protected override void OnContentGUI()
        {
            GUILayout.BeginVertical(Styles.background, GUILayout.ExpandHeight(true));

            LudiqGUI.FlexibleSpace();

            LudiqGUI.BeginHorizontal();
            LudiqGUI.FlexibleSpace();

            var text = "Choose the assemblies in which you want to look for units.\n"
                       + "By default, all project and Unity assemblies are included.\n"
                       + "Unless you use a third-party plugin distributed as a DLL, you shouldn't need to change this.";

            GUILayout.Label(text, LudiqStyles.centeredLabel, GUILayout.MaxWidth(370));
            LudiqGUI.FlexibleSpace();
            LudiqGUI.EndHorizontal();

            LudiqGUI.Space(10);

            var height = LudiqGUI.GetInspectorHeight(null, assemblyOptionsMetadata, Styles.optionsWidth, GUIContent.none);

            LudiqGUI.BeginHorizontal();

            LudiqGUI.FlexibleSpace();

            EditorGUI.BeginChangeCheck();

            var position = GUILayoutUtility.GetRect(Styles.optionsWidth, height);

            LudiqGUI.Inspector(assemblyOptionsMetadata, position, GUIContent.none);

            if (EditorGUI.EndChangeCheck())
            {
                assemblyOptionsMetadata.Save();
                Codebase.UpdateSettings();
            }

            LudiqGUI.FlexibleSpace();
            LudiqGUI.EndHorizontal();

            LudiqGUI.Space(10);

            LudiqGUI.BeginHorizontal();
            LudiqGUI.FlexibleSpace();

            if (GUILayout.Button("Reset to Defaults", Styles.defaultsButton))
            {
                assemblyOptionsMetadata.Reset(true);
                assemblyOptionsMetadata.Save();
            }

            LudiqGUI.FlexibleSpace();
            LudiqGUI.EndHorizontal();

            LudiqGUI.FlexibleSpace();

            LudiqGUI.Space(10);

            LudiqGUI.BeginHorizontal();
            LudiqGUI.FlexibleSpace();

            if (GUILayout.Button(completeLabel, Styles.completeButton))
            {
                Complete();
            }

            LudiqGUI.FlexibleSpace();
            LudiqGUI.EndHorizontal();

            LudiqGUI.FlexibleSpace();

            LudiqGUI.EndVertical();
        }
Esempio n. 24
0
        protected override void OnContentGUI()
        {
            if (!plugins.Any())
            {
                Complete();
            }

            GUILayout.BeginVertical(Styles.background, GUILayout.ExpandHeight(true));
            LudiqGUI.FlexibleSpace();
            GUILayout.Label($"The following plugins have been downgraded to a previous version: ", LudiqStyles.centeredLabel);
            LudiqGUI.FlexibleSpace();
            UpdateWizard.DrawPluginVersionTable(plugins);
            LudiqGUI.FlexibleSpace();
            GUILayout.Label("This will likely cause backwards incompatibility issues.", LudiqStyles.centeredLabel);
            GUILayout.Label("We recommend that you re-install their saved version to avoid data corruption.", LudiqStyles.centeredLabel);
            LudiqGUI.FlexibleSpace();

            LudiqGUI.BeginHorizontal();
            LudiqGUI.FlexibleSpace();

            if (GUILayout.Button("Close", Styles.button))
            {
                throw new WindowClose();
            }

            LudiqGUI.Space(10);

            if (GUILayout.Button("Force Consolidate", Styles.button))
            {
                var consolidationExplanation = string.Empty;
                consolidationExplanation += $"By forcing consolidation, the saved versions will be set to match the installed versions. ";
                consolidationExplanation += "This does not roll back updates and may lead to data corruption. ";
                consolidationExplanation += "You should only do this if you know what you are doing. ";
                consolidationExplanation += "A backup will be created automatically if you decide to proceed.";

                if (EditorUtility.DisplayDialog("Force Consolidate Version", consolidationExplanation, "Force Consolidate", "Cancel"))
                {
                    var forceConsolidate = false;

                    if (EditorUtility.DisplayDialog("Force Consolidate Version", "Create backup before consolidating?", "Yes", "No"))
                    {
                        try
                        {
                            BackupUtility.BackupAssetsFolder();
                            forceConsolidate = true;
                        }
                        catch (Exception ex)
                        {
                            EditorUtility.DisplayDialog("Backup", "Failed to create backup. Version consolidation canceled.", "OK");
                            UnityEngine.Debug.LogException(ex);
                        }
                    }
                    else
                    {
                        forceConsolidate = true;
                    }

                    if (forceConsolidate)
                    {
                        foreach (var plugin in plugins)
                        {
                            plugin.manifest.savedVersion = plugin.manifest.currentVersion;
                        }

                        Complete();
                    }
                }
            }

            LudiqGUI.Space(10);

            if (GUILayout.Button("Backups", Styles.button))
            {
                PathUtility.CreateDirectoryIfNeeded(Paths.backups);
                Process.Start(Paths.backups);
            }

            LudiqGUI.FlexibleSpace();
            LudiqGUI.EndHorizontal();

            LudiqGUI.FlexibleSpace();
            LudiqGUI.EndVertical();
        }
        protected override void OnContentGUI()
        {
            scroll = GUILayout.BeginScrollView(scroll, Styles.background, GUILayout.ExpandHeight(true));

            LudiqGUI.BeginVertical();

            LudiqGUI.FlexibleSpace();
            LudiqGUI.BeginHorizontal();
            LudiqGUI.FlexibleSpace();
            GUILayout.Label("When you start the update, the wizard will run migrations between the previous and new version and make all required automatic changes.", LudiqStyles.centeredLabel, GUILayout.MaxWidth(370));
            LudiqGUI.FlexibleSpace();
            LudiqGUI.EndHorizontal();
            LudiqGUI.FlexibleSpace();

            EditorGUI.BeginDisabledGroup(queue.Count > 0 || migrated);
            LudiqGUI.BeginHorizontal();
            LudiqGUI.FlexibleSpace();

            if (GUILayout.Button("Update", Styles.updateButton))
            {
                foreach (var step in steps)
                {
                    step.Reset();
                }

                foreach (var step in steps)
                {
                    queue.Enqueue(step);
                }

                queue.Peek().Run();
            }

            LudiqGUI.FlexibleSpace();
            LudiqGUI.EndHorizontal();
            EditorGUI.EndDisabledGroup();

            LudiqGUI.FlexibleSpace();

            LudiqGUI.BeginHorizontal();
            LudiqGUI.FlexibleSpace();
            LudiqGUI.BeginVertical();

            foreach (var step in steps)
            {
                step.OnGUI();

                LudiqGUI.Space(Styles.spaceBetweenSteps);
            }

            LudiqGUI.EndVertical();
            LudiqGUI.FlexibleSpace();
            LudiqGUI.EndHorizontal();

            LudiqGUI.FlexibleSpace();

            EditorGUI.BeginDisabledGroup(!migrated);
            LudiqGUI.BeginHorizontal();
            LudiqGUI.FlexibleSpace();

            if (GUILayout.Button(completeLabel, Styles.completeButton))
            {
                Complete();
            }

            LudiqGUI.FlexibleSpace();
            LudiqGUI.EndHorizontal();
            EditorGUI.EndDisabledGroup();

            LudiqGUI.FlexibleSpace();

            LudiqGUI.EndVertical();

            GUILayout.EndScrollView();
        }
Esempio n. 26
0
        protected override void OnContentGUI()
        {
            GUILayout.BeginVertical(Styles.background, GUILayout.ExpandHeight(true));

            LudiqGUI.FlexibleSpace();
            LudiqGUI.FlexibleSpace();

            var paragraph = incentive;

            paragraph += " Here, you can create a zip of your assets folder automatically and store it under 'Project\u00a0/\u00a0Backups'.)";

            LudiqGUI.BeginHorizontal();
            LudiqGUI.FlexibleSpace();
            GUILayout.Label(paragraph, LudiqStyles.centeredLabel, GUILayout.MaxWidth(370));
            LudiqGUI.FlexibleSpace();
            LudiqGUI.EndHorizontal();

            LudiqGUI.FlexibleSpace();

            LudiqGUI.BeginHorizontal();
            LudiqGUI.FlexibleSpace();

            if (GUILayout.Button("Create Backup", Styles.createBackupButton))
            {
                try
                {
                    BackupUtility.BackupAssetsFolder();
                    createdBackup = true;
                }
                catch (Exception ex)
                {
                    EditorUtility.DisplayDialog("Backup Error", "Failed to create backup:\n\n" + ex.Message, "OK");
                }
            }

            LudiqGUI.FlexibleSpace();
            LudiqGUI.EndHorizontal();

            LudiqGUI.Space(10);

            if (createdBackup)
            {
                GUILayout.Label(new GUIContent(" Backup created", BoltCore.Icons.successState?[IconSize.Small]), Styles.backupCreatedLabel);
            }
            else
            {
                LudiqGUI.Space(Styles.backupCreatedLabel.fixedHeight + 2);
            }

            LudiqGUI.Space(10);

            LudiqGUI.BeginHorizontal();
            LudiqGUI.FlexibleSpace();

            OnCloseButtonGUI();

            LudiqGUI.FlexibleSpace();
            LudiqGUI.EndHorizontal();

            LudiqGUI.FlexibleSpace();
            LudiqGUI.FlexibleSpace();

            LudiqGUI.EndVertical();
        }
Esempio n. 27
0
        private void Draw()
        {
            if (Event.current.type == EventType.Layout)
            {
                UpdateDrawnElements();
            }

            LudiqGUI.BeginVertical(Styles.background);

            LudiqGUI.BeginHorizontal(Styles.tipArea, GUILayout.Height(Styles.tipHeight));

            LudiqGUI.BeginVertical();
            LudiqGUI.FlexibleSpace();
            LudiqGUI.LoaderLayout();
            LudiqGUI.FlexibleSpace();
            LudiqGUI.EndVertical();

            if (drawnTip != null)
            {
                LudiqGUI.Space(Styles.spaceBetweenSpinnerAndTip);

                LudiqGUI.BeginVertical();
                LudiqGUI.FlexibleSpace();
                GUILayout.Label("<b>Tip:</b> " + drawnTip, Styles.tip);
                LudiqGUI.FlexibleSpace();
                LudiqGUI.EndVertical();
            }

            LudiqGUI.EndHorizontal();

            if (drawnTasks.Count > 0)
            {
                var first = true;

                foreach (var task in drawnTasks)
                {
                    if (!first)
                    {
                        GUILayout.Space(Styles.spaceBetweenTasks);
                    }

                    if (Event.current.type == EventType.Layout)
                    {
                        task.animatedRatio = Mathf.MoveTowards(task.animatedRatio, task.ratio, progressAnimationSpeed * repaintDeltaTime);
                    }

                    LudiqGUI.BeginVertical(Styles.task);

                    GUILayout.Label(task.title + $" <color=#{ColorPalette.unityForegroundDim.ToHexString()}>({task.elapsed.TotalSeconds:###0.0} seconds)</color>", Styles.taskTitle);

                    var progressBarPosition = EditorGUILayout.GetControlRect();

                    EditorGUI.ProgressBar(progressBarPosition, task.animatedRatio, null);

                    if (task.stepsHaveStarted)
                    {
                        var currentItemPosition = new Rect
                                                  (
                            progressBarPosition.x + (int)(task.animatedRatio * progressBarPosition.width) - 1,
                            progressBarPosition.y,
                            Mathf.Max(3, Mathf.CeilToInt((1f / task.totalSteps) * (progressBarPosition.width)) + 1),
                            progressBarPosition.height
                                                  );

                        if (Event.current.type == EventType.Repaint)
                        {
                            var opacity = Mathf.Lerp(0.25f, 0.25f, (Mathf.Sin((float)EditorApplication.timeSinceStartup * 3) + 1) / 2);

                            using (LudiqGUI.color.Override(LudiqGUI.color.value.WithAlphaMultiplied(opacity)))
                            {
                                Styles.currentItemFill.Draw(currentItemPosition, false, false, false, false);
                            }
                        }

                        LudiqGUI.DrawEmptyRect(currentItemPosition, Styles.currentItemBorder);

                        if (Event.current.type == EventType.Repaint)
                        {
                            Styles.currentItemText.Draw(progressBarPosition, new GUIContent(task.currentStepLabel), false, false, false, false);
                        }
                    }

                    LudiqGUI.EndVertical();

                    first = false;
                }
            }

            LudiqGUI.EndVertical();
        }
Esempio n. 28
0
        protected override void OnContentGUI()
        {
            var previousIconSize = EditorGUIUtility.GetIconSize();

            EditorGUIUtility.SetIconSize(new Vector2(IconSize.Small, IconSize.Small));

            var explanation = "Bolt plugins can automatically display documentation for Unity methods in graphs and in the inspector. ";

            explanation += "To also include documentation from your custom code and from third-party plugins, we need to generate it first.";

            GUILayout.BeginVertical(Styles.background, GUILayout.ExpandHeight(true));

            LudiqGUI.FlexibleSpace();
            LudiqGUI.BeginHorizontal();
            LudiqGUI.FlexibleSpace();
            GUILayout.Label(explanation, Styles.explanationLabel, GUILayout.MaxWidth(350));
            LudiqGUI.FlexibleSpace();
            LudiqGUI.EndHorizontal();
            LudiqGUI.FlexibleSpace();

            LudiqGUI.BeginHorizontal();
            LudiqGUI.FlexibleSpace();

            EditorGUI.BeginDisabledGroup(queue.Count > 0);

            if (GUILayout.Button("Generate Documentation", Styles.generateButton))
            {
                foreach (var step in steps)
                {
                    step.Reset();
                }

                foreach (var step in steps)
                {
                    queue.Enqueue(step);
                }

                queue.Peek().Generate();
                generating = true;
            }

            EditorGUI.EndDisabledGroup();

            LudiqGUI.FlexibleSpace();
            LudiqGUI.EndHorizontal();

            LudiqGUI.FlexibleSpace();

            LudiqGUI.BeginHorizontal();
            LudiqGUI.FlexibleSpace();
            LudiqGUI.BeginVertical();

            foreach (var step in steps)
            {
                step.OnGUI();

                LudiqGUI.Space(Styles.spaceBetweenSteps);
            }

            LudiqGUI.EndVertical();
            LudiqGUI.FlexibleSpace();
            LudiqGUI.EndHorizontal();

            LudiqGUI.FlexibleSpace();

            EditorGUI.BeginDisabledGroup(generating);
            LudiqGUI.BeginHorizontal();
            LudiqGUI.FlexibleSpace();

            if (GUILayout.Button(completeLabel, Styles.nextButton))
            {
                Complete();
            }

            LudiqGUI.FlexibleSpace();
            LudiqGUI.EndHorizontal();
            EditorGUI.EndDisabledGroup();

            LudiqGUI.FlexibleSpace();
            GUILayout.Label("You can regenerate documentation at any time from the tools menu.", EditorStyles.centeredGreyMiniLabel);

            LudiqGUI.EndVertical();

            EditorGUIUtility.SetIconSize(previousIconSize);
        }
        protected override void OnContentGUI()
        {
            GUILayout.BeginVertical(Styles.background, GUILayout.ExpandHeight(true));

            LudiqGUI.FlexibleSpace();

            LudiqGUI.BeginHorizontal();
            LudiqGUI.FlexibleSpace();

            var text = "Choose the types you want to use for variables and units.\n"
                       + "MonoBehaviour types are always included.";

            GUILayout.Label(text, LudiqStyles.centeredLabel, GUILayout.MaxWidth(370));
            LudiqGUI.FlexibleSpace();
            LudiqGUI.EndHorizontal();

            LudiqGUI.Space(10);

            var height = LudiqGUI.GetInspectorHeight(null, typeOptionsMetadata, Styles.optionsWidth, GUIContent.none);

            LudiqGUI.BeginHorizontal();

            LudiqGUI.FlexibleSpace();

            EditorGUI.BeginChangeCheck();

            var position = GUILayoutUtility.GetRect(Styles.optionsWidth, height);

            LudiqGUI.Inspector(typeOptionsMetadata, position, GUIContent.none);

            if (EditorGUI.EndChangeCheck())
            {
                typeOptionsMetadata.Save();
                Codebase.UpdateSettings();
            }

            LudiqGUI.FlexibleSpace();
            LudiqGUI.EndHorizontal();

            LudiqGUI.Space(10);

            LudiqGUI.BeginHorizontal();
            LudiqGUI.FlexibleSpace();

            if (GUILayout.Button("Reset to Defaults", Styles.defaultsButton))
            {
                typeOptionsMetadata.Reset(true);
                typeOptionsMetadata.Save();
            }

            LudiqGUI.FlexibleSpace();
            LudiqGUI.EndHorizontal();

            LudiqGUI.FlexibleSpace();

            LudiqGUI.Space(10);

            LudiqGUI.BeginHorizontal();
            LudiqGUI.FlexibleSpace();

            if (GUILayout.Button("Generate", Styles.completeButton))
            {
                Complete();
            }

            LudiqGUI.FlexibleSpace();
            LudiqGUI.EndHorizontal();

            LudiqGUI.FlexibleSpace();

            LudiqGUI.EndVertical();
        }
Esempio n. 30
0
        private void OnOptionsGUI(float anim, FuzzyOptionNode parent)
        {
            var hasHeader         = !string.IsNullOrEmpty(parent.option.headerLabel);
            var headerHeight      = hasHeader ? Styles.headerHeight : 0;
            var searchFieldHeight = tree.searchable ? LudiqStyles.searchFieldOuterHeight : 0;

            var levelPosition = new Rect
                                (
                position.width * (1 - anim) + 1,
                searchFieldHeight + headerHeight,
                position.width - 2,
                height - (searchFieldHeight + 1) - headerHeight
                                );

            if (e.type == EventType.MouseDown && e.button == (int)MouseButton.Right && levelPosition.Contains(e.mousePosition))
            {
                SelectParent();
                e.Use();
            }

            GUILayout.BeginArea(levelPosition);

            if (parent.isLoading)
            {
                LudiqGUI.BeginVertical();
                LudiqGUI.FlexibleSpace();

                LudiqGUI.BeginHorizontal();
                LudiqGUI.FlexibleSpace();
                LudiqGUI.LoaderLayout();
                LudiqGUI.FlexibleSpace();
                LudiqGUI.EndHorizontal();

                LudiqGUI.Space(16);

                LudiqGUI.BeginHorizontal();
                LudiqGUI.Space(10);
                var progressBarPosition = GUILayoutUtility.GetRect(GUIContent.none, GUIStyle.none, GUILayout.Height(19), GUILayout.ExpandWidth(true));
                if (showProgress)
                {
                    EditorGUI.ProgressBar(progressBarPosition, progress, progressText);
                }

                LudiqGUI.Space(10);
                LudiqGUI.EndHorizontal();
                LudiqGUI.Space(LudiqGUI.loaderSize * 1.5f);

                LudiqGUI.FlexibleSpace();
                LudiqGUI.EndVertical();
                Repaint();
            }
            else
            {
                parent.scroll = GUILayout.BeginScrollView(parent.scroll);

                EditorGUIUtility.SetIconSize(new Vector2(IconSize.Small, IconSize.Small));

                var selectedOptionPosition = default(Rect);

                foreach (var node in parent.children)
                {
                    node.EnsurePositionable();

                    if (e.type == EventType.Layout || e.type == EventType.Repaint)
                    {
                        minOptionWidth = Mathf.Max(minOptionWidth, Mathf.Min(node.width, Styles.maxOptionWidth));
                    }
                }

                for (var i = 0; i < parent.children.Count; i++)
                {
                    var node        = parent.children[i];
                    var isSeparator = node.option is FuzzySeparator;

                    var optionPosition = GUILayoutUtility.GetRect(IconSize.Small, isSeparator ? Styles.separator.fixedHeight : Styles.optionHeight, GUILayout.ExpandWidth(true));

                    if (((e.type == EventType.MouseMove && GUIUtility.GUIToScreenPoint(e.mousePosition) != lastMouseMovePosition) || e.type == EventType.MouseDown) &&
                        parent.selectedIndex != i &&
                        optionPosition.Contains(e.mousePosition))
                    {
                        parent.selectedIndex = i;
                        Repaint();
                        lastMouseMovePosition = GUIUtility.GUIToScreenPoint(e.mousePosition);
                    }

                    var optionIsSelected = false;

                    if (i == parent.selectedIndex)
                    {
                        optionIsSelected       = true;
                        selectedOptionPosition = optionPosition;
                    }

                    // Clipping
                    if (optionPosition.yMax < parent.scroll.y || optionPosition.yMin > parent.scroll.y + levelPosition.height)
                    {
                        continue;
                    }

                    EditorGUI.BeginDisabledGroup(node.option.mode == FuzzyOptionMode.Branch && node.hasChildren == false);

                    node.EnsureDrawable();

                    if (e.type == EventType.Repaint)
                    {
                        using (LudiqGUI.color.Override(node.dim ? LudiqGUI.color.value.WithAlphaMultiplied(0.66f) : LudiqGUI.color.value))
                        {
                            if (node.option is FuzzySeparator)
                            {
                                Styles.separator.Draw(optionPosition, node.label, false, false, false, false);

                                var linePosition = new Rect(optionPosition.x, optionPosition.yMax - 1, optionPosition.width, 1);

                                Styles.separatorLine.Draw(linePosition, GUIContent.none, false, false, false, false);
                            }
                            else
                            {
                                Styles.optionBackground.Draw(optionPosition, GUIContent.none, false, false, optionIsSelected, optionIsSelected);

                                float x = Styles.optionBackground.padding.left;

                                var spaced = false;

                                foreach (var icon in node.icons)
                                {
                                    if (icon == null)
                                    {
                                        continue;
                                    }

                                    var iconPosition = new Rect
                                                       (
                                        optionPosition.x + x,
                                        optionPosition.y + Styles.optionBackground.padding.top,
                                        IconSize.Small,
                                        IconSize.Small
                                                       );

                                    GUI.DrawTexture(iconPosition, icon[IconSize.Small]);

                                    x     += IconSize.Small;
                                    x     += Styles.spaceBetweenIcons;
                                    spaced = true;
                                }

                                if (spaced)
                                {
                                    x -= Styles.spaceBetweenIcons;
                                    x += Styles.spaceAfterIcons;
                                }

                                var foregroundPosition = optionPosition;
                                foregroundPosition.x     += x;
                                foregroundPosition.width -= x;

                                Styles.optionForeground.Draw(foregroundPosition, node.label, false, false, optionIsSelected, optionIsSelected);
                            }
                        }
                    }

                    var right = optionPosition.xMax;

                    if (node.option.mode == FuzzyOptionMode.Branch)
                    {
                        right -= 13;
                        var rightArrowPosition = new Rect(right, optionPosition.y + 4, 13, 13);

                        if (e.type == EventType.Repaint)
                        {
                            Styles.rightArrow.Draw(rightArrowPosition, false, false, false, false);
                        }
                    }

                    if (node.option.mode == FuzzyOptionMode.Leaf && tree.selected.Contains(node.option.value) && !isSeparator)
                    {
                        right -= 16;
                        var checkPosition = new Rect(right, optionPosition.y + 4, 12, 12);

                        if (e.type == EventType.Repaint)
                        {
                            Styles.check.Draw(checkPosition, false, false, false, false);
                        }
                    }

                    EditorGUI.EndDisabledGroup();

                    if (tree.favorites != null && tree.CanFavorite(node.option) && (optionIsSelected || tree.favorites.Contains(node.option)))
                    {
                        right -= 19;
                        var starPosition = new Rect(right, optionPosition.y + 2, IconSize.Small, IconSize.Small);

                        EditorGUI.BeginChangeCheck();

                        var isFavorite = tree.favorites.Contains(node.option);

                        isFavorite = GUI.Toggle(starPosition, isFavorite, GUIContent.none, Styles.star);

                        if (EditorGUI.EndChangeCheck())
                        {
                            if (isFavorite)
                            {
                                tree.favorites.Add(node.option);
                            }
                            else
                            {
                                tree.favorites.Remove(node.option);
                            }

                            tree.OnFavoritesChange();

                            ExecuteTask(() => UpdateFavorites());
                        }
                    }

                    if (e.type == EventType.MouseUp && e.button == (int)MouseButton.Left && optionPosition.Contains(e.mousePosition))
                    {
                        e.Use();
                        parent.selectedIndex = i;
                        SelectChild(node);
                    }
                }

                EditorGUIUtility.SetIconSize(default(Vector2));

                GUILayout.EndScrollView();

                if (scrollToSelected && e.type == EventType.Repaint)
                {
                    scrollToSelected = false;

                    var lastRect = GUILayoutUtility.GetLastRect();

                    if (selectedOptionPosition.yMax - lastRect.height > parent.scroll.y)
                    {
                        var scroll = parent.scroll;
                        scroll.y      = selectedOptionPosition.yMax - lastRect.height;
                        parent.scroll = scroll;
                        Repaint();
                    }

                    if (selectedOptionPosition.y < parent.scroll.y)
                    {
                        var scroll = parent.scroll;
                        scroll.y      = selectedOptionPosition.y;
                        parent.scroll = scroll;
                        Repaint();
                    }
                }
            }

            GUILayout.EndArea();
        }