diff --git a/Patches/FixFleaPatches.cs b/Patches/FixFleaPatches.cs index 93bfd48..7077412 100644 --- a/Patches/FixFleaPatches.cs +++ b/Patches/FixFleaPatches.cs @@ -1,4 +1,5 @@ -using EFT.UI.Ragfair; +using EFT.UI; +using EFT.UI.Ragfair; using HarmonyLib; using SPT.Reflection.Patching; using System.Reflection; @@ -18,6 +19,8 @@ public static class FixFleaPatches new OfferItemFixMaskPatch().Enable(); new OfferViewTweaksPatch().Enable(); + + new SearchPatch().Enable(); } public class DoNotToggleOnMouseOverPatch : ModulePatch @@ -95,4 +98,35 @@ public static class FixFleaPatches timeLeft.childControlWidth = false; } } + + public class SearchPatch : ModulePatch + { + protected override MethodBase GetTargetMethod() + { + return AccessTools.Method(typeof(RagfairCategoriesPanel), nameof(RagfairCategoriesPanel.method_9)); + } + + [PatchPrefix] + public static bool Prefix(RagfairCategoriesPanel __instance, string arg) + { + if (!Settings.ClearFiltersOnSearch.Value) + { + return true; + } + + if (arg.StartsWith("#") || __instance.Ragfair == null || __instance.EViewListType_0 != EViewListType.AllOffers) + { + return true; + } + + __instance.Ragfair.CancellableFilters.Clear(); + + FilterRule filterRule = __instance.Ragfair.method_3(EViewListType.AllOffers); + filterRule.HandbookId = string.Empty; + + __instance.Ragfair.AddSearchesInRule(filterRule, true); + + return false; + } + } } diff --git a/Settings.cs b/Settings.cs index 384dc9b..ad33f8f 100644 --- a/Settings.cs +++ b/Settings.cs @@ -117,6 +117,7 @@ internal class Settings public static ConfigEntry EnableSlotSearch { get; set; } public static ConfigEntry ShowRequiredQuest { get; set; } public static ConfigEntry AutoExpandCategories { get; set; } + public static ConfigEntry ClearFiltersOnSearch { get; set; } public static ConfigEntry KeepAddOfferOpen { get; set; } public static ConfigEntry PurchaseAllKeybind { get; set; } public static ConfigEntry KeepAddOfferOpenIgnoreMaxOffers { get; set; } // Advanced @@ -663,6 +664,15 @@ internal class Settings null, new ConfigurationManagerAttributes { }))); + configEntries.Add(ClearFiltersOnSearch = config.Bind( + FleaMarketSection, + "Clear Filters on Search", + true, + new ConfigDescription( + "Pressing Enter after typing in the flea search bar will clear non-default filters", + null, + new ConfigurationManagerAttributes { }))); + configEntries.Add(ShowRequiredQuest = config.Bind( FleaMarketSection, "Show Required Quest for Locked Offers",