Hideout scroll keybinds; async scroll settings
This commit is contained in:
@@ -6,8 +6,6 @@ using System;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using UnityEngine;
|
|
||||||
using UnityEngine.EventSystems;
|
|
||||||
using UnityEngine.UI;
|
using UnityEngine.UI;
|
||||||
|
|
||||||
namespace UIFixes
|
namespace UIFixes
|
||||||
@@ -18,6 +16,8 @@ namespace UIFixes
|
|||||||
|
|
||||||
private static float LastAbsoluteDownScrollPosition = -1f;
|
private static float LastAbsoluteDownScrollPosition = -1f;
|
||||||
|
|
||||||
|
private static void ClearLastScrollPosition() => LastAbsoluteDownScrollPosition = -1f;
|
||||||
|
|
||||||
public static void Enable()
|
public static void Enable()
|
||||||
{
|
{
|
||||||
new LazyLoadPatch().Enable();
|
new LazyLoadPatch().Enable();
|
||||||
@@ -65,7 +65,7 @@ namespace UIFixes
|
|||||||
{
|
{
|
||||||
// Last one, try to set it exactly
|
// Last one, try to set it exactly
|
||||||
scrollRect.verticalNormalizedPosition = 1f - (LastAbsoluteDownScrollPosition / (scrollRect.content.rect.height - scrollRect.viewport.rect.height));
|
scrollRect.verticalNormalizedPosition = 1f - (LastAbsoluteDownScrollPosition / (scrollRect.content.rect.height - scrollRect.viewport.rect.height));
|
||||||
LastAbsoluteDownScrollPosition = -1f;
|
ClearLastScrollPosition();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -87,6 +87,9 @@ namespace UIFixes
|
|||||||
{
|
{
|
||||||
____searchInputField.text = lastSearch;
|
____searchInputField.text = lastSearch;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ScrollPatches.KeyScroller scroller = __instance.GetComponentInParent<ScrollPatches.KeyScroller>();
|
||||||
|
scroller?.OnKeyScroll.AddListener(ClearLastScrollPosition);
|
||||||
}
|
}
|
||||||
|
|
||||||
[PatchPostfix]
|
[PatchPostfix]
|
||||||
@@ -159,9 +162,14 @@ namespace UIFixes
|
|||||||
ScrollRect scrollRect = __instance.GetComponentInParent<ScrollRect>();
|
ScrollRect scrollRect = __instance.GetComponentInParent<ScrollRect>();
|
||||||
if (scrollRect != null)
|
if (scrollRect != null)
|
||||||
{
|
{
|
||||||
// Need to save the absolute DOWN position, because that's the direction the scrollbox will grow.
|
if (Settings.RestoreAsyncScrollPositions.Value)
|
||||||
// Subtract the viewport height from content heigh because that's the actual RANGE of the scroll position
|
{
|
||||||
LastAbsoluteDownScrollPosition = (1f - scrollRect.verticalNormalizedPosition) * (scrollRect.content.rect.height - scrollRect.viewport.rect.height);
|
// Need to save the absolute DOWN position, because that's the direction the scrollbox will grow.
|
||||||
|
// Subtract the viewport height from content heigh because that's the actual RANGE of the scroll position
|
||||||
|
LastAbsoluteDownScrollPosition = (1f - scrollRect.verticalNormalizedPosition) * (scrollRect.content.rect.height - scrollRect.viewport.rect.height);
|
||||||
|
}
|
||||||
|
|
||||||
|
scrollRect.GetComponent<ScrollPatches.KeyScroller>()?.OnKeyScroll.RemoveListener(ClearLastScrollPosition);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reset the default behavior
|
// Reset the default behavior
|
||||||
@@ -183,7 +191,7 @@ namespace UIFixes
|
|||||||
public static void Postfix()
|
public static void Postfix()
|
||||||
{
|
{
|
||||||
LastSearches.Clear();
|
LastSearches.Clear();
|
||||||
LastAbsoluteDownScrollPosition = -1f;
|
ClearLastScrollPosition();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -197,7 +205,7 @@ namespace UIFixes
|
|||||||
[PatchPostfix]
|
[PatchPostfix]
|
||||||
public static void Postfix()
|
public static void Postfix()
|
||||||
{
|
{
|
||||||
LastAbsoluteDownScrollPosition = -1f;
|
ClearLastScrollPosition();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,4 +1,5 @@
|
|||||||
using Aki.Reflection.Patching;
|
using Aki.Reflection.Patching;
|
||||||
|
using EFT.Hideout;
|
||||||
using EFT.UI;
|
using EFT.UI;
|
||||||
using EFT.UI.Chat;
|
using EFT.UI.Chat;
|
||||||
using EFT.UI.Ragfair;
|
using EFT.UI.Ragfair;
|
||||||
@@ -8,6 +9,7 @@ using System;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
using UnityEngine.Events;
|
||||||
using UnityEngine.EventSystems;
|
using UnityEngine.EventSystems;
|
||||||
using UnityEngine.UI;
|
using UnityEngine.UI;
|
||||||
|
|
||||||
@@ -22,9 +24,10 @@ namespace UIFixes
|
|||||||
new EnhanceFleaScrollingPatch().Enable();
|
new EnhanceFleaScrollingPatch().Enable();
|
||||||
new EnhanceMailScrollingPatch().Enable();
|
new EnhanceMailScrollingPatch().Enable();
|
||||||
new MouseScrollingSpeedPatch().Enable();
|
new MouseScrollingSpeedPatch().Enable();
|
||||||
|
new EnhanceHideoutScrollingPatch().Enable();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void HandleInput(ScrollRect scrollRect)
|
private static bool HandleInput(ScrollRect scrollRect)
|
||||||
{
|
{
|
||||||
if (scrollRect != null)
|
if (scrollRect != null)
|
||||||
{
|
{
|
||||||
@@ -33,10 +36,12 @@ namespace UIFixes
|
|||||||
if (Input.GetKeyDown(KeyCode.Home))
|
if (Input.GetKeyDown(KeyCode.Home))
|
||||||
{
|
{
|
||||||
scrollRect.verticalNormalizedPosition = 1f;
|
scrollRect.verticalNormalizedPosition = 1f;
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
if (Input.GetKeyDown(KeyCode.End))
|
if (Input.GetKeyDown(KeyCode.End))
|
||||||
{
|
{
|
||||||
scrollRect.verticalNormalizedPosition = 0f;
|
scrollRect.verticalNormalizedPosition = 0f;
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -51,6 +56,7 @@ namespace UIFixes
|
|||||||
|
|
||||||
|
|
||||||
scrollRect.verticalNormalizedPosition = Math.Min(1f, scrollRect.verticalNormalizedPosition + pageSize);
|
scrollRect.verticalNormalizedPosition = Math.Min(1f, scrollRect.verticalNormalizedPosition + pageSize);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Input.GetKeyDown(KeyCode.PageDown))
|
if (Input.GetKeyDown(KeyCode.PageDown))
|
||||||
@@ -62,13 +68,16 @@ namespace UIFixes
|
|||||||
|
|
||||||
|
|
||||||
scrollRect.verticalNormalizedPosition = Math.Max(0f, scrollRect.verticalNormalizedPosition - pageSize);
|
scrollRect.verticalNormalizedPosition = Math.Max(0f, scrollRect.verticalNormalizedPosition - pageSize);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// LightScrollers don't expose heights that I can see, so just fudge it with fake OnScroll events
|
// LightScrollers don't expose heights that I can see, so just fudge it with fake OnScroll events
|
||||||
private static void HandleInput(LightScroller lightScroller)
|
private static bool HandleInput(LightScroller lightScroller)
|
||||||
{
|
{
|
||||||
if (lightScroller != null)
|
if (lightScroller != null)
|
||||||
{
|
{
|
||||||
@@ -77,10 +86,12 @@ namespace UIFixes
|
|||||||
if (Input.GetKeyDown(KeyCode.Home))
|
if (Input.GetKeyDown(KeyCode.Home))
|
||||||
{
|
{
|
||||||
lightScroller.SetScrollPosition(0f);
|
lightScroller.SetScrollPosition(0f);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
if (Input.GetKeyDown(KeyCode.End))
|
if (Input.GetKeyDown(KeyCode.End))
|
||||||
{
|
{
|
||||||
lightScroller.SetScrollPosition(1f);
|
lightScroller.SetScrollPosition(1f);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -93,6 +104,7 @@ namespace UIFixes
|
|||||||
scrollDelta = new Vector2(0f, 25f)
|
scrollDelta = new Vector2(0f, 25f)
|
||||||
};
|
};
|
||||||
lightScroller.OnScroll(eventData);
|
lightScroller.OnScroll(eventData);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
if (Input.GetKeyDown(KeyCode.PageDown))
|
if (Input.GetKeyDown(KeyCode.PageDown))
|
||||||
{
|
{
|
||||||
@@ -101,9 +113,12 @@ namespace UIFixes
|
|||||||
scrollDelta = new Vector2(0f, -25f)
|
scrollDelta = new Vector2(0f, -25f)
|
||||||
};
|
};
|
||||||
lightScroller.OnScroll(eventData);
|
lightScroller.OnScroll(eventData);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static IEnumerable<CodeInstruction> RemovePageUpDownHandling(IEnumerable<CodeInstruction> instructions)
|
private static IEnumerable<CodeInstruction> RemovePageUpDownHandling(IEnumerable<CodeInstruction> instructions)
|
||||||
@@ -131,6 +146,27 @@ namespace UIFixes
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class KeyScroller : MonoBehaviour
|
||||||
|
{
|
||||||
|
private ScrollRect scrollRect;
|
||||||
|
|
||||||
|
public UnityEvent OnKeyScroll;
|
||||||
|
|
||||||
|
public void Awake()
|
||||||
|
{
|
||||||
|
scrollRect = GetComponent<ScrollRect>();
|
||||||
|
OnKeyScroll = new();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Update()
|
||||||
|
{
|
||||||
|
if (HandleInput(scrollRect))
|
||||||
|
{
|
||||||
|
OnKeyScroll.Invoke();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public class EnhanceStashScrollingPatch : ModulePatch
|
public class EnhanceStashScrollingPatch : ModulePatch
|
||||||
{
|
{
|
||||||
protected override MethodBase GetTargetMethod()
|
protected override MethodBase GetTargetMethod()
|
||||||
@@ -207,6 +243,26 @@ namespace UIFixes
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class EnhanceHideoutScrollingPatch : ModulePatch
|
||||||
|
{
|
||||||
|
protected override MethodBase GetTargetMethod()
|
||||||
|
{
|
||||||
|
return AccessTools.Method(typeof(AreaScreenSubstrate), nameof(AreaScreenSubstrate.Awake));
|
||||||
|
}
|
||||||
|
|
||||||
|
[PatchPostfix]
|
||||||
|
public static void Postfix(AreaScreenSubstrate __instance)
|
||||||
|
{
|
||||||
|
ScrollRect scrollRect = __instance.transform.Find("Content/CurrentLevel/CurrentContainer/Scrollview")?.GetComponent<ScrollRect>();
|
||||||
|
if (scrollRect == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
scrollRect.GetOrAddComponent<KeyScroller>();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public class EnhanceMailScrollingPatch : ModulePatch
|
public class EnhanceMailScrollingPatch : ModulePatch
|
||||||
{
|
{
|
||||||
protected override MethodBase GetTargetMethod()
|
protected override MethodBase GetTargetMethod()
|
||||||
|
10
Settings.cs
10
Settings.cs
@@ -36,6 +36,7 @@ namespace UIFixes
|
|||||||
public static ConfigEntry<bool> AutofillQuestTurnIns { get; set; }
|
public static ConfigEntry<bool> AutofillQuestTurnIns { get; set; }
|
||||||
public static ConfigEntry<bool> AutoSwitchTrading { get; set; }
|
public static ConfigEntry<bool> AutoSwitchTrading { get; set; }
|
||||||
public static ConfigEntry<bool> ClickOutOfDialogs { get; set; } // Advanced
|
public static ConfigEntry<bool> ClickOutOfDialogs { get; set; } // Advanced
|
||||||
|
public static ConfigEntry<bool> RestoreAsyncScrollPositions { get; set; } // Advanced
|
||||||
|
|
||||||
// Input
|
// Input
|
||||||
public static ConfigEntry<bool> UseHomeEnd { get; set; }
|
public static ConfigEntry<bool> UseHomeEnd { get; set; }
|
||||||
@@ -143,6 +144,15 @@ namespace UIFixes
|
|||||||
null,
|
null,
|
||||||
new ConfigurationManagerAttributes { IsAdvanced = true })));
|
new ConfigurationManagerAttributes { IsAdvanced = true })));
|
||||||
|
|
||||||
|
configEntries.Add(RestoreAsyncScrollPositions = config.Bind(
|
||||||
|
GeneralSection,
|
||||||
|
"Restore Async Scroll Positions",
|
||||||
|
true,
|
||||||
|
new ConfigDescription(
|
||||||
|
"In scroll views that load content dynamically, scroll down as the content loads to restore old scroll position",
|
||||||
|
null,
|
||||||
|
new ConfigurationManagerAttributes { IsAdvanced = true })));
|
||||||
|
|
||||||
// Input
|
// Input
|
||||||
configEntries.Add(UseHomeEnd = config.Bind(
|
configEntries.Add(UseHomeEnd = config.Bind(
|
||||||
InputSection,
|
InputSection,
|
||||||
|
Reference in New Issue
Block a user