Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
EmotesGroupListItem.cs
Go to the documentation of this file.
5using Terraria.UI;
6
8
10{
11 private const int TITLE_HEIGHT = 20;
12
13 private const int SEPARATOR_HEIGHT = 10;
14
15 private const int SIZE_PER_EMOTE = 36;
16
18
19 private int _groupIndex;
20
21 private int _maxEmotesPerRow = 10;
22
23 public EmotesGroupListItem(LocalizedText groupTitle, int groupIndex, int maxEmotesPerRow, params int[] emotes)
24 {
25 maxEmotesPerRow = 14;
26 SetPadding(0f);
27 _groupIndex = groupIndex;
28 _maxEmotesPerRow = maxEmotesPerRow;
29 _tempTex = Main.Assets.Request<Texture2D>("Images/UI/ButtonFavoriteInactive", (AssetRequestMode)1);
30 int num = emotes.Length / _maxEmotesPerRow;
31 if (emotes.Length % _maxEmotesPerRow != 0)
32 {
33 num++;
34 }
35 Height.Set(30 + 36 * num, 0f);
36 Width.Set(0f, 1f);
37 UIElement uIElement = new UIElement
38 {
41 HAlign = 0.5f
42 };
43 uIElement.SetPadding(0f);
44 Append(uIElement);
46 {
48 VAlign = 1f,
49 HAlign = 0.5f,
50 Color = Color.Lerp(Color.White, new Color(63, 65, 151, 255), 0.85f) * 0.9f
51 };
52 uIElement.Append(element);
53 UIText element2 = new UIText(groupTitle)
54 {
55 VAlign = 1f,
56 HAlign = 0.5f,
58 };
59 uIElement.Append(element2);
60 float num2 = 6f;
61 for (int i = 0; i < emotes.Length; i++)
62 {
63 int emoteIndex = emotes[i];
64 int num3 = i / _maxEmotesPerRow;
65 int num4 = i % _maxEmotesPerRow;
66 int num5 = emotes.Length % _maxEmotesPerRow;
67 if (emotes.Length / _maxEmotesPerRow != num3)
68 {
69 num5 = _maxEmotesPerRow;
70 }
71 if (num5 == 0)
72 {
73 num5 = _maxEmotesPerRow;
74 }
75 float num6 = 36f * ((float)num5 / 2f);
76 num6 -= 16f;
77 num6 = -16f;
78 EmoteButton emoteButton = new EmoteButton(emoteIndex)
79 {
80 HAlign = 0f,
81 VAlign = 0f,
82 Top = StyleDimension.FromPixels((float)(30 + num3 * 36) + num2),
83 Left = StyleDimension.FromPixels((float)(36 * num4) - num6)
84 };
85 Append(emoteButton);
86 emoteButton.SetSnapPoint("Group " + groupIndex, i);
87 }
88 }
89
90 public override int CompareTo(object obj)
91 {
92 if (obj is EmotesGroupListItem emotesGroupListItem)
93 {
94 return _groupIndex.CompareTo(emotesGroupListItem._groupIndex);
95 }
96 return base.CompareTo(obj);
97 }
98}
EmotesGroupListItem(LocalizedText groupTitle, int groupIndex, int maxEmotesPerRow, params int[] emotes)
static IAssetRepository Assets
Definition Main.cs:209
StyleDimension Height
Definition UIElement.cs:29
void Append(UIElement element)
Definition UIElement.cs:166
StyleDimension Left
Definition UIElement.cs:25
void SetSnapPoint(string name, int id, Vector2? anchor=null, Vector2? offset=null)
Definition UIElement.cs:122
StyleDimension Width
Definition UIElement.cs:27
void SetPadding(float pixels)
Definition UIElement.cs:361
StyleDimension Top
Definition UIElement.cs:23
static Color Lerp(Color value1, Color value2, float amount)
Definition Color.cs:491
static StyleDimension FromPixels(float pixels)
void Set(float pixels, float precent)
static StyleDimension FromPixelsAndPercent(float pixels, float percent)