private void Form1_Load(object sender, EventArgs e) { launcherTitleLabel.Text = this.Text; ThemeLauncher(); if (isDebug == true) { MessageBox.Show("Debug mode"); } else { // Check for updates updateChecker.checkForUpdate(this); if (updateChecker.errorWhileChecking == true) { notifyUser.Notify(this, "Could not check for updates!", "An unexpected error occurred while checking for updates. Golden Ticket will not be able to notify you of new updates." + Environment.NewLine + Environment.NewLine + "Below is the error. Please screenshot this message box and report it to the developer by creating a new Issue on GitHub." + Environment.NewLine + Environment.NewLine + updateChecker.exForReporting, MessageBoxIcon.Warning, MessageBoxButtons.OK); } // If there wasn't an update, we can start. // Do all our shit in a BackgroundWorker so we don't freeze the UI launchButton.Enabled = false; LauncherStartup.RunWorkerAsync(); } }
void StartupStep5() { // FIXME: This somehow broke after themeing. All of this will run but it isn't passed // to the patching window for some reason. Currently all below code has been modified // and moved to the patching window itself to 'fix' it for now. /* * This is going to get a little hectic... * * Things which need to be done here (in order) * - We need to determine the user's OS. Is it Vista/7? Or is it Windows 8(.1)/10? * - We need to download the correct patch to our Golden Ticket 'Downloads' folder * -- FIXME: We should verify the MD5 of the zip before trying to use it * - Unzip all files to the Golden Ticket 'Temp' folder * -- FIXME: We should verify the MD5 of all individual files before trying to use them * - Place all files from our 'Temp' directory in the game installation directory */ string winVer = machineInfo.WindowsVersion(); if (winVer.Contains("Windows Vista") || winVer.Contains("Windows 7")) { // Patch for Vista/7 PatchingWindowBottom patchingWindowBottom = new PatchingWindowBottom(); PatchingWindow patchingWindow = new PatchingWindow(); patchingWindow.patchToDownload = 1; patchingWindowBottom.ShowDialog(this); return; // ShowDialog has closed. We're done. } if (winVer.Contains("Windows 8") || winVer.Contains("Windows 8.1") || winVer.Contains("Windows 10")) { // Patch for 8/8.1/10 PatchingWindowBottom patchingWindowBottom = new PatchingWindowBottom(); PatchingWindow patchingWindow = new PatchingWindow(); patchingWindow.patchToDownload = 2; patchingWindowBottom.ShowDialog(this); return; // ShowDialog has closed. We're done. } // Just in case there's some freak accident where this doesn't return ANY of our expected Windows versions, let's flip out! if (!winVer.Contains("Windows Vista") & !winVer.Contains("Windows 7") & !winVer.Contains("Windows 8") & !winVer.Contains("Windows 8.1") & !winVer.Contains("Windows 10")) { // Set error code to 3 and stop the launcher errorCode = 3; LauncherStartup.CancelAsync(); } }
private void LauncherStartup_DoWork(object sender, DoWorkEventArgs e) { for (int i = 0; i < 100; i++) // The code needs to go in here so that we can get progress reports { CleanupTempFolder(); // Let's clean the temp folder like we should StartupStep1(); // Begin step 1 LauncherStartup.ReportProgress(i); // Report progress if (LauncherStartup.CancellationPending) { e.Cancel = true; return; } // Check if we need to cancel StartupStep2(); // Begin step 2 LauncherStartup.ReportProgress(i); // Report progress if (LauncherStartup.CancellationPending) { e.Cancel = true; return; } // Check if we need to cancel StartupStep3(); // Begin step 3 LauncherStartup.ReportProgress(i); // Report progress if (LauncherStartup.CancellationPending) { e.Cancel = true; return; } // Check if we need to cancel StartupStep4(); LauncherStartup.ReportProgress(i); // Report progress if (LauncherStartup.CancellationPending) { e.Cancel = true; return; } // Check if we need to cancel if (needsPatching == true) { // We need to patch. Let's go run step 5. LauncherStartup.ReportProgress(i); StartupStep5(); // We need to patch. Go to step 5. LauncherStartup.ReportProgress(i); } else { // Launcher doesn't need patching. We're finished. LauncherStartup.ReportProgress(i); } } // Launcher startup has finished LauncherStartup.ReportProgress(100); }
void StartupStep2() { // We need to make changes to allow us to modify the game folder without admin rights... // But before doing so, let's try to create a file in the game directory. If it gets // an UnauthorizedAccess exception, then we'll run PermissionFix. bool dirPermsCorrect = pathUtils.InstallDirPermissionsAreCorrect(); if (dirPermsCorrect == false) { // Permissions aren't correct. We need to tell the user and let him/her choose if they want us to fix that. DialogResult userAnswer; userAnswer = MessageBox.Show(this, "It appears that Golden Ticket does not have the necessary permissions to make" + " changes to the game. We can fix this by using our open source tool 'PermissionFix'." + Environment.NewLine + Environment.NewLine + "Clicking 'Yes' will allow us to make" + " these changes. A UAC request will popup afterwards. Please select 'Yes' on it." + Environment.NewLine + Environment.NewLine + "Clicking 'No' below will not allow the" + " launcher to continue in it's attempt to make the game compatible!", "Cannot make changes to the game!", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (userAnswer == DialogResult.No) { // User declined to run PermissionFix errorCode = 2; LauncherStartup.CancelAsync(); } else { // User said yes to running PermissionFix! Process process = Process.Start(Application.StartupPath + "\\PermissionFix.exe"); while (!process.HasExited) { // Sleep for 1/4th a second and wait for PermissionFix to run... Thread.Sleep(250); } return; // PermissionFix ran! } } return; // End of step 2! }
void StartupStep1() { // Step 1: Check install directory! // Get install location for the game gameDirectory = gameInfo.GetInstallLocationFromReg(); // Get location the launcher is running from launcherDirectory = pathUtils.GetLauncherDir(); // Compare the two // Fix Issue #6 -- Launcher is sad if the game directory and reg location have mismatch case. // Instead of using a straight 'if (string != string)', use 'string.Equals' so that we can ignore case. if (!launcherDirectory.Equals(gameDirectory, StringComparison.OrdinalIgnoreCase)) { // Launcher isn't running in the game directory. Freak out! errorCode = 1; LauncherStartup.CancelAsync(); } return; // We're good, step 2 please! }