mirror of
https://github.com/Ellpeck/MLEM.git
synced 2024-11-29 23:58:34 +01:00
Fixed dropdown menus not working with gamepads
This commit is contained in:
parent
e96b155f99
commit
6c866cec74
1 changed files with 16 additions and 0 deletions
|
@ -1,4 +1,6 @@
|
||||||
|
using System.Linq;
|
||||||
using Microsoft.Xna.Framework;
|
using Microsoft.Xna.Framework;
|
||||||
|
using MLEM.Misc;
|
||||||
|
|
||||||
namespace MLEM.Ui.Elements {
|
namespace MLEM.Ui.Elements {
|
||||||
public class Dropdown : Button {
|
public class Dropdown : Button {
|
||||||
|
@ -24,6 +26,20 @@ namespace MLEM.Ui.Elements {
|
||||||
|
|
||||||
public void AddElement(Element element) {
|
public void AddElement(Element element) {
|
||||||
this.Panel.AddChild(element);
|
this.Panel.AddChild(element);
|
||||||
|
// Since the dropdown causes elements to be over each other,
|
||||||
|
// usual gamepad code doesn't apply
|
||||||
|
element.GetGamepadNextElement = (dir, usualNext) => {
|
||||||
|
if (dir == Direction2.Up) {
|
||||||
|
var prev = element.GetOlderSibling();
|
||||||
|
if (prev != null)
|
||||||
|
return prev;
|
||||||
|
} else if (dir == Direction2.Down) {
|
||||||
|
var next = element.GetSiblings(e => e.GetOlderSibling() == element).FirstOrDefault();
|
||||||
|
if (next != null)
|
||||||
|
return next;
|
||||||
|
}
|
||||||
|
return usualNext;
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
public void AddElement(string text, GenericCallback pressed = null) {
|
public void AddElement(string text, GenericCallback pressed = null) {
|
||||||
|
|
Loading…
Reference in a new issue