Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
UISelectableTextPanel.cs
Go to the documentation of this file.
1using System;
5using Terraria.UI;
6
8
10{
12
14
15 private Func<UISelectableTextPanel<T>, bool> _isSelected;
16
17 public Func<UISelectableTextPanel<T>, bool> IsSelected
18 {
19 get
20 {
21 return _isSelected;
22 }
23 set
24 {
26 }
27 }
28
29 public UISelectableTextPanel(T text, float textScale = 1f, bool large = false)
30 : base(text, textScale, large)
31 {
32 _BasePanelTexture = Main.Assets.Request<Texture2D>("Images/UI/CharCreation/PanelGrayscale", (AssetRequestMode)1);
33 _hoveredBorderTexture = Main.Assets.Request<Texture2D>("Images/UI/CharCreation/CategoryPanelBorder", (AssetRequestMode)1);
34 }
35
36 protected override void DrawSelf(SpriteBatch spriteBatch)
37 {
38 if (_drawPanel)
39 {
40 CalculatedStyle dimensions = GetDimensions();
41 int num = 4;
42 int num2 = 10;
43 int num3 = 10;
44 Utils.DrawSplicedPanel(spriteBatch, _BasePanelTexture.Value, (int)dimensions.X, (int)dimensions.Y, (int)dimensions.Width, (int)dimensions.Height, num2, num2, num3, num3, Color.Lerp(Color.Black, _color, 0.8f) * 0.5f);
45 if (IsSelected != null && IsSelected(this))
46 {
47 Utils.DrawSplicedPanel(spriteBatch, _BasePanelTexture.Value, (int)dimensions.X + num, (int)dimensions.Y + num, (int)dimensions.Width - num * 2, (int)dimensions.Height - num * 2, num2, num2, num3, num3, Color.Lerp(_color, Color.White, 0.7f) * 0.5f);
48 }
49 if (base.IsMouseHovering)
50 {
51 Utils.DrawSplicedPanel(spriteBatch, _hoveredBorderTexture.Value, (int)dimensions.X, (int)dimensions.Y, (int)dimensions.Width, (int)dimensions.Height, num2, num2, num3, num3, Color.White);
52 }
53 }
54 DrawText(spriteBatch);
55 }
56}
UISelectableTextPanel(T text, float textScale=1f, bool large=false)
Func< UISelectableTextPanel< T >, bool > IsSelected
Func< UISelectableTextPanel< T >, bool > _isSelected
void DrawText(SpriteBatch spriteBatch)
static IAssetRepository Assets
Definition Main.cs:209
CalculatedStyle GetDimensions()
Definition UIElement.cs:382
static void DrawSplicedPanel(SpriteBatch sb, Texture2D texture, int x, int y, int w, int h, int leftEnd, int rightEnd, int topEnd, int bottomEnd, Color c)
Definition Utils.cs:1964
static Color Lerp(Color value1, Color value2, float amount)
Definition Color.cs:491