diff --git a/CHANGELOG.md b/CHANGELOG.md
index 372aca3..02b496c 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -27,6 +27,7 @@ Improvements
- Only set a paragraph's area dirty when a text change would cause it to change size
- Ensure that a panel gets notified of all relevant changes by calling OnChildAreaDirty for all grandchildren
- Avoid unnecessary panel updates by using an Epsilon comparison when scrolling children
+- Allow setting a default text alignment for paragraphs in UiStyle
Fixes
- Fixed paragraph links having incorrect hover locations when using special text alignments
diff --git a/MLEM.Ui/Elements/Paragraph.cs b/MLEM.Ui/Elements/Paragraph.cs
index 0784e2b..87d3ae4 100644
--- a/MLEM.Ui/Elements/Paragraph.cs
+++ b/MLEM.Ui/Elements/Paragraph.cs
@@ -90,7 +90,7 @@ namespace MLEM.Ui.Elements {
///
/// The that this paragraph's text should be rendered with
///
- public TextAlignment Alignment {
+ public StyleProp Alignment {
get => this.alignment;
set {
this.alignment = value;
@@ -99,7 +99,7 @@ namespace MLEM.Ui.Elements {
}
private string text;
- private TextAlignment alignment;
+ private StyleProp alignment;
private StyleProp regularFont;
///
@@ -158,6 +158,7 @@ namespace MLEM.Ui.Elements {
this.RegularFont = this.RegularFont.OrStyle(style.Font ?? throw new NotSupportedException("Paragraphs cannot use ui styles that don't have a font. Please supply a custom font by setting UiStyle.Font."));
this.TextScale = this.TextScale.OrStyle(style.TextScale);
this.TextColor = this.TextColor.OrStyle(style.TextColor);
+ this.Alignment = this.Alignment.OrStyle(style.TextAlignment);
}
///
@@ -202,7 +203,7 @@ namespace MLEM.Ui.Elements {
}
private float GetAlignmentOffset() {
- switch (this.Alignment) {
+ switch (this.Alignment.Value) {
case TextAlignment.Center:
return this.DisplayArea.Width / 2;
case TextAlignment.Right:
diff --git a/MLEM.Ui/Style/UiStyle.cs b/MLEM.Ui/Style/UiStyle.cs
index 8aa7451..427342d 100644
--- a/MLEM.Ui/Style/UiStyle.cs
+++ b/MLEM.Ui/Style/UiStyle.cs
@@ -199,6 +199,10 @@ namespace MLEM.Ui.Style {
///
public Color TextColor = Color.White;
///
+ /// The that a should use by default.
+ ///
+ public TextAlignment TextAlignment;
+ ///
/// The that should be played when an element's and events are called.
/// Note that this sound is only played if the callbacks have any subscribers.
///