コード例 #1
0
        /// <summary>
        /// List all mods located in update\x64\dlcpacks\
        /// </summary>
        public static List <string> ListDlcMods()
        {
            GTAInstall install = Launcher.Instance.Config.SelectedInstall;

            if (install.Path != null)
            {
                if (Directory.Exists(install.Path))
                {
                    List <string> mods = new List <string>();

                    if (Directory.Exists(Path.Combine(install.Path, "update\\x64\\dlcpacks")))
                    {
                        foreach (string file in Directory.GetFileSystemEntries(Path.Combine(install.Path, "update\\x64\\dlcpacks")))
                        {
                            if (Directory.Exists(file))
                            {
                                string filename = Path.GetFileName(file).ToLower();
                                if (!filename.StartsWith("mp") && !filename.StartsWith("patchday"))
                                {
                                    mods.Add(file);
                                }
                            }
                        }
                    }

                    return(mods);
                }
                throw new ApplicationException("GtaPath doesn't exist.");
            }
            else
            {
                throw new ApplicationException("GtaPath is not set.");
            }
        }
コード例 #2
0
        public static bool IsGTAModded()
        {
            GTAInstall install = Launcher.Instance.Config.SelectedInstall;

            foreach (string file in Directory.GetFileSystemEntries(install.Path))
            {
                if (!IsVanillaEntry(Path.GetFileName(file)))
                {
                    return(true);
                }
            }

            if (Directory.Exists(Path.Combine(install.Path, "update\\x64\\dlcpacks")))
            {
                foreach (string file in Directory.GetFileSystemEntries(Path.Combine(install.Path, "update\\x64\\dlcpacks")))
                {
                    if (Directory.Exists(file))
                    {
                        string filename = Path.GetFileName(file).ToLower();
                        if (!filename.StartsWith("mp") && !filename.StartsWith("patchday"))
                        {
                            return(true);
                        }
                    }
                }
            }

            return(false);
        }
コード例 #3
0
        /// <summary>
        /// List all mods located at the root of the game's directory
        /// </summary>
        public static void ListRootMods(out List <string> files, out List <string> dirs)
        {
            GTAInstall install = Launcher.Instance.Config.SelectedInstall;

            if (install.Path != null)
            {
                if (Directory.Exists(install.Path))
                {
                    files = new List <string>();
                    dirs  = new List <string>();

                    foreach (string file in Directory.EnumerateFileSystemEntries(install.Path))
                    {
                        if (!IsVanillaEntry(Path.GetFileName(file)))
                        {
                            if (File.Exists(file))
                            {
                                files.Add(file);
                            }
                            else
                            {
                                dirs.Add(file);
                            }
                        }
                    }
                }
                else
                {
                    throw new ApplicationException("GtaPath doesn't exist.");
                }
            }
            else
            {
                throw new ApplicationException("GtaPath is not set.");
            }
        }
コード例 #4
0
        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;
                }
            }
        }