diff --git a/File_Format_Library/FileFormats/Shader/SHARC/SHARCFB.cs b/File_Format_Library/FileFormats/Shader/SHARC/SHARCFB.cs index 4e278bdd..accacea9 100644 --- a/File_Format_Library/FileFormats/Shader/SHARC/SHARCFB.cs +++ b/File_Format_Library/FileFormats/Shader/SHARC/SHARCFB.cs @@ -178,7 +178,7 @@ namespace FirstPlugin } public ShaderType Type; - public VariationMacroData variationMacroData; + public VariationSymbolData variationMacroData; public VariationSymbolData variationSymbolData; public ShaderSymbolData UniformVariables; public ShaderSymbolData UniformBlocks; @@ -211,7 +211,7 @@ namespace FirstPlugin Text = reader.ReadString((int)NameLength); - variationMacroData = new VariationMacroData(); + variationMacroData = new VariationSymbolData(); variationSymbolData = new VariationSymbolData(); UniformVariables = new ShaderSymbolData(); UniformBlocks = new ShaderSymbolData(); @@ -392,7 +392,7 @@ namespace FirstPlugin public class VariationSymbol { public string Name { get; set; } - public string DefaultValue { get; set; } + public List Values { get; set; } public string SymbolName { get; set; } public void Read(FileReader reader) @@ -400,17 +400,13 @@ namespace FirstPlugin var pos = reader.Position; uint SectionSize = reader.ReadUInt32(); uint macroNameLength = reader.ReadUInt32(); - uint defaultValueLength = reader.ReadUInt32(); + uint valueLength = reader.ReadUInt32(); uint symbolNameLength = reader.ReadUInt32(); - Name = reader.ReadString((int)macroNameLength); - DefaultValue = reader.ReadString((int)defaultValueLength); - SymbolName = reader.ReadString((int)symbolNameLength); - Console.WriteLine("VariationSymbol ------------------"); - Console.WriteLine(Name); - Console.WriteLine(DefaultValue); - Console.WriteLine(SymbolName); - Console.WriteLine("------------------"); + Name = reader.ReadString((int)macroNameLength, true); + Values = reader.ReadStrings((int)valueLength, Syroot.BinaryData.BinaryStringFormat.ZeroTerminated, Encoding.UTF8).ToList(); + SymbolName = reader.ReadString((int)symbolNameLength, true); + reader.Seek(pos + SectionSize, System.IO.SeekOrigin.Begin); reader.Seek(pos + SectionSize, System.IO.SeekOrigin.Begin); } @@ -418,11 +414,12 @@ namespace FirstPlugin public void Write(FileWriter writer) { var pos = writer.Position; - writer.Write(Name.Length); - writer.Write(DefaultValue.Length); - writer.Write(SymbolName.Length); + writer.Write(Name.Length + 1); + writer.Write(Values.Count + 1); + writer.Write(SymbolName.Length + 1); writer.WriteString(Name); - writer.WriteString(DefaultValue); + for (int i = 0; i < Values.Count; i++) + writer.WriteString(Values[i]); writer.WriteString(SymbolName); SharcCommon.WriteSectionSize(writer, pos); } diff --git a/File_Format_Library/XML/Sharc2XML.cs b/File_Format_Library/XML/Sharc2XML.cs index ea1b5ad9..8797bbd1 100644 --- a/File_Format_Library/XML/Sharc2XML.cs +++ b/File_Format_Library/XML/Sharc2XML.cs @@ -76,7 +76,7 @@ namespace FirstPlugin AddAttribute(doc, "Name", program.Text.Replace("\x00", ""), mainNode); doc.AppendChild(mainNode); - WriteMarcos(doc, program.variationMacroData, "macro_array", mainNode); + WriteVariationSymbols(doc, program.variationMacroData, "macro_array", mainNode); WriteVariationSymbols(doc, program.variationSymbolData, "option_array", mainNode); WriteShaderSymbolData(doc, program.UniformVariables, "Uniform_Variables", mainNode); WriteShaderSymbolData(doc, program.UniformBlocks, "Uniform_Blocks", mainNode); @@ -109,7 +109,7 @@ namespace FirstPlugin XmlNode childNode = doc.CreateElement("option"); AddAttribute(doc, "id", symbol.Name.Replace("\x00", ""), childNode); AddAttribute(doc, "symbol", symbol.SymbolName.Replace("\x00", ""), childNode); - AddAttribute(doc, "default", symbol.DefaultValue.Replace("\x00", ""), childNode); + AddAttribute(doc, "values", string.Join(",", symbol.Values).Replace("\x00", ""), childNode); rootNode.AppendChild(childNode); } node.AppendChild(rootNode);