MunitionExpert: add toggle for colorizing backgrounds

This commit is contained in:
IgorEisberg 2023-07-31 21:55:40 +03:00
parent d91be0d666
commit 40cd708ebb
2 changed files with 14 additions and 4 deletions

View File

@ -3,7 +3,7 @@
<PropertyGroup> <PropertyGroup>
<TargetFramework>net472</TargetFramework> <TargetFramework>net472</TargetFramework>
<AssemblyName>IcyClawz.MunitionsExpert</AssemblyName> <AssemblyName>IcyClawz.MunitionsExpert</AssemblyName>
<Version>1.1.0</Version> <Version>1.1.1</Version>
<RootNamespace>IcyClawz.MunitionsExpert</RootNamespace> <RootNamespace>IcyClawz.MunitionsExpert</RootNamespace>
</PropertyGroup> </PropertyGroup>

View File

@ -1,5 +1,6 @@
using Aki.Reflection.Patching; using Aki.Reflection.Patching;
using BepInEx; using BepInEx;
using BepInEx.Configuration;
using EFT.HandBook; using EFT.HandBook;
using EFT.InventoryLogic; using EFT.InventoryLogic;
using EFT.UI; using EFT.UI;
@ -11,11 +12,14 @@ using UnityEngine;
namespace IcyClawz.MunitionsExpert namespace IcyClawz.MunitionsExpert
{ {
[BepInPlugin("com.IcyClawz.MunitionsExpert", "IcyClawz.MunitionsExpert", "1.1.0")] [BepInPlugin("com.IcyClawz.MunitionsExpert", "IcyClawz.MunitionsExpert", "1.1.1")]
public class Plugin : BaseUnityPlugin public class Plugin : BaseUnityPlugin
{ {
internal static ConfigEntry<bool> ColorizeItemBackgrounds;
private void Awake() private void Awake()
{ {
ColorizeItemBackgrounds = Config.Bind("General", "Colorize Icon Backgrounds", true);
IconCache.Initialize(); IconCache.Initialize();
new StaticIconsPatch().Enable(); new StaticIconsPatch().Enable();
new AmmoTemplatePatch().Enable(); new AmmoTemplatePatch().Enable();
@ -77,10 +81,13 @@ namespace IcyClawz.MunitionsExpert
[PatchPrefix] [PatchPrefix]
private static void PatchPrefix(ref ItemView __instance) private static void PatchPrefix(ref ItemView __instance)
{
if (Plugin.ColorizeItemBackgrounds.Value)
{ {
__instance.OverrideColor(__instance.Item); __instance.OverrideColor(__instance.Item);
} }
} }
}
internal class EntityIconPatch : ModulePatch internal class EntityIconPatch : ModulePatch
{ {
@ -89,8 +96,11 @@ namespace IcyClawz.MunitionsExpert
[PatchPostfix] [PatchPostfix]
private static void PatchPostfix(ref EntityIcon __instance, Item item) private static void PatchPostfix(ref EntityIcon __instance, Item item)
{
if (Plugin.ColorizeItemBackgrounds.Value)
{ {
__instance.OverrideColor(item); __instance.OverrideColor(item);
} }
} }
} }
}