mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-14 20:54:16 +01:00
79 lines
2 KiB
C#
79 lines
2 KiB
C#
using Lumina.Excel.GeneratedSheets;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.IO;
|
|
|
|
namespace Dalamud.Game.Chat.SeStringHandling.Payloads
|
|
{
|
|
public class UIGlowPayload : Payload
|
|
{
|
|
public override PayloadType Type => PayloadType.UIGlow;
|
|
|
|
private UIColor color;
|
|
public UIColor UIColor
|
|
{
|
|
get
|
|
{
|
|
this.color ??= this.dataResolver.GetExcelSheet<UIColor>().GetRow(this.colorKey);
|
|
return this.color;
|
|
}
|
|
}
|
|
|
|
public ushort ColorKey
|
|
{
|
|
get { return this.colorKey; }
|
|
set
|
|
{
|
|
this.colorKey = value;
|
|
this.color = null;
|
|
Dirty = true;
|
|
}
|
|
}
|
|
|
|
public uint RGB
|
|
{
|
|
get
|
|
{
|
|
return UIColor.UIGlow;
|
|
}
|
|
}
|
|
|
|
private ushort colorKey;
|
|
|
|
public override string ToString()
|
|
{
|
|
return $"{Type} - UIColor: {colorKey}";
|
|
}
|
|
|
|
protected override byte[] EncodeImpl()
|
|
{
|
|
var colorBytes = MakeInteger(this.colorKey);
|
|
var chunkLen = colorBytes.Length + 1;
|
|
|
|
var bytes = new List<byte>(new byte[]
|
|
{
|
|
START_BYTE, (byte)SeStringChunkType.UIGlow, (byte)chunkLen
|
|
});
|
|
|
|
bytes.AddRange(colorBytes);
|
|
bytes.Add(END_BYTE);
|
|
|
|
return bytes.ToArray();
|
|
}
|
|
|
|
protected override void DecodeImpl(BinaryReader reader, long endOfStream)
|
|
{
|
|
this.colorKey = (ushort)GetInteger(reader);
|
|
}
|
|
|
|
protected override byte GetMarkerForIntegerBytes(byte[] bytes)
|
|
{
|
|
return bytes.Length switch
|
|
{
|
|
// a single byte of 0x01 is used to 'disable' color, and has no marker
|
|
1 => (byte)IntegerType.None,
|
|
_ => base.GetMarkerForIntegerBytes(bytes)
|
|
};
|
|
}
|
|
}
|
|
}
|