static void ConvertToDds(AssetInfo_Single info, string source, string dest) { Directory.CreateDirectory(Path.GetDirectoryName(dest)); string Params = info.GetDssFormat(); RunCommand(Path_nvdxt, string.Format(Params_nvdxt + Params, source, dest)); }
static void Main(string[] args) { //LocalizationToXml(); return; if (args.Length > 0 && args[0] == "1") { args_RedoAll = true; Console.WriteLine("Arguments: Rebuilding all. (Will take a while)"); } if (args.Length > 1 && args[1] == "1") { args_RedoDDS = true; Console.WriteLine("Arguments: Rebuild DDS files. (Will take a while)"); } if (args.Length > 2 && args[2] == "1") { args_RedoList = true; Console.WriteLine("Arguments: Rebuild texture list for C++."); } //args_RedoList = true; Console.WriteLine("Arguments: Rebuild texture list for C++."); // Compiler shaders List <string> ShaderFiles = GetFiles(Path.Combine(ContentPath_Source, "Shaders"), true); foreach (var file in ShaderFiles) { string extension = Path.GetExtension(file).ToLower(); // For WiiU if (extension == ".ps") { CompileWiiUShader(file, Path.ChangeExtension(file, ".vs")); } // For PC C++ if (extension == ".ps" || extension == ".vs") { CopyIfNewer(file, ChangeRootDirectory(file, ContentPath_Source, ContentPath_PC_CPlusPlus)); } // For Xbox if (extension == ".fx") { CopyIfNewer(file, ChangeRootDirectory(file, ContentPath_Source, ContentPath_Xbox)); } // For PS3 if (extension == ".fx") { CompilePS3Shader(file); } // Delete intermediate files var shader_intermediates = GetFiles(Path.Combine(ContentPath_PS3, "Shaders"), true); foreach (var _file in shader_intermediates) { string ext = Path.GetExtension(_file); if (ext == ".vpo" || ext == ".fpo") { File.Delete(_file); } } } // Convert language excel file to unicode tsv ConvertMasterLocalization(); // Get texture asset list string proj = Path.Combine(ContentPath_Source, @"Proj.xlsx"); bool UpdateLoadList = args_RedoAll || args_RedoList || Date(LoadListPath_Cpp) < Date(proj); string connection = string.Format("Provider=Microsoft.ACE.OLEDB.12.0;Data Source={0}; Extended Properties=Excel 12.0;", proj); var adapter = new OleDbDataAdapter("SELECT * FROM [Files$]", connection); var ds = new DataSet(); adapter.Fill(ds); var table = ds.Tables["Table"]; var data = table.AsEnumerable(); foreach (var d in data) { AssetInfo asset = new AssetInfo(); asset.FilePath = (string)d.ItemArray[16]; asset.FilePath = asset.FilePath.Replace('/', '\\'); asset.Priority = (double)d.ItemArray[15]; // Get defaults AssetInfo_Single Default = new AssetInfo_Single(); ParseAsset(ref Default, ref Default, d.ItemArray[12], d.ItemArray[13], d.ItemArray[14]); asset.VideoMemory = ((string)d.ItemArray[17]) == "Yes"; // Xbox ParseAsset(ref asset.Xbox, ref Default, d.ItemArray[0], d.ItemArray[1], d.ItemArray[2]); if (asset.Xbox.Include) { XboxFiles.Add(asset.FilePath); } // PS3 ParseAsset(ref asset.PS3, ref Default, d.ItemArray[3], d.ItemArray[4], d.ItemArray[5]); if (asset.PS3.Include) { PS3Files.Add(asset.FilePath); } // WiiU ParseAsset(ref asset.WiiU, ref Default, d.ItemArray[6], d.ItemArray[7], d.ItemArray[8]); if (asset.WiiU.Include) { WiiUFiles.Add(asset.FilePath); } // PC ParseAsset(ref asset.PC, ref Default, d.ItemArray[9], d.ItemArray[10], d.ItemArray[11]); if (asset.PC.Include) { PCFiles.Add(asset.FilePath); } if (UpdateLoadList) { var size = Load(Path.Combine(ContentPath_Source, asset.FilePath + ".png")).Size; asset.Width = size.Width; asset.Height = size.Height; } TextureAssets.Add(asset); } // Make texture list if (UpdateLoadList) { TextureAssets.Sort((A, B) => A.Priority.CompareTo(B.Priority)); string TextureList_Xbox = "", TextureList_CSharpPC = ""; int count_xbox = 0, count_pc = 0; foreach (var _file in TextureAssets) { if (!_file.FilePath.Contains("Art")) { continue; } var path = _file.FilePath; var name = StripPath(path); var lowerpath = path.ToLower(CultureInfo.InvariantCulture); var lowername = name.ToLower(CultureInfo.InvariantCulture); var bigname = GetFileBigName(path).ToLower(CultureInfo.InvariantCulture); var folder = FirstFolder(path, "Art\\"); if (_file.Xbox.Include) { count_xbox++; var line = string.Format( "Tools.TextureWad.AddTexture_Fast(null, \"{0}\", {4}, {5}, \"{1}\", \"{2}\", \"{3}\"); // {6}\n", EscapeBackslashes(path), EscapeBackslashes(name), EscapeBackslashes(lowername), EscapeBackslashes(folder), _file.Width, _file.Height, count_xbox); TextureList_Xbox += line; } if (_file.PC.Include) { count_pc++; var line = string.Format( "Tools.TextureWad.AddTexture_Fast(null, \"{0}\", {4}, {5}, \"{1}\", \"{2}\", \"{3}\"); // {6}\n", EscapeBackslashes(path), EscapeBackslashes(name), EscapeBackslashes(lowername), EscapeBackslashes(folder), _file.Width, _file.Height, count_pc); TextureList_CSharpPC += line; } } TextureList_Xbox = string.Format(LoadListTemplate_CSharp, TextureList_Xbox); File.WriteAllText(LoadListPath_Xbox, TextureList_Xbox); TextureList_CSharpPC = string.Format(LoadListTemplate_CSharp, TextureList_CSharpPC); File.WriteAllText(LoadListPath_CSharpPC, TextureList_CSharpPC); string TextureList_PS3 = ""; string TextureList_Width_PS3 = ""; string TextureList_Height_PS3 = ""; string TextureList_VideoMemory = ""; foreach (var file in TextureAssets) { if (file.PS3.Include) { if (!file.FilePath.Contains("Art")) { continue; } //if (!file.FilePath.Contains("Art") && !file.FilePath.Contains("Font")) continue; TextureList_PS3 += string.Format("L\"{0}\",\n", file.FilePath.Replace("\\", "/")); TextureList_Width_PS3 += string.Format("{0},\n", file.Width); TextureList_Height_PS3 += string.Format("{0},\n", file.Height); TextureList_VideoMemory += string.Format("{0},\n", file.VideoMemory ? "true" : "false"); } } TextureList_PS3 = string.Format(LoadListTemplate_SingleBuild_Cpp, TextureList_PS3, TextureList_Width_PS3, TextureList_Height_PS3); TextureList_VideoMemory = string.Format(LoadListTemplate_VideoMemory, TextureList_VideoMemory); string TextureList_WiiU = ""; string TextureList_Width_WiiU = ""; string TextureList_Height_WiiU = ""; foreach (var file in TextureAssets) { if (file.WiiU.Include) { if (!file.FilePath.Contains("Art") && !file.FilePath.Contains("Font")) { continue; } TextureList_WiiU += string.Format("L\"{0}\",\n", file.FilePath.Replace("\\", "/")); TextureList_Width_WiiU += string.Format("{0},\n", file.Width); TextureList_Height_WiiU += string.Format("{0},\n", file.Height); } } TextureList_WiiU = string.Format(LoadListTemplate_SingleBuild_Cpp, TextureList_WiiU, TextureList_Width_WiiU, TextureList_Height_WiiU); string TextureList_PC = ""; string TextureList_Width_PC = ""; string TextureList_Height_PC = ""; foreach (var file in TextureAssets) { if (file.PC.Include) { if (!file.FilePath.Contains("Art") && !file.FilePath.Contains("Font")) { continue; } TextureList_PC += string.Format("L\"{0}\",\n", file.FilePath.Replace("\\", "/")); TextureList_Width_PC += string.Format("{0},\n", file.Width); TextureList_Height_PC += string.Format("{0},\n", file.Height); } } TextureList_PC = string.Format(LoadListTemplate_SingleBuild_Cpp, TextureList_PC, TextureList_Width_PC, TextureList_Height_PC); string TextureList = string.Format(LoadListTemplate_Cpp, TextureList_PS3, TextureList_WiiU, TextureList_PC, TextureList_VideoMemory); File.WriteAllText(LoadListPath_Cpp, TextureList); } // Get non-texture assets List <string> Files = GetFiles(ContentPath_Source, true); foreach (var file in Files) { if (file.Contains("__ContentBuilder")) { continue; } string extension = Path.GetExtension(file).ToLower(); if (FileTypes.Contains(extension)) { string relative_path = file.Replace(ContentPath_Source, ""); string xbox_dest = Path.Combine(ContentPath_Xbox, relative_path); CopyIfNewer(file, xbox_dest); XboxFiles.Add(relative_path); string wiiu_dest = Path.Combine(ContentPath_WiiU, relative_path); CopyIfNewer(file, wiiu_dest); WiiUFiles.Add(relative_path); string ps3_dest = Path.Combine(ContentPath_PS3, relative_path); CopyIfNewer(file, ps3_dest); PS3Files.Add(relative_path); string pc_dest = Path.Combine(ContentPath_PC, relative_path); CopyIfNewer(file, pc_dest); string pc_cplusplus_dest = Path.Combine(ContentPath_PC_CPlusPlus, relative_path); CopyIfNewer(file, pc_cplusplus_dest); PCFiles.Add(relative_path); } } // Remove files in destination folders that don't exist anymore. RemoveFiles(ContentPath_Xbox, XboxFiles); RemoveFiles(ContentPath_PS3, PS3Files); RemoveFiles(ContentPath_WiiU, WiiUFiles); RemoveFiles(ContentPath_PC_CPlusPlus, PCFiles); RemoveFiles(ContentPath_PC, PCFiles); // Convert and place all texture assets foreach (var asset in TextureAssets) { string source = SourcePath(asset.FilePath); string temp_premult = TempPremultPath(asset.FilePath); string temp_dds = TempDDSPath(asset.FilePath); DateTime source_date = Date(source); string path_xbox_dds = GetPath_Xbox_DDS(asset.FilePath); string path_ps3_gtf = GetPath_PS3_GTF(asset.FilePath); string path_wiiu_gtx = GetPath_WiiU_GTX(asset.FilePath); string path_pc_cplusplus_png = GetPath_PC_CPlusPlus_PNG(asset.FilePath); string path_pc_dds = GetPath_PC_DDS(asset.FilePath); bool Cascade = false; if (args_RedoAll || Date(temp_premult) < Date(source)) { ConvertToPremultiplied(source, temp_premult); Cascade = true; } if (asset.Xbox.Include) { if (args_RedoAll || args_RedoDDS || Cascade || Date(path_xbox_dds) < source_date) { ConvertToDds(asset.Xbox, temp_premult, temp_dds); Copy(temp_dds, path_xbox_dds); } } if (asset.PC.Include) { if (args_RedoAll || Cascade || Date(path_pc_cplusplus_png) < source_date) { Copy(temp_premult, path_pc_cplusplus_png); } } if (asset.PC.Include) { if (args_RedoAll || args_RedoDDS || Cascade || Date(path_pc_dds) < source_date) { ConvertToDds(asset.PC, temp_premult, temp_dds); Copy(temp_dds, path_pc_dds); } } if (asset.PS3.Include) { if (args_RedoAll || args_RedoDDS || Cascade || Date(path_ps3_gtf) < source_date) { string temp_premult_ps3 = temp_premult; // If the PNG is uncompressed RGBA and doesn't have an even width, pad the width bool pad = false; if (asset.PS3.Format == "Raw Rgba" && asset.GetWidth() % 2 == 1) { pad = true; } if (pad) { temp_premult_ps3 = Path.Combine(Path.GetDirectoryName(temp_premult), Path.GetFileNameWithoutExtension(temp_premult) + " (width padded).png"); PadPngWidth(temp_premult, temp_premult_ps3); } ConvertToDds(asset.PS3, temp_premult_ps3, temp_dds); ConvertToGtf(temp_dds, path_ps3_gtf); if (pad) { ChangeGtfWidth(path_ps3_gtf, asset.Width); } } } if (asset.WiiU.Include) { if (args_RedoAll || args_RedoDDS || Cascade || Date(path_wiiu_gtx) < source_date) { ConvertToDds(asset.WiiU, temp_premult, temp_dds); ConvertToGtx(temp_dds, path_wiiu_gtx); } } } Console.WriteLine("Done!"); }
static void ParseAsset(ref AssetInfo_Single dest, ref AssetInfo_Single _default, object cell1, object cell2, object cell3) { dest.Include = (string)cell1 == " " ? _default.Include : (string)cell1 == "Include"; dest.Format = (string)cell2 == " " ? _default.Format : (string)cell2; dest.Mipmap = (string)cell3 == " " ? _default.Mipmap : (string)cell3 == "Yes"; }