using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using BepInEx.NET.Common;
using BepInExResoniteShim;
using Elements.Assets;
using Elements.Core;
using FrooxEngine;
using FrooxEngine.UIX;
using HarmonyLib;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(/*Could not decode attribute arguments.*/)]
[assembly: TargetFramework(".NETCoreApp,Version=v10.0", FrameworkDisplayName = ".NET 10.0")]
[assembly: AssemblyCompany("art0007i")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.1.0")]
[assembly: AssemblyInformationalVersion("1.0.1+e33c4dfbaa863d9b3ba89dded8c9f0a44c8422e4")]
[assembly: AssemblyProduct("SimpleInventorySearch")]
[assembly: AssemblyTitle("SimpleInventorySearch")]
[assembly: AssemblyMetadata("RepositoryUrl", "https://github.com/art0007i/SimpleInventorySearch")]
[assembly: AssemblyVersion("1.0.1.0")]
[module: RefSafetyRules(11)]
namespace SimpleInventorySearch;
[ResonitePlugin("art0007i.SimpleInventorySearch", "SimpleInventorySearch", "1.0.1", "art0007i", "https://github.com/art0007i/SimpleInventorySearch")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class Plugin : BasePlugin
{
[HarmonyPatch(typeof(BrowserDialog), "OnAttach")]
private class SimpleInventorySearchPatch
{
public static int DEFAULT_ITEM_SIZE = BrowserDialog.DEFAULT_ITEM_SIZE;
public static bool Prefix(BrowserDialog __instance, SyncRef<Text> ____selectedText, SyncRef<Slot> ____pathRoot, SyncRef<Slot> ____buttonsRoot, SyncRef<SlideSwapRegion> ____swapper)
{
//IL_0019: Unknown result type (might be due to invalid IL or missing references)
//IL_001f: Expected O, but got Unknown
//IL_0036: Unknown result type (might be due to invalid IL or missing references)
//IL_003c: Expected O, but got Unknown
//IL_0053: Unknown result type (might be due to invalid IL or missing references)
//IL_0059: Expected O, but got Unknown
//IL_0070: Unknown result type (might be due to invalid IL or missing references)
//IL_0076: Expected O, but got Unknown
//IL_007e: Unknown result type (might be due to invalid IL or missing references)
//IL_0083: Unknown result type (might be due to invalid IL or missing references)
//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
//IL_00dc: Expected O, but got Unknown
//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
//IL_0144: Unknown result type (might be due to invalid IL or missing references)
//IL_014a: Expected O, but got Unknown
UIBuilder val = new UIBuilder(((Component)__instance).Slot, (Slot)null);
RectTransform val2 = default(RectTransform);
RectTransform val3 = default(RectTransform);
val.HorizontalHeader((float)DEFAULT_ITEM_SIZE * 0.4f, ref val2, ref val3);
val = new UIBuilder(val3);
RectTransform val4 = default(RectTransform);
val.HorizontalHeader((float)DEFAULT_ITEM_SIZE * 1.2f, ref val4, ref val3);
val = new UIBuilder(val3);
RectTransform val5 = default(RectTransform);
RectTransform val6 = default(RectTransform);
val.HorizontalHeader((float)DEFAULT_ITEM_SIZE * 0.5f, ref val5, ref val6);
val = new UIBuilder(val2);
UIBuilder val7 = val;
LocaleString val8 = LocaleString.op_Implicit("---");
____selectedText.Target = val7.Text(ref val8, true, (Alignment?)null, true, (string)null);
((SyncField<colorX>)(object)____selectedText.Target.Color).Value = RadiantUI_Constants.TEXT_COLOR;
RectTransform val9 = default(RectTransform);
RectTransform val10 = default(RectTransform);
new UIBuilder(val5).VerticalHeader((float)(DEFAULT_ITEM_SIZE * 2), ref val9, ref val10);
UIBuilder val11 = new UIBuilder(val9);
RadiantUI_Constants.SetupDefaultStyle(val11, false);
TextField obj = val11.TextField((string)null, false, (string)null, true, default(LocaleString));
((SyncField<string>)(object)obj.Text.NullContent).Value = "Filter...";
((SyncField<FinishAction>)(object)obj.Editor.Target.FinishHandling).Value = (FinishAction)2;
obj.Editor.Target.LocalEditingChanged += delegate(TextEditor e)
{
//IL_008f: Unknown result type (might be due to invalid IL or missing references)
//IL_0094: Unknown result type (might be due to invalid IL or missing references)
//IL_0098: Unknown result type (might be due to invalid IL or missing references)
//IL_009d: Unknown result type (might be due to invalid IL or missing references)
//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
string text = e.TargetString.Trim().ToLower();
filterDict.Remove(__instance);
filterDict.Add(__instance, text);
GridLayout target = Traverse.Create((object)__instance).Field("_folderGrid").GetValue<SyncRef<GridLayout>>()
.Target;
Slot val12 = ((target != null) ? ((Component)target).Slot : null);
GridLayout target2 = Traverse.Create((object)__instance).Field("_itemGrid").GetValue<SyncRef<GridLayout>>()
.Target;
Slot val13 = ((target2 != null) ? ((Component)target2).Slot : null);
if (val12 != null)
{
Enumerator<Slot> enumerator = val12.Children.GetEnumerator();
try
{
while (enumerator.MoveNext())
{
DoFilter(enumerator.Current, text, isfolder: true);
}
}
finally
{
((global::System.IDisposable)enumerator/*cast due to .constrained prefix*/).Dispose();
}
}
if (val13 != null)
{
Enumerator<Slot> enumerator = val13.Children.GetEnumerator();
try
{
while (enumerator.MoveNext())
{
DoFilter(enumerator.Current, text, isfolder: false);
}
}
finally
{
((global::System.IDisposable)enumerator/*cast due to .constrained prefix*/).Dispose();
}
}
};
____pathRoot.Target = ((Component)val10).Slot;
val = new UIBuilder(val4);
val.VerticalLayout(0f, 4f, (Alignment?)(Alignment)5, (bool?)null, (bool?)null);
____buttonsRoot.Target = val.Root;
____swapper.Target = ((ContainerWorker<Component>)(object)((Component)val6).Slot).AttachComponent<SlideSwapRegion>(true, (Action<SlideSwapRegion>)null);
return false;
}
}
[HarmonyPatch(typeof(BrowserDialog), "GenerateContent")]
private class NewContentPatch
{
public static void Postfix(BrowserDialog __instance, SyncRef<GridLayout> ____folderGrid, SyncRef<GridLayout> ____itemGrid)
{
//IL_0027: Unknown result type (might be due to invalid IL or missing references)
//IL_0031: Expected O, but got Unknown
//IL_004b: Unknown result type (might be due to invalid IL or missing references)
//IL_0055: Expected O, but got Unknown
if (____folderGrid.Target != null)
{
((Component)____folderGrid.Target).Slot.ChildAdded += (SlotChildEvent)delegate(Slot _, Slot s)
{
//IL_0022: Unknown result type (might be due to invalid IL or missing references)
//IL_002c: Expected O, but got Unknown
//IL_0027: Unknown result type (might be due to invalid IL or missing references)
s.RunInUpdates(0, (Action)delegate
{
DoFilter(s, filterDict.GetValue(__instance, (CreateValueCallback<BrowserDialog, string>)((BrowserDialog k) => "")), isfolder: true);
});
};
}
if (____itemGrid.Target == null)
{
return;
}
((Component)____itemGrid.Target).Slot.ChildAdded += (SlotChildEvent)delegate(Slot _, Slot s)
{
//IL_0022: Unknown result type (might be due to invalid IL or missing references)
//IL_002c: Expected O, but got Unknown
//IL_0027: Unknown result type (might be due to invalid IL or missing references)
s.RunInUpdates(0, (Action)delegate
{
DoFilter(s, filterDict.GetValue(__instance, (CreateValueCallback<BrowserDialog, string>)((BrowserDialog k) => "")), isfolder: false);
});
};
}
}
internal static ManualLogSource Log;
public static ConditionalWeakTable<BrowserDialog, string> filterDict = new ConditionalWeakTable<BrowserDialog, string>();
public override void Load()
{
Log = ((BasePlugin)this).Log;
((BasePlugin)this).HarmonyInstance.PatchAll();
}
public static void DoFilter(Slot item, string filterStr, bool isfolder)
{
//IL_0019: Unknown result type (might be due to invalid IL or missing references)
//IL_0084: Unknown result type (might be due to invalid IL or missing references)
if ((isfolder && !filterStr.StartsWith("@")) || string.IsNullOrEmpty(filterStr) || !Enumerable.Any<Component>((global::System.Collections.Generic.IEnumerable<Component>)(object)((ContainerWorker<Component>)(object)item).Components, (Func<Component, bool>)((Component x) => x is BrowserItem)))
{
item.ActiveSelf = true;
return;
}
if (filterStr.StartsWith("@"))
{
filterStr = filterStr.Substring(1);
}
item.ActiveSelf = item.Name.ToLower().Contains(filterStr) || ((StringNode)new StringRenderTree(item.Name, (List<FontSet>)null, (Func<StringContainerNode, StringContainerNode>)null, true)).GetRawString().ToLower().Contains(filterStr);
}
}
public static class PluginMetadata
{
public const string GUID = "art0007i.SimpleInventorySearch";
public const string NAME = "SimpleInventorySearch";
public const string VERSION = "1.0.1";
public const string AUTHORS = "art0007i";
public const string REPOSITORY_URL = "https://github.com/art0007i/SimpleInventorySearch";
}