コード例 #1
0
        private void _bepInstallButton_Click(object sender, EventArgs e)
        {
            this._bepInstallButton.Enabled = false;
            this._uninstallButton.Enabled  = false;
            MefinoGUI.SetProgressBarActive(true);

            BepInExHandler.UpdateBepInEx();

            // update GUI before moving on
            this._bepInstallButton.Enabled = true;
            this._uninstallButton.Enabled  = true;
            MefinoGUI.SetProgressBarActive(false);

            RefreshBepInExPanel();

            Application.DoEvents();

            if (BepInExHandler.s_lastInstallStateResult != InstallState.Installed)
            {
                MessageBox.Show($"Failed to update BepInEx! Make sure Outward isn't running and you're online.", "Warning", MessageBoxButtons.OK);
            }
            else
            {
                ProfileManager.LoadProfiles(false);
            }
        }
コード例 #2
0
        internal void RefreshBepInExPanel()
        {
            if (!Folders.IsCurrentOutwardPathValid())
            {
                this._bepPanel.Visible        = false;
                this._uninstallButton.Visible = false;
                MefinoGUI.DisableFeaturePages();
                return;
            }

            this._bepPanel.Visible = true;

            if (BepInExHandler.IsBepInExUpdated())
            {
                this._bepStatus.Text           = "Installed";
                this._bepStatus.ForeColor      = Color.LightGreen;
                this._bepInstallButton.Visible = false;

                LocalPackageManager.RefreshInstalledPackages();

                MefinoGUI.EnabledFeaturePages();
                Folders.CheckOutwardMefinoInstall();

                this._uninstallButton.Visible = true;
            }
            else
            {
                this._uninstallButton.Visible = false;
                MefinoGUI.DisableFeaturePages();

                switch (BepInExHandler.s_lastInstallStateResult)
                {
                case InstallState.Outdated:
                    this._bepStatus.Text           = $"Outdated";
                    this._bepStatus.ForeColor      = Color.DarkKhaki;
                    this._bepInstallButton.Visible = true;
                    this._bepInstallButton.Text    = $"Update to {BepInExHandler.s_latestBepInExVersion}";
                    break;

                case InstallState.NotInstalled:
                    this._bepStatus.Text           = "Not installed";
                    this._bepStatus.ForeColor      = Color.IndianRed;
                    this._bepInstallButton.Visible = true;
                    this._bepInstallButton.Text    = $"Install BepInEx {BepInExHandler.s_latestBepInExVersion}";
                    break;
                }
            }
        }
コード例 #3
0
        /// <summary>
        /// Attempt to update BepInEx to the latest version.
        /// </summary>
        public static void UpdateBepInEx()
        {
            if (!Folders.IsCurrentOutwardPathValid())
            {
                Console.WriteLine("Current Outward folder path not set or invalid! Cannot update BepInEx.");
                return;
            }

            // If an update check hasn't been done this launch, do one now.
            if (IsBepInExUpdated())
            {
                return;
            }

            // If the check we just did failed (no query result), we need to abort.
            if (string.IsNullOrEmpty(s_latestBepInExVersion))
            {
                return;
            }

            try
            {
                string releaseURL = $@"https://github.com/BepInEx/BepInEx/releases/latest/download/BepInEx_x64_{s_latestBepInExVersion}.zip";

                var tempFile = TemporaryFile.CreateFile();

                MefinoGUI.SetProgressMessage($"Downloading BepInEx {s_latestBepInExVersion}");

                WebClientManager.DownloadFileAsync(releaseURL, tempFile);

                while (WebClientManager.IsBusy)
                {
                    MefinoApp.SendAsyncProgress(WebClientManager.LastDownloadProgress);
                }

                MefinoGUI.SetProgressMessage($"Extracting BepInEx {s_latestBepInExVersion}");

                ZipHelper.ExtractZip(tempFile, Folders.OUTWARD_FOLDER);

                Console.WriteLine("Updated BepInEx to version '" + s_latestBepInExVersion + "'");
            }
            catch (Exception ex)
            {
                Console.WriteLine("Exception downloading and installing BepInEx!");
                Console.WriteLine(ex);
            }
        }
コード例 #4
0
        internal void SetOtwPathResult(InstallState state)
        {
            switch (state)
            {
            // 'Outdated' is used to indicate its il2cpp in this context.
            case InstallState.Outdated:
                this._otwPathStatus.Text      = $"IL2CPP install detected!";
                this._otwPathStatus.ForeColor = Color.IndianRed;

                var result = MessageBox.Show($"This is an IL2CPP (main branch) install! Do you want to open the guide for swapping to Mono?",
                                             "IL2CPP Install detected",
                                             MessageBoxButtons.YesNo);

                if (result == DialogResult.Yes)
                {
                    Process.Start($"https://outward.gamepedia.com/Installing_Mods#Modding_Branch");
                }

                this._uninstallButton.Visible = false;
                MefinoGUI.DisableFeaturePages();
                break;

            case InstallState.NotInstalled:
                this._otwPathStatus.Text      = $"Not found / invalid path";
                this._otwPathStatus.ForeColor = Color.DarkKhaki;
                this._uninstallButton.Visible = false;
                MefinoGUI.DisableFeaturePages();
                break;

            case InstallState.Installed:
                this._otwPathStatus.Text      = $"Found Mono install";
                this._otwPathStatus.ForeColor = Color.LightGreen;

                Application.DoEvents();

                RefreshBepInExPanel();

                break;
            }
        }
コード例 #5
0
        /// <summary>
        /// Actually download and install the provided PackageManifest instance, which would presumably be a web manifest.
        /// </summary>
        /// <param name="manifest">The PackageManifest to install.</param>
        /// <returns><see langword="true"/> if successful, otherwise <see langword="false"/></returns>
        internal static bool DownloadAndInstallPackage(PackageManifest manifest)
        {
            try
            {
                MefinoGUI.SetProgressBarActive(true);

                MefinoGUI.DisableSensitiveControls();

                var dirPath = $@"{Folders.MEFINO_DISABLED_FOLDER}\{manifest.GUID}";

                if (Directory.Exists(dirPath))
                {
                    Directory.Delete(dirPath, true);
                }

                var tempFile = TemporaryFile.CreateFile();

                var zipUrl = $"{manifest.GithubURL}/releases/latest/download/{manifest.DownloadFileName}";

                Web.WebClientManager.DownloadFileAsync(zipUrl, tempFile);

                while (Web.WebClientManager.IsBusy)
                {
                    Thread.Sleep(20);
                    MefinoApp.SendAsyncProgress(Web.WebClientManager.LastDownloadProgress);
                }

                MefinoGUI.SetProgressMessage($"Installing '{manifest.GUID}' (version {manifest.version})");

                if (ZipHelper.ExtractZip(tempFile, dirPath))
                {
                    var manifestPath = $@"{dirPath}\mefino-manifest.json";

                    if (File.Exists(manifestPath))
                    {
                        File.Delete(manifestPath);
                    }

                    File.WriteAllText(manifestPath, manifest.ToJsonObject().ToString(true));

                    //Console.WriteLine($"Installed package: {manifest.GUID} {manifest.version}");

                    MefinoGUI.SetProgressBarActive(false);

                    MefinoGUI.ReEnableSensitiveControls();

                    return(true);
                }
                else
                {
                    throw new Exception("Zip extraction failed!");
                }
            }
            catch (Exception ex)
            {
                MefinoGUI.SetProgressBarActive(false);
                MefinoGUI.ReEnableSensitiveControls();

                Console.WriteLine("Exception isntalling package '" + manifest.GUID + "'");
                Console.WriteLine($"{ex.GetType()}: {ex.Message}");
                //Mefino.SendAsyncCompletion(false);
                return(false);
            }
        }
コード例 #6
0
        /// <summary>
        /// Attempt to install a GUID from a GitHub web package, if such a package can be found.
        /// </summary>
        /// <param name="guid">The guid to try to install.</param>
        /// <param name="andEnable">Should the package be enabled after installing? Otherwise it will be disabled.</param>
        /// <returns><see langword="true"/> if successful, otherwise <see langword="false"/></returns>
        public static bool TryInstallWebPackage(string guid, bool andEnable = true)
        {
            if (OutwardHelper.IsOutwardRunning())
            {
                MessageBox.Show("You need to close Outward to do that.");
                return(false);
            }

            if (!Folders.IsCurrentOutwardPathValid())
            {
                Console.WriteLine("Outward folder is not set! Cannot install package.");
                return(false);
            }

            WebManifestManager.s_webManifests.TryGetValue(guid, out PackageManifest webManifest);

            if (webManifest == null)
            {
                if (!string.IsNullOrEmpty(guid) && TryGetInstalledPackage(guid) != null)
                {
                    Console.WriteLine("Could not find online package by GUID '" + guid + ", but an installed package exists with that GUID, enabling.");
                    TryEnablePackage(guid);
                    return(true);
                }

                Console.WriteLine("Could not find web package by GUID '" + guid + "'");
                return(false);
            }

            var existing = TryGetInstalledPackage(guid);

            if (existing != null && existing.CompareVersionAgainst(webManifest) != InstallState.Outdated)
            {
                //Console.WriteLine("Installed package is already greater or equal version, skipping install.");

                if (existing.IsDisabled)
                {
                    return(TryEnablePackage(guid));
                }

                return(true);
            }

            if (webManifest.dependencies != null && webManifest.dependencies.Length > 0)
            {
                int i     = 1;
                int count = webManifest.dependencies.Length;
                foreach (var dependency in webManifest.dependencies)
                {
                    MefinoGUI.SetProgressMessage($"Downloading dependency {i} of {count}: {dependency}");

                    if (!TryInstallWebPackage(dependency))
                    {
                        var msgResult = MessageBox.Show("Installing dependency '" + dependency + "' failed!\n\nContinue anyway?", "Dependency failed!", MessageBoxButtons.OKCancel);
                        if (msgResult == DialogResult.OK)
                        {
                            continue;
                        }
                        else
                        {
                            return(false);
                        }
                    }

                    i++;
                }
            }

            // check that the package itself wasn't one of the dependencies.
            existing = TryGetInstalledPackage(guid);
            if (existing != null && existing.CompareVersionAgainst(webManifest) != InstallState.Outdated)
            {
                return(true);
            }

            MefinoGUI.SetProgressMessage($"Downloading package '{webManifest.GUID}'");
            MefinoApp.SendAsyncProgress(0);

            if (!DownloadAndInstallPackage(webManifest))
            {
                MessageBox.Show("Failed to download and install " + guid + "!");
                RefreshInstalledPackages();
                return(false);
            }

            RefreshInstalledPackages();

            OnPackageInstalled?.Invoke(webManifest);

            if (andEnable)
            {
                return(TryEnablePackage(guid));
            }
            else
            {
                return(true);
            }
        }
コード例 #7
0
 /// <summary>
 /// Send generic Async progress percentage.
 /// </summary>
 internal static void SendAsyncProgress(int progress)
 {
     MefinoGUI.SetProgressPercent(progress);
     // let UI actually refresh for the progress.
     Application.DoEvents();
 }