mirror of
https://github.com/Ellpeck/MLEM.git
synced 2024-11-26 06:28:35 +01:00
make next elements into delegates rather than a method
This commit is contained in:
parent
39be76fbbf
commit
e38d95c665
2 changed files with 13 additions and 14 deletions
|
@ -79,6 +79,8 @@ namespace MLEM.Ui.Elements {
|
||||||
public GenericCallback OnAreaUpdated;
|
public GenericCallback OnAreaUpdated;
|
||||||
public OtherElementCallback OnMousedElementChanged;
|
public OtherElementCallback OnMousedElementChanged;
|
||||||
public OtherElementCallback OnSelectedElementChanged;
|
public OtherElementCallback OnSelectedElementChanged;
|
||||||
|
public TabNextElementCallback GetTabNextElement;
|
||||||
|
public GamepadNextElementCallback GetGamepadNextElement;
|
||||||
|
|
||||||
private UiSystem system;
|
private UiSystem system;
|
||||||
public UiSystem System {
|
public UiSystem System {
|
||||||
|
@ -145,6 +147,8 @@ namespace MLEM.Ui.Elements {
|
||||||
this.OnMouseExit += element => this.IsMouseOver = false;
|
this.OnMouseExit += element => this.IsMouseOver = false;
|
||||||
this.OnSelected += element => this.IsSelected = true;
|
this.OnSelected += element => this.IsSelected = true;
|
||||||
this.OnDeselected += element => this.IsSelected = false;
|
this.OnDeselected += element => this.IsSelected = false;
|
||||||
|
this.GetTabNextElement = (backward, next) => next;
|
||||||
|
this.GetGamepadNextElement = (dir, next) => next;
|
||||||
|
|
||||||
this.SetAreaDirty();
|
this.SetAreaDirty();
|
||||||
}
|
}
|
||||||
|
@ -434,14 +438,6 @@ namespace MLEM.Ui.Elements {
|
||||||
return this.CanBeMoused && this.Area.Contains(position) ? this : null;
|
return this.CanBeMoused && this.Area.Contains(position) ? this : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual Element GetTabNextElement(bool backward, Element usualNext) {
|
|
||||||
return usualNext;
|
|
||||||
}
|
|
||||||
|
|
||||||
public virtual Element GetGamepadNextElement(Direction2 dir, Element usualNext) {
|
|
||||||
return usualNext;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void AndChildren(Action<Element> action) {
|
public void AndChildren(Action<Element> action) {
|
||||||
action(this);
|
action(this);
|
||||||
foreach (var child in this.Children)
|
foreach (var child in this.Children)
|
||||||
|
@ -460,5 +456,9 @@ namespace MLEM.Ui.Elements {
|
||||||
|
|
||||||
public delegate void DrawCallback(Element element, GameTime time, SpriteBatch batch, float alpha);
|
public delegate void DrawCallback(Element element, GameTime time, SpriteBatch batch, float alpha);
|
||||||
|
|
||||||
|
public delegate Element TabNextElementCallback(bool backward, Element usualNext);
|
||||||
|
|
||||||
|
public delegate Element GamepadNextElementCallback(Direction2 dir, Element usualNext);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -8,6 +8,11 @@ namespace MLEM.Ui.Elements {
|
||||||
public Slider(Anchor anchor, Vector2 size, int scrollerSize, float maxValue) :
|
public Slider(Anchor anchor, Vector2 size, int scrollerSize, float maxValue) :
|
||||||
base(anchor, size, scrollerSize, maxValue, true) {
|
base(anchor, size, scrollerSize, maxValue, true) {
|
||||||
this.CanBeSelected = true;
|
this.CanBeSelected = true;
|
||||||
|
this.GetGamepadNextElement = (dir, next) => {
|
||||||
|
if (dir == Direction2.Left || dir == Direction2.Right)
|
||||||
|
return null;
|
||||||
|
return next;
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Update(GameTime time) {
|
public override void Update(GameTime time) {
|
||||||
|
@ -22,11 +27,5 @@ namespace MLEM.Ui.Elements {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override Element GetGamepadNextElement(Direction2 dir, Element usualNext) {
|
|
||||||
if (dir == Direction2.Left || dir == Direction2.Right)
|
|
||||||
return null;
|
|
||||||
return base.GetGamepadNextElement(dir, usualNext);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in a new issue