Elin Decompiled Documentation EA 23.102 Nightly
Loading...
Searching...
No Matches
TooltipManager.cs
Go to the documentation of this file.
1using UnityEngine;
2
3public class TooltipManager : MonoBehaviour
4{
5 public static TooltipManager Instance;
6
8
9 public string disableHide;
10
11 public float disableTimer;
12
13 private void Awake()
14 {
15 Instance = this;
16 }
17
18 public void ResetTooltips()
19 {
20 UITooltip[] array = tooltips;
21 for (int i = 0; i < array.Length; i++)
22 {
23 array[i].data = null;
24 }
25 }
26
27 public void ShowTooltip(TooltipData data, Transform target)
28 {
29 if (disableTimer > 0f)
30 {
31 return;
32 }
33 if ((bool)UIContextMenu.Current)
34 {
35 UIButton componentOf = InputModuleEX.GetComponentOf<UIButton>();
36 if (!componentOf || !componentOf.transform.GetComponentInParent<UIContextMenu>())
37 {
38 return;
39 }
40 }
41 UITooltip uITooltip = tooltips[0];
42 UITooltip[] array = tooltips;
43 foreach (UITooltip uITooltip2 in array)
44 {
45 if (uITooltip2.name == data.id)
46 {
47 uITooltip = uITooltip2;
48 }
49 }
50 uITooltip.SetActive(enable: true);
51 uITooltip.SetData(data);
52 if (uITooltip.cg.alpha < 0.1f)
53 {
54 uITooltip.cg.alpha = 1f;
55 }
56 float timer = 0f;
57 uITooltip.hideFunc = delegate
58 {
59 if (target == null || !InputModuleEX.IsPointerOver(target))
60 {
61 timer += Time.smoothDeltaTime;
62 return timer > 0.2f;
63 }
64 timer = 0f;
65 return false;
66 };
67 if (uITooltip.followType == UITooltip.FollowType.None)
68 {
69 return;
70 }
71 Vector3 vector = ((uITooltip.followType == UITooltip.FollowType.Mouse) ? EInput.uiMousePosition : target.position);
72 if (uITooltip.followType == UITooltip.FollowType.Pivot)
73 {
74 GameObject gameObject = target.FindTagInParents("PivotTooltip", includeInactive: false);
75 if ((bool)gameObject)
76 {
77 uITooltip.Rect().pivot = gameObject.transform.Rect().pivot;
78 vector = gameObject.transform.position;
79 }
80 else
81 {
82 uITooltip.Rect().pivot = uITooltip.orgPivot;
83 }
84 }
85 uITooltip.transform.position = vector + data.offset + uITooltip.offset;
86 Util.ClampToScreen(uITooltip.Rect(), 50);
87 }
88
89 public void HideTooltips(bool immediate = false)
90 {
91 UITooltip[] array = tooltips;
92 foreach (UITooltip uITooltip in array)
93 {
94 if (immediate)
95 {
96 uITooltip.cg.alpha = 0f;
97 uITooltip.data = null;
98 uITooltip.SetActive(enable: false);
99 continue;
100 }
101 float timer = 0f;
102 uITooltip.hideFunc = delegate
103 {
104 timer += Time.smoothDeltaTime;
105 return timer > 0.2f;
106 };
107 }
108 }
109
110 private void Update()
111 {
112 if (disableTimer > 0f)
113 {
114 disableTimer -= Time.deltaTime;
115 }
116 UITooltip[] array = tooltips;
117 foreach (UITooltip uITooltip in array)
118 {
119 if (!(uITooltip.name == disableHide) && uITooltip.gameObject.activeSelf)
120 {
121 if (uITooltip.hideFunc())
122 {
123 uITooltip.cg.alpha -= Time.smoothDeltaTime * 5f;
124 }
125 else
126 {
127 uITooltip.cg.alpha += Time.smoothDeltaTime * 5f;
128 }
129 if (uITooltip.cg.alpha <= 0f)
130 {
131 uITooltip.data = null;
132 uITooltip.SetActive(enable: false);
133 }
134 }
135 }
136 }
137}
Definition: EInput.cs:8
static Vector3 uiMousePosition
Definition: EInput.cs:369
static bool IsPointerOver(Component c)
void ResetTooltips()
void ShowTooltip(TooltipData data, Transform target)
static TooltipManager Instance
void HideTooltips(bool immediate=false)
UITooltip[] tooltips
string disableHide
static UIContextMenu Current
Func< bool > hideFunc
Definition: UITooltip.cs:43
TooltipData data
Definition: UITooltip.cs:15
CanvasGroup cg
Definition: UITooltip.cs:41
void SetData(TooltipData _data)
Definition: UITooltip.cs:52