static void HandleCompileGxt2Options(string[] args) { CommandLine.Parse <CompileGxt2Optionns>(args, (opts, gOpts) => { Init(args); if (opts.OutputDirectory == null) { Console.WriteLine("Please provide output directory with -o --output"); return; } var entries = new Dictionary <uint, string>(); ArchiveUtilities.ForEachBinaryFile(Settings.Default.GTAFolder, (string fullFileName, IArchiveBinaryFile file, RageArchiveEncryption7 encryption) => { if (fullFileName.EndsWith(".gxt2") && fullFileName.ToLowerInvariant().Contains(opts.Lang.ToLowerInvariant())) { Console.WriteLine(fullFileName); var gxt2 = new Gxt2File(); byte[] data = Utils.GetBinaryFileData(file, encryption); gxt2.Load(data); for (int i = 0; i < gxt2.TextEntries.Count; i++) { entries[gxt2.TextEntries[i].Hash] = gxt2.TextEntries[i].Text; } } }); var sb = new StringBuilder(); foreach (var entry in entries) { sb.AppendLine(entry.Key + " = " + entry.Value); } File.WriteAllText(opts.OutputDirectory + "\\" + opts.Lang + ".gxt2.txt", sb.ToString()); }); }
static void HandleCompileDrawableShadersOptions(string[] args) { CommandLine.Parse <CompileDrawableShadersOptions>(args, (opts, gOpts) => { EnsurePath(); EnsureKeys(); var shaderNames = new Dictionary <uint, string>(); var shaderParameterSetNames = new Dictionary <uint, string>(); var fxcShaders = new Dictionary <uint, FxcFile>(); ArchiveUtilities.ForEachBinaryFile(Settings.Default.GTAFolder, (fullFileName, binaryFile, encryption) => { if (fullFileName.EndsWith(".fxc")) { string nameLower = binaryFile.Name.ToLowerInvariant().Replace(".fxc", ""); var hash = Jenkins.Hash(nameLower); if (!shaderNames.ContainsKey(hash)) { shaderNames.Add(hash, nameLower); } byte[] data = Utils.GetBinaryFileData((IArchiveBinaryFile)binaryFile, encryption); var fxc = new FxcFile(); fxc.Load(data, nameLower); if (!fxcShaders.ContainsKey(hash)) { fxcShaders.Add(hash, fxc); } } else if (fullFileName.EndsWith(".sps")) { string nameLower = binaryFile.Name.ToLowerInvariant(); var hash = Jenkins.Hash(nameLower); if (!shaderParameterSetNames.ContainsKey(hash)) { shaderParameterSetNames.Add(hash, nameLower); } } }); ArchiveUtilities.ForEachResourceFile(Settings.Default.GTAFolder, (fullFileName, resourceFile, encryption) => { if (fullFileName.EndsWith(".ydr")) { var ms = new MemoryStream(); resourceFile.Export(ms); var ydr = new YdrFile(); ydr.Load(ms); Console.WriteLine(fullFileName.Replace(Settings.Default.GTAFolder, "")); CompileDrawableShaders_ProcessDrawable(ydr.Drawable, shaderNames, fxcShaders); Console.WriteLine(""); } else if (fullFileName.EndsWith(".ydd")) { var ms = new MemoryStream(); resourceFile.Export(ms); var ydd = new YddFile(); ydd.Load(ms); Console.WriteLine(fullFileName.Replace(Settings.Default.GTAFolder, "")); var drawables = ydd.DrawableDictionary.Drawables; for (int d = 0; d < drawables.Count; d++) { var drawable = drawables[d]; Console.WriteLine(" " + drawable.Name.Value); CompileDrawableShaders_ProcessDrawable(drawable, shaderNames, fxcShaders); } Console.WriteLine(""); } }); }); }