Exemplo n.º 1
0
        private void ExtractPbp(string srcPbp,
                                ProcessOptions processOptions,
                                CancellationToken cancellationToken)
        {
            var info = new ExtractOptions()
            {
                SourcePbp               = srcPbp,
                OutputPath              = processOptions.OutputPath,
                DiscName                = "- Disc {0}",
                Discs                   = processOptions.Discs,
                CreateCuesheet          = true,
                CheckIfFileExists       = processOptions.CheckIfFileExists,
                SkipIfFileExists        = processOptions.SkipIfFileExists,
                FileNameFormat          = processOptions.FileNameFormat,
                ExtractResources        = processOptions.ExtractResources,
                GenerateResourceFolders = processOptions.GenerateResourceFolders,
                CustomResourceFormat    = processOptions.CustomResourceFormat,
                ResourceFoldersPath     = processOptions.ResourceFoldersPath,
                FindGame                = (gameId) => GetGameEntry(gameId, srcPbp, false)
            };

            var popstation = new Popstation
            {
                ActionIfFileExists = _eventHandler.ActionIfFileExists,
                Notify             = _notifier.Notify,
                TempFiles          = tempFiles
            };

            popstation.Extract(info, cancellationToken);
        }
Exemplo n.º 2
0
        private void SetResources(ProcessOptions processOptions, ConvertOptions options, GameEntry entry)
        {
            var appPath     = ApplicationInfo.AppPath;
            var defaultPath = Path.Combine(appPath, "Resources");


            if (string.IsNullOrEmpty(processOptions.ResourceFoldersPath))
            {
                processOptions.ResourceFoldersPath = options.OriginalPath;
            }

            Resource GetResourceOrDefault(ResourceType type, string ext)
            {
                var filename = Popstation.GetResourceFilename(processOptions.CustomResourceFormat, options.OriginalFilename, entry.GameID, entry.SaveFolderName, entry.GameName, entry.SaveDescription, entry.Format, type, ext);

                var resourcePath = Path.Combine(processOptions.ResourceFoldersPath, filename);

                if (!File.Exists(resourcePath) || !processOptions.ImportResources)
                {
                    resourcePath = Path.Combine(defaultPath, $"{type}.{ext}");
                }

                return(new Resource(type, resourcePath));
            }

            options.Icon0 = GetResourceOrDefault(ResourceType.ICON0, "png");
            options.Icon1 = GetResourceOrDefault(ResourceType.ICON1, "pmf");
            options.Pic0  = GetResourceOrDefault(ResourceType.PIC0, "png");
            options.Pic1  = GetResourceOrDefault(ResourceType.PIC1, "png");
            options.Snd0  = GetResourceOrDefault(ResourceType.SND0, "at3");
        }
Exemplo n.º 3
0
        public bool RepackPBP(
            string originalFile,
            string srcPbp,
            ProcessOptions processOptions,
            CancellationToken cancellationToken)
        {
            var appPath = ApplicationInfo.AppPath;
            var gameId  = GetPBPGameId(srcPbp);
            var game    = GetGameEntry(gameId, srcPbp, false);


            var options = new ConvertOptions()
            {
                DiscInfos = new List <DiscInfo>()
                {
                    new DiscInfo()
                    {
                        GameID     = game.ScannerID,
                        GameTitle  = game.SaveDescription,
                        GameName   = game.GameName,
                        Region     = game.Format,
                        MainGameID = game.SaveFolderName,
                        SourceIso  = srcPbp,
                    }
                },
                OriginalFilename  = Path.GetFileNameWithoutExtension(originalFile),
                OriginalPath      = Path.GetDirectoryName(originalFile),
                OutputPath        = processOptions.OutputPath,
                MainGameTitle     = game.GameName,
                MainGameRegion    = game.Format,
                MainGameID        = game.SaveFolderName,
                SaveTitle         = game.SaveDescription,
                SaveID            = game.SaveFolderName,
                BasePbp           = Path.Combine(appPath, "Resources", "BASE.PBP"),
                CompressionLevel  = processOptions.CompressionLevel,
                CheckIfFileExists = processOptions.CheckIfFileExists,
                SkipIfFileExists  = processOptions.SkipIfFileExists,
                FileNameFormat    = processOptions.FileNameFormat,
            };

            if (processOptions.GenerateResourceFolders)
            {
                GenerateResourceFolders(processOptions, options, game);
                return(true);
            }

            SetResources(processOptions, options, game);

            _notifier.Notify(PopstationEventEnum.Info, $"Using Title '{game.GameName}'");

            var popstation = new Popstation
            {
                ActionIfFileExists = _eventHandler.ActionIfFileExists,
                Notify             = _notifier.Notify,
                TempFiles          = tempFiles
            };

            return(popstation.Repack(options, cancellationToken));
        }
Exemplo n.º 4
0
        private bool ConvertIsos(
            string[] srcIsos,
            string[] srcTocs,
            ProcessOptions processOptions,
            CancellationToken cancellationToken)
        {
            var appPath = ApplicationInfo.AppPath;
            var gameId  = FindGameId(srcIsos[0]);
            var game    = GetGameEntry(gameId, srcIsos[0], false);

            var options = new ConvertOptions()
            {
                DestinationPbp    = Path.Combine(processOptions.OutputPath, $"{game.SaveDescription}.PBP"),
                DiscInfos         = new List <DiscInfo>(),
                MainGameTitle     = game.SaveDescription,
                MainGameID        = game.SaveFolderName,
                MainGameRegion    = game.Format,
                SaveTitle         = game.SaveDescription,
                SaveID            = game.SaveFolderName,
                Pic0              = Path.Combine(appPath, "Resources", "PIC0.PNG"),
                Pic1              = Path.Combine(appPath, "Resources", "PIC1.PNG"),
                Icon0             = Path.Combine(appPath, "Resources", "ICON0.PNG"),
                BasePbp           = Path.Combine(appPath, "Resources", "BASE.PBP"),
                CompressionLevel  = processOptions.CompressionLevel,
                CheckIfFileExists = processOptions.CheckIfFileExists,
                FileNameFormat    = processOptions.FileNameFormat,
            };

            for (var i = 0; i < srcIsos.Length; i++)
            {
                gameId = FindGameId(srcIsos[i]);
                game   = GetGameEntry(gameId, srcIsos[i]);

                options.DiscInfos.Add(new DiscInfo()
                {
                    GameID     = game.ScannerID,
                    GameTitle  = game.SaveDescription,
                    GameName   = game.GameName,
                    Region     = game.Format,
                    MainGameID = game.SaveFolderName,
                    SourceIso  = srcIsos[i],
                    SourceToc  = i < srcTocs.Length ? srcTocs[i] : "",
                });
            }

            _notifier?.Notify(PopstationEventEnum.Info, $"Using Title '{game.SaveDescription}'");

            var popstation = new Popstation.Popstation
            {
                ActionIfFileExists = _eventHandler.ActionIfFileExists,
                Notify             = _notifier.Notify,
                TempFiles          = tempFiles
            };

            return(popstation.Convert(options, cancellationToken));
        }
Exemplo n.º 5
0
        private void GenerateResourceFolders(ProcessOptions processOptions, ConvertOptions options, GameEntry entry)
        {
            var path = Popstation.GetResourceFilename(processOptions.CustomResourceFormat, options.OriginalFilename, entry.GameID, entry.SaveFolderName, entry.GameName, entry.SaveDescription, entry.Format, ResourceType.ICON0, "png");

            path = Path.GetDirectoryName(path);

            path = Path.Combine(options.OriginalPath, path);

            if (!Directory.Exists(path))
            {
                Directory.CreateDirectory(path);
            }

            using (File.Create(Path.Combine(path, entry.GameName)))
            {
            }
        }
Exemplo n.º 6
0
        static Task ExtractPbp(string srcPbp, string outpath, CancellationToken cancellationToken)
        {
            var filename = Path.GetFileNameWithoutExtension(srcPbp) + ".bin";

            var info = new ExtractIsoInfo()
            {
                SourcePbp      = srcPbp,
                DestinationIso = Path.Combine(outpath, filename),
                CreateCuesheet = true
            };

            var popstation = new Popstation.Popstation();

            popstation.OnEvent = Notify;

            total = 0;

            return(popstation.Extract(info, cancellationToken));
        }
Exemplo n.º 7
0
        private void ExtractPbp(string srcPbp,
                                ProcessOptions processOptions,
                                CancellationToken cancellationToken)
        {
            var info = new ExtractOptions()
            {
                SourcePbp         = srcPbp,
                OutputPath        = processOptions.OutputPath,
                DiscName          = "- Disc {0}",
                Discs             = processOptions.Discs,
                CreateCuesheet    = true,
                CheckIfFileExists = processOptions.CheckIfFileExists,
                FileNameFormat    = processOptions.FileNameFormat,
                GetGameInfo       = (gameId) =>
                {
                    var game = GetGameEntry(gameId, srcPbp, false);
                    if (game == null)
                    {
                        return(null);
                    }
                    return(new GameInfo()
                    {
                        GameID = game.ScannerID,
                        GameName = game.GameName,
                        Title = game.SaveDescription,
                        MainGameID = game.SaveFolderName,
                        Region = game.Format
                    });
                }
            };

            var popstation = new Popstation.Popstation
            {
                ActionIfFileExists = _eventHandler.ActionIfFileExists,
                Notify             = _notifier.Notify,
                TempFiles          = tempFiles
            };

            popstation.Extract(info, cancellationToken);
        }
Exemplo n.º 8
0
        static Task ConvertIso(string srcIso, string srcToc, string outpath, int compressionLevel, CancellationToken cancellationToken, string savedesc = "PS1 Game - Save Data", string name = "PS1 Game", string pic0 = "PIC0.PNG", string pic1 = "PIC1.PNG", string icon0 = "ICON0.PNG", string basePbp = "BASE.PBP")
        {
            var game    = FindGameInfo(srcIso, name);
            var appPath = ApplicationInfo.AppPath;

            var info = new ConvertIsoInfo()
            {
                DiscInfos = new List <DiscInfo>()
                {
                    new DiscInfo()
                    {
                        GameID    = game.ScannerID,
                        GameTitle = game.GameName,
                        SourceIso = srcIso,
                        SourceToc = srcToc,
                    }
                },
                DestinationPbp   = Path.Combine(outpath, $"{game.GameName}.PBP"),
                MainGameTitle    = game.GameName,
                MainGameID       = game.SaveFolderName,
                SaveTitle        = game.SaveDescription,
                SaveID           = game.SaveFolderName,
                Pic0             = pic0,
                Pic1             = pic1,
                Icon0            = icon0,
                BasePbp          = basePbp,
                CompressionLevel = compressionLevel
            };

            var popstation = new Popstation.Popstation();

            popstation.OnEvent = Notify;

            total = 0;

            return(popstation.Convert(info, cancellationToken));
        }
Exemplo n.º 9
0
        private bool ConvertIsos(
            string originalFile,
            string[] srcIsos,
            string[] srcTocs,
            ProcessOptions processOptions,
            CancellationToken cancellationToken)
        {
            var appPath = ApplicationInfo.AppPath;
            var srcIso  = srcIsos[0];
            var gameId  = GameDB.FindGameId(srcIso);
            var game    = GetGameEntry(gameId, srcIso, false);

            var options = new ConvertOptions()
            {
                OriginalPath      = Path.GetDirectoryName(originalFile),
                OriginalFilename  = Path.GetFileNameWithoutExtension(originalFile),
                OutputPath        = processOptions.OutputPath,
                DiscInfos         = new List <DiscInfo>(),
                MainGameTitle     = game.SaveDescription,
                MainGameID        = game.SaveFolderName,
                MainGameRegion    = game.Format,
                SaveTitle         = game.SaveDescription,
                SaveID            = game.SaveFolderName,
                BasePbp           = Path.Combine(appPath, "Resources", "BASE.PBP"),
                CompressionLevel  = processOptions.CompressionLevel,
                CheckIfFileExists = processOptions.CheckIfFileExists,
                SkipIfFileExists  = processOptions.SkipIfFileExists,
                FileNameFormat    = processOptions.FileNameFormat,
            };

            if (processOptions.GenerateResourceFolders)
            {
                GenerateResourceFolders(processOptions, options, game);
                return(true);
            }
            SetResources(processOptions, options, game);

            for (var i = 0; i < srcIsos.Length; i++)
            {
                gameId = GameDB.FindGameId(srcIso);
                game   = GetGameEntry(gameId, srcIsos[i]);

                options.DiscInfos.Add(new DiscInfo()
                {
                    GameID     = game.ScannerID,
                    GameTitle  = game.SaveDescription,
                    GameName   = game.GameName,
                    Region     = game.Format,
                    MainGameID = game.SaveFolderName,
                    SourceIso  = srcIsos[i],
                    SourceToc  = i < srcTocs.Length ? srcTocs[i] : "",
                });
            }

            _notifier?.Notify(PopstationEventEnum.Info, $"Using Title '{game.SaveDescription}'");

            var popstation = new Popstation
            {
                ActionIfFileExists = _eventHandler.ActionIfFileExists,
                Notify             = _notifier.Notify,
                TempFiles          = tempFiles
            };

            return(popstation.Convert(options, cancellationToken));
        }