Fix HookCreator method filtering

This commit is contained in:
Sinai 2022-04-22 21:03:51 +10:00
parent 3afee7254c
commit abf5267364

View File

@ -7,6 +7,7 @@ using UnityEngine.UI;
using UnityExplorer.CSConsole; using UnityExplorer.CSConsole;
using UnityExplorer.Runtime; using UnityExplorer.Runtime;
using UnityExplorer.UI.Panels; using UnityExplorer.UI.Panels;
using UnityExplorer.UI.Widgets;
using UnityExplorer.UI.Widgets.AutoComplete; using UnityExplorer.UI.Widgets.AutoComplete;
using UniverseLib; using UniverseLib;
using UniverseLib.UI; using UniverseLib.UI;
@ -23,6 +24,7 @@ namespace UnityExplorer.Hooks
static readonly List<MethodInfo> currentAddEligableMethods = new(); static readonly List<MethodInfo> currentAddEligableMethods = new();
static readonly List<MethodInfo> filteredEligableMethods = new(); static readonly List<MethodInfo> filteredEligableMethods = new();
static readonly List<string> currentEligableNamesForFiltering = new();
// hook editor // hook editor
static readonly LexerBuilder Lexer = new(); static readonly LexerBuilder Lexer = new();
@ -58,7 +60,8 @@ namespace UnityExplorer.Hooks
if (type.IsGenericType) if (type.IsGenericType)
{ {
pendingGenericDefinition = type; pendingGenericDefinition = type;
GenericHookHandler.Show(OnGenericClassChosen, OnGenericClassCancel, type); HookManagerPanel.genericArgsHandler.Show(OnGenericClassChosen, OnGenericClassCancel, type);
HookManagerPanel.Instance.SetPage(HookManagerPanel.Pages.GenericArgsSelector);
return; return;
} }
@ -73,11 +76,13 @@ namespace UnityExplorer.Hooks
filteredEligableMethods.Clear(); filteredEligableMethods.Clear();
currentAddEligableMethods.Clear(); currentAddEligableMethods.Clear();
currentEligableNamesForFiltering.Clear();
foreach (MethodInfo method in type.GetMethods(ReflectionUtility.FLAGS)) foreach (MethodInfo method in type.GetMethods(ReflectionUtility.FLAGS))
{ {
if (UERuntimeHelper.IsBlacklisted(method)) if (UERuntimeHelper.IsBlacklisted(method))
continue; continue;
currentAddEligableMethods.Add(method); currentAddEligableMethods.Add(method);
currentEligableNamesForFiltering.Add(SignatureHighlighter.RemoveHighlighting(SignatureHighlighter.HighlightMethod(method)));
filteredEligableMethods.Add(method); filteredEligableMethods.Add(method);
} }
@ -119,7 +124,8 @@ namespace UnityExplorer.Hooks
else if (method.IsGenericMethod) else if (method.IsGenericMethod)
{ {
pendingGenericMethod = method; pendingGenericMethod = method;
GenericHookHandler.Show(OnGenericMethodChosen, OnGenericMethodCancel, method); HookManagerPanel.genericArgsHandler.Show(OnGenericMethodChosen, OnGenericMethodCancel, method);
HookManagerPanel.Instance.SetPage(HookManagerPanel.Pages.GenericArgsSelector);
return; return;
} }
@ -168,10 +174,12 @@ namespace UnityExplorer.Hooks
filteredEligableMethods.AddRange(currentAddEligableMethods); filteredEligableMethods.AddRange(currentAddEligableMethods);
else else
{ {
foreach (MethodInfo method in currentAddEligableMethods) for (int i = 0; i < currentAddEligableMethods.Count; i++)
{ {
if (method.Name.ContainsIgnoreCase(input)) MethodInfo eligable = currentAddEligableMethods[i];
filteredEligableMethods.Add(method); string sig = currentEligableNamesForFiltering[i];
if (sig.ContainsIgnoreCase(input))
filteredEligableMethods.Add(eligable);
} }
} }
@ -245,7 +253,8 @@ namespace UnityExplorer.Hooks
ClassSelectorInputField = UIFactory.CreateInputField(addRow, "ClassInput", "Enter a class to add hooks to..."); ClassSelectorInputField = UIFactory.CreateInputField(addRow, "ClassInput", "Enter a class to add hooks to...");
UIFactory.SetLayoutElement(ClassSelectorInputField.Component.gameObject, flexibleWidth: 9999, minHeight: 25, flexibleHeight: 0); UIFactory.SetLayoutElement(ClassSelectorInputField.Component.gameObject, flexibleWidth: 9999, minHeight: 25, flexibleHeight: 0);
new TypeCompleter(typeof(object), ClassSelectorInputField, true, false, Universe.Context != UniverseLib.Runtime.RuntimeContext.IL2CPP); TypeCompleter completer = new(typeof(object), ClassSelectorInputField, true, false, Universe.Context != UniverseLib.Runtime.RuntimeContext.IL2CPP);
//completer.AllTypes = true;
ButtonRef addButton = UIFactory.CreateButton(addRow, "AddButton", "View Methods"); ButtonRef addButton = UIFactory.CreateButton(addRow, "AddButton", "View Methods");
UIFactory.SetLayoutElement(addButton.Component.gameObject, minWidth: 110, minHeight: 25); UIFactory.SetLayoutElement(addButton.Component.gameObject, minWidth: 110, minHeight: 25);