3 using Microsoft.Xna.Framework;
4 using Microsoft.Xna.Framework.Graphics;
10 internal abstract class GuiTab : UIElement
12 internal const int SPACING = GuiUtils.SPACING;
13 internal const int PADDING = GuiUtils.PADDING;
15 public abstract string Header {
get; }
16 private int _pageHeight;
18 internal int _GetPageHeight()
20 _pageHeight = GetPageHeight();
24 public abstract int GetPageHeight();
26 public virtual void OnShow()
31 public virtual void OnHide()
35 internal virtual void ToggleUI(
bool visible)
39 public virtual void GiveBackItems()
44 protected UIElement TabFrame;
45 protected static Texture2D _topTexture => Assets.Textures.GUI.PanelTopTexture;
46 protected static Texture2D _middleTexture => Assets.Textures.GUI.PanelTileTexture;
47 protected static Texture2D _bottomTexture => Assets.Textures.GUI.PanelBottomTexture;
49 public int TotalHeight => _topTexture.Height + _pageHeight + _bottomTexture.Height;
51 public override void OnInitialize()
55 Height.Set(_pageHeight + _topTexture.Height + _bottomTexture.Height, 0);
58 TabFrame =
new UIElement
60 Top =
new StyleDimension(SPACING, 0),
61 Left =
new StyleDimension(SPACING, 0),
62 Width =
new StyleDimension(Width.Pixels - SPACING * 2, 0),
63 Height =
new StyleDimension(Height.Pixels - SPACING * 2, 0)
68 protected override void DrawSelf(SpriteBatch spriteBatch)
70 var parentBounds = GetOuterDimensions().ToRectangle();
72 Rectangle BoundsWithOffset(Vector2 bounds, Point off)
74 return new Rectangle(parentBounds.X + off.X, parentBounds.Y + off.Y, (
int)bounds.X, (
int)bounds.Y);
79 _topTexture.BoundsFromParent(parentBounds),
83 Point offset =
new Point(
88 for (
int i = 0; i < _pageHeight; i++)
92 _middleTexture.BoundsFromParent(BoundsWithOffset(_middleTexture.Size(), offset)),
100 _bottomTexture.BoundsFromParent(BoundsWithOffset(_bottomTexture.Size(), offset)),