Rearrange advanced settings; separate raid scroll speed; remember hideout level

This commit is contained in:
Tyfon
2024-05-26 17:30:44 -07:00
parent 3d8b1edc13
commit 66ce87f5e7
5 changed files with 131 additions and 25 deletions

View File

@@ -0,0 +1,87 @@
using Aki.Reflection.Patching;
using EFT.Hideout;
using HarmonyLib;
using System.Reflection;
namespace UIFixes
{
public static class HideoutLevelPatches
{
private static string CurrentArea;
private static ELevelType CurrentLevel = ELevelType.NotSet;
public static void Enable()
{
new SelectAreaPatch().Enable();
new ChangeLevelPatch().Enable();
new PickInitialLevelPatch().Enable();
new ClearLevelPatch().Enable();
}
public class SelectAreaPatch : ModulePatch
{
protected override MethodBase GetTargetMethod()
{
return AccessTools.Method(typeof(AreaScreenSubstrate), nameof(AreaScreenSubstrate.SelectArea));
}
[PatchPrefix]
public static void Prefix(AreaData areaData)
{
if (areaData.Template.Id != CurrentArea)
{
CurrentArea = areaData.Template.Id;
CurrentLevel = ELevelType.NotSet;
}
}
}
public class ChangeLevelPatch : ModulePatch
{
protected override MethodBase GetTargetMethod()
{
return AccessTools.Method(typeof(AreaScreenSubstrate), nameof(AreaScreenSubstrate.method_6));
}
[PatchPrefix]
public static void Prefix(ELevelType state)
{
CurrentLevel = state;
}
}
public class PickInitialLevelPatch : ModulePatch
{
protected override MethodBase GetTargetMethod()
{
return AccessTools.Method(typeof(AreaScreenSubstrate), nameof(AreaScreenSubstrate.method_3));
}
[PatchPrefix]
public static bool Prefix(ref ELevelType __result)
{
if (CurrentLevel != ELevelType.NotSet) {
__result = CurrentLevel;
return false;
}
return true;
}
}
public class ClearLevelPatch : ModulePatch
{
protected override MethodBase GetTargetMethod()
{
return AccessTools.Method(typeof(HideoutScreenOverlay), nameof(HideoutScreenOverlay.ReturnToPreviousState));
}
[PatchPostfix]
public static void Postfix()
{
CurrentArea = null;
CurrentLevel = ELevelType.NotSet;
}
}
}
}

View File

@@ -233,7 +233,8 @@ namespace UIFixes
[PatchPrefix]
public static void Prefix(PointerEventData data)
{
data.scrollDelta *= Settings.MouseScrollMulti.Value;
int multi = Settings.UseRaidMouseScrollMulti.Value && Plugin.InRaid() ? Settings.MouseScrollMultiInRaid.Value : Settings.MouseScrollMulti.Value;
data.scrollDelta *= multi;
}
}
}

View File

@@ -1,7 +1,5 @@
using Aki.Reflection.Patching;
using Aki.Reflection.Utils;
using Comfort.Common;
using EFT;
using EFT.InventoryLogic;
using EFT.UI;
using EFT.UI.DragAndDrop;
@@ -45,11 +43,6 @@ namespace UIFixes
new RememberSwapGridHoverPatch().Enable();
new InspectWindowUpdateStatsOnSwapPatch().Enable();
}
private static bool InRaid()
{
bool? inRaid = Singleton<AbstractGame>.Instance?.InRaid;
return inRaid.HasValue && inRaid.Value;
}
private static bool ValidPrerequisites(ItemContextClass itemContext, ItemContextAbstractClass targetItemContext, object operation)
{
@@ -91,7 +84,7 @@ namespace UIFixes
}
string error = wrappedOperation.Error.ToString();
if (Settings.SwapImpossibleContainers.Value && !InRaid() && error.StartsWith("No free room"))
if (Settings.SwapImpossibleContainers.Value && !Plugin.InRaid() && error.StartsWith("No free room"))
{
// Check if it isn't allowed in that container, if so try to swap
if (LastCheckItemFilterId == itemContext.Item.Id && !LastCheckItemFilterResult)

View File

@@ -1,4 +1,6 @@
using BepInEx;
using Comfort.Common;
using EFT;
namespace UIFixes
{
@@ -17,6 +19,7 @@ namespace UIFixes
new FixWeaponBindsDisplayPatch().Enable();
FocusFleaOfferNumberPatches.Enable();
HideoutSearchPatches.Enable();
HideoutLevelPatches.Enable();
InspectWindowResizePatches.Enable();
InspectWindowStatsPatches.Enable();
new RemoveDoorActionsPatch().Enable();
@@ -33,5 +36,11 @@ namespace UIFixes
KeepOfferWindowOpenPatches.Enable();
AddOfferClickablePricesPatches.Enable();
}
public static bool InRaid()
{
bool? inRaid = Singleton<AbstractGame>.Instance?.InRaid;
return inRaid.HasValue && inRaid.Value;
}
}
}

View File

@@ -27,7 +27,6 @@ namespace UIFixes
private const string InspectSection = "4. Inspect Windows";
private const string InRaidSection = "5. In Raid";
private const string FleaMarketSection = "6. Flea Market";
private const string AdvancedSection = "7. Advanced";
// General
public static ConfigEntry<WeaponPresetConfirmationOption> ShowPresetConfirmations { get; set; }
@@ -37,6 +36,8 @@ namespace UIFixes
public static ConfigEntry<bool> UseHomeEnd { get; set; }
public static ConfigEntry<bool> RebindPageUpDown { get; set; }
public static ConfigEntry<int> MouseScrollMulti { get; set; }
public static ConfigEntry<bool> UseRaidMouseScrollMulti { get; set; } // Advanced
public static ConfigEntry<int> MouseScrollMultiInRaid { get; set; } // Advanced
// Inventory
public static ConfigEntry<bool> SwapItems { get; set; }
@@ -51,6 +52,7 @@ namespace UIFixes
public static ConfigEntry<bool> RememberInspectSize { get; set; }
public static ConfigEntry<bool> LockInspectPreviewSize { get; set; }
public static ConfigEntry<bool> ExpandDescriptionHeight { get; set; }
public static ConfigEntry<bool> StyleItemPanel { get; set; } // Advanced
// In Raid
public static ConfigEntry<bool> RemoveDisabledActions { get; set; }
@@ -60,10 +62,7 @@ namespace UIFixes
public static ConfigEntry<bool> ShowRequiredQuest { get; set; }
public static ConfigEntry<bool> AutoExpandCategories { get; set; }
public static ConfigEntry<bool> KeepAddOfferOpen { get; set; }
// Advanced
public static ConfigEntry<bool> StyleItemPanel { get; set; }
public static ConfigEntry<bool> KeepAddOfferOpenIgnoreMaxOffers { get; set; }
public static ConfigEntry<bool> KeepAddOfferOpenIgnoreMaxOffers { get; set; } // Advanced
public static void Init(ConfigFile config)
{
@@ -116,6 +115,24 @@ namespace UIFixes
new AcceptableValueRange<int>(1, 10),
new ConfigurationManagerAttributes { })));
configEntries.Add(UseRaidMouseScrollMulti = config.Bind(
InputSection,
"Use Different Scrolling Speed in Raid",
false,
new ConfigDescription(
"Change PageUp and PageDown to scroll up and down one page",
null,
new ConfigurationManagerAttributes { IsAdvanced = true })));
configEntries.Add(MouseScrollMultiInRaid = config.Bind(
InputSection,
"Mousewheel Scrolling Speed in Raid",
1,
new ConfigDescription(
"A separate mousewheel scroll speed for in raid.",
new AcceptableValueRange<int>(1, 10),
new ConfigurationManagerAttributes { IsAdvanced = true })));
// Inventory
configEntries.Add(SwapItems = config.Bind(
InventorySection,
@@ -208,6 +225,15 @@ namespace UIFixes
null,
new ConfigurationManagerAttributes { })));
configEntries.Add(StyleItemPanel = config.Bind(
InspectSection,
"Style Attribute Panels",
true,
new ConfigDescription(
"Clean up and colorize item stats",
null,
new ConfigurationManagerAttributes { IsAdvanced = true })));
// In Raid
configEntries.Add(RemoveDisabledActions = config.Bind(
InRaidSection,
@@ -255,18 +281,8 @@ namespace UIFixes
null,
new ConfigurationManagerAttributes { })));
// Advanced
configEntries.Add(StyleItemPanel = config.Bind(
AdvancedSection,
"Style Item Panel",
true,
new ConfigDescription(
"Clean up and colorize item stats",
null,
new ConfigurationManagerAttributes { IsAdvanced = true })));
configEntries.Add(KeepAddOfferOpenIgnoreMaxOffers = config.Bind(
AdvancedSection,
FleaMarketSection,
"Keep Add Offer Window Open: Ignore Max Offers",
false,
new ConfigDescription(