Skip to content

Commit

Permalink
v0.0.1 let's go
Browse files Browse the repository at this point in the history
  • Loading branch information
Aryetis committed Apr 10, 2021
1 parent b51405d commit b017db4
Showing 3 changed files with 10 additions and 35 deletions.
10 changes: 4 additions & 6 deletions FasterScroll/FasterScrollController.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
#define DEBUG_FASTERSCROLL
//#define DEBUG_FASTERSCROLL
using UnityEngine;
using HMUI;
using IPA.Utilities;
using VRUIControls;
using System.Linq;
using Libraries.HM.HMLib.VR;
using System;
using RumbleMod;

#if DEBUG_FASTERSCROLL
@@ -99,7 +97,7 @@ public static void SetStockRumbleStrength(float f)
public static void ResetInertia()
{
m_fInertia = 0.0f; m_fScrollTimer = 0.0f;
} // TODO check what happens when coming back from level with inertia
}

/******************************
* Actual Fun stuff *
@@ -213,7 +211,7 @@ public static void PostHandlePointerDidExit()
/******************************
* Debug stuff *
******************************/
#region debug
#region debug
#if DEBUG_FASTERSCROLL
private IEnumerator DebugUpdate()
{
@@ -244,7 +242,7 @@ public static string GetGameObjectFullPath(GameObject go)
}
return path;
}
}
#endif
#endregion debug
}
}
22 changes: 1 addition & 21 deletions FasterScroll/HarmonyPatches/Patches.cs
Original file line number Diff line number Diff line change
@@ -4,9 +4,6 @@
using UnityEngine;
using VRUIControls;
using Libraries.HM.HMLib.VR;
using System.Linq;
using System;
using System.Reflection;

// only interested in modifying ( and its ScrollSpeed):
// Wrapper/ScreenSystem/ScreenContainer/MainScreen/LevelSelectionNavigationController/LevelCollectionNavigationController/LevelCollecionViewController/LevelsTableView/TableView
@@ -21,10 +18,7 @@ class ScrollViewAwakePatch
static void Prefix(ScrollView __instance)
{
if (__instance.transform.parent.gameObject.name == "LevelsTableView")
{
//Plugin.Log?.Error("ScrollViewAwakePatch");
FasterScrollController.SetStockScrollSpeed(__instance);
}
return;
}
}
@@ -36,10 +30,9 @@ class TLevelCollectionTableViewOnEnablePostFixPatch
{
static void Postfix(LevelCollectionTableView __instance)
{
//Plugin.Log?.Error("TLevelCollectionTableViewOnEnablePostFixPatch");
if (FasterScrollController.FasterScrollMode == FasterScrollController.FasterScrollModeEnum.Constant)
FasterScrollController.ScrollViewPatcherConstant(__instance);
if (FasterScrollController.FasterScrollMode == FasterScrollController.FasterScrollModeEnum.Stock)
else if (FasterScrollController.FasterScrollMode == FasterScrollController.FasterScrollModeEnum.Stock)
FasterScrollController.ScrollViewPatcherStock(__instance); // Repatching to stock if previously was on Constant
}
}
@@ -58,10 +51,7 @@ static void Prefix(ScrollView __instance, Vector2 deltaPos)
if ((FasterScrollController.FasterScrollMode == FasterScrollController.FasterScrollModeEnum.Exp
|| FasterScrollController.FasterScrollMode == FasterScrollController.FasterScrollModeEnum.Linear
) && __instance.transform.parent.gameObject.name == "LevelsTableView")
{
//Plugin.Log?.Error("ScrollViewHandleJoystickWasNotCenteredThisFramePostfixPatch");
FasterScrollController.ScrollViewPatcherDynamic(__instance);
}
}
}

@@ -75,10 +65,7 @@ static void Prefix(ScrollView __instance)
if ((FasterScrollController.FasterScrollMode == FasterScrollController.FasterScrollModeEnum.Exp
|| FasterScrollController.FasterScrollMode == FasterScrollController.FasterScrollModeEnum.Linear
) && __instance.transform.parent.gameObject.name == "LevelsTableView")
{
//Plugin.Log?.Error("ScrollViewHandleJoystickWasCenteredThisFramePostfixPatch");
FasterScrollController.ResetInertia();
}
}
}

@@ -93,10 +80,7 @@ class ScrollViewHandlePointerDidEnterPostFixPatch
static void Prefix(ScrollView __instance, PointerEventData eventData)
{
if (__instance.transform.parent.gameObject.name == "LevelsTableView")
{
//Plugin.Log?.Error("ScrollViewHandlePointerDidEnterPostFixPatch");
FasterScrollController.PostHandlePointerDidEnter();
}
}
}

@@ -108,10 +92,7 @@ class ScrollViewHandlePointerDidExitPostFixPatch
static void Prefix(ScrollView __instance, PointerEventData eventData)
{
if (__instance.transform.parent.gameObject.name == "LevelsTableView")
{
//Plugin.Log?.Error("ScrollViewHandlePointerDidExitPostFixPatch");
FasterScrollController.PostHandlePointerDidExit();
}
}
}

@@ -123,7 +104,6 @@ static void Prefix(HapticPresetSO ____rumblePreset)
{
if (FasterScrollController.IsRumbleStrengthValueDirty)
{
//Plugin.Log?.Error("VRInputModuleHandlePointerExitAndEnterPreFixPatch");
____rumblePreset._strength = FasterScrollController.RumbleStrength;
FasterScrollController.IsRumbleStrengthValueDirty = false;
}
13 changes: 5 additions & 8 deletions FasterScroll/Plugin.cs
Original file line number Diff line number Diff line change
@@ -9,15 +9,14 @@

namespace FasterScroll
{
[Plugin(RuntimeOptions.DynamicInit)] // TODO turn into nondynamic ... otherwise it will be a pain in the butt to reset potential tweaked scrollvalue
[Plugin(RuntimeOptions.SingleStartInit)]
public class Plugin
{
public const string HarmonyId = "com.github.Aryetis.FasterScroll";
internal static readonly HarmonyLib.Harmony harmony = new HarmonyLib.Harmony(HarmonyId);

internal static Plugin Instance { get; private set; }
internal static IPALogger Log { get; private set; }
internal static FasterScrollController PluginController { get { return FasterScrollController.Instance; } }

[Init]
public Plugin(IPALogger logger, Config conf)
@@ -29,20 +28,18 @@ public Plugin(IPALogger logger, Config conf)
}

#region Disableable
[OnEnable]
public void OnEnable()
[OnStart]
public void OnApplicationStart()
{
BSMLSettings.instance.AddSettingsMenu("FasterScroll", "FasterScroll.Views.Settings.bsml", PluginSettings.instance);
new GameObject("FasterScrollController").AddComponent<FasterScrollController>();
ApplyHarmonyPatches();
}

[OnDisable]
public void OnDisable()
[OnExit]
public void OnApplicationQuit()
{
BSMLSettings.instance.RemoveSettingsMenu(PluginSettings.instance);
if (PluginController != null)
GameObject.Destroy(PluginController);
RemoveHarmonyPatches();
}
#endregion

0 comments on commit b017db4

Please sign in to comment.