Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
UIKeybindingSimpleListItem.cs
Go to the documentation of this file.
1using System;
4using Terraria.UI;
6
8
10{
11 private Color _color;
12
13 private Func<string> _GetTextFunction;
14
15 public UIKeybindingSimpleListItem(Func<string> getText, Color color)
16 {
17 _color = color;
18 _GetTextFunction = ((getText != null) ? getText : ((Func<string>)(() => "???")));
19 }
20
21 protected override void DrawSelf(SpriteBatch spriteBatch)
22 {
23 float num = 6f;
24 base.DrawSelf(spriteBatch);
25 CalculatedStyle dimensions = GetDimensions();
26 float num2 = dimensions.Width + 1f;
27 Vector2 vector = new Vector2(dimensions.X, dimensions.Y);
28 Vector2 baseScale = new Vector2(0.8f);
29 Color value = (base.IsMouseHovering ? Color.White : Color.Silver);
30 value = Color.Lerp(value, Color.White, base.IsMouseHovering ? 0.5f : 0f);
31 Color color = (base.IsMouseHovering ? _color : _color.MultiplyRGBA(new Color(180, 180, 180)));
32 Vector2 position = vector;
33 Utils.DrawSettings2Panel(spriteBatch, position, num2, color);
34 position.X += 8f;
35 position.Y += 2f + num;
36 string text = _GetTextFunction();
37 Vector2 stringSize = ChatManager.GetStringSize(FontAssets.ItemStack.Value, text, baseScale);
38 position.X = dimensions.X + dimensions.Width / 2f - stringSize.X / 2f;
39 ChatManager.DrawColorCodedStringWithShadow(spriteBatch, FontAssets.ItemStack.Value, text, position, value, 0f, Vector2.Zero, baseScale, num2);
40 }
41}
static Asset< DynamicSpriteFont > ItemStack
Definition FontAssets.cs:8
static Vector2 DrawColorCodedStringWithShadow(SpriteBatch spriteBatch, DynamicSpriteFont font, TextSnippet[] snippets, Vector2 position, float rotation, Vector2 origin, Vector2 baseScale, out int hoveredSnippet, float maxWidth=-1f, float spread=2f)
static Vector2 GetStringSize(DynamicSpriteFont font, string text, Vector2 baseScale, float maxWidth=-1f)
CalculatedStyle GetDimensions()
Definition UIElement.cs:382
static void DrawSettings2Panel(SpriteBatch spriteBatch, Vector2 position, float width, Color color)
Definition Utils.cs:1990
static Color Lerp(Color value1, Color value2, float amount)
Definition Color.cs:491