2019-08-24 00:07:54 +02:00
|
|
|
using Microsoft.Xna.Framework;
|
2020-01-04 00:27:45 +01:00
|
|
|
using MLEM.Animations;
|
2019-12-26 19:05:26 +01:00
|
|
|
using MLEM.Font;
|
2019-09-05 20:28:05 +02:00
|
|
|
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 {
|
|
|
|
|
2019-09-05 20:28:05 +02:00
|
|
|
public readonly Type CodeType;
|
2019-08-24 00:07:54 +02:00
|
|
|
public readonly Color Color;
|
|
|
|
public readonly TextStyle Style;
|
2020-01-04 00:27:45 +01:00
|
|
|
public readonly SpriteAnimation Icon;
|
2020-02-03 04:37:14 +01:00
|
|
|
public readonly TextAnimation.DrawCharacter Animation;
|
2019-08-24 00:07:54 +02:00
|
|
|
|
2020-02-03 04:37:14 +01:00
|
|
|
public FormattingCode(Color color) {
|
2019-08-24 00:07:54 +02:00
|
|
|
this.Color = color;
|
2020-02-03 04:37:14 +01:00
|
|
|
this.CodeType = Type.Color;
|
2019-08-24 00:07:54 +02:00
|
|
|
}
|
|
|
|
|
2020-02-03 04:37:14 +01:00
|
|
|
public FormattingCode(TextStyle style) {
|
2019-08-24 00:07:54 +02:00
|
|
|
this.Style = style;
|
2020-02-03 04:37:14 +01:00
|
|
|
this.CodeType = Type.Style;
|
2019-09-05 20:28:05 +02:00
|
|
|
}
|
|
|
|
|
2020-02-03 04:36:49 +01:00
|
|
|
public FormattingCode(TextureRegion icon) :
|
|
|
|
this(new SpriteAnimation(0, icon)) {
|
2020-01-04 00:27:45 +01:00
|
|
|
}
|
|
|
|
|
2020-02-03 04:37:14 +01:00
|
|
|
public FormattingCode(SpriteAnimation icon) {
|
2019-09-05 20:28:05 +02:00
|
|
|
this.Icon = icon;
|
2020-02-03 04:37:14 +01:00
|
|
|
this.CodeType = Type.Icon;
|
2019-09-06 15:49:59 +02:00
|
|
|
}
|
|
|
|
|
2020-02-03 04:37:14 +01:00
|
|
|
public FormattingCode(TextAnimation.DrawCharacter animation) {
|
|
|
|
this.Animation = animation;
|
|
|
|
this.CodeType = Type.Animation;
|
2020-02-03 03:04:13 +01:00
|
|
|
}
|
|
|
|
|
2020-02-03 04:37:14 +01:00
|
|
|
public virtual string GetReplacementString(IGenericFont font) {
|
|
|
|
return this.CodeType == Type.Icon ? TextFormatting.GetOneEmString(font) : string.Empty;
|
2020-02-03 03:04:13 +01:00
|
|
|
}
|
|
|
|
|
2019-09-05 20:28:05 +02:00
|
|
|
public enum Type {
|
|
|
|
|
|
|
|
Color,
|
|
|
|
Style,
|
2019-09-06 15:49:59 +02:00
|
|
|
Icon,
|
|
|
|
Animation
|
2019-09-05 20:28:05 +02:00
|
|
|
|
2019-08-24 00:07:54 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
public enum TextStyle {
|
|
|
|
|
|
|
|
Regular,
|
|
|
|
Bold,
|
2019-12-26 19:30:17 +01:00
|
|
|
Italic,
|
|
|
|
Shadow
|
2019-08-24 00:07:54 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
}
|