Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
FlavorTextBestiaryInfoElement.cs
Go to the documentation of this file.
6using Terraria.UI;
7
9
11{
12 private string _key;
13
14 public FlavorTextBestiaryInfoElement(string languageKey)
15 {
16 _key = languageKey;
17 }
18
20 {
21 if (info.UnlockState < BestiaryEntryUnlockState.CanShowStats_2)
22 {
23 return null;
24 }
25 UIPanel obj = new UIPanel(Main.Assets.Request<Texture2D>("Images/UI/Bestiary/Stat_Panel", (AssetRequestMode)1), null, 12, 7)
26 {
27 Width = new StyleDimension(-11f, 1f),
28 Height = new StyleDimension(109f, 0f),
29 BackgroundColor = new Color(43, 56, 101),
30 BorderColor = Color.Transparent,
31 Left = new StyleDimension(3f, 0f),
32 PaddingLeft = 4f,
33 PaddingRight = 4f
34 };
35 UIText uIText = new UIText(Language.GetText(_key), 0.8f)
36 {
37 HAlign = 0f,
38 VAlign = 0f,
40 Height = StyleDimension.FromPixelsAndPercent(0f, 1f),
41 IsWrapped = true
42 };
43 AddDynamicResize(obj, uIText);
44 obj.Append(uIText);
45 return obj;
46 }
47
48 private static void AddDynamicResize(UIElement container, UIText text)
49 {
50 text.OnInternalTextChange += delegate
51 {
52 container.Height = new StyleDimension(text.MinHeight.Pixels, 0f);
53 };
54 }
55}
static LocalizedText GetText(string key)
Definition Language.cs:10
static IAssetRepository Assets
Definition Main.cs:209
static Color Transparent
Definition Color.cs:76
static StyleDimension FromPixelsAndPercent(float pixels, float percent)