コード例 #1
0
        static void Main5()
        {
            var Patcher  = new Patcher((string)null);
            var PatchAll = new PatchAll(Patcher);

            Patcher.InitWithGamePath(@"C:\vesperia\vesperia");
            //Patcher.InitWithGamePath(@"I:\GAMES\vesperia");
            PatchAll.CheckFileSystemVesperiaExceptions(Patcher.GameFileSystem);
            PatchAll.Handle();
        }
コード例 #2
0
ファイル: PatchThread.cs プロジェクト: talestra/tov
        static public void Run(MainWindow MainWindow, Action <ProgressHandler> OnProgress, string OriginalGamePath, string TranslatedGamePath, bool UseJTAGFolder)
        {
            //string OriginalPath = GamePath;
            //string TranslatedISOPath = System.IO.Path.Combine(System.IO.Path.GetDirectoryName(OriginalPath), "Tales of Vesperia [PAL] [Español].iso");

            if (OriginalGamePath == TranslatedGamePath)
            {
                MessageBox.Show("No se puede actualizar el mismo archivo directamente.", "Hubo un error", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }

            const bool CheckMd5 = true;
            //const bool CheckMd5 = false;

            var RunTask = Task.Run(() =>
            {
                try
                {
                    MainWindow.InProgress = true;

                    TryCatchIfNotDebugger(() =>
                    {
                        //throw (new Exception("Test ERROR!"));

                        var Patcher  = new Patcher((string)null);
                        var PatchAll = new PatchAll(Patcher);

                        if (!UseJTAGFolder)
                        {
                            var Iso = new Dvd9Xbox360FileSystem(File.OpenRead(OriginalGamePath));
                            PatchAll.CheckFileSystemVesperiaExceptions(Iso);
                        }

                        Patcher.Progress += (ProgressHandler) =>
                        {
                            OnProgress(ProgressHandler);
                        };

                        if (!UseJTAGFolder)
                        {
                            Patcher.ProgressHandler.ExecuteActionsWithProgressTracking("Preparándose para parchear", () =>
                            {
                                Patcher.ProgressHandler.AddProgressLevel("Comprobando MD5 de la ISO", 1, () =>
                                {
                                    if (CheckMd5)
                                    {
                                        var ExpectedMd5 = "546f74b4e48bb985fcd365496e03bd10";
                                        var ComputedMd5 = Hashing.GetMd5Hash(OriginalGamePath, (Current, Total) =>
                                        {
                                            Patcher.ProgressHandler.SetLevelProgressTo(Current, Total);
                                        });

                                        if (ComputedMd5 != ExpectedMd5)
                                        {
                                            throw (new Exception(
                                                       "El md5 de la ISO a parchear no coincide.\n" +
                                                       "Si estás intentando reparchear el juego, asegúrate de haber borrado la anterior ISO en español.\n" +
                                                       "Se tiene que parchear usando la ISO original PAL, y no se puede usar la ISO en español ni ninguna otra ISO para el reparcheo.\n" +
                                                       "Md5 calculado: " + ComputedMd5 + "\n" +
                                                       "Md5 esperado: " + ExpectedMd5 + "\n" +
                                                       ""));
                                        }
                                    }
                                });
                            }, () =>
                            {
                                if (CheckMd5)
                                {
                                    if (File.Exists(TranslatedGamePath))
                                    {
                                        try { File.Delete(TranslatedGamePath); }
                                        catch { }
                                    }
                                }

                                var TranslatedGameDvdPath = System.IO.Path.ChangeExtension(TranslatedGamePath, ".dvd");

                                //LayerBreak=1913760
                                //s-tov.iso

                                File.WriteAllLines(TranslatedGameDvdPath, new[] {
                                    "LayerBreak=1913760",
                                    System.IO.Path.GetFileName(TranslatedGamePath),
                                });

                                Patcher.ProgressHandler.AddProgressLevel("Copiando ISO", 1, () =>
                                {
                                    Console.WriteLine("Copying ISO...");
                                    if (!File.Exists(TranslatedGamePath) || (new FileInfo(TranslatedGamePath).Length != new FileInfo(OriginalGamePath).Length))
                                    {
                                        using (var In = File.OpenRead(OriginalGamePath))
                                            using (var Out = File.Open(TranslatedGamePath, FileMode.Create, FileAccess.Write, FileShare.None))
                                            {
                                                Out.WriteStream(In, (Current, Total) =>
                                                {
                                                    //Console.WriteLine("{0}%", ((double)Current / (double)Total) * 100);
                                                    Patcher.ProgressHandler.SetLevelProgressTo(Current, Total);
                                                });
                                            }
                                    }
                                    Console.WriteLine("Done");
                                });
                            });
                        }

                        if (!Patcher.ExternalPatchData)
                        {
                            PatchDataDecompress();
                        }

                        Patcher.InitWithGamePath(TranslatedGamePath);
                        PatchAll.CheckFileSystemVesperiaExceptions(Patcher.GameFileSystem);
                        PatchAll.Handle();

                        if (!Patcher.ExternalPatchData)
                        {
                            PatchDataDelete();
                        }

                        MessageBox.Show("¡El parcheador ha terminado de traducir Tales of Vesperia al español!", "¡Felicidades!", MessageBoxButton.OK, MessageBoxImage.Information);
                    });
                }
                finally
                {
                    MainWindow.InProgress = false;
                }
            });
        }