Elin Modding Docs Doc
Loading...
Searching...
No Matches
UIMagicChest.cs
1using System;
2using System.Collections.Generic;
3using UnityEngine;
4using UnityEngine.Events;
5using UnityEngine.UI;
6
7// Token: 0x0200057F RID: 1407
8public class UIMagicChest : EMono
9{
10 // Token: 0x17000B97 RID: 2967
11 // (get) Token: 0x060026BD RID: 9917 RVA: 0x000DB993 File Offset: 0x000D9B93
12 public Card container
13 {
14 get
15 {
16 return this.uiInventory.owner.Container;
17 }
18 }
19
20 // Token: 0x17000B98 RID: 2968
21 // (get) Token: 0x060026BE RID: 9918 RVA: 0x000DB9A5 File Offset: 0x000D9BA5
22 public int GridSize
23 {
24 get
25 {
26 return this.container.things.GridSize;
27 }
28 }
29
30 // Token: 0x060026BF RID: 9919 RVA: 0x000DB9B8 File Offset: 0x000D9BB8
31 public void Init()
32 {
33 UIButton t = this.layoutPage.CreateMold(null);
34 this.moldCat = this.layoutCat.CreateMold(null);
35 for (int i = 0; i < 9; i++)
36 {
37 UIButton b = Util.Instantiate<UIButton>(t, this.layoutPage);
38 b.mainText.text = ((i + 1).ToString() ?? "");
39 this.buttonsPage.Add(b);
40 int _i = i;
41 b.SetOnClick(delegate
42 {
43 this.page = _i;
44 this.groupPage.Select(b, true);
45 SE.Tab();
46 this.Redraw();
47 });
48 }
49 this.groupPage.Init(0, null, false);
50 this.inputSearch.onValueChanged.AddListener(new UnityAction<string>(this.Search));
51 this.inputSearch.onSubmit.AddListener(new UnityAction<string>(this.Search));
52 this.RefreshBottom();
53 this.itemNum.RebuildLayout(false);
54 this.itemElec.RebuildLayout(false);
55 this.layoutBottom.RebuildLayout(false);
56 }
57
58 // Token: 0x060026C0 RID: 9920 RVA: 0x000DBAD4 File Offset: 0x000D9CD4
59 public void OnAfterRedraw()
60 {
61 this.RefreshBottom();
62 for (int i = 0; i < this.buttonsPage.Count; i++)
63 {
64 this.buttonsPage[i].interactable = (i <= this.pageMax);
65 }
66 this.groupPage.selected = null;
67 this.groupPage.Select(this.page);
68 }
69
70 // Token: 0x060026C1 RID: 9921 RVA: 0x000DBB38 File Offset: 0x000D9D38
71 public void RefreshCats()
72 {
73 foreach (string text in this.cats)
74 {
75 if (!this.catButton.ContainsKey(text))
76 {
77 UIButton uibutton = Util.Instantiate<UIButton>(this.moldCat, this.layoutCat);
78 this.catButton[text] = uibutton;
79 string _c = text;
80 uibutton.SetOnClick(delegate
81 {
82 SE.Tab();
83 if (this.idCat == _c)
84 {
85 this.idCat = "";
86 }
87 else
88 {
89 this.idCat = _c;
90 }
91 this.Redraw();
92 });
93 }
94 }
95 foreach (KeyValuePair<string, UIButton> keyValuePair in this.catButton)
96 {
97 bool flag = this.cats.Contains(keyValuePair.Key);
98 UIButton value = keyValuePair.Value;
99 value.SetActive(flag);
100 if (flag)
101 {
102 value.mainText.text = EMono.sources.categories.map[keyValuePair.Key].GetName() + " (" + this.catCount[keyValuePair.Key].ToString() + ")";
103 value.image.color = ((keyValuePair.Key == this.idCat) ? this.colorCatSelected : this.colorCat);
104 }
105 }
106 }
107
108 // Token: 0x060026C2 RID: 9922 RVA: 0x000DBCCC File Offset: 0x000D9ECC
109 public void RefreshBottom()
110 {
111 this.itemNum.mainText.text = this.container.things.Count.ToString() + " / " + this.container.things.MaxCapacity.ToString();
112 this.itemElec.mainText.SetText(Mathf.Abs(this.container.trait.Electricity).ToString() + " " + "mw".lang(), (this.container.trait.Electricity == 0 || this.container.isOn) ? FontColor.Good : FontColor.Bad);
113 }
114
115 // Token: 0x060026C3 RID: 9923 RVA: 0x000DBD88 File Offset: 0x000D9F88
116 private void LateUpdate()
117 {
118 if (this.timerSearch > 0f)
119 {
120 this.timerSearch -= Core.delta;
121 if (this.timerSearch <= 0f)
122 {
123 this.Search(this.inputSearch.text);
124 }
125 }
126 if (EInput.wheel != 0)
127 {
128 SE.Tab();
129 this.page -= EInput.wheel;
130 if (this.page < 0)
131 {
132 this.page = this.pageMax;
133 }
134 if (this.page > this.pageMax)
135 {
136 this.page = 0;
137 }
138 this.Redraw();
139 }
140 }
141
142 // Token: 0x060026C4 RID: 9924 RVA: 0x000DBE20 File Offset: 0x000DA020
143 public void Search(string s)
144 {
145 s = s.ToLower();
146 if (s.IsEmpty())
147 {
148 s = "";
149 }
150 this.buttonClearSearch.SetActive(this.inputSearch.text != "");
151 if (s == this.lastSearch)
152 {
153 return;
154 }
155 if (this.firstSearch)
156 {
157 this.firstSearch = false;
158 foreach (Thing thing in this.container.things)
159 {
160 thing.tempName = thing.GetName(NameStyle.Full, 1).ToLower();
161 }
162 }
163 this.timerSearch = this.intervalSearch;
164 this.lastSearch = s;
165 this.Redraw();
166 }
167
168 // Token: 0x060026C5 RID: 9925 RVA: 0x000DBEF0 File Offset: 0x000DA0F0
169 public void ClearSearch()
170 {
171 this.inputSearch.text = "";
172 this.timerSearch = 0f;
173 this.lastSearch = "";
174 this.Redraw();
175 }
176
177 // Token: 0x060026C6 RID: 9926 RVA: 0x000DBF1E File Offset: 0x000DA11E
178 public void Redraw()
179 {
180 this.uiInventory.list.Redraw();
181 }
182
183 // Token: 0x0400154A RID: 5450
184 public LayoutGroup layoutPage;
185
186 // Token: 0x0400154B RID: 5451
187 public LayoutGroup layoutCat;
188
189 // Token: 0x0400154C RID: 5452
190 public LayoutGroup layoutBottom;
191
192 // Token: 0x0400154D RID: 5453
193 public UIButton itemNum;
194
195 // Token: 0x0400154E RID: 5454
196 public UIButton itemElec;
197
198 // Token: 0x0400154F RID: 5455
199 public UIButton buttonClearSearch;
200
201 // Token: 0x04001550 RID: 5456
202 public UIButton moldCat;
203
204 // Token: 0x04001551 RID: 5457
205 public UISelectableGroup groupPage;
206
207 // Token: 0x04001552 RID: 5458
208 public List<UIButton> buttonsPage;
209
210 // Token: 0x04001553 RID: 5459
211 public UIInventory uiInventory;
212
213 // Token: 0x04001554 RID: 5460
214 public InputField inputSearch;
215
216 // Token: 0x04001555 RID: 5461
217 public float intervalSearch;
218
219 // Token: 0x04001556 RID: 5462
220 public int page;
221
222 // Token: 0x04001557 RID: 5463
223 public int pageMax;
224
225 // Token: 0x04001558 RID: 5464
226 public List<Thing> filteredList = new List<Thing>();
227
228 // Token: 0x04001559 RID: 5465
229 public Color colorCat;
230
231 // Token: 0x0400155A RID: 5466
232 public Color colorCatSelected;
233
234 // Token: 0x0400155B RID: 5467
235 public HashSet<string> cats = new HashSet<string>();
236
237 // Token: 0x0400155C RID: 5468
238 public Dictionary<string, UIButton> catButton = new Dictionary<string, UIButton>();
239
240 // Token: 0x0400155D RID: 5469
241 public Dictionary<string, int> catCount = new Dictionary<string, int>();
242
243 // Token: 0x0400155E RID: 5470
244 public string idCat = "";
245
246 // Token: 0x0400155F RID: 5471
247 private bool firstSearch = true;
248
249 // Token: 0x04001560 RID: 5472
250 private float timerSearch;
251
252 // Token: 0x04001561 RID: 5473
253 public string lastSearch = "";
254
255 // Token: 0x04001562 RID: 5474
256 public HashSet<Recipe> searchRecipes = new HashSet<Recipe>();
257}
Definition Card.cs:13
Definition EMono.cs:6
Definition Thing.cs:10