Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
UIKeybindingSliderItem.cs
Go to the documentation of this file.
1using System;
6using Terraria.UI;
8
10
12{
13 private Color _color;
14
15 private Func<string> _TextDisplayFunction;
16
17 private Func<float> _GetStatusFunction;
18
19 private Action<float> _SlideKeyboardAction;
20
21 private Action _SlideGamepadAction;
22
23 private int _sliderIDInPage;
24
26
27 public UIKeybindingSliderItem(Func<string> getText, Func<float> getStatus, Action<float> setStatusKeyboard, Action setStatusGamepad, int sliderIDInPage, Color color)
28 {
29 _color = color;
30 _toggleTexture = Main.Assets.Request<Texture2D>("Images/UI/Settings_Toggle", (AssetRequestMode)1);
31 _TextDisplayFunction = ((getText != null) ? getText : ((Func<string>)(() => "???")));
32 _GetStatusFunction = ((getStatus != null) ? getStatus : ((Func<float>)(() => 0f)));
33 _SlideKeyboardAction = ((setStatusKeyboard != null) ? setStatusKeyboard : ((Action<float>)delegate
34 {
35 }));
36 _SlideGamepadAction = ((setStatusGamepad != null) ? setStatusGamepad : ((Action)delegate
37 {
38 }));
39 _sliderIDInPage = sliderIDInPage;
40 }
41
42 protected override void DrawSelf(SpriteBatch spriteBatch)
43 {
44 float num = 6f;
45 base.DrawSelf(spriteBatch);
46 int num2 = 0;
47 IngameOptions.rightHover = -1;
48 if (!Main.mouseLeft)
49 {
50 IngameOptions.rightLock = -1;
51 }
53 {
54 num2 = 1;
55 }
56 else if (IngameOptions.rightLock != -1)
57 {
58 num2 = 2;
59 }
60 CalculatedStyle dimensions = GetDimensions();
61 float num3 = dimensions.Width + 1f;
62 Vector2 vector = new Vector2(dimensions.X, dimensions.Y);
63 bool flag = base.IsMouseHovering;
64 if (num2 == 1)
65 {
66 flag = true;
67 }
68 if (num2 == 2)
69 {
70 flag = false;
71 }
72 Vector2 baseScale = new Vector2(0.8f);
73 Color value = (false ? Color.Gold : (flag ? Color.White : Color.Silver));
74 value = Color.Lerp(value, Color.White, flag ? 0.5f : 0f);
75 Color color = (flag ? _color : _color.MultiplyRGBA(new Color(180, 180, 180)));
76 Vector2 position = vector;
77 Utils.DrawSettingsPanel(spriteBatch, position, num3, color);
78 position.X += 8f;
79 position.Y += 2f + num;
80 ChatManager.DrawColorCodedStringWithShadow(spriteBatch, FontAssets.ItemStack.Value, _TextDisplayFunction(), position, value, 0f, Vector2.Zero, baseScale, num3);
81 position.X -= 17f;
82 TextureAssets.ColorBar.Frame();
83 position = new Vector2(dimensions.X + dimensions.Width - 10f, dimensions.Y + 10f + num);
84 IngameOptions.valuePosition = position;
85 float obj = IngameOptions.DrawValueBar(spriteBatch, 1f, _GetStatusFunction(), num2);
87 {
88 IngameOptions.rightHover = _sliderIDInPage;
90 {
92 }
93 }
95 {
96 IngameOptions.rightLock = IngameOptions.rightHover;
97 }
98 if (base.IsMouseHovering && PlayerInput.CurrentProfile.AllowEditting)
99 {
101 }
102 }
103}
static Asset< DynamicSpriteFont > ItemStack
Definition FontAssets.cs:8
static Asset< Texture2D > ColorBar
UIKeybindingSliderItem(Func< string > getText, Func< float > getStatus, Action< float > setStatusKeyboard, Action setStatusGamepad, int sliderIDInPage, Color color)
static TriggersPack Triggers
static PlayerInputProfile CurrentProfile
static float DrawValueBar(SpriteBatch sb, float scale, float perc, int lockState=0, Utils.ColorLerpMethod colorMethod=null)
static IAssetRepository Assets
Definition Main.cs:209
static bool mouseLeft
Definition Main.cs:614
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)
CalculatedStyle GetDimensions()
Definition UIElement.cs:382
static void DrawSettingsPanel(SpriteBatch spriteBatch, Vector2 position, float width, Color color)
Definition Utils.cs:1985
delegate void Action()
static Color Lerp(Color value1, Color value2, float amount)
Definition Color.cs:491