diff --git a/Silksong.ModMenu/Directory.Build.props b/Silksong.ModMenu/Directory.Build.props
index b58d1d5..a463834 100644
--- a/Silksong.ModMenu/Directory.Build.props
+++ b/Silksong.ModMenu/Directory.Build.props
@@ -11,6 +11,6 @@
It should follow the format major.minor.patch (semantic versioning). If you publish your mod
as a library to NuGet, this version will also be used as the package version.
-->
- 0.5.1
+ 0.5.2
diff --git a/Silksong.ModMenu/Elements/DynamicDescriptionChoiceElement.cs b/Silksong.ModMenu/Elements/DynamicDescriptionChoiceElement.cs
index 69bf968..65a33ac 100644
--- a/Silksong.ModMenu/Elements/DynamicDescriptionChoiceElement.cs
+++ b/Silksong.ModMenu/Elements/DynamicDescriptionChoiceElement.cs
@@ -1,9 +1,5 @@
using System;
-using Mono.Cecil.Cil;
-using MonoDetour;
-using MonoDetour.Cil;
-using MonoDetour.HookGen;
-using MonoMod.Cil;
+using Silksong.ModMenu.Internal;
using Silksong.ModMenu.Models;
using Silksong.UnityHelper.Extensions;
using UnityEngine;
@@ -28,7 +24,7 @@ LocalizedText rightDescription
)
: base(label, model, description)
{
- RightText = SetupRightDescription(DescriptionText, ChoiceText);
+ RightText = SetupRightDescription(DescriptionText, ChoiceText, SelectableComponent);
RightText.LocalizedText = rightDescription;
}
@@ -55,7 +51,11 @@ Func getRightDescription
///
public readonly Text RightText;
- private static Text SetupRightDescription(Text descriptionText, Text choiceText)
+ private static Text SetupRightDescription(
+ Text descriptionText,
+ Text choiceText,
+ Selectable selectable
+ )
{
GameObject desc = descriptionText.gameObject;
GameObject rightDesc = UObject.Instantiate(
@@ -85,6 +85,10 @@ private static Text SetupRightDescription(Text descriptionText, Text choiceText)
cpbl.originalPosition = rightDesc.transform.localPosition;
}
+ selectable
+ .gameObject.GetOrAddComponent()
+ .Animators.Add(rightDesc.GetComponent());
+
return rightText;
}
@@ -102,85 +106,3 @@ public override void SetMainColor(Color color)
RightText.color = color;
}
}
-
-// Separate class because this can't be done on a generic class
-[MonoDetourTargets(typeof(MenuSelectable))]
-internal static class RightDescriptionChoiceElementHooks
-{
- [MonoDetourHookInitialize]
- private static void Hook()
- {
- Md.UnityEngine.UI.MenuSelectable.OnSelect.ILHook(HookOnSelect);
- Md.UnityEngine.UI.MenuSelectable.ValidateDeselect.ILHookMoveNext(HookOnDeselect);
- }
-
- private static void HookOnSelect(ILManipulationInfo info)
- {
- ILCursor cursor = new(info.Context);
- while (
- cursor.TryGotoNext(
- MoveType.After,
- // this.descriptionText.SetTrigger(MenuSelectable._showPropId)
- i => i.MatchLdarg(0),
- i => i.MatchLdfld(nameof(MenuSelectable.descriptionText)),
- i => i.MatchLdsfld(nameof(MenuSelectable._showPropId)),
- i => i.MatchCallOrCallvirt(nameof(Animator.SetTrigger))
- )
- )
- {
- cursor.Emit(OpCodes.Ldarg_0);
- cursor.EmitDelegate(AnimateUp);
- }
- }
-
- private static void HookOnDeselect(ILManipulationInfo info)
- {
- ILCursor cursor = new(info.Context);
-
- int locIndex = 1;
- while (
- cursor.TryGotoNext(
- MoveType.After,
- // this.descriptionText.SetTrigger(MenuSelectable._hidePropId)
- // It is Ldloc rather than Ldarg.0 because it is the IEnumerator.MoveNext method
- // that is being hooked
- i => i.MatchLdloc(out locIndex),
- i => i.MatchLdfld(nameof(MenuSelectable.descriptionText)),
- i => i.MatchLdsfld(nameof(MenuSelectable._hidePropId)),
- i => i.MatchCallOrCallvirt(nameof(Animator.SetTrigger))
- )
- )
- {
- cursor.Emit(OpCodes.Ldloc, locIndex);
- cursor.EmitDelegate(AnimateDown);
- }
- }
-
- private static void AnimateUp(MenuSelectable selectable)
- {
- GameObject? rightDesc = selectable.gameObject.FindChild(
- DynamicDescriptionChoiceElement