summaryrefslogtreecommitdiff
path: root/GameCode/TFUIEnumMouseCatcher.cs
diff options
context:
space:
mode:
authorchai <215380520@qq.com>2023-11-02 11:51:31 +0800
committerchai <215380520@qq.com>2023-11-02 11:51:31 +0800
commit7f493f682503f5186308de7b8f74b5b49233cfe4 (patch)
tree8a91e2056bc79788ee4735dce88b8d516ba12beb /GameCode/TFUIEnumMouseCatcher.cs
+init
Diffstat (limited to 'GameCode/TFUIEnumMouseCatcher.cs')
-rw-r--r--GameCode/TFUIEnumMouseCatcher.cs51
1 files changed, 51 insertions, 0 deletions
diff --git a/GameCode/TFUIEnumMouseCatcher.cs b/GameCode/TFUIEnumMouseCatcher.cs
new file mode 100644
index 0000000..e46eb62
--- /dev/null
+++ b/GameCode/TFUIEnumMouseCatcher.cs
@@ -0,0 +1,51 @@
+using System.Collections.Generic;
+using UnityEngine;
+
+public class TFUIEnumMouseCatcher : ThronefallUIElement
+{
+ public List<ThronefallUIElement> focusWhitelist = new List<ThronefallUIElement>();
+
+ public GameObject buttons;
+
+ private UIFrame targetFrame;
+
+ protected override void OnApply()
+ {
+ }
+
+ protected override void OnClear()
+ {
+ }
+
+ protected override void OnFocus()
+ {
+ buttons.SetActive(value: true);
+ targetFrame.onNewFocus.AddListener(ListenForUnfocus);
+ }
+
+ protected override void OnFocusAndSelect()
+ {
+ }
+
+ protected override void OnHardStateSet(SelectionState selectionState)
+ {
+ }
+
+ protected override void OnSelect()
+ {
+ }
+
+ private void Start()
+ {
+ targetFrame = GetComponentInParent<UIFrame>();
+ }
+
+ private void ListenForUnfocus()
+ {
+ if (!(targetFrame.CurrentFocus == this) && !focusWhitelist.Contains(targetFrame.CurrentFocus))
+ {
+ buttons.SetActive(value: false);
+ targetFrame.onNewFocus.RemoveListener(ListenForUnfocus);
+ }
+ }
+}