Skip to content

Commit

Permalink
fix: spell item description (#2337)
Browse files Browse the repository at this point in the history
  • Loading branch information
Arufonsu authored Jul 21, 2024
1 parent 15f9e77 commit daa2827
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ protected virtual void GenerateComponents()
/// </summary>
/// <param name="x">The X position to move the control to.</param>
/// <param name="y">The Y position to move the control to.</param>
public virtual void SetPosition(int x, int y) => mContainer.SetPosition(x, y);
/// <param name="itemDecriptionContainer">The container for the item description.</param>
public virtual void SetPosition(int x, int y, ImagePanel? itemDecriptionContainer = null) => mContainer.SetPosition(x, y);

/// <summary>
/// Sets the control position based on ImagePanel.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ protected void FinalizeWindow()
}

/// <inheritdoc/>
public override void SetPosition(int x, int y)
public override void SetPosition(int x, int y, ImagePanel? itemDecriptionContainer = null)
{
if (mContainer == null || mContainer.Canvas == null)
{
Expand All @@ -143,7 +143,7 @@ public override void SetPosition(int x, int y)
HoveredControlX = InputHandler.HoveredControl.LocalPosToCanvas(new Point(0, 0)).X;
HoveredControlY = InputHandler.HoveredControl.LocalPosToCanvas(new Point(0, 0)).Y;
newX = HoveredControlX + InputHandler.HoveredControl.Width;
newY = HoveredControlY + InputHandler.HoveredControl.Height;
newY = itemDecriptionContainer != null ? itemDecriptionContainer.Bottom : HoveredControlY + InputHandler.HoveredControl.Height;

// Do not allow it to render outside of the screen canvas.
if (newX > mContainer.Canvas.Width - mContainer.Width)
Expand All @@ -153,7 +153,7 @@ public override void SetPosition(int x, int y)

if (newY > mContainer.Canvas.Height - mContainer.Height)
{
newY = HoveredControlY - mContainer.Height;
newY = itemDecriptionContainer != null ? itemDecriptionContainer.Y - mContainer.Height : HoveredControlY - mContainer.Height;
}

mContainer.MoveTo(newX, newY);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public partial class ItemDescriptionWindow : DescriptionWindowBase

protected string mValueLabel;

protected SpellDescriptionWindow mSpellDescWindow;
protected SpellDescriptionWindow? mSpellDescWindow;

public ItemDescriptionWindow(
ItemBase item,
Expand All @@ -45,7 +45,7 @@ public ItemDescriptionWindow(
// If a spell, also display the spell description!
if (mItem.ItemType == ItemType.Spell)
{
mSpellDescWindow = new SpellDescriptionWindow(mItem.SpellId, x, mContainer.Bottom);
mSpellDescWindow = new SpellDescriptionWindow(mItem.SpellId, x, y, mContainer);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ public partial class SpellDescriptionWindow : DescriptionWindowBase
{
protected SpellBase mSpell;

public SpellDescriptionWindow(Guid spellId, int x, int y) : base(Interface.GameUi.GameCanvas, "DescriptionWindow")
public SpellDescriptionWindow(Guid spellId, int x, int y, ImagePanel? itemDecriptionContainer = null) : base(Interface.GameUi.GameCanvas, "DescriptionWindow")
{
mSpell = SpellBase.Get(spellId);

GenerateComponents();
SetupDescriptionWindow();
SetPosition(x, y);
SetPosition(x, y, itemDecriptionContainer);
}

public SpellDescriptionWindow(Guid spellId, ImagePanel _statusIcon) : base(Interface.GameUi.GameCanvas, "DescriptionWindow")
Expand Down

0 comments on commit daa2827

Please sign in to comment.