Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions Silksong.ModMenu/Elements/TextInput.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,6 @@ public TextInput(LocalizedText label, ITextModel<T> model, LocalizedText descrip
InputField.contentType = InputField.ContentType.IntegerNumber;
else if (floatTypes.Contains(typeof(T)))
InputField.contentType = InputField.ContentType.DecimalNumber;

input.AddComponent<DescriptionAnimationHelper>().DescriptionAnimator =
DescriptionText.gameObject.GetComponent<Animator>();
}

/// <summary>
Expand Down
6 changes: 6 additions & 0 deletions Silksong.ModMenu/Internal/MenuPrefabs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,12 @@ private MenuPrefabs(UIManager uiManager)
textInputField.contentType = InputField.ContentType.Standard;
textInputField.caretWidth = 8;
textInputField.text = "";
textInputChild.AddComponent<MenuSelectableAnimationProxy>().Animators =
[
textInputChild.FindChild("Description")!.GetComponent<Animator>(),
textInputChild.FindChild("CursorLeft")!.GetComponent<Animator>(),
textInputChild.FindChild("CursorRight")!.GetComponent<Animator>(),
];

sliderTemplate = Object.Instantiate(
canvas.FindChild("AudioMenuScreen/Content/MasterVolume")!
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;

namespace Silksong.ModMenu.Internal;

internal class DescriptionAnimationHelper
internal class MenuSelectableAnimationProxy
: MonoBehaviour,
ISelectHandler,
IDeselectHandler,
ICancelHandler
{
private Selectable _selectable;
public Animator? DescriptionAnimator { get; set; }
public List<Animator> Animators = [];

void Awake()
{
Expand All @@ -27,7 +28,7 @@ public void OnDeselect(BaseEventData eventData)
// My best attempt to imitate the code from MenuSelectable.ValidateDeselect
private IEnumerator ValidateDeselect(BaseEventData eventData, bool force)
{
if (DescriptionAnimator == null)
if (Animators.Count == 0)
{
yield break;
}
Expand All @@ -51,8 +52,11 @@ private IEnumerator ValidateDeselect(BaseEventData eventData, bool force)

if (EventSystem.current.currentSelectedGameObject != null || force)
{
DescriptionAnimator.ResetTrigger(MenuSelectable._showPropId);
DescriptionAnimator.SetTrigger(MenuSelectable._hidePropId);
foreach (Animator animator in Animators)
{
animator.ResetTrigger(MenuSelectable._showPropId);
animator.SetTrigger(MenuSelectable._hidePropId);
}
}
else if (prevSelectedObject != null && prevSelectedObject.activeInHierarchy)
{
Expand All @@ -62,7 +66,7 @@ private IEnumerator ValidateDeselect(BaseEventData eventData, bool force)

public void OnSelect(BaseEventData eventData)
{
if (DescriptionAnimator == null)
if (Animators.Count == 0)
{
return;
}
Expand All @@ -72,8 +76,11 @@ public void OnSelect(BaseEventData eventData)
return;
}

DescriptionAnimator.ResetTrigger(MenuSelectable._hidePropId);
DescriptionAnimator.SetTrigger(MenuSelectable._showPropId);
foreach (Animator animator in Animators)
{
animator.ResetTrigger(MenuSelectable._hidePropId);
animator.SetTrigger(MenuSelectable._showPropId);
}
}

public void OnCancel(BaseEventData eventData)
Expand Down