2019-09-11 12:30:29 +02:00
|
|
|
using System.Linq;
|
2019-08-16 19:08:36 +02:00
|
|
|
using Microsoft.Xna.Framework;
|
2019-09-09 17:12:36 +02:00
|
|
|
using Microsoft.Xna.Framework.Input;
|
|
|
|
using MLEM.Misc;
|
2019-08-16 19:08:36 +02:00
|
|
|
|
|
|
|
namespace MLEM.Ui.Elements {
|
|
|
|
public class Slider : ScrollBar {
|
|
|
|
|
|
|
|
public Slider(Anchor anchor, Vector2 size, int scrollerSize, float maxValue) :
|
|
|
|
base(anchor, size, scrollerSize, maxValue, true) {
|
2019-09-09 17:12:36 +02:00
|
|
|
this.CanBeSelected = true;
|
2019-09-11 10:49:51 +02:00
|
|
|
this.GetGamepadNextElement = (dir, next) => {
|
|
|
|
if (dir == Direction2.Left || dir == Direction2.Right)
|
|
|
|
return null;
|
|
|
|
return next;
|
|
|
|
};
|
2019-09-09 17:12:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public override void Update(GameTime time) {
|
|
|
|
base.Update(time);
|
|
|
|
|
|
|
|
if (this.IsSelected) {
|
2020-03-16 19:44:32 +01:00
|
|
|
if (this.Controls.LeftButtons.Any(b => this.Input.IsPressed(b, this.Controls.GamepadIndex))) {
|
2019-09-09 17:12:36 +02:00
|
|
|
this.CurrentValue -= this.StepPerScroll;
|
2020-03-16 19:44:32 +01:00
|
|
|
} else if (this.Controls.RightButtons.Any(b => this.Input.IsPressed(b, this.Controls.GamepadIndex))) {
|
2019-09-09 17:12:36 +02:00
|
|
|
this.CurrentValue += this.StepPerScroll;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-08-16 19:08:36 +02:00
|
|
|
}
|
|
|
|
}
|