Elin Decompiled Documentation EA 23.197 Nightly Patch 1
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 t = tooltips[0];
42 UITooltip[] array = tooltips;
43 foreach (UITooltip uITooltip in array)
44 {
45 if (uITooltip.name == data.id)
46 {
47 t = uITooltip;
48 }
49 }
50 t.SetActive(enable: true);
51 t.SetData(data);
52 if (t.cg.alpha < 0.1f)
53 {
54 t.cg.alpha = 1f;
55 }
56 t.hideTimer = 0f;
57 t.hideFunc = delegate
58 {
59 if (target == null || !InputModuleEX.IsPointerOver(target))
60 {
61 t.hideTimer += Time.smoothDeltaTime;
62 return t.hideTimer > 0.2f;
63 }
64 t.hideTimer = 0f;
65 return false;
66 };
67 if (t.followType == UITooltip.FollowType.None)
68 {
69 return;
70 }
71 Vector3 vector = ((t.followType == UITooltip.FollowType.Mouse) ? EInput.uiMousePosition : target.position);
72 if (t.followType == UITooltip.FollowType.Pivot)
73 {
74 GameObject gameObject = target.FindTagInParents("PivotTooltip", includeInactive: false);
75 if ((bool)gameObject)
76 {
77 t.Rect().pivot = gameObject.transform.Rect().pivot;
78 vector = gameObject.transform.position;
79 }
80 else
81 {
82 t.Rect().pivot = t.orgPivot;
83 }
84 }
85 t.transform.position = vector + data.offset + t.offset;
86 Util.ClampToScreen(t.Rect(), 20);
87 }
88
89 public void HideTooltips(bool immediate = false)
90 {
91 UITooltip[] array = tooltips;
92 foreach (UITooltip t in array)
93 {
94 if (immediate)
95 {
96 t.cg.alpha = 0f;
97 t.data = null;
98 t.SetActive(enable: false);
99 }
100 else
101 {
102 t.hideFunc = delegate
103 {
104 t.hideTimer += Time.smoothDeltaTime;
105 return t.hideTimer > 0.2f;
106 };
107 }
108 }
109 }
110
111 private void Update()
112 {
113 if (disableTimer > 0f)
114 {
115 disableTimer -= Time.deltaTime;
116 }
117 UITooltip[] array = tooltips;
118 foreach (UITooltip uITooltip in array)
119 {
120 if (!(uITooltip.name == disableHide) && uITooltip.gameObject.activeSelf)
121 {
122 if (uITooltip.hideFunc())
123 {
124 uITooltip.cg.alpha -= Time.smoothDeltaTime * 5f;
125 }
126 else
127 {
128 uITooltip.cg.alpha += Time.smoothDeltaTime * 5f;
129 }
130 if (uITooltip.cg.alpha <= 0f)
131 {
132 uITooltip.data = null;
133 uITooltip.SetActive(enable: false);
134 }
135 }
136 }
137 }
138}
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:55