diff options
| author | hazel <hazel@hazelthats.me> | 2026-01-26 22:04:39 +0100 |
|---|---|---|
| committer | hazel <hazel@hazelthats.me> | 2026-01-26 22:04:39 +0100 |
| commit | 567c422f8cd42eba2437f9a8c2522716a1649be7 (patch) | |
| tree | 93c5b296f3b7c14b626d0aadf5cad37764c41c74 /source/ui/elements/game/tooltips/ItemTooltipDisplay.cs | |
| download | celesteia-567c422f8cd42eba2437f9a8c2522716a1649be7.tar.gz celesteia-567c422f8cd42eba2437f9a8c2522716a1649be7.tar.bz2 celesteia-567c422f8cd42eba2437f9a8c2522716a1649be7.zip | |
celesteia archive, last updated april 9th 2024
Signed-off-by: hazel <hazel@hazelthats.me>
Diffstat (limited to 'source/ui/elements/game/tooltips/ItemTooltipDisplay.cs')
| -rw-r--r-- | source/ui/elements/game/tooltips/ItemTooltipDisplay.cs | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/source/ui/elements/game/tooltips/ItemTooltipDisplay.cs b/source/ui/elements/game/tooltips/ItemTooltipDisplay.cs new file mode 100644 index 0000000..9b62af4 --- /dev/null +++ b/source/ui/elements/game/tooltips/ItemTooltipDisplay.cs @@ -0,0 +1,62 @@ +using Celesteia.Resources.Types; +using Celesteia.UI.Properties; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; + +namespace Celesteia.UI.Elements.Game.Tooltips { + public class ItemTooltipDisplay : TooltipDisplay + { + private const float OUTER_SPACING = 16f; + private const float INNER_SPACING = 8f; + public readonly Container Content; + public readonly Label Title; + public readonly ItemDisplay Item; + + public ItemTooltipDisplay(Rect rect, Texture2D background) : base(rect) { + AddChild(new Image(Rect.RelativeFull(new Rect( + AbsoluteUnit.WithValue(0f), + AbsoluteUnit.WithValue(0f), + AbsoluteUnit.WithValue(256f + (2 * OUTER_SPACING)), + AbsoluteUnit.WithValue(32f + (2 * OUTER_SPACING)) + ))).SetTexture(background).MakePatches(4).SetColor(Color.White)); + + Content = new Container(new Rect( + AbsoluteUnit.WithValue(OUTER_SPACING), + AbsoluteUnit.WithValue(OUTER_SPACING), + AbsoluteUnit.WithValue(256f), + AbsoluteUnit.WithValue(32f) + )); + + Container titleCard = new Container(new Rect( + AbsoluteUnit.WithValue(0f), + AbsoluteUnit.WithValue(0f), + new RelativeUnit(1f, Content.GetRect(), RelativeUnit.Orientation.Horizontal), + AbsoluteUnit.WithValue(32f) + )); + titleCard.AddChild(Item = new ItemDisplay(new Rect( + AbsoluteUnit.WithValue(0f), + AbsoluteUnit.WithValue(0f), + AbsoluteUnit.WithValue(32f), + AbsoluteUnit.WithValue(32f) + )) { + Text = new TextProperties().Standard().SetTextAlignment(TextAlignment.Bottom | TextAlignment.Right) + }); + titleCard.AddChild(Title = new Label(new Rect( + AbsoluteUnit.WithValue(72f), + AbsoluteUnit.WithValue(0f), + AbsoluteUnit.WithValue(150f), + AbsoluteUnit.WithValue(32f) + )).SetTextProperties(new Properties.TextProperties().Standard().SetTextAlignment(TextAlignment.Left)).SetPivotPoint(new Vector2(0f, 0f))); + Content.AddChild(titleCard); + + AddChild(Content); + + SetEnabled(false); + } + + public void SetItem(ItemType type) { + Item.Item = type; + Title.SetText(type.Name); + } + } +}
\ No newline at end of file |
