Elin Decompiled Documentation EA 23.130 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, null);
88 }
89 }
90 Util.Instantiate(moldEqual, b);
91 AddThing(a.thing, (a.type == "FixedResource") ? "noInherit" : null);
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, string lang)
114 {
115 if (id.IsEmpty() || id == "notImplemented" || id == "any")
116 {
117 Util.Instantiate(moldUnknown, P_2.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_2.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() || lang != null)
142 {
143 Util.Instantiate(moldCat, transform).GetComponentInChildren<UIText>().SetText((lang ?? "category").lang());
144 if (lang == null)
145 {
146 string @ref = EMono.sources.categories.map[text].GetName();
147 s = "ingCat".lang(@ref);
148 }
149 }
150 component.tooltip.lang = s.ToTitleCase();
151 }
152 }
153 }
154
155 public void InitFuel(Card _owner)
156 {
157 owner = _owner;
158 textHeader.text = "knownFuel".lang();
159 List<SourceThing.Row> fuels = new List<SourceThing.Row>();
160 foreach (SourceThing.Row row in EMono.sources.things.rows)
161 {
162 if (owner.trait.IsFuel(row.id))
163 {
164 fuels.Add(row);
165 }
166 }
167 list.callbacks = new UIList.Callback<SourceThing.Row, LayoutGroup>
168 {
169 onClick = delegate
170 {
171 },
172 onInstantiate = delegate(SourceThing.Row a, LayoutGroup b)
173 {
174 AddThing(a.id);
175 Util.Instantiate(moldEqual, b);
176 AddThing(owner.id);
177 },
178 onList = delegate
179 {
180 foreach (SourceThing.Row item in fuels)
181 {
182 list.Add(item);
183 }
184 }
185 };
186 list.List();
187 window.SetActive(enable: true);
188 window.RebuildLayout(recursive: true);
189 void AddThing(string id)
190 {
191 if (id.IsEmpty() || id == "notImplemented" || id == "any")
192 {
193 Util.Instantiate(moldUnknown, P_1.b).GetComponentInChildren<UIButton>().tooltip.lang = "???";
194 }
195 else
196 {
197 id = id.Replace("%", "@");
198 string[] array = id.Split('@');
199 string cat = "";
200 id = array[0];
201 if (id.StartsWith('#'))
202 {
203 cat = id.Replace("#", "");
204 List<CardRow> obj = EMono.sources.cards.rows.Where((CardRow r) => r.Category.IsChildOf(cat)).ToList();
205 obj.Sort((CardRow a, CardRow b) => a.value - b.value);
206 id = obj[0].id;
207 }
208 CardRow cardRow = EMono.sources.cards.map[id];
210 if (array.Length >= 2)
211 {
212 mat = ((!(array[1] == "gelatin")) ? EMono.sources.materials.alias[array[1]] : EMono.sources.materials.alias["jelly"]);
213 }
214 Transform transform = Util.Instantiate(moldThing, P_1.b);
215 Image componentInChildren = transform.GetComponentInChildren<Image>();
216 UIButton component = componentInChildren.GetComponent<UIButton>();
217 cardRow.SetImage(componentInChildren, null, cardRow.GetColorInt(mat));
218 string s = cardRow.GetName();
219 if (!cat.IsEmpty())
220 {
221 Transform obj2 = Util.Instantiate(moldCat, transform);
222 string @ref = EMono.sources.categories.map[cat].GetName();
223 obj2.GetComponentInChildren<UIText>().SetText("(" + "category".lang() + ")");
224 s = "ingCat".lang(@ref);
225 }
226 component.tooltip.lang = s.ToTitleCase();
227 }
228 }
229 }
230}
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:892
int GetColorInt(SourceMaterial.Row mat)
Definition: RenderRow.cs:422
void SetImage(Image image, Sprite sprite=null, int matCol=0, bool setNativeSize=true, int dir=0, int idSkin=0)
Definition: RenderRow.cs:351
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:36
virtual int numIng
Definition: TraitCrafter.cs:34
bool IsFuel(string s)
Definition: Trait.cs:1316
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:3556