Elin Decompiled Documentation EA 23.102 Nightly
All Classes Namespaces Files Functions Variables Enumerations Enumerator Properties Events Pages
DropdownGrid Class Reference
Inheritance diagram for DropdownGrid:
EMono

Public Member Functions

void Build (List< GridItem > items)
 
List< ThingListIngredients (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 259 of file DropdownGrid.cs.

260 {
261 IsActive = true;
262 Instance = this;
263 rectDrop.SetActive(enable: true);
264 rectDrop.SetParent(EMono.ui.transform);
265 rectDrop.sizeDelta = new Vector2(0f, 0f);
266 rectDrop.anchoredPosition = Vector3.zero;
267 listDrop.callbacks = new UIList.Callback<Thing, ButtonGrid>
268 {
269 onClick = delegate(Thing a, ButtonGrid b)
270 {
271 SE.Resource();
272 ingredient.SetThing(a);
275 if (onValueChange != null)
276 {
278 }
279 Deactivate();
280 if ((bool)LayerCraft.Instance)
281 {
283 }
284 },
285 onInstantiate = delegate(Thing a, ButtonGrid b)
286 {
287 b.SetIngredient(recipe, a);
288 b.SetOnClick(delegate
289 {
290 });
291 b.onRightClick = delegate
292 {
293 };
294 }
295 };
296 listDrop.Clear();
297 foreach (Thing thing in things)
298 {
299 listDrop.Add(thing);
300 }
302 rectDropContent.position = list.transform.position + fixPos;
303 if (listDrop.items.Count == 0)
304 {
305 SE.Beep();
306 Deactivate();
307 }
308 else if ((bool)soundPop)
309 {
310 soundPop.Play();
311 }
312 }
void SetIngredient(Recipe r, Recipe.Ingredient _ing)
Definition: ButtonGrid.cs:435
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:89
void SaveLastIngredients()
Definition: Recipe.cs:975
Definition: Thing.cs:8
Definition: UIList.cs:9
List< object > items
Definition: UIList.cs:241
override void Clear()
Definition: UIList.cs:349
override void Add(object item)
Definition: UIList.cs:302
virtual void Refresh(bool highlightLast=false)
Definition: UIList.cs:424

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 j = 0; j < slots; j++)
70 {
71 if (j < items.Count)
72 {
73 list.Add(items[j]);
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 88 of file DropdownGrid.cs.

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

332 {
333 IsActive = false;
334 if (rectDrop != null)
335 {
336 rectDrop.SetActive(enable: false);
337 }
338 }

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 return EMono._map.Stocked.ListThingStack(ingredient, searchMode).list;
86 }
ThingStack ListThingStack(Recipe.Ingredient ing, StockSearchMode searchMode)
Definition: Props.cs:204
List< Thing > list
Definition: ThingStack.cs:5

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

Referenced by BuildIngredients().

◆ Next()

void DropdownGrid.Next ( )
inline

Definition at line 383 of file DropdownGrid.cs.

384 {
385 TrySelect(1);
386 }
void TrySelect(int a)

References TrySelect().

Referenced by Scene.OnUpdate().

◆ OnChangeIngredient()

void DropdownGrid.OnChangeIngredient ( )
inline

Definition at line 314 of file DropdownGrid.cs.

315 {
316 if (recipe == null)
317 {
318 return;
319 }
321 if ((bool)rectDrop)
322 {
323 if ((bool)icon)
324 {
326 }
327 list.Redraw();
328 }
329 }
virtual RenderRow renderRow
Definition: Recipe.cs:193
virtual void OnChangeIngredient()
Definition: Recipe.cs:532
int idSkin
Definition: Recipe.cs:181
virtual SourceMaterial.Row GetColorMaterial()
Definition: Recipe.cs:481
int GetColorInt(SourceMaterial.Row mat)
Definition: RenderRow.cs:417
void SetImage(Image image, Sprite sprite=null, int matCol=0, bool setNativeSize=true, int dir=0, int idSkin=0)
Definition: RenderRow.cs:346
override void Redraw()
Definition: UIList.cs:740

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 340 of file DropdownGrid.cs.

341 {
342 IsActive = false;
343 UnityEngine.Object.DestroyImmediate(rectDrop.gameObject);
344 }

References IsActive, and rectDrop.

◆ Prev()

void DropdownGrid.Prev ( )
inline

Definition at line 388 of file DropdownGrid.cs.

389 {
390 TrySelect(-1);
391 }

References TrySelect().

Referenced by Scene.OnUpdate().

◆ Redraw()

void DropdownGrid.Redraw ( )
inline

Definition at line 254 of file DropdownGrid.cs.

255 {
256 list.Redraw();
257 }

References list, and UIList.Redraw().

Referenced by UIRecipeInfo.RefreshBalance().

◆ TrySelect()

void DropdownGrid.TrySelect ( int  a)
inline

Definition at line 346 of file DropdownGrid.cs.

347 {
348 ButtonGrid componentOf = InputModuleEX.GetComponentOf<ButtonGrid>();
349 if (!componentOf || componentOf.ing == null)
350 {
351 return;
352 }
353 Recipe.Ingredient ing = componentOf.ing;
354 List<Thing> list = EMono._map.Stocked.ListThingStack(ing, searchMode).list;
355 int num = list.IndexOf(ing.thing);
356 if (num != -1)
357 {
358 SE.Resource();
359 num += a;
360 if (num < 0)
361 {
362 num = 0;
363 }
364 if (num >= list.Count)
365 {
366 num = list.Count - 1;
367 }
368 ing.SetThing(list[num]);
371 componentOf.ShowTooltip();
372 if ((bool)recipeInfo)
373 {
375 }
376 if ((bool)LayerCraft.Instance)
377 {
379 }
380 }
381 }
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 EMono._map, ButtonGrid.ing, LayerCraft.Instance, TooltipManager.Instance, list, ThingStack.list, Props.ListThingStack(), OnChangeIngredient(), recipeInfo, UIRecipeInfo.RefreshImages(), LayerCraft.RefreshProduct(), TooltipManager.ResetTooltips(), searchMode, Recipe.Ingredient.SetThing(), UIButton.ShowTooltip(), Map.Stocked, 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: