mirror of
https://github.com/Ellpeck/MLEM.git
synced 2024-11-22 12:58:33 +01:00
added getParentTree to ui
This commit is contained in:
parent
05f148514f
commit
79a4c36029
2 changed files with 10 additions and 1 deletions
|
@ -383,6 +383,14 @@ namespace MLEM.Ui.Elements {
|
|||
}
|
||||
}
|
||||
|
||||
public IEnumerable<Element> GetParentTree() {
|
||||
if (this.Parent == null)
|
||||
yield break;
|
||||
yield return this.Parent;
|
||||
foreach (var parent in this.Parent.GetParentTree())
|
||||
yield return parent;
|
||||
}
|
||||
|
||||
public virtual void Update(GameTime time) {
|
||||
foreach (var child in this.SortedChildren)
|
||||
child.Update(time);
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using System;
|
||||
using System.Linq;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using MLEM.Extensions;
|
||||
|
@ -63,7 +64,7 @@ namespace MLEM.Ui.Elements {
|
|||
}
|
||||
}
|
||||
|
||||
if (!this.Horizontal && (moused == this.Parent || moused?.Parent == this.Parent)) {
|
||||
if (!this.Horizontal && moused != null && (moused == this.Parent || moused.GetParentTree().Contains(this.Parent))) {
|
||||
var scroll = this.Input.LastScrollWheel - this.Input.ScrollWheel;
|
||||
if (scroll != 0)
|
||||
this.CurrentValue += this.StepPerScroll * Math.Sign(scroll);
|
||||
|
|
Loading…
Reference in a new issue