Elin Modding Docs Doc
Loading...
Searching...
No Matches
ButtonElement.cs
1using System;
2using UnityEngine;
3using UnityEngine.UI;
4
5// Token: 0x020004FF RID: 1279
6public class ButtonElement : UIButton
7{
8 // Token: 0x06002240 RID: 8768 RVA: 0x000BE098 File Offset: 0x000BC298
9 public void SetElement(Element _e, ElementContainer _owner, ButtonElement.Mode _mode = ButtonElement.Mode.Skill)
10 {
11 this.e = _e;
12 this.owner = _owner;
13 this.mode = _mode;
14 this.Refresh();
15 }
16
17 // Token: 0x06002241 RID: 8769 RVA: 0x000BE0B8 File Offset: 0x000BC2B8
18 public void Refresh()
19 {
20 string str = "";
21 if (WindowChara.Instance && WindowChara.Instance.chara == EClass.pc && EClass.player.trackedElements.Contains(this.e.id))
22 {
23 str = "*";
24 }
25 switch (this.mode)
26 {
27 case ButtonElement.Mode.Attribute:
28 this.mainText.SetText(str + this.e.Name, FontColor.Default);
29 this.e.SetTextValue(this.subText);
30 goto IL_507;
31 case ButtonElement.Mode.Tech:
32 {
33 this.mainText.SetText(str + this.e.Name + " " + this.e.DisplayValue.ToString(), FontColor.Default);
34 int techUpgradeCost = EClass.Branch.GetTechUpgradeCost(this.e);
35 int currency = EClass.pc.GetCurrency("money2");
36 if (EClass.Branch.elements.ValueWithoutLink(this.e.id) == 0 || this.e.source.cost[0] == 0 || techUpgradeCost == 0)
37 {
38 this.subText.SetText("-");
39 goto IL_507;
40 }
41 this.subText.SetText(techUpgradeCost.ToString() ?? "", (currency >= techUpgradeCost) ? FontColor.Good : FontColor.Bad);
42 goto IL_507;
43 }
44 case ButtonElement.Mode.Feat:
45 case ButtonElement.Mode.FeatPurchase:
46 case ButtonElement.Mode.FeatMini:
47 if (this.mode == ButtonElement.Mode.FeatPurchase)
48 {
49 this.mainText.SetText(this.e.FullName, FontColor.Default);
50 this.subText.text = this.e.GetDetail().SplitNewline()[0].StripLastPun();
51 this.subText2.text = "".TagColor((EClass.pc.feat >= this.e.CostLearn) ? EClass.Colors.Skin.textGood : EClass.Colors.Skin.textBad, this.e.CostLearn.ToString() ?? "");
52 }
53 else
54 {
55 string str2 = (this.mode == ButtonElement.Mode.FeatMini) ? this.e.FullName : this.e.source.GetText("textPhase", false).SplitNewline().TryGet(this.e.Value - 1, -1).StripLastPun();
56 FontColor c = this.e.HasTag("neg") ? FontColor.Bad : FontColor.ButtonSelectable;
57 if (this.e.source.category == "ether")
58 {
59 c = FontColor.Ether;
60 }
61 this.mainText.SetText(str + str2, c);
62 this.subText.text = ((this.mode == ButtonElement.Mode.FeatMini) ? "" : (this.e as Feat).GetHint(this.owner));
63 }
64 if (this.imagePotential)
65 {
66 this.imagePotential.SetActive(false);
67 goto IL_507;
68 }
69 goto IL_507;
70 case ButtonElement.Mode.Policy:
71 this.mainText.SetText(str + this.e.Name, FontColor.Default);
72 this.e.SetTextValue(this.subText);
73 Mathf.Clamp((float)this.e.Potential / 300f, 0.1f, 1f);
74 if (this.imagePotential)
75 {
76 this.imagePotential.SetActive(false);
77 goto IL_507;
78 }
79 goto IL_507;
80 case ButtonElement.Mode.OnlyValue:
81 this.e.SetTextValue(this.subText);
82 this.imagePotential.SetActive(false);
83 goto IL_507;
84 case ButtonElement.Mode.LandFeat:
85 {
86 string text = str + this.e.Name;
87 if (this.e.HasTag("network") && EClass.Branch != null && EClass.Branch.HasNetwork)
88 {
89 text = "feat_network".lang(text, null, null, null, null);
90 }
91 this.mainText.SetText(text + " " + this.e.Value.ToString(), FontColor.Default);
92 this.subText.horizontalOverflow = HorizontalWrapMode.Overflow;
93 this.subText.text = this.e.GetDetail().SplitNewline()[0].StripLastPun();
94 if (this.imagePotential)
95 {
96 this.imagePotential.SetActive(false);
97 goto IL_507;
98 }
99 goto IL_507;
100 }
101 }
102 this.mainText.SetText(str + this.e.Name, (this.e.owner != null && this.e.IsFactionElement(this.e.owner.Card as Chara)) ? FontColor.Myth : FontColor.Default);
103 this.e.SetTextValue(this.subText);
104 bool enable = this.e.source.category == "skill";
105 if (this.imagePotential)
106 {
107 this.imagePotential.SetActive(enable);
108 }
109 IL_507:
110 if (this.imagePotential)
111 {
112 int num = (this.e.Potential - 80) / 20;
113 this.imagePotential.enabled = (this.e.Potential != 80);
114 this.imagePotential.sprite = EClass.core.refs.spritesPotential[Mathf.Clamp(Mathf.Abs(num), 0, EClass.core.refs.spritesPotential.Count - 1)];
115 this.imagePotential.color = ((num >= 0) ? Color.white : new Color(1f, 0.7f, 0.7f));
116 }
117 this.e.SetImage(this.icon);
118 if (this.mode == ButtonElement.Mode.FeatPurchase && this.e.Value > 1)
119 {
120 Element refEle = Element.Create(this.e.id, this.e.Value - 1);
121 base.SetTooltip("note", delegate(UITooltip tt)
122 {
123 this.e.WriteNoteWithRef(tt.note, this.owner, null, refEle);
124 }, true);
125 return;
126 }
127 base.SetTooltip("note", delegate(UITooltip tt)
128 {
129 this.e.WriteNote(tt.note, this.owner, null);
130 }, true);
131 }
132
133 // Token: 0x06002242 RID: 8770 RVA: 0x000BE708 File Offset: 0x000BC908
134 public void SetGrid(Element e, Chara c)
135 {
136 bool flag = false;
137 string text;
138 foreach (BodySlot bodySlot in c.body.slots)
139 {
140 if (bodySlot.elementId != 44)
141 {
142 UIItem uiitem = Util.Instantiate<UIItem>(this.moldItemResist, this.layout);
143 Thing thing = bodySlot.thing;
144 if (thing == null)
145 {
146 uiitem.text1.SetActive(false);
147 uiitem.image1.color = Color.white.SetAlpha(0.5f);
148 }
149 else if (!thing.IsIdentified)
150 {
151 flag = true;
152 uiitem.text1.SetText("?", FontColor.Passive);
153 uiitem.image1.color = Color.white.SetAlpha(0.5f);
154 }
155 else
156 {
157 Element element = bodySlot.thing.elements.GetElement(e.id);
158 int num = 0;
159 if (element != null)
160 {
161 num = element.Value;
162 if (!element.CanLink(thing.elements) || element.IsGlobalElement)
163 {
164 num = 0;
165 }
166 }
167 if (num == 0)
168 {
169 uiitem.text1.SetActive(false);
170 uiitem.image1.color = Color.white.SetAlpha(0.5f);
171 }
172 text = (e.IsFlag ? "✓" : (Mathf.Abs(num).ToString() ?? ""));
173 uiitem.text1.SetText(text, (num >= 0) ? FontColor.Good : FontColor.Bad);
174 }
175 }
176 }
177 text = "";
178 int value = e.Value;
179 int num2 = value;
180 if (e is Resistance)
181 {
182 num2 = Element.GetResistLv(value);
183 if (num2 > 0)
184 {
185 text = Lang.GetList("resist")[Mathf.Min(num2, 5)];
186 }
187 else
188 {
189 text = Lang.GetList("resistNeg")[-num2];
190 }
191 }
192 text = text + " (" + (flag ? "?" : (e.IsFlag ? "✓" : (value.ToString() ?? ""))) + ")";
193 Sprite icon = e.GetIcon("");
194 if (icon != null && this.icon)
195 {
196 this.icon.sprite = icon;
197 }
198 this.mainText.SetText(e.ShortName, e.IsFactionElement(c) ? FontColor.Myth : FontColor.Default);
199 this.subText.SetText(text, (num2 == 0) ? FontColor.Default : ((num2 > 0) ? FontColor.Good : FontColor.Bad));
200 base.SetTooltip("note", delegate(UITooltip tt)
201 {
202 e.WriteNote(tt.note, c.elements, null);
203 }, true);
204 }
205
206 // Token: 0x040011C2 RID: 4546
207 public Image imagePotential;
208
209 // Token: 0x040011C3 RID: 4547
210 public GameObject goExp;
211
212 // Token: 0x040011C4 RID: 4548
213 public Element e;
214
215 // Token: 0x040011C5 RID: 4549
216 public ElementContainer owner;
217
218 // Token: 0x040011C6 RID: 4550
219 public UIButton buttonUpgrade;
220
221 // Token: 0x040011C7 RID: 4551
222 public UIItem moldItemResist;
223
224 // Token: 0x040011C8 RID: 4552
225 public LayoutGroup layout;
226
227 // Token: 0x040011C9 RID: 4553
228 public ButtonElement.Mode mode;
229
230 // Token: 0x02000A08 RID: 2568
231 public enum Mode
232 {
233 // Token: 0x04002965 RID: 10597
234 Skill,
235 // Token: 0x04002966 RID: 10598
236 Attribute,
237 // Token: 0x04002967 RID: 10599
238 Tech,
239 // Token: 0x04002968 RID: 10600
240 Feat,
241 // Token: 0x04002969 RID: 10601
242 Enchant,
243 // Token: 0x0400296A RID: 10602
244 Policy,
245 // Token: 0x0400296B RID: 10603
246 OnlyValue,
247 // Token: 0x0400296C RID: 10604
248 FeatPurchase,
249 // Token: 0x0400296D RID: 10605
250 LandFeat,
251 // Token: 0x0400296E RID: 10606
252 FeatMini
253 }
254}
Definition Chara.cs:12
Definition Feat.2.cs:8
Definition Thing.cs:10