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))
                {
                    throw new WindowClose();
                }
            }

            LudiqGUI.FlexibleSpace();

            LudiqGUI.EndHorizontal();

            LudiqGUI.FlexibleSpace();
            LudiqGUI.EndVertical();
        }
Beispiel #2
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();
        }