feat: add chat database
This commit is contained in:
+26
-10
@@ -1,17 +1,33 @@
|
||||
using ChatTwo.Code;
|
||||
using Dalamud.Game.Text.SeStringHandling;
|
||||
using LiteDB;
|
||||
|
||||
namespace ChatTwo;
|
||||
|
||||
internal abstract class Chunk {
|
||||
[BsonIgnore]
|
||||
internal Message? Message { get; set; }
|
||||
internal SeString? Source { get; set; }
|
||||
|
||||
internal ChunkSource Source { get; set; }
|
||||
internal Payload? Link { get; set; }
|
||||
|
||||
protected Chunk(SeString? source, Payload? link) {
|
||||
protected Chunk(ChunkSource source, Payload? link) {
|
||||
this.Source = source;
|
||||
this.Link = link;
|
||||
}
|
||||
|
||||
internal SeString? GetSeString() => this.Source switch {
|
||||
ChunkSource.None => null,
|
||||
ChunkSource.Sender => this.Message?.SenderSource,
|
||||
ChunkSource.Content => this.Message?.ContentSource,
|
||||
_ => null,
|
||||
};
|
||||
}
|
||||
|
||||
internal enum ChunkSource {
|
||||
None,
|
||||
Sender,
|
||||
Content,
|
||||
}
|
||||
|
||||
internal class TextChunk : Chunk {
|
||||
@@ -21,23 +37,23 @@ internal class TextChunk : Chunk {
|
||||
internal bool Italic { get; set; }
|
||||
internal string Content { get; set; }
|
||||
|
||||
internal TextChunk(SeString? source, Payload? link, string content) : base(source, link) {
|
||||
internal TextChunk(ChunkSource source, Payload? link, string content) : base(source, link) {
|
||||
this.Content = content;
|
||||
}
|
||||
|
||||
internal TextChunk(SeString? source, Payload? link, ChatType? fallbackColour, uint? foreground, uint? glow, bool italic, string content) : base(source, link) {
|
||||
this.FallbackColour = fallbackColour;
|
||||
this.Foreground = foreground;
|
||||
this.Glow = glow;
|
||||
this.Italic = italic;
|
||||
this.Content = content;
|
||||
#pragma warning disable CS8618
|
||||
public TextChunk() : base(ChunkSource.None, null) {
|
||||
}
|
||||
#pragma warning restore CS8618
|
||||
}
|
||||
|
||||
internal class IconChunk : Chunk {
|
||||
internal BitmapFontIcon Icon { get; set; }
|
||||
|
||||
public IconChunk(SeString? source, Payload? link, BitmapFontIcon icon) : base(source, link) {
|
||||
public IconChunk(ChunkSource source, Payload? link, BitmapFontIcon icon) : base(source, link) {
|
||||
this.Icon = icon;
|
||||
}
|
||||
|
||||
public IconChunk() : base(ChunkSource.None, null) {
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user