Program.cs 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. using System;
  2. using System.Collections.Generic;
  3. using System.IO;
  4. using System.Linq;
  5. /// <summary>
  6. /// Extract Bink Movies from CDs
  7. /// </summary>
  8. namespace OpenVIII.PAK_Extractor
  9. {
  10. internal class Program
  11. {
  12. #region Methods
  13. private static void Main(string[] args)
  14. {
  15. Memory.Init(null, null, null, args);
  16. var destPath = Path.Combine(Memory.FF8DirData, "movies");
  17. //DestPath = Path.Combine(Path.GetTempPath(), "movies"); //comment out to default to ff8 folder.
  18. var files = new List<FileInfo>(1);
  19. var data = new List<PAK>(1);
  20. Console.WriteLine("This tool is used to extract the movies from the FF8 CDs, to be more like the steam version.");
  21. Console.WriteLine("Detecting Compact Disc drives...");
  22. foreach (var drive in DriveInfo.GetDrives()
  23. .Where(d => d.DriveType == DriveType.CDRom && d.IsReady))
  24. {
  25. var dir = drive.RootDirectory;
  26. Console.WriteLine($"Found disc: {dir}");
  27. Console.WriteLine("Scanning for PAK files...");
  28. files.AddRange(dir.GetFiles("*", SearchOption.TopDirectoryOnly).Where(x =>
  29. x.FullName.EndsWith(".pak", StringComparison.OrdinalIgnoreCase)));
  30. }
  31. foreach (var f in files)
  32. {
  33. Console.WriteLine($"PAK file detected: {f}");
  34. var pak = new PAK(f);
  35. var sumHigh = pak.Movies.Sum(g => g.BinkHigh.Size);
  36. var sumLow = pak.Movies.Sum(g => g.BinkLow.Size);
  37. var sumCam = pak.Movies.Sum(g => g.Cam.Size);
  38. Console.WriteLine($"PAK has {pak.Count} videos. Total of {sumHigh / 1024} KB (HI Res BINK), {sumLow / 1024} KB (LOW Res BINK), {sumCam / 1024} KB (CAM)");
  39. data.Add(pak);
  40. }
  41. if (data.Count > 0)
  42. {
  43. Console.WriteLine($"Destination: {Path.GetFullPath(destPath)}\nPress [Enter] to continue. If you'd like to override this path, type a new destination, and then press [ENTER].");
  44. var input = Console.ReadLine();
  45. if (input != null && !string.IsNullOrWhiteSpace(input.Trim()))
  46. {
  47. Console.WriteLine($"Changed destination to: {Path.GetFullPath(input)}");
  48. destPath = input;
  49. }
  50. if (!Directory.Exists(destPath))
  51. {
  52. Console.WriteLine("Created directory.");
  53. Directory.CreateDirectory(destPath);
  54. }
  55. foreach (var pak in data)
  56. {
  57. pak.Extract(destPath);
  58. }
  59. }
  60. Console.WriteLine("Insert disc and press [Enter].");
  61. Console.ReadLine();
  62. }
  63. #endregion Methods
  64. }
  65. }