Add yucky textrepl parsing

This commit is contained in:
Jarrod Doyle 2024-08-31 09:34:18 +01:00
parent 81fde92ea4
commit 5d23f87359
Signed by: Jayrude
GPG Key ID: 38B57B16E7C0ADF7
3 changed files with 47 additions and 0 deletions

View File

@ -93,3 +93,14 @@ public class PropRenderType : Property
mode = (Mode)reader.ReadUInt32(); mode = (Mode)reader.ReadUInt32();
} }
} }
public class PropString : Property
{
public string value;
public override void Read(BinaryReader reader)
{
base.Read(reader);
value = Encoding.UTF8.GetString(reader.ReadBytes(length)).Replace("\0", string.Empty);
}
}

View File

@ -105,6 +105,10 @@ public class DbFile
"P$ModelName" => new PropertyChunk<PropModelName>(), "P$ModelName" => new PropertyChunk<PropModelName>(),
"P$Scale" => new PropertyChunk<PropScale>(), "P$Scale" => new PropertyChunk<PropScale>(),
"P$RenderTyp" => new PropertyChunk<PropRenderType>(), "P$RenderTyp" => new PropertyChunk<PropRenderType>(),
"P$OTxtRepr0" => new PropertyChunk<PropString>(),
"P$OTxtRepr1" => new PropertyChunk<PropString>(),
"P$OTxtRepr2" => new PropertyChunk<PropString>(),
"P$OTxtRepr3" => new PropertyChunk<PropString>(),
"LD$MetaProp" => new LinkDataMetaProp(), "LD$MetaProp" => new LinkDataMetaProp(),
_ when entryName.StartsWith("L$") => new LinkChunk(), _ when entryName.StartsWith("L$") => new LinkChunk(),
_ when entryName.StartsWith("P$") => new PropertyChunk<PropGeneric>(), _ when entryName.StartsWith("P$") => new PropertyChunk<PropGeneric>(),

View File

@ -38,12 +38,20 @@ public class ObjectHierarchy
if (db.Chunks.TryGetValue("P$ModelName", out var modelNamesRaw) && if (db.Chunks.TryGetValue("P$ModelName", out var modelNamesRaw) &&
db.Chunks.TryGetValue("P$Scale", out var scalesRaw) && db.Chunks.TryGetValue("P$Scale", out var scalesRaw) &&
db.Chunks.TryGetValue("P$RenderTyp", out var renderTypesRaw) && db.Chunks.TryGetValue("P$RenderTyp", out var renderTypesRaw) &&
db.Chunks.TryGetValue("P$OTxtRepr0", out var txtRepl0Raw) &&
db.Chunks.TryGetValue("P$OTxtRepr1", out var txtRepl1Raw) &&
db.Chunks.TryGetValue("P$OTxtRepr2", out var txtRepl2Raw) &&
db.Chunks.TryGetValue("P$OTxtRepr3", out var txtRepl3Raw) &&
db.Chunks.TryGetValue("L$MetaProp", out var metaPropLinksRaw) && db.Chunks.TryGetValue("L$MetaProp", out var metaPropLinksRaw) &&
db.Chunks.TryGetValue("LD$MetaProp", out var metaPropLinkDataRaw)) db.Chunks.TryGetValue("LD$MetaProp", out var metaPropLinkDataRaw))
{ {
var modelNames = (PropertyChunk<PropModelName>)modelNamesRaw; var modelNames = (PropertyChunk<PropModelName>)modelNamesRaw;
var scales = (PropertyChunk<PropScale>)scalesRaw; var scales = (PropertyChunk<PropScale>)scalesRaw;
var renderTypes = (PropertyChunk<PropRenderType>)renderTypesRaw; var renderTypes = (PropertyChunk<PropRenderType>)renderTypesRaw;
var txtRepl0s = (PropertyChunk<PropString>)txtRepl0Raw;
var txtRepl1s = (PropertyChunk<PropString>)txtRepl1Raw;
var txtRepl2s = (PropertyChunk<PropString>)txtRepl2Raw;
var txtRepl3s = (PropertyChunk<PropString>)txtRepl3Raw;
var metaPropLinks = (LinkChunk)metaPropLinksRaw; var metaPropLinks = (LinkChunk)metaPropLinksRaw;
var metaPropLinkData = (LinkDataMetaProp)metaPropLinkDataRaw; var metaPropLinkData = (LinkDataMetaProp)metaPropLinkDataRaw;
@ -52,12 +60,20 @@ public class ObjectHierarchy
gam.Chunks.TryGetValue("P$ModelName", out var gamModelNames) && gam.Chunks.TryGetValue("P$ModelName", out var gamModelNames) &&
gam.Chunks.TryGetValue("P$Scale", out var gamScales) && gam.Chunks.TryGetValue("P$Scale", out var gamScales) &&
gam.Chunks.TryGetValue("P$RenderTyp", out var gamRenderTypes) && gam.Chunks.TryGetValue("P$RenderTyp", out var gamRenderTypes) &&
gam.Chunks.TryGetValue("P$OTxtRepr0", out var gamTxtRepl0s) &&
gam.Chunks.TryGetValue("P$OTxtRepr1", out var gamTxtRepl1s) &&
gam.Chunks.TryGetValue("P$OTxtRepr2", out var gamTxtRepl2s) &&
gam.Chunks.TryGetValue("P$OTxtRepr3", out var gamTxtRepl3s) &&
gam.Chunks.TryGetValue("L$MetaProp", out var gamLinks) && gam.Chunks.TryGetValue("L$MetaProp", out var gamLinks) &&
gam.Chunks.TryGetValue("LD$MetaProp", out var gamLinkData)) gam.Chunks.TryGetValue("LD$MetaProp", out var gamLinkData))
{ {
modelNames.properties.AddRange(((PropertyChunk<PropModelName>)gamModelNames).properties); modelNames.properties.AddRange(((PropertyChunk<PropModelName>)gamModelNames).properties);
scales.properties.AddRange(((PropertyChunk<PropScale>)gamScales).properties); scales.properties.AddRange(((PropertyChunk<PropScale>)gamScales).properties);
renderTypes.properties.AddRange(((PropertyChunk<PropRenderType>)gamRenderTypes).properties); renderTypes.properties.AddRange(((PropertyChunk<PropRenderType>)gamRenderTypes).properties);
txtRepl0s.properties.AddRange(((PropertyChunk<PropString>)gamTxtRepl0s).properties);
txtRepl1s.properties.AddRange(((PropertyChunk<PropString>)gamTxtRepl1s).properties);
txtRepl2s.properties.AddRange(((PropertyChunk<PropString>)gamTxtRepl2s).properties);
txtRepl3s.properties.AddRange(((PropertyChunk<PropString>)gamTxtRepl3s).properties);
metaPropLinks.links.AddRange(((LinkChunk)gamLinks).links); metaPropLinks.links.AddRange(((LinkChunk)gamLinks).links);
metaPropLinkData.linkData.AddRange(((LinkDataMetaProp)gamLinkData).linkData); metaPropLinkData.linkData.AddRange(((LinkDataMetaProp)gamLinkData).linkData);
} }
@ -108,6 +124,22 @@ public class ObjectHierarchy
{ {
TryAddProp("P$RenderTyp", prop); TryAddProp("P$RenderTyp", prop);
} }
foreach (var prop in txtRepl0s.properties)
{
TryAddProp("P$OTxtRepr0", prop);
}
foreach (var prop in txtRepl1s.properties)
{
TryAddProp("P$OTxtRepr1", prop);
}
foreach (var prop in txtRepl2s.properties)
{
TryAddProp("P$OTxtRepr2", prop);
}
foreach (var prop in txtRepl3s.properties)
{
TryAddProp("P$OTxtRepr3", prop);
}
} }
} }