Ejemplo n.º 1
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();
            }
        }
Ejemplo n.º 2
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;
            }
        }
Ejemplo n.º 3
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...");
        }
Ejemplo n.º 4
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();
             * }*/
        }