Ejemplo n.º 1
0
 /// <summary>
 /// Sets the current game version text.
 /// </summary>
 /// <param name="v">Version to set.</param>
 public void SetGameVersion(VersionGameFiles v)
 {
     if (v is null)
     {
         throw new ArgumentNullException(nameof(v));
     }
     if (GameVersionLabel.InvokeRequired)
     {
         SGV d = SetGameVersion;
         Invoke(d, new object[] { v });
     }
     else
     {
         GameVersionLabel.Text = "Build: " + v.ToString();
     }
 }
Ejemplo n.º 2
0
        private bool PatchDownload(IDownloadable download, string destination)
        {
            try {
                if (download is VersionGameFiles)
                {
                    VersionGameFiles vgf = download as VersionGameFiles;
                    if (vgf.IsPatch)
                    {
                        UpdateProgressText("Patching...");
                        string versionpath = Path.Combine(Config.InstallPath, "Versions", download.Prerequisite.ToString());
                        RecursiveCopy(versionpath, destination, false);
                    }
                }
                else if (download is VersionAudio)
                {
                    VersionAudio va          = download as VersionAudio;
                    string       versionpath = Path.Combine(Config.InstallPath, "Versions", mostRecent.ToString());
                    RecursiveCopy(destination, versionpath, true);
                }
            } catch (DirectoryNotFoundException) {
                MessageBox.Show(
                    $"Could not find download{Environment.NewLine}{destination}{Environment.NewLine}The file appears to be missing. It may have been quarantined by your antivirus software. Please check your antivirus settings and retry. If the issue persists, please report this error.",
                    "Apex Launcher Error",
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Warning);
                return(false);
            }

            if (download == mostRecent && !(download is VersionAudio))
            {
                bool downloadingNewAudio = false;
                foreach (IDownloadable d in downloadQueue)
                {
                    if (d is VersionAudio)
                    {
                        downloadingNewAudio = true;
                        break;
                    }
                }

                if (!downloadingNewAudio)
                {
                    string versionpath      = Path.Combine(Config.InstallPath, "Versions", mostRecent.ToString());
                    string audioversionpath = Path.Combine(Config.InstallPath, "Versions", VersionAudio.GetMostRecentVersion().ToString());
                    RecursiveCopy(audioversionpath, versionpath, true);
                }
            }

            try {
                File.Delete(currentFilepath);
            } catch (IOException e) {
                MessageBox.Show($"Error encountered when trying to delete {currentFilepath} after patching. You may need to delete the file manually, but the program should otherwise work correctly. Details:{Environment.NewLine}{e.Message}");
            }

            return(true);
        }
Ejemplo n.º 3
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();
                }
            }
        }