Elin Decompiled Documentation EA 23.102 Nightly
Loading...
Searching...
No Matches
UIRecipeInfo.cs
Go to the documentation of this file.
1using System;
2using System.Collections.Generic;
3using DG.Tweening;
4using UnityEngine;
5using UnityEngine.UI;
6
7public class UIRecipeInfo : EMono
8{
9 public class RecipeVariation
10 {
11 public Recipe recipe;
12
13 public int dir;
14 }
15
17
19
21
23
25
27
29
30 public Thing factory;
31
32 public Recipe recipe;
33
34 public Area area;
35
37
39
40 public Image imageArea;
41
42 public Image imageIcon;
43
44 public UINote note;
45
47
49
50 public GameObject goMoney;
51
52 public GameObject goIngredients;
53
54 public GameObject goInfo;
55
56 public bool main;
57
58 public bool CraftMode;
59
61
63
65
67
68 [NonSerialized]
69 public Dictionary<string, int> lastMats = new Dictionary<string, int>();
70
71 [NonSerialized]
72 public bool hideMode = true;
73
74 [NonSerialized]
75 public List<DropdownRecipe> dds = new List<DropdownRecipe>();
76
78
79 public void Init()
80 {
81 DropdownRecipe.colorCost = colorCost;
82 DropdownRecipe.colorPredict = colorPredict;
83 SetRecipe(null);
84 }
85
86 public void SetArea(Area a)
87 {
88 if (a == null)
89 {
90 Clear();
91 return;
92 }
93 if (main)
94 {
95 goInfo.SetActive(value: true);
96 goIngredients.SetActive(value: false);
97 }
98 if (area != a)
99 {
100 area = a;
101 recipe = null;
102 textName.text = a.Name;
103 textDetail.SetActive(enable: true);
104 textDetail.SetText(a.source.GetDetail());
105 note.Clear();
106 note.Build();
107 if (!main)
108 {
109 listIngredients.SetActive(enable: false);
110 }
111 RefreshList();
112 if ((bool)imageArea)
113 {
114 imageArea.SetActive(enable: true);
115 }
116 if ((bool)listVariations)
117 {
118 listVariations.SetActive(enable: false);
119 }
120 this.SetActive(enable: true);
121 this.RebuildLayout(recursive: true);
122 }
123 }
124
125 public void SetRecipe(Recipe r)
126 {
127 if ((bool)imageArea)
128 {
129 imageArea.SetActive(enable: false);
130 }
131 area = null;
132 if (r == null)
133 {
134 textDetail.SetActive(enable: false);
135 Clear();
136 return;
137 }
138 if (main)
139 {
140 goInfo.SetActive(value: true);
141 goIngredients.SetActive(r.ingredients.Count > 0 && !r.UseStock);
142 }
143 if (recipe != r)
144 {
145 recipe = r;
146 Refresh();
147 }
148 }
149
150 public void Clear()
151 {
152 recipe = null;
153 area = null;
154 if (main)
155 {
156 goIngredients.SetActive(value: false);
157 goInfo.SetActive(value: false);
158 if ((bool)listVariations)
159 {
160 listVariations.SetActive(enable: false);
161 }
162 }
163 if (textName.text != "")
164 {
165 UIText uIText = textName;
166 string text2 = (textDetail.text = "");
167 uIText.text = text2;
168 RefreshList();
170 if ((bool)imageArea)
171 {
172 imageArea.SetActive(enable: false);
173 }
174 note.Clear();
175 note.Build();
176 this.RebuildLayout(recursive: true);
177 }
178 }
179
180 public void RefreshBalance()
181 {
182 if (!main)
183 {
184 return;
185 }
186 string text = Lang._Number(EMono.pc.GetCurrency());
187 if (summary.money != 0)
188 {
189 text = text + "<color=" + colorCost.ToHex() + "> -" + summary.money + "</color>";
190 }
191 textCost.SetText(text);
192 foreach (DropdownRecipe dd in dds)
193 {
194 dd.RefreshLabel();
195 }
196 if ((bool)ddList)
197 {
198 ddList.Redraw();
199 }
200 if ((bool)textCostSP)
201 {
202 int countValid = summary.countValid;
203 int num = ((countValid == 0) ? (-1) : (recipe.source.GetSPCost(summary.factory) * countValid));
204 text = ((num == -1) ? "-" : (num.ToString() ?? ""));
205 DOTweenAnimation component = textCostSP.GetComponent<DOTweenAnimation>();
206 Transform transform = textCostSP.Find("nerun");
207 bool flag = num >= EMono.pc.stamina.value;
208 if ((bool)component && !flag)
209 {
210 component.DOPause();
211 }
212 textCostSP.SetText(text, (num == -1) ? FontColor.Bad : ((num < EMono.pc.stamina.value) ? FontColor.Good : FontColor.Warning));
213 if ((bool)component && flag)
214 {
215 component.tween.Restart();
216 }
217 if ((bool)transform)
218 {
219 transform.SetActive(flag);
220 }
221 }
222 }
223
224 public void RefreshImages()
225 {
226 Recipe recipe = this.recipe;
227 if ((bool)listVariations)
228 {
230 }
231 if ((bool)imageIcon)
232 {
234 {
235 recipe.ingredients[0].thing.SetImage(imageIcon, recipe._dir, recipe.ingredients[0].thing.trait.IdSkin);
236 }
237 else
238 {
240 }
241 }
242 }
243
244 public void Refresh()
245 {
246 if (recipe == null)
247 {
248 return;
249 }
251 {
252 Thing thing = recipe.ingredients[0].thing;
253 if (thing == null || thing.isDestroyed || thing.ExistsOnMap)
254 {
255 return;
256 }
257 }
258 Recipe r = recipe;
259 r.OnSelected();
260 RefreshList();
262 if (r.UseStock && r.ingredients[0].thing == null)
263 {
264 return;
265 }
266 textName.text = r.GetName();
267 string text = "";
268 int[] tiles = recipe.renderRow.tiles;
270 {
271 text = text + "(" + recipe.id + " " + recipe.renderRow.idRenderData + "/" + ((tiles.Length != 0) ? tiles[0] : (-1)) + ")" + Environment.NewLine;
272 }
273 textDetail.SetActive(enable: true);
274 if (CraftMode)
275 {
276 if (main)
277 {
279 int num = EMono.player.recipes.knownRecipes.TryGetValue(r.id, 0);
280 textInfo.SetText("recipe_lv".lang(num.ToString() ?? ""));
281 text += r.GetDetail();
282 }
283 else
284 {
285 text += r.GetDetail();
286 r.WriteNote(note);
287 }
288 }
289 else
290 {
291 string detail = r.GetDetail();
292 if (!detail.IsEmpty())
293 {
294 text = text + detail + "\n\n";
295 }
296 text = text + "( " + r.tileType.LangPlaceType.lang() + " ) " + (r.tileType.LangPlaceType + "_hint").lang();
297 if (r.UseStock && r.ingredients[0].thing != null)
298 {
299 r.ingredients[0].thing.WriteNote(note, null, IInspect.NoteMode.Recipe);
300 }
301 else
302 {
303 r.WriteNote(note);
304 }
305 if (!r.UseStock && r.source.NeedFactory)
306 {
307 PropSet propSet = EMono._map.Installed.cardMap.TryGetValue(r.source.idFactory);
308 if ((propSet == null || propSet.Count == 0) && EMono.pc.things.Find((Thing t) => t.id == r.source.idFactory) == null)
309 {
310 note.Space(8);
311 note.AddText("noFactory".lang(r.source.NameFactory), FontColor.Bad);
312 note.Build();
313 }
314 }
315 }
316 textDetail.SetText(text);
317 if ((bool)goMoney)
318 {
319 goMoney.transform.SetAsLastSibling();
320 }
321 if (main)
322 {
323 if ((bool)listVariations)
324 {
325 UIList uIList = listVariations;
326 bool flag = r.CanRotate && r.renderRow != null;
327 int[] array = (flag ? r.renderRow._tiles : null);
328 if (flag && array.Length <= 1)
329 {
330 flag = false;
331 }
332 uIList.SetActive(flag);
333 if (flag)
334 {
335 uIList.Clear();
336 uIList.callbacks = new UIList.Callback<RecipeVariation, ButtonGrid>
337 {
338 onClick = delegate(RecipeVariation a, ButtonGrid b)
339 {
340 r.SetDir(a.dir);
341 },
342 onInstantiate = delegate(RecipeVariation a, ButtonGrid b)
343 {
345 },
346 onRedraw = delegate(RecipeVariation a, ButtonGrid b, int i)
347 {
349 }
350 };
351 for (int j = 0; j < array.Length; j++)
352 {
353 uIList.Add(new RecipeVariation
354 {
355 recipe = r,
356 dir = j
357 });
358 }
359 uIList.Refresh();
360 uIList.group.Init(r._dir);
361 }
362 }
363 if ((bool)goMoney)
364 {
365 goMoney.SetActive(!CraftMode);
366 }
367 }
368 else
369 {
371 if ((bool)goMoney)
372 {
373 goMoney.SetActive(r.CostMoney != 0);
374 }
375 }
377 this.SetActive(enable: true);
378 this.RebuildLayout(recursive: true);
379 }
380
381 public void OnRotate()
382 {
383 if (listVariations.gameObject.activeSelf)
384 {
386 }
388 }
389
390 public void RefreshQuality()
391 {
392 if ((bool)textQuality)
393 {
395 }
396 }
397
398 public void RefreshList()
399 {
400 if ((bool)textReqSkill)
401 {
402 string str = "";
403 FontColor c = FontColor.Good;
404 if (recipe != null)
405 {
406 Element reqSkill = recipe.source.GetReqSkill();
407 int value = EMono.pc.elements.GetOrCreateElement(reqSkill).Value;
408 _ = reqSkill.Name + " " + reqSkill.Value;
409 str = "reqSkill2".lang(reqSkill.Name, reqSkill.Value.ToString() ?? "", value.ToString() ?? "");
410 if (value < reqSkill.Value)
411 {
412 c = FontColor.Warning;
413 }
414 }
415 textReqSkill.SetText(str.IsEmpty("noReqSkill".lang()), c);
416 }
417 if ((bool)ddFactory)
418 {
419 List<GridItem> list = new List<GridItem>();
421 {
422 GridItemCardSource gridItemCardSource = new GridItemCardSource
423 {
425 };
426 if (factory != null && recipe.source.idFactory == factory.id)
427 {
428 gridItemCardSource.thing = factory;
429 }
430 list.Add(gridItemCardSource);
431 }
432 ddFactory.Build(list);
433 }
435 if ((bool)ddList)
436 {
437 ddList.SetActive(recipe != null && !recipe.UseStock);
438 if (recipe != null && !recipe.UseStock)
439 {
440 ddList.recipeInfo = this;
441 ddList.lastMats = lastMats;
443 }
444 return;
445 }
446 Recipe r = recipe;
447 UIList uIList = listIngredients;
448 uIList.Clear();
449 dds.Clear();
450 if (r == null || r.UseStock)
451 {
452 return;
453 }
454 uIList.callbacks = new UIList.Callback<Recipe.Ingredient, UIItem>
455 {
456 onClick = delegate
457 {
458 },
459 onInstantiate = delegate(Recipe.Ingredient ingredient, UIItem b)
460 {
461 DropdownRecipe dropdownRecipe = b.dd as DropdownRecipe;
462 dropdownRecipe.recipe = r;
463 dds.Add(dropdownRecipe);
464 ThingStack thingStack = EMono._map.Stocked.ListThingStack(ingredient, searchMode);
465 int num = thingStack.count;
466 Color color = ((num >= ingredient.req) ? SkinManager.CurrentColors.textGood : SkinManager.CurrentColors.textBad);
467 dropdownRecipe.SetList(0, new List<string> { ingredient.id }, (string n, int i) => "<color=" + color.ToHex() + ">" + ingredient.GetName() + " x " + ingredient.req + " (" + num + ")</color>", delegate
468 {
469 });
470 dropdownRecipe.textLabel.text = dropdownRecipe.orgLabel.text;
471 if ((bool)textCost)
472 {
473 textCost.text = r.CostMoney.ToString() ?? "";
474 }
475 }
476 };
477 foreach (Recipe.Ingredient ingredient in r.ingredients)
478 {
479 uIList.Add(ingredient);
480 }
481 uIList.Refresh();
482 }
483}
FontColor
Definition: FontColor.cs:2
StockSearchMode
Definition: Area.cs:4
virtual string Name
Definition: BaseArea.cs:37
SourceArea.Row source
Definition: BaseArea.cs:50
BaseTileSelector tileSelector
void SetRecipeVariation(UIRecipeInfo.RecipeVariation a)
Definition: ButtonGrid.cs:518
bool isDestroyed
Definition: Card.cs:71
ElementContainerCard elements
Definition: Card.cs:37
string id
Definition: Card.cs:31
bool ExistsOnMap
Definition: Card.cs:1961
int GetCurrency(string id="money")
Definition: Card.cs:3652
ThingContainer things
Definition: Card.cs:34
Thing Add(string id, int num=1, int lv=1)
Definition: Card.cs:2878
Stats stamina
Definition: Chara.cs:955
bool showExtra
Definition: CoreDebug.cs:167
void BuildIngredients(Recipe _recipe, Image _icon, Action _onValueChange, StockSearchMode _searchMode)
Definition: DropdownGrid.cs:88
void Build(List< GridItem > items)
Definition: DropdownGrid.cs:51
Definition: EMono.cs:4
static Chara pc
Definition: EMono.cs:13
static Player player
Definition: EMono.cs:11
static BaseGameScreen screen
Definition: EMono.cs:29
static Map _map
Definition: EMono.cs:17
static CoreDebug debug
Definition: EMono.cs:45
static SourceManager sources
Definition: EMono.cs:41
Element GetOrCreateElement(Element ele)
int Value
Definition: ELEMENT.cs:282
virtual string Name
Definition: ELEMENT.cs:294
int countValid
Definition: HitSummary.cs:10
int money
Definition: HitSummary.cs:6
Thing factory
Definition: HitSummary.cs:18
Definition: Lang.cs:6
static string _Number(int a)
Definition: Lang.cs:157
PropsInstalled Installed
Definition: Map.cs:123
PropsStocked Stocked
Definition: Map.cs:121
RecipeManager recipes
Definition: Player.cs:898
Dictionary< string, PropSet > cardMap
Definition: Props.cs:10
ThingStack ListThingStack(Recipe.Ingredient ing, StockSearchMode searchMode)
Definition: Props.cs:204
Dictionary< string, int > knownRecipes
Element GetReqSkill()
string idFactory
Definition: RecipeSource.cs:85
string NameFactory
Definition: RecipeSource.cs:73
int GetSPCost(Card factory)
bool NeedFactory
Definition: RecipeSource.cs:61
Definition: Recipe.cs:7
string id
Definition: Recipe.cs:161
virtual int GetRefVal()
Definition: Recipe.cs:405
void SetTextDifficulty(UIText text)
Definition: Recipe.cs:936
virtual void WriteNote(UINote n)
Definition: Recipe.cs:787
virtual string GetIdThing()
Definition: Recipe.cs:422
virtual void SetDir(int d)
Definition: Recipe.cs:868
virtual TileType tileType
Definition: Recipe.cs:198
virtual void OnSelected()
Definition: Recipe.cs:817
virtual RenderRow renderRow
Definition: Recipe.cs:193
RecipeSource source
Definition: Recipe.cs:187
List< Ingredient > ingredients
Definition: Recipe.cs:164
bool VirtualBlock
Definition: Recipe.cs:173
virtual int CostMoney
Definition: Recipe.cs:279
virtual string GetDetail()
Definition: Recipe.cs:782
bool UseStock
Definition: Recipe.cs:167
int _dir
Definition: Recipe.cs:175
int idSkin
Definition: Recipe.cs:181
string GetName()
Definition: Recipe.cs:760
virtual SourceMaterial.Row GetColorMaterial()
Definition: Recipe.cs:481
bool IngAsProduct
Definition: Recipe.cs:170
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
int[] tiles
Definition: RenderRow.cs:10
static SkinColorProfile CurrentColors
Definition: SkinManager.cs:84
Dictionary< string, CardRow > map
Definition: SourceCard.cs:8
SourceCard cards
virtual int value
Definition: Stats.cs:56
Thing Find(int uid)
ThingStack GetThingStack(string id, int refVal=-1)
int count
Definition: ThingStack.cs:7
Definition: Thing.cs:8
virtual string LangPlaceType
Definition: TileType.cs:119
Definition: UIItem.cs:5
Definition: UIList.cs:9
UISelectableGroup group
Definition: UIList.cs:205
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
override void Redraw()
Definition: UIList.cs:740
Definition: UINote.cs:6
void Clear()
Definition: UINote.cs:35
UIItem AddText(string text, FontColor color=FontColor.DontChange)
Definition: UINote.cs:113
void Space(int sizeY=0, int sizeX=1)
Definition: UINote.cs:62
void Build()
Definition: UINote.cs:49
void SetArea(Area a)
Definition: UIRecipeInfo.cs:86
GameObject goInfo
Definition: UIRecipeInfo.cs:54
void RefreshImages()
void RefreshList()
Dictionary< string, int > lastMats
Definition: UIRecipeInfo.cs:69
Color colorPredict
Definition: UIRecipeInfo.cs:48
Color colorCost
Definition: UIRecipeInfo.cs:46
HitSummary summary
Definition: UIRecipeInfo.cs:77
GameObject goIngredients
Definition: UIRecipeInfo.cs:52
void RefreshBalance()
UIList listVariations
Definition: UIRecipeInfo.cs:38
void Refresh()
void SetRecipe(Recipe r)
UIText textCost
Definition: UIRecipeInfo.cs:20
ButtonGrid buttonProduct
Definition: UIRecipeInfo.cs:66
DropdownGrid ddList
Definition: UIRecipeInfo.cs:62
void OnRotate()
UIText textName
Definition: UIRecipeInfo.cs:16
Image imageIcon
Definition: UIRecipeInfo.cs:42
List< DropdownRecipe > dds
Definition: UIRecipeInfo.cs:75
UIText textInfo
Definition: UIRecipeInfo.cs:22
GameObject goMoney
Definition: UIRecipeInfo.cs:50
void RefreshQuality()
UIText textCostSP
Definition: UIRecipeInfo.cs:28
DropdownGrid ddFactory
Definition: UIRecipeInfo.cs:64
UIList listIngredients
Definition: UIRecipeInfo.cs:36
UIText textReqSkill
Definition: UIRecipeInfo.cs:26
StockSearchMode searchMode
Definition: UIRecipeInfo.cs:60
UIText textDetail
Definition: UIRecipeInfo.cs:18
Recipe recipe
Definition: UIRecipeInfo.cs:32
UIText textQuality
Definition: UIRecipeInfo.cs:24
Image imageArea
Definition: UIRecipeInfo.cs:40
void Select(UIButton button, bool check=true)
virtual void Init(int index=0, UnityAction< int > action=null, bool directChildren=false)
Definition: UIText.cs:6
void SetText(string s)
Definition: UIText.cs:159
NoteMode
Definition: IInspect.cs:7