From 766cdff5ffa72b65d7f106658d1603f47739b2ba Mon Sep 17 00:00:00 2001
From: chai <215380520@qq.com>
Date: Fri, 27 Oct 2023 11:05:14 +0800
Subject: + init

---
 GameCode/ListMenuButton.cs | 102 +++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 102 insertions(+)
 create mode 100644 GameCode/ListMenuButton.cs

(limited to 'GameCode/ListMenuButton.cs')

diff --git a/GameCode/ListMenuButton.cs b/GameCode/ListMenuButton.cs
new file mode 100644
index 0000000..b208a12
--- /dev/null
+++ b/GameCode/ListMenuButton.cs
@@ -0,0 +1,102 @@
+using SoundImplementation;
+using TMPro;
+using UnityEngine;
+using UnityEngine.EventSystems;
+
+public class ListMenuButton : MonoBehaviour, IPointerClickHandler, IEventSystemHandler, IPointerEnterHandler, IPointerExitHandler, IUpdateSelectedHandler, ISelectHandler
+{
+	private TextMeshProUGUI text;
+
+	private Color defaultColor;
+
+	private Vector3 defaultPos;
+
+	public bool changeFontSize = true;
+
+	public bool hideBar;
+
+	public float setBarHeight;
+
+	public bool toggleTextColor;
+
+	public Color selectedTextColor;
+
+	public Color defaultTextColor;
+
+	private float smallFont = 40f;
+
+	private bool inited;
+
+	private void Awake()
+	{
+	}
+
+	private void Start()
+	{
+		Init();
+		smallFont = text.fontSize;
+		defaultPos = text.transform.localPosition;
+		defaultColor = text.color;
+	}
+
+	public void Nope()
+	{
+		Init();
+		MenuEffects.instance.BlinkInColor(text, MenuEffects.instance.nopeColor, defaultColor, 0.15f);
+		MenuEffects.instance.ShakeObject(text.gameObject, defaultPos, 15f, 0.2f);
+	}
+
+	public void Deselect()
+	{
+		Init();
+		text.fontStyle = FontStyles.Normal;
+		_ = changeFontSize;
+		if (toggleTextColor)
+		{
+			GetComponentInChildren<TextMeshProUGUI>().color = defaultTextColor;
+		}
+	}
+
+	public void Select()
+	{
+		Init();
+		text.fontStyle = FontStyles.Bold;
+		_ = changeFontSize;
+		if (toggleTextColor)
+		{
+			GetComponentInChildren<TextMeshProUGUI>().color = selectedTextColor;
+		}
+	}
+
+	public void OnPointerClick(PointerEventData eventData)
+	{
+		SoundPlayerStatic.Instance.PlayButtonClick();
+	}
+
+	public void OnPointerEnter(PointerEventData eventData)
+	{
+		ListMenu.instance.SelectButton(this);
+	}
+
+	public void OnPointerExit(PointerEventData eventData)
+	{
+	}
+
+	public void OnUpdateSelected(BaseEventData eventData)
+	{
+	}
+
+	public void OnSelect(BaseEventData eventData)
+	{
+		ListMenu.instance.SelectButton(this);
+	}
+
+	private void Init()
+	{
+		if (!inited)
+		{
+			inited = true;
+			text = GetComponentInChildren<TextMeshProUGUI>();
+		}
+	}
+}
-- 
cgit v1.1-26-g67d0