using System.Collections.Generic; using System.IO; using System; namespace Dalamud.Game.Chat.SeStringHandling.Payloads { /// /// SeString payload representing a bitmap icon from fontIcon /// public class IconPayload : Payload { /// /// Index of the icon /// [Obsolete("Use IconPayload.Icon")] public uint IconIndex => (uint) Icon; /// /// Icon the payload represents. /// public BitmapFontIcon Icon { get; set; } = BitmapFontIcon.None; internal IconPayload() { } /// /// Create a Icon payload for the specified icon. /// /// Index of the icon [Obsolete("IconPayload(uint) is deprecated, please use IconPayload(BitmapFontIcon).")] public IconPayload(uint iconIndex) : this((BitmapFontIcon) iconIndex) { } /// /// Create a Icon payload for the specified icon. /// /// The Icon public IconPayload(BitmapFontIcon icon) { Icon = icon; } /// public override PayloadType Type => PayloadType.Icon; /// protected override byte[] EncodeImpl() { var indexBytes = MakeInteger((uint) this.Icon); var chunkLen = indexBytes.Length + 1; var bytes = new List(new byte[] { START_BYTE, (byte)SeStringChunkType.Icon, (byte)chunkLen }); bytes.AddRange(indexBytes); bytes.Add(END_BYTE); return bytes.ToArray(); } /// protected override void DecodeImpl(BinaryReader reader, long endOfStream) { Icon = (BitmapFontIcon) GetInteger(reader); } /// public override string ToString() { return $"{Type} - {Icon}"; } } }