Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
UIBestiaryInfoItemLine.cs
Go to the documentation of this file.
8using Terraria.ID;
9using Terraria.UI;
10
12
14{
16
17 private bool _hideMouseOver;
18
19 public int OrderInUIList { get; set; }
20
22 {
23 _infoDisplayItem = new Item();
24 _infoDisplayItem.SetDefaults(info.itemId);
26 SetPadding(0f);
27 PaddingLeft = 10f;
28 PaddingRight = 10f;
29 Width.Set(-14f, 1f);
30 Height.Set(32f, 0f);
31 Left.Set(5f, 0f);
32 base.OnMouseOver += MouseOver;
33 base.OnMouseOut += MouseOut;
34 BorderColor = new Color(89, 116, 213, 255);
36 if (uiinfo.UnlockState < BestiaryEntryUnlockState.CanShowDropsWithoutDropRates_3)
37 {
38 _hideMouseOver = true;
39 Asset<Texture2D> texture = Main.Assets.Request<Texture2D>("Images/UI/Bestiary/Icon_Locked", (AssetRequestMode)1);
41 {
42 Height = new StyleDimension(0f, 1f),
43 Width = new StyleDimension(0f, 1f),
44 HAlign = 0.5f,
45 VAlign = 0.5f
46 };
47 uIElement.SetPadding(0f);
48 UIImage element = new UIImage(texture)
49 {
50 ImageScale = 0.55f,
51 HAlign = 0.5f,
52 VAlign = 0.5f
53 };
54 uIElement.Append(element);
56 }
57 else
58 {
59 UIItemIcon element2 = new UIItemIcon(_infoDisplayItem, uiinfo.UnlockState < BestiaryEntryUnlockState.CanShowDropsWithoutDropRates_3)
60 {
62 HAlign = 0f,
63 Left = new StyleDimension(4f, 0f)
64 };
66 if (!string.IsNullOrEmpty(stackRange))
67 {
69 }
71 {
73 DrawPanel = false,
74 HAlign = 1f,
75 Top = new StyleDimension(-4f, 0f)
76 };
78 }
79 }
80
82 {
83 if (dropRateInfo.stackMin != dropRateInfo.stackMax)
84 {
85 stackRange = $" ({dropRateInfo.stackMin}-{dropRateInfo.stackMax})";
86 }
87 else if (dropRateInfo.stackMin == 1)
88 {
89 stackRange = "";
90 }
91 else
92 {
93 stackRange = " (" + dropRateInfo.stackMin + ")";
94 }
95 string originalFormat = "P";
96 if ((double)dropRateInfo.dropRate < 0.001)
97 {
98 originalFormat = "P4";
99 }
100 if (dropRateInfo.dropRate != 1f)
101 {
103 }
104 else
105 {
106 droprate = "100%";
107 }
108 if (uiinfo.UnlockState != BestiaryEntryUnlockState.CanShowDropsWithDropRates_4)
109 {
110 droprate = "???";
111 stackRange = "";
112 }
113 }
114
115 protected override void DrawSelf(SpriteBatch spriteBatch)
116 {
117 base.DrawSelf(spriteBatch);
118 if (base.IsMouseHovering && !_hideMouseOver)
119 {
121 }
122 }
123
124 private void DrawMouseOver()
125 {
126 Main.HoverItem = _infoDisplayItem;
127 Main.instance.MouseText("", 0, 0);
128 Main.mouseText = true;
129 }
130
131 public override int CompareTo(object obj)
132 {
134 {
135 return OrderInUIList.CompareTo(manuallyOrderedUIElement.OrderInUIList);
136 }
137 return base.CompareTo(obj);
138 }
139
141 {
142 List<string> list = new List<string>();
143 if (info.conditions == null)
144 {
145 return;
146 }
147 foreach (IItemDropRuleCondition condition in info.conditions)
148 {
149 if (condition != null)
150 {
152 if (!string.IsNullOrWhiteSpace(conditionDescription))
153 {
154 list.Add(conditionDescription);
155 }
156 }
157 }
158 _infoDisplayItem.BestiaryNotes = string.Join("\n", list);
159 }
160
166
168 {
169 BorderColor = new Color(89, 116, 213, 255);
170 }
171}
static void PlaySound(int type, Vector2 position, int style=1)
UIBestiaryInfoItemLine(DropRateInfo info, BestiaryUICollectionInfo uiinfo, float textScale=1f)
void MouseOver(UIMouseEvent evt, UIElement listeningElement)
void GetDropInfo(DropRateInfo dropRateInfo, BestiaryUICollectionInfo uiinfo, out string stackRange, out string droprate)
void MouseOut(UIMouseEvent evt, UIElement listeningElement)
void DrawPanel(SpriteBatch spriteBatch, Texture2D texture, Color color)
Definition UIPanel.cs:50
static readonly Color FancyUIFatButtonMouseOver
Definition Colors.cs:91
void SetDefaults(int Type=0)
Definition Item.cs:47332
static Main instance
Definition Main.cs:283
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
StyleDimension Width
Definition UIElement.cs:27
void SetPadding(float pixels)
Definition UIElement.cs:361
StyleDimension Top
Definition UIElement.cs:23
static string PrettifyPercentDisplay(float percent, string originalFormat)
Definition Utils.cs:717
void Set(float pixels, float precent)