diff --git a/MLEM.Ui/Elements/Paragraph.cs b/MLEM.Ui/Elements/Paragraph.cs
index 8dedb66..2eb2ac7 100644
--- a/MLEM.Ui/Elements/Paragraph.cs
+++ b/MLEM.Ui/Elements/Paragraph.cs
@@ -23,20 +23,11 @@ namespace MLEM.Ui.Elements {
public class Paragraph : Element {
private string text;
- private string splitText;
- [Obsolete("Use the new text formatting system in MLEM.Formatting instead")]
- public FormattingCodeCollection Formatting;
///
/// The font that this paragraph draws text with.
/// To set its bold and italic font, use and .
///
public StyleProp RegularFont;
- [Obsolete("Use the new GenericFont.Bold and GenericFont.Italic instead")]
- public StyleProp BoldFont;
- [Obsolete("Use the new GenericFont.Bold and GenericFont.Italic instead")]
- public StyleProp ItalicFont;
- [Obsolete("Use the new text formatting system in MLEM.Formatting instead")]
- public StyleProp FormatSettings;
///
/// The tokenized version of the
///
@@ -78,10 +69,6 @@ namespace MLEM.Ui.Elements {
/// Use this event for setting this paragraph's text if it changes frequently.
///
public TextCallback GetTextCallback;
- [Obsolete("Use the new text formatting system in MLEM.Formatting instead")]
- public TextModifier RenderedTextModifier = text => text;
- [Obsolete("Use the new text formatting system in MLEM.Formatting instead")]
- public TimeSpan TimeIntoAnimation;
///
/// Creates a new paragraph with the given settings.
@@ -112,13 +99,6 @@ namespace MLEM.Ui.Elements {
protected override Vector2 CalcActualSize(RectangleF parentArea) {
var size = base.CalcActualSize(parentArea);
this.ParseText(size);
-
- // old formatting stuff
- if (this.Formatting.Count > 0) {
- var textDims = this.RegularFont.Value.MeasureString(this.splitText) * this.TextScale * this.Scale;
- return new Vector2(this.AutoAdjustWidth ? textDims.X + this.ScaledPadding.Width : size.X, textDims.Y + this.ScaledPadding.Height);
- }
-
var dims = this.TokenizedText.Measure(this.RegularFont) * this.TextScale * this.Scale;
return new Vector2(this.AutoAdjustWidth ? dims.X + this.ScaledPadding.Width : size.X, dims.Y + this.ScaledPadding.Height);
}
@@ -127,9 +107,6 @@ namespace MLEM.Ui.Elements {
public override void Update(GameTime time) {
this.QueryTextCallback();
base.Update(time);
-
- this.TimeIntoAnimation += time.ElapsedGameTime;
-
if (this.TokenizedText != null)
this.TokenizedText.Update(time);
}
@@ -138,15 +115,8 @@ namespace MLEM.Ui.Elements {
public override void Draw(GameTime time, SpriteBatch batch, float alpha, BlendState blendState, SamplerState samplerState, Matrix matrix) {
var pos = this.DisplayArea.Location;
var sc = this.TextScale * this.Scale;
-
var color = this.TextColor.OrDefault(Color.White) * alpha;
- // legacy formatting stuff
- if (this.Formatting.Count > 0) {
- var toRender = this.RenderedTextModifier(this.splitText);
- this.RegularFont.Value.DrawFormattedString(batch, pos, toRender, this.Formatting, color, sc, this.BoldFont.Value, this.ItalicFont.Value, 0, this.TimeIntoAnimation, this.FormatSettings);
- } else {
- this.TokenizedText.Draw(time, batch, pos, this.RegularFont, color, sc, 0);
- }
+ this.TokenizedText.Draw(time, batch, pos, this.RegularFont, color, sc, 0);
base.Draw(time, batch, alpha, blendState, samplerState, matrix);
}
@@ -154,10 +124,7 @@ namespace MLEM.Ui.Elements {
protected override void InitStyle(UiStyle style) {
base.InitStyle(style);
this.TextScale.SetFromStyle(style.TextScale);
- this.RegularFont.SetFromStyle(style.Font);
- this.BoldFont.SetFromStyle(style.BoldFont ?? style.Font);
- this.ItalicFont.SetFromStyle(style.ItalicFont ?? style.Font);
- this.FormatSettings.SetFromStyle(style.FormatSettings);
+ this.RegularFont.SetFromStyle(style.Font);
}
///
@@ -166,10 +133,6 @@ namespace MLEM.Ui.Elements {
///
/// The paragraph's default size
protected virtual void ParseText(Vector2 size) {
- // old formatting stuff
- this.splitText = this.RegularFont.Value.SplitString(this.Text.RemoveFormatting(this.RegularFont.Value), size.X - this.ScaledPadding.Width, this.TextScale * this.Scale);
- this.Formatting = this.Text.GetFormattingCodes(this.RegularFont.Value);
-
if (this.TokenizedText == null)
this.TokenizedText = this.System.TextFormatter.Tokenize(this.RegularFont, this.Text);
@@ -204,9 +167,6 @@ namespace MLEM.Ui.Elements {
/// The current paragraph
public delegate string TextCallback(Paragraph paragraph);
- [Obsolete("Use the new text formatting system in MLEM.Formatting instead")]
- public delegate string TextModifier(string text);
-
///
/// A link is a sub-element of the that is added onto it as a child for any tokens that contain , to make them selectable and clickable.
///
diff --git a/MLEM.Ui/Style/UiStyle.cs b/MLEM.Ui/Style/UiStyle.cs
index db3cbb2..ad23233 100644
--- a/MLEM.Ui/Style/UiStyle.cs
+++ b/MLEM.Ui/Style/UiStyle.cs
@@ -129,12 +129,6 @@ namespace MLEM.Ui.Style {
/// Note that, to specify a bold and italic font for , you should use and .
///
public GenericFont Font;
- [Obsolete("Use the new GenericFont.Bold and GenericFont.Italic instead")]
- public GenericFont BoldFont;
- [Obsolete("Use the new GenericFont.Bold and GenericFont.Italic instead")]
- public GenericFont ItalicFont;
- [Obsolete("Use the new text formatting system in MLEM.Formatting instead")]
- public FormatSettings FormatSettings;
///
/// The scale that text should be rendered with in and other elements
///
diff --git a/MLEM/Formatting/Obsolete/FormatSettings.cs b/MLEM/Formatting/Obsolete/FormatSettings.cs
deleted file mode 100644
index f0e1149..0000000
--- a/MLEM/Formatting/Obsolete/FormatSettings.cs
+++ /dev/null
@@ -1,18 +0,0 @@
-using System;
-using Microsoft.Xna.Framework;
-using MLEM.Misc;
-
-namespace MLEM.Formatting {
- [Obsolete("Use the new text formatting system in MLEM.Formatting instead")]
- public class FormatSettings : GenericDataHolder {
-
- public static readonly FormatSettings Default = new FormatSettings();
-
- public float WobbleModifier = 5;
- public float WobbleHeightModifier = 1 / 8F;
- public float TypingSpeed = 20;
- public Color DropShadowColor = Color.Black;
- public Vector2 DropShadowOffset = new Vector2(2);
-
- }
-}
\ No newline at end of file
diff --git a/MLEM/Formatting/Obsolete/FormattingCode.cs b/MLEM/Formatting/Obsolete/FormattingCode.cs
deleted file mode 100644
index 3c1c155..0000000
--- a/MLEM/Formatting/Obsolete/FormattingCode.cs
+++ /dev/null
@@ -1,65 +0,0 @@
-using System;
-using Microsoft.Xna.Framework;
-using MLEM.Animations;
-using MLEM.Extensions;
-using MLEM.Font;
-using MLEM.Textures;
-
-namespace MLEM.Formatting {
- [Obsolete("Use the new text formatting system in MLEM.Formatting instead")]
- public class FormattingCode {
-
- public readonly Type CodeType;
- public readonly Color Color;
- public readonly TextStyle Style;
- public readonly SpriteAnimation Icon;
- public readonly TextAnimation.DrawCharacter Animation;
-
- public FormattingCode(Color color) {
- this.Color = color;
- this.CodeType = Type.Color;
- }
-
- public FormattingCode(TextStyle style) {
- this.Style = style;
- this.CodeType = Type.Style;
- }
-
- public FormattingCode(TextureRegion icon) :
- this(new SpriteAnimation(0, icon)) {
- }
-
- public FormattingCode(SpriteAnimation icon) {
- this.Icon = icon;
- this.CodeType = Type.Icon;
- }
-
- public FormattingCode(TextAnimation.DrawCharacter animation) {
- this.Animation = animation;
- this.CodeType = Type.Animation;
- }
-
- public virtual string GetReplacementString(GenericFont font) {
- return this.CodeType == Type.Icon ? font.GetWidthString(font.LineHeight) : string.Empty;
- }
-
- public enum Type {
-
- Color,
- Style,
- Icon,
- Animation
-
- }
-
- }
-
- public enum TextStyle {
-
- Regular,
- Bold,
- Italic,
- Shadow
-
- }
-}
\ No newline at end of file
diff --git a/MLEM/Formatting/Obsolete/FormattingCodeCollection.cs b/MLEM/Formatting/Obsolete/FormattingCodeCollection.cs
deleted file mode 100644
index e1a5ba3..0000000
--- a/MLEM/Formatting/Obsolete/FormattingCodeCollection.cs
+++ /dev/null
@@ -1,26 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text.RegularExpressions;
-using MLEM.Misc;
-
-namespace MLEM.Formatting {
- [Obsolete("Use the new text formatting system in MLEM.Formatting instead")]
- public class FormattingCodeCollection : Dictionary> {
-
- }
-
- [Obsolete("Use the new text formatting system in MLEM.Formatting instead")]
- public class FormattingCodeData : GenericDataHolder {
-
- public readonly FormattingCode Code;
- public readonly Match Match;
- public readonly int UnformattedIndex;
-
- public FormattingCodeData(FormattingCode code, Match match, int unformattedIndex) {
- this.Code = code;
- this.Match = match;
- this.UnformattedIndex = unformattedIndex;
- }
-
- }
-}
\ No newline at end of file
diff --git a/MLEM/Formatting/Obsolete/TextAnimation.cs b/MLEM/Formatting/Obsolete/TextAnimation.cs
deleted file mode 100644
index 5a82645..0000000
--- a/MLEM/Formatting/Obsolete/TextAnimation.cs
+++ /dev/null
@@ -1,27 +0,0 @@
-using System;
-using Microsoft.Xna.Framework;
-using Microsoft.Xna.Framework.Graphics;
-using MLEM.Font;
-
-namespace MLEM.Formatting {
- [Obsolete("Use the new text formatting system in MLEM.Formatting instead")]
- public static class TextAnimation {
-
- public static readonly DrawCharacter Default = (settings, font, batch, totalText, index, effectStartIndex, charSt, position, color, scale, layerDepth, timeIntoAnimation) => {
- font.DrawString(batch, charSt, position, color, 0, Vector2.Zero, scale, SpriteEffects.None, layerDepth);
- };
-
- public static readonly DrawCharacter Wobbly = (settings, font, batch, totalText, index, effectStartIndex, charSt, position, color, scale, layerDepth, timeIntoAnimation) => {
- var offset = new Vector2(0, (float) Math.Sin(index + timeIntoAnimation.TotalSeconds * settings.WobbleModifier) * font.LineHeight * settings.WobbleHeightModifier * scale);
- font.DrawString(batch, charSt, position + offset, color, 0, Vector2.Zero, scale, SpriteEffects.None, layerDepth);
- };
-
- public static readonly DrawCharacter Typing = (settings, font, batch, totalText, index, effectStartIndex, charSt, position, color, scale, layerDepth, timeIntoAnimation) => {
- if (timeIntoAnimation.TotalSeconds * settings.TypingSpeed > index - effectStartIndex + 1)
- font.DrawString(batch, charSt, position, color, 0, Vector2.Zero, scale, SpriteEffects.None, layerDepth);
- };
-
- public delegate void DrawCharacter(FormatSettings settings, GenericFont font, SpriteBatch batch, string totalText, int index, int effectStartIndex, string charSt, Vector2 position, Color color, float scale, float layerDepth, TimeSpan timeIntoAnimation);
-
- }
-}
\ No newline at end of file
diff --git a/MLEM/Formatting/Obsolete/TextFormatting.cs b/MLEM/Formatting/Obsolete/TextFormatting.cs
deleted file mode 100644
index 525df1b..0000000
--- a/MLEM/Formatting/Obsolete/TextFormatting.cs
+++ /dev/null
@@ -1,141 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text.RegularExpressions;
-using Microsoft.Xna.Framework;
-using Microsoft.Xna.Framework.Graphics;
-using MLEM.Extensions;
-using MLEM.Font;
-using MLEM.Misc;
-using MLEM.Textures;
-
-namespace MLEM.Formatting {
- [Obsolete("Use the new text formatting system in MLEM.Formatting instead")]
- public static class TextFormatting {
-
- public static readonly Dictionary FormattingCodes = new Dictionary(StringComparer.OrdinalIgnoreCase);
- private static Regex formatRegex;
-
- static TextFormatting() {
- SetFormatIndicators('[', ']');
-
- // style codes
- FormattingCodes["regular"] = new FormattingCode(TextStyle.Regular);
- FormattingCodes["italic"] = new FormattingCode(TextStyle.Italic);
- FormattingCodes["bold"] = new FormattingCode(TextStyle.Bold);
- FormattingCodes["shadow"] = new FormattingCode(TextStyle.Shadow);
-
- // color codes
- var colors = typeof(Color).GetProperties();
- foreach (var color in colors) {
- if (color.GetGetMethod().IsStatic)
- FormattingCodes[color.Name] = new FormattingCode((Color) color.GetValue(null));
- }
-
- // animations
- FormattingCodes["unanimated"] = new FormattingCode(TextAnimation.Default);
- FormattingCodes["wobbly"] = new FormattingCode(TextAnimation.Wobbly);
- FormattingCodes["typing"] = new FormattingCode(TextAnimation.Typing);
- }
-
- public static void SetFormatIndicators(char opener, char closer) {
- // escape the opener and closer so that any character can be used
- var op = "\\" + opener;
- var cl = "\\" + closer;
- // find any text that is surrounded by the opener and closer
- formatRegex = new Regex($"{op}[^{op}{cl}]*{cl}");
- }
-
- public static string RemoveFormatting(this string s, GenericFont font) {
- return formatRegex.Replace(s, match => {
- var code = FromMatch(match);
- return code != null ? code.GetReplacementString(font) : match.Value;
- });
- }
-
- public static FormattingCodeCollection GetFormattingCodes(this string s, GenericFont font) {
- var codes = new FormattingCodeCollection();
- var codeLengths = 0;
- foreach (Match match in formatRegex.Matches(s)) {
- var code = FromMatch(match);
- if (code == null)
- continue;
- var index = match.Index - codeLengths;
- var data = new FormattingCodeData(code, match, index);
- if (codes.TryGetValue(index, out var curr)) {
- curr.Add(data);
- } else {
- codes.Add(index, new List {data});
- }
- codeLengths += match.Length - code.GetReplacementString(font).Length;
- }
- return codes;
- }
-
- public static void DrawFormattedString(this GenericFont regularFont, SpriteBatch batch, Vector2 pos, string unformattedText, FormattingCodeCollection formatting, Color color, float scale, GenericFont boldFont = null, GenericFont italicFont = null, float depth = 0, TimeSpan timeIntoAnimation = default, FormatSettings formatSettings = null) {
- var settings = formatSettings ?? FormatSettings.Default;
- var currColor = color;
- var currFont = regularFont;
- var currStyle = TextStyle.Regular;
- var currAnim = TextAnimation.Default;
- var animStart = 0;
-
- var innerOffset = new Vector2();
- var formatIndex = 0;
- foreach (var c in unformattedText) {
- // check if the current character's index has a formatting code
- if (formatting.TryGetValue(formatIndex, out var codes)) {
- foreach (var data in codes) {
- var code = data.Code;
- // if so, apply it
- switch (code.CodeType) {
- case FormattingCode.Type.Color:
- currColor = code.Color.CopyAlpha(color);
- break;
- case FormattingCode.Type.Style:
- switch (code.Style) {
- case TextStyle.Regular:
- currFont = regularFont;
- break;
- case TextStyle.Bold:
- currFont = boldFont ?? regularFont;
- break;
- case TextStyle.Italic:
- currFont = italicFont ?? regularFont;
- break;
- }
- currStyle = code.Style;
- break;
- case FormattingCode.Type.Icon:
- code.Icon.SetTime(timeIntoAnimation.TotalSeconds * code.Icon.SpeedMultiplier % code.Icon.TotalTime);
- batch.Draw(code.Icon.CurrentRegion, new RectangleF(pos + innerOffset, new Vector2(regularFont.LineHeight * scale)), color, 0, Vector2.Zero, SpriteEffects.None, depth);
- break;
- case FormattingCode.Type.Animation:
- currAnim = code.Animation;
- animStart = formatIndex;
- break;
- }
- }
- }
-
- var cSt = c.ToString();
- if (c == '\n') {
- innerOffset.X = 0;
- innerOffset.Y += regularFont.LineHeight * scale;
- } else {
- if (currStyle == TextStyle.Shadow)
- currAnim(settings, currFont, batch, unformattedText, formatIndex, animStart, cSt, pos + innerOffset + settings.DropShadowOffset * scale, settings.DropShadowColor, scale, depth, timeIntoAnimation);
- currAnim(settings, currFont, batch, unformattedText, formatIndex, animStart, cSt, pos + innerOffset, currColor, scale, depth, timeIntoAnimation);
- innerOffset.X += regularFont.MeasureString(cSt).X * scale;
- formatIndex++;
- }
- }
- }
-
- private static FormattingCode FromMatch(Capture match) {
- var rawCode = match.Value.Substring(1, match.Value.Length - 2);
- FormattingCodes.TryGetValue(rawCode, out var val);
- return val;
- }
-
- }
-}
\ No newline at end of file