Elin Decompiled Documentation EA 23.102 Nightly
Loading...
Searching...
No Matches
WidgetMouseover.cs
Go to the documentation of this file.
1using System;
2using DG.Tweening;
3using UnityEngine;
4using UnityEngine.UI;
5
6public class WidgetMouseover : Widget
7{
8 public static WidgetMouseover Instance;
9
10 public Chara roster;
11
13
14 public LayoutGroup layout;
15
16 public CanvasGroup cg;
17
18 public Tween tween;
19
20 private float timer;
21
22 public override void OnActivate()
23 {
24 Instance = this;
25 Hide(immediate: true);
26 }
27
28 public void Refresh()
29 {
30 timer += Core.delta;
31 PointTarget mouseTarget = EMono.scene.mouseTarget;
32 if (!mouseTarget.hasTargetChanged && timer < 0.1f)
33 {
34 return;
35 }
36 timer = 0f;
37 bool flag = EInput.isShiftDown && mouseTarget.pos.Equals(EMono.pc.pos) && (EMono.pc.ride != null || EMono.pc.parasite != null);
38 if (((!flag && mouseTarget.target == null) || (ActionMode.IsAdv && Input.GetMouseButton(0))) && roster == null)
39 {
40 Hide();
41 return;
42 }
43 string text = "";
44 Card card = mouseTarget.card;
45 if (roster != null && roster.ExistsOnMap)
46 {
47 flag = false;
48 card = roster;
49 }
50 if (flag)
51 {
52 if (EMono.pc.ride != null)
53 {
54 text += EMono.pc.ride.GetHoverText();
55 text += EMono.pc.ride.GetHoverText2();
56 }
57 if (EMono.pc.parasite != null)
58 {
59 if (EMono.pc.ride != null)
60 {
61 text += Environment.NewLine;
62 }
63 text += EMono.pc.parasite.GetHoverText();
65 }
66 }
67 else if (card != null)
68 {
69 text = card.GetHoverText();
70 if (roster == null)
71 {
72 int count = EMono.scene.mouseTarget.cards.Count;
73 if (count > 1)
74 {
75 text += "otherCards".lang((count - 1).ToString() ?? "");
76 }
77 }
78 text += card.GetHoverText2();
79 if (roster == null && mouseTarget.target != card)
80 {
81 text = text + Environment.NewLine + mouseTarget.target.InspectName;
82 }
83 }
84 else if (mouseTarget.target != null)
85 {
86 text = mouseTarget.target.InspectName;
87 }
88 Show(text);
89 }
90
91 public void Show(string s)
92 {
93 layout.SetActive(enable: true);
94 cg.alpha = 1f;
95 TweenUtil.KillTween(ref tween);
96 textName.text = s;
97 switch (this.Rect().GetAnchor())
98 {
99 case RectPosition.TopLEFT:
100 case RectPosition.BottomLEFT:
101 layout.childAlignment = TextAnchor.MiddleLeft;
102 break;
103 case RectPosition.TopRIGHT:
104 case RectPosition.BottomRIGHT:
105 layout.childAlignment = TextAnchor.MiddleRight;
106 break;
107 default:
108 layout.childAlignment = TextAnchor.MiddleCenter;
109 break;
110 }
111 layout.RebuildLayout();
112 }
113
114 public void Hide(bool immediate = false)
115 {
116 imageBG.raycastTarget = false;
117 if (immediate)
118 {
119 layout.SetActive(enable: false);
120 return;
121 }
122 TweenUtil.KillTween(ref tween);
123 tween = cg.DOFade(0f, 0.3f).OnComplete(delegate
124 {
125 if ((bool)layout)
126 {
127 layout.SetActive(enable: false);
128 }
129 }).SetEase(Ease.InQuad);
130 }
131
132 public override void OnManagerActivate()
133 {
134 base.OnManagerActivate();
135 imageBG.raycastTarget = true;
136 Show("[" + Lang.Get("WidgetMouseover") + "]");
137 }
138
139 public override void OnManagerDeactivate()
140 {
141 base.OnManagerDeactivate();
142 Hide(immediate: true);
143 }
144}
RectPosition
Definition: RectPosition.cs:2
static bool IsAdv
Definition: ActionMode.cs:117
Definition: Card.cs:11
bool ExistsOnMap
Definition: Card.cs:1961
Point pos
Definition: Card.cs:55
Definition: Chara.cs:10
override string GetHoverText()
Definition: Chara.cs:6118
Chara parasite
Definition: Chara.cs:30
Chara ride
Definition: Chara.cs:27
override string GetHoverText2()
Definition: Chara.cs:6186
Definition: Core.cs:14
static float delta
Definition: Core.cs:17
Definition: EMono.cs:4
static Chara pc
Definition: EMono.cs:13
static Scene scene
Definition: EMono.cs:27
Definition: Hide.cs:4
Definition: Lang.cs:6
static string Get(string id)
Definition: Lang.cs:91
bool hasTargetChanged
Definition: PointTarget.cs:20
IInspect target
Definition: PointTarget.cs:16
List< Card > cards
Definition: PointTarget.cs:38
bool Equals(int _x, int _z)
Definition: Point.cs:924
PointTarget mouseTarget
Definition: Scene.cs:129
Definition: UIText.cs:6
void Show(string s)
void Hide(bool immediate=false)
override void OnManagerActivate()
override void OnManagerDeactivate()
CanvasGroup cg
LayoutGroup layout
override void OnActivate()
static WidgetMouseover Instance
Definition: Widget.cs:7
string InspectName
Definition: IInspect.cs:16