mirror of
https://github.com/Ellpeck/MLEM.git
synced 2024-11-26 14:38:34 +01:00
allow for underline and shadow codes to be mixed with font codes
This commit is contained in:
parent
f94d471365
commit
e916ddb7a8
4 changed files with 31 additions and 3 deletions
17
MLEM/Formatting/Codes/ResetFormattingCode.cs
Normal file
17
MLEM/Formatting/Codes/ResetFormattingCode.cs
Normal file
|
@ -0,0 +1,17 @@
|
|||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace MLEM.Formatting.Codes {
|
||||
/// <inheritdoc />
|
||||
public class ResetFormattingCode : Code {
|
||||
|
||||
/// <inheritdoc />
|
||||
public ResetFormattingCode(Match match, Regex regex) : base(match, regex) {
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override bool EndsHere(Code other) {
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -6,13 +6,13 @@ using MLEM.Font;
|
|||
|
||||
namespace MLEM.Formatting.Codes {
|
||||
/// <inheritdoc />
|
||||
public class ShadowCode : FontCode {
|
||||
public class ShadowCode : Code {
|
||||
|
||||
private readonly Color color;
|
||||
private readonly Vector2 offset;
|
||||
|
||||
/// <inheritdoc />
|
||||
public ShadowCode(Match match, Regex regex, Color color, Vector2 offset) : base(match, regex, null) {
|
||||
public ShadowCode(Match match, Regex regex, Color color, Vector2 offset) : base(match, regex) {
|
||||
this.color = color;
|
||||
this.offset = offset;
|
||||
}
|
||||
|
@ -24,5 +24,10 @@ namespace MLEM.Formatting.Codes {
|
|||
return false;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override bool EndsHere(Code other) {
|
||||
return base.EndsHere(other) || other is ResetFormattingCode;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -29,5 +29,10 @@ namespace MLEM.Formatting.Codes {
|
|||
return false;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override bool EndsHere(Code other) {
|
||||
return base.EndsHere(other) || other is ResetFormattingCode;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -38,7 +38,8 @@ namespace MLEM.Formatting {
|
|||
m.Groups[1].Success ? ColorHelper.FromHexString(m.Groups[1].Value) : Color.Black,
|
||||
new Vector2(float.TryParse(m.Groups[2].Value, NumberStyles.Number, CultureInfo.InvariantCulture, out var offset) ? offset : 2)));
|
||||
this.Codes.Add(new Regex("<u>"), (f, m, r) => new UnderlineCode(m, r, 1 / 16F, 0.85F));
|
||||
this.Codes.Add(new Regex("</(b|i|s|u|l)>"), (f, m, r) => new FontCode(m, r, null));
|
||||
this.Codes.Add(new Regex("</(s|u|l)>"), (f, m, r) => new ResetFormattingCode(m, r));
|
||||
this.Codes.Add(new Regex("</(b|i)>"), (f, m, r) => new FontCode(m, r, null));
|
||||
|
||||
// color codes
|
||||
foreach (var c in typeof(Color).GetProperties()) {
|
||||
|
|
Loading…
Reference in a new issue