diff --git a/MLEM.Ui/Elements/Element.cs b/MLEM.Ui/Elements/Element.cs index a514d13..976e5a7 100644 --- a/MLEM.Ui/Elements/Element.cs +++ b/MLEM.Ui/Elements/Element.cs @@ -331,9 +331,7 @@ namespace MLEM.Ui.Elements { public Element GetLowestChild(Func condition = null) { Element lowest = null; - // the lowest child is expected to be towards the back, so search is usually faster if done backwards - for (var i = this.Children.Count - 1; i >= 0; i--) { - var child = this.Children[i]; + foreach (var child in this.Children) { if (condition != null && !condition(child)) continue; if (child.Anchor > Anchor.TopRight && child.Anchor < Anchor.AutoLeft) @@ -384,18 +382,6 @@ namespace MLEM.Ui.Elements { } } - public IEnumerable GetChildren(Func condition = null, bool regardGrandchildren = false, bool ignoreFalseGrandchildren = false) { - foreach (var child in this.Children) { - var applies = condition == null || condition(child); - if (applies) - yield return child; - if (regardGrandchildren && (!ignoreFalseGrandchildren || applies)) { - foreach (var cc in child.GetChildren(condition, true, ignoreFalseGrandchildren)) - yield return cc; - } - } - } - public IEnumerable GetChildren(Func condition = null, bool regardGrandchildren = false, bool ignoreFalseGrandchildren = false) where T : Element { foreach (var child in this.Children) { var applies = child is T t && (condition == null || condition(t)); @@ -408,6 +394,10 @@ namespace MLEM.Ui.Elements { } } + public IEnumerable GetChildren(Func condition = null, bool regardGrandchildren = false, bool ignoreFalseGrandchildren = false) { + return this.GetChildren(condition, regardGrandchildren, ignoreFalseGrandchildren); + } + public IEnumerable GetParentTree() { if (this.Parent == null) yield break;