Expose a few mutable properties that make sense; most are still read-only for existing payloads. The obvious major point missing in this is the ability to create new payloads from fields.. coming soon

This commit is contained in:
meli 2020-04-21 17:59:43 -07:00
parent 7bab3a45f5
commit 442fc9d137
5 changed files with 73 additions and 16 deletions

View file

@ -21,11 +21,25 @@ namespace Dalamud.Game.Chat.SeStringHandling.Payloads
}
}
// mainly to allow overriding the name (for things like owo)
private string displayName;
public string DisplayName
{
get
{
return this.displayName;
}
set
{
this.displayName = value;
Dirty = true;
}
}
public bool IsHQ { get; private set; } = false;
private uint itemId;
// mainly to allow overriding the name (for things like owo)
private string displayName;
public override string ToString()
{

View file

@ -10,7 +10,16 @@ namespace Dalamud.Game.Chat.SeStringHandling.Payloads
{
public override PayloadType Type => PayloadType.Player;
public string PlayerName { get; private set; }
private string playerName;
public string PlayerName
{
get { return this.playerName; }
set
{
this.playerName = value;
Dirty = true;
}
}
private World world;
public World World
@ -31,7 +40,7 @@ namespace Dalamud.Game.Chat.SeStringHandling.Payloads
protected override byte[] EncodeImpl()
{
var chunkLen = PlayerName.Length + 7;
var chunkLen = this.playerName.Length + 7;
var bytes = new List<byte>()
{
START_BYTE,
@ -39,18 +48,20 @@ namespace Dalamud.Game.Chat.SeStringHandling.Payloads
/* unk */ 0x01,
(byte)(this.serverId+1), // I didn't want to deal with single-byte values in MakeInteger, so we have to do the +1 manually
/* unk */0x01, /* unk */0xFF, // these sometimes vary but are frequently this
(byte)(PlayerName.Length+1)
(byte)(this.playerName.Length+1)
};
bytes.AddRange(Encoding.UTF8.GetBytes(PlayerName));
bytes.AddRange(Encoding.UTF8.GetBytes(this.playerName));
bytes.Add(END_BYTE);
// encoded names are followed by the name in plain text again
// use the payload parsing for consistency, as this is technically a new chunk
// bytes.AddRange(new TextPayload(PlayerName).Encode());
// FIXME
bytes.AddRange(Encoding.UTF8.GetBytes(PlayerName));
bytes.AddRange(
new TextPayload()
{
Text = playerName
}.Encode()
);
// unsure about this entire packet, but it seems to always follow a name
bytes.AddRange(new byte[]
@ -74,7 +85,7 @@ namespace Dalamud.Game.Chat.SeStringHandling.Payloads
reader.ReadBytes(2);
var nameLen = (int)GetInteger(reader);
PlayerName = Encoding.UTF8.GetString(reader.ReadBytes(nameLen));
this.playerName = Encoding.UTF8.GetString(reader.ReadBytes(nameLen));
}
}
}

View file

@ -9,7 +9,17 @@ namespace Dalamud.Game.Chat.SeStringHandling.Payloads
{
public override PayloadType Type => PayloadType.RawText;
public string Text { get; private set; }
// allow modifying the text of existing payloads on the fly
private string text;
public string Text
{
get { return this.text; }
set
{
this.text = value;
Dirty = true;
}
}
public override string ToString()
{
@ -23,7 +33,7 @@ namespace Dalamud.Game.Chat.SeStringHandling.Payloads
protected override void DecodeImpl(BinaryReader reader, long endOfStream)
{
var text = new List<byte>();
var textBytes = new List<byte>();
while (reader.BaseStream.Position < endOfStream)
{
@ -31,13 +41,13 @@ namespace Dalamud.Game.Chat.SeStringHandling.Payloads
break;
// not the most efficient, but the easiest
text.Add(reader.ReadByte());
textBytes.Add(reader.ReadByte());
}
if (text.Count > 0)
if (textBytes.Count > 0)
{
// TODO: handling of the game's assorted special unicode characters
Text = Encoding.UTF8.GetString(text.ToArray());
this.text = Encoding.UTF8.GetString(textBytes.ToArray());
}
}
}

View file

@ -19,6 +19,17 @@ namespace Dalamud.Game.Chat.SeStringHandling.Payloads
}
}
public ushort ColorKey
{
get { return this.colorKey; }
set
{
this.colorKey = value;
this.color = null;
Dirty = true;
}
}
public uint RGB
{
get

View file

@ -19,6 +19,17 @@ namespace Dalamud.Game.Chat.SeStringHandling.Payloads
}
}
public ushort ColorKey
{
get { return this.colorKey; }
set
{
this.colorKey = value;
this.color = null;
Dirty = true;
}
}
public uint RGB
{
get