From 182b8506155593a32ba20cc1e10a52def65371c5 Mon Sep 17 00:00:00 2001 From: Samuele Lorefice Date: Mon, 25 Dec 2023 16:38:18 +0100 Subject: [PATCH] added collection of widget options during the node DB generation --- ComfySharp/NodeDBGenerator.cs | 11 +++++++++-- ComfySharp/Types/HistoryEntry.cs | 1 + 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/ComfySharp/NodeDBGenerator.cs b/ComfySharp/NodeDBGenerator.cs index 50f0f24..2f06fb9 100644 --- a/ComfySharp/NodeDBGenerator.cs +++ b/ComfySharp/NodeDBGenerator.cs @@ -29,6 +29,7 @@ public class NodeDBGenerator { private int typeFields; private int enumFields; private int stringListFields; + private List widgetEntries = new(); #endregion #region CodeGeneration @@ -132,6 +133,10 @@ public class NodeDBGenerator { Logger.Trace($"List of recognized Enums: {enums}"); Logger.Info($"Total amount of enums detected\\iterated:\t\t {knownEnums.Count}\t\\{enumFields}"); Logger.Info($"Total amount of stringLists detected\\iterated:\t {knownStringLists.Count}\t\\{knownStringLists.Count}"); + + string widgets = ""; + foreach (var entry in widgetEntries) widgets += $"\t{entry}"; + Logger.Info($"Possible Widget Properties: {widgets}"); Logger.Info("NodeDB Scan phase 2: generating types"); timer.Restart(); @@ -153,8 +158,6 @@ public class NodeDBGenerator { codeNamespace.Imports.AddRange(new CodeNamespaceImport[] { new ("System"), new ("System.Collections.Generics"), new ("ComfySharp") }); } - - private void GenerateEnum(string name, List enumValues, CodeNamespace ns) { string path = Path.Combine(Environment.CurrentDirectory, settings.CodeOutputFolderName, $"{name}.cs"); @@ -229,6 +232,10 @@ public class NodeDBGenerator { // if element 0 is a string, this is a type if (inputProperty.Value[0].ValueKind == JsonValueKind.String) { AddKnownType(inputProperty.Value[0].ToString()); + if (inputProperty.Value.GetArrayLength() > 1 && inputProperty.Value[1].EnumerateObject().Count() > 1) + foreach (var widgetEntry in inputProperty.Value[1].EnumerateObject()) + if(!widgetEntries.Contains(widgetEntry.Name)) + widgetEntries.Add(widgetEntry.Name); return; } diff --git a/ComfySharp/Types/HistoryEntry.cs b/ComfySharp/Types/HistoryEntry.cs index d917582..0b2f610 100644 --- a/ComfySharp/Types/HistoryEntry.cs +++ b/ComfySharp/Types/HistoryEntry.cs @@ -1,4 +1,5 @@ namespace ComfySharp.Types; public class HistoryEntry { + //TODO: this is just a stub, fill it in } \ No newline at end of file