1
0
Fork 0
mirror of https://github.com/Ellpeck/MLEM.git synced 2024-05-24 01:23:37 +02:00

added getParentTree to ui

This commit is contained in:
Ellpeck 2019-08-21 17:00:22 +02:00
parent 05f148514f
commit 79a4c36029
2 changed files with 10 additions and 1 deletions

View file

@ -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);

View file

@ -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);