Exemplo n.º 1
0
        public GameManager()
        {
            Stopwatch s = new Stopwatch();

            s.Start();
            Utils.Log("Initializing GTA manager...");

            string registryInstallPath = String.Empty;

            try
            {
                registryInstallPath = Registry.GetValue(GTA_REGISTRY_PATH, "InstallFolder", String.Empty).ToString();
            }
            catch (Exception ex)
            {
                MainWindow.ShowInitErrorAndExit();
            }
            if (registryInstallPath == String.Empty || registryInstallPath == null)
            {
                this.IsSteam       = true;
                this.InstallFolder = GetSteamGTAInstallationFolder();
                Utils.Log("Game found! Edition: Steam");
                Utils.Log("Installation folder: " + InstallFolder);
            }
            else
            {
                this.IsSteam       = false;
                this.InstallFolder = registryInstallPath;
                Utils.Log("Game found! Edition: Rockstar Warehouse");
                Utils.Log("Installation folder: " + InstallFolder);
            }

            if (string.IsNullOrEmpty(this.InstallFolder))
            {
                return;
            }
            FileVersionInfo GTAFileVersionInfo = FileVersionInfo.GetVersionInfo(registryInstallPath + @"\GTA5.exe");

            this.PatchVersion = GTAFileVersionInfo.ProductVersion;
            this.Language     = GTAFileVersionInfo.Language;

            if (File.Exists(this.InstallFolder + @"\commandline.txt"))
            {
                this.CommandlinePath = this.InstallFolder + @"\commandline.txt";
            }
            else
            {
                File.Create(this.InstallFolder + @"\commandline.txt");
                this.CommandlinePath = this.CommandlinePath + @"\commandline.txt";
                Utils.Log("Commandline.txt doesn't exitst, creating...");
            }

            if (!Directory.Exists(this.InstallFolder + Utils.MOD_STORAGE_FOLDER_ENDPOINT))
            {
                Utils.Log("ToolsV mods folder doesn't exist, creating...");
                Directory.CreateDirectory(this.InstallFolder + Utils.MOD_STORAGE_FOLDER_ENDPOINT);
            }
            this.ModStorageFolder = this.InstallFolder + Utils.MOD_STORAGE_FOLDER_ENDPOINT;

            this.IsModded = Directory.Exists(this.InstallFolder) && Directory.Exists(this.InstallFolder + @"\mods") ? Directory.GetFiles(this.InstallFolder + @"\mods").Length != 0 : false;
            if (!IsModded && GetMods(false).Count != 0 || GetModdedRPFs().Count != 0)
            {
                this.IsModded = true;
            }
            this.GameProperties = GetGameProperties();

            s.Stop();
            Utils.Log("Patch version: " + PatchVersion);
            Utils.Log("Language: " + Language);
            Utils.Log("Enabled mods: " + GetMods(false).Count);
            Utils.Log("Total mods: " + GetMods(true).Count);
            Utils.Log("RPF mods: " + GetModdedRPFs().Count);
            Utils.Log($"Game installation initialized in {Math.Round(s.Elapsed.TotalMilliseconds / 1000, 3)} seconds");
            s.Reset();
        }
Exemplo n.º 2
0
        public GameManager()
        {
            var s = new Stopwatch();

            s.Start();
            Utils.Log("Initializing GTA manager...");

            var gamePath = GetSteamGameInstallationFolder();

            if (gamePath.Equals(string.Empty))
            {
                gamePath = GetRockstarGameInstallationFolder();
                if (!gamePath.Equals(string.Empty))
                {
                    this.IsSteam       = false;
                    this.InstallFolder = gamePath;
                }
                else
                {
                    // game detection failed
                    // TODO: prompt user to manually select directory
                    this.IsSteam       = true;
                    this.InstallFolder = string.Empty;
                }
            }
            else
            {
                this.IsSteam       = true;
                this.InstallFolder = gamePath;
            }

            if (string.IsNullOrEmpty(this.InstallFolder))
            {
                MainWindow.ShowInitErrorAndExit();
            }

            // game directory is found, all good
            var edition = IsSteam ? "Steam" : "Rockstar Warehouse";

            Utils.Log($"Game found! Edition: {edition}");
            Utils.Log($"Installation folder: {InstallFolder}");

            var gtaFileVersionInfo = FileVersionInfo.GetVersionInfo(InstallFolder + @"\GTA5.exe");

            this.PatchVersion = gtaFileVersionInfo.ProductVersion;
            this.Language     = gtaFileVersionInfo.Language;

            if (File.Exists(this.InstallFolder + @"\commandline.txt"))
            {
                this.CommandlinePath = this.InstallFolder + @"\commandline.txt";
            }
            else
            {
                File.Create(this.InstallFolder + @"\commandline.txt");
                this.CommandlinePath = this.CommandlinePath + @"\commandline.txt";
                Utils.Log("Commandline.txt doesn't exitst, creating...");
            }

            if (!Directory.Exists(this.InstallFolder + Utils.MOD_STORAGE_FOLDER_ENDPOINT))
            {
                Utils.Log("ToolsV mods folder doesn't exist, creating...");
                Directory.CreateDirectory(this.InstallFolder + Utils.MOD_STORAGE_FOLDER_ENDPOINT);
            }
            this.ModStorageFolder = this.InstallFolder + Utils.MOD_STORAGE_FOLDER_ENDPOINT;

            if (Directory.Exists(this.InstallFolder + Utils.MOD_FOLDER_ENDPOINT))
            {
                if (GetMods(false).Count > 0)
                {
                    this.IsModded = true;
                }
            }
            if (!IsModded && GetMods(false).Count != 0 || GetModdedRpfs().Count != 0)
            {
                this.IsModded = true;
            }
            this.GameProperties = GetGameProperties();

            s.Stop();
            Utils.Log("Patch version: " + PatchVersion);
            Utils.Log("Language: " + Language);
            Utils.Log("Enabled mods: " + GetMods(false).Count);
            Utils.Log("Total mods: " + GetMods(true).Count);
            Utils.Log("RPF mods: " + GetModdedRpfs().Count);
            Utils.Log($"Game installation initialized in {Math.Round(s.Elapsed.TotalMilliseconds / 1000, 3)} seconds");
            s.Reset();
        }