1
0
Fork 0
mirror of https://github.com/Ellpeck/MLEM.git synced 2024-11-26 06:28:35 +01:00
MLEM/MLEM.Ui/Elements/Slider.cs
2019-09-09 17:12:36 +02:00

32 lines
No EOL
1.2 KiB
C#

using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Input;
using MLEM.Misc;
namespace MLEM.Ui.Elements {
public class Slider : ScrollBar {
public Slider(Anchor anchor, Vector2 size, int scrollerSize, float maxValue) :
base(anchor, size, scrollerSize, maxValue, true) {
this.CanBeSelected = true;
}
public override void Update(GameTime time) {
base.Update(time);
if (this.IsSelected) {
if (this.Input.IsGamepadButtonDown(Buttons.DPadLeft) || this.Input.IsGamepadButtonDown(Buttons.LeftThumbstickLeft)) {
this.CurrentValue -= this.StepPerScroll;
} else if (this.Input.IsGamepadButtonDown(Buttons.DPadRight) || this.Input.IsGamepadButtonDown(Buttons.LeftThumbstickRight)) {
this.CurrentValue += this.StepPerScroll;
}
}
}
public override Element GetGamepadNextElement(Direction2 dir, Element usualNext) {
if (dir == Direction2.Left || dir == Direction2.Right)
return null;
return base.GetGamepadNextElement(dir, usualNext);
}
}
}