Elin Modding Docs Doc
Loading...
Searching...
No Matches
WidgetStatsBar.cs
1using System;
2using System.Collections.Generic;
3using UnityEngine;
4using UnityEngine.UI;
5
6// Token: 0x02000642 RID: 1602
7public class WidgetStatsBar : Widget
8{
9 // Token: 0x06002CFA RID: 11514 RVA: 0x000FB86A File Offset: 0x000F9A6A
10 public override object CreateExtra()
11 {
12 return new WidgetStatsBar.Extra();
13 }
14
15 // Token: 0x17000CC3 RID: 3267
16 // (get) Token: 0x06002CFB RID: 11515 RVA: 0x000FB871 File Offset: 0x000F9A71
17 public WidgetStatsBar.Extra extra
18 {
19 get
20 {
21 return base.config.extra as WidgetStatsBar.Extra;
22 }
23 }
24
25 // Token: 0x17000CC4 RID: 3268
26 // (get) Token: 0x06002CFC RID: 11516 RVA: 0x000FB883 File Offset: 0x000F9A83
27 public Color colorDefault
28 {
29 get
30 {
31 return base.config.skin.BG.colors.textDefault;
32 }
33 }
34
35 // Token: 0x17000CC5 RID: 3269
36 // (get) Token: 0x06002CFD RID: 11517 RVA: 0x000FB89F File Offset: 0x000F9A9F
37 public Color colorBad
38 {
39 get
40 {
41 return base.config.skin.BG.colors.textBad;
42 }
43 }
44
45 // Token: 0x17000CC6 RID: 3270
46 // (get) Token: 0x06002CFE RID: 11518 RVA: 0x000FB8BB File Offset: 0x000F9ABB
47 public Color colorVeryBad
48 {
49 get
50 {
51 return base.config.skin.BG.colors.textBad;
52 }
53 }
54
55 // Token: 0x06002CFF RID: 11519 RVA: 0x000FB8D7 File Offset: 0x000F9AD7
56 public override void OnActivate()
57 {
58 WidgetStatsBar.Instance = this;
59 this.mold = this.layout.CreateMold(null);
60 this.Build();
61 base.InvokeRepeating("Refresh", 0.2f, 0.2f);
62 }
63
64 // Token: 0x06002D00 RID: 11520 RVA: 0x000FB90C File Offset: 0x000F9B0C
65 public void Build()
66 {
67 this.items.Clear();
68 this.layout.DestroyChildren(false, true);
69 if (this.extra.attributes)
70 {
71 foreach (Element ele in EMono.pc.elements.ListElements((Element e) => e.HasTag("primary"), null))
72 {
73 this.Add(ele, "", null, null, null, null);
74 }
75 this.Add(EMono.pc.elements.GetElement(79), "", null, null, null, null);
76 }
77 if (this.extra.maxAlly)
78 {
79 this.Add(null, "maxAlly", this.iconMaxAlly, () => (EMono.pc.party.members.Count - 1).ToString() + "/" + EMono.player.MaxAlly.ToString(), delegate
80 {
81 if (EMono.player.lastEmptyAlly >= 0)
82 {
83 return FontColor.Default;
84 }
85 return FontColor.Bad;
86 }, null);
87 }
88 if (this.extra.money)
89 {
90 this.Add(null, "money", this.iconMoney, () => EMono.pc.GetCurrency("money").ToString("#,0") ?? "", null, null);
91 }
92 if (this.extra.money2)
93 {
94 this.Add(null, "money2", this.iconMoney2, () => EMono.pc.GetCurrency("money2").ToString("#,0") ?? "", null, null);
95 }
96 if (this.extra.plat)
97 {
98 this.Add(null, "plat", this.iconPlat, () => EMono.pc.GetCurrency("plat").ToString("#,0") ?? "", null, null);
99 }
100 if (this.extra.medal)
101 {
102 this.Add(null, "medal", this.iconMedal, () => EMono.pc.GetCurrency("medal").ToString("#,0") ?? "", null, null);
103 }
104 if (this.extra.karma)
105 {
106 this.Add(null, "karma", this.iconKarma, () => EMono.player.karma.ToString() ?? "", null, null);
107 }
108 if (this.extra.mood)
109 {
110 this.Add(null, "mood", this.iconGodMood, () => EMono.pc.faith.TextMood ?? "", null, null);
111 }
112 if (this.extra.fame)
113 {
114 this.Add(null, "fame", this.iconFame, () => EMono.player.fame.ToString() ?? "", null, null);
115 }
116 if (this.extra.influence)
117 {
118 this.Add(null, "influence", this.iconInfluence, () => EMono._zone.influence.ToString() ?? "", null, () => EMono._zone.influence != 0);
119 }
120 if (this.extra.tourism_value)
121 {
122 this.Add(null, "tourism_value", this.iconTourismValue, delegate
123 {
124 if (EMono.Branch != null)
125 {
126 return EMono.Branch.tourism.ToFormat();
127 }
128 return "";
129 }, null, () => EMono._zone.IsPCFaction);
130 }
131 if (this.extra.hearthLv)
132 {
133 this.Add(null, "hearth_lv", this.iconHearth, delegate
134 {
135 if (EMono.Branch != null)
136 {
137 return EMono.Branch.TextLv;
138 }
139 return "";
140 }, delegate
141 {
142 if (EMono.Branch != null && EMono.Branch.exp < EMono.Branch.GetNextExp(-1))
143 {
144 return FontColor.Default;
145 }
146 return FontColor.Good;
147 }, () => EMono._zone.IsPCFaction);
148 }
149 if (this.extra.weight)
150 {
151 this.Add(null, "weight", this.iconWeight, () => ((float)EMono.pc.ChildrenWeight / 1000f).ToString("F1") + " / " + ((float)EMono.pc.WeightLimit / 1000f).ToString("F1"), delegate
152 {
153 int phase = EMono.pc.burden.GetPhase();
154 if (phase == 0)
155 {
156 return FontColor.Default;
157 }
158 if (phase != 1)
159 {
160 return FontColor.Bad;
161 }
162 return FontColor.Warning;
163 }, null);
164 }
165 this.Refresh();
166 }
167
168 // Token: 0x06002D01 RID: 11521 RVA: 0x000FBDA4 File Offset: 0x000F9FA4
169 public UIItem Add(Element ele, string id = "", Sprite sprite = null, Func<string> func = null, Func<FontColor> funcCol = null, Func<bool> funcShow = null)
170 {
171 UIItem uiitem = Util.Instantiate<UIItem>(this.mold, this.layout);
173 {
174 ele = ele,
175 component = uiitem,
176 id = id,
177 func = func,
178 funcCol = funcCol,
179 funcShow = funcShow
180 };
181 if (sprite)
182 {
183 uiitem.image1.sprite = sprite;
184 }
185 else
186 {
187 uiitem.image1.sprite = ele.GetIcon("_m");
188 }
189 uiitem.image1.SetNativeSize();
190 uiitem.text1.skinRoot = base.skinRoot;
191 Shadow component = uiitem.text1.GetComponent<Shadow>();
192 if (component)
193 {
194 component.enabled = base.config.skin.BG.textShadow;
195 }
196 this.items.Add(item);
197 return uiitem;
198 }
199
200 // Token: 0x06002D02 RID: 11522 RVA: 0x000FBE7C File Offset: 0x000FA07C
201 public void Refresh()
202 {
203 bool flag = false;
204 foreach (WidgetStatsBar.Item item in this.items)
205 {
206 string text = item.component.text1.text;
207 FontColor fontColor = FontColor.Default;
208 string text2;
209 if (!item.id.IsEmpty())
210 {
211 text2 = item.func();
212 if (item.funcCol != null)
213 {
214 fontColor = item.funcCol();
215 }
216 }
217 else
218 {
219 Element ele = item.ele;
220 text2 = (ele.DisplayValue.ToString() ?? "");
221 if (ele.DisplayValue < ele.ValueWithoutLink)
222 {
223 text2 = text2 + " (" + ele.ValueWithoutLink.ToString() + ")";
224 }
225 if (ele.DisplayValue < ele.ValueWithoutLink)
226 {
227 fontColor = FontColor.Bad;
228 }
229 else if (EMono.pc.tempElements != null)
230 {
231 Element element = EMono.pc.tempElements.GetElement(ele.id);
232 if (element != null && element.vBase > 0)
233 {
234 fontColor = FontColor.Good;
235 }
236 }
237 }
238 if (text2 != text || item.lastColor != fontColor)
239 {
240 item.component.text1.SetText(text2, fontColor);
241 item.component.RebuildLayout(false);
242 flag = true;
243 item.lastColor = fontColor;
244 }
245 if (item.funcShow != null)
246 {
247 item.component.SetActive(item.funcShow());
248 }
249 }
250 if (flag)
251 {
252 this.layout.RebuildLayout(false);
253 this.RebuildLayout(false);
254 }
255 }
256
257 // Token: 0x06002D03 RID: 11523 RVA: 0x000FC040 File Offset: 0x000FA240
258 public override void OnSetContextMenu(UIContextMenu m)
259 {
260 UIContextMenu uicontextMenu = m.AddChild("setting");
261 uicontextMenu.AddToggle("attributes", this.extra.attributes, delegate(bool a)
262 {
263 this.extra.attributes = a;
264 this.Build();
265 });
266 uicontextMenu.AddToggle("maxAlly", this.extra.maxAlly, delegate(bool a)
267 {
268 this.extra.maxAlly = a;
269 this.Build();
270 });
271 uicontextMenu.AddToggle("money", this.extra.money, delegate(bool a)
272 {
273 this.extra.money = a;
274 this.Build();
275 });
276 uicontextMenu.AddToggle("money2", this.extra.money2, delegate(bool a)
277 {
278 this.extra.money2 = a;
279 this.Build();
280 });
281 uicontextMenu.AddToggle("plat", this.extra.plat, delegate(bool a)
282 {
283 this.extra.plat = a;
284 this.Build();
285 });
286 uicontextMenu.AddToggle("medal", this.extra.medal, delegate(bool a)
287 {
288 this.extra.medal = a;
289 this.Build();
290 });
291 uicontextMenu.AddToggle("influence", this.extra.influence, delegate(bool a)
292 {
293 this.extra.influence = a;
294 this.Build();
295 });
296 uicontextMenu.AddToggle("karma", this.extra.karma, delegate(bool a)
297 {
298 this.extra.karma = a;
299 this.Build();
300 });
301 uicontextMenu.AddToggle("fame", this.extra.fame, delegate(bool a)
302 {
303 this.extra.fame = a;
304 this.Build();
305 });
306 if (EMono.debug)
307 {
308 uicontextMenu.AddToggle("godMood", this.extra.mood, delegate(bool a)
309 {
310 this.extra.mood = a;
311 this.Build();
312 });
313 }
314 uicontextMenu.AddToggle("tourism_value", this.extra.tourism_value, delegate(bool a)
315 {
316 this.extra.tourism_value = a;
317 this.Build();
318 });
319 uicontextMenu.AddToggle("hearth_lv", this.extra.hearthLv, delegate(bool a)
320 {
321 this.extra.hearthLv = a;
322 this.Build();
323 });
324 uicontextMenu.AddToggle("invWeight", this.extra.weight, delegate(bool a)
325 {
326 this.extra.weight = a;
327 this.Build();
328 });
329 base.SetBaseContextMenu(m);
330 }
331
332 // Token: 0x06002D04 RID: 11524 RVA: 0x000FC233 File Offset: 0x000FA433
333 public override void OnApplySkin()
334 {
335 base.OnApplySkin();
336 this.Build();
337 }
338
339 // Token: 0x0400191E RID: 6430
340 public static WidgetStatsBar Instance;
341
342 // Token: 0x0400191F RID: 6431
343 public LayoutGroup layout;
344
345 // Token: 0x04001920 RID: 6432
346 public List<WidgetStatsBar.Item> items = new List<WidgetStatsBar.Item>();
347
348 // Token: 0x04001921 RID: 6433
349 public Sprite iconMoney;
350
351 // Token: 0x04001922 RID: 6434
352 public Sprite iconMoney2;
353
354 // Token: 0x04001923 RID: 6435
355 public Sprite iconPlat;
356
357 // Token: 0x04001924 RID: 6436
358 public Sprite iconMedal;
359
360 // Token: 0x04001925 RID: 6437
361 public Sprite iconKarma;
362
363 // Token: 0x04001926 RID: 6438
364 public Sprite iconWeight;
365
366 // Token: 0x04001927 RID: 6439
367 public Sprite iconInfluence;
368
369 // Token: 0x04001928 RID: 6440
370 public Sprite iconMaxAlly;
371
372 // Token: 0x04001929 RID: 6441
373 public Sprite iconGodMood;
374
375 // Token: 0x0400192A RID: 6442
376 public Sprite iconHearth;
377
378 // Token: 0x0400192B RID: 6443
379 public Sprite iconTourismValue;
380
381 // Token: 0x0400192C RID: 6444
382 public Sprite iconFame;
383
384 // Token: 0x0400192D RID: 6445
385 private UIItem mold;
386
387 // Token: 0x02000BB1 RID: 2993
388 public class Item
389 {
390 // Token: 0x04002EC5 RID: 11973
391 public UIItem component;
392
393 // Token: 0x04002EC6 RID: 11974
394 public Element ele;
395
396 // Token: 0x04002EC7 RID: 11975
397 public string id;
398
399 // Token: 0x04002EC8 RID: 11976
400 public Sprite sprite;
401
402 // Token: 0x04002EC9 RID: 11977
403 public Func<string> func;
404
405 // Token: 0x04002ECA RID: 11978
406 public Func<FontColor> funcCol;
407
408 // Token: 0x04002ECB RID: 11979
409 public Func<bool> funcShow;
410
411 // Token: 0x04002ECC RID: 11980
412 public FontColor lastColor;
413 }
414
415 // Token: 0x02000BB2 RID: 2994
416 public class Extra
417 {
418 // Token: 0x04002ECD RID: 11981
419 public bool attributes;
420
421 // Token: 0x04002ECE RID: 11982
422 public bool money;
423
424 // Token: 0x04002ECF RID: 11983
425 public bool money2;
426
427 // Token: 0x04002ED0 RID: 11984
428 public bool plat;
429
430 // Token: 0x04002ED1 RID: 11985
431 public bool medal;
432
433 // Token: 0x04002ED2 RID: 11986
434 public bool karma;
435
436 // Token: 0x04002ED3 RID: 11987
437 public bool mood;
438
439 // Token: 0x04002ED4 RID: 11988
440 public bool weight;
441
442 // Token: 0x04002ED5 RID: 11989
443 public bool influence;
444
445 // Token: 0x04002ED6 RID: 11990
446 public bool maxAlly;
447
448 // Token: 0x04002ED7 RID: 11991
449 public bool hearthLv;
450
451 // Token: 0x04002ED8 RID: 11992
452 public bool tourism_value;
453
454 // Token: 0x04002ED9 RID: 11993
455 public bool fame;
456 }
457}
Definition EMono.cs:6