Elin Decompiled Documentation EA 23.259 Nightly
Loading...
Searching...
No Matches
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 265 of file DropdownGrid.cs.

266 {
267 IsActive = true;
268 Instance = this;
269 rectDrop.SetActive(enable: true);
270 rectDrop.SetParent(EMono.ui.transform);
271 rectDrop.sizeDelta = new Vector2(0f, 0f);
272 rectDrop.anchoredPosition = Vector3.zero;
273 listDrop.callbacks = new UIList.Callback<Thing, ButtonGrid>
274 {
275 onClick = delegate(Thing a, ButtonGrid b)
276 {
277 SE.Resource();
278 ingredient.SetThing(a);
281 if (onValueChange != null)
282 {
284 }
285 Deactivate();
286 if ((bool)LayerCraft.Instance)
287 {
289 }
290 },
291 onInstantiate = delegate(Thing a, ButtonGrid b)
292 {
293 b.SetIngredient(recipe, a);
294 b.SetOnClick(delegate
295 {
296 });
297 b.onRightClick = delegate
298 {
299 };
300 }
301 };
302 listDrop.Clear();
303 foreach (Thing thing in things)
304 {
305 listDrop.Add(thing);
306 }
308 rectDropContent.position = list.transform.position + fixPos;
309 if (listDrop.items.Count == 0)
310 {
311 SE.Beep();
312 Deactivate();
313 }
314 else if ((bool)soundPop)
315 {
316 soundPop.Play();
317 }
318 }
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:98
void SaveLastIngredients()
Definition: Recipe.cs:992
Definition: Thing.cs:8
Definition: UIList.cs:9
List< object > items
Definition: UIList.cs:272
override void Clear()
Definition: UIList.cs:400
override void Add(object item)
Definition: UIList.cs:353
virtual void Refresh(bool highlightLast=false)
Definition: UIList.cs:475

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 if (ingredient.thing == null && EMono.debug.godBuild)
159 {
160 Thing thing3 = ThingGen.Create(ingredient.id, num2).SetNum(999);
161 EMono.pc.AddThing(thing3);
162 ingredient.SetThing(thing3);
163 }
164 }
165 if (ingredient.thing == null)
166 {
167 SourceMaterial.Row defaultMaterial = recipe.DefaultMaterial;
168 foreach (Thing item2 in things)
169 {
170 if (item2.material.id == defaultMaterial.id && item2.Num >= ingredient.req)
171 {
172 ingredient.SetThing(item2);
173 break;
174 }
175 }
176 if (EMono.debug.godBuild && ingredient.thing == null)
177 {
178 Thing thing4 = (ingredient.useCat ? ThingGen.CreateFromCategory(ingredient.id) : ThingGen.Create(ingredient.id, defaultMaterial.alias)).SetNum(99);
179 things.Add(thing4);
180 ingredient.SetThing(thing4);
181 }
182 }
183 if (ingredient.thing == null)
184 {
185 ingredient.SetThing(FindMax());
186 }
187 }
188 else
189 {
190 bool flag2 = true;
191 foreach (Thing item3 in things)
192 {
193 if (ingredient.thing == item3)
194 {
195 flag2 = false;
196 break;
197 }
198 }
199 if (flag2 && ingredient.thing == null)
200 {
201 ingredient.SetThing(FindMax());
202 }
203 }
204 }
205 }
206 b.SetIngredient(recipe, ingredient);
207 b.onClick.RemoveAllListeners();
208 b.onClick.AddListener(delegate
209 {
210 List<Thing> list2 = ListIngredients(ingredient, searchMode);
211 if (list2.Count == 0 || list2[0] == null)
212 {
213 SE.Beep();
214 }
215 else if ((bool)rectDrop)
216 {
217 Activate(ingredient, list2);
218 }
219 });
220 }
221 Thing FindMax()
222 {
223 if (things.Count == 0)
224 {
225 return null;
226 }
227 int num3 = 0;
228 Thing result = null;
229 foreach (Thing item4 in things)
230 {
231 if (item4.Num > num3)
232 {
233 num3 = item4.Num;
234 result = item4;
235 }
236 }
237 return result;
238 }
239 },
240 onRedraw = delegate(Recipe.Ingredient a, ButtonGrid b, int i)
241 {
242 b.SetIngredient(recipe, a);
243 }
244 };
245 for (int j = 0; j < slots; j++)
246 {
247 if (j < recipe.ingredients.Count)
248 {
250 continue;
251 }
253 {
254 id = ""
255 });
256 }
257 list.Refresh();
258 }
Definition: Card.cs:11
SourceMaterial.Row material
Definition: Card.cs:2052
Thing AddThing(string id, int lv=-1)
Definition: Card.cs:3123
ICardParent parent
Definition: Card.cs:56
Thing SetNum(int a)
Definition: Card.cs:3520
int uid
Definition: Card.cs:123
ThingContainer things
Definition: Card.cs:39
Thing Add(string id, int num=1, int lv=1)
Definition: Card.cs:3100
int Num
Definition: Card.cs:159
bool godBuild
Definition: CoreDebug.cs:304
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:1097
Thing Find(int uid)
Definition: Props.cs:389
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 337 of file DropdownGrid.cs.

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

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

390 {
391 TrySelect(1);
392 }
void TrySelect(int a)

References TrySelect().

Referenced by Scene.OnUpdate().

◆ OnChangeIngredient()

void DropdownGrid.OnChangeIngredient ( )
inline

Definition at line 320 of file DropdownGrid.cs.

321 {
322 if (recipe == null)
323 {
324 return;
325 }
327 if ((bool)rectDrop)
328 {
329 if ((bool)icon)
330 {
332 }
333 list.Redraw();
334 }
335 }
virtual RenderRow renderRow
Definition: Recipe.cs:210
virtual void OnChangeIngredient()
Definition: Recipe.cs:549
int idSkin
Definition: Recipe.cs:198
virtual SourceMaterial.Row GetColorMaterial()
Definition: Recipe.cs:498
int GetColorInt(SourceMaterial.Row mat)
Definition: RenderRow.cs:429
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:351
override void Redraw()
Definition: UIList.cs:791

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

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

References IsActive, and rectDrop.

◆ Prev()

void DropdownGrid.Prev ( )
inline

Definition at line 394 of file DropdownGrid.cs.

395 {
396 TrySelect(-1);
397 }

References TrySelect().

Referenced by Scene.OnUpdate().

◆ Redraw()

void DropdownGrid.Redraw ( )
inline

Definition at line 260 of file DropdownGrid.cs.

261 {
262 list.Redraw();
263 }

References list, and UIList.Redraw().

Referenced by UIRecipeInfo.RefreshBalance().

◆ TrySelect()

void DropdownGrid.TrySelect ( int  a)
inline

Definition at line 352 of file DropdownGrid.cs.

353 {
354 ButtonGrid componentOf = InputModuleEX.GetComponentOf<ButtonGrid>();
355 if (!componentOf || componentOf.ing == null)
356 {
357 return;
358 }
359 Recipe.Ingredient ing = componentOf.ing;
360 List<Thing> list = EMono._map.Stocked.ListThingStack(ing, searchMode).list;
361 int num = list.IndexOf(ing.thing);
362 if (num != -1)
363 {
364 SE.Resource();
365 num += a;
366 if (num < 0)
367 {
368 num = 0;
369 }
370 if (num >= list.Count)
371 {
372 num = list.Count - 1;
373 }
374 ing.SetThing(list[num]);
377 componentOf.ShowTooltip();
378 if ((bool)recipeInfo)
379 {
381 }
382 if ((bool)LayerCraft.Instance)
383 {
385 }
386 }
387 }
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: