Skip to content

Commit 21cac47

Browse files
committed
Make selection of custom generics in component selectors case-insensitive
Adds a fix for: * Yellow-Dog-Man/Resonite-Issues#620 * Yellow-Dog-Man/Resonite-Issues#636 * Yellow-Dog-Man/Resonite-Issues#4022
1 parent 7057ef9 commit 21cac47

4 files changed

Lines changed: 60 additions & 2 deletions

File tree

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
using FrooxEngine;
2+
using HarmonyLib;
3+
using MonkeyLoader;
4+
using MonkeyLoader.Meta;
5+
using MonkeyLoader.Patching;
6+
using System;
7+
using System.Collections.Generic;
8+
using System.Reflection;
9+
using System.Text;
10+
11+
// Taken from ComponentSelectorAdditions
12+
// https://github.com/ResoniteModdingGroup/ComponentSelectorAdditions
13+
14+
namespace CommunityBugFixCollection
15+
{
16+
[HarmonyPatch]
17+
[HarmonyPatchCategory(nameof(CaseInsensitiveCustomGenerics))]
18+
internal sealed class CaseInsensitiveCustomGenerics : Monkey<CaseInsensitiveCustomGenerics>
19+
{
20+
public override IEnumerable<string> Authors => Contributors.Banane9;
21+
22+
public override bool CanBeDisabled => true;
23+
24+
protected override bool OnLoaded()
25+
{
26+
if (!Enabled)
27+
return true;
28+
29+
if (Mod.Loader.Get<Mod>().ById("ComponentSelectorAdditions") is not null)
30+
{
31+
Logger.Info(() => "Skipping in favor of the ComponentSelectorAdditions fix.");
32+
return true;
33+
}
34+
35+
GlobalTypeRegistry._nameToSystemType = new(GlobalTypeRegistry._nameToSystemType, StringComparer.OrdinalIgnoreCase);
36+
GlobalTypeRegistry._byName = new(GlobalTypeRegistry._byName, StringComparer.OrdinalIgnoreCase);
37+
38+
return base.OnLoaded();
39+
}
40+
41+
private static void Postfix(AssemblyTypeRegistry __instance)
42+
{
43+
__instance._typesByFullName = new(__instance._typesByFullName, StringComparer.OrdinalIgnoreCase);
44+
__instance._typesByName.dictionary = new(__instance._typesByName.dictionary, StringComparer.OrdinalIgnoreCase);
45+
__instance._movedTypes = new(__instance._movedTypes, StringComparer.OrdinalIgnoreCase);
46+
}
47+
48+
private static IEnumerable<MethodBase> TargetMethods()
49+
=> AccessTools.GetDeclaredConstructors(typeof(AssemblyTypeRegistry), false);
50+
}
51+
}

CommunityBugFixCollection/Locale/de.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
"CommunityBugFixCollection.Name": "Community Bug-Fix Sammlung",
66
"CommunityBugFixCollection.Description": "Diese Mod enthällt Fixes für verschiedene kleine Resonite Issues die noch offen sind.",
77

8-
"CommunityBugFixCollection.CopyToClipboard": "In Zwischenablage kopieren"
8+
"CommunityBugFixCollection.CopyToClipboard": "In Zwischenablage kopieren",
9+
10+
"CommunityBugFixCollection.CaseInsensitiveCustomGenerics.Description": "Macht das Auswählen von eigenen generischen Typparametern unabhängig von Groß- und Kleinschreibung."
911
}
1012
}

CommunityBugFixCollection/Locale/en.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
"CommunityBugFixCollection.CopyToClipboard": "Copy to Clipboard",
99

10-
"CommunityBugFixCollection.NoZeroScaleToolRaycast": "Fixes Resonite Issue #98: World crashes when a (multi)tool is scaled to zero."
10+
"CommunityBugFixCollection.NoZeroScaleToolRaycast": "Fixes Resonite Issue #98: World crashes when a (multi)tool is scaled to zero.",
11+
"CommunityBugFixCollection.CaseInsensitiveCustomGenerics.Description": "Makes picking custom generic type parameters case-insensitive."
1112
}
1213
}

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ just disable them in the settings in the meantime.
3434
* The selected Home World in the Inventory not being highlighted as a favorite (https://github.com/Yellow-Dog-Man/Resonite-Issues/issues/503)
3535
* The MaterialGizmo being scaled twice when using Edit on the Material Tool (https://github.com/Yellow-Dog-Man/Resonite-Issues/issues/528)
3636
* The `ValueDisplay<color>` ProtoFluxNode not having a `ValueProxySource<color>` (https://github.com/Yellow-Dog-Man/Resonite-Issues/issues/557)
37+
* Picking custom generic types in Component Selectors not being case-insensitive
38+
* https://github.com/Yellow-Dog-Man/Resonite-Issues/issues/620
39+
* https://github.com/Yellow-Dog-Man/Resonite-Issues/issues/636
40+
* https://github.com/Yellow-Dog-Man/Resonite-Issues/issues/4022
3741
* Tools derived from `BrushTool` not firing *OnDequipped* events (https://github.com/Yellow-Dog-Man/Resonite-Issues/issues/723)
3842
* It not being possible to import multiple audio clips at once (https://github.com/Yellow-Dog-Man/Resonite-Issues/issues/737)
3943
* URLs to text files or Resonite Packages failing to import instead of appearing as a hyperlink (https://github.com/Yellow-Dog-Man/Resonite-Issues/issues/785)

0 commit comments

Comments
 (0)