Code cleanup
This commit is contained in:
@@ -14,14 +14,14 @@ namespace UIFixes
|
|||||||
|
|
||||||
protected override MethodBase GetTargetMethod()
|
protected override MethodBase GetTargetMethod()
|
||||||
{
|
{
|
||||||
MethodInfo method = AccessTools.Method(typeof(InteractionsHandlerClass), "smethod_0");
|
MethodInfo method = AccessTools.Method(typeof(InteractionsHandlerClass), nameof(InteractionsHandlerClass.smethod_0));
|
||||||
MergeableItemType = method.GetParameters()[2].ParameterType.GetElementType(); // parameter is a ref type, get underlying type
|
MergeableItemType = method.GetParameters()[2].ParameterType.GetElementType(); // parameter is a ref type, get underlying type
|
||||||
return method;
|
return method;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reimplementing this entire method to ignore SpawnedInSession for certain types
|
// Reimplementing this entire method to ignore SpawnedInSession for certain types
|
||||||
[PatchPrefix]
|
[PatchPrefix]
|
||||||
private static bool Prefix(IEnumerable<StashGridClass> gridsToPut, Item itemToMerge, ref object mergeableItem, int overrideCount, ref bool __result)
|
public static bool Prefix(IEnumerable<StashGridClass> gridsToPut, Item itemToMerge, ref object mergeableItem, int overrideCount, ref bool __result)
|
||||||
{
|
{
|
||||||
if (!MergeableItemType.IsInstanceOfType(itemToMerge))
|
if (!MergeableItemType.IsInstanceOfType(itemToMerge))
|
||||||
{
|
{
|
||||||
|
@@ -32,7 +32,7 @@ namespace UIFixes
|
|||||||
}
|
}
|
||||||
|
|
||||||
[PatchPostfix]
|
[PatchPostfix]
|
||||||
private static void Postfix(object __instance, bool ___bool_0)
|
public static void Postfix(object __instance, bool ___bool_0)
|
||||||
{
|
{
|
||||||
if (!___bool_0)
|
if (!___bool_0)
|
||||||
{
|
{
|
||||||
@@ -52,11 +52,13 @@ namespace UIFixes
|
|||||||
protected override MethodBase GetTargetMethod()
|
protected override MethodBase GetTargetMethod()
|
||||||
{
|
{
|
||||||
// The parent has a Show() so need to be specific
|
// The parent has a Show() so need to be specific
|
||||||
return typeof(HandoverRagfairMoneyWindow).GetMethods().First(m => m.Name == "Show" && m.GetParameters()[0].ParameterType == typeof(Inventory));
|
return AccessTools.GetDeclaredMethods(typeof(HandoverRagfairMoneyWindow)).First(
|
||||||
|
m => m.Name == nameof(HandoverRagfairMoneyWindow.Show) &&
|
||||||
|
m.GetParameters()[0].ParameterType == typeof(Inventory));
|
||||||
}
|
}
|
||||||
|
|
||||||
[PatchPostfix]
|
[PatchPostfix]
|
||||||
private static void Postfix(TMP_InputField ____inputField)
|
public static void Postfix(TMP_InputField ____inputField)
|
||||||
{
|
{
|
||||||
____inputField.contentType = TMP_InputField.ContentType.IntegerNumber;
|
____inputField.contentType = TMP_InputField.ContentType.IntegerNumber;
|
||||||
____inputField.ActivateInputField();
|
____inputField.ActivateInputField();
|
||||||
|
@@ -8,19 +8,20 @@ namespace UIFixes
|
|||||||
{
|
{
|
||||||
public class DisabledActionsPatch : ModulePatch
|
public class DisabledActionsPatch : ModulePatch
|
||||||
{
|
{
|
||||||
private static string[] UnimplementedActions = ["Bang & clear", "Flash & clear", "Move in"];
|
private static readonly string[] UnimplementedActions = ["Bang & clear", "Flash & clear", "Move in"];
|
||||||
|
|
||||||
protected override MethodBase GetTargetMethod()
|
protected override MethodBase GetTargetMethod()
|
||||||
{
|
{
|
||||||
Type type = typeof(GetActionsClass);
|
Type type = typeof(GetActionsClass);
|
||||||
return AccessTools.GetDeclaredMethods(type).FirstOrDefault(x =>
|
return AccessTools.GetDeclaredMethods(type).FirstOrDefault(x =>
|
||||||
{
|
{
|
||||||
var parameters = x.GetParameters();
|
var parameters = x.GetParameters();
|
||||||
return x.Name == "GetAvailableActions" && parameters[0].Name == "owner";
|
return x.Name == nameof(GetActionsClass.GetAvailableActions) && parameters[0].Name == "owner";
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
[PatchPostfix]
|
[PatchPostfix]
|
||||||
private static void Postfix(ref ActionsReturnClass __result)
|
public static void Postfix(ref ActionsReturnClass __result)
|
||||||
{
|
{
|
||||||
if (Settings.RemoveDisabledActions.Value && __result != null)
|
if (Settings.RemoveDisabledActions.Value && __result != null)
|
||||||
{
|
{
|
||||||
|
@@ -1,5 +1,6 @@
|
|||||||
using Aki.Reflection.Patching;
|
using Aki.Reflection.Patching;
|
||||||
using EFT.UI;
|
using EFT.UI;
|
||||||
|
using HarmonyLib;
|
||||||
using System;
|
using System;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
@@ -25,11 +26,11 @@ namespace UIFixes
|
|||||||
protected override MethodBase GetTargetMethod()
|
protected override MethodBase GetTargetMethod()
|
||||||
{
|
{
|
||||||
Type type = typeof(EditBuildScreen).GetNestedTypes().Single(x => x.GetMethod("CloseScreenInterruption") != null); // EditBuildScreen.GClass3126
|
Type type = typeof(EditBuildScreen).GetNestedTypes().Single(x => x.GetMethod("CloseScreenInterruption") != null); // EditBuildScreen.GClass3126
|
||||||
return type.GetMethod("CloseScreenInterruption");
|
return AccessTools.Method(type, "CloseScreenInterruption");
|
||||||
}
|
}
|
||||||
|
|
||||||
[PatchPrefix]
|
[PatchPrefix]
|
||||||
private static void Prefix(bool moveForward)
|
public static void Prefix(bool moveForward)
|
||||||
{
|
{
|
||||||
MoveForward = moveForward;
|
MoveForward = moveForward;
|
||||||
}
|
}
|
||||||
@@ -39,12 +40,11 @@ namespace UIFixes
|
|||||||
{
|
{
|
||||||
protected override MethodBase GetTargetMethod()
|
protected override MethodBase GetTargetMethod()
|
||||||
{
|
{
|
||||||
Type type = typeof(EditBuildScreen);
|
return AccessTools.Method(typeof(EditBuildScreen), nameof(EditBuildScreen.method_35));
|
||||||
return type.GetMethod("method_35");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[PatchPrefix]
|
[PatchPrefix]
|
||||||
private static bool Prefix(ref Task<bool> __result)
|
public static bool Prefix(ref Task<bool> __result)
|
||||||
{
|
{
|
||||||
if (MoveForward && Settings.ShowPresetConfirmations.Value == WeaponPresetConfirmationOption.Always)
|
if (MoveForward && Settings.ShowPresetConfirmations.Value == WeaponPresetConfirmationOption.Always)
|
||||||
{
|
{
|
||||||
@@ -56,7 +56,7 @@ namespace UIFixes
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
__result = Task.FromResult<bool>(true);
|
__result = Task.FromResult(true);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -41,32 +41,30 @@ namespace UIFixes
|
|||||||
{
|
{
|
||||||
protected override MethodBase GetTargetMethod()
|
protected override MethodBase GetTargetMethod()
|
||||||
{
|
{
|
||||||
return AccessTools.Method(typeof(ItemSpecificationPanel), "method_5");
|
return AccessTools.Method(typeof(ItemSpecificationPanel), nameof(ItemSpecificationPanel.method_5));
|
||||||
}
|
}
|
||||||
|
|
||||||
[PatchPostfix]
|
[PatchPostfix]
|
||||||
private static void Postfix(
|
public static void Postfix(
|
||||||
ItemSpecificationPanel __instance,
|
ItemSpecificationPanel __instance,
|
||||||
Item ___item_0,
|
Item ___item_0,
|
||||||
CompactCharacteristicPanel ____compactCharTemplate,
|
CompactCharacteristicPanel ____compactCharTemplate,
|
||||||
Transform ____compactPanel,
|
Transform ____compactPanel,
|
||||||
SimpleTooltip ___simpleTooltip_0)
|
SimpleTooltip ___simpleTooltip_0)
|
||||||
{
|
{
|
||||||
if (!Settings.ShowModStats.Value || !(___item_0 is Mod))
|
if (!Settings.ShowModStats.Value || ___item_0 is not Mod)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool changed;
|
var deepAttributes = GetDeepAttributes(___item_0, out bool changed);
|
||||||
var deepAttributes = GetDeepAttributes(___item_0, out changed);
|
|
||||||
if (!changed)
|
if (!changed)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var compactPanels = AttributeCompactPanelDictionaryField.GetValue(__instance) as IDisposable;
|
|
||||||
// Clean up existing one
|
// Clean up existing one
|
||||||
if (compactPanels != null)
|
if (AttributeCompactPanelDictionaryField.GetValue(__instance) is IDisposable compactPanels)
|
||||||
{
|
{
|
||||||
compactPanels.Dispose();
|
compactPanels.Dispose();
|
||||||
}
|
}
|
||||||
@@ -110,13 +108,13 @@ namespace UIFixes
|
|||||||
|
|
||||||
protected override MethodBase GetTargetMethod()
|
protected override MethodBase GetTargetMethod()
|
||||||
{
|
{
|
||||||
RefreshStaticMethod = AccessTools.Method(typeof(ItemSpecificationPanel), "smethod_1", null, [typeof(CompactCharacteristicPanel)]);
|
RefreshStaticMethod = AccessTools.Method(typeof(ItemSpecificationPanel), nameof(ItemSpecificationPanel.smethod_1), null, [typeof(CompactCharacteristicPanel)]);
|
||||||
|
|
||||||
return AccessTools.Method(typeof(ItemSpecificationPanel), "method_6");
|
return AccessTools.Method(typeof(ItemSpecificationPanel), nameof(ItemSpecificationPanel.method_6));
|
||||||
}
|
}
|
||||||
|
|
||||||
[PatchPrefix]
|
[PatchPrefix]
|
||||||
private static void Prefix(Item compareItem)
|
public static void Prefix(Item compareItem)
|
||||||
{
|
{
|
||||||
if (compareItem == null)
|
if (compareItem == null)
|
||||||
{
|
{
|
||||||
@@ -129,26 +127,27 @@ namespace UIFixes
|
|||||||
{
|
{
|
||||||
float maxDurability = armorComponents.Sum(c => c.Repairable.Durability);
|
float maxDurability = armorComponents.Sum(c => c.Repairable.Durability);
|
||||||
|
|
||||||
ItemAttributeClass itemAttributeClass = new ItemAttributeClass(EItemAttributeId.ArmorPoints);
|
var itemAttributeClass = new ItemAttributeClass(EItemAttributeId.ArmorPoints)
|
||||||
itemAttributeClass.Name = EItemAttributeId.ArmorPoints.GetName();
|
{
|
||||||
itemAttributeClass.Base = () => maxDurability;
|
Name = EItemAttributeId.ArmorPoints.GetName(),
|
||||||
itemAttributeClass.StringValue = () => Math.Round(maxDurability, 1).ToString(CultureInfo.InvariantCulture);
|
Base = () => maxDurability,
|
||||||
itemAttributeClass.DisplayType = () => EItemAttributeDisplayType.Compact;
|
StringValue = () => Math.Round(maxDurability, 1).ToString(CultureInfo.InvariantCulture),
|
||||||
|
DisplayType = () => EItemAttributeDisplayType.Compact
|
||||||
|
};
|
||||||
|
|
||||||
compareItem.Attributes.Insert(0, itemAttributeClass);
|
compareItem.Attributes.Insert(0, itemAttributeClass);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[PatchPostfix]
|
[PatchPostfix]
|
||||||
private static void Postfix(ItemSpecificationPanel __instance, Item compareItem)
|
public static void Postfix(ItemSpecificationPanel __instance, Item compareItem)
|
||||||
{
|
{
|
||||||
if (!Settings.ShowModStats.Value || !(compareItem is Mod))
|
if (!Settings.ShowModStats.Value || compareItem is not Mod)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool changed;
|
List<ItemAttributeClass> deepAttributes = GetDeepAttributes(compareItem, out bool changed);
|
||||||
List<ItemAttributeClass> deepAttributes = GetDeepAttributes(compareItem, out changed);
|
|
||||||
if (!changed)
|
if (!changed)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
@@ -179,7 +178,7 @@ namespace UIFixes
|
|||||||
|
|
||||||
SimpleContextMenuButtonTextField = AccessTools.Field(typeof(ContextMenuButton), "_text");
|
SimpleContextMenuButtonTextField = AccessTools.Field(typeof(ContextMenuButton), "_text");
|
||||||
|
|
||||||
return AccessTools.Method(typeof(ItemSpecificationPanel), "method_4");
|
return AccessTools.Method(typeof(ItemSpecificationPanel), nameof(ItemSpecificationPanel.method_4));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static string GetLabel()
|
private static string GetLabel()
|
||||||
@@ -188,9 +187,9 @@ namespace UIFixes
|
|||||||
}
|
}
|
||||||
|
|
||||||
[PatchPostfix]
|
[PatchPostfix]
|
||||||
private static void Postfix(ItemSpecificationPanel __instance, ItemInfoInteractionsAbstractClass<EItemInfoButton> contextInteractions, Item ___item_0, InteractionButtonsContainer ____interactionButtonsContainer)
|
public static void Postfix(ItemSpecificationPanel __instance, ItemInfoInteractionsAbstractClass<EItemInfoButton> contextInteractions, Item ___item_0, InteractionButtonsContainer ____interactionButtonsContainer)
|
||||||
{
|
{
|
||||||
if (!(___item_0 is Mod))
|
if (___item_0 is not Mod)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -200,25 +199,28 @@ namespace UIFixes
|
|||||||
|
|
||||||
SimpleContextMenuButton toggleButton = null;
|
SimpleContextMenuButton toggleButton = null;
|
||||||
|
|
||||||
Action onClick = () => Settings.ShowModStats.Value = !Settings.ShowModStats.Value;
|
|
||||||
|
|
||||||
// Listen to the setting and the work there to handle multiple windows open at once
|
// Listen to the setting and the work there to handle multiple windows open at once
|
||||||
EventHandler onSettingChanged = (sender, args) =>
|
void onSettingChanged(object sender, EventArgs args)
|
||||||
{
|
{
|
||||||
var text = SimpleContextMenuButtonTextField.GetValue(toggleButton) as TextMeshProUGUI;
|
var text = SimpleContextMenuButtonTextField.GetValue(toggleButton) as TextMeshProUGUI;
|
||||||
text.text = GetLabel();
|
text.text = GetLabel();
|
||||||
|
|
||||||
__instance.method_5(); // rebuild stat panels
|
__instance.method_5(); // rebuild stat panels
|
||||||
};
|
}
|
||||||
Settings.ShowModStats.SettingChanged += onSettingChanged;
|
Settings.ShowModStats.SettingChanged += onSettingChanged;
|
||||||
|
|
||||||
Action createButton = () =>
|
static void onClick()
|
||||||
|
{
|
||||||
|
Settings.ShowModStats.Value = !Settings.ShowModStats.Value;
|
||||||
|
}
|
||||||
|
|
||||||
|
void createButton()
|
||||||
{
|
{
|
||||||
Sprite sprite = CacheResourcesPopAbstractClass.Pop<Sprite>("Characteristics/Icons/Modding");
|
Sprite sprite = CacheResourcesPopAbstractClass.Pop<Sprite>("Characteristics/Icons/Modding");
|
||||||
toggleButton = UnityEngine.Object.Instantiate(template, transform, false);
|
toggleButton = UnityEngine.Object.Instantiate(template, transform, false);
|
||||||
toggleButton.Show(GetLabel(), null, sprite, onClick, null);
|
toggleButton.Show(GetLabel(), null, sprite, onClick, null);
|
||||||
____interactionButtonsContainer.method_5(toggleButton); // add to disposable list
|
____interactionButtonsContainer.method_5(toggleButton); // add to disposable list
|
||||||
};
|
}
|
||||||
|
|
||||||
// Subscribe to redraws to recreate when mods get dropped in
|
// Subscribe to redraws to recreate when mods get dropped in
|
||||||
contextInteractions.OnRedrawRequired += createButton;
|
contextInteractions.OnRedrawRequired += createButton;
|
||||||
@@ -238,11 +240,11 @@ namespace UIFixes
|
|||||||
{
|
{
|
||||||
protected override MethodBase GetTargetMethod()
|
protected override MethodBase GetTargetMethod()
|
||||||
{
|
{
|
||||||
return AccessTools.Method(typeof(CompactCharacteristicPanel), "SetValues");
|
return AccessTools.Method(typeof(CompactCharacteristicPanel), nameof(CompactCharacteristicPanel.SetValues));
|
||||||
}
|
}
|
||||||
|
|
||||||
[PatchPostfix]
|
[PatchPostfix]
|
||||||
private static void Postfix(CompactCharacteristicPanel __instance, TextMeshProUGUI ___ValueText)
|
public static void Postfix(CompactCharacteristicPanel __instance, TextMeshProUGUI ___ValueText)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -262,14 +264,14 @@ namespace UIFixes
|
|||||||
|
|
||||||
protected override MethodBase GetTargetMethod()
|
protected override MethodBase GetTargetMethod()
|
||||||
{
|
{
|
||||||
RoundToIntMethod = AccessTools.Method(typeof(Mathf), "RoundToInt");
|
RoundToIntMethod = AccessTools.Method(typeof(Mathf), nameof(Mathf.RoundToInt));
|
||||||
ToStringMethod = AccessTools.Method(typeof(float), "ToString", [typeof(string)]);
|
ToStringMethod = AccessTools.Method(typeof(float), nameof(float.ToString), [typeof(string)]);
|
||||||
|
|
||||||
return AccessTools.Method(typeof(CharacteristicPanel), "SetValues");
|
return AccessTools.Method(typeof(CharacteristicPanel), nameof(CharacteristicPanel.SetValues));
|
||||||
}
|
}
|
||||||
|
|
||||||
[PatchPostfix]
|
[PatchPostfix]
|
||||||
private static void Postfix(CharacteristicPanel __instance, TextMeshProUGUI ___ValueText)
|
public static void Postfix(CharacteristicPanel __instance, TextMeshProUGUI ___ValueText)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -283,7 +285,7 @@ namespace UIFixes
|
|||||||
|
|
||||||
// This transpiler looks for where it rounds a float to an int, and skips that. Instead it calls ToString("0.0#") on it
|
// This transpiler looks for where it rounds a float to an int, and skips that. Instead it calls ToString("0.0#") on it
|
||||||
[PatchTranspiler]
|
[PatchTranspiler]
|
||||||
private static IEnumerable<CodeInstruction> Transpile(IEnumerable<CodeInstruction> instructions)
|
public static IEnumerable<CodeInstruction> Transpile(IEnumerable<CodeInstruction> instructions)
|
||||||
{
|
{
|
||||||
int skip = 0;
|
int skip = 0;
|
||||||
CodeInstruction lastInstruction = null;
|
CodeInstruction lastInstruction = null;
|
||||||
@@ -351,18 +353,15 @@ namespace UIFixes
|
|||||||
// Completely redo it
|
// Completely redo it
|
||||||
if ((EItemAttributeId)attribute.Id == EItemAttributeId.CenterOfImpact)
|
if ((EItemAttributeId)attribute.Id == EItemAttributeId.CenterOfImpact)
|
||||||
{
|
{
|
||||||
ItemAttributeClass compareAttribute = CompactCharacteristicPanelCompareItemAttributeField.GetValue(panel) as ItemAttributeClass;
|
if (CompactCharacteristicPanelCompareItemAttributeField.GetValue(panel) is ItemAttributeClass compareAttribute)
|
||||||
if (compareAttribute != null)
|
|
||||||
{
|
{
|
||||||
string currentStringValue = attribute.StringValue();
|
string currentStringValue = attribute.StringValue();
|
||||||
var moaMatch = Regex.Match(currentStringValue, @"^(\S+)");
|
var moaMatch = Regex.Match(currentStringValue, @"^(\S+)");
|
||||||
float moa;
|
if (float.TryParse(moaMatch.Groups[1].Value, out float moa))
|
||||||
if (float.TryParse(moaMatch.Groups[1].Value, out moa))
|
|
||||||
{
|
{
|
||||||
string compareStringValue = compareAttribute.StringValue();
|
string compareStringValue = compareAttribute.StringValue();
|
||||||
moaMatch = Regex.Match(compareStringValue, @"^(\S+)");
|
moaMatch = Regex.Match(compareStringValue, @"^(\S+)");
|
||||||
float compareMoa;
|
if (float.TryParse(moaMatch.Groups[1].Value, out float compareMoa))
|
||||||
if (float.TryParse(moaMatch.Groups[1].Value, out compareMoa))
|
|
||||||
{
|
{
|
||||||
float delta = compareMoa - moa;
|
float delta = compareMoa - moa;
|
||||||
string final = currentStringValue;
|
string final = currentStringValue;
|
||||||
@@ -384,9 +383,8 @@ namespace UIFixes
|
|||||||
var match = Regex.Match(text, @" %\(([+-].*)\)");
|
var match = Regex.Match(text, @" %\(([+-].*)\)");
|
||||||
if (match.Success)
|
if (match.Success)
|
||||||
{
|
{
|
||||||
float value;
|
|
||||||
// If this fails to parse, I don't know what it is, leave it be
|
// If this fails to parse, I don't know what it is, leave it be
|
||||||
if (float.TryParse(match.Groups[1].Value, out value))
|
if (float.TryParse(match.Groups[1].Value, out float value))
|
||||||
{
|
{
|
||||||
string sign = value > 0 ? "+" : "";
|
string sign = value > 0 ? "+" : "";
|
||||||
string color = (attribute.LessIsGood && value < 0) || (!attribute.LessIsGood && value > 0) ? IncreasingColorHex : DecreasingColorHex;
|
string color = (attribute.LessIsGood && value < 0) || (!attribute.LessIsGood && value > 0) ? IncreasingColorHex : DecreasingColorHex;
|
||||||
@@ -408,9 +406,8 @@ namespace UIFixes
|
|||||||
match = Regex.Match(text, @"(\S)%\(([+-].*)\)");
|
match = Regex.Match(text, @"(\S)%\(([+-].*)\)");
|
||||||
if (match.Success)
|
if (match.Success)
|
||||||
{
|
{
|
||||||
float value;
|
|
||||||
// If this fails to parse, I don't know what it is, leave it be
|
// If this fails to parse, I don't know what it is, leave it be
|
||||||
if (float.TryParse(match.Groups[2].Value, out value))
|
if (float.TryParse(match.Groups[2].Value, out float value))
|
||||||
{
|
{
|
||||||
string sign = value > 0 ? "+" : "";
|
string sign = value > 0 ? "+" : "";
|
||||||
string color = (attribute.LessIsGood && value < 0) || (!attribute.LessIsGood && value > 0) ? IncreasingColorHex : DecreasingColorHex;
|
string color = (attribute.LessIsGood && value < 0) || (!attribute.LessIsGood && value > 0) ? IncreasingColorHex : DecreasingColorHex;
|
||||||
@@ -423,9 +420,8 @@ namespace UIFixes
|
|||||||
match = Regex.Match(text, @"\(([+-].*)\)");
|
match = Regex.Match(text, @"\(([+-].*)\)");
|
||||||
if (match.Success)
|
if (match.Success)
|
||||||
{
|
{
|
||||||
float value;
|
|
||||||
// If this fails to parse, I don't know what it is, leave it be
|
// If this fails to parse, I don't know what it is, leave it be
|
||||||
if (float.TryParse(match.Groups[1].Value, out value))
|
if (float.TryParse(match.Groups[1].Value, out float value))
|
||||||
{
|
{
|
||||||
string sign = value > 0 ? "+" : "";
|
string sign = value > 0 ? "+" : "";
|
||||||
string color = (attribute.LessIsGood && value < 0) || (!attribute.LessIsGood && value > 0) ? IncreasingColorHex : DecreasingColorHex;
|
string color = (attribute.LessIsGood && value < 0) || (!attribute.LessIsGood && value > 0) ? IncreasingColorHex : DecreasingColorHex;
|
||||||
@@ -471,7 +467,7 @@ namespace UIFixes
|
|||||||
|
|
||||||
private static IEnumerable<ItemAttributeClass> CombineAttributes(IList<ItemAttributeClass> first, IList<ItemAttributeClass> second)
|
private static IEnumerable<ItemAttributeClass> CombineAttributes(IList<ItemAttributeClass> first, IList<ItemAttributeClass> second)
|
||||||
{
|
{
|
||||||
foreach (EItemAttributeId id in first.Select(a => a.Id).Union(second.Select(a => a.Id)))
|
foreach (EItemAttributeId id in first.Select(a => a.Id).Union(second.Select(a => a.Id)).Select(v => (EItemAttributeId)v))
|
||||||
{
|
{
|
||||||
// Need to cast the id since it's of type Enum for some reason
|
// Need to cast the id since it's of type Enum for some reason
|
||||||
var attribute = first.FirstOrDefault(a => (EItemAttributeId)a.Id == id);
|
var attribute = first.FirstOrDefault(a => (EItemAttributeId)a.Id == id);
|
||||||
|
@@ -35,11 +35,11 @@ namespace UIFixes
|
|||||||
{
|
{
|
||||||
protected override MethodBase GetTargetMethod()
|
protected override MethodBase GetTargetMethod()
|
||||||
{
|
{
|
||||||
return AccessTools.Method(typeof(StretchArea), "OnDrag");
|
return AccessTools.Method(typeof(StretchArea), nameof(StretchArea.OnDrag));
|
||||||
}
|
}
|
||||||
|
|
||||||
[PatchPostfix]
|
[PatchPostfix]
|
||||||
private static void Postfix(LayoutElement ___layoutElement_0)
|
public static void Postfix(LayoutElement ___layoutElement_0)
|
||||||
{
|
{
|
||||||
if (!Settings.RememberInspectSize.Value || ___layoutElement_0.GetComponent<ItemSpecificationPanel>() == null)
|
if (!Settings.RememberInspectSize.Value || ___layoutElement_0.GetComponent<ItemSpecificationPanel>() == null)
|
||||||
{
|
{
|
||||||
@@ -62,11 +62,11 @@ namespace UIFixes
|
|||||||
|
|
||||||
protected override MethodBase GetTargetMethod()
|
protected override MethodBase GetTargetMethod()
|
||||||
{
|
{
|
||||||
return AccessTools.Method(typeof(ItemSpecificationPanel), "Show");
|
return AccessTools.Method(typeof(ItemSpecificationPanel), nameof(ItemSpecificationPanel.Show));
|
||||||
}
|
}
|
||||||
|
|
||||||
[PatchPrefix]
|
[PatchPrefix]
|
||||||
private static void Prefix(LayoutElement ___layoutElement_0)
|
public static void Prefix(LayoutElement ___layoutElement_0)
|
||||||
{
|
{
|
||||||
if (Settings.RememberInspectSize.Value)
|
if (Settings.RememberInspectSize.Value)
|
||||||
{
|
{
|
||||||
@@ -75,7 +75,7 @@ namespace UIFixes
|
|||||||
}
|
}
|
||||||
|
|
||||||
[PatchPostfix]
|
[PatchPostfix]
|
||||||
private static void Postfix(ItemSpecificationPanel __instance, LayoutElement ___layoutElement_0)
|
public static void Postfix(ItemSpecificationPanel __instance, LayoutElement ___layoutElement_0)
|
||||||
{
|
{
|
||||||
if (Settings.LockInspectPreviewSize.Value)
|
if (Settings.LockInspectPreviewSize.Value)
|
||||||
{
|
{
|
||||||
@@ -191,7 +191,7 @@ namespace UIFixes
|
|||||||
|
|
||||||
LayoutRebuilder.ForceRebuildLayoutImmediate(layoutRect);
|
LayoutRebuilder.ForceRebuildLayoutImmediate(layoutRect);
|
||||||
|
|
||||||
layoutRect.CorrectPositionResolution(default(MarginsStruct));
|
layoutRect.CorrectPositionResolution(default);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -217,11 +217,11 @@ namespace UIFixes
|
|||||||
{
|
{
|
||||||
protected override MethodBase GetTargetMethod()
|
protected override MethodBase GetTargetMethod()
|
||||||
{
|
{
|
||||||
return AccessTools.Method(typeof(ItemUiContext), "Inspect");
|
return AccessTools.Method(typeof(ItemUiContext), nameof(ItemUiContext.Inspect));
|
||||||
}
|
}
|
||||||
|
|
||||||
[PatchPostfix]
|
[PatchPostfix]
|
||||||
private static void Postfix(List<InputNode> ____children)
|
public static void Postfix(List<InputNode> ____children)
|
||||||
{
|
{
|
||||||
var inspectWindow = ____children.Last();
|
var inspectWindow = ____children.Last();
|
||||||
if (inspectWindow != null)
|
if (inspectWindow != null)
|
||||||
|
@@ -1,5 +1,6 @@
|
|||||||
using Aki.Reflection.Patching;
|
using Aki.Reflection.Patching;
|
||||||
using EFT.UI.Chat;
|
using EFT.UI.Chat;
|
||||||
|
using HarmonyLib;
|
||||||
using System;
|
using System;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
|
|
||||||
@@ -9,12 +10,11 @@ namespace UIFixes
|
|||||||
{
|
{
|
||||||
protected override MethodBase GetTargetMethod()
|
protected override MethodBase GetTargetMethod()
|
||||||
{
|
{
|
||||||
Type type = typeof(ChatMessageSendBlock);
|
return AccessTools.Method(typeof(ChatMessageSendBlock), nameof(ChatMessageSendBlock.Show));
|
||||||
return type.GetMethod("Show", BindingFlags.Public | BindingFlags.Instance);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[PatchPrefix]
|
[PatchPrefix]
|
||||||
private static void Prefix(DialogueClass dialogue)
|
public static void Prefix(DialogueClass dialogue)
|
||||||
{
|
{
|
||||||
// Force this false will recalculate each time. This is less than ideal, but the way the code is structured makes it very difficult to do correctly.
|
// Force this false will recalculate each time. This is less than ideal, but the way the code is structured makes it very difficult to do correctly.
|
||||||
dialogue.HasMessagesWithRewards = false;
|
dialogue.HasMessagesWithRewards = false;
|
||||||
|
@@ -15,7 +15,7 @@ namespace UIFixes
|
|||||||
private static FieldInfo ProductionPanelSearch;
|
private static FieldInfo ProductionPanelSearch;
|
||||||
private static FieldInfo SubstrateContentLayoutField;
|
private static FieldInfo SubstrateContentLayoutField;
|
||||||
|
|
||||||
private static Dictionary<string, string> LastSearches = [];
|
private static readonly Dictionary<string, string> LastSearches = [];
|
||||||
|
|
||||||
public static void Enable()
|
public static void Enable()
|
||||||
{
|
{
|
||||||
@@ -45,7 +45,7 @@ namespace UIFixes
|
|||||||
}
|
}
|
||||||
|
|
||||||
[PatchPostfix]
|
[PatchPostfix]
|
||||||
private static void Postfix(ProductionPanel.Class1631 __instance, GClass1923 scheme, ProduceView view)
|
public static void Postfix(ProductionPanel.Class1631 __instance, GClass1923 scheme, ProduceView view)
|
||||||
{
|
{
|
||||||
var searchField = ProductionPanelSearch.GetValue(__instance.productionPanel_0) as ValidationInputField;
|
var searchField = ProductionPanelSearch.GetValue(__instance.productionPanel_0) as ValidationInputField;
|
||||||
if (searchField.text.Length > 0 && scheme.endProduct.LocalizedName().IndexOf(searchField.text, StringComparison.InvariantCultureIgnoreCase) < 0)
|
if (searchField.text.Length > 0 && scheme.endProduct.LocalizedName().IndexOf(searchField.text, StringComparison.InvariantCultureIgnoreCase) < 0)
|
||||||
@@ -61,21 +61,20 @@ namespace UIFixes
|
|||||||
|
|
||||||
protected override MethodBase GetTargetMethod()
|
protected override MethodBase GetTargetMethod()
|
||||||
{
|
{
|
||||||
return AccessTools.Method(typeof(ProductionPanel), "ShowContents");
|
return AccessTools.Method(typeof(ProductionPanel), nameof(ProductionPanel.ShowContents));
|
||||||
}
|
}
|
||||||
|
|
||||||
[PatchPrefix]
|
[PatchPrefix]
|
||||||
private static void Prefix(ProductionPanel __instance, ValidationInputField ____searchInputField)
|
public static void Prefix(ProductionPanel __instance, ValidationInputField ____searchInputField)
|
||||||
{
|
{
|
||||||
string lastSearch;
|
if (LastSearches.TryGetValue(__instance.AreaData.ToString(), out string lastSearch))
|
||||||
if (LastSearches.TryGetValue(__instance.AreaData.ToString(), out lastSearch))
|
|
||||||
{
|
{
|
||||||
____searchInputField.text = lastSearch;
|
____searchInputField.text = lastSearch;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[PatchPostfix]
|
[PatchPostfix]
|
||||||
private static void Postfix(ProductionPanel __instance, ValidationInputField ____searchInputField)
|
public static void Postfix(ProductionPanel __instance, ValidationInputField ____searchInputField)
|
||||||
{
|
{
|
||||||
// Force it to render immediately, at full height, even if the search filtering would reduce the number of children
|
// Force it to render immediately, at full height, even if the search filtering would reduce the number of children
|
||||||
if (__instance.method_4().Count() > 2)
|
if (__instance.method_4().Count() > 2)
|
||||||
@@ -96,13 +95,13 @@ namespace UIFixes
|
|||||||
{
|
{
|
||||||
protected override MethodBase GetTargetMethod()
|
protected override MethodBase GetTargetMethod()
|
||||||
{
|
{
|
||||||
return AccessTools.Method(typeof(ProductionPanel), "method_4");
|
return AccessTools.Method(typeof(ProductionPanel), nameof(ProductionPanel.method_4));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Working with GClasses directly here, because this would be a nightmare with reflection
|
// Working with GClasses directly here, because this would be a nightmare with reflection
|
||||||
// Copied directly from method_4
|
// Copied directly from method_4
|
||||||
[PatchPrefix]
|
[PatchPrefix]
|
||||||
private static bool Prefix(ref IEnumerable<GClass1923> __result, ProductionPanel __instance, GClass1922[] ___gclass1922_0, ValidationInputField ____searchInputField)
|
public static bool Prefix(ref IEnumerable<GClass1923> __result, ProductionPanel __instance, GClass1922[] ___gclass1922_0, ValidationInputField ____searchInputField)
|
||||||
{
|
{
|
||||||
__result = ___gclass1922_0.OfType<GClass1923>().Where(scheme => !scheme.locked)
|
__result = ___gclass1922_0.OfType<GClass1923>().Where(scheme => !scheme.locked)
|
||||||
.OrderBy(scheme => scheme.endProduct.LocalizedName().Contains(____searchInputField.text) ? 0 : 1) // search-matching items first
|
.OrderBy(scheme => scheme.endProduct.LocalizedName().Contains(____searchInputField.text) ? 0 : 1) // search-matching items first
|
||||||
@@ -119,11 +118,11 @@ namespace UIFixes
|
|||||||
{
|
{
|
||||||
protected override MethodBase GetTargetMethod()
|
protected override MethodBase GetTargetMethod()
|
||||||
{
|
{
|
||||||
return AccessTools.Method(typeof(ProductionPanel), "method_9");
|
return AccessTools.Method(typeof(ProductionPanel), nameof(ProductionPanel.method_9));
|
||||||
}
|
}
|
||||||
|
|
||||||
[PatchPrefix]
|
[PatchPrefix]
|
||||||
private static void Prefix(ProductionPanel __instance)
|
public static void Prefix(ProductionPanel __instance)
|
||||||
{
|
{
|
||||||
__instance.method_8(); // update sort order
|
__instance.method_8(); // update sort order
|
||||||
}
|
}
|
||||||
@@ -134,11 +133,11 @@ namespace UIFixes
|
|||||||
{
|
{
|
||||||
protected override MethodBase GetTargetMethod()
|
protected override MethodBase GetTargetMethod()
|
||||||
{
|
{
|
||||||
return AccessTools.Method(typeof(ProductionPanel), "Close");
|
return AccessTools.Method(typeof(ProductionPanel), nameof(ProductionPanel.Close));
|
||||||
}
|
}
|
||||||
|
|
||||||
[PatchPrefix]
|
[PatchPrefix]
|
||||||
private static void Prefix(ProductionPanel __instance, ValidationInputField ____searchInputField)
|
public static void Prefix(ProductionPanel __instance, ValidationInputField ____searchInputField)
|
||||||
{
|
{
|
||||||
LastSearches[__instance.AreaData.ToString()] = ____searchInputField.text;
|
LastSearches[__instance.AreaData.ToString()] = ____searchInputField.text;
|
||||||
|
|
||||||
@@ -154,11 +153,11 @@ namespace UIFixes
|
|||||||
{
|
{
|
||||||
protected override MethodBase GetTargetMethod()
|
protected override MethodBase GetTargetMethod()
|
||||||
{
|
{
|
||||||
return AccessTools.Method(typeof(HideoutScreenOverlay), "ReturnToPreviousState");
|
return AccessTools.Method(typeof(HideoutScreenOverlay), nameof(HideoutScreenOverlay.ReturnToPreviousState));
|
||||||
}
|
}
|
||||||
|
|
||||||
[PatchPostfix]
|
[PatchPostfix]
|
||||||
private static void Postfix()
|
public static void Postfix()
|
||||||
{
|
{
|
||||||
LastSearches.Clear();
|
LastSearches.Clear();
|
||||||
}
|
}
|
||||||
|
@@ -126,23 +126,18 @@ namespace UIFixes
|
|||||||
{
|
{
|
||||||
protected override MethodBase GetTargetMethod()
|
protected override MethodBase GetTargetMethod()
|
||||||
{
|
{
|
||||||
Type type = typeof(SimpleStashPanel);
|
return AccessTools.Method(typeof(SimpleStashPanel), nameof(SimpleStashPanel.Update));
|
||||||
return type.GetMethod("Update", BindingFlags.Public | BindingFlags.Instance);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[PatchPrefix]
|
[PatchPrefix]
|
||||||
private static void Prefix(SimpleStashPanel __instance, ScrollRect ____stashScroll)
|
public static void Prefix(SimpleStashPanel __instance, ScrollRect ____stashScroll)
|
||||||
{
|
{
|
||||||
if (____stashScroll == null)
|
// For some reason, sometimes SimpleStashPanel doesn't have a reference to its own ScrollRect?
|
||||||
{
|
HandleInput(____stashScroll ?? __instance.GetComponentInChildren<ScrollRect>());
|
||||||
// For some reason, sometimes SimpleStashPanel doesn't have a reference to its own ScrollRect?
|
|
||||||
____stashScroll = __instance.GetComponentInChildren<ScrollRect>();
|
|
||||||
}
|
|
||||||
HandleInput(____stashScroll);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[PatchTranspiler]
|
[PatchTranspiler]
|
||||||
private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
|
public static IEnumerable<CodeInstruction> Transpile(IEnumerable<CodeInstruction> instructions)
|
||||||
{
|
{
|
||||||
if (Settings.RebindPageUpDown.Value)
|
if (Settings.RebindPageUpDown.Value)
|
||||||
{
|
{
|
||||||
@@ -157,18 +152,17 @@ namespace UIFixes
|
|||||||
{
|
{
|
||||||
protected override MethodBase GetTargetMethod()
|
protected override MethodBase GetTargetMethod()
|
||||||
{
|
{
|
||||||
Type type = typeof(TraderDealScreen);
|
return AccessTools.Method(typeof(TraderDealScreen), nameof(TraderDealScreen.Update));
|
||||||
return type.GetMethod("Update", BindingFlags.Public | BindingFlags.Instance);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[PatchPrefix]
|
[PatchPrefix]
|
||||||
private static void Prefix(TraderDealScreen __instance, TraderDealScreen.ETraderMode ___etraderMode_0, ScrollRect ____traderScroll, ScrollRect ____stashScroll)
|
public static void Prefix(TraderDealScreen.ETraderMode ___etraderMode_0, ScrollRect ____traderScroll, ScrollRect ____stashScroll)
|
||||||
{
|
{
|
||||||
HandleInput(___etraderMode_0 == TraderDealScreen.ETraderMode.Purchase ? ____traderScroll : ____stashScroll);
|
HandleInput(___etraderMode_0 == TraderDealScreen.ETraderMode.Purchase ? ____traderScroll : ____stashScroll);
|
||||||
}
|
}
|
||||||
|
|
||||||
[PatchTranspiler]
|
[PatchTranspiler]
|
||||||
private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
|
public static IEnumerable<CodeInstruction> Transpile(IEnumerable<CodeInstruction> instructions)
|
||||||
{
|
{
|
||||||
if (Settings.RebindPageUpDown.Value)
|
if (Settings.RebindPageUpDown.Value)
|
||||||
{
|
{
|
||||||
@@ -183,12 +177,11 @@ namespace UIFixes
|
|||||||
{
|
{
|
||||||
protected override MethodBase GetTargetMethod()
|
protected override MethodBase GetTargetMethod()
|
||||||
{
|
{
|
||||||
Type type = typeof(OfferViewList);
|
return AccessTools.Method(typeof(OfferViewList), nameof(OfferViewList.Update));
|
||||||
return type.GetMethod("Update", BindingFlags.Public | BindingFlags.Instance);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[PatchPrefix]
|
[PatchPrefix]
|
||||||
private static void Prefix(OfferViewList __instance, LightScroller ____scroller)
|
public static void Prefix(LightScroller ____scroller)
|
||||||
{
|
{
|
||||||
HandleInput(____scroller);
|
HandleInput(____scroller);
|
||||||
}
|
}
|
||||||
@@ -209,12 +202,11 @@ namespace UIFixes
|
|||||||
{
|
{
|
||||||
protected override MethodBase GetTargetMethod()
|
protected override MethodBase GetTargetMethod()
|
||||||
{
|
{
|
||||||
Type type = typeof(MessagesContainer);
|
return AccessTools.Method(typeof(MessagesContainer), nameof(MessagesContainer.Update));
|
||||||
return type.GetMethod("Update", BindingFlags.Public | BindingFlags.Instance);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[PatchPrefix]
|
[PatchPrefix]
|
||||||
private static void Prefix(MessagesContainer __instance, LightScroller ____scroller)
|
public static void Prefix(LightScroller ____scroller)
|
||||||
{
|
{
|
||||||
HandleInput(____scroller);
|
HandleInput(____scroller);
|
||||||
}
|
}
|
||||||
@@ -235,12 +227,11 @@ namespace UIFixes
|
|||||||
{
|
{
|
||||||
protected override MethodBase GetTargetMethod()
|
protected override MethodBase GetTargetMethod()
|
||||||
{
|
{
|
||||||
Type type = typeof(ScrollRectNoDrag);
|
return AccessTools.Method(typeof(ScrollRectNoDrag), nameof(ScrollRectNoDrag.OnScroll)); //type.GetMethod("OnScroll");
|
||||||
return type.GetMethod("OnScroll");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[PatchPrefix]
|
[PatchPrefix]
|
||||||
private static void Prefix(PointerEventData data)
|
public static void Prefix(PointerEventData data)
|
||||||
{
|
{
|
||||||
data.scrollDelta *= Settings.MouseScrollMulti.Value;
|
data.scrollDelta *= Settings.MouseScrollMulti.Value;
|
||||||
}
|
}
|
||||||
|
@@ -39,11 +39,11 @@ namespace UIFixes
|
|||||||
{
|
{
|
||||||
protected override MethodBase GetTargetMethod()
|
protected override MethodBase GetTargetMethod()
|
||||||
{
|
{
|
||||||
return AccessTools.Method(typeof(SimpleStashPanel), "Show");
|
return AccessTools.Method(typeof(SimpleStashPanel), nameof(SimpleStashPanel.Show));
|
||||||
}
|
}
|
||||||
|
|
||||||
[PatchPostfix]
|
[PatchPostfix]
|
||||||
private static void Postfix(SimpleStashPanel __instance)
|
public static void Postfix(SimpleStashPanel __instance)
|
||||||
{
|
{
|
||||||
SynchronizeScrollRect(__instance);
|
SynchronizeScrollRect(__instance);
|
||||||
}
|
}
|
||||||
@@ -53,13 +53,13 @@ namespace UIFixes
|
|||||||
{
|
{
|
||||||
protected override MethodBase GetTargetMethod()
|
protected override MethodBase GetTargetMethod()
|
||||||
{
|
{
|
||||||
return AccessTools.Method(typeof(TraderDealScreen), "method_3");
|
return AccessTools.Method(typeof(TraderDealScreen), nameof(TraderDealScreen.method_3));
|
||||||
}
|
}
|
||||||
|
|
||||||
// TraderDealScreen is a monstrosity that loads multiple times and isn't done loading when Show() is done
|
// TraderDealScreen is a monstrosity that loads multiple times and isn't done loading when Show() is done
|
||||||
// method_3 shows the stash grid, if method_5() returned true
|
// method_3 shows the stash grid, if method_5() returned true
|
||||||
[PatchPostfix]
|
[PatchPostfix]
|
||||||
private static void Postfix(TraderDealScreen __instance, ScrollRect ____stashScroll)
|
public static void Postfix(TraderDealScreen __instance, ScrollRect ____stashScroll)
|
||||||
{
|
{
|
||||||
if (__instance.method_5())
|
if (__instance.method_5())
|
||||||
{
|
{
|
||||||
@@ -72,11 +72,11 @@ namespace UIFixes
|
|||||||
{
|
{
|
||||||
protected override MethodBase GetTargetMethod()
|
protected override MethodBase GetTargetMethod()
|
||||||
{
|
{
|
||||||
return AccessTools.Method(typeof(AddOfferWindow), "Show");
|
return AccessTools.Method(typeof(AddOfferWindow), nameof(AddOfferWindow.Show));
|
||||||
}
|
}
|
||||||
|
|
||||||
[PatchPostfix]
|
[PatchPostfix]
|
||||||
private static void Postfix(AddOfferWindow __instance)
|
public static void Postfix(AddOfferWindow __instance)
|
||||||
{
|
{
|
||||||
SynchronizeScrollRect(__instance);
|
SynchronizeScrollRect(__instance);
|
||||||
}
|
}
|
||||||
|
@@ -46,7 +46,7 @@ namespace UIFixes
|
|||||||
// The most recent GridItemView that was hovered - needed to forcibly update hover state after swap
|
// The most recent GridItemView that was hovered - needed to forcibly update hover state after swap
|
||||||
private static GridItemView LastHoveredGridItemView;
|
private static GridItemView LastHoveredGridItemView;
|
||||||
|
|
||||||
private static EOwnerType[] BannedOwnerTypes = [EOwnerType.Mail, EOwnerType.Trader];
|
private static readonly EOwnerType[] BannedOwnerTypes = [EOwnerType.Mail, EOwnerType.Trader];
|
||||||
|
|
||||||
public static void Enable()
|
public static void Enable()
|
||||||
{
|
{
|
||||||
@@ -61,7 +61,7 @@ namespace UIFixes
|
|||||||
CanAcceptOperationSucceededProperty = AccessTools.Property(CanAcceptOperationType, "Succeeded");
|
CanAcceptOperationSucceededProperty = AccessTools.Property(CanAcceptOperationType, "Succeeded");
|
||||||
CanAcceptOperationErrorProperty = AccessTools.Property(CanAcceptOperationType, "Error");
|
CanAcceptOperationErrorProperty = AccessTools.Property(CanAcceptOperationType, "Error");
|
||||||
|
|
||||||
SwapOperationType = AccessTools.Method(typeof(InteractionsHandlerClass), "Swap").ReturnType; // GStruct414<GClass2797>
|
SwapOperationType = AccessTools.Method(typeof(InteractionsHandlerClass), nameof(InteractionsHandlerClass.Swap)).ReturnType; // GStruct414<GClass2797>
|
||||||
SwapOperationToCanAcceptOperationOperator = SwapOperationType.GetMethods().First(m => m.Name == "op_Implicit" && m.ReturnType == CanAcceptOperationType);
|
SwapOperationToCanAcceptOperationOperator = SwapOperationType.GetMethods().First(m => m.Name == "op_Implicit" && m.ReturnType == CanAcceptOperationType);
|
||||||
|
|
||||||
GridViewNonInteractableField = AccessTools.Field(typeof(GridView), "_nonInteractable");
|
GridViewNonInteractableField = AccessTools.Field(typeof(GridView), "_nonInteractable");
|
||||||
@@ -146,8 +146,7 @@ namespace UIFixes
|
|||||||
private static bool CouldEverFit(ItemContextClass itemContext, ItemContextAbstractClass containerItemContext)
|
private static bool CouldEverFit(ItemContextClass itemContext, ItemContextAbstractClass containerItemContext)
|
||||||
{
|
{
|
||||||
Item item = itemContext.Item;
|
Item item = itemContext.Item;
|
||||||
LootItemClass container = containerItemContext.Item as LootItemClass;
|
if (containerItemContext.Item is not LootItemClass container)
|
||||||
if (container == null)
|
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -171,12 +170,11 @@ namespace UIFixes
|
|||||||
{
|
{
|
||||||
protected override MethodBase GetTargetMethod()
|
protected override MethodBase GetTargetMethod()
|
||||||
{
|
{
|
||||||
Type type = typeof(ItemView);
|
return AccessTools.Method(typeof(ItemView), nameof(ItemView.OnDrag));
|
||||||
return type.GetMethod("OnDrag");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[PatchPrefix]
|
[PatchPrefix]
|
||||||
private static void Prefix(ItemView __instance)
|
public static void Prefix(ItemView __instance)
|
||||||
{
|
{
|
||||||
SourceContainer = __instance.Container;
|
SourceContainer = __instance.Container;
|
||||||
}
|
}
|
||||||
@@ -188,9 +186,8 @@ namespace UIFixes
|
|||||||
|
|
||||||
protected override MethodBase GetTargetMethod()
|
protected override MethodBase GetTargetMethod()
|
||||||
{
|
{
|
||||||
Type type = typeof(GridView);
|
GridViewTraderControllerClassField = AccessTools.GetDeclaredFields(typeof(GridView)).First(f => f.FieldType == typeof(TraderControllerClass));
|
||||||
GridViewTraderControllerClassField = AccessTools.GetDeclaredFields(type).First(f => f.FieldType == typeof(TraderControllerClass));
|
return AccessTools.Method(typeof(GridView), nameof(GridView.CanAccept));
|
||||||
return type.GetMethod("CanAccept");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Essentially doing what happens in StashGridClass.method_6, which checks if any of the squares are already taken
|
// Essentially doing what happens in StashGridClass.method_6, which checks if any of the squares are already taken
|
||||||
@@ -236,7 +233,7 @@ namespace UIFixes
|
|||||||
}
|
}
|
||||||
|
|
||||||
[PatchPostfix]
|
[PatchPostfix]
|
||||||
private static void Postfix(GridView __instance, ItemContextClass itemContext, ItemContextAbstractClass targetItemContext, ref object operation, ref bool __result, Dictionary<string, ItemView> ___dictionary_0)
|
public static void Postfix(GridView __instance, ItemContextClass itemContext, ItemContextAbstractClass targetItemContext, ref object operation, ref bool __result, Dictionary<string, ItemView> ___dictionary_0)
|
||||||
{
|
{
|
||||||
if (!ValidPrerequisites(itemContext, targetItemContext, operation))
|
if (!ValidPrerequisites(itemContext, targetItemContext, operation))
|
||||||
{
|
{
|
||||||
@@ -254,8 +251,7 @@ namespace UIFixes
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Repair kits are special
|
// Repair kits are special
|
||||||
ItemView targetItemView;
|
if (___dictionary_0.TryGetValue(targetItem.Id, out ItemView targetItemView))
|
||||||
if (___dictionary_0.TryGetValue(targetItem.Id, out targetItemView))
|
|
||||||
{
|
{
|
||||||
if (targetItemView.CanInteract(itemContext))
|
if (targetItemView.CanInteract(itemContext))
|
||||||
{
|
{
|
||||||
@@ -328,21 +324,15 @@ namespace UIFixes
|
|||||||
// Swap does not do that, because spaghetti, so do it here.
|
// Swap does not do that, because spaghetti, so do it here.
|
||||||
public class SwapOperationRaiseEventsPatch : ModulePatch
|
public class SwapOperationRaiseEventsPatch : ModulePatch
|
||||||
{
|
{
|
||||||
private static MethodInfo RaiseUnbindItemEvent;
|
|
||||||
private static Type RaiseUnbindItemEventArgs; // GEventArgs13
|
|
||||||
|
|
||||||
protected override MethodBase GetTargetMethod()
|
protected override MethodBase GetTargetMethod()
|
||||||
{
|
{
|
||||||
RaiseUnbindItemEvent = AccessTools.Method(typeof(InventoryControllerClass), "RaiseUnbindItemEvent");
|
|
||||||
RaiseUnbindItemEventArgs = RaiseUnbindItemEvent.GetParameters()[0].ParameterType;
|
|
||||||
return AccessTools.Method(SwapOperationType.GenericTypeArguments[0], "RaiseEvents"); // GClass2787
|
return AccessTools.Method(SwapOperationType.GenericTypeArguments[0], "RaiseEvents"); // GClass2787
|
||||||
}
|
}
|
||||||
|
|
||||||
[PatchPostfix]
|
[PatchPostfix]
|
||||||
private static void Postfix(TraderControllerClass controller, CommandStatus status, Item ___Item, Item ___Item1)
|
public static void Postfix(TraderControllerClass controller, CommandStatus status, Item ___Item, Item ___Item1)
|
||||||
{
|
{
|
||||||
InventoryControllerClass inventoryController = controller as InventoryControllerClass;
|
if (status != CommandStatus.Succeed || ___Item == null || ___Item1 == null || controller is not InventoryControllerClass inventoryController)
|
||||||
if (status != CommandStatus.Succeed || inventoryController == null || ___Item == null || ___Item1 == null)
|
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -378,11 +368,11 @@ namespace UIFixes
|
|||||||
{
|
{
|
||||||
protected override MethodBase GetTargetMethod()
|
protected override MethodBase GetTargetMethod()
|
||||||
{
|
{
|
||||||
return AccessTools.Method(typeof(GridItemView), "OnPointerEnter");
|
return AccessTools.Method(typeof(GridItemView), nameof(GridItemView.OnPointerEnter));
|
||||||
}
|
}
|
||||||
|
|
||||||
[PatchPostfix]
|
[PatchPostfix]
|
||||||
private static void Postfix(GridItemView __instance)
|
public static void Postfix(GridItemView __instance)
|
||||||
{
|
{
|
||||||
LastHoveredGridItemView = __instance;
|
LastHoveredGridItemView = __instance;
|
||||||
}
|
}
|
||||||
@@ -394,12 +384,11 @@ namespace UIFixes
|
|||||||
{
|
{
|
||||||
protected override MethodBase GetTargetMethod()
|
protected override MethodBase GetTargetMethod()
|
||||||
{
|
{
|
||||||
Type type = typeof(ItemContextClass);
|
return AccessTools.Method(typeof(ItemContextClass), nameof(ItemContextClass.CanAccept));
|
||||||
return type.GetMethod("CanAccept");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[PatchPostfix]
|
[PatchPostfix]
|
||||||
private static void Postfix(ItemContextClass __instance, Slot slot, ItemContextAbstractClass targetItemContext, ref object operation, TraderControllerClass itemController, bool simulate, ref bool __result)
|
public static void Postfix(ItemContextClass __instance, Slot slot, ItemContextAbstractClass targetItemContext, ref object operation, TraderControllerClass itemController, bool simulate, ref bool __result)
|
||||||
{
|
{
|
||||||
// targetItemContext here is not the target item, it's the *parent* context, i.e. the owner of the slot
|
// targetItemContext here is not the target item, it's the *parent* context, i.e. the owner of the slot
|
||||||
// Do a few more checks
|
// Do a few more checks
|
||||||
@@ -437,18 +426,17 @@ namespace UIFixes
|
|||||||
{
|
{
|
||||||
protected override MethodBase GetTargetMethod()
|
protected override MethodBase GetTargetMethod()
|
||||||
{
|
{
|
||||||
Type type = typeof(GridItemView);
|
return AccessTools.Method(typeof(GridItemView), nameof(GridItemView.method_12));
|
||||||
return type.GetMethod("method_12");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[PatchPrefix]
|
[PatchPrefix]
|
||||||
private static void Prefix()
|
public static void Prefix()
|
||||||
{
|
{
|
||||||
InHighlight = true;
|
InHighlight = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
[PatchPostfix]
|
[PatchPostfix]
|
||||||
private static void Postfix()
|
public static void Postfix()
|
||||||
{
|
{
|
||||||
InHighlight = false;
|
InHighlight = false;
|
||||||
}
|
}
|
||||||
@@ -460,18 +448,18 @@ namespace UIFixes
|
|||||||
{
|
{
|
||||||
protected override MethodBase GetTargetMethod()
|
protected override MethodBase GetTargetMethod()
|
||||||
{
|
{
|
||||||
Type type = typeof(SlotView);
|
return AccessTools.Method(typeof(SlotView), nameof(SlotView.method_2));
|
||||||
return type.GetMethod("method_2");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[PatchPrefix]
|
[PatchPrefix]
|
||||||
private static void Prefix()
|
public static void Prefix()
|
||||||
{
|
{
|
||||||
InHighlight = true;
|
InHighlight = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
[PatchPostfix]
|
[PatchPostfix]
|
||||||
private static void Postfix()
|
public static void Postfix()
|
||||||
{
|
{
|
||||||
InHighlight = false;
|
InHighlight = false;
|
||||||
}
|
}
|
||||||
@@ -488,7 +476,7 @@ namespace UIFixes
|
|||||||
}
|
}
|
||||||
|
|
||||||
[PatchPostfix]
|
[PatchPostfix]
|
||||||
private static void Postfix(Item item, ref bool __result)
|
public static void Postfix(Item item, ref bool __result)
|
||||||
{
|
{
|
||||||
LastCheckItemFilterId = item.Id;
|
LastCheckItemFilterId = item.Id;
|
||||||
LastCheckItemFilterResult = __result;
|
LastCheckItemFilterResult = __result;
|
||||||
@@ -501,11 +489,11 @@ namespace UIFixes
|
|||||||
{
|
{
|
||||||
protected override MethodBase GetTargetMethod()
|
protected override MethodBase GetTargetMethod()
|
||||||
{
|
{
|
||||||
return AccessTools.Method(typeof(DraggedItemView), "UpdateTargetUnderCursor");
|
return AccessTools.Method(typeof(DraggedItemView), nameof(DraggedItemView.UpdateTargetUnderCursor));
|
||||||
}
|
}
|
||||||
|
|
||||||
[PatchPostfix]
|
[PatchPostfix]
|
||||||
private static void Postfix(DraggedItemView __instance, ItemContextAbstractClass itemUnderCursor)
|
public static void Postfix(DraggedItemView __instance, ItemContextAbstractClass itemUnderCursor)
|
||||||
{
|
{
|
||||||
if (SourceContainer is Component sourceComponent)
|
if (SourceContainer is Component sourceComponent)
|
||||||
{
|
{
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
using Aki.Reflection.Patching;
|
using Aki.Reflection.Patching;
|
||||||
using EFT.UI.DragAndDrop;
|
using EFT.UI.DragAndDrop;
|
||||||
using System;
|
using HarmonyLib;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
|
|
||||||
namespace UIFixes
|
namespace UIFixes
|
||||||
@@ -9,18 +9,14 @@ namespace UIFixes
|
|||||||
{
|
{
|
||||||
protected override MethodBase GetTargetMethod()
|
protected override MethodBase GetTargetMethod()
|
||||||
{
|
{
|
||||||
Type type = typeof(QuestItemViewPanel);
|
return AccessTools.Method(typeof(QuestItemViewPanel), nameof(QuestItemViewPanel.method_2));
|
||||||
return type.GetMethod("method_2");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[PatchPostfix]
|
[PatchPostfix]
|
||||||
private static void Postfix(QuestItemViewPanel __instance)
|
public static void Postfix(QuestItemViewPanel __instance)
|
||||||
{
|
{
|
||||||
GridItemView parent = __instance.GetComponentInParent<GridItemView>();
|
GridItemView parent = __instance.GetComponentInParent<GridItemView>();
|
||||||
if (parent != null)
|
parent?.ShowTooltip();
|
||||||
{
|
|
||||||
parent.ShowTooltip();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
using Aki.Reflection.Patching;
|
using Aki.Reflection.Patching;
|
||||||
using EFT.UI;
|
using EFT.UI;
|
||||||
using System;
|
using HarmonyLib;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
@@ -10,19 +10,18 @@ namespace UIFixes
|
|||||||
{
|
{
|
||||||
protected override MethodBase GetTargetMethod()
|
protected override MethodBase GetTargetMethod()
|
||||||
{
|
{
|
||||||
Type type = typeof(TransferItemsScreen);
|
return AccessTools.Method(typeof(TransferItemsScreen), nameof(TransferItemsScreen.method_4));
|
||||||
return type.GetMethod("method_4", BindingFlags.Public | BindingFlags.Instance);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[PatchPrefix]
|
[PatchPrefix]
|
||||||
private static bool Prefix(ref Task<bool> __result)
|
public static bool Prefix(ref Task<bool> __result)
|
||||||
{
|
{
|
||||||
if (Settings.ShowTransferConfirmations.Value == TransferConfirmationOption.Always)
|
if (Settings.ShowTransferConfirmations.Value == TransferConfirmationOption.Always)
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
__result = Task.FromResult<bool>(true);
|
__result = Task.FromResult(true);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -2,6 +2,7 @@
|
|||||||
using Aki.Reflection.Utils;
|
using Aki.Reflection.Utils;
|
||||||
using EFT.InputSystem;
|
using EFT.InputSystem;
|
||||||
using EFT.InventoryLogic;
|
using EFT.InventoryLogic;
|
||||||
|
using HarmonyLib;
|
||||||
using System;
|
using System;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
@@ -16,12 +17,12 @@ namespace UIFixes
|
|||||||
protected override MethodBase GetTargetMethod()
|
protected override MethodBase GetTargetMethod()
|
||||||
{
|
{
|
||||||
ControlSettingsClass = PatchConstants.EftTypes.Single(x => x.GetMethod("GetBoundItemNames") != null); // GClass960
|
ControlSettingsClass = PatchConstants.EftTypes.Single(x => x.GetMethod("GetBoundItemNames") != null); // GClass960
|
||||||
GetKeyNameMethod = ControlSettingsClass.GetMethod("GetKeyName");
|
GetKeyNameMethod = AccessTools.Method(ControlSettingsClass, "GetKeyName");
|
||||||
return ControlSettingsClass.GetMethod("GetBoundItemNames", BindingFlags.Public | BindingFlags.Instance);
|
return AccessTools.Method(ControlSettingsClass, "GetBoundItemNames");
|
||||||
}
|
}
|
||||||
|
|
||||||
[PatchPostfix]
|
[PatchPostfix]
|
||||||
private static void Postfix(object __instance, EBoundItem boundItem, ref string __result)
|
public static void Postfix(object __instance, EBoundItem boundItem, ref string __result)
|
||||||
{
|
{
|
||||||
switch(boundItem)
|
switch(boundItem)
|
||||||
{
|
{
|
||||||
|
@@ -2,6 +2,7 @@
|
|||||||
using EFT.InventoryLogic;
|
using EFT.InventoryLogic;
|
||||||
using EFT.UI;
|
using EFT.UI;
|
||||||
using EFT.UI.WeaponModding;
|
using EFT.UI.WeaponModding;
|
||||||
|
using HarmonyLib;
|
||||||
using System;
|
using System;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using UnityEngine.EventSystems;
|
using UnityEngine.EventSystems;
|
||||||
@@ -18,22 +19,16 @@ namespace UIFixes
|
|||||||
|
|
||||||
public class EditBuildScreenZoomPatch : ModulePatch
|
public class EditBuildScreenZoomPatch : ModulePatch
|
||||||
{
|
{
|
||||||
private static ScrollTrigger ScrollTrigger;
|
|
||||||
protected override MethodBase GetTargetMethod()
|
protected override MethodBase GetTargetMethod()
|
||||||
{
|
{
|
||||||
Type type = typeof(EditBuildScreen);
|
return AccessTools.Method(typeof(EditBuildScreen), nameof(EditBuildScreen.Show), [typeof(Item), typeof(Item), typeof(InventoryControllerClass), typeof(ISession)]);
|
||||||
return type.GetMethod("Show", [typeof(Item), typeof(Item), typeof(InventoryControllerClass), typeof(ISession)]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[PatchPrefix]
|
[PatchPrefix]
|
||||||
private static void Prefix(EditBuildScreen __instance, WeaponPreview ____weaponPreview)
|
public static void Prefix(EditBuildScreen __instance, WeaponPreview ____weaponPreview)
|
||||||
{
|
{
|
||||||
if (ScrollTrigger == null)
|
var scrollTrigger = __instance.gameObject.AddComponent<ScrollTrigger>();
|
||||||
{
|
scrollTrigger.OnOnScroll += (PointerEventData eventData) =>
|
||||||
ScrollTrigger = __instance.gameObject.AddComponent<ScrollTrigger>();
|
|
||||||
}
|
|
||||||
|
|
||||||
ScrollTrigger.OnOnScroll += (PointerEventData eventData) =>
|
|
||||||
{
|
{
|
||||||
if (____weaponPreview != null && __instance != null)
|
if (____weaponPreview != null && __instance != null)
|
||||||
{
|
{
|
||||||
@@ -46,22 +41,16 @@ namespace UIFixes
|
|||||||
|
|
||||||
public class WeaponModdingScreenZoomPatch : ModulePatch
|
public class WeaponModdingScreenZoomPatch : ModulePatch
|
||||||
{
|
{
|
||||||
private static ScrollTrigger ScrollTrigger;
|
|
||||||
protected override MethodBase GetTargetMethod()
|
protected override MethodBase GetTargetMethod()
|
||||||
{
|
{
|
||||||
Type type = typeof(WeaponModdingScreen);
|
return AccessTools.Method(typeof(WeaponModdingScreen), nameof(WeaponModdingScreen.Show), [typeof(Item), typeof(InventoryControllerClass), typeof(LootItemClass[])]);
|
||||||
return type.GetMethod("Show", [typeof(Item), typeof(InventoryControllerClass), typeof(LootItemClass[])]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[PatchPrefix]
|
[PatchPrefix]
|
||||||
private static void Prefix(WeaponModdingScreen __instance, WeaponPreview ____weaponPreview)
|
public static void Prefix(WeaponModdingScreen __instance, WeaponPreview ____weaponPreview)
|
||||||
{
|
{
|
||||||
if (ScrollTrigger == null)
|
var scrollTrigger = __instance.gameObject.AddComponent<ScrollTrigger>();
|
||||||
{
|
scrollTrigger.OnOnScroll += (PointerEventData eventData) =>
|
||||||
ScrollTrigger = __instance.gameObject.AddComponent<ScrollTrigger>();
|
|
||||||
}
|
|
||||||
|
|
||||||
ScrollTrigger.OnOnScroll += (PointerEventData eventData) =>
|
|
||||||
{
|
{
|
||||||
if (____weaponPreview != null && __instance != null)
|
if (____weaponPreview != null && __instance != null)
|
||||||
{
|
{
|
||||||
|
@@ -5,7 +5,7 @@ namespace UIFixes
|
|||||||
[BepInPlugin(PluginInfo.PLUGIN_GUID, PluginInfo.PLUGIN_NAME, PluginInfo.PLUGIN_VERSION)]
|
[BepInPlugin(PluginInfo.PLUGIN_GUID, PluginInfo.PLUGIN_NAME, PluginInfo.PLUGIN_VERSION)]
|
||||||
public class Plugin : BaseUnityPlugin
|
public class Plugin : BaseUnityPlugin
|
||||||
{
|
{
|
||||||
private void Awake()
|
public void Awake()
|
||||||
{
|
{
|
||||||
Settings.Init(Config);
|
Settings.Init(Config);
|
||||||
|
|
||||||
|
@@ -228,8 +228,7 @@ namespace UIFixes
|
|||||||
int settingOrder = configEntries.Count;
|
int settingOrder = configEntries.Count;
|
||||||
foreach (var entry in configEntries)
|
foreach (var entry in configEntries)
|
||||||
{
|
{
|
||||||
ConfigurationManagerAttributes attributes = entry.Description.Tags[0] as ConfigurationManagerAttributes;
|
if (entry.Description.Tags[0] is ConfigurationManagerAttributes attributes)
|
||||||
if (attributes != null)
|
|
||||||
{
|
{
|
||||||
attributes.Order = settingOrder;
|
attributes.Order = settingOrder;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user