public ResourceLoader(GraphicsDevice device, string gamePath) { if (device == null) { throw new ArgumentNullException(nameof(device)); } if (string.IsNullOrEmpty(gamePath)) { throw new ArgumentNullException(nameof(gamePath)); } GraphicsDevice = device; GamePath = gamePath; _entries = DirProcessor.BuildEntries(gamePath); }
static void Main(string[] args) { if (args.Length < 2) { Console.WriteLine("Usage: Unpacker <path/to/sora> <output/path>"); return; } try { var entries = DirProcessor.BuildEntries(args[0]); foreach (var pair in entries) { Console.WriteLine("Processing '{0}'", pair.Key); foreach (var entry in pair.Value) { if (entry.CompressedSize == 0 || entry.DecompressedSize == 0) { continue; } if (!entry.Name.EndsWith("_X2")) { continue; } var unpack = !entry.Name.EndsWith("_DT") && !entry.Name.EndsWith("_DS") && !entry.Name.EndsWith("WAV") && !entry.Name.EndsWith("_VS"); if (unpack) { Console.WriteLine("Unpacking '{0}'", entry.Name); } else { Console.WriteLine("Saving '{0}'", entry.Name); } try { byte[] bytes = new byte[entry.CompressedSize]; using (var stream = File.OpenRead(pair.Key)) { stream.Seek(entry.Offset, SeekOrigin.Begin); stream.Read(bytes, 0, bytes.Length); } if (unpack) { bytes = FalcomDecompressor.Decompress(bytes); } var outputPath = Path.Combine(args[1], entry.Name); File.WriteAllBytes(outputPath, bytes); } catch (Exception ex) { Console.WriteLine(ex); } } } } catch (Exception ex) { Console.WriteLine(ex); } }
static void Main(string[] args) { if (args.Length < 2) { Console.WriteLine("Usage: Unpacker <path/to/sora> <output/path>"); return; } try { var entries = DirProcessor.BuildEntries(args[0]); foreach (var pair in entries) { Console.WriteLine("Processing '{0}'", pair.Key); foreach (var entry in pair.Value) { if (entry.CompressedSize == 0 || entry.DecompressedSize == 0) { continue; } if (!entry.Name.EndsWith("_SN")) { continue; } /* if (!entry.Name.StartsWith("T0310")) * { * continue; * }*/ Console.WriteLine("Processing script '{0}'", entry.Name); try { byte[] bytes = new byte[entry.CompressedSize]; using (var stream = File.OpenRead(pair.Key)) { stream.Seek(entry.Offset, SeekOrigin.Begin); stream.Read(bytes, 0, bytes.Length); } bytes = FalcomDecompressor.Decompress(bytes); var output = string.Empty; using (var stream = new MemoryStream(bytes)) { var scenario = Scenario.FromFCStream(stream); output = scenario.ToString(); } var fileName = Path.Combine(args[1], Path.ChangeExtension(entry.Name, "txt")); File.WriteAllText(fileName, output); } catch (Exception ex) { Console.WriteLine(ex); } } } } catch (Exception ex) { Console.WriteLine(ex); } }