1
0
mirror of synced 2025-01-19 09:17:30 +01:00

SHARCFB : Fixes to variation value parsing.

This commit is contained in:
KillzXGaming 2021-02-21 13:04:57 -05:00
parent d8da7f0e3f
commit 0db9434041
2 changed files with 15 additions and 18 deletions

View File

@ -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<string> 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);
}

View File

@ -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);