private void InitLauncher() { Log.Info("Initializing launcher..."); SteamHelper.Initialize(); if (this.Config.SelectedInstall != null && (this.Config.SelectedInstall.Path == null || !Directory.Exists(this.Config.SelectedInstall.Path))) { this.Config.SelectedInstall = null; } if (this.Config.SelectedInstall == null) { GTAInstall[] installs = GTAInstall.FindInstalls(); if (installs.Length > 0) { this.Config.SelectedInstall = installs[0]; } else { LocalizedMessage.Show("GTANotFound", "Info", DialogIcon.Information, DialogButtons.Ok); HostWindow host = new HostWindow(); host.Content = new ChooseInstallDialog(host); host.ShowDialog(); if (this.Config.SelectedInstall == null) { Environment.Exit(1); return; } } this.Config.Save(); } Log.Info("Using GTA V installation at " + this.Config.SelectedInstall.Path); Log.Info("Installation type: " + this.Config.SelectedInstall.Type); if (Path.GetFullPath(this.WorkingDirectory).Equals(Path.GetFullPath(this.Config.SelectedInstall.Path))) { LocalizedMessage.Show("InstalledInGTA", "Error", DialogIcon.Error, DialogButtons.Ok); Environment.Exit(1); } GameScanner.Init(); Log.Info("Loading profiles..."); string profilesDir = Path.Combine(this.UserDirectory, "Profiles"); if (!Directory.Exists(profilesDir)) { Directory.CreateDirectory(profilesDir); } if (this.Config.VanillaProfile == null) { Log.Info("Vanilla profile not found. Creating it"); this.Config.Profiles.Add(new Profile("Vanilla", true)); } foreach (string dir in Directory.EnumerateDirectories(profilesDir)) { string name = Path.GetFileName(dir); if (!this.Config.ProfileExists(name)) { this.Config.Profiles.Add(new Profile(name)); } } if (this.Config.Profile == null) { Log.Info("Current profile is invalid"); if (GameScanner.IsGTAModded()) { Log.Info("GTA is currently modded: creating new modded profile"); Profile profile = new Profile(this.GetNewProfileName()); this.Config.Profiles.Add(profile); this.Config.Profile = profile; } else { Log.Info("GTA is currently not modded: considering the game vanilla"); this.Config.CurrentProfile = this.Config.VanillaProfile.Name; } } }
private void InitLauncher() { Log.Info("Initializing launcher..."); if (this.Settings.CustomGTAFolder != null) { this.GtaPath = this.Settings.CustomGTAFolder; } else { this.ReadGamePath(); } if (this.GtaPath != null) { if (this.GtaPath.EndsWith("\\")) { this.GtaPath = this.GtaPath.Substring(0, this.GtaPath.Length - 1); } Log.Info("Found GTA V installation at " + this.GtaPath + ' ' + (this.IsSteamVersion() ? "(Steam version)" : this.IsCustomVersion() ? "(Custom retail version)" : "(Retail version)")); if (Directory.Exists(this.GtaPath)) { GameScanner.Init(); if (File.Exists(Path.Combine(UserDirPath, "profiles.dat"))) { try { using (Stream stream = File.Open(Path.Combine(UserDirPath, "profiles.dat"), FileMode.Open)) { this.Profiles = (ProfileList)formatter.Deserialize(stream); } } catch (Exception ex) { Log.Error("Unable to read saved profiles."); Log.Error(ex.ToString()); Messages.UnableToReadProfiles(); this.createDefaultProfiles(); } } else { Log.Info("No profiles.dat file found."); this.createDefaultProfiles(); } this.Window.Dispatcher.Invoke(new Callback(UpdateUI)); } else { Log.Error("GTA V wasn't found at the specified location."); Messages.GTANotFound(); } } else { Log.Error("No GTA installation found."); Messages.NoGTA(); } }