mirror of
https://github.com/Ellpeck/MLEM.git
synced 2024-11-22 04:53:29 +01:00
Increased some recursion limits, and added useful Element ToString
This commit is contained in:
parent
dbd7f66c89
commit
c4836eedd6
3 changed files with 25 additions and 6 deletions
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
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;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Performs the specified action on this element and all of its <see cref="Children"/>
|
||||
/// </summary>
|
||||
|
|
|
@ -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) {
|
||||
|
|
Loading…
Reference in a new issue