Elin Modding Docs Doc
Loading...
Searching...
No Matches
Dialog.cs
1using System;
2using System.Collections.Generic;
3using UnityEngine;
4using UnityEngine.UI;
5
6// Token: 0x02000514 RID: 1300
7public class Dialog : ELayer
8{
9 // Token: 0x060022D8 RID: 8920 RVA: 0x000C2A7C File Offset: 0x000C0C7C
10 public override void OnAfterInit()
11 {
12 ELayer.ui.hud.textMouseHintRight.transform.parent.SetActive(false);
13 this.textDetail.SetActive(!this.textDetail.text.IsEmpty());
14 this.listGrid.SetActive(this.gridItems.Count > 0);
15 if (this.gridItems.Count >= 8)
16 {
17 GridLayoutGroup gridLayoutGroup = this.listGrid.layoutItems as GridLayoutGroup;
18 gridLayoutGroup.constraint = GridLayoutGroup.Constraint.FixedColumnCount;
19 gridLayoutGroup.constraintCount = 8;
20 }
21 if (this.gridItems.Count > 0)
22 {
23 this.listGrid.Clear();
24 BaseList baseList = this.listGrid;
25 UIList.Callback<GridItem, ButtonGrid> callback = new UIList.Callback<GridItem, ButtonGrid>();
26 callback.onInstantiate = delegate(GridItem a, ButtonGrid b)
27 {
28 b.SetItem(a);
29 };
30 callback.onClick = delegate(GridItem a, ButtonGrid b)
31 {
32 a.OnClick(b);
33 };
34 baseList.callbacks = callback;
35 foreach (GridItem o in this.gridItems)
36 {
37 this.listGrid.Add(o);
38 }
39 this.listGrid.Refresh(false);
40 }
41 this.list.Refresh(false);
42 this.RebuildLayout(true);
43 GraphicRaycaster g = this.windows[0].GetComponent<GraphicRaycaster>();
44 g.enabled = false;
45 TweenUtil.Delay(0.3f, delegate
46 {
47 if (g)
48 {
49 g.enabled = true;
50 }
51 });
52 if (this.input)
53 {
54 this.input.Focus();
55 }
56 EInput.WaitReleaseKey();
57 }
58
59 // Token: 0x060022D9 RID: 8921 RVA: 0x000C2C48 File Offset: 0x000C0E48
60 public void AddButton(string text, Action onClick = null, bool close = true)
61 {
62 this.list.AddButton(null, text, delegate
63 {
64 if (onClick != null)
65 {
66 onClick();
67 }
68 if (close)
69 {
70 this.Close();
71 }
72 }, null);
73 }
74
75 // Token: 0x060022DA RID: 8922 RVA: 0x000C2C8A File Offset: 0x000C0E8A
76 private void Update()
77 {
78 if (this.input && this.option.canClose && Input.GetKeyDown(KeyCode.Escape))
79 {
80 this.Close();
81 }
82 }
83
84 // Token: 0x060022DB RID: 8923 RVA: 0x000C2CB8 File Offset: 0x000C0EB8
85 public override void OnUpdateInput()
86 {
87 if (this.input && this.option.canClose && Input.GetKeyDown(KeyCode.Return))
88 {
89 this.isInputEnter = true;
90 this.Close();
91 return;
92 }
93 if (!this.input.gameObject.activeInHierarchy && this.list != null)
94 {
95 foreach (UIList.ButtonPair buttonPair in this.list.buttons)
96 {
97 UIButton uibutton = buttonPair.component as UIButton;
98 if (uibutton && uibutton.interactable && !EInput.waitReleaseAnyKey && uibutton.keyText && !uibutton.keyText.text.IsEmpty() && uibutton.keyText.text == Input.inputString)
99 {
100 uibutton.onClick.Invoke();
101 return;
102 }
103 }
104 }
105 if (this.keymap != null)
106 {
107 List<KeyCode> list = new List<KeyCode>
108 {
109 KeyCode.Mouse0,
110 KeyCode.Mouse1,
111 KeyCode.Mouse2,
112 KeyCode.Mouse3,
113 KeyCode.Mouse4,
114 KeyCode.Escape,
115 KeyCode.Return,
116 KeyCode.LeftShift,
117 KeyCode.Delete,
118 KeyCode.Backspace
119 };
120 if (Input.GetKeyDown(KeyCode.Delete))
121 {
122 if (this.keymap.required)
123 {
124 SE.Beep();
125 return;
126 }
127 SE.Tab();
128 this.keymap.key = KeyCode.None;
129 this.Close();
130 return;
131 }
132 else
133 {
134 foreach (object obj in Enum.GetValues(typeof(KeyCode)))
135 {
136 KeyCode keyCode = (KeyCode)obj;
137 if (!list.Contains(keyCode) && Input.GetKey(keyCode))
138 {
139 foreach (EInput.KeyMap keyMap in ELayer.core.config.input.keys.List())
140 {
141 if (keyMap.key == keyCode && keyMap.GetGroup() == this.keymap.GetGroup())
142 {
143 keyMap.key = this.keymap.key;
144 }
145 }
146 this.keymap.key = keyCode;
147 SE.Tab();
148 this.Close();
149 return;
150 }
151 }
152 }
153 }
154 base.OnUpdateInput();
155 }
156
157 // Token: 0x060022DC RID: 8924 RVA: 0x000C2F7C File Offset: 0x000C117C
158 public void OnEnterInput()
159 {
160 this.isInputEnter = true;
161 this.Close();
162 }
163
164 // Token: 0x060022DD RID: 8925 RVA: 0x000C2F8C File Offset: 0x000C118C
165 public override void OnKill()
166 {
167 ELayer.ui.hud.textMouseHintRight.transform.parent.SetActive(true);
168 if (this.input && this.onEnterInput != null)
169 {
170 this.onEnterInput(!this.isInputEnter, this.input.Text);
171 }
172 EInput.WaitReleaseKey();
173 }
174
175 // Token: 0x060022DE RID: 8926 RVA: 0x000C2FF4 File Offset: 0x000C11F4
176 public static Dialog CreateNarration(string idImage, string idText)
177 {
178 Dialog dialog = Layer.Create<Dialog>("DialogNarration");
179 dialog.image.SetActive(true);
180 dialog.image.sprite = Resources.Load<Sprite>("Media/Graphics/Image/Dialog/" + idImage);
181 dialog.image.SetNativeSize();
182 dialog.textDetail.SetText(IO.LoadText(CorePath.CorePackage.TextNarration + idText + ".txt"));
183 return dialog;
184 }
185
186 // Token: 0x060022DF RID: 8927 RVA: 0x000C3060 File Offset: 0x000C1260
187 public static Dialog Ok(string langDetail)
188 {
189 Dialog dialog = Layer.Create<Dialog>();
190 dialog.textDetail.SetText(langDetail.lang() + " ");
191 dialog.list.AddButton(null, Lang.Get("ok"), new Action(dialog.Close), null);
192 ELayer.ui.AddLayer(dialog);
193 return dialog;
194 }
195
196 // Token: 0x060022E0 RID: 8928 RVA: 0x000C30C0 File Offset: 0x000C12C0
197 public static Dialog Choice(string langDetail, Action<Dialog> action)
198 {
199 Dialog dialog = Layer.Create<Dialog>();
200 dialog.textDetail.SetText(langDetail.lang() + " ");
201 action(dialog);
202 ELayer.ui.AddLayer(dialog);
203 return dialog;
204 }
205
206 // Token: 0x060022E1 RID: 8929 RVA: 0x000C3104 File Offset: 0x000C1304
207 public static Dialog YesNo(string langDetail, Action actionYes, Action actionNo = null, string langYes = "yes", string langNo = "no")
208 {
209 Dialog d = Layer.Create<Dialog>();
210 d.textDetail.SetText(langDetail.lang() + " ");
211 d.list.AddButton(null, Lang.Get(langYes), delegate
212 {
213 if (actionYes != null)
214 {
215 actionYes();
216 }
217 d.Close();
218 }, null);
219 d.list.AddButton(null, Lang.Get(langNo), delegate
220 {
221 if (actionNo != null)
222 {
223 actionNo();
224 }
225 d.Close();
226 }, null);
227 ELayer.ui.AddLayer(d);
228 return d;
229 }
230
231 // Token: 0x060022E2 RID: 8930 RVA: 0x000C31B0 File Offset: 0x000C13B0
232 public static Dialog List<TValue>(string langDetail, ICollection<TValue> items, Func<TValue, string> getString, Func<int, string, bool> onSelect, bool canCancel = false)
233 {
234 Dialog d = Layer.Create<Dialog>();
235 d.textDetail.SetText(langDetail.lang() + " ");
236 int num = 0;
237 using (IEnumerator<TValue> enumerator = items.GetEnumerator())
238 {
239 while (enumerator.MoveNext())
240 {
241 TValue item = enumerator.Current;
242 int _i = num;
243 d.list.AddButton(null, getString(item).lang(), delegate
244 {
245 if (onSelect(_i, getString(item)))
246 {
247 d.Close();
248 }
249 }, null);
250 num++;
251 }
252 }
253 d.option.canClose = canCancel;
254 ELayer.ui.AddLayer(d);
255 return d;
256 }
257
258 // Token: 0x060022E3 RID: 8931 RVA: 0x000C32B8 File Offset: 0x000C14B8
259 private static void TryWarn(string lang, Action action)
260 {
261 Dialog d = Layer.Create<Dialog>();
262 d.textDetail.SetText(lang.lang() + " ");
263 d.SetOnKill(delegate
264 {
265 ELayer.core.actionsNextFrame.Add(delegate
266 {
267 ActPlan.warning = false;
268 });
269 });
270 d.list.AddButton(null, Lang.Get("yes"), delegate
271 {
272 d.Close();
273 base.<TryWarn>g__Commit|0();
274 }, null);
275 d.list.AddButton(null, Lang.Get("yes_dontask"), delegate
276 {
277 string lang2 = lang;
278 if (!(lang2 == "warn_crime"))
279 {
280 if (!(lang2 == "warn_mana"))
281 {
282 if (lang2 == "warn_disassemble")
283 {
284 ELayer.core.config.game.ignoreWarnDisassemble = true;
285 }
286 }
287 else
288 {
289 ELayer.core.config.game.ignoreWarnMana = true;
290 }
291 }
292 else
293 {
294 ELayer.core.config.game.ignoreWarnCrime = true;
295 }
296 d.Close();
297 base.<TryWarn>g__Commit|0();
298 }, null);
299 d.list.AddButton(null, Lang.Get("no"), delegate
300 {
301 d.Close();
302 }, null);
303 ELayer.ui.AddLayer(d);
304 }
305
306 // Token: 0x060022E4 RID: 8932 RVA: 0x000C33C0 File Offset: 0x000C15C0
307 public static void TryWarnCrime(Action action)
308 {
309 if (!ELayer.core.config.game.warnCrime || ELayer.core.config.game.ignoreWarnCrime)
310 {
311 Dialog.warned = true;
312 action();
313 Dialog.warned = false;
314 ActPlan.warning = false;
315 return;
316 }
317 Dialog.TryWarn("warn_crime", action);
318 }
319
320 // Token: 0x060022E5 RID: 8933 RVA: 0x000C3420 File Offset: 0x000C1620
321 public static void TryWarnMana(Action action)
322 {
323 if (!ELayer.core.config.game.warnMana || ELayer.core.config.game.ignoreWarnMana)
324 {
325 Dialog.warned = true;
326 action();
327 Dialog.warned = false;
328 ActPlan.warning = false;
329 return;
330 }
331 Dialog.TryWarn("warn_mana", action);
332 }
333
334 // Token: 0x060022E6 RID: 8934 RVA: 0x000C3480 File Offset: 0x000C1680
335 public static void TryWarnDisassemble(Action action)
336 {
337 if (!ELayer.core.config.game.warnDisassemble || ELayer.core.config.game.ignoreWarnDisassemble)
338 {
339 Dialog.warned = true;
340 action();
341 Dialog.warned = false;
342 return;
343 }
344 Dialog.TryWarn("warn_disassemble", action);
345 }
346
347 // Token: 0x060022E7 RID: 8935 RVA: 0x000C34D7 File Offset: 0x000C16D7
348 public static Dialog Gift(string langHeader, bool autoAdd, params Card[] cards)
349 {
350 return Dialog.Gift(langHeader, autoAdd, new List<Card>(cards));
351 }
352
353 // Token: 0x060022E8 RID: 8936 RVA: 0x000C34E8 File Offset: 0x000C16E8
354 public static Dialog Gift(string langHeader, bool autoAdd, List<Card> list)
355 {
356 List<GridItem> list2 = new List<GridItem>();
357 foreach (Card c in list)
358 {
359 list2.Add(new GridItemCard
360 {
361 c = c
362 });
363 }
364 return Dialog.Gift(langHeader, autoAdd, list2);
365 }
366
367 // Token: 0x060022E9 RID: 8937 RVA: 0x000C3550 File Offset: 0x000C1750
368 public static Dialog Gift(string langHeader, bool autoAdd, List<GridItem> list)
369 {
370 Dialog d = Layer.Create<Dialog>();
371 d.spacer.SetActive(false);
372 d.note.AddHeader(langHeader.IsEmpty("headerGift").lang(), null);
373 d.list.AddButton(null, Lang.Get("ok"), delegate
374 {
375 if (autoAdd)
376 {
377 foreach (GridItem gridItem in list)
378 {
379 gridItem.AutoAdd();
380 }
381 }
382 d.Close();
383 }, null);
384 d.option.soundActivate = null;
385 d.option.canClose = false;
386 d.gridItems = list;
387 ELayer.Sound.Play("good");
388 ELayer.ui.AddLayer(d);
389 return d;
390 }
391
392 // Token: 0x060022EA RID: 8938 RVA: 0x000C3634 File Offset: 0x000C1834
393 public static Dialog Recipe(List<RecipeSource> list)
394 {
395 Dialog d = Layer.Create<Dialog>();
396 d.spacer.SetActive(false);
397 d.note.AddHeader("giftRecipe".lang(), null);
398 d.list.AddButton(null, Lang.Get("ok"), delegate
399 {
400 d.Close();
401 }, null);
402 d.option.soundActivate = null;
403 for (int i = 0; i < list.Count; i++)
404 {
405 RecipeSource recipeSource = list[i];
406 List<Recipe.Ingredient> ingredients = recipeSource.GetIngredients();
407 if (ingredients.Count > 0 && ELayer.sources.cards.map.ContainsKey(ingredients[0].id))
408 {
409 ELayer.sources.cards.map[ingredients[0].id].GetName();
410 }
411 d.note.AddText("・" + recipeSource.Name.ToTitleCase(false), FontColor.DontChange);
412 if (i >= 9 && list.Count > 10)
413 {
414 d.note.Space(6, 1);
415 d.note.AddText("moreRecipes".lang((list.Count - 10).ToString() ?? "", null, null, null, null), FontColor.DontChange);
416 break;
417 }
418 }
419 d.SetOnKill(new Action(SE.Click));
420 ELayer.Sound.Play("idea");
421 ELayer.ui.AddLayer(d);
422 return d;
423 }
424
425 // Token: 0x060022EB RID: 8939 RVA: 0x000C37F4 File Offset: 0x000C19F4
426 public static Dialog Confetti(string langTitle, string langDetail, string langConfetti = "Grats!")
427 {
428 ELayer.Sound.Play("confetti");
429 return Dialog._Confetti("DialogConfetti", langTitle, langDetail, langConfetti);
430 }
431
432 // Token: 0x060022EC RID: 8940 RVA: 0x000C3813 File Offset: 0x000C1A13
433 public static Dialog ConfettiSimple(string langTitle, string langDetail, string langConfetti = "Grats!")
434 {
435 ELayer.Sound.Play("confettiSimple");
436 return Dialog._Confetti("DialogConfettiSimple", langTitle, langDetail, langConfetti);
437 }
438
439 // Token: 0x060022ED RID: 8941 RVA: 0x000C3834 File Offset: 0x000C1A34
440 public static Dialog _Confetti(string idPrefab, string langTitle, string langDetail, string langConfetti = "Grats!")
441 {
442 Dialog d = Layer.Create(idPrefab) as Dialog;
443 d.textConfetti.text = langConfetti.lang();
444 d.textDetail.SetText(langDetail.lang());
445 d.list.AddButton(null, Lang.Get("ok"), delegate
446 {
447 d.Close();
448 }, null);
449 ELayer.ui.AddLayer(d);
450 return d;
451 }
452
453 // Token: 0x060022EE RID: 8942 RVA: 0x000C38C4 File Offset: 0x000C1AC4
454 public static Dialog Keymap(EInput.KeyMap keymap)
455 {
456 Dialog dialog = Layer.Create<Dialog>("DialogKeymap");
457 dialog.textDetail.SetText("dialog_keymap".lang(("key_" + keymap.action.ToString()).lang(), null, null, null, null));
458 dialog.keymap = keymap;
459 ELayer.ui.AddLayer(dialog);
460 return dialog;
461 }
462
463 // Token: 0x060022EF RID: 8943 RVA: 0x000C392C File Offset: 0x000C1B2C
464 public static Dialog InputName(string langDetail, string text, Action<bool, string> onClose, Dialog.InputType inputType = Dialog.InputType.Default)
465 {
466 Dialog d = Layer.Create<Dialog>("DialogInput");
467 d.inputType = inputType;
468 d.langHint = langDetail;
469 d.input.Text = text;
470 d.note.AddText(langDetail.lang(), FontColor.DontChange).text1.alignment = TextAnchor.MiddleCenter;
471 if (inputType == Dialog.InputType.Password)
472 {
473 d.input.field.characterLimit = 8;
474 d.input.field.contentType = InputField.ContentType.Alphanumeric;
475 }
476 d.onEnterInput = onClose;
477 d.list.AddButton(null, Lang.Get("ok"), delegate
478 {
479 onClose(false, d.input.Text);
480 d.Close();
481 }, null);
482 d.list.AddButton(null, Lang.Get("cancel"), delegate
483 {
484 onClose(true, "");
485 d.Close();
486 }, null);
487 ELayer.ui.AddLayer(d);
488 return d;
489 }
490
491 // Token: 0x04001240 RID: 4672
492 public Text textConfetti;
493
494 // Token: 0x04001241 RID: 4673
495 public Image image;
496
497 // Token: 0x04001242 RID: 4674
498 public UIText textDetail;
499
500 // Token: 0x04001243 RID: 4675
501 public UINote note;
502
503 // Token: 0x04001244 RID: 4676
504 public UIButtonList list;
505
506 // Token: 0x04001245 RID: 4677
507 public LayoutGroup layout;
508
509 // Token: 0x04001246 RID: 4678
510 public ScreenEffect effect;
511
512 // Token: 0x04001247 RID: 4679
513 public UIList listGrid;
514
515 // Token: 0x04001248 RID: 4680
516 public Transform spacer;
517
518 // Token: 0x04001249 RID: 4681
519 public List<GridItem> gridItems = new List<GridItem>();
520
521 // Token: 0x0400124A RID: 4682
522 public UIInputText input;
523
524 // Token: 0x0400124B RID: 4683
525 public Dialog.InputType inputType;
526
527 // Token: 0x0400124C RID: 4684
528 [NonSerialized]
529 public EInput.KeyMap keymap;
530
531 // Token: 0x0400124D RID: 4685
532 [NonSerialized]
533 public bool isInputEnter;
534
535 // Token: 0x0400124E RID: 4686
536 public Action<bool, string> onEnterInput;
537
538 // Token: 0x0400124F RID: 4687
539 public static bool warned;
540
541 // Token: 0x02000A19 RID: 2585
542 public enum InputType
543 {
544 // Token: 0x040029A2 RID: 10658
545 None,
546 // Token: 0x040029A3 RID: 10659
547 Default,
548 // Token: 0x040029A4 RID: 10660
549 Password
550 }
551}
Definition Card.cs:13