Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed Alignment of Bundle Hover Info #37

Merged
merged 3 commits into from
Oct 25, 2020
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 16 additions & 11 deletions SDVModTest/UIElements/ShowItemHoverInformation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -208,11 +208,17 @@ private void DrawAdvancedTooltip()
}
}

int largestTextWidth = 0;
int stackTextWidth = (int)(Game1.smallFont.MeasureString(stackPrice.ToString()).Length());

int bundleTextWidth = 0;
if (!String.IsNullOrEmpty(requiredBundleName))
{
bundleTextWidth = (int)Game1.dialogueFont.MeasureString(requiredBundleName).Length();
bundleTextWidth -= 30; //Text offset from left
}
int stackTextWidth = (int)(Game1.smallFont.MeasureString(stackPrice.ToString()).Length());
int itemTextWidth = (int)(Game1.smallFont.MeasureString(itemPrice.ToString()).Length());
largestTextWidth = (stackTextWidth > itemTextWidth) ? stackTextWidth : itemTextWidth;
int windowWidth = Math.Max(largestTextWidth + 90, String.IsNullOrEmpty(requiredBundleName) ? 100 : 300);
int largestTextWidth = Math.Max(bundleTextWidth,Math.Max(stackTextWidth, itemTextWidth));
LunaLycan287 marked this conversation as resolved.
Show resolved Hide resolved
int windowWidth = largestTextWidth + 90;

int windowHeight = 75;

Expand Down Expand Up @@ -370,32 +376,31 @@ private void DrawAdvancedTooltip()
if (!String.IsNullOrEmpty(requiredBundleName))
{
int num1 = (int)windowPos.X - 30;
int num2 = (int)windowPos.Y - 10;
int num2 = (int)windowPos.Y - 14;
int num3 = num1 + 52;
int y3 = num2 - 2;
int num4 = 288;
int y3 = num2 + 4;
int height = 36;
int num5 = 36;
int width = num4 / num5;
int width = (bundleTextWidth+90) / num5;
int num6 = 6;

for (int i = 0; i < 36; ++i)
for (int i = 0; i < num5; ++i)
{
float num7 = (float)(i >= num6 ? 0.92 - (i - num6) * (1.0 / (num5 - num6)) : 0.92f);
Game1.spriteBatch.Draw(
Game1.staminaRect,
new Rectangle(num3 + width * i, y3, width, height),
Color.Crimson * num7);
}

Game1.spriteBatch.DrawString(
Game1.dialogueFont,
requiredBundleName,
new Vector2(num1 + 72, num2),
Color.White);

_bundleIcon.bounds.X = num1 + 16;
_bundleIcon.bounds.Y = num2;
_bundleIcon.bounds.Y = num2 - 6;
_bundleIcon.scale = 3;
_bundleIcon.draw(Game1.spriteBatch);
}
Expand Down