public WebPatchSource(RXPatcher patcher, string downloadPath) { Patcher = patcher; DownloadPath = downloadPath; }
public void StartupApp(object sender, StartupEventArgs e) { //Determine if the permissionChange is succesfull after launcher update bool isGoodUpdate = false; bool isLogging = false; Logger.Instance.Write("Application starting up..."); foreach (string a in e.Args) { if (a.Equals("--log", StringComparison.OrdinalIgnoreCase)) { Logger.Instance.StartLogConsole(); isLogging = true; } if (a.StartsWith("--patch-result=")) { string code = a.Substring("--patch-result=".Length); Logger.Instance.Write($"Startup Parameter 'patch-result' found - contents: {code}"); //If the code !=0 -> there is something wrong with the patching of the launcher if (code != "0") { MessageBox.Show(string.Format("Failed to update the launcher (code {0}).\n\nPlease close any applications related to Renegade-X and try again.", code), "Patch failed", MessageBoxButton.OK, MessageBoxImage.Error); } else//Otherwise -> change folderpermissions and afterwards launch the launcher { try { SetFullControlPermissionsToEveryone(GameInstallation.GetRootPath()); isGoodUpdate = true; //Set isGoodUpdate to true to indicate correct permissionChange } catch (Exception ex) { MessageBox.Show(ex.Message); } } } else if (a.StartsWith("--firstInstall")) //Init the first install { Logger.Instance.Write("Startup parameters 'firstInstall' found - Starting RenX Installer"); Installer x = new Installer(); x.Show(); x.FirstInstall(); return; } else if (a.StartsWith("--UpdateGame="))//Manually opdate the game to a given URL. { // Close any other instances of the RenX-Launcher if (InstanceHandler.IsAnotherInstanceRunning()) { InstanceHandler.KillDuplicateInstance(); } var targetDir = GameInstallation.GetRootPath(); var applicationDir = System.IO.Path.Combine(GameInstallation.GetRootPath(), "patch"); String[] patchUrls = new string[1]; patchUrls[0] = a.Substring("--UpdateGame=".Length); var patchVersion = VersionCheck.GetLatestGameVersionName(); var progress = new Progress <DirectoryPatcherProgressReport>(); var cancellationTokenSource = new System.Threading.CancellationTokenSource(); System.Threading.Tasks.Task task = new RXPatchLib.RXPatcher().ApplyPatchFromWeb(patchUrls, targetDir, applicationDir, progress, cancellationTokenSource.Token); var window = new Views.ApplyUpdateWindow(task, progress, patchVersion, cancellationTokenSource, Views.ApplyUpdateWindow.UpdateWindowType.Update); window.ShowDialog(); VersionCheck.UpdateGameVersion(); return; } } if (LauncherTwo.Properties.Settings.Default.UpgradeRequired) { LauncherTwo.Properties.Settings.Default.Upgrade(); LauncherTwo.Properties.Settings.Default.UpgradeRequired = false; LauncherTwo.Properties.Settings.Default.Save(); } /* Commented out untill I found a better way to intergrate it in the installation * if (!GameInstallation.IsRootPathPlausible()) * { * var result = MessageBox.Show("The game path seems to be incorrect. Please ensure that the launcher is placed in the correct location. If you proceed, files in the following location might be affected:\n\n" + GameInstallation.GetRootPath() + "\n\nAre you sure want to proceed?", "Invalid game path", MessageBoxButton.YesNo, MessageBoxImage.Warning, MessageBoxResult.No); * if (result != MessageBoxResult.Yes) * { * Shutdown(); * return; * } * } */ //If no args are present, or a permissionChange update was executed -> normally start the launcher if (e.Args.Length == 0 || isGoodUpdate || isLogging) { if (InstanceHandler.IsAnotherInstanceRunning() && !isGoodUpdate) { MessageBox.Show("Error:\nUnable to start Renegade-X Launcher: Another instance is already running!", "Renegade-X Launcher", MessageBoxButton.OK, MessageBoxImage.Error, MessageBoxResult.OK); Current.Shutdown(); } Logger.Instance.Write("Initial application startup complete, Creating new MainWindow"); new MainWindow().Show(); } else { Application.Current.Shutdown(); } }