at main 967 B view raw
1using Electropunk.Content.Entities; 2using Raylib_cs; 3 4namespace Electropunk.UI; 5 6public class UIInvPreview : UINode 7{ 8 public static readonly int Scale = 2; 9 10 public UIInvPreview(EntityPlayer.PlayerInventory inv, UINode? parent = null) : base(0, 0, parent) 11 { 12 int padding = 4; 13 14 Width = (32 + padding * 2) * Scale; 15 Height = (16 + padding * 2) * Scale; 16 17 AddChild(new UIItemSlot(inv.GetSlot(2)!, padding * Scale, padding * Scale, this) { Width = 16 * Scale, Height = 16 * Scale }); 18 AddChild(new UIItemSlot(inv.GetSlot(3)!, (padding + 16) * Scale, padding * Scale, this) { Width = 16 * Scale, Height = 16 * Scale }); 19 20 Reposition(); 21 } 22 23 public override void Render() 24 { 25 Raylib.DrawRectangleRec(GetRectangle(), Color.DarkBlue); 26 Raylib.DrawRectangleLinesEx(GetRectangle(), 2f, Color.Blue); 27 28 base.Render(); 29 } 30 31 public override void Reposition() 32 { 33 LocalX = Raylib.GetScreenWidth() / 2 - Width / 2; 34 LocalY = Raylib.GetScreenHeight() - Height - 8; 35 } 36}