Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
UIEmotesMenu.cs
Go to the documentation of this file.
1using System;
3using System.Linq;
9using Terraria.ID;
11using Terraria.UI;
13
15
16public class UIEmotesMenu : UIState
17{
19
21
23
24 private UIList _list;
25
27
29
30 public override void OnActivate()
31 {
33 if (Main.gameMenu)
34 {
35 _outerContainer.Top.Set(220f, 0f);
36 _outerContainer.Height.Set(-220f, 1f);
37 }
38 else
39 {
40 _outerContainer.Top.Set(120f, 0f);
41 _outerContainer.Height.Set(-120f, 1f);
42 }
43 }
44
45 public void InitializePage()
46 {
49 uIElement.Width.Set(590f, 0f);
50 uIElement.Top.Set(220f, 0f);
51 uIElement.Height.Set(-220f, 1f);
52 uIElement.HAlign = 0.5f;
55 UIPanel uIPanel = new UIPanel();
56 uIPanel.Width.Set(0f, 1f);
57 uIPanel.Height.Set(-110f, 1f);
58 uIPanel.BackgroundColor = new Color(33, 43, 79) * 0.8f;
59 uIPanel.PaddingTop = 0f;
60 uIElement.Append(uIPanel);
62 UIList uIList = new UIList();
63 uIList.Width.Set(-25f, 1f);
64 uIList.Height.Set(-50f, 1f);
65 uIList.Top.Set(50f, 0f);
66 uIList.HAlign = 0.5f;
67 uIList.ListPadding = 14f;
68 uIPanel.Append(uIList);
69 _list = uIList;
71 uIScrollbar.SetView(100f, 1000f);
72 uIScrollbar.Height.Set(-20f, 1f);
73 uIScrollbar.HAlign = 1f;
74 uIScrollbar.VAlign = 1f;
75 uIScrollbar.Top = StyleDimension.FromPixels(-5f);
76 uIList.SetScrollbar(uIScrollbar);
79 uITextPanel.Width.Set(-10f, 0.5f);
80 uITextPanel.Height.Set(50f, 0f);
81 uITextPanel.VAlign = 1f;
82 uITextPanel.HAlign = 0.5f;
83 uITextPanel.Top.Set(-45f, 0f);
84 uITextPanel.OnMouseOver += FadedMouseOver;
85 uITextPanel.OnMouseOut += FadedMouseOut;
86 uITextPanel.OnLeftClick += GoBackClick;
87 uITextPanel.SetSnapPoint("Back", 0);
88 uIElement.Append(uITextPanel);
90 int currentGroupIndex = 0;
91 TryAddingList(Language.GetText("UI.EmoteCategoryGeneral"), ref currentGroupIndex, 10, GetEmotesGeneral());
92 TryAddingList(Language.GetText("UI.EmoteCategoryRPS"), ref currentGroupIndex, 10, GetEmotesRPS());
93 TryAddingList(Language.GetText("UI.EmoteCategoryItems"), ref currentGroupIndex, 11, GetEmotesItems());
94 TryAddingList(Language.GetText("UI.EmoteCategoryBiomesAndEvents"), ref currentGroupIndex, 8, GetEmotesBiomesAndEvents());
95 TryAddingList(Language.GetText("UI.EmoteCategoryTownNPCs"), ref currentGroupIndex, 9, GetEmotesTownNPCs());
96 TryAddingList(Language.GetText("UI.EmoteCategoryCritters"), ref currentGroupIndex, 7, GetEmotesCritters());
97 TryAddingList(Language.GetText("UI.EmoteCategoryBosses"), ref currentGroupIndex, 8, GetEmotesBosses());
98 }
99
107
109 {
110 return new List<int>
111 {
112 0, 1, 2, 3, 15, 136, 94, 16, 135, 134,
113 137, 138, 139, 17, 87, 88, 89, 91, 92, 93,
114 8, 9, 10, 11, 14, 100, 146, 147, 148
115 };
116 }
117
119 {
120 return new List<int> { 36, 37, 38, 33, 34, 35 };
121 }
122
124 {
125 return new List<int>
126 {
127 7, 73, 74, 75, 76, 131, 77, 78, 79, 80,
128 81, 82, 83, 84, 85, 86, 90, 132, 126, 127,
129 128, 129, 149
130 };
131 }
132
134 {
135 return new List<int>
136 {
137 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
138 32, 18, 19, 20, 21, 99, 4, 5, 6, 95,
139 96, 97, 98
140 };
141 }
142
144 {
145 return new List<int>
146 {
147 101, 102, 103, 104, 105, 106, 107, 108, 109, 110,
148 111, 112, 113, 114, 115, 116, 117, 118, 119, 120,
149 121, 122, 123, 124, 125, 130, 140, 141, 142, 145
150 };
151 }
152
154 {
155 List<int> list = new List<int>();
156 list.AddRange(new int[5] { 12, 13, 61, 62, 63 });
157 list.AddRange(new int[4] { 67, 68, 69, 70 });
158 list.Add(72);
159 if (NPC.downedGoblins)
160 {
161 list.Add(64);
162 }
163 if (NPC.downedFrost)
164 {
165 list.Add(66);
166 }
167 if (NPC.downedPirates)
168 {
169 list.Add(65);
170 }
172 {
173 list.Add(71);
174 }
175 return list;
176 }
177
179 {
180 List<int> list = new List<int>();
181 if (NPC.downedBoss1)
182 {
183 list.Add(39);
184 }
185 if (NPC.downedBoss2)
186 {
187 list.Add(40);
188 list.Add(41);
189 }
191 {
192 list.Add(51);
193 }
195 {
196 list.Add(150);
197 }
199 {
200 list.Add(42);
201 }
202 if (NPC.downedBoss3)
203 {
204 list.Add(43);
205 }
206 if (Main.hardMode)
207 {
208 list.Add(44);
209 }
211 {
212 list.Add(144);
213 }
215 {
216 list.Add(45);
217 }
219 {
220 list.Add(46);
221 }
223 {
224 list.Add(47);
225 }
227 {
228 list.Add(48);
229 }
231 {
232 list.Add(49);
233 }
234 if (NPC.downedFishron)
235 {
236 list.Add(50);
237 }
239 {
240 list.Add(143);
241 }
243 {
244 list.Add(52);
245 }
247 {
248 list.Add(53);
249 }
251 {
252 list.Add(54);
253 }
255 {
256 list.Add(55);
257 }
259 {
260 list.Add(56);
261 }
263 {
264 list.Add(57);
265 }
267 {
268 list.Add(58);
269 }
270 if (NPC.downedPirates)
271 {
272 list.Add(59);
273 }
275 {
276 list.Add(60);
277 }
279 {
280 list.Add(133);
281 }
282 return list;
283 }
284
285 public override void Recalculate()
286 {
287 if (_scrollBar != null)
288 {
290 {
292 _isScrollbarAttached = false;
293 _list.Width.Set(0f, 1f);
294 }
296 {
299 _list.Width.Set(-25f, 1f);
300 }
301 }
302 base.Recalculate();
303 }
304
306 {
307 Main.menuMode = 0;
309 }
310
312 {
314 ((UIPanel)evt.Target).BackgroundColor = new Color(73, 94, 171);
315 ((UIPanel)evt.Target).BorderColor = Colors.FancyUIFatButtonMouseOver;
316 }
317
319 {
320 ((UIPanel)evt.Target).BackgroundColor = new Color(63, 82, 151) * 0.8f;
321 ((UIPanel)evt.Target).BorderColor = Color.Black;
322 }
323
324 public override void Draw(SpriteBatch spriteBatch)
325 {
326 base.Draw(spriteBatch);
327 SetupGamepadPoints2(spriteBatch);
328 }
329
330 private void SetupGamepadPoints2(SpriteBatch spriteBatch)
331 {
332 int num = 7;
333 UILinkPointNavigator.Shortcuts.BackButtonCommand = 1;
334 int num2;
335 int iD = (num2 = 3001);
340 uILinkPoint.Unlink();
341 uILinkPoint.Up = num2 + 1;
343 num2++;
344 int num3 = 0;
346 for (int i = 0; i < num; i++)
347 {
349 if (emoteGroup.Count > 0)
350 {
351 list.Add(emoteGroup);
352 }
353 num3 += (int)Math.Ceiling((float)emoteGroup.Count / 14f);
354 }
355 SnapPoint[,] array = new SnapPoint[14, num3];
356 int num4 = 0;
357 for (int j = 0; j < list.Count; j++)
358 {
360 for (int k = 0; k < list2.Count; k++)
361 {
362 int num5 = num4 + k / 14;
363 int num6 = k % 14;
364 array[num6, num5] = list2[k];
365 }
366 num4 += (int)Math.Ceiling((float)list2.Count / 14f);
367 }
368 int[,] array2 = new int[14, num3];
369 int up = 0;
370 for (int l = 0; l < array.GetLength(1); l++)
371 {
372 for (int m = 0; m < array.GetLength(0); m++)
373 {
375 if (snapPoint != null)
376 {
379 array2[m, l] = num2;
380 if (m == 0)
381 {
382 up = num2;
383 }
384 num2++;
385 }
386 }
387 }
388 uILinkPoint2.Up = up;
389 for (int n = 0; n < array.GetLength(1); n++)
390 {
391 for (int num7 = 0; num7 < array.GetLength(0); num7++)
392 {
393 int num8 = array2[num7, n];
394 if (num8 == 0)
395 {
396 continue;
397 }
399 if (TryGetPointOnGrid(array2, num7, n, -1, 0))
400 {
401 uILinkPoint3.Left = array2[num7 - 1, n];
402 }
403 else
404 {
405 uILinkPoint3.Left = uILinkPoint3.ID;
406 for (int num9 = num7; num9 < array.GetLength(0); num9++)
407 {
408 if (TryGetPointOnGrid(array2, num9, n, 0, 0))
409 {
410 uILinkPoint3.Left = array2[num9, n];
411 }
412 }
413 }
414 if (TryGetPointOnGrid(array2, num7, n, 1, 0))
415 {
416 uILinkPoint3.Right = array2[num7 + 1, n];
417 }
418 else
419 {
420 uILinkPoint3.Right = uILinkPoint3.ID;
421 for (int num10 = num7; num10 >= 0; num10--)
422 {
423 if (TryGetPointOnGrid(array2, num10, n, 0, 0))
424 {
425 uILinkPoint3.Right = array2[num10, n];
426 }
427 }
428 }
429 if (TryGetPointOnGrid(array2, num7, n, 0, -1))
430 {
431 uILinkPoint3.Up = array2[num7, n - 1];
432 }
433 else
434 {
435 uILinkPoint3.Up = uILinkPoint3.ID;
436 for (int num11 = n - 1; num11 >= 0; num11--)
437 {
438 if (TryGetPointOnGrid(array2, num7, num11, 0, 0))
439 {
440 uILinkPoint3.Up = array2[num7, num11];
441 break;
442 }
443 }
444 }
445 if (TryGetPointOnGrid(array2, num7, n, 0, 1))
446 {
447 uILinkPoint3.Down = array2[num7, n + 1];
448 continue;
449 }
450 uILinkPoint3.Down = uILinkPoint3.ID;
451 for (int num12 = n + 1; num12 < array.GetLength(1); num12++)
452 {
453 if (TryGetPointOnGrid(array2, num7, num12, 0, 0))
454 {
455 uILinkPoint3.Down = array2[num7, num12];
456 break;
457 }
458 }
459 if (uILinkPoint3.Down == uILinkPoint3.ID)
460 {
461 uILinkPoint3.Down = uILinkPoint2.ID;
462 }
463 }
464 }
465 }
466
467 private bool TryGetPointOnGrid(int[,] grid, int x, int y, int offsetX, int offsetY)
468 {
469 if (x + offsetX < 0)
470 {
471 return false;
472 }
473 if (x + offsetX >= grid.GetLength(0))
474 {
475 return false;
476 }
477 if (y + offsetY < 0)
478 {
479 return false;
480 }
481 if (y + offsetY >= grid.GetLength(1))
482 {
483 return false;
484 }
485 if (grid[x + offsetX, y + offsetY] == 0)
486 {
487 return false;
488 }
489 return true;
490 }
491
493 {
494 float num = 1f / Main.UIScale;
496 Vector2 minimum = clippingRectangle.TopLeft() * num;
497 Vector2 maximum = clippingRectangle.BottomRight() * num;
498 for (int i = 0; i < pts.Count; i++)
499 {
500 if (!pts[i].Position.Between(minimum, maximum))
501 {
502 pts.Remove(pts[i]);
503 i--;
504 }
505 }
506 }
507
508 private void SetupGamepadPoints(SpriteBatch spriteBatch)
509 {
510 UILinkPointNavigator.Shortcuts.BackButtonCommand = 1;
511 int num = 3001;
512 int num2 = num;
516 uILinkPoint.Unlink();
517 uILinkPoint.Up = num2 + 1;
519 num2++;
520 float num3 = 1f / Main.UIScale;
523 Vector2 maximum = clippingRectangle.BottomRight() * num3;
524 for (int i = 0; i < snapPoints.Count; i++)
525 {
526 if (!snapPoints[i].Position.Between(minimum, maximum))
527 {
529 i--;
530 }
531 }
532 int num4 = 0;
533 int num5 = 0;
534 int num6 = 7;
536 for (int j = 0; j < num6; j++)
537 {
539 if (emoteGroup.Count > 0)
540 {
541 list.Add(emoteGroup);
542 }
543 }
544 List<SnapPoint>[] array = list.ToArray();
545 for (int k = 0; k < array.Length; k++)
546 {
548 int num7 = list2.Count / 14;
549 if (list2.Count % 14 > 0)
550 {
551 num7++;
552 }
553 int num8 = 14;
554 if (list2.Count % 14 != 0)
555 {
556 num8 = list2.Count % 14;
557 }
558 for (int l = 0; l < list2.Count; l++)
559 {
561 uILinkPoint.Unlink();
563 int num9 = 14;
564 if (l / 14 == num7 - 1 && list2.Count % 14 != 0)
565 {
566 num9 = list2.Count % 14;
567 }
568 int num10 = l % 14;
569 uILinkPoint.Left = num2 - 1;
570 uILinkPoint.Right = num2 + 1;
571 uILinkPoint.Up = num2 - 14;
572 uILinkPoint.Down = num2 + 14;
573 if (num10 == num9 - 1)
574 {
575 uILinkPoint.Right = num2 - num9 + 1;
576 }
577 if (num10 == 0)
578 {
579 uILinkPoint.Left = num2 + num9 - 1;
580 }
581 if (num10 == 0)
582 {
583 uILinkPoint2.Up = num2;
584 }
585 if (l < 14)
586 {
587 if (num4 == 0)
588 {
589 uILinkPoint.Up = -1;
590 }
591 else
592 {
593 uILinkPoint.Up = num2 - 14;
594 if (num10 >= num4)
595 {
596 uILinkPoint.Up -= 14;
597 }
598 int num11 = k - 1;
599 while (num11 > 0 && array[num11].Count <= num10)
600 {
601 uILinkPoint.Up -= 14;
602 num11--;
603 }
604 }
605 }
606 int down = num;
607 if (k == array.Length - 1)
608 {
609 if (l / 14 < num7 - 1 && num10 >= list2.Count % 14)
610 {
611 uILinkPoint.Down = down;
612 }
613 if (l / 14 == num7 - 1)
614 {
615 uILinkPoint.Down = down;
616 }
617 }
618 else if (l / 14 == num7 - 1)
619 {
620 uILinkPoint.Down = num2 + 14;
621 for (int m = k + 1; m < array.Length && array[m].Count <= num10; m++)
622 {
623 uILinkPoint.Down += 14;
624 }
625 if (k == array.Length - 1)
626 {
627 uILinkPoint.Down = down;
628 }
629 }
630 else if (num10 >= num8)
631 {
632 uILinkPoint.Down = num2 + 14 + 14;
633 for (int n = k + 1; n < array.Length && array[n].Count <= num10; n++)
634 {
635 uILinkPoint.Down += 14;
636 }
637 }
638 num2++;
639 }
640 num4 = num8;
641 num5 = 14 - num4;
642 num2 += num5;
643 }
644 }
645
647 {
648 string groupName = "Group " + groupIndex;
649 List<SnapPoint> list = ptsOnPage.Where((SnapPoint a) => a.Name == groupName).ToList();
650 list.Sort(SortPoints);
651 return list;
652 }
653
655 {
656 return a.Id.CompareTo(b.Id);
657 }
658}
bool ICollection< KeyValuePair< TKey, TValue > >. Remove(KeyValuePair< TKey, TValue > keyValuePair)
static double Ceiling(double a)
static void PlaySound(int type, Vector2 position, int style=1)
virtual void Add(UIElement item)
Definition UIList.cs:82
void FadedMouseOut(UIMouseEvent evt, UIElement listeningElement)
void SetupGamepadPoints(SpriteBatch spriteBatch)
bool TryGetPointOnGrid(int[,] grid, int x, int y, int offsetX, int offsetY)
void FadedMouseOver(UIMouseEvent evt, UIElement listeningElement)
int SortPoints(SnapPoint a, SnapPoint b)
void GoBackClick(UIMouseEvent evt, UIElement listeningElement)
override void Draw(SpriteBatch spriteBatch)
List< SnapPoint > GetEmoteGroup(List< SnapPoint > ptsOnPage, int groupIndex)
void SetupGamepadPoints2(SpriteBatch spriteBatch)
void TryAddingList(LocalizedText title, ref int currentGroupIndex, int maxEmotesPerRow, List< int > emoteIds)
void RemoveSnapPointsOutOfScreen(SpriteBatch spriteBatch, List< SnapPoint > pts)
static readonly Color FancyUIFatButtonMouseOver
Definition Colors.cs:91
static LocalizedText GetText(string key)
Definition Language.cs:10
static float UIScale
Definition Main.cs:2624
static bool gameMenu
Definition Main.cs:1926
static bool hardMode
Definition Main.cs:1022
static bool downedChristmasSantank
Definition NPC.cs:379
static bool downedFrost
Definition NPC.cs:357
static bool downedMechBoss2
Definition NPC.cs:425
static bool downedFishron
Definition NPC.cs:369
static bool downedBoss2
Definition NPC.cs:347
static bool downedEmpressOfLight
Definition NPC.cs:393
static bool downedHalloweenKing
Definition NPC.cs:373
static bool downedBoss1
Definition NPC.cs:345
static bool downedSlimeKing
Definition NPC.cs:353
static bool downedMechBoss3
Definition NPC.cs:427
static bool downedPirates
Definition NPC.cs:359
static bool downedMoonlord
Definition NPC.cs:383
static bool downedQueenBee
Definition NPC.cs:351
static bool downedHalloweenTree
Definition NPC.cs:371
static bool downedChristmasTree
Definition NPC.cs:377
static bool downedGoblins
Definition NPC.cs:355
static bool downedGolemBoss
Definition NPC.cs:365
static bool downedMartians
Definition NPC.cs:367
static bool downedChristmasIceQueen
Definition NPC.cs:375
static bool downedAncientCultist
Definition NPC.cs:381
static bool downedBoss3
Definition NPC.cs:349
static bool downedPlantBoss
Definition NPC.cs:363
static bool downedMechBoss1
Definition NPC.cs:423
static bool downedDeerclops
Definition NPC.cs:397
static bool downedQueenSlime
Definition NPC.cs:395
static Dictionary< int, UILinkPoint > Points
static void SetPosition(int ID, Vector2 Position)
StyleDimension Height
Definition UIElement.cs:29
void Append(UIElement element)
Definition UIElement.cs:166
CalculatedStyle GetInnerDimensions()
Definition UIElement.cs:377
StyleDimension Width
Definition UIElement.cs:27
void RemoveChild(UIElement child)
Definition UIElement.cs:182
virtual List< SnapPoint > GetSnapPoints()
Definition UIElement.cs:267
StyleDimension Top
Definition UIElement.cs:23
Rectangle GetClippingRectangle(SpriteBatch spriteBatch)
Definition UIElement.cs:246
static StyleDimension FromPixels(float pixels)
void Set(float pixels, float precent)