mirror of
https://github.com/goatcorp/Dalamud.git
synced 2026-02-19 22:37:43 +01:00
refactor: Dalamud.Game.Chat => Dalamud.Game.Text, move Sanitizer
This commit is contained in:
parent
7996b64827
commit
3decb57b2c
38 changed files with 141 additions and 140 deletions
66
Dalamud/Game/Text/SeStringHandling/Payloads/IconPayload.cs
Normal file
66
Dalamud/Game/Text/SeStringHandling/Payloads/IconPayload.cs
Normal file
|
|
@ -0,0 +1,66 @@
|
|||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System;
|
||||
|
||||
namespace Dalamud.Game.Text.SeStringHandling.Payloads {
|
||||
|
||||
/// <summary>
|
||||
/// SeString payload representing a bitmap icon from fontIcon
|
||||
/// </summary>
|
||||
public class IconPayload : Payload {
|
||||
|
||||
/// <summary>
|
||||
/// Index of the icon
|
||||
/// </summary>
|
||||
[Obsolete("Use IconPayload.Icon")]
|
||||
public uint IconIndex => (uint) Icon;
|
||||
|
||||
/// <summary>
|
||||
/// Icon the payload represents.
|
||||
/// </summary>
|
||||
public BitmapFontIcon Icon { get; set; } = BitmapFontIcon.None;
|
||||
|
||||
internal IconPayload() { }
|
||||
|
||||
/// <summary>
|
||||
/// Create a Icon payload for the specified icon.
|
||||
/// </summary>
|
||||
/// <param name="iconIndex">Index of the icon</param>
|
||||
[Obsolete("IconPayload(uint) is deprecated, please use IconPayload(BitmapFontIcon).")]
|
||||
public IconPayload(uint iconIndex) : this((BitmapFontIcon) iconIndex) { }
|
||||
|
||||
/// <summary>
|
||||
/// Create a Icon payload for the specified icon.
|
||||
/// </summary>
|
||||
/// <param name="icon">The Icon</param>
|
||||
public IconPayload(BitmapFontIcon icon) {
|
||||
Icon = icon;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override PayloadType Type => PayloadType.Icon;
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override byte[] EncodeImpl() {
|
||||
var indexBytes = MakeInteger((uint) this.Icon);
|
||||
var chunkLen = indexBytes.Length + 1;
|
||||
var bytes = new List<byte>(new byte[] {
|
||||
START_BYTE, (byte)SeStringChunkType.Icon, (byte)chunkLen
|
||||
});
|
||||
bytes.AddRange(indexBytes);
|
||||
bytes.Add(END_BYTE);
|
||||
return bytes.ToArray();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void DecodeImpl(BinaryReader reader, long endOfStream) {
|
||||
Icon = (BitmapFontIcon) GetInteger(reader);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override string ToString() {
|
||||
return $"{Type} - {Icon}";
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue