Elin Decompiled Documentation EA 23.102 Nightly
Loading...
Searching...
No Matches
WidgetHP.cs
Go to the documentation of this file.
1using Newtonsoft.Json;
2using UnityEngine;
3using UnityEngine.UI;
4
5public class WidgetHP : Widget
6{
7 public class Extra
8 {
9 [JsonProperty]
10 public int layout;
11
12 [JsonProperty]
13 public bool showGauge;
14
15 [JsonProperty]
16 public bool showMax;
17
18 [JsonProperty]
19 public bool stamina;
20 }
21
22 public Gauge gaugeHP;
23
24 public Gauge gaugeMP;
25
27
28 public UIText textHP;
29
30 public UIText textMP;
31
33
35
36 public GridLayoutGroup grid;
37
38 public GameObject goBarrier;
39
40 public Extra extra => base.config.extra as Extra;
41
42 public override object CreateExtra()
43 {
44 return new Extra();
45 }
46
47 public override void OnActivate()
48 {
49 Rebuild();
50 InvokeRepeating("Refresh", 0f, 0.2f);
51 }
52
53 public void Rebuild()
54 {
55 grid.constraintCount = extra.layout + 1;
56 Refresh();
57 this.RebuildLayout();
58 }
59
60 public void Refresh()
61 {
62 if (!EMono.game.isLoading)
63 {
64 if (EMono.pc.hp > EMono.pc.MaxHP)
65 {
66 EMono.pc.hp = EMono.pc.MaxHP;
67 }
69 {
70 EMono.pc.mana.value = EMono.pc.mana.max;
71 }
73 {
74 EMono.pc.stamina.value = EMono.pc.stamina.max;
75 }
76 }
77 gaugeHP.hideBar = !extra.showGauge;
78 gaugeMP.hideBar = !extra.showGauge;
79 gaugeStamina.hideBar = !extra.showGauge;
80 gaugeStamina.SetActive(extra.stamina);
84 Color c = EMono.Colors.Dark.gradientHP.Evaluate((float)EMono.pc.hp / (float)EMono.pc.MaxHP);
85 gaugeHP.textNow.text = "".TagColor(c, EMono.pc.hp.ToString() ?? "") + (extra.showMax ? ("/" + EMono.pc.MaxHP) : "");
86 c = EMono.Colors.Dark.gradientMP.Evaluate((float)EMono.pc.mana.value / (float)EMono.pc.mana.max);
87 gaugeMP.textNow.text = "".TagColor(c, EMono.pc.mana.value.ToString() ?? "") + (extra.showMax ? ("/" + EMono.pc.mana.max) : "");
88 c = EMono.Colors.Dark.gradientSP.Evaluate((float)EMono.pc.stamina.value / (float)EMono.pc.stamina.max);
89 gaugeStamina.textNow.text = "".TagColor(c, EMono.pc.stamina.value.ToString() ?? "") + (extra.showMax ? ("/" + EMono.pc.stamina.max) : "");
90 goBarrier.SetActive(value: false);
91 textBarrier.text = "10";
92 }
93
94 public override void OnSetContextMenu(UIContextMenu m)
95 {
96 UIContextMenu uIContextMenu = m.AddChild("setting");
97 uIContextMenu.AddSlider("layout", (float n) => n.ToString() ?? "", extra.layout, delegate(float a)
98 {
99 extra.layout = (int)a;
100 Rebuild();
102 }, 0f, 2f, isInt: true);
103 uIContextMenu.AddToggle("showGauge", extra.showGauge, delegate(bool a)
104 {
105 extra.showGauge = a;
106 Refresh();
107 this.RebuildLayout(recursive: true);
108 });
109 uIContextMenu.AddToggle("showMax", extra.showMax, delegate(bool a)
110 {
111 extra.showMax = a;
112 Refresh();
113 this.RebuildLayout(recursive: true);
114 });
115 uIContextMenu.AddToggle("stamina", extra.stamina, delegate(bool a)
116 {
117 extra.stamina = a;
118 Refresh();
119 this.RebuildLayout(recursive: true);
120 });
122 }
123}
int hp
Definition: Card.cs:226
override int MaxHP
Definition: Chara.cs:693
Stats mana
Definition: Chara.cs:963
Stats stamina
Definition: Chara.cs:955
SkinColorProfile Dark
Definition: EMono.cs:4
static ColorProfile Colors
Definition: EMono.cs:35
static Chara pc
Definition: EMono.cs:13
static Game game
Definition: EMono.cs:7
bool isLoading
Definition: Game.cs:235
Definition: Gauge.cs:7
void UpdateValue(float now, float _max)
Definition: Gauge.cs:68
virtual int value
Definition: Stats.cs:56
virtual int max
Definition: Stats.cs:68
UIContextMenuItem AddToggle(string idLang="", bool isOn=false, UnityAction< bool > action=null)
UIContextMenuItem AddSlider(string text, Func< float, string > textFunc, float value, Action< float > action, float min=0f, float max=1f, bool isInt=false, bool hideOther=true, bool useInput=false)
UIContextMenu AddChild(string idLang, TextAnchor anchor)
Definition: UIText.cs:6
bool showGauge
Definition: WidgetHP.cs:13
bool stamina
Definition: WidgetHP.cs:19
bool showMax
Definition: WidgetHP.cs:16
Gauge gaugeMP
Definition: WidgetHP.cs:24
override void OnSetContextMenu(UIContextMenu m)
Definition: WidgetHP.cs:94
UIText textStamina
Definition: WidgetHP.cs:32
override object CreateExtra()
Definition: WidgetHP.cs:42
override void OnActivate()
Definition: WidgetHP.cs:47
GameObject goBarrier
Definition: WidgetHP.cs:38
UIText textHP
Definition: WidgetHP.cs:28
Gauge gaugeStamina
Definition: WidgetHP.cs:26
void Rebuild()
Definition: WidgetHP.cs:53
void Refresh()
Definition: WidgetHP.cs:60
UIText textBarrier
Definition: WidgetHP.cs:34
GridLayoutGroup grid
Definition: WidgetHP.cs:36
Extra extra
Definition: WidgetHP.cs:40
UIText textMP
Definition: WidgetHP.cs:30
Gauge gaugeHP
Definition: WidgetHP.cs:22
Definition: Widget.cs:7
void SetBaseContextMenu(UIContextMenu m)
Definition: Widget.cs:608
void ClampToScreen()
Definition: Widget.cs:437