Skip to content

Commit

Permalink
0.2.0.4 release, fix itemicon issue, item customizer issue
Browse files Browse the repository at this point in the history
  • Loading branch information
JavidPack committed Jun 24, 2017
1 parent 52641e0 commit 9c0609b
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 66 deletions.
1 change: 1 addition & 0 deletions UIElements/UIDragablePanel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ protected override void DrawSelf(SpriteBatch spriteBatch)
{
Main.LocalPlayer.mouseInterface = true;
Main.LocalPlayer.showItemIcon = false;
Main.ItemIconCacheUpdate(0);
}
if (dragging)
{
Expand Down
134 changes: 69 additions & 65 deletions UIElements/UIItemSlot.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,88 +34,92 @@ public UIItemSlot(Item item, float scale = .75f)
const int frameDelay = 7;
protected override void DrawSelf(SpriteBatch spriteBatch)
{
if (item != null /*&& !item.IsAir*/)
if (item != null)
{
CalculatedStyle dimensions = base.GetInnerDimensions();
Rectangle rectangle = dimensions.ToRectangle();
spriteBatch.Draw(backgroundTexture, dimensions.Position(), null, Color.White, 0f, Vector2.Zero, scale, SpriteEffects.None, 0f);

Texture2D itemTexture = Main.itemTexture[this.item.type];
Rectangle rectangle2;
if (Main.itemAnimations[item.type] != null)
if (!item.IsAir)
{
rectangle2 = Main.itemAnimations[item.type].GetFrame(itemTexture);
}
else
{
rectangle2 = itemTexture.Frame(1, 1, 0, 0);
}
Color newColor = Color.White;
float pulseScale = 1f;
ItemSlot.GetItemLight(ref newColor, ref pulseScale, item, false);
int height = rectangle2.Height;
int width = rectangle2.Width;
float drawScale = 1f;
float availableWidth = (float)defaultBackgroundTexture.Width * scale;
if (width > availableWidth || height > availableWidth)
{
if (width > height)

Texture2D itemTexture = Main.itemTexture[this.item.type];
Rectangle rectangle2;
if (Main.itemAnimations[item.type] != null)
{
drawScale = availableWidth / width;
rectangle2 = Main.itemAnimations[item.type].GetFrame(itemTexture);
}
else
{
drawScale = availableWidth / height;
rectangle2 = itemTexture.Frame(1, 1, 0, 0);
}
}
drawScale *= scale;
Vector2 vector = backgroundTexture.Size() * scale;
Vector2 position2 = dimensions.Position() + vector / 2f - rectangle2.Size() * drawScale / 2f;
Vector2 origin = rectangle2.Size() * (pulseScale / 2f - 0.5f);
//Vector2 drawPosition = dimensions.Position();
//drawPosition.X += defaultBackgroundTexture.Width * scale / 2f - (float)width * drawScale / 2f;
//drawPosition.Y += defaultBackgroundTexture.Height * scale / 2f - (float)height * drawScale / 2f;
Color newColor = Color.White;
float pulseScale = 1f;
ItemSlot.GetItemLight(ref newColor, ref pulseScale, item, false);
int height = rectangle2.Height;
int width = rectangle2.Width;
float drawScale = 1f;
float availableWidth = (float)defaultBackgroundTexture.Width * scale;
if (width > availableWidth || height > availableWidth)
{
if (width > height)
{
drawScale = availableWidth / width;
}
else
{
drawScale = availableWidth / height;
}
}
drawScale *= scale;
Vector2 vector = backgroundTexture.Size() * scale;
Vector2 position2 = dimensions.Position() + vector / 2f - rectangle2.Size() * drawScale / 2f;
Vector2 origin = rectangle2.Size() * (pulseScale / 2f - 0.5f);
//Vector2 drawPosition = dimensions.Position();
//drawPosition.X += defaultBackgroundTexture.Width * scale / 2f - (float)width * drawScale / 2f;
//drawPosition.Y += defaultBackgroundTexture.Height * scale / 2f - (float)height * drawScale / 2f;

if (ItemLoader.PreDrawInInventory(item, spriteBatch, position2, rectangle2, item.GetAlpha(newColor),
item.GetColor(Color.White), origin, drawScale * pulseScale))
{
spriteBatch.Draw(itemTexture, position2, new Rectangle?(rectangle2), item.GetAlpha(newColor), 0f, origin, drawScale * pulseScale, SpriteEffects.None, 0f);
if (item.color != Color.Transparent)
if (ItemLoader.PreDrawInInventory(item, spriteBatch, position2, rectangle2, item.GetAlpha(newColor),
item.GetColor(Color.White), origin, drawScale * pulseScale))
{
spriteBatch.Draw(itemTexture, position2, new Rectangle?(rectangle2), item.GetColor(Color.White), 0f, origin, drawScale * pulseScale, SpriteEffects.None, 0f);
spriteBatch.Draw(itemTexture, position2, new Rectangle?(rectangle2), item.GetAlpha(newColor), 0f, origin, drawScale * pulseScale, SpriteEffects.None, 0f);
if (item.color != Color.Transparent)
{
spriteBatch.Draw(itemTexture, position2, new Rectangle?(rectangle2), item.GetColor(Color.White), 0f, origin, drawScale * pulseScale, SpriteEffects.None, 0f);
}
}
ItemLoader.PostDrawInInventory(item, spriteBatch, position2, rectangle2, item.GetAlpha(newColor),
item.GetColor(Color.White), origin, drawScale * pulseScale);
if (ItemID.Sets.TrapSigned[item.type])
{
spriteBatch.Draw(Main.wireTexture, dimensions.Position() + new Vector2(40f, 40f) * scale, new Rectangle?(new Rectangle(4, 58, 8, 8)), Color.White, 0f, new Vector2(4f), 1f, SpriteEffects.None, 0f);
}
if (item.stack > 1)
{
ChatManager.DrawColorCodedStringWithShadow(spriteBatch, Main.fontItemStack, item.stack.ToString(), dimensions.Position() + new Vector2(10f, 26f) * scale, Color.White, 0f, Vector2.Zero, new Vector2(scale), -1f, scale);
}
}
ItemLoader.PostDrawInInventory(item, spriteBatch, position2, rectangle2, item.GetAlpha(newColor),
item.GetColor(Color.White), origin, drawScale * pulseScale);
if (ItemID.Sets.TrapSigned[item.type])
{
spriteBatch.Draw(Main.wireTexture, dimensions.Position() + new Vector2(40f, 40f) * scale, new Rectangle?(new Rectangle(4, 58, 8, 8)), Color.White, 0f, new Vector2(4f), 1f, SpriteEffects.None, 0f);
}
if (item.stack > 1)
{
ChatManager.DrawColorCodedStringWithShadow(spriteBatch, Main.fontItemStack, item.stack.ToString(), dimensions.Position() + new Vector2(10f, 26f) * scale, Color.White, 0f, Vector2.Zero, new Vector2(scale), -1f, scale);
}

//this.item.GetColor(Color.White);
//spriteBatch.Draw(itemTexture, drawPosition, rectangle2, this.item.GetAlpha(Color.White), 0f, Vector2.Zero, drawScale, SpriteEffects.None, 0f);
//if (this.item.color != default(Color))
//{
// spriteBatch.Draw(itemTexture, drawPosition, new Rectangle?(rectangle2), this.item.GetColor(Color.White), 0f, Vector2.Zero, drawScale, SpriteEffects.None, 0f);
//}
//if (this.item.stack > 1)
//{
// spriteBatch.DrawString(Main.fontItemStack, this.item.stack.ToString(), new Vector2(drawPosition.X + 10f * scale, drawPosition.Y + 26f * scale), Color.White, 0f, Vector2.Zero, scale, SpriteEffects.None, 0f);
//}
//this.item.GetColor(Color.White);
//spriteBatch.Draw(itemTexture, drawPosition, rectangle2, this.item.GetAlpha(Color.White), 0f, Vector2.Zero, drawScale, SpriteEffects.None, 0f);
//if (this.item.color != default(Color))
//{
// spriteBatch.Draw(itemTexture, drawPosition, new Rectangle?(rectangle2), this.item.GetColor(Color.White), 0f, Vector2.Zero, drawScale, SpriteEffects.None, 0f);
//}
//if (this.item.stack > 1)
//{
// spriteBatch.DrawString(Main.fontItemStack, this.item.stack.ToString(), new Vector2(drawPosition.X + 10f * scale, drawPosition.Y + 26f * scale), Color.White, 0f, Vector2.Zero, scale, SpriteEffects.None, 0f);
//}

if (IsMouseHovering)
{
// TODO, should only need 2 of these 3 I think
Main.HoverItem = item.Clone();
Main.hoverItemName = Main.HoverItem.Name + (Main.HoverItem.modItem != null ? " [" + Main.HoverItem.modItem.mod.Name + "]" : "");
if (IsMouseHovering)
{
// TODO, should only need 2 of these 3 I think
Main.HoverItem = item.Clone();
Main.hoverItemName = Main.HoverItem.Name + (Main.HoverItem.modItem != null ? " [" + Main.HoverItem.modItem.mod.Name + "]" : "");

// Main.hoverItemName = this.item.name;
// Main.toolTip = item.Clone();
Main.HoverItem.SetNameOverride(Main.HoverItem.Name + (Main.HoverItem.modItem != null ? " [" + Main.HoverItem.modItem.mod.Name + "]" : ""));
// Main.hoverItemName = this.item.name;
// Main.toolTip = item.Clone();
Main.HoverItem.SetNameOverride(Main.HoverItem.Name + (Main.HoverItem.modItem != null ? " [" + Main.HoverItem.modItem.mod.Name + "]" : ""));
}
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion build.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
author = jopojelly
version = 0.2.0.3
version = 0.2.0.4
displayName = Recipe Browser
homepage = http://forums.terraria.org/index.php?threads/cheat-sheet.41407/
buildIgnore = .vs\*, Properties\*, *.csproj, *.user, obj\*, bin\*, *.config, unused\*
Expand Down

0 comments on commit 9c0609b

Please sign in to comment.