Elin Decompiled Documentation EA 23.289 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 int spacing;
14
15 [JsonProperty]
16 public int fontSize;
17
18 [JsonProperty]
19 public bool showGauge;
20
21 [JsonProperty]
22 public bool showMax;
23
24 [JsonProperty]
25 public bool stamina;
26 }
27
28 public Gauge gaugeHP;
29
30 public Gauge gaugeMP;
31
33
34 public UIText textHP;
35
36 public UIText textMP;
37
39
41
42 public GridLayoutGroup grid;
43
44 public GameObject goBarrier;
45
46 public Extra extra => base.config.extra as Extra;
47
48 public override object CreateExtra()
49 {
50 return new Extra();
51 }
52
53 public override void OnActivate()
54 {
55 Rebuild();
56 InvokeRepeating("Refresh", 0f, 0.2f);
57 }
58
59 public void Rebuild()
60 {
61 grid.constraintCount = extra.layout + 1;
62 Refresh();
63 this.RebuildLayout();
64 }
65
66 public void Refresh()
67 {
68 if (!EMono.game.isLoading)
69 {
70 if (EMono.pc.hp > EMono.pc.MaxHP)
71 {
72 EMono.pc.hp = EMono.pc.MaxHP;
73 }
75 {
76 EMono.pc.mana.value = EMono.pc.mana.max;
77 }
79 {
80 EMono.pc.stamina.value = EMono.pc.stamina.max;
81 }
82 }
83 grid.spacing = new Vector2(extra.spacing, 0f);
84 gaugeHP.hideBar = !extra.showGauge;
85 gaugeMP.hideBar = !extra.showGauge;
86 gaugeStamina.hideBar = !extra.showGauge;
87 gaugeStamina.SetActive(extra.stamina);
94 Color c = EMono.Colors.Dark.gradientHP.Evaluate((float)EMono.pc.hp / (float)EMono.pc.MaxHP);
95 gaugeHP.textNow.text = "".TagColor(c, EMono.pc.hp.ToString() ?? "") + (extra.showMax ? (" / " + EMono.pc.MaxHP) : "");
96 c = EMono.Colors.Dark.gradientMP.Evaluate((float)EMono.pc.mana.value / (float)EMono.pc.mana.max);
97 gaugeMP.textNow.text = "".TagColor(c, EMono.pc.mana.value.ToString() ?? "") + (extra.showMax ? (" / " + EMono.pc.mana.max) : "");
98 c = EMono.Colors.Dark.gradientSP.Evaluate((float)EMono.pc.stamina.value / (float)EMono.pc.stamina.max);
99 gaugeStamina.textNow.text = "".TagColor(c, EMono.pc.stamina.value.ToString() ?? "") + (extra.showMax ? (" / " + EMono.pc.stamina.max) : "");
100 goBarrier.SetActive(value: false);
101 textBarrier.text = "10";
102 }
103
104 public override void OnSetContextMenu(UIContextMenu m)
105 {
106 UIContextMenu uIContextMenu = m.AddChild("setting");
107 uIContextMenu.AddSlider("layout", (float n) => n.ToString() ?? "", extra.layout, delegate(float a)
108 {
109 extra.layout = (int)a;
110 Rebuild();
112 }, 0f, 2f, isInt: true);
113 uIContextMenu.AddSlider("spacing", (float n) => n.ToString() ?? "", extra.spacing, delegate(float a)
114 {
115 extra.spacing = (int)a;
116 }, 0f, 100f, isInt: true);
117 uIContextMenu.AddSlider("fontSize", (float n) => n.ToString() ?? "", extra.fontSize, delegate(float a)
118 {
119 extra.fontSize = (int)a;
120 }, -2f, 5f, isInt: true);
121 uIContextMenu.AddToggle("showGauge", extra.showGauge, delegate(bool a)
122 {
123 extra.showGauge = a;
124 Refresh();
125 this.RebuildLayout(recursive: true);
126 });
127 uIContextMenu.AddToggle("showMax", extra.showMax, delegate(bool a)
128 {
129 extra.showMax = a;
130 Refresh();
131 this.RebuildLayout(recursive: true);
132 });
133 uIContextMenu.AddToggle("stamina", extra.stamina, delegate(bool a)
134 {
135 extra.stamina = a;
136 Refresh();
137 this.RebuildLayout(recursive: true);
138 });
140 }
141}
int hp
Definition: Card.cs:243
override int MaxHP
Definition: Chara.cs:722
Stats mana
Definition: Chara.cs:1180
Stats stamina
Definition: Chara.cs:1172
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:242
Definition: Gauge.cs:7
void UpdateValue(float now, float _max)
Definition: Gauge.cs:68
UIText textNow
Definition: Gauge.cs:8
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
int orgSize
Definition: UIText.cs:30
UIText SetSize(int a)
Definition: UIText.cs:231
bool showGauge
Definition: WidgetHP.cs:19
bool stamina
Definition: WidgetHP.cs:25
bool showMax
Definition: WidgetHP.cs:22
Gauge gaugeMP
Definition: WidgetHP.cs:30
override void OnSetContextMenu(UIContextMenu m)
Definition: WidgetHP.cs:104
UIText textStamina
Definition: WidgetHP.cs:38
override object CreateExtra()
Definition: WidgetHP.cs:48
override void OnActivate()
Definition: WidgetHP.cs:53
GameObject goBarrier
Definition: WidgetHP.cs:44
UIText textHP
Definition: WidgetHP.cs:34
Gauge gaugeStamina
Definition: WidgetHP.cs:32
void Rebuild()
Definition: WidgetHP.cs:59
void Refresh()
Definition: WidgetHP.cs:66
UIText textBarrier
Definition: WidgetHP.cs:40
GridLayoutGroup grid
Definition: WidgetHP.cs:42
Extra extra
Definition: WidgetHP.cs:46
UIText textMP
Definition: WidgetHP.cs:36
Gauge gaugeHP
Definition: WidgetHP.cs:28
Definition: Widget.cs:7
void SetBaseContextMenu(UIContextMenu m)
Definition: Widget.cs:624
void ClampToScreen()
Definition: Widget.cs:453