Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
FilterProviderInfoElement.cs
Go to the documentation of this file.
6using Terraria.UI;
7
9
11{
12 private const int framesPerRow = 16;
13
14 private const int framesPerColumn = 5;
15
17
18 private string _key;
19
20 public int DisplayTextPriority { get; set; }
21
22 public bool HideInPortraitInfo { get; set; }
23
24 public FilterProviderInfoElement(string nameLanguageKey, int filterIconFrame)
25 {
26 _key = nameLanguageKey;
27 _filterIconFrame.X = filterIconFrame % 16;
28 _filterIconFrame.Y = filterIconFrame / 16;
29 }
30
32 {
33 Asset<Texture2D> obj = Main.Assets.Request<Texture2D>("Images/UI/Bestiary/Icon_Tags_Shadow", (AssetRequestMode)1);
34 return new UIImageFramed(obj, obj.Frame(16, 5, _filterIconFrame.X, _filterIconFrame.Y))
35 {
36 HAlign = 0.5f,
37 VAlign = 0.5f
38 };
39 }
40
42 {
43 if (info.UnlockState == BestiaryEntryUnlockState.NotKnownAtAll_0)
44 {
45 return null;
46 }
47 return Language.GetText(_key).Value;
48 }
49
50 public string GetDisplayNameKey()
51 {
52 return _key;
53 }
54
56 {
58 {
59 return null;
60 }
61 if (info.UnlockState == BestiaryEntryUnlockState.NotKnownAtAll_0)
62 {
63 return null;
64 }
65 UIElement uIElement = new UIPanel(Main.Assets.Request<Texture2D>("Images/UI/Bestiary/Stat_Panel", (AssetRequestMode)1), null, 12, 7)
66 {
67 Width = new StyleDimension(-14f, 1f),
68 Height = new StyleDimension(34f, 0f),
69 BackgroundColor = new Color(43, 56, 101),
70 BorderColor = Color.Transparent,
71 Left = new StyleDimension(5f, 0f)
72 };
73 uIElement.SetPadding(0f);
74 uIElement.PaddingRight = 5f;
75 UIElement filterImage = GetFilterImage();
76 filterImage.HAlign = 0f;
77 filterImage.Left = new StyleDimension(5f, 0f);
78 UIText element = new UIText(Language.GetText(GetDisplayNameKey()), 0.8f)
79 {
80 HAlign = 0f,
81 Left = new StyleDimension(38f, 0f),
82 TextOriginX = 0f,
83 TextOriginY = 0f,
84 VAlign = 0.5f,
85 DynamicallyScaleDownToWidth = true
86 };
87 if (filterImage != null)
88 {
89 uIElement.Append(filterImage);
90 }
91 uIElement.Append(element);
92 AddOnHover(uIElement);
93 return uIElement;
94 }
95
96 private void AddOnHover(UIElement button)
97 {
98 button.OnUpdate += delegate(UIElement e)
99 {
101 };
102 }
103
104 private void ShowButtonName(UIElement element)
105 {
106 if (element.IsMouseHovering)
107 {
108 string textValue = Language.GetTextValue(GetDisplayNameKey());
109 Main.instance.MouseText(textValue, 0, 0);
110 }
111 }
112}
string GetSearchString(ref BestiaryUICollectionInfo info)
FilterProviderInfoElement(string nameLanguageKey, int filterIconFrame)
static LocalizedText GetText(string key)
Definition Language.cs:10
static string GetTextValue(string key)
Definition Language.cs:15
static Main instance
Definition Main.cs:283
static IAssetRepository Assets
Definition Main.cs:209
void Append(UIElement element)
Definition UIElement.cs:166
void SetPadding(float pixels)
Definition UIElement.cs:361
static Color Transparent
Definition Color.cs:76