Exemplo n.º 1
0
        private void BuildPackfileButton_Click(object sender, EventArgs e)
        {
            GameSteamID game = GetSelectedGame();

            switch (game)
            {
            case GameSteamID.SaintsRow2:
            {
                PackfileSaveDialog.Filter     = "Normal Packfile|*.vpp_pc|All files|*.*";
                PackfileSaveDialog.DefaultExt = "vpp_pc";
                DialogResult dr = PackfileSaveDialog.ShowDialog();
                if (dr == System.Windows.Forms.DialogResult.OK)
                {
                    BeginBuild(SourceFolderPath.Text, PackfileSaveDialog.FileName, UpdateASM.Checked ? AsmPath.Text : null, game);
                }

                break;
            }

            case GameSteamID.SaintsRowIV:
            case GameSteamID.SaintsRowGatOutOfHell:
            {
                PackfileSaveDialog.Filter     = "Streamed Packfile|*.str2_pc|Normal Packfile|*.vpp_pc|All files|*.*";
                PackfileSaveDialog.DefaultExt = "str2_pc";
                DialogResult dr = PackfileSaveDialog.ShowDialog();
                if (dr == System.Windows.Forms.DialogResult.OK)
                {
                    BeginBuild(SourceFolderPath.Text, PackfileSaveDialog.FileName, UpdateASM.Checked ? AsmPath.Text : null, game);
                }

                break;
            }
            }
        }
Exemplo n.º 2
0
 public BuildOptions(string source, string destination, string asm, GameSteamID game)
 {
     Source      = source;
     Destination = destination;
     Asm         = asm;
     Game        = game;
 }
Exemplo n.º 3
0
        private void BeginBuild(string source, string destination, string asm, GameSteamID game)
        {
            var options = new BuildOptions(source, destination, asm, game);

            ParameterizedThreadStart pts = new ParameterizedThreadStart(DoBuild);
            Thread t = new Thread(pts);

            t.Start(options);
        }
Exemplo n.º 4
0
        public static IAssetAssemblerFile Create(GameSteamID game)
        {
            switch (game)
            {
            case GameSteamID.SaintsRow2:
                throw new Exception("Saints Row 2 does not have Asset Assembler files!");

            case GameSteamID.SaintsRowTheThird:
                return(Create(0x0B));

            case GameSteamID.SaintsRowIV:
            case GameSteamID.SaintsRowGatOutOfHell:
                return(Create(0x0C));

            default:
                throw new NotImplementedException(String.Format("Unsupported game ID: {0}", game));
            }
        }
        public static IGameInstance GetFromSteamId(GameSteamID game)
        {
            switch (game)
            {
                case GameSteamID.SaintsRow2:
                    return new SR2Instance();

                case GameSteamID.SaintsRowTheThird:
                    return new SRTTInstance();

                case GameSteamID.SaintsRowIV:
                    return new SRIVInstance();

                case GameSteamID.SaintsRowGatOutOfHell:
                    return new SRGOOHInstance();

                default:
                    throw new NotImplementedException();
            }
        }
        public static IGameInstance GetFromSteamId(GameSteamID game)
        {
            switch (game)
            {
            case GameSteamID.SaintsRow2:
                return(new SR2Instance());

            case GameSteamID.SaintsRowTheThird:
                return(new SRTTInstance());

            case GameSteamID.SaintsRowIV:
                return(new SRIVInstance());

            case GameSteamID.SaintsRowGatOutOfHell:
                return(new SRGOOHInstance());

            default:
                throw new NotImplementedException();
            }
        }
Exemplo n.º 7
0
        public static string GetGamePath(GameSteamID gameId)
        {
            int id = (int)gameId;

            string steamPath = GetRegistryEntry(@"HKEY_LOCAL_MACHINE\SOFTWARE\Valve\Steam", "InstallPath");

            if (steamPath == null)
            {
                steamPath = GetRegistryEntry(@"HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Valve\Steam", "InstallPath");
            }

            if (steamPath != null)
            {
                string appManifestFile = Path.Combine(steamPath, "SteamApps", String.Format("appmanifest_{0}.acf", id));
                if (File.Exists(appManifestFile))
                {
                    KeyValues manifestKv;
                    using (Stream s = File.OpenRead(appManifestFile))
                    {
                        manifestKv = new KeyValues(s);
                    }

                    Dictionary <string, object> appState = (Dictionary <string, object>)manifestKv.Items["AppState"];
                    string installdir = (string)appState["installdir"];
                    string path       = Path.Combine(steamPath, "SteamApps", "common", installdir);
                    if (Directory.Exists(path))
                    {
                        return(path);
                    }
                }
                else
                {
                    string libraryFoldersFile = Path.Combine(steamPath, "SteamApps", String.Format("libraryfolders.vdf"));
                    if (File.Exists(libraryFoldersFile))
                    {
                        KeyValues kv;
                        using (Stream s = File.OpenRead(libraryFoldersFile))
                        {
                            kv = new KeyValues(s);
                        }

                        Dictionary <string, object> libraryFolders = (Dictionary <string, object>)kv.Items["LibraryFolders"];
                        int folderId = 0;
                        while (true)
                        {
                            folderId++;
                            if (!libraryFolders.ContainsKey(folderId.ToString()))
                            {
                                break;
                            }

                            string extraLibrary = (string)libraryFolders[folderId.ToString()];

                            appManifestFile = Path.Combine(extraLibrary, "steamapps", String.Format("appmanifest_{0}.acf", id));
                            if (File.Exists(appManifestFile))
                            {
                                KeyValues manifestKv;
                                using (Stream s = File.OpenRead(appManifestFile))
                                {
                                    manifestKv = new KeyValues(s);
                                }

                                Dictionary <string, object> appState = (Dictionary <string, object>)manifestKv.Items["AppState"];
                                string installdir = (string)appState["installdir"];
                                string path       = Path.Combine(extraLibrary, "steamapps", "common", installdir);
                                if (Directory.Exists(path))
                                {
                                    return(path);
                                }
                            }
                        }
                    }
                }
            }

            return(null);
        }
Exemplo n.º 8
0
        public static string GetGamePath(GameSteamID gameId)
        {
            int id = (int)gameId;

            string steamPath = GetRegistryEntry(@"HKEY_LOCAL_MACHINE\SOFTWARE\Valve\Steam", "InstallPath");
            if (steamPath == null)
                steamPath = GetRegistryEntry(@"HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Valve\Steam", "InstallPath");

            if (steamPath != null)
            {
                string appManifestFile = Path.Combine(steamPath, "SteamApps", String.Format("appmanifest_{0}.acf", id));
                if (File.Exists(appManifestFile))
                {
                    KeyValues manifestKv;
                    using (Stream s = File.OpenRead(appManifestFile))
                    {
                        manifestKv = new KeyValues(s);
                    }

                    Dictionary<string, object> appState = (Dictionary<string, object>)manifestKv.Items["AppState"];
                    string installdir = (string)appState["installdir"];
                    string path = Path.Combine(steamPath, "SteamApps", "common", installdir);
                    if (Directory.Exists(path))
                        return path;
                }
                else
                {
                    string libraryFoldersFile = Path.Combine(steamPath, "SteamApps", String.Format("libraryfolders.vdf"));
                    if (File.Exists(libraryFoldersFile))
                    {
                        KeyValues kv;
                        using (Stream s = File.OpenRead(libraryFoldersFile))
                        {
                            kv = new KeyValues(s);
                        }

                        Dictionary<string, object> libraryFolders = (Dictionary<string, object>)kv.Items["LibraryFolders"];
                        int folderId = 0;
                        while (true)
                        {
                            folderId++;
                            if (!libraryFolders.ContainsKey(folderId.ToString()))
                                break;

                            string extraLibrary = (string)libraryFolders[folderId.ToString()];

                            appManifestFile = Path.Combine(extraLibrary, "steamapps", String.Format("appmanifest_{0}.acf", id));
                            if (File.Exists(appManifestFile))
                            {
                                KeyValues manifestKv;
                                using (Stream s = File.OpenRead(appManifestFile))
                                {
                                    manifestKv = new KeyValues(s);
                                }

                                Dictionary<string, object> appState = (Dictionary<string, object>)manifestKv.Items["AppState"];
                                string installdir = (string)appState["installdir"];
                                string path = Path.Combine(extraLibrary, "steamapps", "common", installdir);
                                if (Directory.Exists(path))
                                    return path;
                            }
                        }
                    }
                }
            }

            return null;
        }
Exemplo n.º 9
0
        public static string GetGamePath(GameSteamID gameId)
        {
            Settings settings = new Settings();

            switch (gameId)
            {
            case GameSteamID.SaintsRow2:
                if (settings.SaintsRow2Path != null)
                {
                    return(settings.SaintsRow2Path);
                }
                break;

            case GameSteamID.SaintsRowTheThird:
                if (settings.SaintsRowTheThirdPath != null)
                {
                    return(settings.SaintsRowTheThirdPath);
                }
                break;

            case GameSteamID.SaintsRowIV:
                if (settings.SaintsRowIVPath != null)
                {
                    return(settings.SaintsRowIVPath);
                }
                break;

            case GameSteamID.SaintsRowGatOutOfHell:
                if (settings.SaintsRowGatOutOfHellPath != null)
                {
                    return(settings.SaintsRowGatOutOfHellPath);
                }
                break;
            }

            int id = (int)gameId;

            string steamPath = GetSteamPath();

            if (steamPath != null)
            {
                string appManifestFile = Path.Combine(steamPath, "SteamApps", String.Format("appmanifest_{0}.acf", id));
                if (File.Exists(appManifestFile))
                {
                    KeyValues manifestKv;
                    using (Stream s = File.OpenRead(appManifestFile))
                    {
                        manifestKv = new KeyValues(s);
                    }

                    Dictionary <string, object> appState = (Dictionary <string, object>)manifestKv.Items["AppState"];
                    string installdir = (string)appState["installdir"];
                    string path       = Path.Combine(steamPath, "SteamApps", "common", installdir);
                    if (Directory.Exists(path))
                    {
                        return(path);
                    }
                }
                else
                {
                    string libraryFoldersFile = Path.Combine(steamPath, "SteamApps", String.Format("libraryfolders.vdf"));
                    if (File.Exists(libraryFoldersFile))
                    {
                        KeyValues kv;
                        using (Stream s = File.OpenRead(libraryFoldersFile))
                        {
                            kv = new KeyValues(s);
                        }

                        Dictionary <string, object> libraryFolders = (Dictionary <string, object>)kv.Items["LibraryFolders"];
                        int folderId = 0;
                        while (true)
                        {
                            folderId++;
                            if (!libraryFolders.ContainsKey(folderId.ToString()))
                            {
                                break;
                            }

                            string extraLibrary = (string)libraryFolders[folderId.ToString()];

                            appManifestFile = Path.Combine(extraLibrary, "steamapps", String.Format("appmanifest_{0}.acf", id));
                            if (File.Exists(appManifestFile))
                            {
                                KeyValues manifestKv;
                                using (Stream s = File.OpenRead(appManifestFile))
                                {
                                    manifestKv = new KeyValues(s);
                                }

                                Dictionary <string, object> appState = (Dictionary <string, object>)manifestKv.Items["AppState"];
                                string installdir = (string)appState["installdir"];
                                string path       = Path.Combine(extraLibrary, "steamapps", "common", installdir);
                                if (Directory.Exists(path))
                                {
                                    return(path);
                                }
                            }
                        }
                    }
                }
            }

            return(null);
        }
Exemplo n.º 10
0
        static void Main(string[] args)
        {
            string src  = @"D:\Gaming\Saints Row 4\test\in";
            string temp = @"D:\Gaming\Saints Row 4\test";
            string dst  = @"D:\Gaming\Saints Row 4\test\out";

            string[] packfileFolders = Directory.GetDirectories(src);

            GameSteamID game = GameSteamID.SaintsRowIV;

            foreach (string packfileFolder in packfileFolders)
            {
                string pfTemp = Path.Combine(temp, Path.GetFileName(packfileFolder));

                Directory.CreateDirectory(pfTemp);

                // Copy raw files
                string[] pfFiles = Directory.GetFiles(packfileFolder);
                foreach (string file in pfFiles)
                {
                    File.Copy(file, Path.Combine(pfTemp, Path.GetFileName(file)));
                }

                string[] asmFiles = Directory.GetFiles(pfTemp, "*.asm_pc");


                foreach (string asmFile in asmFiles)
                {
                    IAssetAssemblerFile asm = null;
                    using (Stream stream = File.OpenRead(asmFile))
                    {
                        asm = AssetAssemblerFile.FromStream(stream);
                    }

                    int count = 0;
                    foreach (var container in asm.Containers)
                    {
                        count++;
                        string str2Name = Path.ChangeExtension(container.Name, ".str2_pc");
                        string str2Src  = Path.Combine(packfileFolder, str2Name);

                        Console.Write("[{0}/{1}] Building {2}...", count, asm.Containers.Count, str2Src.Remove(0, src.Length + 1));
                        if (Directory.Exists(str2Src))
                        {
                            string           outputFile = Path.Combine(pfTemp, Path.GetFileName(str2Src));
                            ProcessStartInfo psi        = new ProcessStartInfo(@"D:\Development\SaintsRow\bin\Release\ThomasJepp.SaintsRow.BuildPackfile.exe", String.Format("{3} \"{0}\" \"{1}\" /asm:\"{2}\"", str2Src, outputFile, asmFile, game.ToString()));
                            psi.CreateNoWindow = true;
                            psi.WindowStyle    = ProcessWindowStyle.Hidden;
                            Process p = Process.Start(psi);
                            p.WaitForExit();
                            Console.WriteLine(" OK");
                        }
                        else
                        {
                            Console.WriteLine(" not found!");
                        }
                    }
                }

                Console.Write("Building {0}...", Path.GetFileName(packfileFolder));

                var options = OriginalPackfileInfo.OptionsList[game][Path.GetFileName(packfileFolder)];

                ProcessStartInfo packpsi = new ProcessStartInfo(@"D:\Development\SaintsRow\bin\Release\ThomasJepp.SaintsRow.BuildPackfile.exe", String.Format("sriv \"{0}\" \"{1}\" /condensed:{2} /compressed:{3}", pfTemp, Path.Combine(dst, Path.GetFileName(packfileFolder)), options.Condense, options.Compress));
                packpsi.CreateNoWindow = true;
                packpsi.WindowStyle    = ProcessWindowStyle.Hidden;
                Process packProcess = Process.Start(packpsi);
                packProcess.WaitForExit();

                Console.WriteLine(" OK");
            }

            Console.WriteLine("Done.");
        }
Exemplo n.º 11
0
        private void BeginBuild(string source, string destination, string asm, GameSteamID game)
        {
            var options = new BuildOptions(source, destination, asm, game);

            ParameterizedThreadStart pts = new ParameterizedThreadStart(DoBuild);
            Thread t = new Thread(pts);
            t.Start(options);
        }
Exemplo n.º 12
0
 public BuildOptions(string source, string destination, string asm, GameSteamID game)
 {
     Source = source;
     Destination = destination;
     Asm = asm;
     Game = game;
 }