2020-05-15 14:22:33 +02:00
|
|
|
using System.Text.RegularExpressions;
|
|
|
|
using Microsoft.Xna.Framework;
|
|
|
|
using Microsoft.Xna.Framework.Graphics;
|
|
|
|
using MLEM.Extensions;
|
|
|
|
using MLEM.Font;
|
|
|
|
|
|
|
|
namespace MLEM.Formatting.Codes {
|
2020-05-21 12:53:42 +02:00
|
|
|
/// <inheritdoc />
|
2021-05-18 16:19:40 +02:00
|
|
|
public class ShadowCode : Code {
|
2020-05-15 14:22:33 +02:00
|
|
|
|
|
|
|
private readonly Color color;
|
|
|
|
private readonly Vector2 offset;
|
|
|
|
|
2020-05-21 12:53:42 +02:00
|
|
|
/// <inheritdoc />
|
2021-05-18 16:19:40 +02:00
|
|
|
public ShadowCode(Match match, Regex regex, Color color, Vector2 offset) : base(match, regex) {
|
2020-05-15 14:22:33 +02:00
|
|
|
this.color = color;
|
|
|
|
this.offset = offset;
|
|
|
|
}
|
|
|
|
|
2020-05-21 12:53:42 +02:00
|
|
|
/// <inheritdoc />
|
2022-02-13 22:43:51 +01:00
|
|
|
public override bool DrawCharacter(GameTime time, SpriteBatch batch, char c, string cString, Token token, int indexInToken, ref Vector2 pos, GenericFont font, ref Color color, ref float scale, float depth) {
|
2020-05-15 14:22:33 +02:00
|
|
|
font.DrawString(batch, cString, pos + this.offset * scale, this.color.CopyAlpha(color), 0, Vector2.Zero, scale, SpriteEffects.None, depth);
|
|
|
|
// we return false since we still want regular drawing to occur
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2021-05-18 16:19:40 +02:00
|
|
|
/// <inheritdoc />
|
|
|
|
public override bool EndsHere(Code other) {
|
2021-05-24 17:12:02 +02:00
|
|
|
return other is ShadowCode || other is ResetFormattingCode;
|
2021-05-18 16:19:40 +02:00
|
|
|
}
|
|
|
|
|
2020-05-15 14:22:33 +02:00
|
|
|
}
|
|
|
|
}
|