Example #1
0
        public async Task <bool> DownloadRedist(string source, string target, CancellationToken cancelToken, Action <long, long> progressCallback)
        {
            // Initialize directory and WebClient
            System.IO.Directory.CreateDirectory(GameInstallation.GetRootPath() + "Launcher\\Redist");
            System.Net.WebClient redistRequest = new WebClient();

            // Report progress
            redistRequest.DownloadProgressChanged += (o, args) =>
            {
                // Listen for cancellation
                if (cancelToken.IsCancellationRequested)
                {
                    redistRequest.CancelAsync();
                }

                // Update progress
                progressCallback(args.BytesReceived, args.TotalBytesToReceive);
            };

            // Download file
            await redistRequest.DownloadFileTaskAsync(new Uri(source), target);

            // Verify (UE3Redist isn't expected to ever change, so we're just dumping the hash here).
            return(await RXPatchLib.Sha256.GetFileHashAsync(target) == "A1A49F3C2E6830BAE084259650DFADF3AD97A30F59391930639D59220CC0B01F");
        }
Example #2
0
        public string GetProcessPath()
        {
            if (Use64Bit && File.Exists(GameInstallation.GetRootPath() + "Binaries\\Win64\\UDK.exe"))
            {
                return(GameInstallation.GetRootPath() + "Binaries\\Win64\\UDK.exe");
            }

            return(GameInstallation.GetRootPath() + "Binaries\\Win32\\UDK.exe");
        }
Example #3
0
        public static void UpdateGameVersion()
        {
            const string INI_PATH              = "\\UDKGame\\Config\\DefaultRenegadeX.ini";
            const string VERSION_PREFIX        = "GameVersion=";
            const string VERSION_NUMBER_PREFIX = "GameVersionNumber=";

            try
            {
                string versionName   = null;
                int?   versionNumber = null;
                string filename      = GameInstallation.GetRootPath() + INI_PATH;
                foreach (var line in File.ReadAllLines(filename))
                {
                    if (line.StartsWith(VERSION_PREFIX))
                    {
                        versionName = line
                                      .Replace(VERSION_PREFIX, "")
                                      .Replace("\"", "");
                    }
                    else if (line.StartsWith(VERSION_NUMBER_PREFIX))
                    {
                        versionNumber = int.Parse(line
                                                  .Replace(VERSION_NUMBER_PREFIX, "")
                                                  .Replace("\"", ""));
                    }
                }

                if (versionName == "Open Beta 2" ||
                    versionName == "Open Beta 3")
                {
                    versionNumber = 0;
                }

                if (versionName == null)
                {
                    throw new Exception("No version number found.");
                }
                if (versionNumber == null)
                {
                    throw new Exception("No version number found.");
                }
                GameVersion = new Version
                {
                    Name   = versionName,
                    Number = versionNumber.Value,
                };
            }
            catch
            {
                GameVersion = new Version
                {
                    Name   = "Unknown",
                    Number = 0,
                };
            }
        }
Example #4
0
        void ShowGameUpdateWindow(out bool wasUpdated)
        {
            RxLogger.Logger.Instance.Write("Showing game update window");
            UpdateAvailableWindow theWindow = new UpdateAvailableWindow();

            theWindow.LatestVersionText.Content = VersionCheck.GetLatestGameVersionName();
            theWindow.GameVersionText.Content   = VersionCheck.GetGameVersionName();
            theWindow.WindowTitle.Content       = "Game update available!";
            theWindow.Owner = this;
            theWindow.ShowDialog();

            if (!theWindow.WantsToUpdate)
            {
                wasUpdated = false;
            }
            else
            {
                //Get the previous vid that plays and store it. Nullify the playing vid so no handle is open
                Uri previousVid = sv_MapPreviewVid.Source;
                sv_MapPreviewVid.Source = null;

                // Close any other instances of the RenX-Launcher
                if (InstanceHandler.IsAnotherInstanceRunning())
                {
                    InstanceHandler.KillDuplicateInstance();
                }

                var targetDir      = GameInstallation.GetRootPath();
                var applicationDir = Path.Combine(GameInstallation.GetRootPath(), "patch");
                var patchPath      = VersionCheck.GamePatchPath;
                var patchUrls      = VersionCheck.GamePatchUrls;
                var patchVersion   = VersionCheck.GetLatestGameVersionName();

                var progress = new Progress <DirectoryPatcherProgressReport>();
                var cancellationTokenSource = new CancellationTokenSource();

                RxLogger.Logger.Instance.Write($"Starting game update | TargetDir: {targetDir} | AppDir: {applicationDir} | PatchPath: {patchPath},| PatchVersion: {patchVersion}");
                Task task = RxPatcher.Instance.ApplyPatchFromWeb(patchPath, targetDir, applicationDir, progress, cancellationTokenSource.Token, VersionCheck.InstructionsHash);

                RxLogger.Logger.Instance.Write("Download complete, Showing ApplyUpdateWindow");
                var window = new ApplyUpdateWindow(task, RxPatcher.Instance, progress, patchVersion, cancellationTokenSource, ApplyUpdateWindow.UpdateWindowType.Update);
                window.Owner = this;
                window.ShowDialog();

                VersionCheck.UpdateGameVersion();
                wasUpdated = true;

                //Resume playback of vid
                sv_MapPreviewVid.Source = previousVid;
                sv_MapPreviewVid.Play();

                // Refresh server list
                StartRefreshingServers();
            }
        }
Example #5
0
 public override string GetProcessPath()
 {
     if (Use64bit)
     {
         return(GameInstallation.GetRootPath() + "Binaries\\Win64\\UDK.exe");
     }
     else
     {
         return(GameInstallation.GetRootPath() + "Binaries\\Win32\\UDK.exe");
     }
 }
Example #6
0
        void ShowGameUpdateWindow(out bool wasUpdated)
        {
            UpdateAvailableWindow theWindow = new UpdateAvailableWindow();

            theWindow.LatestVersionText.Content = VersionCheck.GetLatestGameVersionName();
            theWindow.GameVersionText.Content   = VersionCheck.GetGameVersionName();
            theWindow.WindowTitle.Content       = "Game update available!";
            theWindow.Owner = this;
            theWindow.ShowDialog();

            if (!theWindow.WantsToUpdate)
            {
                wasUpdated = false;
            }
            else
            {
                // Close any other instances of the RenX-Launcher
                if (InstanceHandler.IsAnotherInstanceRunning())
                {
                    InstanceHandler.KillDuplicateInstance();
                }

                var targetDir      = GameInstallation.GetRootPath();
                var applicationDir = Path.Combine(GameInstallation.GetRootPath(), "patch");
                var patchPath      = VersionCheck.GamePatchPath;
                var patchUrls      = VersionCheck.GamePatchUrls;
                var patchVersion   = VersionCheck.GetLatestGameVersionName();

                var progress = new Progress <DirectoryPatcherProgressReport>();
                var cancellationTokenSource = new CancellationTokenSource();

                var  patcher = new RXPatcher();
                Task task    = patcher.ApplyPatchFromWeb(patchUrls.Select(url => url.ServerUri.AbsoluteUri).ToArray(), patchPath, targetDir, applicationDir, progress, cancellationTokenSource.Token, VersionCheck.InstructionsHash);

                var window = new ApplyUpdateWindow(task, patcher, progress, patchVersion, cancellationTokenSource, ApplyUpdateWindow.UpdateWindowType.Update);
                window.Owner = this;
                window.ShowDialog();

                VersionCheck.UpdateGameVersion();
                wasUpdated = true;
            }
        }
Example #7
0
 public virtual string GetProcessPath()
 {
     return(GameInstallation.GetRootPath() + "Binaries\\UDKLift.exe");
 }
Example #8
0
        /// <summary>
        /// Function to control the first launch install.
        /// </summary>
        public async void FirstInstall()
        {
            VersionCheck.GetLatestGameVersionName();
            await VersionCheck.UpdateLatestVersions();

            //Get the current root path and prepare the installation
            var targetDir      = GameInstallation.GetRootPath();
            var applicationDir = System.IO.Path.Combine(GameInstallation.GetRootPath(), "patch");
            var patchPath      = VersionCheck.GamePatchPath;
            var patchVersion   = VersionCheck.GetLatestGameVersionName();

            //Create an empty var containing the progress report from the patcher
            var progress = new Progress <DirectoryPatcherProgressReport>();
            var cancellationTokenSource = new System.Threading.CancellationTokenSource();

            Task task = RxPatcher.Instance.ApplyPatchFromWeb(patchPath, targetDir, applicationDir, progress,
                                                             cancellationTokenSource.Token, VersionCheck.InstructionsHash);

            //Create the update window
            var window = new ApplyUpdateWindow(task, RxPatcher.Instance, progress, patchVersion,
                                               cancellationTokenSource, ApplyUpdateWindow.UpdateWindowType.Install);

            window.Owner = this;
            //Show the dialog and wait for completion
            window.Show();

            while (!task.IsCompleted)
            {
                await Task.Delay(1000);

                if (cancellationTokenSource.IsCancellationRequested)
                {
                    task.Dispose();
                }
            }

            RxLogger.Logger.Instance.Write($"Install complete, task state isCompleted = {task.IsCompleted}");

            if (task?.IsCompleted == true && task?.Status != TaskStatus.Canceled)
            {
                VersionCheck.UpdateGameVersion();
                //Create the UE3 redist dialog

                RxLogger.Logger.Instance.Write("Creating the UE3 Redist package dialog");
                ModernDialog ueRedistDialog = new ModernDialog();
                ueRedistDialog.Title   = "UE3 Redistributable";
                ueRedistDialog.Content = MessageRedistInstall;
                ueRedistDialog.Buttons = new Button[] { ueRedistDialog.OkButton, ueRedistDialog.CancelButton };
                ueRedistDialog.ShowDialog();

                RxLogger.Logger.Instance.Write($"Did the user want to install the UE3 Redist? - {ueRedistDialog.DialogResult.Value}");

                if (ueRedistDialog.DialogResult.Value == true)
                {
                    bool downloadSuccess = false;

                    var bestPatchServer = RxPatcher.Instance.UpdateServerHandler.SelectBestPatchServer();
                    Uri RedistServer    = bestPatchServer.Uri;

                    //Create new URL based on the patch url (Without the patch part)
                    String redistUrl  = RedistServer + "redists/UE3Redist.exe";
                    string systemPath = GameInstallation.GetRootPath() + "Launcher\\Redist\\UE3Redist.exe";

                    //Create canceltokens to stop the downloaderthread if neccesary
                    CancellationTokenSource downloaderTokenSource = new CancellationTokenSource();
                    CancellationToken       downloaderToken       = downloaderTokenSource.Token;

                    //Redist downloader statuswindow
                    GeneralDownloadWindow redistWindow = new GeneralDownloadWindow(downloaderTokenSource, "UE3Redist download");
                    redistWindow.Show();

                    //Start downloading redist
                    RxLogger.Logger.Instance.Write($"Downloading UE3 Redist from {RedistServer.AbsoluteUri}");
                    downloadSuccess = await DownloadRedist(redistUrl, systemPath, downloaderToken, (received, size) =>
                    {
                        redistWindow.UpdateProgressBar(received, size);
                    });

                    RxLogger.Logger.Instance.Write("UE3 Redist Download Complete");

                    redistWindow.Close();

                    if (downloadSuccess)
                    {
                        //When done, execute the UE3Redist here
                        try
                        {
                            using (Process ue3Redist = Process.Start(systemPath))
                            {
                                ue3Redist.WaitForExit();
                                if (ue3Redist.ExitCode != 0)//If redist install fails, notify the user
                                {
                                    MessageBox.Show("Error while installing the UE3 Redist.");
                                }
                                else//Everything done! save installed flag and restart
                                {
                                    Properties.Settings.Default.Installed = true;
                                    Properties.Settings.Default.Save();
                                    try
                                    {
                                        System.IO.File.Delete(systemPath);
                                        System.IO.Directory.Delete(GameInstallation.GetRootPath() + "Launcher\\Redist\\");
                                    }
                                    catch (Exception)
                                    {
                                        MessageBox.Show("Could not cleanup the redist file. This won't hinder the game.");
                                    }
                                }
                            }
                        }
                        catch
                        {
                            MessageBox.Show("Error while executing the UE3 Redist.");
                        }
                        finally
                        {
                            //Restart launcher
                            System.Diagnostics.Process.Start(Application.ResourceAssembly.Location);
                            Application.Current.Shutdown();
                        }
                    }

                    if (downloadSuccess == false)
                    {
                        MessageBox.Show("Unable to download the UE3 Redist (corrupt download)");
                    }
                }
                else
                {
                    ModernDialog notInstalledDialog = new ModernDialog();
                    notInstalledDialog.Title   = "UE3 Redistributable";
                    notInstalledDialog.Content = MessageNotInstalled;
                    notInstalledDialog.Buttons = new Button[] { notInstalledDialog.OkButton };
                    notInstalledDialog.ShowDialog();
                    //Shutdown launcher
                    Application.Current.Shutdown();
                }
            }
            else
            {
                Application.Current.Shutdown();
            }
        }
Example #9
0
        public void StartupApp(object sender, StartupEventArgs e)
        {
            //Determine if the permissionChange is succesfull after launcher update
            bool didTryUpdate = false;
            bool isLogging    = false;

            Logger.Instance.Write("Application starting up; checking command line options...");

            foreach (string a in e.Args)
            {
                Logger.Instance.Write("Parsing option: " + a);
                if (a.Equals("--log", StringComparison.OrdinalIgnoreCase))
                {
                    Logger.Instance.StartLogConsole();
                    isLogging = true;
                }
                if (a.StartsWith("--patch-result="))
                {
                    didTryUpdate = true;
                    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" && code != "Success")
                    {
                        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());
                        }
                        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 update 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 patchUrl       = a.Substring("--UpdateGame=".Length);
                    var    patchVersion   = VersionCheck.GetLatestGameVersionName();

                    var progress = new Progress <DirectoryPatcherProgressReport>();
                    var cancellationTokenSource = new System.Threading.CancellationTokenSource();

                    RxPatcher.Instance.AddNewUpdateServer(patchUrl);
                    System.Threading.Tasks.Task task = RxPatcher.Instance.ApplyPatchFromWebDownloadTask(RXPatchLib.RxPatcher.Instance.GetNextUpdateServerEntry(), targetDir, applicationDir, progress, cancellationTokenSource.Token, null); // no verificaiton on instructions.json, as we're bypassing standard version checking

                    var window = new Views.ApplyUpdateWindow(task, RxPatcher.Instance, progress, patchVersion, cancellationTokenSource, Views.ApplyUpdateWindow.UpdateWindowType.Update);

                    window.ShowDialog();

                    VersionCheck.UpdateGameVersion();
                    return;
                }
                Logger.Instance.Write("Parsed option: " + a);
            }

            Logger.Instance.Write("Done checking command line options");

            if (LauncherTwo.Properties.Settings.Default.UpgradeRequired)
            {
                Logger.Instance.Write("Upgrading properties...");
                LauncherTwo.Properties.Settings.Default.Upgrade();
                LauncherTwo.Properties.Settings.Default.UpgradeRequired = false;
                LauncherTwo.Properties.Settings.Default.Save();
                Logger.Instance.Write("Properties upgraded");
            }

            //If no args are present, or a permissionChange update was executed -> normally start the launcher
            // didTryUpdate - If we tried an update, we have args, so we need to check this as well to make the main window load.
            if (e.Args.Length == 0 || didTryUpdate || isLogging)
            {
                if (InstanceHandler.IsAnotherInstanceRunning() && !didTryUpdate)
                {
                    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();
            }

            Logger.Instance.Write("Exiting StartupApp...");
        }
Example #10
0
        private void ServerInfoGrid_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (ServerInfoGrid.SelectedIndex >= OFilteredServerList.Count || ServerInfoGrid.SelectedIndex <= -1)
            {
                return;
            }

            ServerInfo selected = GetSelectedServer();

            //Original mappreview code
            //sv_MapPreview.Source = BitmapToImageSourceConverter.Convert(MapPreviewSettings.GetMapBitmap(selected.MapName));

            //Movie mappreview code
            if (File.Exists(GameInstallation.GetRootPath() + "\\PreviewVids\\" + selected.MapName + ".mp4"))
            {
                this.DefaultMoviePlays  = false;
                sv_MapPreviewVid.Source = new Uri(GameInstallation.GetRootPath() + "\\PreviewVids\\" + selected.MapName + ".mp4");
                sv_MapPreviewVid.Play();
            }
            else if (!this.DefaultMoviePlays)
            {
                sv_MapPreviewVid.Source = new Uri(GameInstallation.GetRootPath() + "\\PreviewVids\\Default.mp4");
                this.DefaultMoviePlays  = true;
                sv_MapPreviewVid.Play();
            }

            SD_ClanHeader.Source = BannerTools.GetBanner(selected.IPWithPort);
            SD_ClanHeader.Cursor = BannerTools.GetBannerLink(selected.IPWithPort) != "" ? Cursors.Hand : null;

            SD_Name.Content          = selected.ServerName;
            SD_GameLength.Content    = selected.TimeLimit.ToString();
            SD_MineLimit.Content     = selected.MineLimit.ToString();
            SD_GameMode.Content      = selected.MapMode.ToString();
            SD_PlayerLimit.Content   = selected.MaxPlayers.ToString();
            SD_ServerVersion.Content = selected.GameVersion;
            SD_VehicleLimit.Content  = selected.VehicleLimit;
            SD_CN.Content            = selected.CountryName;

            Rect r;

            ServerInfo.FlagCodes.TryGetValue(selected.CountryCode, out r);
            this.SD_CFI.Viewbox = r;

            Autobalance_Checkbx.Source  = GetChkBxImg(selected.AutoBalance);
            Steam_Checkbx.Source        = GetChkBxImg(selected.SteamRequired);
            Crates_Checkbx.Source       = GetChkBxImg(selected.SpawnCrates);
            InfantryOnly_Checkbx.Source = GetChkBxImg(selected.VehicleLimit <= 0);
            Ranked_Checkbx.Source       = GetChkBxImg(selected.Ranked);

            // Set version mismatch message visibility and join button opacity
            if (VersionCheck.GetGameVersionName() == selected.GameVersion)
            {
                version_mismatch = false;
                SD_VersionMismatch.Visibility           = Visibility.Hidden;
                this.Join_Server_Btn.Background.Opacity = 1.0;
                this.Join_Server_Btn.Content            = "Join Server";
            }
            else
            {
                version_mismatch = true;
                SD_VersionMismatch.Visibility           = Visibility.Visible;
                this.Join_Server_Btn.Background.Opacity = 0.5;
                this.Join_Server_Btn.Content            = "Server Version Mismatch";
            }

            System.Windows.Media.Animation.Storyboard sb = this.FindResource("JoinButtonGlow") as System.Windows.Media.Animation.Storyboard;
            System.Windows.Media.Animation.Storyboard.SetTarget(sb, this.Join_Server_Btn);
            sb.Begin();

            ServerInfoGrid.UpdateLayout();
        }
Example #11
0
        /// <summary>
        /// Function to control the first launch install.
        /// </summary>
        public async void FirstInstall()
        {
            VersionCheck.GetLatestGameVersionName();
            await VersionCheck.UpdateLatestVersions();

            //Get the current root path and prepare the installation
            var targetDir      = GameInstallation.GetRootPath();
            var applicationDir = System.IO.Path.Combine(GameInstallation.GetRootPath(), "patch");
            var patchUrls      = VersionCheck.GamePatchUrls;
            var patchVersion   = VersionCheck.GetLatestGameVersionName();

            //Create an empty var containing the progress report from the patcher
            var  progress = new Progress <DirectoryPatcherProgressReport>();
            var  cancellationTokenSource = new System.Threading.CancellationTokenSource();
            Task task = new RXPatcher().ApplyPatchFromWeb(patchUrls, targetDir, applicationDir, progress, cancellationTokenSource.Token);


            //Create the update window
            int index  = await new UpdateServerSelector().SelectHostIndex(patchUrls);
            var window = new ApplyUpdateWindow(task, progress, patchVersion, cancellationTokenSource, ApplyUpdateWindow.UpdateWindowType.Install, new Uri(patchUrls[index]).Host);

            //window.Owner = this;
            //Show the dialog and wait for completion
            window.ShowDialog();

            if (task.IsCompleted == true)
            {
                VersionCheck.UpdateGameVersion();
                //Create the UE3 redist dialog

                if (UERedistDialog.DialogResult.Value == true)
                {
                    //Determine which server has best ping
                    String[] PatchUrls = VersionCheck.GamePatchUrls;
                    RXPatchLib.UpdateServerSelector Selector = new RXPatchLib.UpdateServerSelector(); //Need to solve a import issue regarding duplicate classes
                    Task <int> SelectorTask = Selector.SelectHostIndex(VersionCheck.GamePatchUrls);   //NEed to suppress the ui from showing here
                    await      SelectorTask;
                    Uri        Redistserver = new Uri(PatchUrls[SelectorTask.Result]);
                    //Create new URL based on the patch url (Without the patch part)
                    String RedistUrl = "http://" + Redistserver.Host + "/redists/UE3Redist.exe";
                    string SystemUrl = GameInstallation.GetRootPath() + "Launcher\\Redist\\UE3Redist.exe";

                    //Create canceltokens to stop the downloaderthread if neccesary
                    CancellationTokenSource downloaderTokenSource = new CancellationTokenSource();
                    CancellationToken       downloaderToken       = downloaderTokenSource.Token;

                    //Task for downloading the redist from patch server
                    Task RedistDownloader = new Task(() => {
                        System.IO.Directory.CreateDirectory(GameInstallation.GetRootPath() + "Launcher\\Redist");
                        System.Net.WebClient RedistRequest = new WebClient();
                        RedistRequest.DownloadFileAsync(new Uri(RedistUrl), SystemUrl);
                        while (RedistRequest.IsBusy && !downloaderToken.IsCancellationRequested)
                        {
                            if (downloaderToken.IsCancellationRequested)
                            {
                                RedistRequest.CancelAsync();
                            }
                            //Thread.Sleep(1000);
                        }
                    }, downloaderToken);

                    //Redist downloader statuswindow
                    GeneralDownloadWindow RedistWindow = new GeneralDownloadWindow(downloaderTokenSource, "UE3Redist download");
                    RedistWindow.Show();
                    //Task to keep the status of the UE3Redist download
                    Task RedistDownloadStatus = new Task(() =>
                    {
                        WebRequest req = System.Net.HttpWebRequest.Create(RedistUrl);
                        req.Method     = "HEAD";
                        int ContentLength;
                        using (WebResponse resp = req.GetResponse())
                        {
                            int.TryParse(resp.Headers.Get("Content-Length"), out ContentLength);
                        }

                        RedistWindow.initProgressBar(ContentLength);
                        while (RedistDownloader.Status == TaskStatus.Running)
                        {
                            RedistWindow.Status = "Downloading UE3Redist";
                            FileInfo inf        = new FileInfo(SystemUrl);
                            RedistWindow.updateProgressBar(inf.Length);
                            //Thread.Sleep(1000);
                        }
                    });

                    //Start downloading
                    RedistDownloader.Start();
                    RedistDownloadStatus.Start();
                    await RedistDownloader;
                    RedistWindow.Close();

                    //When done, execute the UE3Redist here
                    try
                    {
                        using (Process UE3Redist = Process.Start(GameInstallation.GetRootPath() + "Launcher\\Redist\\UE3Redist.exe"))
                        {
                            UE3Redist.WaitForExit();
                            if (UE3Redist.ExitCode != 0)//If redist install fails, notify the user
                            {
                                MessageBox.Show("Error while installing the UE3 Redist.");
                            }
                            else//Everything done! save installed flag and restart
                            {
                                Properties.Settings.Default.Installed = true;
                                Properties.Settings.Default.Save();
                                try
                                {
                                    System.IO.File.Delete(GameInstallation.GetRootPath() + "Launcher\\Redist\\UE3Redist.exe");
                                    System.IO.Directory.Delete(GameInstallation.GetRootPath() + "Launcher\\Redist\\");
                                }
                                catch (Exception)
                                {
                                    MessageBox.Show("Could not cleanup the redist file. This won't hinder the game.");
                                }
                            }
                        }
                    }
                    catch
                    {
                        MessageBox.Show("Error while executing the UE3 Redist.");
                    }
                    finally
                    {
                        //Restart launcher
                        System.Diagnostics.Process.Start(Application.ResourceAssembly.Location);
                        Application.Current.Shutdown();
                    }
                }
                else
                {
                    ModernDialog notInstalledDialog = new ModernDialog();
                    notInstalledDialog.Title   = "UE3 Redistributable";
                    notInstalledDialog.Content = MessageNotInstalled;
                    notInstalledDialog.Buttons = new Button[] { notInstalledDialog.OkButton };
                    notInstalledDialog.ShowDialog();
                    //Shutdown launcher
                    Application.Current.Shutdown();
                }
            }
            else
            {
                Application.Current.Shutdown();
            }
        }
Example #12
0
        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 patchUrl       = a.Substring("--UpdateGame=".Length);
                    var    patchVersion   = VersionCheck.GetLatestGameVersionName();

                    var progress = new Progress <DirectoryPatcherProgressReport>();
                    var cancellationTokenSource = new System.Threading.CancellationTokenSource();

                    RxPatcher.Instance.AddNewUpdateServer(patchUrl, "");
                    System.Threading.Tasks.Task task = RxPatcher.Instance.ApplyPatchFromWebDownloadTask(RXPatchLib.RxPatcher.Instance.GetNextUpdateServerEntry(), targetDir, applicationDir, progress, cancellationTokenSource.Token, null); // no verificaiton on instructions.json, as we're bypassing standard version checking

                    var window = new Views.ApplyUpdateWindow(task, RxPatcher.Instance, 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();
             * }*/
        }
Example #13
0
 public string GetProcessPath()
 {
     return(GameInstallation.GetRootPath() + "Binaries\\Win32\\UDK.exe");
 }