Elin Modding Docs Doc
Loading...
Searching...
No Matches
ItemGeneral.cs
1using System;
2using UnityEngine;
3using UnityEngine.UI;
4
5// Token: 0x02000510 RID: 1296
6public class ItemGeneral : UIItem, IPrefImage
7{
8 // Token: 0x060022B9 RID: 8889 RVA: 0x000C195C File Offset: 0x000BFB5C
9 public void SetChara(Chara c)
10 {
11 this.card = c;
12 c.SetImage(this.button1.icon);
13 string text = c.Name;
14 FactionBranch branch = EClass.Branch;
15 int? num = (branch != null) ? new int?(branch.uidMaid) : null;
16 int uid = c.uid;
17 if (num.GetValueOrDefault() == uid & num != null)
18 {
19 text += ("(" + "maid".lang() + ")").TagSize(12);
20 }
21 this.button1.mainText.SetText(text, c.isDead ? FontColor.Bad : ((c.hp < c.MaxHP / 2) ? FontColor.Warning : FontColor.ButtonGeneral));
22 RectTransform rectTransform = this.button1.icon.rectTransform;
23 }
24
25 // Token: 0x060022BA RID: 8890 RVA: 0x000C1A2C File Offset: 0x000BFC2C
26 public RenderRow GetRenderRow()
27 {
28 Card card = this.card;
29 if (card == null)
30 {
31 return null;
32 }
33 return card.sourceRenderCard;
34 }
35
36 // Token: 0x060022BB RID: 8891 RVA: 0x000C1A3F File Offset: 0x000BFC3F
37 public void OnRefreshPref()
38 {
39 if (this.card != null && this.card.isChara)
40 {
41 this.SetChara(this.card.Chara);
42 }
43 }
44
45 // Token: 0x060022BC RID: 8892 RVA: 0x000C1A68 File Offset: 0x000BFC68
46 public void Clear()
47 {
48 if (this.count > 0)
49 {
50 foreach (UIButton uibutton in base.transform.GetComponentsInDirectChildren(true))
51 {
52 if (uibutton != this.button1)
53 {
54 UnityEngine.Object.DestroyImmediate(uibutton.gameObject);
55 }
56 }
57 this.count = 0;
58 }
59 }
60
61 // Token: 0x060022BD RID: 8893 RVA: 0x000C1AE4 File Offset: 0x000BFCE4
62 public UIButton AddSubButton(Sprite sprite, Action action, string lang = null, Action<UITooltip> onTooltip = null)
63 {
64 UIButton uibutton = Util.Instantiate<UIButton>("UI/Element/Button/SubButton", base.transform);
65 uibutton.Rect().anchoredPosition = new Vector2((float)(this.count * -40 - 20 - 10), 0f);
66 uibutton.icon.sprite = sprite;
67 uibutton.onClick.AddListener(delegate()
68 {
69 action();
70 });
71 if (!lang.IsEmpty())
72 {
73 uibutton.tooltip.enable = true;
74 uibutton.tooltip.lang = lang;
75 }
76 if (onTooltip != null)
77 {
78 uibutton.tooltip.id = "note";
79 uibutton.tooltip.onShowTooltip = onTooltip;
80 uibutton.tooltip.enable = true;
81 }
82 uibutton.highlightTarget = this.button1;
83 this.count++;
84 return uibutton;
85 }
86
87 // Token: 0x060022BE RID: 8894 RVA: 0x000C1BC0 File Offset: 0x000BFDC0
88 public void SetMainText(string lang, Sprite sprite = null, bool disableMask = true)
89 {
90 this.button1.mainText.SetText(lang.lang());
91 if (sprite)
92 {
93 this.button1.icon.sprite = sprite;
94 this.button1.icon.SetNativeSize();
95 if (disableMask)
96 {
97 this.DisableMask();
98 return;
99 }
100 }
101 else
102 {
103 this.DisableIcon();
104 }
105 }
106
107 // Token: 0x060022BF RID: 8895 RVA: 0x000C1C1C File Offset: 0x000BFE1C
108 public UIButton SetSubText(string lang, int x, FontColor c = FontColor.Default, TextAnchor align = TextAnchor.MiddleLeft)
109 {
110 this.button1.subText.SetActive(true);
111 this.button1.subText.SetText(lang.lang(), c);
112 this.button1.subText.alignment = align;
113 this.button1.mainText.rectTransform.sizeDelta = new Vector2((float)(x - this.paddingSubText), 20f);
114 this.button1.subText.rectTransform.anchoredPosition = new Vector2((float)x, 0f);
115 return this.button1;
116 }
117
118 // Token: 0x060022C0 RID: 8896 RVA: 0x000C1CB4 File Offset: 0x000BFEB4
119 public UIButton SetSubText2(string lang, FontColor c = FontColor.Default, TextAnchor align = TextAnchor.MiddleRight)
120 {
121 this.button1.subText2.SetActive(true);
122 this.button1.subText2.SetText(lang.lang(), c);
123 this.button1.subText2.alignment = align;
124 return this.button1;
125 }
126
127 // Token: 0x060022C1 RID: 8897 RVA: 0x000C1D00 File Offset: 0x000BFF00
128 public T AddPrefab<T>(string id) where T : Component
129 {
130 return Util.Instantiate<T>("UI/Element/Item/Extra/" + id, base.transform);
131 }
132
133 // Token: 0x060022C2 RID: 8898 RVA: 0x000C1D18 File Offset: 0x000BFF18
134 public void SetSound(SoundData data = null)
135 {
136 this.button1.soundClick = (data ?? SE.DataClick);
137 }
138
139 // Token: 0x060022C3 RID: 8899 RVA: 0x000C1D30 File Offset: 0x000BFF30
140 public void DisableIcon()
141 {
142 this.button1.icon.transform.parent.SetActive(false);
143 if (this.button1.keyText)
144 {
145 return;
146 }
147 this.button1.mainText.rectTransform.anchoredPosition = new Vector2(20f, 0f);
148 }
149
150 // Token: 0x060022C4 RID: 8900 RVA: 0x000C1D8F File Offset: 0x000BFF8F
151 public void DisableMask()
152 {
153 this.image2.enabled = false;
154 }
155
156 // Token: 0x060022C5 RID: 8901 RVA: 0x000C1DA0 File Offset: 0x000BFFA0
157 public void Build()
158 {
159 RectTransform rectTransform = this.button1.Rect();
160 if (this.count > 0)
161 {
162 rectTransform.sizeDelta = new Vector2((float)(this.count * -40 - 10 - 3), 0f);
163 }
164 }
165
166 // Token: 0x0400120C RID: 4620
167 private const int IconSize = 40;
168
169 // Token: 0x0400120D RID: 4621
170 private const int IconPadding = 10;
171
172 // Token: 0x0400120E RID: 4622
173 private const int ButtonPaddingWhenIcon = 3;
174
175 // Token: 0x0400120F RID: 4623
176 public LayoutGroup layout;
177
178 // Token: 0x04001210 RID: 4624
179 public int paddingSubText = 50;
180
181 // Token: 0x04001211 RID: 4625
182 public Card card;
183
184 // Token: 0x04001212 RID: 4626
185 private int count;
186}
Definition Card.cs:13
Definition Chara.cs:12