mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-15 21:24:16 +01:00
explicit interface for when payloads include user-displayed text - this may go away later
This commit is contained in:
parent
1832702a0a
commit
5416c4bc7e
5 changed files with 19 additions and 19 deletions
9
Dalamud/Game/Chat/SeStringHandling/ITextProvider.cs
Normal file
9
Dalamud/Game/Chat/SeStringHandling/ITextProvider.cs
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
using System;
|
||||
|
||||
namespace Dalamud.Game.Chat.SeStringHandling
|
||||
{
|
||||
interface ITextProvider
|
||||
{
|
||||
string Text { get; }
|
||||
}
|
||||
}
|
||||
|
|
@ -200,6 +200,7 @@ namespace Dalamud.Game.Chat.SeStringHandling
|
|||
Byte = 0xF0,
|
||||
ByteTimes256 = 0xF1,
|
||||
Int16 = 0xF2,
|
||||
// ByteTimes65536 = 0xF3, // from RE but never seen
|
||||
Int16Packed = 0xF4, // seen in map links, seemingly 2 8-bit values packed into 2 bytes with only one marker
|
||||
Int24Special = 0xF6, // unsure how different form Int24 - used for hq items that add 1 million, also used for normal 24-bit values in map links
|
||||
Int24 = 0xFA,
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ using System.Linq;
|
|||
|
||||
namespace Dalamud.Game.Chat.SeStringHandling.Payloads
|
||||
{
|
||||
public class AutoTranslatePayload : Payload
|
||||
public class AutoTranslatePayload : Payload, ITextProvider
|
||||
{
|
||||
public override PayloadType Type => PayloadType.AutoTranslateText;
|
||||
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ using System.Text;
|
|||
|
||||
namespace Dalamud.Game.Chat.SeStringHandling.Payloads
|
||||
{
|
||||
public class TextPayload : Payload
|
||||
public class TextPayload : Payload, ITextProvider
|
||||
{
|
||||
public override PayloadType Type => PayloadType.RawText;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Dalamud.Game.Chat.SeStringHandling.Payloads;
|
||||
|
||||
namespace Dalamud.Game.Chat.SeStringHandling
|
||||
{
|
||||
|
|
@ -29,22 +29,12 @@ namespace Dalamud.Game.Chat.SeStringHandling
|
|||
/// </returns>
|
||||
public string TextValue
|
||||
{
|
||||
get {
|
||||
var sb = new StringBuilder();
|
||||
foreach (var p in Payloads)
|
||||
{
|
||||
if (p.Type == PayloadType.RawText)
|
||||
{
|
||||
sb.Append(((TextPayload)p).Text);
|
||||
}
|
||||
// TODO: temporary (probably)
|
||||
else if (p.Type == PayloadType.AutoTranslateText)
|
||||
{
|
||||
sb.Append(((AutoTranslatePayload)p).Text);
|
||||
}
|
||||
}
|
||||
|
||||
return sb.ToString();
|
||||
get
|
||||
{
|
||||
return Payloads
|
||||
.Where(p => p is ITextProvider)
|
||||
.Cast<ITextProvider>()
|
||||
.Aggregate(new StringBuilder(), (sb, tp) => sb.Append(tp.Text), sb => sb.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue