Elin Modding Docs Doc
Loading...
Searching...
No Matches
WidgetCodex.cs
1using System;
2using System.Collections.Generic;
3using UnityEngine;
4using UnityEngine.Events;
5using UnityEngine.UI;
6
7// Token: 0x020005F7 RID: 1527
8public class WidgetCodex : Widget
9{
10 // Token: 0x17000C1C RID: 3100
11 // (get) Token: 0x06002A2D RID: 10797 RVA: 0x000ED517 File Offset: 0x000EB717
12 public virtual WidgetCodex.SearchType type
13 {
14 get
15 {
16 return WidgetCodex.SearchType.Codex;
17 }
18 }
19
20 // Token: 0x06002A2E RID: 10798 RVA: 0x000ED51C File Offset: 0x000EB71C
21 public override void OnActivate()
22 {
23 this.field.onValueChanged.AddListener(new UnityAction<string>(this.Search));
24 this.field.onSubmit.AddListener(new UnityAction<string>(this.Search));
25 this.lastSearch = null;
26 this.Search("");
27 if (EMono._zone.isStarted)
28 {
29 this.field.Select();
30 }
31 }
32
33 // Token: 0x06002A2F RID: 10799 RVA: 0x000ED58C File Offset: 0x000EB78C
34 public void Clear()
35 {
36 this.field.text = "";
37 }
38
39 // Token: 0x06002A30 RID: 10800 RVA: 0x000ED5A0 File Offset: 0x000EB7A0
40 public virtual void Search(string s)
41 {
42 s = s.ToLower();
43 this.buttonClear.SetActive(this.field.text != "");
44 if (s == this.lastSearch)
45 {
46 return;
47 }
48 RecipeManager.BuildList();
49 HashSet<Recipe> hashSet = new HashSet<Recipe>();
50 if (!s.IsEmpty())
51 {
52 using (List<RecipeSource>.Enumerator enumerator = RecipeManager.list.GetEnumerator())
53 {
54 while (enumerator.MoveNext())
55 {
56 RecipeSource recipeSource = enumerator.Current;
57 if (!recipeSource.isChara && !recipeSource.noListing && !recipeSource.isBridgePillar && (recipeSource.row.GetSearchName(false).Contains(s) || recipeSource.row.GetSearchName(true).Contains(s)) && (EMono.player.recipes.knownRecipes.ContainsKey(recipeSource.id) || recipeSource.alwaysKnown))
58 {
59 hashSet.Add(Recipe.Create(recipeSource, -1, null));
60 }
61 }
62 goto IL_16D;
63 }
64 }
65 foreach (RecipeSource recipeSource2 in RecipeManager.list)
66 {
67 if (!recipeSource2.isChara && !recipeSource2.noListing && !recipeSource2.isBridgePillar && (EMono.player.recipes.knownRecipes.ContainsKey(recipeSource2.id) || recipeSource2.alwaysKnown))
68 {
69 hashSet.Add(Recipe.Create(recipeSource2, -1, null));
70 }
71 }
72 IL_16D:
73 if (!hashSet.SetEquals(this.recipes))
74 {
75 this.recipes = hashSet;
76 this.RefreshList();
77 }
78 this.lastSearch = s;
79 }
80
81 // Token: 0x06002A31 RID: 10801 RVA: 0x000ED758 File Offset: 0x000EB958
82 public virtual void RefreshList()
83 {
84 BaseList baseList = this.list;
85 UIList.Callback<Recipe, ButtonGrid> callback = new UIList.Callback<Recipe, ButtonGrid>();
86 callback.onClick = delegate(Recipe a, ButtonGrid b)
87 {
88 };
89 callback.onRedraw = delegate(Recipe a, ButtonGrid b, int i)
90 {
91 b.SetCraftRecipe(a, ButtonGrid.Mode.RecipeGrid, true);
92 };
93 callback.onList = delegate(UIList.SortMode m)
94 {
95 foreach (Recipe o in this.recipes)
96 {
97 this.list.Add(o);
98 }
99 };
100 baseList.callbacks = callback;
101 this.list.List();
102 this.list.dsv.OnResize();
103 }
104
105 // Token: 0x06002A32 RID: 10802 RVA: 0x000ED7EC File Offset: 0x000EB9EC
106 private void Update()
107 {
108 this.count++;
109 if (Input.GetKeyDown(KeyCode.Escape))
110 {
111 base.Close();
112 EInput.Consume(false, 5);
113 return;
114 }
115 int functionkeyDown = EInput.GetFunctionkeyDown();
116 if (this.count > 10 && functionkeyDown != -1)
117 {
118 WidgetHotbar hotbarExtra = WidgetHotbar.HotbarExtra;
119 if (hotbarExtra)
120 {
121 HotItemWidget hotItemWidget = hotbarExtra.GetItem(functionkeyDown) as HotItemWidget;
122 if (hotItemWidget != null && hotItemWidget.id == base.ID)
123 {
124 base.Close();
125 EInput.Consume(false, 5);
126 return;
127 }
128 }
129 }
130 if (this.CheckClose())
131 {
132 base.Close();
133 EInput.Consume(false, 1);
134 }
135 }
136
137 // Token: 0x06002A33 RID: 10803 RVA: 0x000ED886 File Offset: 0x000EBA86
138 public virtual bool CheckClose()
139 {
140 return false;
141 }
142
143 // Token: 0x040017C6 RID: 6086
144 public InputField field;
145
146 // Token: 0x040017C7 RID: 6087
147 public WordSearch search = new WordSearch();
148
149 // Token: 0x040017C8 RID: 6088
150 public UIDynamicList list;
151
152 // Token: 0x040017C9 RID: 6089
153 public HashSet<Recipe> recipes = new HashSet<Recipe>();
154
155 // Token: 0x040017CA RID: 6090
156 public string lastSearch;
157
158 // Token: 0x040017CB RID: 6091
159 public UIButton buttonClear;
160
161 // Token: 0x040017CC RID: 6092
162 public Transform transResult;
163
164 // Token: 0x040017CD RID: 6093
165 private int count;
166
167 // Token: 0x02000B65 RID: 2917
168 public enum SearchType
169 {
170 // Token: 0x04002DC7 RID: 11719
171 Codex,
172 // Token: 0x04002DC8 RID: 11720
173 Search
174 }
175}
Definition EMono.cs:6