Elin Decompiled Documentation EA 23.102 Nightly
Loading...
Searching...
No Matches
UIDragGridInfo.cs
Go to the documentation of this file.
1using System.Collections.Generic;
2using System.Linq;
3using UnityEngine;
4using UnityEngine.UI;
5
6public class UIDragGridInfo : EMono
7{
8 public Window window;
9
11
12 public Transform transMold;
13
14 public Transform moldThing;
15
16 public Transform moldPlus;
17
18 public Transform moldEqual;
19
20 public Transform moldOr;
21
22 public Transform moldCat;
23
24 public Transform moldUnknown;
25
26 public UIList list;
27
28 public Card owner;
29
30 public UINote note;
31
32 private void Awake()
33 {
34 window.SetActive(enable: false);
35 transMold.SetActive(enable: false);
36 }
37
38 public void Refresh()
39 {
40 Init(owner);
41 }
42
43 public void Init(Card _owner)
44 {
45 owner = _owner;
46 TraitCrafter crafter = owner.trait as TraitCrafter;
47 if (crafter == null)
48 {
49 return;
50 }
51 textHeader.text = "knownRecipe".lang();
52 List<SourceRecipe.Row> recipes = EMono.sources.recipes.rows.Where((SourceRecipe.Row r) => r.factory == crafter.IdSource).ToList();
53 if (recipes.Count == 0)
54 {
55 return;
56 }
57 list.callbacks = new UIList.Callback<SourceRecipe.Row, LayoutGroup>
58 {
59 onClick = delegate
60 {
61 },
62 onInstantiate = delegate(SourceRecipe.Row a, LayoutGroup b)
63 {
64 for (int i = 0; i < crafter.numIng; i++)
65 {
66 if (i != 0)
67 {
68 Util.Instantiate(moldPlus, b);
69 }
70 string[] array2 = i switch
71 {
72 1 => a.ing2,
73 0 => a.ing1,
74 _ => a.ing3,
75 };
76 if (array2.IsEmpty())
77 {
78 break;
79 }
80 string[] array3 = array2;
81 foreach (string text2 in array3)
82 {
83 if (text2 != array2[0])
84 {
85 Util.Instantiate(moldOr, b);
86 }
87 AddThing(text2);
88 }
89 }
90 Util.Instantiate(moldEqual, b);
91 AddThing(a.thing);
92 },
93 onList = delegate
94 {
95 foreach (SourceRecipe.Row item in recipes)
96 {
97 if (item.tag.Contains("known") || EMono.player.knownCraft.Contains(item.id) || EMono.debug.godCraft)
98 {
99 list.Add(item);
100 }
101 }
102 }
103 };
104 list.List();
105 TraitRollingFortune traitRollingFortune = owner.trait as TraitRollingFortune;
106 note.SetActive(traitRollingFortune != null);
107 if (traitRollingFortune != null)
108 {
110 }
111 window.SetActive(enable: true);
112 window.RebuildLayout(recursive: true);
113 void AddThing(string id)
114 {
115 if (id.IsEmpty() || id == "notImplemented" || id == "any")
116 {
117 Util.Instantiate(moldUnknown, P_1.b).GetComponentInChildren<UIButton>().tooltip.lang = "???";
118 }
119 else
120 {
121 id = id.Replace("%", "@");
122 string[] array = id.Split('@');
123 string text = "";
124 id = array[0];
125 if (id.StartsWith('#'))
126 {
127 text = id.Replace("#", "");
128 id = EMono.sources.categories.map[text].GetIdThing();
129 }
130 CardRow cardRow = EMono.sources.cards.map[id];
132 if (array.Length >= 2)
133 {
134 mat = ((!(array[1] == "gelatin")) ? EMono.sources.materials.alias[array[1]] : EMono.sources.materials.alias["jelly"]);
135 }
136 Transform transform = Util.Instantiate(moldThing, P_1.b);
137 Image componentInChildren = transform.GetComponentInChildren<Image>();
138 UIButton component = componentInChildren.GetComponent<UIButton>();
139 cardRow.SetImage(componentInChildren, null, cardRow.GetColorInt(mat));
140 string s = cardRow.GetName();
141 if (!text.IsEmpty())
142 {
143 Transform obj = Util.Instantiate(moldCat, transform);
144 string @ref = EMono.sources.categories.map[text].GetName();
145 obj.GetComponentInChildren<UIText>().SetText("category".lang());
146 s = "ingCat".lang(@ref);
147 }
148 component.tooltip.lang = s.ToTitleCase();
149 }
150 }
151 }
152
153 public void InitFuel(Card _owner)
154 {
155 owner = _owner;
156 textHeader.text = "knownFuel".lang();
157 List<SourceThing.Row> fuels = new List<SourceThing.Row>();
158 foreach (SourceThing.Row row in EMono.sources.things.rows)
159 {
160 if (owner.trait.IsFuel(row.id))
161 {
162 fuels.Add(row);
163 }
164 }
165 list.callbacks = new UIList.Callback<SourceThing.Row, LayoutGroup>
166 {
167 onClick = delegate
168 {
169 },
170 onInstantiate = delegate(SourceThing.Row a, LayoutGroup b)
171 {
172 AddThing(a.id);
173 Util.Instantiate(moldEqual, b);
174 AddThing(owner.id);
175 },
176 onList = delegate
177 {
178 foreach (SourceThing.Row item in fuels)
179 {
180 list.Add(item);
181 }
182 }
183 };
184 list.List();
185 window.SetActive(enable: true);
186 window.RebuildLayout(recursive: true);
187 void AddThing(string id)
188 {
189 if (id.IsEmpty() || id == "notImplemented" || id == "any")
190 {
191 Util.Instantiate(moldUnknown, P_1.b).GetComponentInChildren<UIButton>().tooltip.lang = "???";
192 }
193 else
194 {
195 id = id.Replace("%", "@");
196 string[] array = id.Split('@');
197 string cat = "";
198 id = array[0];
199 if (id.StartsWith('#'))
200 {
201 cat = id.Replace("#", "");
202 List<CardRow> obj = EMono.sources.cards.rows.Where((CardRow r) => r.Category.IsChildOf(cat)).ToList();
203 obj.Sort((CardRow a, CardRow b) => a.value - b.value);
204 id = obj[0].id;
205 }
206 CardRow cardRow = EMono.sources.cards.map[id];
208 if (array.Length >= 2)
209 {
210 mat = ((!(array[1] == "gelatin")) ? EMono.sources.materials.alias[array[1]] : EMono.sources.materials.alias["jelly"]);
211 }
212 Transform transform = Util.Instantiate(moldThing, P_1.b);
213 Image componentInChildren = transform.GetComponentInChildren<Image>();
214 UIButton component = componentInChildren.GetComponent<UIButton>();
215 cardRow.SetImage(componentInChildren, null, cardRow.GetColorInt(mat));
216 string s = cardRow.GetName();
217 if (!cat.IsEmpty())
218 {
219 Transform obj2 = Util.Instantiate(moldCat, transform);
220 string @ref = EMono.sources.categories.map[cat].GetName();
221 obj2.GetComponentInChildren<UIText>().SetText("(" + "category".lang() + ")");
222 s = "ingCat".lang(@ref);
223 }
224 component.tooltip.lang = s.ToTitleCase();
225 }
226 }
227 }
228}
virtual string GetName(int i)
Definition: CardRow.cs:95
Definition: Card.cs:11
string id
Definition: Card.cs:31
Trait trait
Definition: Card.cs:49
bool godCraft
Definition: CoreDebug.cs:180
Definition: EMono.cs:4
static Player player
Definition: EMono.cs:11
static Zone _zone
Definition: EMono.cs:19
static CoreDebug debug
Definition: EMono.cs:45
static SourceManager sources
Definition: EMono.cs:41
void WriteNote(UINote n)
HashSet< int > knownCraft
Definition: Player.cs:877
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
SourceCategory.Row Category
Definition: RenderRow.cs:119
int value
Definition: RenderRow.cs:20
SourceMaterial.Row DefaultMaterial
Definition: RenderRow.cs:86
List< CardRow > rows
Definition: SourceCard.cs:6
Dictionary< string, CardRow > map
Definition: SourceCard.cs:8
SourceMaterial materials
SourceCard cards
SourceThing things
SourceRecipe recipes
SourceCategory categories
virtual string IdSource
Definition: TraitCrafter.cs:35
virtual int numIng
Definition: TraitCrafter.cs:33
bool IsFuel(string s)
Definition: Trait.cs:1286
Transform moldPlus
void Init(Card _owner)
Transform moldUnknown
void InitFuel(Card _owner)
Transform transMold
Transform moldCat
Transform moldOr
Transform moldEqual
Transform moldThing
Definition: UIList.cs:9
override void Add(object item)
Definition: UIList.cs:302
override void List()
Definition: UIList.cs:717
Definition: UINote.cs:6
Definition: UIText.cs:6
string lang
Definition: UIText.cs:9
Definition: Window.cs:13
FortuneRollData GetOrCreateFortuneRollData(bool refresh=true)
Definition: Zone.cs:3536