Updated for client version 0.14.1.2.29197

This commit is contained in:
IgorEisberg 2024-04-02 10:56:51 +03:00 committed by IcyClawz
parent e4c0280a09
commit ab9ca14b93
19 changed files with 43 additions and 50 deletions

View File

@ -3,7 +3,7 @@
<PropertyGroup> <PropertyGroup>
<TargetFramework>net472</TargetFramework> <TargetFramework>net472</TargetFramework>
<AssemblyName>IcyClawz.CustomInteractions.Prepatch</AssemblyName> <AssemblyName>IcyClawz.CustomInteractions.Prepatch</AssemblyName>
<Version>1.3.1</Version> <Version>1.4.0</Version>
<RootNamespace>IcyClawz.CustomInteractions</RootNamespace> <RootNamespace>IcyClawz.CustomInteractions</RootNamespace>
<LangVersion>latest</LangVersion> <LangVersion>latest</LangVersion>
</PropertyGroup> </PropertyGroup>

View File

@ -10,8 +10,7 @@ public static class Prepatch
public static void Patch(AssemblyDefinition assembly) public static void Patch(AssemblyDefinition assembly)
{ {
TypeDefinition type = assembly.MainModule.GetType("GClass2816"); // DynamicInteraction TypeDefinition type = assembly.MainModule.GetType("DynamicInteractionClass");
type.IsSealed = false;
FieldDefinition field = type.Fields.SingleOrDefault(c => c.Name is "action_0"); FieldDefinition field = type.Fields.SingleOrDefault(c => c.Name is "action_0");
field.IsFamily = true; field.IsFamily = true;
field.IsInitOnly = false; field.IsInitOnly = false;

View File

@ -1,3 +1,4 @@
using Comfort.Common;
using EFT.InventoryLogic; using EFT.InventoryLogic;
using EFT.UI; using EFT.UI;
using JetBrains.Annotations; using JetBrains.Annotations;
@ -8,8 +9,7 @@ using System.Linq;
using System.Reflection; using System.Reflection;
using UnityEngine; using UnityEngine;
using DynamicInteraction = GClass2816; using EmptyInteractionsAbstractClass = GClass3039;
using EmptyInteractions = GClass2817<System.Enum>;
namespace IcyClawz.CustomInteractions; namespace IcyClawz.CustomInteractions;
@ -34,7 +34,7 @@ public static class CustomInteractionsManager
public class CustomInteraction() public class CustomInteraction()
{ {
internal readonly CustomInteractionImpl Impl = new(); internal readonly CustomInteractionImpl Impl = new(UnityEngine.Random.Range(0, int.MaxValue).ToString("x4"));
public Func<string> Caption { get => Impl.Caption; set => Impl.Caption = value; } public Func<string> Caption { get => Impl.Caption; set => Impl.Caption = value; }
public Func<Sprite> Icon { get => Impl.Icon; set => Impl.Icon = value; } public Func<Sprite> Icon { get => Impl.Icon; set => Impl.Icon = value; }
@ -44,8 +44,7 @@ public class CustomInteraction()
public Func<string> Error { get => Impl.Error; set => Impl.Error = value; } public Func<string> Error { get => Impl.Error; set => Impl.Error = value; }
} }
internal sealed class CustomInteractionImpl() internal sealed class CustomInteractionImpl(string id) : DynamicInteractionClass(id, id)
: DynamicInteraction(UnityEngine.Random.Range(0, int.MaxValue).ToString("x4"))
{ {
public Func<string> Caption { get; set; } public Func<string> Caption { get; set; }
public new Func<Sprite> Icon { get; set; } public new Func<Sprite> Icon { get; set; }
@ -71,32 +70,27 @@ public abstract class CustomSubInteractions(ItemUiContext uiContext)
public void AddRange(IEnumerable<CustomInteraction> interactions) => interactions.ExecuteForEach(Impl.AddCustomInteraction); public void AddRange(IEnumerable<CustomInteraction> interactions) => interactions.ExecuteForEach(Impl.AddCustomInteraction);
public void Remove(CustomInteraction interaction) => Impl.RemoveCustomInteraction(interaction); public void Remove(CustomInteraction interaction) => Impl.RemoveCustomInteraction(interaction);
public void RemoveRange(IEnumerable<CustomInteraction> interactions) => interactions.ExecuteForEach(Impl.RemoveCustomInteraction); public void RemoveRange(IEnumerable<CustomInteraction> interactions) => interactions.ExecuteForEach(Impl.RemoveCustomInteraction);
public void CallRedraw() => Impl.CallRedraw();
public void CallRedraw(string templateId) => Impl.CallRedraw(templateId);
} }
internal sealed class CustomSubInteractionsImpl(ItemUiContext uiContext) internal sealed class CustomSubInteractionsImpl(ItemUiContext uiContext) : EmptyInteractionsAbstractClass(uiContext)
: EmptyInteractions(uiContext)
{ {
public IEnumerable<CustomInteractionImpl> CustomInteractions => DynamicInteractions.OfType<CustomInteractionImpl>(); public IEnumerable<CustomInteractionImpl> CustomInteractions => DynamicInteractions.OfType<CustomInteractionImpl>();
public bool ExaminationRequiredInternal { get; set; } = true; public bool ExaminationRequiredInternal { get; set; } = true;
public override bool ExaminationRequired => ExaminationRequiredInternal; public override bool ExaminationRequired => ExaminationRequiredInternal;
public override bool HasIcons => CustomInteractions.Any(interaction => interaction.Icon is not null); public override bool HasIcons => CustomInteractions.Any(interaction => interaction.Icon is not null);
public void CallRedraw() => itemUiContext_0.RedrawContextMenus(null);
} }
internal static class AbstractInteractionsExtensions internal static class AbstractInteractionsExtensions
{ {
private static Dictionary<string, DynamicInteraction> GetDynamicInteractions<T>(this GClass2817<T> instance) where T : Enum => private static Dictionary<string, DynamicInteractionClass> GetDynamicInteractions<T>(this ItemInfoInteractionsAbstractClass<T> instance) where T : struct, Enum =>
typeof(GClass2817<T>).GetField("dictionary_1", BindingFlags.NonPublic | BindingFlags.Instance) typeof(ItemInfoInteractionsAbstractClass<T>).GetField("dictionary_0", BindingFlags.NonPublic | BindingFlags.Instance)
.GetValue(instance) as Dictionary<string, DynamicInteraction>; .GetValue(instance) as Dictionary<string, DynamicInteractionClass>;
public static void AddCustomInteraction<T>(this GClass2817<T> instance, CustomInteraction interaction) where T : Enum => public static void AddCustomInteraction<T>(this ItemInfoInteractionsAbstractClass<T> instance, CustomInteraction interaction) where T : struct, Enum =>
instance.GetDynamicInteractions()[interaction.Impl.Key] = interaction.Impl; instance.GetDynamicInteractions()[interaction.Impl.Key] = interaction.Impl;
public static void RemoveCustomInteraction<T>(this GClass2817<T> instance, CustomInteraction interaction) where T : Enum => public static void RemoveCustomInteraction<T>(this ItemInfoInteractionsAbstractClass<T> instance, CustomInteraction interaction) where T : struct, Enum =>
instance.GetDynamicInteractions().Remove(interaction.Impl.Key); instance.GetDynamicInteractions().Remove(interaction.Impl.Key);
} }
@ -121,7 +115,7 @@ internal static class InteractionButtonsContainerExtensions
CurrentButtonField.SetValue(instance, button); CurrentButtonField.SetValue(instance, button);
private static readonly MethodInfo CreateButtonMethod = private static readonly MethodInfo CreateButtonMethod =
typeof(InteractionButtonsContainer).GetMethod("method_1", BindingFlags.NonPublic | BindingFlags.Instance); typeof(InteractionButtonsContainer).GetMethod("method_1", BindingFlags.Public | BindingFlags.Instance);
private static SimpleContextMenuButton CreateButton(this InteractionButtonsContainer instance, private static SimpleContextMenuButton CreateButton(this InteractionButtonsContainer instance,
string key, string caption, SimpleContextMenuButton template, RectTransform container, string key, string caption, SimpleContextMenuButton template, RectTransform container,
@ -132,13 +126,13 @@ internal static class InteractionButtonsContainerExtensions
]); ]);
private static readonly MethodInfo CloseSubMenuMethod = private static readonly MethodInfo CloseSubMenuMethod =
typeof(InteractionButtonsContainer).GetMethod("method_4", BindingFlags.NonPublic | BindingFlags.Instance); typeof(InteractionButtonsContainer).GetMethod("method_4", BindingFlags.Public | BindingFlags.Instance);
private static void CloseSubMenu(this InteractionButtonsContainer instance) => private static void CloseSubMenu(this InteractionButtonsContainer instance) =>
CloseSubMenuMethod.Invoke(instance, null); CloseSubMenuMethod.Invoke(instance, null);
private static readonly MethodInfo AddButtonMethod = private static readonly MethodInfo AddButtonMethod =
typeof(InteractionButtonsContainer).GetMethod("method_5", BindingFlags.NonPublic | BindingFlags.Instance); typeof(InteractionButtonsContainer).GetMethod("method_5", BindingFlags.Public | BindingFlags.Instance);
private static void AddButton(this InteractionButtonsContainer instance, SimpleContextMenuButton button) => private static void AddButton(this InteractionButtonsContainer instance, SimpleContextMenuButton button) =>
AddButtonMethod.Invoke(instance, [button]); AddButtonMethod.Invoke(instance, [button]);
@ -173,7 +167,7 @@ internal static class InteractionButtonsContainerExtensions
false false
); );
button.SetButtonInteraction( button.SetButtonInteraction(
(isInteractive, impl.Error?.Invoke() ?? "") isInteractive ? SuccessfulResult.New : new FailedResult(impl.Error?.Invoke() ?? "", 0)
); );
instance.AddButton(button); instance.AddButton(button);
} }

View File

@ -3,7 +3,7 @@
<PropertyGroup> <PropertyGroup>
<TargetFramework>net472</TargetFramework> <TargetFramework>net472</TargetFramework>
<AssemblyName>IcyClawz.CustomInteractions</AssemblyName> <AssemblyName>IcyClawz.CustomInteractions</AssemblyName>
<Version>1.3.1</Version> <Version>1.4.0</Version>
<RootNamespace>IcyClawz.CustomInteractions</RootNamespace> <RootNamespace>IcyClawz.CustomInteractions</RootNamespace>
<LangVersion>latest</LangVersion> <LangVersion>latest</LangVersion>
</PropertyGroup> </PropertyGroup>
@ -18,6 +18,9 @@
<Reference Include="BepInEx"> <Reference Include="BepInEx">
<HintPath>..\Shared\BepInEx.dll</HintPath> <HintPath>..\Shared\BepInEx.dll</HintPath>
</Reference> </Reference>
<Reference Include="Comfort">
<HintPath>..\Shared\Comfort.dll</HintPath>
</Reference>
<Reference Include="Sirenix.Serialization"> <Reference Include="Sirenix.Serialization">
<HintPath>..\Shared\Sirenix.Serialization.dll</HintPath> <HintPath>..\Shared\Sirenix.Serialization.dll</HintPath>
</Reference> </Reference>

View File

@ -4,13 +4,9 @@ using EFT.UI;
using System.Linq; using System.Linq;
using System.Reflection; using System.Reflection;
using DynamicInteraction = GClass2816;
using ItemContext = GClass2623;
using ItemInfoInteractions = GClass2817<EFT.InventoryLogic.EItemInfoButton>;
namespace IcyClawz.CustomInteractions; namespace IcyClawz.CustomInteractions;
[BepInPlugin("com.IcyClawz.CustomInteractions", "IcyClawz.CustomInteractions", "1.3.1")] [BepInPlugin("com.IcyClawz.CustomInteractions", "IcyClawz.CustomInteractions", "1.4.0")]
public class Plugin : BaseUnityPlugin public class Plugin : BaseUnityPlugin
{ {
private void Awake() private void Awake()
@ -26,7 +22,8 @@ internal class ItemUiContextPatch : ModulePatch
typeof(ItemUiContext).GetMethod("GetItemContextInteractions", BindingFlags.Public | BindingFlags.Instance); typeof(ItemUiContext).GetMethod("GetItemContextInteractions", BindingFlags.Public | BindingFlags.Instance);
[PatchPostfix] [PatchPostfix]
private static void Postfix(ref ItemInfoInteractions __result, ref ItemUiContext __instance, ItemContext itemContext) private static void Postfix(ref ItemInfoInteractionsAbstractClass<EFT.InventoryLogic.EItemInfoButton> __result,
ref ItemUiContext __instance, ItemContextClass itemContext)
{ {
foreach (var provider in CustomInteractionsManager.Providers.OfType<IItemCustomInteractionsProvider>()) foreach (var provider in CustomInteractionsManager.Providers.OfType<IItemCustomInteractionsProvider>())
{ {
@ -42,10 +39,10 @@ internal class ItemUiContextPatch : ModulePatch
internal class InteractionButtonsContainerPatch : ModulePatch internal class InteractionButtonsContainerPatch : ModulePatch
{ {
protected override MethodBase GetTargetMethod() => protected override MethodBase GetTargetMethod() =>
typeof(InteractionButtonsContainer).GetMethod("method_3", BindingFlags.NonPublic | BindingFlags.Instance); typeof(InteractionButtonsContainer).GetMethod("method_3", BindingFlags.Public | BindingFlags.Instance);
[PatchPrefix] [PatchPrefix]
private static bool Prefix(ref InteractionButtonsContainer __instance, DynamicInteraction interaction) private static bool Prefix(ref InteractionButtonsContainer __instance, DynamicInteractionClass interaction)
{ {
if (interaction is CustomInteractionImpl impl) if (interaction is CustomInteractionImpl impl)
{ {

View File

@ -3,7 +3,7 @@
<PropertyGroup> <PropertyGroup>
<TargetFramework>net472</TargetFramework> <TargetFramework>net472</TargetFramework>
<AssemblyName>IcyClawz.ItemAttributeFix</AssemblyName> <AssemblyName>IcyClawz.ItemAttributeFix</AssemblyName>
<Version>1.2.0</Version> <Version>1.3.0</Version>
<RootNamespace>IcyClawz.ItemAttributeFix</RootNamespace> <RootNamespace>IcyClawz.ItemAttributeFix</RootNamespace>
<LangVersion>latest</LangVersion> <LangVersion>latest</LangVersion>
</PropertyGroup> </PropertyGroup>

View File

@ -5,7 +5,7 @@ using System.Reflection;
namespace IcyClawz.ItemAttributeFix; namespace IcyClawz.ItemAttributeFix;
[BepInPlugin("com.IcyClawz.ItemAttributeFix", "IcyClawz.ItemAttributeFix", "1.2.0")] [BepInPlugin("com.IcyClawz.ItemAttributeFix", "IcyClawz.ItemAttributeFix", "1.3.0")]
public class Plugin : BaseUnityPlugin public class Plugin : BaseUnityPlugin
{ {
private void Awake() => private void Awake() =>

View File

@ -8,8 +8,8 @@ using System.Linq;
using System.Reflection; using System.Reflection;
using UnityEngine; using UnityEngine;
using ILightTemplate = GInterface246; using ILightTemplate = GInterface295;
using ResourceCache = GClass1977; using GlobalEvents = GClass3019;
namespace IcyClawz.ItemContextMenuExt; namespace IcyClawz.ItemContextMenuExt;
@ -60,12 +60,12 @@ internal sealed class CustomInteractionsProvider : IItemCustomInteractionsProvid
yield return new() yield return new()
{ {
Caption = () => (lightComponent.IsActive ? "TurnOff" : "TurnOn").Localized(), Caption = () => (lightComponent.IsActive ? "TurnOff" : "TurnOn").Localized(),
Icon = () => ResourceCache.Pop<Sprite>(IconsPrefix + (lightComponent.IsActive ? "TurnOff" : "TurnOn")), Icon = () => CacheResourcesPopAbstractClass.Pop<Sprite>(IconsPrefix + (lightComponent.IsActive ? "TurnOff" : "TurnOn")),
Action = () => Action = () =>
{ {
Singleton<GUISounds>.Instance.PlayUISound(EUISoundType.MenuContextMenu); Singleton<GUISounds>.Instance.PlayUISound(EUISoundType.MenuContextMenu);
ComponentUtils.SetLightState(lightComponent, !lightComponent.IsActive, lightComponent.SelectedMode); ComponentUtils.SetLightState(lightComponent, !lightComponent.IsActive, lightComponent.SelectedMode);
uiContext.RedrawContextMenus([item.TemplateId]); GlobalEvents.RequestGlobalRedraw();
} }
}; };
// Switch mode // Switch mode

View File

@ -3,7 +3,7 @@
<PropertyGroup> <PropertyGroup>
<TargetFramework>net472</TargetFramework> <TargetFramework>net472</TargetFramework>
<AssemblyName>IcyClawz.ItemContextMenuExt</AssemblyName> <AssemblyName>IcyClawz.ItemContextMenuExt</AssemblyName>
<Version>1.2.1</Version> <Version>1.4.0</Version>
<RootNamespace>IcyClawz.ItemContextMenuExt</RootNamespace> <RootNamespace>IcyClawz.ItemContextMenuExt</RootNamespace>
<LangVersion>latest</LangVersion> <LangVersion>latest</LangVersion>
</PropertyGroup> </PropertyGroup>

View File

@ -3,7 +3,7 @@ using IcyClawz.CustomInteractions;
namespace IcyClawz.ItemContextMenuExt; namespace IcyClawz.ItemContextMenuExt;
[BepInPlugin("com.IcyClawz.ItemContextMenuExt", "IcyClawz.ItemContextMenuExt", "1.2.1")] [BepInPlugin("com.IcyClawz.ItemContextMenuExt", "IcyClawz.ItemContextMenuExt", "1.4.0")]
[BepInDependency("com.IcyClawz.CustomInteractions")] [BepInDependency("com.IcyClawz.CustomInteractions")]
public class Plugin : BaseUnityPlugin public class Plugin : BaseUnityPlugin
{ {

View File

@ -8,7 +8,7 @@ using System.Linq;
using System.Reflection; using System.Reflection;
using UnityEngine; using UnityEngine;
using CurrencyUtil = GClass2334; using CurrencyUtil = GClass2517;
namespace IcyClawz.ItemSellPrice; namespace IcyClawz.ItemSellPrice;

View File

@ -3,7 +3,7 @@
<PropertyGroup> <PropertyGroup>
<TargetFramework>net472</TargetFramework> <TargetFramework>net472</TargetFramework>
<AssemblyName>IcyClawz.ItemSellPrice</AssemblyName> <AssemblyName>IcyClawz.ItemSellPrice</AssemblyName>
<Version>1.2.1</Version> <Version>1.3.0</Version>
<RootNamespace>IcyClawz.ItemSellPrice</RootNamespace> <RootNamespace>IcyClawz.ItemSellPrice</RootNamespace>
<LangVersion>latest</LangVersion> <LangVersion>latest</LangVersion>
</PropertyGroup> </PropertyGroup>

View File

@ -5,7 +5,7 @@ using System.Reflection;
namespace IcyClawz.ItemSellPrice; namespace IcyClawz.ItemSellPrice;
[BepInPlugin("com.IcyClawz.ItemSellPrice", "IcyClawz.ItemSellPrice", "1.2.1")] [BepInPlugin("com.IcyClawz.ItemSellPrice", "IcyClawz.ItemSellPrice", "1.3.0")]
public class Plugin : BaseUnityPlugin public class Plugin : BaseUnityPlugin
{ {
private void Awake() private void Awake()

View File

@ -7,7 +7,7 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using UnityEngine; using UnityEngine;
using InGameStatus = GClass1716; using InGameStatus = GClass1849;
namespace IcyClawz.MagazineInspector; namespace IcyClawz.MagazineInspector;

View File

@ -3,7 +3,7 @@
<PropertyGroup> <PropertyGroup>
<TargetFramework>net472</TargetFramework> <TargetFramework>net472</TargetFramework>
<AssemblyName>IcyClawz.MagazineInspector</AssemblyName> <AssemblyName>IcyClawz.MagazineInspector</AssemblyName>
<Version>1.2.1</Version> <Version>1.3.0</Version>
<RootNamespace>IcyClawz.MagazineInspector</RootNamespace> <RootNamespace>IcyClawz.MagazineInspector</RootNamespace>
<LangVersion>latest</LangVersion> <LangVersion>latest</LangVersion>
</PropertyGroup> </PropertyGroup>

View File

@ -4,7 +4,7 @@ using System.Reflection;
namespace IcyClawz.MagazineInspector; namespace IcyClawz.MagazineInspector;
[BepInPlugin("com.IcyClawz.MagazineInspector", "IcyClawz.MagazineInspector", "1.2.1")] [BepInPlugin("com.IcyClawz.MagazineInspector", "IcyClawz.MagazineInspector", "1.3.0")]
public class Plugin : BaseUnityPlugin public class Plugin : BaseUnityPlugin
{ {
private void Awake() => private void Awake() =>

View File

@ -39,7 +39,7 @@ internal sealed class ConfigurationManagerAttributes
/// Custom setting editor (OnGUI code that replaces the default editor provided by ConfigurationManager). /// Custom setting editor (OnGUI code that replaces the default editor provided by ConfigurationManager).
/// See below for a deeper explanation. Using a custom drawer will cause many of the other fields to do nothing. /// See below for a deeper explanation. Using a custom drawer will cause many of the other fields to do nothing.
/// </summary> /// </summary>
public System.Action<BepInEx.Configuration.ConfigEntryBase> CustomDrawer; public System.Action<ConfigEntryBase> CustomDrawer;
/// <summary> /// <summary>
/// Show this setting in the settings screen at all? If false, don't show. /// Show this setting in the settings screen at all? If false, don't show.

View File

@ -3,7 +3,7 @@
<PropertyGroup> <PropertyGroup>
<TargetFramework>net472</TargetFramework> <TargetFramework>net472</TargetFramework>
<AssemblyName>IcyClawz.MunitionsExpert</AssemblyName> <AssemblyName>IcyClawz.MunitionsExpert</AssemblyName>
<Version>1.2.1</Version> <Version>1.3.0</Version>
<RootNamespace>IcyClawz.MunitionsExpert</RootNamespace> <RootNamespace>IcyClawz.MunitionsExpert</RootNamespace>
<LangVersion>latest</LangVersion> <LangVersion>latest</LangVersion>
</PropertyGroup> </PropertyGroup>

View File

@ -13,7 +13,7 @@ using UnityEngine.UI;
namespace IcyClawz.MunitionsExpert; namespace IcyClawz.MunitionsExpert;
[BepInPlugin("com.IcyClawz.MunitionsExpert", "IcyClawz.MunitionsExpert", "1.2.1")] [BepInPlugin("com.IcyClawz.MunitionsExpert", "IcyClawz.MunitionsExpert", "1.3.0")]
public class Plugin : BaseUnityPlugin public class Plugin : BaseUnityPlugin
{ {
private static ConfigEntry<bool> ColorizeSwitch { get; set; } private static ConfigEntry<bool> ColorizeSwitch { get; set; }
@ -82,7 +82,7 @@ internal class ItemViewPatch : ModulePatch
typeof(ItemView).GetField("BackgroundColor", BindingFlags.NonPublic | BindingFlags.Instance); typeof(ItemView).GetField("BackgroundColor", BindingFlags.NonPublic | BindingFlags.Instance);
protected override MethodBase GetTargetMethod() => protected override MethodBase GetTargetMethod() =>
typeof(ItemView).GetMethod("UpdateColor", BindingFlags.NonPublic | BindingFlags.Instance); typeof(ItemView).GetMethod("UpdateColor", BindingFlags.Public | BindingFlags.Instance);
[PatchPrefix] [PatchPrefix]
private static void PatchPrefix(ref ItemView __instance) private static void PatchPrefix(ref ItemView __instance)