Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ MouseText_DrawItemTooltip()

void Terraria.Main.MouseText_DrawItemTooltip ( MouseTextCache info,
int rare,
byte diff,
int X,
int Y )
inlineprivate

Definition at line 18893 of file Main.cs.

18894 {
18898 int yoyoLogo = -1;
18899 int researchLine = -1;
18900 rare = hoverItem.rare;
18901 float knockBack = hoverItem.knockBack;
18902 float num = 1f;
18903 if (hoverItem.melee && player[myPlayer].kbGlove)
18904 {
18905 num += 1f;
18906 }
18907 if (player[myPlayer].kbBuff)
18908 {
18909 num += 0.5f;
18910 }
18911 if (num != 1f)
18912 {
18913 hoverItem.knockBack *= num;
18914 }
18915 if (hoverItem.ranged && player[myPlayer].shroomiteStealth)
18916 {
18917 hoverItem.knockBack *= 1f + (1f - player[myPlayer].stealth) * 0.5f;
18918 }
18919 int num2 = 30;
18920 int numLines = 1;
18921 string[] array = new string[num2];
18922 bool[] array2 = new bool[num2];
18923 bool[] array3 = new bool[num2];
18924 for (int i = 0; i < num2; i++)
18925 {
18926 array2[i] = false;
18927 array3[i] = false;
18928 }
18930 float num3 = (float)(int)mouseTextColor / 255f;
18931 float num4 = num3;
18932 int a = mouseTextColor;
18933 if (npcShop > 0 && hoverItem.value >= 0 && (hoverItem.type < 71 || hoverItem.type > 74))
18934 {
18936 long num5 = ((hoverItem.isAShopItem || hoverItem.buyOnce) ? calcForBuying : calcForSelling);
18937 if (hoverItem.shopSpecialCurrency != -1)
18938 {
18940 color = new Microsoft.Xna.Framework.Color((byte)(255f * num4), (byte)(255f * num4), (byte)(255f * num4), a);
18941 }
18942 else if (num5 > 0)
18943 {
18944 string text = "";
18945 long num6 = 0L;
18946 long num7 = 0L;
18947 long num8 = 0L;
18948 long num9 = 0L;
18949 long num10 = num5 * hoverItem.stack;
18950 if (!hoverItem.buy)
18951 {
18952 num10 = num5 / 5;
18953 if (num10 < 1)
18954 {
18955 num10 = 1L;
18956 }
18957 long num11 = num10;
18958 num10 *= hoverItem.stack;
18959 int amount = shopSellbackHelper.GetAmount(hoverItem);
18960 if (amount > 0)
18961 {
18962 num10 += (-num11 + calcForBuying) * Math.Min(amount, hoverItem.stack);
18963 }
18964 }
18965 if (num10 < 1)
18966 {
18967 num10 = 1L;
18968 }
18969 if (num10 >= 1000000)
18970 {
18971 num6 = num10 / 1000000;
18972 num10 -= num6 * 1000000;
18973 }
18974 if (num10 >= 10000)
18975 {
18976 num7 = num10 / 10000;
18977 num10 -= num7 * 10000;
18978 }
18979 if (num10 >= 100)
18980 {
18981 num8 = num10 / 100;
18982 num10 -= num8 * 100;
18983 }
18984 if (num10 >= 1)
18985 {
18986 num9 = num10;
18987 }
18988 if (num6 > 0)
18989 {
18990 text = text + num6 + " " + Lang.inter[15].Value + " ";
18991 }
18992 if (num7 > 0)
18993 {
18994 text = text + num7 + " " + Lang.inter[16].Value + " ";
18995 }
18996 if (num8 > 0)
18997 {
18998 text = text + num8 + " " + Lang.inter[17].Value + " ";
18999 }
19000 if (num9 > 0)
19001 {
19002 text = text + num9 + " " + Lang.inter[18].Value + " ";
19003 }
19004 if (!hoverItem.buy)
19005 {
19006 array[numLines] = Lang.tip[49].Value + " " + text;
19007 }
19008 else
19009 {
19010 array[numLines] = Lang.tip[50].Value + " " + text;
19011 }
19012 numLines++;
19013 if (num6 > 0)
19014 {
19015 color = new Microsoft.Xna.Framework.Color((byte)(220f * num4), (byte)(220f * num4), (byte)(198f * num4), a);
19016 }
19017 else if (num7 > 0)
19018 {
19019 color = new Microsoft.Xna.Framework.Color((byte)(224f * num4), (byte)(201f * num4), (byte)(92f * num4), a);
19020 }
19021 else if (num8 > 0)
19022 {
19023 color = new Microsoft.Xna.Framework.Color((byte)(181f * num4), (byte)(192f * num4), (byte)(193f * num4), a);
19024 }
19025 else if (num9 > 0)
19026 {
19027 color = new Microsoft.Xna.Framework.Color((byte)(246f * num4), (byte)(138f * num4), (byte)(96f * num4), a);
19028 }
19029 }
19030 else if (hoverItem.type != 3817)
19031 {
19032 array[numLines] = Lang.tip[51].Value;
19033 numLines++;
19034 color = new Microsoft.Xna.Framework.Color((byte)(120f * num4), (byte)(120f * num4), (byte)(120f * num4), a);
19035 }
19036 }
19038 int num12 = 0;
19039 for (int j = 0; j < numLines; j++)
19040 {
19042 if (stringSize.X > zero.X)
19043 {
19044 zero.X = stringSize.X;
19045 }
19046 zero.Y += stringSize.Y + (float)num12;
19047 }
19048 if (yoyoLogo != -1)
19049 {
19050 zero.Y += 24f;
19051 }
19052 X += toolTipDistance;
19053 Y += toolTipDistance;
19054 int num13 = 4;
19056 {
19057 X += 8;
19058 Y += 2;
19059 num13 = 18;
19060 }
19061 int num14 = screenWidth;
19062 int num15 = screenHeight;
19063 if ((float)X + zero.X + (float)num13 > (float)num14)
19064 {
19065 X = (int)((float)num14 - zero.X - (float)num13);
19066 }
19067 if ((float)Y + zero.Y + (float)num13 > (float)num15)
19068 {
19069 Y = (int)((float)num15 - zero.Y - (float)num13);
19070 }
19071 int num16 = 0;
19072 num3 = (float)(int)mouseTextColor / 255f;
19074 {
19075 num3 = MathHelper.Lerp(num3, 1f, 1f);
19076 int num17 = 14;
19077 int num18 = 9;
19078 Utils.DrawInvBG(spriteBatch, new Microsoft.Xna.Framework.Rectangle(X - num17, Y - num18, (int)zero.X + num17 * 2, (int)zero.Y + num18 + num18 / 2), new Microsoft.Xna.Framework.Color(23, 25, 81, 255) * 0.925f);
19079 }
19080 for (int k = 0; k < numLines; k++)
19081 {
19082 if (k == yoyoLogo)
19083 {
19084 float num19 = 1f;
19085 int num20 = (int)((float)(int)mouseTextColor * num19);
19087 for (int l = 0; l < 5; l++)
19088 {
19089 int num21 = X;
19090 int num22 = Y + num16;
19091 if (l == 4)
19092 {
19094 }
19095 switch (l)
19096 {
19097 case 0:
19098 num21--;
19099 break;
19100 case 1:
19101 num21++;
19102 break;
19103 case 2:
19104 num22--;
19105 break;
19106 case 3:
19107 num22++;
19108 break;
19109 }
19110 spriteBatch.Draw(TextureAssets.OneDropLogo.Value, new Vector2(num21, num22), null, color2, 0f, default(Vector2), 1f, SpriteEffects.None, 0f);
19111 }
19112 }
19113 else
19114 {
19117 if (k == 0)
19118 {
19119 if (rare == -13)
19120 {
19121 black = new Microsoft.Xna.Framework.Color((byte)(255f * num4), (byte)(masterColor * 200f * num4), 0, a);
19122 }
19123 if (rare == -11)
19124 {
19125 black = new Microsoft.Xna.Framework.Color((byte)(255f * num4), (byte)(175f * num4), (byte)(0f * num4), a);
19126 }
19127 if (rare == -1)
19128 {
19129 black = new Microsoft.Xna.Framework.Color((byte)(130f * num4), (byte)(130f * num4), (byte)(130f * num4), a);
19130 }
19131 if (rare == 1)
19132 {
19133 black = new Microsoft.Xna.Framework.Color((byte)(150f * num4), (byte)(150f * num4), (byte)(255f * num4), a);
19134 }
19135 if (rare == 2)
19136 {
19137 black = new Microsoft.Xna.Framework.Color((byte)(150f * num4), (byte)(255f * num4), (byte)(150f * num4), a);
19138 }
19139 if (rare == 3)
19140 {
19141 black = new Microsoft.Xna.Framework.Color((byte)(255f * num4), (byte)(200f * num4), (byte)(150f * num4), a);
19142 }
19143 if (rare == 4)
19144 {
19145 black = new Microsoft.Xna.Framework.Color((byte)(255f * num4), (byte)(150f * num4), (byte)(150f * num4), a);
19146 }
19147 if (rare == 5)
19148 {
19149 black = new Microsoft.Xna.Framework.Color((byte)(255f * num4), (byte)(150f * num4), (byte)(255f * num4), a);
19150 }
19151 if (rare == 6)
19152 {
19153 black = new Microsoft.Xna.Framework.Color((byte)(210f * num4), (byte)(160f * num4), (byte)(255f * num4), a);
19154 }
19155 if (rare == 7)
19156 {
19157 black = new Microsoft.Xna.Framework.Color((byte)(150f * num4), (byte)(255f * num4), (byte)(10f * num4), a);
19158 }
19159 if (rare == 8)
19160 {
19161 black = new Microsoft.Xna.Framework.Color((byte)(255f * num4), (byte)(255f * num4), (byte)(10f * num4), a);
19162 }
19163 if (rare == 9)
19164 {
19165 black = new Microsoft.Xna.Framework.Color((byte)(5f * num4), (byte)(200f * num4), (byte)(255f * num4), a);
19166 }
19167 if (rare == 10)
19168 {
19169 black = new Microsoft.Xna.Framework.Color((byte)(255f * num4), (byte)(40f * num4), (byte)(100f * num4), a);
19170 }
19171 if (rare >= 11)
19172 {
19173 black = new Microsoft.Xna.Framework.Color((byte)(180f * num4), (byte)(40f * num4), (byte)(255f * num4), a);
19174 }
19175 if (diff == 1)
19176 {
19177 black = new Microsoft.Xna.Framework.Color((byte)((float)(int)mcColor.R * num4), (byte)((float)(int)mcColor.G * num4), (byte)((float)(int)mcColor.B * num4), a);
19178 }
19179 if (diff == 2)
19180 {
19181 black = new Microsoft.Xna.Framework.Color((byte)((float)(int)hcColor.R * num4), (byte)((float)(int)hcColor.G * num4), (byte)((float)(int)hcColor.B * num4), a);
19182 }
19183 if (hoverItem.expert || rare == -12)
19184 {
19185 black = new Microsoft.Xna.Framework.Color((byte)((float)DiscoR * num4), (byte)((float)DiscoG * num4), (byte)((float)DiscoB * num4), a);
19186 }
19187 }
19188 else if (array2[k])
19189 {
19190 black = ((!array3[k]) ? new Microsoft.Xna.Framework.Color((byte)(120f * num4), (byte)(190f * num4), (byte)(120f * num4), a) : new Microsoft.Xna.Framework.Color((byte)(190f * num4), (byte)(120f * num4), (byte)(120f * num4), a));
19191 }
19192 else if (k == numLines - 1)
19193 {
19194 black = color;
19195 }
19196 if (k == researchLine)
19197 {
19199 }
19201 }
19202 num16 += (int)(FontAssets.MouseText.Value.MeasureString(array[k]).Y + (float)num12);
19203 }
19204 }
static float Lerp(float value1, float value2, float amount)
Definition MathHelper.cs:53
static byte Min(byte val1, byte val2)
Definition Math.cs:912
static Asset< DynamicSpriteFont > MouseText
Definition FontAssets.cs:10
static Asset< Texture2D > OneDropLogo
static void GetPriceText(int currencyIndex, string[] lines, ref int currentLine, long price)
static readonly Color JourneyMode
Definition Colors.cs:41
static float masterColor
Definition Main.cs:1338
static SpriteBatch spriteBatch
Definition Main.cs:974
static ItemShopSellbackHelper shopSellbackHelper
Definition Main.cs:1841
static int myPlayer
Definition Main.cs:1801
static int DiscoR
Definition Main.cs:1062
static int rare
Definition Main.cs:2457
static int screenHeight
Definition Main.cs:1721
static byte mouseTextColor
Definition Main.cs:1751
static int DiscoG
Definition Main.cs:1066
static Item HoverItem
Definition Main.cs:1910
static int npcShop
Definition Main.cs:2833
static int DiscoB
Definition Main.cs:1064
static void MouseText_DrawItemTooltip_GetLinesInfo(Item item, ref int yoyoLogo, ref int researchLine, float oldKB, ref int numLines, string[] toolTipLine, bool[] preFixLine, bool[] badPreFixLine)
Definition Main.cs:19206
static int toolTipDistance
Definition Main.cs:403
static int screenWidth
Definition Main.cs:1719
static bool SettingsEnabled_OpaqueBoxBehindTooltips
Definition Main.cs:253
static Player LocalPlayer
Definition Main.cs:2829
static Player[] player
Definition Main.cs:1803
static Vector2 DrawColorCodedStringWithShadow(SpriteBatch spriteBatch, DynamicSpriteFont font, TextSnippet[] snippets, Vector2 position, float rotation, Vector2 origin, Vector2 baseScale, out int hoveredSnippet, float maxWidth=-1f, float spread=2f)
static Vector2 GetStringSize(DynamicSpriteFont font, string text, Vector2 baseScale, float maxWidth=-1f)

References System.array, Microsoft.Xna.Framework.Color.Black, Terraria.Main.DiscoB, Terraria.Main.DiscoG, Terraria.Main.DiscoR, Terraria.UI.Chat.ChatManager.DrawColorCodedStringWithShadow(), Terraria.Utils.DrawInvBG(), Terraria.GameContent.UI.CustomCurrencyManager.GetPriceText(), Terraria.UI.Chat.ChatManager.GetStringSize(), Terraria.Main.HoverItem, System.Text.RegularExpressions.i, Terraria.Lang.inter, Terraria.ID.Colors.JourneyMode, System.L, Microsoft.Xna.Framework.MathHelper.Lerp(), Terraria.Main.LocalPlayer, Terraria.Main.masterColor, System.Math.Min(), Terraria.GameContent.FontAssets.MouseText, Terraria.Main.MouseText_DrawItemTooltip_GetLinesInfo(), Terraria.Main.mouseTextColor, Terraria.Main.myPlayer, Terraria.Main.npcShop, Microsoft.Xna.Framework.Vector2.One, Terraria.GameContent.TextureAssets.OneDropLogo, Terraria.Main.player, Terraria.Main.rare, Terraria.Main.screenHeight, Terraria.Main.screenWidth, Terraria.Main.SettingsEnabled_OpaqueBoxBehindTooltips, Terraria.Main.shopSellbackHelper, Terraria.Main.spriteBatch, System.text, Terraria.Lang.tip, Terraria.Main.toolTipDistance, System.X, System.Y, and Microsoft.Xna.Framework.Vector2.Zero.

Referenced by Terraria.Main.MouseTextInner().