diff --git a/CHANGELOG.md b/CHANGELOG.md
index 81cdc74..271354a 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -19,10 +19,16 @@ Fixes
- Fixed TextInput drawing characters with the wrong width if a masking character is used
- Fixed a multiline TextInput's cursor not returning to the default position when the last character is removed
+Improvements
+- Increased TextFormatter macro recursion limit to 64
+
### MLEM.Ui
Fixes
- Fixed images not updating their hidden state properly when the displayed texture changes
+Improvements
+- Increased Element area calculation recursion limit to 64
+
## 6.1.0
### MLEM
diff --git a/MLEM.Ui/Elements/Element.cs b/MLEM.Ui/Elements/Element.cs
index d646d0e..d72d81d 100644
--- a/MLEM.Ui/Elements/Element.cs
+++ b/MLEM.Ui/Elements/Element.cs
@@ -801,8 +801,8 @@ namespace MLEM.Ui.Elements {
// we want to leave some leeway to prevent float rounding causing an infinite loop
if (!autoSize.Equals(this.UnscrolledArea.Size, Element.Epsilon)) {
recursion++;
- if (recursion >= 16)
- throw new ArithmeticException($"The area of {this} with root {this.Root.Name} has recursively updated too often. Does its child {foundChild} contain any conflicting auto-sizing settings?");
+ if (recursion >= 64)
+ throw new ArithmeticException($"The area of {this} has recursively updated too often. Does its child {foundChild} contain any conflicting auto-sizing settings?");
UpdateDisplayArea(autoSize);
}
}
@@ -1150,6 +1150,18 @@ namespace MLEM.Ui.Elements {
GC.SuppressFinalize(this);
}
+ ///
+ public override string ToString() {
+ var ret = this.GetType().ToString();
+ // elements will contain their path up to the root (Paragraph@Panel@...@RootName)
+ if (this.Parent != null) {
+ ret += $"@{this.Parent}";
+ } else if (this.Root?.Element == this) {
+ ret += $"@{this.Root.Name}";
+ }
+ return ret;
+ }
+
///
/// Performs the specified action on this element and all of its
///
diff --git a/MLEM/Formatting/TextFormatter.cs b/MLEM/Formatting/TextFormatter.cs
index 205f0f2..11c1880 100644
--- a/MLEM/Formatting/TextFormatter.cs
+++ b/MLEM/Formatting/TextFormatter.cs
@@ -131,21 +131,22 @@ namespace MLEM.Formatting {
public string ResolveMacros(string s) {
// resolve macros that resolve into macros
var rec = 0;
+ var ret = s;
bool matched;
do {
matched = false;
foreach (var macro in this.Macros) {
- s = macro.Key.Replace(s, m => {
+ ret = macro.Key.Replace(ret, m => {
// if the match evaluator was queried, then we know we matched something
matched = true;
return macro.Value(this, m, macro.Key);
});
}
rec++;
- if (rec >= 16)
- throw new ArithmeticException($"A string resolved macros recursively too many times. Does it contain any conflicting macros?\n{s}");
+ if (rec >= 64)
+ throw new ArithmeticException($"A string resolved macros recursively too many times. Does it contain any conflicting macros?\nOriginal: {s}\nCurrent: {ret}");
} while (matched);
- return s;
+ return ret;
}
private Code GetNextCode(string s, int index, int maxIndex = int.MaxValue) {