Elin Decompiled Documentation EA 23.356.1 Nightly
Loading...
Searching...
No Matches
DropdownGrid Class Reference
Inheritance diagram for DropdownGrid:
EMono

Public Member Functions

void Build (List< GridItem > items)
 
List< Thing > ListIngredients (Recipe.Ingredient ingredient, StockSearchMode searchMode)
 
void BuildIngredients (Recipe _recipe, Image _icon, Action _onValueChange, StockSearchMode _searchMode)
 
void Redraw ()
 
void Activate (Recipe.Ingredient ingredient, List< Thing > things)
 
void OnChangeIngredient ()
 
void Deactivate ()
 
void OnDestroy ()
 
void TrySelect (int a)
 
void Next ()
 
void Prev ()
 

Public Attributes

UIList list
 
UIList listDrop
 
RectTransform rectDrop
 
RectTransform rectDropContent
 
RectTransform pivot
 
Recipe recipe
 
Image icon
 
SoundData soundPop
 
Action onValueChange
 
int slots = 4
 
Vector3 fixPos
 
StockSearchMode searchMode
 
UIRecipeInfo recipeInfo
 
Dictionary< string, int > lastMats = new Dictionary<string, int>()
 

Static Public Attributes

static bool IsActive
 
static DropdownGrid Instance
 
- Static Public Attributes inherited from EMono
static Core core
 

Private Member Functions

void Awake ()
 
void Update ()
 

Additional Inherited Members

- Static Public Member Functions inherited from EMono
static int rnd (int a)
 
- Properties inherited from EMono
static Game game [get]
 
static bool AdvMode [get]
 
static Player player [get]
 
static Chara pc [get]
 
static UI ui [get]
 
static Map _map [get]
 
static Zone _zone [get]
 
static FactionBranch Branch [get]
 
static FactionBranch BranchOrHomeBranch [get]
 
static Faction Home [get]
 
static Scene scene [get]
 
static BaseGameScreen screen [get]
 
static GameSetting setting [get]
 
static GameData gamedata [get]
 
static ColorProfile Colors [get]
 
static World world [get]
 
static SoundManager Sound [get]
 
static SourceManager sources [get]
 
static SourceManager editorSources [get]
 
static CoreDebug debug [get]
 

Detailed Description

Definition at line 6 of file DropdownGrid.cs.

Member Function Documentation

◆ Activate()

void DropdownGrid.Activate ( Recipe::Ingredient  ingredient,
List< Thing >  things 
)
inline

Definition at line 267 of file DropdownGrid.cs.

268 {
269 IsActive = true;
270 Instance = this;
271 rectDrop.SetActive(enable: true);
272 rectDrop.SetParent(EMono.ui.transform);
273 rectDrop.sizeDelta = new Vector2(0f, 0f);
274 rectDrop.anchoredPosition = Vector3.zero;
275 listDrop.callbacks = new UIList.Callback<Thing, ButtonGrid>
276 {
277 onClick = delegate(Thing a, ButtonGrid b)
278 {
279 SE.Resource();
280 ingredient.SetThing(a);
283 if (onValueChange != null)
284 {
286 }
287 Deactivate();
288 if ((bool)LayerCraft.Instance)
289 {
291 }
292 },
293 onInstantiate = delegate(Thing a, ButtonGrid b)
294 {
295 b.SetIngredient(recipe, a);
296 b.SetOnClick(delegate
297 {
298 });
299 b.onRightClick = delegate
300 {
301 };
302 }
303 };
304 listDrop.Clear();
305 foreach (Thing thing in things)
306 {
307 listDrop.Add(thing);
308 }
310 rectDropContent.position = list.transform.position + fixPos;
311 if (listDrop.items.Count == 0)
312 {
313 SE.Beep();
314 Deactivate();
315 }
316 else if ((bool)soundPop)
317 {
318 soundPop.Play();
319 }
320 }
void SetIngredient(Recipe r, Recipe.Ingredient _ing)
Definition: ButtonGrid.cs:442
Action onValueChange
Definition: DropdownGrid.cs:28
Recipe recipe
Definition: DropdownGrid.cs:22
void OnChangeIngredient()
RectTransform rectDrop
Definition: DropdownGrid.cs:16
Vector3 fixPos
Definition: DropdownGrid.cs:32
SoundData soundPop
Definition: DropdownGrid.cs:26
static bool IsActive
Definition: DropdownGrid.cs:8
static DropdownGrid Instance
Definition: DropdownGrid.cs:10
void Deactivate()
UIList listDrop
Definition: DropdownGrid.cs:14
Definition: EMono.cs:4
static UI ui
Definition: EMono.cs:15
void OnChangeIngredient()
Definition: LayerCraft.cs:406
static LayerCraft Instance
Definition: LayerCraft.cs:8
void SetThing(Thing t=null)
Definition: Recipe.cs:98
void SaveLastIngredients()
Definition: Recipe.cs:1027
Definition: Thing.cs:8
Definition: UIList.cs:9
List< object > items
Definition: UIList.cs:273
override void Clear()
Definition: UIList.cs:404
override void Add(object item)
Definition: UIList.cs:357
virtual void Refresh(bool highlightLast=false)
Definition: UIList.cs:479

References UIList.Add(), UIList.Clear(), Deactivate(), fixPos, Instance, LayerCraft.Instance, IsActive, UIList.items, listDrop, OnChangeIngredient(), LayerCraft.OnChangeIngredient(), onValueChange, recipe, rectDrop, UIList.Refresh(), Recipe.SaveLastIngredients(), ButtonGrid.SetIngredient(), soundPop, and EMono.ui.

Referenced by BuildIngredients().

◆ Awake()

void DropdownGrid.Awake ( )
inlineprivate

Definition at line 41 of file DropdownGrid.cs.

42 {
43 rectDrop.SetActive(enable: false);
44 }

References rectDrop.

◆ Build()

void DropdownGrid.Build ( List< GridItem >  items)
inline

Definition at line 51 of file DropdownGrid.cs.

52 {
53 list.Clear();
54 list.callbacks = new UIList.Callback<GridItem, ButtonGrid>
55 {
56 onInstantiate = delegate(GridItem a, ButtonGrid b)
57 {
58 a.SetButton(b);
59 },
60 onClick = delegate(GridItem a, ButtonGrid b)
61 {
62 a.OnClick(b);
63 },
64 onRedraw = delegate(GridItem a, ButtonGrid b, int i)
65 {
66 a.SetButton(b);
67 }
68 };
69 for (int num = 0; num < slots; num++)
70 {
71 if (num < items.Count)
72 {
73 list.Add(items[num]);
74 }
75 else
76 {
77 list.Add(new GridItem());
78 }
79 }
80 list.Refresh();
81 }
virtual void SetButton(ButtonGrid b)
Definition: GridItem.cs:3
virtual void OnClick(ButtonGrid b)
Definition: GridItem.cs:8

References UIList.Add(), UIList.Clear(), list, GridItem.OnClick(), UIList.Refresh(), GridItem.SetButton(), and slots.

Referenced by UIRecipeInfo.RefreshList().

◆ BuildIngredients()

void DropdownGrid.BuildIngredients ( Recipe  _recipe,
Image  _icon,
Action  _onValueChange,
StockSearchMode  _searchMode 
)
inline

Definition at line 90 of file DropdownGrid.cs.

91 {
92 recipe = _recipe;
93 icon = _icon;
94 list.Clear();
95 onValueChange = _onValueChange;
96 searchMode = _searchMode;
97 if (recipe == null)
98 {
99 return;
100 }
101 list.callbacks = new UIList.Callback<Recipe.Ingredient, ButtonGrid>
102 {
103 onInstantiate = delegate(Recipe.Ingredient ingredient, ButtonGrid b)
104 {
105 List<Thing> things;
106 if (ingredient.id.IsEmpty())
107 {
108 b.SetIngredient(recipe, ingredient);
109 }
110 else
111 {
112 bool flag = false;
113 List<int> list = EMono.player.recipes.lastIngredients.TryGetValue(recipe.id);
114 int num2 = recipe.ingredients.IndexOf(ingredient);
115 if (num2 != -1 && list != null && list.Count > num2)
116 {
117 int uid = list[num2];
118 if (uid != 0)
119 {
120 Thing thing = EMono.pc.things.Find((Thing t) => t.uid == uid) ?? EMono._map.Stocked.Find(uid);
121 if (thing != null && ingredient.IsValidIngredient(thing) && (!(thing.parent is Card card) || card.GetWindowSaveData() == null || !card.GetWindowSaveData().excludeCraft))
122 {
123 ingredient.SetThing(thing);
124 flag = true;
125 }
126 }
127 }
128 if (!flag)
129 {
130 things = ListIngredients(ingredient, searchMode);
131 if (things.Count == 0)
132 {
133 if (EMono.debug.godBuild && ingredient.thing == null)
134 {
135 Thing thing2 = ThingGen.Create(ingredient.IdThing, recipe.DefaultMaterial.alias).SetNum(99);
136 things.Add(thing2);
137 ingredient.SetThing(thing2);
138 }
139 else
140 {
141 ingredient.SetThing();
142 things.Insert(0, null);
143 }
144 }
145 else if (!ingredient.optional)
146 {
147 if (ingredient.thing == null)
148 {
149 int num3 = lastMats.TryGetValue(recipe.id, -1);
150 if (num3 != -1)
151 {
152 foreach (Thing item in things)
153 {
154 if (item.material.id == num3 && item.Num >= ingredient.req)
155 {
156 ingredient.SetThing(item);
157 break;
158 }
159 }
160 if (ingredient.thing == null && EMono.debug.godBuild)
161 {
162 Thing thing3 = ThingGen.Create(ingredient.id, num3).SetNum(999);
163 EMono.pc.AddThing(thing3);
164 ingredient.SetThing(thing3);
165 }
166 }
167 if (ingredient.thing == null)
168 {
169 SourceMaterial.Row defaultMaterial = recipe.DefaultMaterial;
170 foreach (Thing item2 in things)
171 {
172 if (item2.material.id == defaultMaterial.id && item2.Num >= ingredient.req)
173 {
174 ingredient.SetThing(item2);
175 break;
176 }
177 }
178 if (EMono.debug.godBuild && ingredient.thing == null)
179 {
180 Thing thing4 = (ingredient.useCat ? ThingGen.CreateFromCategory(ingredient.id) : ThingGen.Create(ingredient.id, defaultMaterial.alias)).SetNum(99);
181 things.Add(thing4);
182 ingredient.SetThing(thing4);
183 }
184 }
185 if (ingredient.thing == null)
186 {
187 ingredient.SetThing(FindMax());
188 }
189 }
190 else
191 {
192 bool flag2 = true;
193 foreach (Thing item3 in things)
194 {
195 if (ingredient.thing == item3)
196 {
197 flag2 = false;
198 break;
199 }
200 }
201 if (flag2 && ingredient.thing == null)
202 {
203 ingredient.SetThing(FindMax());
204 }
205 }
206 }
207 }
208 b.SetIngredient(recipe, ingredient);
209 b.onClick.RemoveAllListeners();
210 b.onClick.AddListener(delegate
211 {
212 List<Thing> list2 = ListIngredients(ingredient, searchMode);
213 if (list2.Count == 0 || list2[0] == null)
214 {
215 SE.Beep();
216 }
217 else if ((bool)rectDrop)
218 {
219 Activate(ingredient, list2);
220 }
221 });
222 }
223 Thing FindMax()
224 {
225 if (things.Count == 0)
226 {
227 return null;
228 }
229 int num4 = 0;
230 Thing result = null;
231 foreach (Thing item4 in things)
232 {
233 if (item4.Num > num4)
234 {
235 num4 = item4.Num;
236 result = item4;
237 }
238 }
239 return result;
240 }
241 },
242 onRedraw = delegate(Recipe.Ingredient a, ButtonGrid b, int i)
243 {
244 b.SetIngredient(recipe, a);
245 }
246 };
247 for (int num = 0; num < slots; num++)
248 {
249 if (num < recipe.ingredients.Count)
250 {
252 continue;
253 }
255 {
256 id = ""
257 });
258 }
259 list.Refresh();
260 }
Definition: Card.cs:11
SourceMaterial.Row material
Definition: Card.cs:2103
Thing AddThing(string id, int lv=-1)
Definition: Card.cs:3280
ICardParent parent
Definition: Card.cs:56
Thing SetNum(int a)
Definition: Card.cs:3676
int uid
Definition: Card.cs:125
ThingContainer things
Definition: Card.cs:39
Thing Add(string id, int num=1, int lv=1)
Definition: Card.cs:3257
int Num
Definition: Card.cs:161
bool godBuild
Definition: CoreDebug.cs:320
List< Thing > ListIngredients(Recipe.Ingredient ingredient, StockSearchMode searchMode)
Definition: DropdownGrid.cs:83
StockSearchMode searchMode
Definition: DropdownGrid.cs:34
void Activate(Recipe.Ingredient ingredient, List< Thing > things)
Dictionary< string, int > lastMats
Definition: DropdownGrid.cs:39
static Chara pc
Definition: EMono.cs:13
static Player player
Definition: EMono.cs:11
static Map _map
Definition: EMono.cs:17
static CoreDebug debug
Definition: EMono.cs:45
PropsStocked Stocked
Definition: Map.cs:126
RecipeManager recipes
Definition: Player.cs:1167
Thing Find(int uid)
Definition: Props.cs:395
Dictionary< string, List< int > > lastIngredients
Definition: Recipe.cs:7
string id
Definition: Recipe.cs:178
SourceMaterial.Row DefaultMaterial
Definition: Recipe.cs:206
List< Ingredient > ingredients
Definition: Recipe.cs:181
Thing Find(int uid)
static Thing CreateFromCategory(string idCat, int lv=-1)
Definition: ThingGen.cs:75
static Thing Create(string id, int idMat=-1, int lv=-1)
Definition: ThingGen.cs:53

References EMono._map, Activate(), UIList.Add(), Card.Add(), Card.AddThing(), card, UIList.Clear(), ThingGen.Create(), ThingGen.CreateFromCategory(), EMono.debug, Recipe.DefaultMaterial, Props.Find(), ThingContainer.Find(), CoreDebug.godBuild, icon, Recipe.id, Recipe.ingredients, Thing.IsValidIngredient(), item, RecipeManager.lastIngredients, lastMats, list, ListIngredients(), Card.material, Card.Num, onValueChange, Card.parent, EMono.pc, EMono.player, recipe, Player.recipes, rectDrop, UIList.Refresh(), searchMode, ButtonGrid.SetIngredient(), Card.SetNum(), slots, Map.Stocked, Card.things, and Card.uid.

Referenced by UIRecipeInfo.RefreshList().

◆ Deactivate()

void DropdownGrid.Deactivate ( )
inline

Definition at line 339 of file DropdownGrid.cs.

340 {
341 IsActive = false;
342 if (rectDrop != null)
343 {
344 rectDrop.SetActive(enable: false);
345 }
346 }

References IsActive, and rectDrop.

Referenced by Activate(), and ActionMode.UpdateInput().

◆ ListIngredients()

List< Thing > DropdownGrid.ListIngredients ( Recipe::Ingredient  ingredient,
StockSearchMode  searchMode 
)
inline

Definition at line 83 of file DropdownGrid.cs.

84 {
85 List<Thing> obj = EMono._map.Stocked.ListThingStack(ingredient, searchMode).list;
86 obj.Sort(UIList.SortMode.ByCategory);
87 return obj;
88 }
ThingStack ListThingStack(Recipe.Ingredient ing, StockSearchMode searchMode)
Definition: Props.cs:204
List< Thing > list
Definition: ThingStack.cs:5
SortMode
Definition: UIList.cs:27

References EMono._map, ThingStack.list, Props.ListThingStack(), searchMode, and Map.Stocked.

Referenced by BuildIngredients(), and TrySelect().

◆ Next()

void DropdownGrid.Next ( )
inline

Definition at line 391 of file DropdownGrid.cs.

392 {
393 TrySelect(1);
394 }
void TrySelect(int a)

References TrySelect().

Referenced by Scene.OnUpdate().

◆ OnChangeIngredient()

void DropdownGrid.OnChangeIngredient ( )
inline

Definition at line 322 of file DropdownGrid.cs.

323 {
324 if (recipe == null)
325 {
326 return;
327 }
329 if ((bool)rectDrop)
330 {
331 if ((bool)icon)
332 {
334 }
335 list.Redraw();
336 }
337 }
virtual RenderRow renderRow
Definition: Recipe.cs:210
virtual void OnChangeIngredient()
Definition: Recipe.cs:562
int idSkin
Definition: Recipe.cs:198
virtual SourceMaterial.Row GetColorMaterial()
Definition: Recipe.cs:506
int GetColorInt(SourceMaterial.Row mat)
Definition: RenderRow.cs:459
void SetImage(Image image, Sprite sprite=null, int matCol=0, bool setNativeSize=true, int dir=0, int idSkin=0, Card card=null)
Definition: RenderRow.cs:381
override void Redraw()
Definition: UIList.cs:796

References RenderRow.GetColorInt(), Recipe.GetColorMaterial(), icon, Recipe.idSkin, list, Recipe.OnChangeIngredient(), recipe, rectDrop, UIList.Redraw(), Recipe.renderRow, and RenderRow.SetImage().

Referenced by Activate(), and TrySelect().

◆ OnDestroy()

void DropdownGrid.OnDestroy ( )
inline

Definition at line 348 of file DropdownGrid.cs.

349 {
350 IsActive = false;
351 UnityEngine.Object.DestroyImmediate(rectDrop.gameObject);
352 }

References IsActive, and rectDrop.

◆ Prev()

void DropdownGrid.Prev ( )
inline

Definition at line 396 of file DropdownGrid.cs.

397 {
398 TrySelect(-1);
399 }

References TrySelect().

Referenced by Scene.OnUpdate().

◆ Redraw()

void DropdownGrid.Redraw ( )
inline

Definition at line 262 of file DropdownGrid.cs.

263 {
264 list.Redraw();
265 }

References list, and UIList.Redraw().

Referenced by UIRecipeInfo.RefreshBalance().

◆ TrySelect()

void DropdownGrid.TrySelect ( int  a)
inline

Definition at line 354 of file DropdownGrid.cs.

355 {
356 ButtonGrid componentOf = InputModuleEX.GetComponentOf<ButtonGrid>();
357 if (!componentOf || componentOf.ing == null)
358 {
359 return;
360 }
361 Recipe.Ingredient ing = componentOf.ing;
362 List<Thing> list = ListIngredients(ing, searchMode);
363 int num = list.IndexOf(ing.thing);
364 if (num != -1)
365 {
366 SE.Resource();
367 num += a;
368 if (num < 0)
369 {
370 num = 0;
371 }
372 if (num >= list.Count)
373 {
374 num = list.Count - 1;
375 }
376 ing.SetThing(list[num]);
379 componentOf.ShowTooltip();
380 if ((bool)recipeInfo)
381 {
383 }
384 if ((bool)LayerCraft.Instance)
385 {
387 }
388 }
389 }
Recipe.Ingredient ing
Definition: ButtonGrid.cs:22
UIRecipeInfo recipeInfo
Definition: DropdownGrid.cs:36
void RefreshProduct()
Definition: LayerCraft.cs:455
void ResetTooltips()
static TooltipManager Instance
virtual void ShowTooltip()
Definition: UIButton.cs:379
void RefreshImages()

References ButtonGrid.ing, LayerCraft.Instance, TooltipManager.Instance, list, ListIngredients(), OnChangeIngredient(), recipeInfo, UIRecipeInfo.RefreshImages(), LayerCraft.RefreshProduct(), TooltipManager.ResetTooltips(), searchMode, Recipe.Ingredient.SetThing(), UIButton.ShowTooltip(), and Recipe.Ingredient.thing.

Referenced by Next(), and Prev().

◆ Update()

void DropdownGrid.Update ( )
inlineprivate

Definition at line 46 of file DropdownGrid.cs.

47 {
48 rectDrop.SetActive(IsActive);
49 }

References IsActive, and rectDrop.

Member Data Documentation

◆ fixPos

Vector3 DropdownGrid.fixPos

Definition at line 32 of file DropdownGrid.cs.

Referenced by Activate().

◆ icon

Image DropdownGrid.icon

Definition at line 24 of file DropdownGrid.cs.

Referenced by BuildIngredients(), and OnChangeIngredient().

◆ Instance

DropdownGrid DropdownGrid.Instance
static

Definition at line 10 of file DropdownGrid.cs.

Referenced by Activate(), and ActionMode.UpdateInput().

◆ IsActive

bool DropdownGrid.IsActive
static

◆ lastMats

Dictionary<string, int> DropdownGrid.lastMats = new Dictionary<string, int>()

Definition at line 39 of file DropdownGrid.cs.

Referenced by BuildIngredients().

◆ list

UIList DropdownGrid.list

Definition at line 12 of file DropdownGrid.cs.

Referenced by Build(), BuildIngredients(), OnChangeIngredient(), Redraw(), and TrySelect().

◆ listDrop

UIList DropdownGrid.listDrop

Definition at line 14 of file DropdownGrid.cs.

Referenced by Activate().

◆ onValueChange

Action DropdownGrid.onValueChange

Definition at line 28 of file DropdownGrid.cs.

Referenced by Activate(), and BuildIngredients().

◆ pivot

RectTransform DropdownGrid.pivot

Definition at line 20 of file DropdownGrid.cs.

Referenced by LayerCraft.OnAfterInit().

◆ recipe

Recipe DropdownGrid.recipe

Definition at line 22 of file DropdownGrid.cs.

Referenced by Activate(), BuildIngredients(), and OnChangeIngredient().

◆ recipeInfo

UIRecipeInfo DropdownGrid.recipeInfo

Definition at line 36 of file DropdownGrid.cs.

Referenced by TrySelect().

◆ rectDrop

RectTransform DropdownGrid.rectDrop

◆ rectDropContent

RectTransform DropdownGrid.rectDropContent

Definition at line 18 of file DropdownGrid.cs.

◆ searchMode

StockSearchMode DropdownGrid.searchMode

Definition at line 34 of file DropdownGrid.cs.

Referenced by BuildIngredients(), ListIngredients(), and TrySelect().

◆ slots

int DropdownGrid.slots = 4

Definition at line 30 of file DropdownGrid.cs.

Referenced by Build(), and BuildIngredients().

◆ soundPop

SoundData DropdownGrid.soundPop

Definition at line 26 of file DropdownGrid.cs.

Referenced by Activate().


The documentation for this class was generated from the following file: