Skip to content

Instantly share code, notes, and snippets.

@Trivaxy
Created January 13, 2017 07:40
Show Gist options
  • Save Trivaxy/24c189b0ea41a7b9dfbce87bbc79eb1c to your computer and use it in GitHub Desktop.
Save Trivaxy/24c189b0ea41a7b9dfbce87bbc79eb1c to your computer and use it in GitHub Desktop.
internal class UIHoverImageButton : UIImageButton
{
internal string hoverText;
public UIHoverImageButton(Texture2D texture, string hoverText) : base(texture)
{
this.hoverText = hoverText;
}
protected override void DrawSelf(SpriteBatch spriteBatch)
{
base.DrawSelf(spriteBatch);
if (IsMouseHovering)
{
Main.hoverItemName = hoverText;
}
}
}
Texture2D duskButtonTexture = ModLoader.GetTexture("TrivaxysStuff/UI/DuskButton");
UIHoverImageButton duskButton = new UIHoverImageButton(duskButtonTexture, "whatever string here");
duskButton.Left.Set(8, 0f);
duskButton.Top.Set(8, 0f);
duskButton.Width.Set(22, 0f);
duskButton.Height.Set(22, 0f);
duskButton.OnClick += new MouseEvent(DuskButtonClicked);
MainPanel.Append(duskButton);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment