Using ___fields properly, fixing mail null ref
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
using Aki.Reflection.Patching;
|
using Aki.Reflection.Patching;
|
||||||
|
using EFT.UI;
|
||||||
using System;
|
using System;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using EFT.UI;
|
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace UIFixes
|
namespace UIFixes
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
using Aki.Reflection.Patching;
|
using Aki.Reflection.Patching;
|
||||||
|
using EFT.UI.Chat;
|
||||||
using System;
|
using System;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using EFT.UI.Chat;
|
|
||||||
|
|
||||||
namespace UIFixes
|
namespace UIFixes
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ using HarmonyLib;
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Reflection.Emit;
|
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.EventSystems;
|
using UnityEngine.EventSystems;
|
||||||
using UnityEngine.UI;
|
using UnityEngine.UI;
|
||||||
@@ -58,6 +57,45 @@ namespace UIFixes
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// LightScrollers don't expose heights that I can see, so just fudge it with fake OnScroll events
|
||||||
|
protected static void HandleInput(LightScroller lightScroller)
|
||||||
|
{
|
||||||
|
if (lightScroller != null)
|
||||||
|
{
|
||||||
|
if (Settings.UseHomeEnd.Value)
|
||||||
|
{
|
||||||
|
if (Input.GetKeyDown(KeyCode.Home))
|
||||||
|
{
|
||||||
|
lightScroller.SetScrollPosition(0f);
|
||||||
|
}
|
||||||
|
if (Input.GetKeyDown(KeyCode.End))
|
||||||
|
{
|
||||||
|
lightScroller.SetScrollPosition(1f);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Settings.RebindPageUpDown.Value)
|
||||||
|
{
|
||||||
|
if (Input.GetKeyDown(KeyCode.PageUp))
|
||||||
|
{
|
||||||
|
var eventData = new PointerEventData(EventSystem.current)
|
||||||
|
{
|
||||||
|
scrollDelta = new Vector2(0f, 25f)
|
||||||
|
};
|
||||||
|
lightScroller.OnScroll(eventData);
|
||||||
|
}
|
||||||
|
if (Input.GetKeyDown(KeyCode.PageDown))
|
||||||
|
{
|
||||||
|
var eventData = new PointerEventData(EventSystem.current)
|
||||||
|
{
|
||||||
|
scrollDelta = new Vector2(0f, -25f)
|
||||||
|
};
|
||||||
|
lightScroller.OnScroll(eventData);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
protected static IEnumerable<CodeInstruction> RemovePageUpDownHandling(IEnumerable<CodeInstruction> instructions)
|
protected static IEnumerable<CodeInstruction> RemovePageUpDownHandling(IEnumerable<CodeInstruction> instructions)
|
||||||
{
|
{
|
||||||
foreach (var instruction in instructions)
|
foreach (var instruction in instructions)
|
||||||
@@ -92,10 +130,9 @@ namespace UIFixes
|
|||||||
}
|
}
|
||||||
|
|
||||||
[PatchPrefix]
|
[PatchPrefix]
|
||||||
private static void Prefix(SimpleStashPanel __instance)
|
private static void Prefix(SimpleStashPanel __instance, ScrollRect ____stashScroll)
|
||||||
{
|
{
|
||||||
ScrollRect stashScroll = Traverse.Create(__instance).Field("_stashScroll").GetValue<ScrollRect>();
|
HandleInput(____stashScroll);
|
||||||
HandleInput(stashScroll);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[PatchTranspiler]
|
[PatchTranspiler]
|
||||||
@@ -119,11 +156,9 @@ namespace UIFixes
|
|||||||
}
|
}
|
||||||
|
|
||||||
[PatchPrefix]
|
[PatchPrefix]
|
||||||
private static void Prefix(TraderDealScreen __instance)
|
private static void Prefix(TraderDealScreen __instance, TraderDealScreen.ETraderMode ___etraderMode_0, ScrollRect ____traderScroll, ScrollRect ____stashScroll)
|
||||||
{
|
{
|
||||||
TraderDealScreen.ETraderMode mode = Traverse.Create(__instance).Field("etraderMode_0").GetValue<TraderDealScreen.ETraderMode>();
|
HandleInput(___etraderMode_0 == TraderDealScreen.ETraderMode.Purchase ? ____traderScroll : ____stashScroll);
|
||||||
ScrollRect traderScroll = Traverse.Create(__instance).Field(mode == TraderDealScreen.ETraderMode.Purchase ? "_traderScroll" : "_stashScroll").GetValue<ScrollRect>();
|
|
||||||
HandleInput(traderScroll);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[PatchTranspiler]
|
[PatchTranspiler]
|
||||||
@@ -147,46 +182,11 @@ namespace UIFixes
|
|||||||
}
|
}
|
||||||
|
|
||||||
[PatchPrefix]
|
[PatchPrefix]
|
||||||
private static void Prefix(OfferViewList __instance)
|
private static void Prefix(OfferViewList __instance, LightScroller ____scroller)
|
||||||
{
|
{
|
||||||
LightScroller scroller = Traverse.Create(__instance).Field("_scroller").GetValue<LightScroller>();
|
|
||||||
|
|
||||||
// Different kind of scroller - I don't see a way to get the rects.
|
// Different kind of scroller - I don't see a way to get the rects.
|
||||||
// New approach: faking scroll events
|
// New approach: faking scroll events
|
||||||
if (scroller != null)
|
HandleInput(____scroller);
|
||||||
{
|
|
||||||
if (Settings.UseHomeEnd.Value)
|
|
||||||
{
|
|
||||||
if (Input.GetKeyDown(KeyCode.Home))
|
|
||||||
{
|
|
||||||
scroller.SetScrollPosition(0f);
|
|
||||||
}
|
|
||||||
if (Input.GetKeyDown(KeyCode.End))
|
|
||||||
{
|
|
||||||
scroller.SetScrollPosition(1f);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Settings.RebindPageUpDown.Value)
|
|
||||||
{
|
|
||||||
if (Input.GetKeyDown(KeyCode.PageUp))
|
|
||||||
{
|
|
||||||
var eventData = new PointerEventData(EventSystem.current)
|
|
||||||
{
|
|
||||||
scrollDelta = new Vector2(0f, 25f)
|
|
||||||
};
|
|
||||||
scroller.OnScroll(eventData);
|
|
||||||
}
|
|
||||||
if (Input.GetKeyDown(KeyCode.PageDown))
|
|
||||||
{
|
|
||||||
var eventData = new PointerEventData(EventSystem.current)
|
|
||||||
{
|
|
||||||
scrollDelta = new Vector2(0f, -25f)
|
|
||||||
};
|
|
||||||
scroller.OnScroll(eventData);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[PatchTranspiler]
|
[PatchTranspiler]
|
||||||
@@ -210,10 +210,9 @@ namespace UIFixes
|
|||||||
}
|
}
|
||||||
|
|
||||||
[PatchPrefix]
|
[PatchPrefix]
|
||||||
private static void Prefix(MessagesContainer __instance)
|
private static void Prefix(MessagesContainer __instance, LightScroller ____scroller)
|
||||||
{
|
{
|
||||||
ScrollRect scroller = Traverse.Create(__instance).Field("_scroller").GetValue<ScrollRect>();
|
HandleInput(____scroller);
|
||||||
HandleInput(scroller);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[PatchTranspiler]
|
[PatchTranspiler]
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
using Aki.Reflection.Patching;
|
using Aki.Reflection.Patching;
|
||||||
|
using EFT.UI;
|
||||||
using System;
|
using System;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using EFT.UI;
|
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace UIFixes
|
namespace UIFixes
|
||||||
|
|||||||
@@ -2,7 +2,6 @@
|
|||||||
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;
|
||||||
@@ -27,9 +26,8 @@ namespace UIFixes
|
|||||||
}
|
}
|
||||||
|
|
||||||
[PatchPrefix]
|
[PatchPrefix]
|
||||||
private static void Prefix(EditBuildScreen __instance)
|
private static void Prefix(EditBuildScreen __instance, WeaponPreview ____weaponPreview)
|
||||||
{
|
{
|
||||||
WeaponPreview weaponPreview = Traverse.Create(__instance).Field("_weaponPreview").GetValue<WeaponPreview>();
|
|
||||||
if (ScrollTrigger == null)
|
if (ScrollTrigger == null)
|
||||||
{
|
{
|
||||||
ScrollTrigger = __instance.gameObject.AddComponent<ScrollTrigger>();
|
ScrollTrigger = __instance.gameObject.AddComponent<ScrollTrigger>();
|
||||||
@@ -37,9 +35,9 @@ namespace UIFixes
|
|||||||
|
|
||||||
ScrollTrigger.OnOnScroll += (PointerEventData eventData) =>
|
ScrollTrigger.OnOnScroll += (PointerEventData eventData) =>
|
||||||
{
|
{
|
||||||
if (weaponPreview != null && __instance != null)
|
if (____weaponPreview != null && __instance != null)
|
||||||
{
|
{
|
||||||
weaponPreview.Zoom(eventData.scrollDelta.y * 0.12f);
|
____weaponPreview.Zoom(eventData.scrollDelta.y * 0.12f);
|
||||||
__instance.UpdatePositions();
|
__instance.UpdatePositions();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -56,9 +54,8 @@ namespace UIFixes
|
|||||||
}
|
}
|
||||||
|
|
||||||
[PatchPrefix]
|
[PatchPrefix]
|
||||||
private static void Prefix(WeaponModdingScreen __instance)
|
private static void Prefix(WeaponModdingScreen __instance, WeaponPreview ____weaponPreview)
|
||||||
{
|
{
|
||||||
WeaponPreview weaponPreview = Traverse.Create(__instance).Field("_weaponPreview").GetValue<WeaponPreview>();
|
|
||||||
if (ScrollTrigger == null)
|
if (ScrollTrigger == null)
|
||||||
{
|
{
|
||||||
ScrollTrigger = __instance.gameObject.AddComponent<ScrollTrigger>();
|
ScrollTrigger = __instance.gameObject.AddComponent<ScrollTrigger>();
|
||||||
@@ -66,9 +63,9 @@ namespace UIFixes
|
|||||||
|
|
||||||
ScrollTrigger.OnOnScroll += (PointerEventData eventData) =>
|
ScrollTrigger.OnOnScroll += (PointerEventData eventData) =>
|
||||||
{
|
{
|
||||||
if (weaponPreview != null && __instance != null)
|
if (____weaponPreview != null && __instance != null)
|
||||||
{
|
{
|
||||||
weaponPreview.Zoom(eventData.scrollDelta.y * 0.12f);
|
____weaponPreview.Zoom(eventData.scrollDelta.y * 0.12f);
|
||||||
__instance.UpdatePositions();
|
__instance.UpdatePositions();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user