mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-15 05:04:15 +01:00
Some static helpers for frequent payloads and groupings
This commit is contained in:
parent
ea6c130aa7
commit
430d834074
5 changed files with 29 additions and 12 deletions
|
|
@ -6,6 +6,9 @@ namespace Dalamud.Game.Chat.SeStringHandling.Payloads
|
|||
{
|
||||
class EmphasisItalicPayload : Payload
|
||||
{
|
||||
public static EmphasisItalicPayload ItalicsOn => new EmphasisItalicPayload(true);
|
||||
public static EmphasisItalicPayload ItalicsOff => new EmphasisItalicPayload(false);
|
||||
|
||||
public override PayloadType Type => PayloadType.EmphasisItalic;
|
||||
|
||||
public bool IsEnabled { get; private set; }
|
||||
|
|
|
|||
|
|
@ -7,6 +7,9 @@ namespace Dalamud.Game.Chat.SeStringHandling.Payloads
|
|||
{
|
||||
public class RawPayload : Payload
|
||||
{
|
||||
// this and others could be an actual static member somewhere and avoid construction costs, but that probably isn't a real concern
|
||||
public static RawPayload LinkTerminator => new RawPayload(new byte[] { 0x02, 0x27, 0x07, 0xCF, 0x01, 0x01, 0x01, 0xFF, 0x01, 0x03 });
|
||||
|
||||
public override PayloadType Type => PayloadType.Unknown;
|
||||
|
||||
private byte[] data;
|
||||
|
|
|
|||
|
|
@ -7,6 +7,8 @@ namespace Dalamud.Game.Chat.SeStringHandling.Payloads
|
|||
{
|
||||
public class UIForegroundPayload : Payload
|
||||
{
|
||||
public static UIForegroundPayload UIForegroundOff => new UIForegroundPayload(0);
|
||||
|
||||
public override PayloadType Type => PayloadType.UIForeground;
|
||||
|
||||
public bool IsEnabled => ColorKey != 0;
|
||||
|
|
|
|||
|
|
@ -7,6 +7,8 @@ namespace Dalamud.Game.Chat.SeStringHandling.Payloads
|
|||
{
|
||||
public class UIGlowPayload : Payload
|
||||
{
|
||||
public static UIGlowPayload UIGlowOff => new UIGlowPayload(0);
|
||||
|
||||
public override PayloadType Type => PayloadType.UIGlow;
|
||||
|
||||
public bool IsEnabled => ColorKey != 0;
|
||||
|
|
|
|||
|
|
@ -19,19 +19,17 @@ namespace Dalamud.Game.Chat.SeStringHandling
|
|||
displayName += " \uE03C";
|
||||
}
|
||||
|
||||
// TODO: probably a cleaner way to build these than doing the bulk+insert
|
||||
var payloads = new List<Payload>(new Payload[]
|
||||
{
|
||||
new UIForegroundPayload(0x0225),
|
||||
new UIGlowPayload(0x0226),
|
||||
new ItemPayload(itemId, isHQ),
|
||||
new UIForegroundPayload(0x01F4),
|
||||
new UIGlowPayload(0x01F5),
|
||||
new TextPayload("\uE0BB"),
|
||||
new UIGlowPayload(0),
|
||||
new UIForegroundPayload(0),
|
||||
// arrow goes here
|
||||
new TextPayload(displayName),
|
||||
new RawPayload(new byte[] { 0x02, 0x27, 0x07, 0xCF, 0x01, 0x01, 0x01, 0xFF, 0x01, 0x03 })
|
||||
RawPayload.LinkTerminator
|
||||
});
|
||||
payloads.InsertRange(3, TextArrowPayloads());
|
||||
|
||||
return new SeString(payloads);
|
||||
}
|
||||
|
|
@ -44,14 +42,11 @@ namespace Dalamud.Game.Chat.SeStringHandling
|
|||
var payloads = new List<Payload>(new Payload[]
|
||||
{
|
||||
mapPayload,
|
||||
new UIForegroundPayload(0x01F4),
|
||||
new UIGlowPayload(0x01F5),
|
||||
new TextPayload("\uE0BB"),
|
||||
new UIGlowPayload(0),
|
||||
new UIForegroundPayload(0),
|
||||
// arrow goes here
|
||||
new TextPayload(nameString),
|
||||
new RawPayload(new byte[] { 0x02, 0x27, 0x07, 0xCF, 0x01, 0x01, 0x01, 0xFF, 0x01, 0x03 })
|
||||
RawPayload.LinkTerminator
|
||||
});
|
||||
payloads.InsertRange(1, TextArrowPayloads());
|
||||
|
||||
return new SeString(payloads);
|
||||
}
|
||||
|
|
@ -76,5 +71,17 @@ namespace Dalamud.Game.Chat.SeStringHandling
|
|||
// TODO: empty? throw?
|
||||
return null;
|
||||
}
|
||||
|
||||
public static List<Payload> TextArrowPayloads()
|
||||
{
|
||||
return new List<Payload>(new Payload[]
|
||||
{
|
||||
new UIForegroundPayload(0x01F4),
|
||||
new UIGlowPayload(0x01F5),
|
||||
new TextPayload("\uE0BB"),
|
||||
UIGlowPayload.UIGlowOff,
|
||||
UIForegroundPayload.UIForegroundOff
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue