Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
NPCPortraitInfoElement.cs
Go to the documentation of this file.
1using System;
3using System.Linq;
8using Terraria.UI;
9
11
13{
14 private int? _filledStarsCount;
15
20
22 {
24 {
25 Width = new StyleDimension(0f, 1f),
26 Height = new StyleDimension(112f, 0f)
27 };
28 uIElement.SetPadding(0f);
32 bestiaryEntry.Icon = info.OwnerEntry.Icon.CreateClone();
33 bestiaryEntry.UIInfoProvider = info.OwnerEntry.UIInfoProvider;
35 bool flag = info.UnlockState > BestiaryEntryUnlockState.NotKnownAtAll_0;
36 if (flag)
37 {
42 bool flag2 = false;
44 {
45 Asset<Texture2D> backgroundImage = item.GetBackgroundImage();
46 if (backgroundImage != null)
47 {
49 flag2 = true;
50 Color? backgroundColor = item.GetBackgroundColor();
51 if (backgroundColor.HasValue)
52 {
54 }
55 break;
56 }
57 }
58 foreach (IBestiaryInfoElement item2 in info.OwnerEntry.Info)
59 {
61 {
63 if (backgroundImage2 == null)
64 {
65 continue;
66 }
67 if (!flag2)
68 {
70 }
72 if (backgroundColor2.HasValue)
73 {
75 }
76 }
78 {
80 }
81 }
84 }
86 {
87 Left = new StyleDimension(4f, 0f),
88 HAlign = 0f
89 };
90 uIElement.Append(element);
91 if (flag && _filledStarsCount.HasValue)
92 {
94 uIElement.Append(element2);
95 }
96 return uIElement;
97 }
98
107
109 {
110 int num = 14;
111 int num2 = 14;
112 int num3 = -4;
113 int num4 = num + num3;
114 int num5 = 5;
115 int num6 = 5;
116 int value = _filledStarsCount.Value;
117 float num7 = 1f;
118 int num8 = num4 * Math.Min(num6, num5) - num3;
119 double num9 = (double)num4 * Math.Ceiling((double)num5 / (double)num6) - (double)num3;
120 UIElement uIElement = new UIPanel(Main.Assets.Request<Texture2D>("Images/UI/Bestiary/Stat_Panel", (AssetRequestMode)1), null, 5, 21)
121 {
122 Width = new StyleDimension((float)num8 + num7 * 2f, 0f),
123 Height = new StyleDimension((float)num9 + num7 * 2f, 0f),
124 BackgroundColor = Color.Gray * 0f,
125 BorderColor = Color.Transparent,
126 Left = new StyleDimension(10f, 0f),
127 Top = new StyleDimension(6f, 0f),
128 VAlign = 0f
129 };
130 uIElement.SetPadding(0f);
131 for (int num10 = num5 - 1; num10 >= 0; num10--)
132 {
133 string text = "Images/UI/Bestiary/Icon_Rank_Light";
134 if (num10 >= value)
135 {
136 text = "Images/UI/Bestiary/Icon_Rank_Dim";
137 }
138 UIImage element = new UIImage(Main.Assets.Request<Texture2D>(text, (AssetRequestMode)1))
139 {
140 Left = new StyleDimension((float)(num4 * (num10 % num6)) - (float)num8 * 0.5f + (float)num * 0.5f, 0f),
141 Top = new StyleDimension((float)(num4 * (num10 / num6)) - (float)num9 * 0.5f + (float)num2 * 0.5f, 0f),
142 HAlign = 0.5f,
143 VAlign = 0.5f
144 };
145 uIElement.Append(element);
146 }
147 return uIElement;
148 }
149}
void AddRange(IEnumerable< KeyValuePair< TKey, TValue > > collection)
void Add(TKey key, TValue value)
static byte Min(byte val1, byte val2)
Definition Math.cs:912
static double Ceiling(double a)
UIElement ProvideUIElement(BestiaryUICollectionInfo info)
float GetSortingValueForElement(IBestiaryInfoElement element)
static IAssetRepository Assets
Definition Main.cs:209
static Color Transparent
Definition Color.cs:76