Skip to content

Commit

Permalink
feat: handle output pins
Browse files Browse the repository at this point in the history
  • Loading branch information
Notexe committed Feb 4, 2024
1 parent 03383a9 commit e2a5bd6
Show file tree
Hide file tree
Showing 2 changed files with 80 additions and 15 deletions.
12 changes: 12 additions & 0 deletions G2GFxDataTool/Helpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,5 +59,17 @@ internal static string UIControlPathDeriver(string inputPath, string className)
}
}

internal static bool IsOutputPin(string methodName, out string pinName)
{
if (methodName.ToLower().StartsWith("send_"))
{
pinName = methodName.Substring("send_".Length);
return true;
}

pinName = "";
return false;
}

}
}
83 changes: 68 additions & 15 deletions G2GFxDataTool/UIControlWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,41 +14,94 @@ internal class UIControlWriter
{ "Object", "E_ATTRIBUTE_TYPE_OBJECT" }
};

internal class UICBData
{
public List<Pin> Pins { get; set; }
public List<Property> Properties { get; set; }

public UICBData()
{
Pins = new List<Pin>();
Properties = new List<Property>();
}
}

internal class Pin
{
public string Name { get; set; }
public string m_eKind { get; set; } = "E_ATTRIBUTE_KIND_INPUT_PIN";
public string m_eType { get; set; }
}

internal class Property
{
public string Name { get; set; }
public string m_eKind { get; set; } = "E_ATTRIBUTE_KIND_PROPERTY";
public string m_eType { get; set; }
public int m_nPropertyOffset { get; set; } = 0;
public int m_nPropertyId { get; set; } = 0;
}

internal static void WriteUIControl(string inputPath, string outputPath)
{
var definitions = ParseSWF.ParseAS(inputPath);

foreach (var definition in definitions)
{
var uicbData = new
UICBData data = new UICBData();

foreach (var method in definition.classMethods)
{
m_aPins = definition.classMethods.Select(method => new

if (method.argumentTypes.Count > 1 || (method.argumentTypes.Count == 1 && !typeMapping.ContainsKey(method.argumentTypes[0])))
{
continue;
}

Pin pins = new Pin
{
Name = method.methodName,
m_eKind = "E_ATTRIBUTE_KIND_INPUT_PIN",
m_eType = method.argumentTypes != null && method.argumentTypes.Count == 1
? typeMapping.GetValueOrDefault(method.argumentTypes[0], "E_ATTRIBUTE_TYPE_VOID")
: "E_ATTRIBUTE_TYPE_VOID",
m_sName = method.methodName
}).ToList(),
m_aProperties = definition.classProperties.Select(prop => new
m_eType = "E_ATTRIBUTE_TYPE_VOID",
};

if (Helpers.IsOutputPin(method.methodName, out string pinName))
{
pins.Name = pinName;
pins.m_eKind = "E_ATTRIBUTE_KIND_OUTPUT_PIN";
}

if (method.argumentTypes.Count == 1)
{
pins.m_eType = typeMapping.GetValueOrDefault(method.argumentTypes[0]);
}

data.Pins.Add(pins);
}

foreach (var property in definition.classProperties)
{
Property properties = new Property
{
eKind = "E_ATTRIBUTE_KIND_PROPERTY",
eType = typeMapping.GetValueOrDefault(prop.classPropertyType, "E_ATTRIBUTE_TYPE_OBJECT"),
m_sName = prop.classPropertyName,
Name = property.classPropertyName,
m_eKind = "E_ATTRIBUTE_KIND_PROPERTY",
m_eType = typeMapping.GetValueOrDefault(property.classPropertyType),
m_nPropertyOffset = 0,
m_nPropertyId = 0
}).ToList()
};
};

data.Properties.Add(properties);
}

string uictAssemblyPath = Helpers.UIControlPathDeriver(inputPath, definition.className) + "entitytype";
string uicbAssemblyPath = Helpers.UIControlPathDeriver(inputPath, definition.className) + "entityblueprint";

string uictAssemblyPathHash = Helpers.ConvertStringtoMD5(uictAssemblyPath);
string uicbAssemblyPathHash = Helpers.ConvertStringtoMD5(uicbAssemblyPath);

Program.logUIControlPaths.Add(definition.className + ":");
Program.logUIControlPaths.Add(uictAssemblyPathHash + ".UICT," + uictAssemblyPath);
Program.logUIControlPaths.Add(uicbAssemblyPathHash + ".UICB," + uicbAssemblyPath);
Program.logUIControlPaths.Add(uicbAssemblyPathHash + ".UICB," + uicbAssemblyPath + "\r\n");

MetaFiles.MetaData uictMetaData = new MetaFiles.MetaData();
uictMetaData.hashValue = uictAssemblyPathHash;
Expand Down Expand Up @@ -90,7 +143,7 @@ internal static void WriteUIControl(string inputPath, string outputPath)
MetaFiles.GenerateMeta(ref uictMetaData, Path.Combine(outputPath, uictAssemblyPathHash + ".UICT.meta.json"));
MetaFiles.GenerateMeta(ref uicbMetaData, Path.Combine(outputPath, uicbAssemblyPathHash + ".UICB.meta.json"));

string jsonData = JsonSerializer.Serialize(uicbData);
string jsonData = JsonSerializer.Serialize(data);

File.Create(Path.Combine(outputPath, uictAssemblyPathHash + ".UICT"));
File.WriteAllText(Path.Combine(outputPath, uicbAssemblyPathHash + ".UICB.json"), jsonData);
Expand Down

0 comments on commit e2a5bd6

Please sign in to comment.