16 return this.uiInventory.owner.Container;
26 return this.container.things.GridSize;
33 UIButton t = this.layoutPage.CreateMold(
null);
34 this.moldCat = this.layoutCat.CreateMold(
null);
35 for (
int i = 0; i < 9; i++)
37 UIButton b = Util.Instantiate<UIButton>(t, this.layoutPage);
38 b.mainText.text = ((i + 1).ToString() ??
"");
39 this.buttonsPage.Add(b);
44 this.groupPage.Select(b,
true);
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));
53 this.itemNum.RebuildLayout(
false);
54 this.itemElec.RebuildLayout(
false);
55 this.layoutBottom.RebuildLayout(
false);
59 public void OnAfterRedraw()
62 for (
int i = 0; i < this.buttonsPage.Count; i++)
64 this.buttonsPage[i].interactable = (i <= this.pageMax);
66 this.groupPage.selected =
null;
67 this.groupPage.Select(this.page);
71 public void RefreshCats()
73 foreach (
string text
in this.cats)
75 if (!this.catButton.ContainsKey(text))
77 UIButton uibutton = Util.Instantiate<UIButton>(this.moldCat, this.layoutCat);
78 this.catButton[text] = uibutton;
80 uibutton.SetOnClick(delegate
95 foreach (KeyValuePair<string, UIButton> keyValuePair
in this.catButton)
97 bool flag = this.cats.Contains(keyValuePair.Key);
98 UIButton value = keyValuePair.Value;
99 value.SetActive(flag);
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);
109 public void RefreshBottom()
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);
116 private void LateUpdate()
118 if (this.timerSearch > 0f)
120 this.timerSearch -= Core.delta;
121 if (this.timerSearch <= 0f)
123 this.Search(this.inputSearch.text);
126 if (EInput.wheel != 0)
129 this.page -= EInput.wheel;
132 this.page = this.pageMax;
134 if (this.page > this.pageMax)
143 public void Search(
string s)
150 this.buttonClearSearch.SetActive(this.inputSearch.text !=
"");
151 if (s == this.lastSearch)
155 if (this.firstSearch)
157 this.firstSearch =
false;
158 foreach (
Thing thing
in this.container.things)
160 thing.tempName = thing.GetName(NameStyle.Full, 1).ToLower();
163 this.timerSearch = this.intervalSearch;
169 public void ClearSearch()
171 this.inputSearch.text =
"";
172 this.timerSearch = 0f;
173 this.lastSearch =
"";
180 this.uiInventory.list.Redraw();
184 public LayoutGroup layoutPage;
187 public LayoutGroup layoutCat;
190 public LayoutGroup layoutBottom;
193 public UIButton itemNum;
196 public UIButton itemElec;
199 public UIButton buttonClearSearch;
202 public UIButton moldCat;
205 public UISelectableGroup groupPage;
208 public List<UIButton> buttonsPage;
214 public InputField inputSearch;
217 public float intervalSearch;
226 public List<Thing> filteredList =
new List<Thing>();
229 public Color colorCat;
232 public Color colorCatSelected;
235 public HashSet<string> cats =
new HashSet<string>();
238 public Dictionary<string, UIButton> catButton =
new Dictionary<string, UIButton>();
241 public Dictionary<string, int> catCount =
new Dictionary<string, int>();
244 public string idCat =
"";
247 private bool firstSearch =
true;
250 private float timerSearch;
253 public string lastSearch =
"";
256 public HashSet<Recipe> searchRecipes =
new HashSet<Recipe>();