mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-13 12:14:16 +01:00
commit
e296fea20e
3 changed files with 79 additions and 0 deletions
|
|
@ -151,6 +151,10 @@ namespace Dalamud.Game.Chat.SeStringHandling
|
|||
payload = new StatusPayload();
|
||||
break;
|
||||
|
||||
case EmbeddedInfoType.QuestLink:
|
||||
payload = new QuestPayload();
|
||||
break;
|
||||
|
||||
case EmbeddedInfoType.LinkTerminator:
|
||||
// this has no custom handling and so needs to fallthrough to ensure it is captured
|
||||
default:
|
||||
|
|
@ -225,6 +229,7 @@ namespace Dalamud.Game.Chat.SeStringHandling
|
|||
PlayerName = 0x01,
|
||||
ItemLink = 0x03,
|
||||
MapPositionLink = 0x04,
|
||||
QuestLink = 0x05,
|
||||
Status = 0x09,
|
||||
|
||||
LinkTerminator = 0xCF // not clear but seems to always follow a link
|
||||
|
|
|
|||
|
|
@ -47,6 +47,10 @@ namespace Dalamud.Game.Chat.SeStringHandling
|
|||
/// </summary>
|
||||
Icon,
|
||||
/// <summary>
|
||||
/// A SeString payload representing a quest link.
|
||||
/// </summary>
|
||||
Quest,
|
||||
/// <summary>
|
||||
/// An SeString payload representing any data we don't handle.
|
||||
/// </summary>
|
||||
Unknown
|
||||
|
|
|
|||
70
Dalamud/Game/Chat/SeStringHandling/Payloads/QuestPayload.cs
Normal file
70
Dalamud/Game/Chat/SeStringHandling/Payloads/QuestPayload.cs
Normal file
|
|
@ -0,0 +1,70 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using Dalamud.Data;
|
||||
using Lumina.Excel.GeneratedSheets;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Dalamud.Game.Chat.SeStringHandling.Payloads {
|
||||
/// <summary>
|
||||
/// An SeString Payload representing an interactable quest link.
|
||||
/// </summary>
|
||||
public class QuestPayload : Payload {
|
||||
public override PayloadType Type => PayloadType.Quest;
|
||||
|
||||
private Quest quest;
|
||||
/// <summary>
|
||||
/// The underlying Lumina Quest represented by this payload.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Value is evaluated lazily and cached.
|
||||
/// </remarks>
|
||||
|
||||
[JsonIgnore]
|
||||
public Quest Quest {
|
||||
get {
|
||||
this.quest ??= this.DataResolver.GetExcelSheet<Quest>().GetRow(this.questId);
|
||||
return this.quest;
|
||||
}
|
||||
}
|
||||
|
||||
[JsonProperty]
|
||||
private uint questId;
|
||||
|
||||
internal QuestPayload() { }
|
||||
|
||||
/// <summary>
|
||||
/// Creates a payload representing an interactable quest link for the specified quest.
|
||||
/// </summary>
|
||||
/// <param name="data">DataManager instance needed to resolve game data.</param>
|
||||
/// <param name="questId">The id of the quest.</param>
|
||||
public QuestPayload(DataManager data, uint questId) {
|
||||
this.DataResolver = data;
|
||||
this.questId = questId;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override string ToString() {
|
||||
return $"{Type} - QuestId: {this.questId}, Name: {Quest?.Name ?? "QUEST NOT FOUND"}";
|
||||
}
|
||||
|
||||
protected override byte[] EncodeImpl() {
|
||||
var idBytes = MakeInteger((ushort) this.questId);
|
||||
var chunkLen = idBytes.Length + 4;
|
||||
|
||||
var bytes = new List<byte>() {
|
||||
START_BYTE, (byte) SeStringChunkType.Interactable, (byte) chunkLen, (byte) EmbeddedInfoType.QuestLink,
|
||||
};
|
||||
|
||||
bytes.AddRange(idBytes);
|
||||
bytes.AddRange(new byte[] {0x01, 0x01, END_BYTE});
|
||||
return bytes.ToArray();
|
||||
|
||||
}
|
||||
|
||||
protected override void DecodeImpl(BinaryReader reader, long endOfStream) {
|
||||
// Game uses int16, Luimina uses int32
|
||||
this.questId = GetInteger(reader) + 65536;
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue