public void LaunchGame(bool online) { Log.Info("Launching game..."); Profile profile = this.Config.Profile; if (this.CanLaunchGame() && this.CheckCurrentProfile()) { if (online && !profile.IsVanilla) { LocalizedMessage.Show(this.Window, "CantPlayOnline", "Impossible", DialogIcon.Error, DialogButtons.Ok); this.UiManager.Working = false; this.UiManager.UIEnabled = true; } else { ProcessBuilder builder = new ProcessBuilder(); builder.WorkingDirectory = this.Config.SelectedInstall.Path; if (this.Config.UseRph && this.Config.SelectedInstall.Type != InstallType.Epic && File.Exists(Path.Combine(this.Config.SelectedInstall.Path, "RAGEPluginHook.exe"))) { Log.Info("Starting RAGE Plugin Hook process..."); builder.FilePath = Path.Combine(this.Config.SelectedInstall.Path, "RAGEPluginHook.exe"); } else if (this.Config.SelectedInstall.Type == InstallType.Steam) { Log.Info("Starting steam game process..."); builder.FilePath = SteamHelper.ExecutablePath; builder.AddArgument("-applaunch 271590"); if (!File.Exists(builder.FilePath)) { builder.FilePath = null; Log.Error("Error: Steam.exe not found"); LocalizedMessage.Show(this.Window, "SteamNotFound", "Error", DialogIcon.Error, DialogButtons.Ok); } } else if (this.Config.SelectedInstall.Type == InstallType.Retail) { Log.Info("Starting retail game process..."); builder.FilePath = Path.Combine(this.Config.SelectedInstall.Path, "PlayGTAV.exe"); if (!File.Exists(builder.FilePath)) { builder.FilePath = null; Log.Error("Error: PlayGTAV.exe not found"); LocalizedMessage.Show(this.Window, "PlayGTANotFound", "Error", DialogIcon.Error, DialogButtons.Ok); } } else if (this.Config.SelectedInstall.Type == InstallType.Epic) { Log.Info("Starting epic game process..."); builder.FilePath = "com.epicgames.launcher://apps/9d2d0eb64d5c44529cece33fe2a46482?action=launch&silent=true"; } if (builder.FilePath != null) { Log.Info("Setting game language to " + this.Config.GtaLanguage); builder.AddArgument("-uilanguage " + this.Config.GtaLanguage); if (online) { builder.AddArgument("-StraightIntoFreemode"); } else if (!profile.IsVanilla && this.Config.OfflineMode) { builder.AddArgument("-scOfflineOnly"); } Log.Info("Executing " + builder); builder.StartProcess(); this.Window.Dispatcher.Invoke(() => this.Window.Visibility = Visibility.Hidden); if (this.Config.KillLauncher) { Log.Info("Waiting for game to launch..."); long start = Environment.TickCount; while (true) { if (Process.GetProcessesByName("GTA5").Length > 0) { Process process = Process.GetProcessesByName("GTA5")[0]; if (DateTime.Now - process.StartTime > TimeSpan.FromMilliseconds(GameInitTime)) { Log.Info("Closing Rockstar launcher"); ProcessUtil.Kill("PlayGTAV"); ProcessUtil.Kill("GTAVLauncher"); ProcessUtil.Kill("LauncherPatcher"); ProcessUtil.Kill("Launcher"); break; } } else { Thread.Sleep(GameCheckInterval); } if (Environment.TickCount - start > GameWaitTimeout) { Log.Warn("The game wasn't launched properly."); break; } } } this.CloseLauncher(); } else { this.UiManager.Working = false; this.UiManager.UIEnabled = true; } } } else { Log.Info("Aborting game launch."); this.UiManager.Working = false; this.UiManager.UIEnabled = true; } }
private void LaunchGame(bool online) { Log.Info("Launching game..."); if (this.CheckCurrentProfile()) { if (online && this.Profiles.CurrentProfile != 0) { Messages.Show(this.Window, "CantPlayOnline", "Impossible", MessageBoxButton.OK, MessageBoxImage.Error); this.UiManager.Working = false; this.UiManager.ButtonsEnabled = true; this.UiManager.CanPlayOnline = this.UiManager.SelectedProfile == 0; } else { ProcessBuilder builder = new ProcessBuilder(); builder.WorkingDirectory = this.GtaPath; if (this.Settings.UseRph && File.Exists(Path.Combine(this.GtaPath, "RAGEPluginHook.exe"))) { Log.Info("Starting RAGE Plugin Hook process..."); builder.FilePath = Path.Combine(this.GtaPath, "RAGEPluginHook.exe"); } else if (this.IsSteamVersion()) { Log.Info("Starting steam game process..."); builder.FilePath = Path.Combine(this.SteamPath, "steam.exe"); builder.AddArgument("-applaunch 271590"); } else { Log.Info("Starting game process..."); builder.FilePath = Path.Combine(this.GtaPath, "GTAVLauncher.exe"); } Log.Info("Setting game language to " + this.Settings.GtaLanguage); builder.AddArgument("-uilanguage " + this.Settings.GtaLanguage); if (online) { builder.AddArgument("-StraightIntoFreemode"); } else if (this.Profiles.CurrentProfile != 0 && this.Settings.OfflineMode) { builder.AddArgument("-scOfflineOnly"); } Log.Info("Executing " + builder); builder.StartProcess(); this.CloseLauncher(); } } else { Log.Info("Aborting game launch."); this.UiManager.Working = false; this.UiManager.ButtonsEnabled = true; this.UiManager.CanPlayOnline = this.UiManager.SelectedProfile == 0; } }