Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
UnlockProgressDisplayBestiaryInfoElement.cs
Go to the documentation of this file.
5using Terraria.UI;
6
8
10{
12
14
16
18 {
19 _progressReport = progressReport;
20 }
21
23 {
24 UIElement uIElement = new UIPanel(Main.Assets.Request<Texture2D>("Images/UI/Bestiary/Stat_Panel", (AssetRequestMode)1), null, 12, 7)
25 {
26 Width = new StyleDimension(-11f, 1f),
27 Height = new StyleDimension(109f, 0f),
28 BackgroundColor = new Color(43, 56, 101),
29 BorderColor = Color.Transparent,
30 Left = new StyleDimension(3f, 0f)
31 };
32 uIElement.PaddingLeft = 4f;
33 uIElement.PaddingRight = 4f;
34 string arg = Utils.PrettifyPercentDisplay((float)info.UnlockState / 4f, "P2");
35 string text = $"{arg} Entry Collected";
37 string text2 = $"{arg2} Bestiary Collected";
38 int num = 8;
39 UIText uIText = new UIText(text, 0.8f)
40 {
41 HAlign = 0f,
42 VAlign = 0f,
44 Height = StyleDimension.FromPixelsAndPercent(0f, 1f),
45 IsWrapped = true,
46 PaddingTop = -num,
47 PaddingBottom = -num
48 };
49 UIText uIText2 = new UIText(text2, 0.8f)
50 {
51 HAlign = 0f,
52 VAlign = 0f,
54 Height = StyleDimension.FromPixelsAndPercent(0f, 1f),
55 IsWrapped = true,
56 PaddingTop = -num,
57 PaddingBottom = -num
58 };
59 _text1 = uIText;
60 _text2 = uIText2;
61 AddDynamicResize(uIElement, uIText);
62 uIElement.Append(uIText);
63 uIElement.Append(uIText2);
64 return uIElement;
65 }
66
67 private void AddDynamicResize(UIElement container, UIText text)
68 {
69 text.OnInternalTextChange += delegate
70 {
71 container.Height = new StyleDimension(_text1.MinHeight.Pixels + 4f + _text2.MinHeight.Pixels, 0f);
72 _text2.Top = new StyleDimension(_text1.MinHeight.Pixels + 4f, 0f);
73 };
74 }
75}
static IAssetRepository Assets
Definition Main.cs:209
void Append(UIElement element)
Definition UIElement.cs:166
StyleDimension MinHeight
Definition UIElement.cs:37
static string PrettifyPercentDisplay(float percent, string originalFormat)
Definition Utils.cs:717
static Color Transparent
Definition Color.cs:76
static StyleDimension FromPixelsAndPercent(float pixels, float percent)