Ejemplo n.º 1
0
        /// <summary>
        /// Check for and download the latest version of the game files.
        /// </summary>
        /// <returns>True if a download was made.</returns>
        public static bool InstallLatestVersion()
        {
            Launcher.UpdateStatus("Checking for new versions...");

            VersionGameFiles mostRecent = VersionGameFiles.GetMostRecentVersion();

            if (mostRecent != null && mostRecent.GreaterThan(Config.CurrentVersion))
            {
                DialogResult result = MessageBox.Show($"New version found: {mostRecent.Channel} {mostRecent.Number}\nDownload and install this update?", "Update Found", MessageBoxButtons.YesNo);

                if (result == DialogResult.Yes)
                {
                    DownloadVersion(mostRecent);
                    return(true);
                }
            }

            VersionAudio mostRecentAudio = VersionAudio.GetMostRecentVersion();

            if (!Config.DisableAudioDownload && mostRecentAudio.GreaterThan(Config.CurrentAudioVersion))
            {
                DialogResult result = MessageBox.Show($"New audio version found: {mostRecentAudio}.\nDownload and install this update?\n(Note, audio updates are often large downloads)", "Audio Update Found", MessageBoxButtons.YesNo);
                if (result == DialogResult.Yes)
                {
                    DownloadVersion(mostRecentAudio);
                }
            }

            Launcher.UpdateStatus("No new version found.");
            return(false);
        }
Ejemplo n.º 2
0
        private void LaunchButton_Click(object sender, EventArgs e)
        {
            if (Program.Downloading)
            {
                MessageBox.Show("A download is currently in progress. Please cancel your download or wait until it finishes.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            VersionGameFiles currentVersion = Config.CurrentVersion;

            if (currentVersion is null)
            {
                if (MessageBox.Show("No installed version found. Would you like to download now?", "No Version Found", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) != DialogResult.Yes)
                {
                    return;
                }

                Program.InstallLatestVersion();
                return;
            }

            string launchpath = Path.Combine(Config.InstallPath, "Versions", currentVersion.ToString(), "Game.exe");

            if (Program.ForceUpdate)
            {
                string path = Path.Combine(Config.InstallPath, "Versions", currentVersion.ToString());
                if (File.Exists(path + ".zip"))
                {
                    File.Delete(path + ".zip");
                }
                if (Directory.Exists(path))
                {
                    Directory.Delete(path, true);
                }
                if (currentVersion.IsPatch)
                {
                    string previousPath = Path.Combine(Config.InstallPath, "Versions", currentVersion.Prerequisite.ToString());
                    if (File.Exists(previousPath + ".zip"))
                    {
                        File.Delete(previousPath + ".zip");
                    }
                    if (Directory.Exists(previousPath))
                    {
                        Directory.Delete(previousPath, true);
                    }
                    Config.CurrentVersion = VersionGameFiles.FromString("ALPHA 0.0");
                }

                Program.DownloadVersion(VersionGameFiles.GetMostRecentVersion());
                Program.ForceUpdate = false;
            }
            else if (!File.Exists(launchpath))
            {
                DialogResult res = MessageBox.Show(
                    $"Cannot find the game in your install path. It might be moved or deleted.\nCheck \n{launchpath}\nfor your files, or redownload them.\nWould you like to redownload?",
                    "Game not found",
                    MessageBoxButtons.YesNo);
                if (res == DialogResult.Yes)
                {
                    Program.InstallLatestVersion();
                }
                else
                {
                    return;
                }
            }

            if (File.Exists(launchpath))
            {
                Process.Start(launchpath);
                if (!Config.KeepLauncherOpen)
                {
                    Close();
                }
            }
        }