Elin Modding Docs Doc
Loading...
Searching...
No Matches
UICurrency.cs
1using System;
2using System.Collections.Generic;
3using UnityEngine;
4using UnityEngine.UI;
5
6// Token: 0x020005E4 RID: 1508
7public class UICurrency : EMono
8{
9 // Token: 0x0600298E RID: 10638 RVA: 0x000EA994 File Offset: 0x000E8B94
10 private void Awake()
11 {
12 if (this.autoBuild)
13 {
14 this.Build();
15 }
16 base.InvokeRepeating("Refresh", 0.1f, 0.1f);
17 }
18
19 // Token: 0x0600298F RID: 10639 RVA: 0x000EA9B9 File Offset: 0x000E8BB9
20 private void OnEnable()
21 {
22 this.Refresh();
23 }
24
25 // Token: 0x06002990 RID: 10640 RVA: 0x000EA9C1 File Offset: 0x000E8BC1
26 public void Build(UICurrency.Options _options)
27 {
28 this.options = _options;
29 this.Build();
30 }
31
32 // Token: 0x06002991 RID: 10641 RVA: 0x000EA9D0 File Offset: 0x000E8BD0
33 public void Build()
34 {
35 this.items.Clear();
36 this.mold = this.layout.CreateMold(null);
37 if (this.options.plat)
38 {
39 this.Add(this.icons[1], "plat", () => EMono.pc.GetCurrency("plat").ToString("#,0") ?? "");
40 }
41 if (this.options.money)
42 {
43 this.Add(this.icons[0], "money", () => EMono.pc.GetCurrency("money").ToString("#,0") ?? "");
44 }
45 if (this.options.money2)
46 {
47 this.Add(this.icons[5], "money2", () => EMono.pc.GetCurrency("money2").ToString("#,0") ?? "");
48 }
49 if (this.options.medal)
50 {
51 this.Add(this.icons[4], "medal", () => EMono.pc.GetCurrency("medal").ToString("#,0") ?? "");
52 }
53 if (this.options.ecopo)
54 {
55 this.Add(EMono.sources.cards.map["ecopo"].GetSprite(0, 0, false), "ecopo", () => EMono.pc.GetCurrency("ecopo").ToString("#,0") ?? "");
56 }
57 if (this.options.influence)
58 {
59 this.Add(this.icons[3], "influence", () => EMono._zone.influence.ToString() ?? "");
60 }
61 if (this.options.casino)
62 {
63 this.Add(this.icons[10], "casino_coin", () => EMono.pc.GetCurrency("casino_coin").ToString("#,0") ?? "");
64 }
65 if (this.options.weight)
66 {
67 this.Add(this.icons[11], "weightInv", () => Lang._weight(this.target.ChildrenWeight, false, 0) + " / " + Lang._weight(this.target.WeightLimit, true, 0));
68 }
69 if (EMono.BranchOrHomeBranch != null)
70 {
71 HomeResourceManager resources = EMono.BranchOrHomeBranch.resources;
72 if (this.options.branchMoney)
73 {
74 this.Add(this.icons[5], resources.money.Name, () => resources.money.value.ToString("#,0") ?? "");
75 }
76 if (this.options.branchFood)
77 {
78 this.Add(this.icons[6], resources.food.Name, () => resources.food.value.ToString("#,0") ?? "");
79 }
80 if (this.options.branchKnowledge)
81 {
82 this.Add(this.icons[7], resources.knowledge.Name, () => resources.knowledge.value.ToString("#,0") ?? "");
83 }
84 if (this.options.admin)
85 {
86 this.Add(this.icons[9], "ap", () => EMono.Branch.policies.CurrentAP().ToString() + "/" + EMono.Branch.MaxAP.ToString());
87 }
88 if (this.options.resources)
89 {
90 using (List<BaseHomeResource>.Enumerator enumerator = EMono.BranchOrHomeBranch.resources.list.GetEnumerator())
91 {
92 while (enumerator.MoveNext())
93 {
94 BaseHomeResource r = enumerator.Current;
95 if (r.IsAvailable)
96 {
97 this.Add(r.Sprite, r.Name, () => r.value.ToString("#,0") ?? "");
98 }
99 }
100 }
101 }
102 }
103 this.layout.RebuildLayout(false);
104 }
105
106 // Token: 0x06002992 RID: 10642 RVA: 0x000EADA0 File Offset: 0x000E8FA0
107 public void Add(Sprite icon, string lang, Func<string> func)
108 {
109 UIButton uibutton = Util.Instantiate<UIButton>(this.mold, this.layout);
110 uibutton.icon.sprite = icon;
111 uibutton.icon.SetNativeSize();
112 uibutton.tooltip.lang = lang.lang().ToTitleCase(true);
113 this.items.Add(new UICurrency.Item
114 {
115 func = func,
116 text = uibutton.mainText
117 });
118 uibutton.mainText.SetText(func());
119 uibutton.mainText.RebuildLayout(false);
120 uibutton.RebuildLayout(false);
121 }
122
123 // Token: 0x06002993 RID: 10643 RVA: 0x000EAE34 File Offset: 0x000E9034
124 public void Refresh()
125 {
126 foreach (UICurrency.Item item in this.items)
127 {
128 string text = item.func();
129 if (item.text.text != (text ?? ""))
130 {
131 item.text.SetText(text);
132 item.text.RebuildLayout(false);
133 item.text.transform.parent.RebuildLayout(false);
134 }
135 }
136 }
137
138 // Token: 0x0400176F RID: 5999
139 public List<UICurrency.Item> items = new List<UICurrency.Item>();
140
141 // Token: 0x04001770 RID: 6000
142 public bool autoBuild;
143
144 // Token: 0x04001771 RID: 6001
145 public bool disable;
146
147 // Token: 0x04001772 RID: 6002
148 public UICurrency.Options options;
149
150 // Token: 0x04001773 RID: 6003
151 public Sprite[] icons;
152
153 // Token: 0x04001774 RID: 6004
154 public LayoutGroup layout;
155
156 // Token: 0x04001775 RID: 6005
157 public Card target;
158
159 // Token: 0x04001776 RID: 6006
160 private UIButton mold;
161
162 // Token: 0x02000B4E RID: 2894
163 [Serializable]
164 public class Options
165 {
166 // Token: 0x04002D66 RID: 11622
167 public bool money;
168
169 // Token: 0x04002D67 RID: 11623
170 public bool plat;
171
172 // Token: 0x04002D68 RID: 11624
173 public bool ecopo;
174
175 // Token: 0x04002D69 RID: 11625
176 public bool knowledge;
177
178 // Token: 0x04002D6A RID: 11626
179 public bool influence;
180
181 // Token: 0x04002D6B RID: 11627
182 public bool medal;
183
184 // Token: 0x04002D6C RID: 11628
185 public bool money2;
186
187 // Token: 0x04002D6D RID: 11629
188 public bool resources;
189
190 // Token: 0x04002D6E RID: 11630
191 public bool branchMoney;
192
193 // Token: 0x04002D6F RID: 11631
194 public bool branchFood;
195
196 // Token: 0x04002D70 RID: 11632
197 public bool branchMaterial;
198
199 // Token: 0x04002D71 RID: 11633
200 public bool branchKnowledge;
201
202 // Token: 0x04002D72 RID: 11634
203 public bool admin;
204
205 // Token: 0x04002D73 RID: 11635
206 public bool casino;
207
208 // Token: 0x04002D74 RID: 11636
209 public bool weight;
210 }
211
212 // Token: 0x02000B4F RID: 2895
213 public class Item
214 {
215 // Token: 0x04002D75 RID: 11637
216 public Func<string> func;
217
218 // Token: 0x04002D76 RID: 11638
219 public UIText text;
220 }
221}
Definition Card.cs:13
Definition EMono.cs:6