Skip to content

Commit

Permalink
Add Rect to primitives. Add text padding to display. Fix display patc…
Browse files Browse the repository at this point in the history
…hing logixnode's generate visual.
  • Loading branch information
Banane9 committed Jul 5, 2022
1 parent bd422d6 commit f8eae8d
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 10 deletions.
7 changes: 6 additions & 1 deletion LogixVisualCustomizer/DisplayPatches.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,16 @@ private static void createAlphaRemovalLogix(Slot root, Sync<color> source, Sync<
private static void OnGenerateVisualPostfix(LogixNode __instance, Slot root)
{
var type = __instance.GetType();
root.ForeachComponentInChildren<Text>(VisualCustomizing.CustomizeDisplay);

// Only create special display for color
if (type != colorType)
{
root.GetComponentsInChildren<Text>().ForEach(VisualCustomizing.CustomizeLabel);

return;
}

root.ForeachComponentInChildren<Text>(VisualCustomizing.CustomizeDisplay);

var colorDisplayRoot = root.GetComponentInChildren<HorizontalLayout>().Slot;
var alphaColorImage = colorDisplayRoot.GetComponentInChildren<Image>();
Expand Down
5 changes: 3 additions & 2 deletions LogixVisualCustomizer/LogixVisualCustomizer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -160,6 +160,7 @@ static LogixVisualCustomizer()

NeosPrimitiveTypes = traverse.Field<Type[]>("neosPrimitives").Value
.Where(type => type.Name != "String")
.AddItem(typeof(Rect))
.AddItem(typeof(dummy))
.AddItem(typeof(object))
.ToArray();
Expand Down Expand Up @@ -206,7 +207,7 @@ public static IEnumerable<MethodBase> GenerateMethodTargets(string methodName, p

public static IEnumerable<MethodBase> GenerateMethodTargets(string methodName, IEnumerable<Type> 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()
Expand Down
4 changes: 2 additions & 2 deletions LogixVisualCustomizer/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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")]
[assembly: AssemblyVersion("1.1.0.0")]
[assembly: AssemblyFileVersion("1.1.0.0")]
6 changes: 1 addition & 5 deletions LogixVisualCustomizer/TextFieldPatch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,7 @@ internal static class TextFieldPatch

public static void Patch(Harmony harmony)
{
var genericTypes = Traverse.Create(typeof(GenericTypes)).Field<Type[]>("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);
Expand Down

0 comments on commit f8eae8d

Please sign in to comment.