From f8eae8d3bc93c45b424d43aed2431572b589752f Mon Sep 17 00:00:00 2001 From: Arne Kiesewetter Date: Tue, 5 Jul 2022 22:47:48 +0200 Subject: [PATCH] Add Rect to primitives. Add text padding to display. Fix display patching logixnode's generate visual. --- LogixVisualCustomizer/DisplayPatches.cs | 7 ++++++- LogixVisualCustomizer/LogixVisualCustomizer.cs | 5 +++-- LogixVisualCustomizer/Properties/AssemblyInfo.cs | 4 ++-- LogixVisualCustomizer/TextFieldPatch.cs | 6 +----- 4 files changed, 12 insertions(+), 10 deletions(-) diff --git a/LogixVisualCustomizer/DisplayPatches.cs b/LogixVisualCustomizer/DisplayPatches.cs index 156e30a..3fa5c0f 100644 --- a/LogixVisualCustomizer/DisplayPatches.cs +++ b/LogixVisualCustomizer/DisplayPatches.cs @@ -39,11 +39,16 @@ private static void createAlphaRemovalLogix(Slot root, Sync source, Sync< private static void OnGenerateVisualPostfix(LogixNode __instance, Slot root) { var type = __instance.GetType(); - root.ForeachComponentInChildren(VisualCustomizing.CustomizeDisplay); // Only create special display for color if (type != colorType) + { + root.GetComponentsInChildren().ForEach(VisualCustomizing.CustomizeLabel); + return; + } + + root.ForeachComponentInChildren(VisualCustomizing.CustomizeDisplay); var colorDisplayRoot = root.GetComponentInChildren().Slot; var alphaColorImage = colorDisplayRoot.GetComponentInChildren(); diff --git a/LogixVisualCustomizer/LogixVisualCustomizer.cs b/LogixVisualCustomizer/LogixVisualCustomizer.cs index 20ccd5c..e1448af 100644 --- a/LogixVisualCustomizer/LogixVisualCustomizer.cs +++ b/LogixVisualCustomizer/LogixVisualCustomizer.cs @@ -98,7 +98,7 @@ public class LogixVisualCustomizer : NeosMod public override string Author => "Banane9"; public override string Link => "https://github.com/Banane9/NeosLogixVisualCustomizer"; public override string Name => "LogixVisualCustomizer"; - public override string Version => "1.0.1"; + public override string Version => "1.1.0"; internal static float4 BackgroundHorizontalSlices => UseBackground ? Config.GetValue(BackgroundHorizontalSlicesKey) : defaultSlices; internal static Uri BackgroundSpriteUri => UseBackground ? Config.GetValue(BackgroundSpriteUriKey) : null; internal static float4 BackgroundVerticalSlices => UseBackground ? Config.GetValue(BackgroundVerticalSlicesKey) : defaultSlices; @@ -160,6 +160,7 @@ static LogixVisualCustomizer() NeosPrimitiveTypes = traverse.Field("neosPrimitives").Value .Where(type => type.Name != "String") + .AddItem(typeof(Rect)) .AddItem(typeof(dummy)) .AddItem(typeof(object)) .ToArray(); @@ -206,7 +207,7 @@ public static IEnumerable GenerateMethodTargets(string methodName, p public static IEnumerable GenerateMethodTargets(string methodName, IEnumerable baseTypes) { - return baseTypes.Select(type => type.GetMethod(methodName, AccessTools.all)).Where(m => m != null); + return baseTypes.Select(type => type.GetMethod(methodName, AccessTools.allDeclared)).Where(m => m != null); } public override void OnEngineInit() diff --git a/LogixVisualCustomizer/Properties/AssemblyInfo.cs b/LogixVisualCustomizer/Properties/AssemblyInfo.cs index 91ab018..0ff9d94 100644 --- a/LogixVisualCustomizer/Properties/AssemblyInfo.cs +++ b/LogixVisualCustomizer/Properties/AssemblyInfo.cs @@ -31,5 +31,5 @@ // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.1.0")] -[assembly: AssemblyFileVersion("1.0.1.0")] \ No newline at end of file +[assembly: AssemblyVersion("1.1.0.0")] +[assembly: AssemblyFileVersion("1.1.0.0")] \ No newline at end of file diff --git a/LogixVisualCustomizer/TextFieldPatch.cs b/LogixVisualCustomizer/TextFieldPatch.cs index 66c6fb9..f6175ff 100644 --- a/LogixVisualCustomizer/TextFieldPatch.cs +++ b/LogixVisualCustomizer/TextFieldPatch.cs @@ -21,11 +21,7 @@ internal static class TextFieldPatch public static void Patch(Harmony harmony) { - var genericTypes = Traverse.Create(typeof(GenericTypes)).Field("neosPrimitives").Value - .Where(type => type.Name != "String") - .AddItem(typeof(object)); - - foreach (var type in genericTypes) + foreach (var type in LogixVisualCustomizer.NeosPrimitiveTypes) { var createdType = textFieldNodeBaseType.MakeGenericType(type); var methodInfo = createdType.GetMethod("OnGenerateVisual", AccessTools.allDeclared);