2
0
Fork 0
mirror of https://github.com/KillzXGaming/Switch-Toolbox synced 2025-02-03 07:43:26 +00:00

BYAML : Some yaml tag fixes

This commit is contained in:
KillzXGaming 2020-04-16 17:19:23 -04:00
parent 224972df98
commit d5f2d60bfa
2 changed files with 39003 additions and 14 deletions
File_Format_Library/FileFormats/Byaml
Toolbox/Hashes

View file

@ -113,7 +113,14 @@ namespace FirstPlugin
ReferenceNodes.Add(node.Tag, values);
foreach (var child in ((YamlMappingNode)node).Children)
values.Add(((YamlScalarNode)child.Key).Value, ParseNode(child.Value));
{
var key = ((YamlScalarNode)child.Key).Value;
var tag = ((YamlScalarNode)child.Key).Tag;
if (tag == "!h")
key = Crc32.Compute(key).ToString("x");
values.Add(key, ParseNode(child.Value));
}
return values;
}
else if (node is YamlSequenceNode) {
@ -175,16 +182,7 @@ namespace FirstPlugin
bool isFloat = float.TryParse(value, out floatValue);
if (isFloat)
return floatValue;
else
{
if (BYAML.IsHash(value))
{
uint hash = Convert.ToUInt32(value, 16);
if (BYAML.Hashes.ContainsKey(hash))
return $"!h {BYAML.Hashes[hash]}";
}
return value;
}
return value;
}
}
@ -225,13 +223,17 @@ namespace FirstPlugin
foreach (var item in (IDictionary<string, dynamic>)node)
{
string key = item.Key;
YamlNode keyNode = new YamlScalarNode(key);
if (BYAML.IsHash(key))
{
uint hash = Convert.ToUInt32(key, 16);
if (BYAML.Hashes.ContainsKey(hash))
key = $"!h {BYAML.Hashes[hash]}";
key = $"{BYAML.Hashes[hash]}";
keyNode = new YamlScalarNode(key);
keyNode.Tag = "!h";
}
yamlNode.Add(key, SaveNode(item.Key, item.Value));
yamlNode.Add(keyNode, SaveNode(item.Key, item.Value));
}
return yamlNode;
}

File diff suppressed because one or more lines are too long