Confirm split with space; fix armor tooltip; remember repairer
This commit is contained in:
@@ -1,11 +1,21 @@
|
||||
using Aki.Reflection.Patching;
|
||||
using EFT.InputSystem;
|
||||
using EFT.UI;
|
||||
using HarmonyLib;
|
||||
using System.Reflection;
|
||||
using UnityEngine;
|
||||
|
||||
namespace UIFixes
|
||||
{
|
||||
public class ConfirmationDialogKeysPatch : ModulePatch
|
||||
public static class ConfirmDialogKeysPatches
|
||||
{
|
||||
public static void Enable()
|
||||
{
|
||||
new DialogWindowPatch().Enable();
|
||||
new SplitDialogPatch().Enable();
|
||||
}
|
||||
|
||||
public class DialogWindowPatch : ModulePatch
|
||||
{
|
||||
protected override MethodBase GetTargetMethod()
|
||||
{
|
||||
@@ -29,4 +39,27 @@ namespace UIFixes
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class SplitDialogPatch : ModulePatch
|
||||
{
|
||||
protected override MethodBase GetTargetMethod()
|
||||
{
|
||||
return AccessTools.Method(typeof(ItemUiContext), nameof(ItemUiContext.TranslateCommand));
|
||||
}
|
||||
|
||||
[PatchPrefix]
|
||||
public static bool Prefix(ECommand command, ref InputNode.ETranslateResult __result, SplitDialog ___splitDialog_0)
|
||||
{
|
||||
// It's wild to me that they implement UI keyboard shortcuts via the in-raid movement keybinds
|
||||
if (___splitDialog_0 != null && ___splitDialog_0.gameObject.activeSelf && command == ECommand.Jump)
|
||||
{
|
||||
___splitDialog_0.Accept();
|
||||
__result = InputNode.ETranslateResult.Block;
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,21 @@
|
||||
using Aki.Reflection.Patching;
|
||||
using EFT.UI;
|
||||
using EFT.UI.DragAndDrop;
|
||||
using HarmonyLib;
|
||||
using System.Reflection;
|
||||
using TMPro;
|
||||
|
||||
namespace UIFixes
|
||||
{
|
||||
public class FixTooltipPatch : ModulePatch
|
||||
public static class FixTooltipPatches
|
||||
{
|
||||
public static void Enable()
|
||||
{
|
||||
new QuestTooltipPatch().Enable();
|
||||
new ArmorTooltipPatch().Enable();
|
||||
}
|
||||
|
||||
public class QuestTooltipPatch : ModulePatch
|
||||
{
|
||||
protected override MethodBase GetTargetMethod()
|
||||
{
|
||||
@@ -19,4 +29,30 @@ namespace UIFixes
|
||||
parent?.ShowTooltip();
|
||||
}
|
||||
}
|
||||
|
||||
public class ArmorTooltipPatch : ModulePatch
|
||||
{
|
||||
protected override MethodBase GetTargetMethod()
|
||||
{
|
||||
return AccessTools.Method(typeof(GridItemView), nameof(GridItemView.NewGridItemView));
|
||||
}
|
||||
|
||||
// BSG loves to implement the same stuff in totally different ways, and this way is bad and also wrong
|
||||
[PatchPostfix]
|
||||
public static void Postfix(GridItemView __instance, TextMeshProUGUI ___ItemValue, PointerEventsProxy ____valuePointerEventsProxy)
|
||||
{
|
||||
// Add hover events to the correct place
|
||||
HoverTrigger trigger = ___ItemValue.GetOrAddComponent<HoverTrigger>();
|
||||
trigger.OnHoverStart += eventData => __instance.method_31();
|
||||
trigger.OnHoverEnd += eventData =>
|
||||
{
|
||||
__instance.method_32();
|
||||
__instance.ShowTooltip();
|
||||
};
|
||||
|
||||
// Remove them from the wrong place
|
||||
UnityEngine.Object.Destroy(____valuePointerEventsProxy);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -192,7 +192,7 @@ namespace UIFixes
|
||||
contextInteractions.OnRedrawRequired += createButton;
|
||||
|
||||
// And unsubscribe when the window goes away
|
||||
buttonsContainer.AddDisposable(() =>
|
||||
buttonsContainer.UI.AddDisposable(() =>
|
||||
{
|
||||
contextInteractions.OnRedrawRequired -= createButton;
|
||||
Settings.ShowModStats.SettingChanged -= onSettingChanged;
|
||||
|
||||
29
Patches/RememberRepairerPatch.cs
Normal file
29
Patches/RememberRepairerPatch.cs
Normal file
@@ -0,0 +1,29 @@
|
||||
using Aki.Reflection.Patching;
|
||||
using EFT.UI;
|
||||
using HarmonyLib;
|
||||
using System.Reflection;
|
||||
using UnityEngine;
|
||||
|
||||
namespace UIFixes
|
||||
{
|
||||
public class RememberRepairerPatch : ModulePatch
|
||||
{
|
||||
private static readonly string PlayerPrefKey = "UIFixes.Repair.CurrentRepairerIndex";
|
||||
|
||||
protected override MethodBase GetTargetMethod()
|
||||
{
|
||||
return AccessTools.Method(typeof(RepairerParametersPanel), nameof(RepairerParametersPanel.Show));
|
||||
}
|
||||
|
||||
[PatchPostfix]
|
||||
public static void Postfix(RepairerParametersPanel __instance, DropDownBox ____tradersDropDown)
|
||||
{
|
||||
__instance.R().UI.AddDisposable(____tradersDropDown.OnValueChanged.Subscribe(index => PlayerPrefs.SetInt(PlayerPrefKey, index)));
|
||||
|
||||
if (PlayerPrefs.HasKey(PlayerPrefKey))
|
||||
{
|
||||
____tradersDropDown.UpdateValue(PlayerPrefs.GetInt(PlayerPrefKey));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -35,7 +35,7 @@ namespace UIFixes
|
||||
BuyTab = wrappedInstance.BuyTab;
|
||||
SellTab = wrappedInstance.SellTab;
|
||||
|
||||
wrappedInstance.AddDisposable(() =>
|
||||
wrappedInstance.UI.AddDisposable(() =>
|
||||
{
|
||||
BuyTab = null;
|
||||
SellTab = null;
|
||||
|
||||
@@ -13,9 +13,9 @@ namespace UIFixes
|
||||
|
||||
R.Init();
|
||||
|
||||
new ConfirmationDialogKeysPatch().Enable();
|
||||
ConfirmDialogKeysPatches.Enable();
|
||||
new FixMailRecieveAllPatch().Enable();
|
||||
new FixTooltipPatch().Enable();
|
||||
FixTooltipPatches.Enable();
|
||||
new FixWeaponBindsDisplayPatch().Enable();
|
||||
FocusFleaOfferNumberPatches.Enable();
|
||||
HideoutSearchPatches.Enable();
|
||||
@@ -42,6 +42,7 @@ namespace UIFixes
|
||||
AddOfferRememberAutoselectPatches.Enable();
|
||||
KeepMessagesOpenPatches.Enable();
|
||||
new FocusTradeQuantityPatch().Enable();
|
||||
new RememberRepairerPatch().Enable();
|
||||
}
|
||||
|
||||
public static bool InRaid()
|
||||
|
||||
47
R.cs
47
R.cs
@@ -23,6 +23,8 @@ namespace UIFixes
|
||||
public static void Init()
|
||||
{
|
||||
// Order is significant, as some reference each other
|
||||
UIElement.InitUITypes();
|
||||
UIContext.InitTypes();
|
||||
DialogWindow.InitTypes();
|
||||
ControlSettings.InitTypes();
|
||||
ProductionPanel.InitTypes();
|
||||
@@ -58,6 +60,32 @@ namespace UIFixes
|
||||
public object Value { get; protected set; } = value;
|
||||
}
|
||||
|
||||
public class UIElement(object value) : Wrapper(value)
|
||||
{
|
||||
private static FieldInfo UIField;
|
||||
|
||||
public static void InitUITypes()
|
||||
{
|
||||
UIField = AccessTools.Field(typeof(EFT.UI.UIElement), "UI");
|
||||
}
|
||||
|
||||
public UIContext UI { get { return new UIContext(UIField.GetValue(Value)); } }
|
||||
}
|
||||
|
||||
public class UIContext(object value) : Wrapper(value)
|
||||
{
|
||||
public static Type Type { get; private set; }
|
||||
private static MethodInfo AddDisposableActionMethod;
|
||||
|
||||
public static void InitTypes()
|
||||
{
|
||||
Type = AccessTools.Field(typeof(EFT.UI.UIElement), "UI").FieldType;
|
||||
AddDisposableActionMethod = AccessTools.Method(Type, "AddDisposable", [typeof(Action)]);
|
||||
}
|
||||
|
||||
public void AddDisposable(Action destroy) => AddDisposableActionMethod.Invoke(Value, [destroy]);
|
||||
}
|
||||
|
||||
public class DialogWindow(object value) : Wrapper(value)
|
||||
{
|
||||
public static Type Type { get; private set; }
|
||||
@@ -288,27 +316,21 @@ namespace UIFixes
|
||||
public object ToGridViewCanAcceptOperation() => ImplicitCastToGridViewCanAcceptOperationMethod.Invoke(null, [Value]);
|
||||
}
|
||||
|
||||
public class InteractionButtonsContainer(object value) : Wrapper(value)
|
||||
public class InteractionButtonsContainer(object value) : UIElement(value)
|
||||
{
|
||||
public static Type Type { get; private set; }
|
||||
private static FieldInfo ButtonTemplateField;
|
||||
private static FieldInfo ContainerField;
|
||||
private static FieldInfo UIField;
|
||||
private static MethodInfo UIAddDisposableMethod;
|
||||
|
||||
public static void InitTypes()
|
||||
{
|
||||
Type = typeof(EFT.UI.InteractionButtonsContainer);
|
||||
ButtonTemplateField = AccessTools.Field(Type, "_buttonTemplate");
|
||||
ContainerField = AccessTools.Field(Type, "_buttonsContainer");
|
||||
UIField = AccessTools.Field(Type, "UI"); // GClass767
|
||||
UIAddDisposableMethod = AccessTools.Method(UIField.FieldType, "AddDisposable", [typeof(Action)]);
|
||||
}
|
||||
|
||||
public SimpleContextMenuButton ButtonTemplate { get { return (SimpleContextMenuButton)ButtonTemplateField.GetValue(Value); } }
|
||||
public Transform Container { get { return (Transform)ContainerField.GetValue(Value); } }
|
||||
public object UI { get { return UIField.GetValue(Value); } }
|
||||
public void AddDisposable(Action action) => UIAddDisposableMethod.Invoke(UI, [action]);
|
||||
}
|
||||
|
||||
public class ContextMenuButton(object value) : Wrapper(value)
|
||||
@@ -488,25 +510,19 @@ namespace UIFixes
|
||||
public static Dictionary<ECurrencyType, int> GetMoneySums(IEnumerable<Item> items) => (Dictionary<ECurrencyType, int>)GetMoneySumsMethod.Invoke(null, [items]);
|
||||
}
|
||||
|
||||
public class TraderScreensGroup(object value) : Wrapper(value)
|
||||
public class TraderScreensGroup(object value) : UIElement(value)
|
||||
{
|
||||
public static Type Type { get; private set; }
|
||||
private static FieldInfo UIField;
|
||||
private static MethodInfo UIAddDisposableMethod;
|
||||
private static FieldInfo BuyTabField;
|
||||
private static FieldInfo SellTabField;
|
||||
|
||||
public static void InitTypes()
|
||||
{
|
||||
Type = typeof(EFT.UI.TraderScreensGroup);
|
||||
UIField = AccessTools.Field(Type, "UI");
|
||||
UIAddDisposableMethod = AccessTools.Method(UIField.FieldType, "AddDisposable", [typeof(Action)]);
|
||||
BuyTabField = AccessTools.Field(Type, "_buyTab");
|
||||
SellTabField = AccessTools.Field(Type, "_sellTab");
|
||||
}
|
||||
|
||||
public object UI { get { return UIField.GetValue(Value); } }
|
||||
public void AddDisposable(Action action) => UIAddDisposableMethod.Invoke(UI, [action]);
|
||||
public Tab BuyTab { get { return (Tab)BuyTabField.GetValue(Value); } }
|
||||
public Tab SellTab { get { return (Tab)SellTabField.GetValue(Value); } }
|
||||
}
|
||||
@@ -552,6 +568,8 @@ namespace UIFixes
|
||||
|
||||
public Button Button { get { return (Button)ButtonField.GetValue(Value); } }
|
||||
}
|
||||
|
||||
public class RepairerParametersPanel(object value) : UIElement(value) { }
|
||||
}
|
||||
|
||||
public static class RExtentensions
|
||||
@@ -574,5 +592,6 @@ namespace UIFixes
|
||||
public static R.TradingItemView R(this TradingItemView value) => new(value);
|
||||
public static R.GridWindow R(this GridWindow value) => new(value);
|
||||
public static R.GridSortPanel R(this GridSortPanel value) => new(value);
|
||||
public static R.RepairerParametersPanel R(this RepairerParametersPanel value) => new(value);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user