コード例 #1
0
ファイル: SaveTex.cs プロジェクト: viion-misc/FFXIV_TexTools2
        /// <summary>
        /// Saves the currently displayed texture map as a DDS file.
        /// </summary>
        /// <param name="selectedCategory">The items category.</param>
        /// <param name="selectedItem">The currently selected item.</param>
        /// <param name="internalFilePath">The internal file path of the texture map.</param>
        /// <param name="textureMap">The name of the currently selected texture map.</param>
        /// <param name="mtrlData">The items mtrl file data</param>
        /// <param name="texData">The items tex file data</param>
        public static void SaveDDS(string selectedCategory, string selectedItem, string internalFilePath, string textureMap, MTRLData mtrlData, TEXData texData, string subCategory)
        {
            bool isVFX = internalFilePath.Contains("/vfx/");

            string savePath = "";

            if (selectedCategory.Equals("UI"))
            {
                savePath = Properties.Settings.Default.Save_Directory + "/" + selectedCategory + "/" + subCategory;
            }
            else
            {
                savePath = Properties.Settings.Default.Save_Directory + "/" + selectedCategory + "/" + selectedItem;
            }

            Directory.CreateDirectory(savePath);

            var fullSavePath = Path.Combine(savePath, (Path.GetFileNameWithoutExtension(internalFilePath) + ".dds"));

            List <byte> DDS = new List <byte>();

            if (textureMap.Equals(Strings.ColorSet))
            {
                if (mtrlData.ColorFlags != null)
                {
                    var colorFlagsDir = Path.Combine(savePath, (Path.GetFileNameWithoutExtension(internalFilePath) + ".dat"));
                    File.WriteAllBytes(colorFlagsDir, mtrlData.ColorFlags);
                }

                DDS.AddRange(CreateColorDDSHeader());
                DDS.AddRange(mtrlData.ColorData);
            }
            else if (isVFX)
            {
                DDS.AddRange(CreateDDSHeader(texData));
                DDS.AddRange(TEX.GetRawVFX(texData));
            }
            else
            {
                DDS.AddRange(CreateDDSHeader(texData));
                DDS.AddRange(TEX.TexRawData(texData));
            }

            File.WriteAllBytes(fullSavePath, DDS.ToArray());
        }