diff --git a/CHANGELOG.md b/CHANGELOG.md
index 9201426..fda7b5c 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -75,6 +75,7 @@ Improvements
- Added TextField.OnCopyPasteException to allow handling exceptions thrown by TextCopy
- Avoid paragraphs splitting or truncating their text unnecessarily
- Automatically mark elements dirty when various member values are changed
+- Allow initializing a ui system's text formatter without default codes and macros
Fixes
- Fixed parents of elements that prevent spill not being notified properly
@@ -86,6 +87,7 @@ Fixes
- Fixed the scroll bar of an empty panel being positioned incorrectly
- Fixed UiControls maintaining old input states when input types are toggled off
- Fixed an occasional deadlock when a game is disposed with a scrolling Panel present
+- Fixed UiStyle.LinkColor not being applied to the ui system when changed
Removals
- Marked Element.OnDisposed as obsolete in favor of the more predictable OnRemovedFromUi
diff --git a/MLEM.Ui/UiSystem.cs b/MLEM.Ui/UiSystem.cs
index b99caba..4e96e2e 100644
--- a/MLEM.Ui/UiSystem.cs
+++ b/MLEM.Ui/UiSystem.cs
@@ -206,7 +206,12 @@ namespace MLEM.Ui {
/// The style settings that this ui should have. Use for the default, untextured style.
/// The input handler that this ui's should use. If none is supplied, a new input handler is created for this ui.
/// If this value is set to true, the ui system's will be set automatically based on the 's size. Defaults to true.
- public UiSystem(Game game, UiStyle style, InputHandler inputHandler = null, bool automaticViewport = true) : base(game) {
+ /// Whether default font modifier codes should be added to this ui system's , including bold, italic, strikethrough, shadow, subscript, and more.
+ /// Whether default color codes should be added to this ui system's , including all values and the ability to use custom colors.
+ /// Whether default animation codes should be added to this ui system's , namely the wobbly animation.
+ /// Whether default macros should be added to this ui system's , including TeX's ~ non-breaking space and more.
+ /// Whether -based formatting codes should be added to this ui system's , including codes and font switching.
+ public UiSystem(Game game, UiStyle style, InputHandler inputHandler = null, bool automaticViewport = true, bool hasFontModifierFormatting = true, bool hasColorFormatting = true, bool hasAnimationFormatting = true, bool hasMacroFormatting = true, bool hasUiFormatting = true) : base(game) {
this.Controls = new UiControls(this, inputHandler);
this.style = style;
@@ -248,12 +253,14 @@ namespace MLEM.Ui {
};
}
- this.TextFormatter = new TextFormatter();
- this.TextFormatter.Codes.Add(new Regex("]+))?>"), (f, m, r) => new LinkCode(m, r, 1 / 16F, 0.85F,
- t => this.Controls.MousedElement is Paragraph.Link l1 && l1.Token == t || this.Controls.TouchedElement is Paragraph.Link l2 && l2.Token == t,
- this.Style.LinkColor));
- this.TextFormatter.Codes.Add(new Regex("]+)>"), (_, m, r) => new FontCode(m, r,
- f => this.Style.AdditionalFonts != null && this.Style.AdditionalFonts.TryGetValue(m.Groups[1].Value, out var c) ? c : f));
+ this.TextFormatter = new TextFormatter(hasFontModifierFormatting, hasColorFormatting, hasAnimationFormatting, hasMacroFormatting);
+ if (hasUiFormatting) {
+ this.TextFormatter.Codes.Add(new Regex("]+))?>"), (f, m, r) => new LinkCode(m, r, 1 / 16F, 0.85F,
+ t => this.Controls.MousedElement is Paragraph.Link l1 && l1.Token == t || this.Controls.TouchedElement is Paragraph.Link l2 && l2.Token == t,
+ d => this.Style.LinkColor));
+ this.TextFormatter.Codes.Add(new Regex("]+)>"), (_, m, r) => new FontCode(m, r,
+ f => this.Style.AdditionalFonts != null && this.Style.AdditionalFonts.TryGetValue(m.Groups[1].Value, out var c) ? c : f));
+ }
}
///
diff --git a/MLEM/Formatting/Codes/LinkCode.cs b/MLEM/Formatting/Codes/LinkCode.cs
index e8118ac..618d63a 100644
--- a/MLEM/Formatting/Codes/LinkCode.cs
+++ b/MLEM/Formatting/Codes/LinkCode.cs
@@ -9,14 +9,19 @@ namespace MLEM.Formatting.Codes {
public class LinkCode : UnderlineCode {
private readonly Func isSelected;
- private readonly Color? color;
+ private readonly Func color;
///
- public LinkCode(Match match, Regex regex, float thickness, float yOffset, Func isSelected, Color? color = null) : base(match, regex, thickness, yOffset) {
+ public LinkCode(Match match, Regex regex, float thickness, float yOffset, Func isSelected, Func color) :
+ base(match, regex, thickness, yOffset) {
this.isSelected = isSelected;
this.color = color;
}
+ ///
+ public LinkCode(Match match, Regex regex, float thickness, float yOffset, Func isSelected, Color? color = null) :
+ this(match, regex, thickness, yOffset, isSelected, d => color) {}
+
///
/// Returns true if this link formatting code is currently selected or hovered over, based on the selection function.
///
@@ -31,7 +36,7 @@ namespace MLEM.Formatting.Codes {
///
public override Color? GetColor(Color defaultPick) {
- return this.color;
+ return this.color.Invoke(defaultPick);
}
///