1
0
Fork 0
mirror of https://github.com/Ellpeck/MLEM.git synced 2024-07-01 08:26:36 +02:00
MLEM/MLEM/Formatting/FormattingCode.cs

62 lines
1.4 KiB
C#
Raw Normal View History

2019-08-24 00:07:54 +02:00
using Microsoft.Xna.Framework;
using MLEM.Animations;
using MLEM.Font;
using MLEM.Textures;
2019-08-24 00:07:54 +02:00
2019-09-06 12:20:53 +02:00
namespace MLEM.Formatting {
2019-08-24 00:07:54 +02:00
public class FormattingCode {
public readonly Type CodeType;
2019-08-24 00:07:54 +02:00
public readonly Color Color;
public readonly TextStyle Style;
public readonly SpriteAnimation Icon;
public readonly TextAnimation.DrawCharacter Animation;
2019-08-24 00:07:54 +02:00
public FormattingCode(Color color) {
2019-08-24 00:07:54 +02:00
this.Color = color;
this.CodeType = Type.Color;
2019-08-24 00:07:54 +02:00
}
public FormattingCode(TextStyle style) {
2019-08-24 00:07:54 +02:00
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;
2019-09-06 15:49:59 +02:00
}
public FormattingCode(TextAnimation.DrawCharacter animation) {
this.Animation = animation;
this.CodeType = Type.Animation;
}
public virtual string GetReplacementString(IGenericFont font) {
return this.CodeType == Type.Icon ? TextFormatting.GetOneEmString(font) : string.Empty;
}
public enum Type {
Color,
Style,
2019-09-06 15:49:59 +02:00
Icon,
Animation
2019-08-24 00:07:54 +02:00
}
}
public enum TextStyle {
Regular,
Bold,
Italic,
Shadow
2019-08-24 00:07:54 +02:00
}
}