diff --git a/G2GFxDataTool/Helpers.cs b/G2GFxDataTool/Helpers.cs index 5da34de..eb06456 100644 --- a/G2GFxDataTool/Helpers.cs +++ b/G2GFxDataTool/Helpers.cs @@ -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; + } + } } diff --git a/G2GFxDataTool/UIControlWriter.cs b/G2GFxDataTool/UIControlWriter.cs index 605e3b3..fc3a8ef 100644 --- a/G2GFxDataTool/UIControlWriter.cs +++ b/G2GFxDataTool/UIControlWriter.cs @@ -14,32 +14,84 @@ internal class UIControlWriter { "Object", "E_ATTRIBUTE_TYPE_OBJECT" } }; + internal class UICBData + { + public List Pins { get; set; } + public List Properties { get; set; } + + public UICBData() + { + Pins = new List(); + Properties = new List(); + } + } + + 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"; @@ -47,8 +99,9 @@ internal static void WriteUIControl(string inputPath, string outputPath) 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; @@ -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);