Move ItemKind to Dalamud.Utility (#2324)

This commit is contained in:
Haselnussbomber 2025-07-26 21:51:20 +02:00 committed by GitHub
parent 564c220ed2
commit b425ee0a2a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 35 additions and 38 deletions

View file

@ -3,7 +3,6 @@ using Dalamud.Utility;
using Lumina.Extensions; using Lumina.Extensions;
using ItemKind = Dalamud.Game.Text.SeStringHandling.Payloads.ItemPayload.ItemKind;
using LSheets = Lumina.Excel.Sheets; using LSheets = Lumina.Excel.Sheets;
namespace Dalamud.Game.Text.Evaluator.Internal; namespace Dalamud.Game.Text.Evaluator.Internal;

View file

@ -72,33 +72,6 @@ public class ItemPayload : Payload
{ {
} }
/// <summary>
/// Kinds of items that can be fetched from this payload.
/// </summary>
[Api13ToDo("Move this out of ItemPayload. It's used in other classes too.")]
public enum ItemKind : uint
{
/// <summary>
/// Normal items.
/// </summary>
Normal,
/// <summary>
/// Collectible Items.
/// </summary>
Collectible = 500_000,
/// <summary>
/// High-Quality items.
/// </summary>
Hq = 1_000_000,
/// <summary>
/// Event/Key items.
/// </summary>
EventItem = 2_000_000,
}
/// <inheritdoc/> /// <inheritdoc/>
public override PayloadType Type => PayloadType.Item; public override PayloadType Type => PayloadType.Item;

View file

@ -181,7 +181,7 @@ public class SeString
/// <param name="displayNameOverride">An optional name override to display, instead of the actual item name.</param> /// <param name="displayNameOverride">An optional name override to display, instead of the actual item name.</param>
/// <returns>An SeString containing all the payloads necessary to display an item link in the chat log.</returns> /// <returns>An SeString containing all the payloads necessary to display an item link in the chat log.</returns>
public static SeString CreateItemLink(uint itemId, bool isHq, string? displayNameOverride = null) => public static SeString CreateItemLink(uint itemId, bool isHq, string? displayNameOverride = null) =>
CreateItemLink(itemId, isHq ? ItemPayload.ItemKind.Hq : ItemPayload.ItemKind.Normal, displayNameOverride); CreateItemLink(itemId, isHq ? ItemKind.Hq : ItemKind.Normal, displayNameOverride);
/// <summary> /// <summary>
/// Creates an SeString representing an entire Payload chain that can be used to link an item in the chat log. /// Creates an SeString representing an entire Payload chain that can be used to link an item in the chat log.
@ -190,7 +190,7 @@ public class SeString
/// <param name="kind">The kind of item to link.</param> /// <param name="kind">The kind of item to link.</param>
/// <param name="displayNameOverride">An optional name override to display, instead of the actual item name.</param> /// <param name="displayNameOverride">An optional name override to display, instead of the actual item name.</param>
/// <returns>An SeString containing all the payloads necessary to display an item link in the chat log.</returns> /// <returns>An SeString containing all the payloads necessary to display an item link in the chat log.</returns>
public static SeString CreateItemLink(uint itemId, ItemPayload.ItemKind kind = ItemPayload.ItemKind.Normal, string? displayNameOverride = null) public static SeString CreateItemLink(uint itemId, ItemKind kind = ItemKind.Normal, string? displayNameOverride = null)
{ {
var clientState = Service<ClientState.ClientState>.Get(); var clientState = Service<ClientState.ClientState>.Get();
var seStringEvaluator = Service<SeStringEvaluator>.Get(); var seStringEvaluator = Service<SeStringEvaluator>.Get();

View file

@ -1,6 +1,7 @@
using System.Collections.Generic; using System.Collections.Generic;
using Dalamud.Game.Text.SeStringHandling.Payloads; using Dalamud.Game.Text.SeStringHandling.Payloads;
using Dalamud.Utility;
namespace Dalamud.Game.Text.SeStringHandling; namespace Dalamud.Game.Text.SeStringHandling;
@ -126,7 +127,7 @@ public class SeStringBuilder
/// <param name="kind">Kind of item to encode.</param> /// <param name="kind">Kind of item to encode.</param>
/// <param name="itemNameOverride">Override for the item's name.</param> /// <param name="itemNameOverride">Override for the item's name.</param>
/// <returns>The current builder.</returns> /// <returns>The current builder.</returns>
public SeStringBuilder AddItemLink(uint itemId, ItemPayload.ItemKind kind = ItemPayload.ItemKind.Normal, string? itemNameOverride = null) => public SeStringBuilder AddItemLink(uint itemId, ItemKind kind = ItemKind.Normal, string? itemNameOverride = null) =>
this.Append(SeString.CreateItemLink(itemId, kind, itemNameOverride)); this.Append(SeString.CreateItemLink(itemId, kind, itemNameOverride));
/// <summary> /// <summary>

View file

@ -1,6 +1,6 @@
using Dalamud.Game.Gui; using Dalamud.Game.Gui;
using Dalamud.Game.Text.SeStringHandling; using Dalamud.Game.Text.SeStringHandling;
using Dalamud.Game.Text.SeStringHandling.Payloads; using Dalamud.Utility;
using ImGuiNET; using ImGuiNET;
@ -59,7 +59,7 @@ internal class ItemPayloadSelfTestStep : ISelfTestStep
this.currentSubStep++; this.currentSubStep++;
break; break;
case SubStep.PrintHqItem: case SubStep.PrintHqItem:
toPrint = SeString.CreateItemLink(hqItemId, ItemPayload.ItemKind.Hq); toPrint = SeString.CreateItemLink(hqItemId, ItemKind.Hq);
this.currentSubStep++; this.currentSubStep++;
break; break;
case SubStep.HoverHqItem: case SubStep.HoverHqItem:
@ -69,7 +69,7 @@ internal class ItemPayloadSelfTestStep : ISelfTestStep
this.currentSubStep++; this.currentSubStep++;
break; break;
case SubStep.PrintCollectable: case SubStep.PrintCollectable:
toPrint = SeString.CreateItemLink(collectableItemId, ItemPayload.ItemKind.Collectible); toPrint = SeString.CreateItemLink(collectableItemId, ItemKind.Collectible);
this.currentSubStep++; this.currentSubStep++;
break; break;
case SubStep.HoverCollectable: case SubStep.HoverCollectable:
@ -79,7 +79,7 @@ internal class ItemPayloadSelfTestStep : ISelfTestStep
this.currentSubStep++; this.currentSubStep++;
break; break;
case SubStep.PrintEventItem: case SubStep.PrintEventItem:
toPrint = SeString.CreateItemLink(eventItemId, ItemPayload.ItemKind.EventItem); toPrint = SeString.CreateItemLink(eventItemId, ItemKind.EventItem);
this.currentSubStep++; this.currentSubStep++;
break; break;
case SubStep.HoverEventItem: case SubStep.HoverEventItem:

View file

@ -7,10 +7,34 @@ using Lumina.Excel.Sheets;
using Lumina.Text; using Lumina.Text;
using Lumina.Text.ReadOnly; using Lumina.Text.ReadOnly;
using static Dalamud.Game.Text.SeStringHandling.Payloads.ItemPayload;
namespace Dalamud.Utility; namespace Dalamud.Utility;
/// <summary>
/// Kinds of items that can be fetched from this payload.
/// </summary>
public enum ItemKind : uint
{
/// <summary>
/// Normal items.
/// </summary>
Normal,
/// <summary>
/// Collectible Items.
/// </summary>
Collectible = 500_000,
/// <summary>
/// High-Quality items.
/// </summary>
Hq = 1_000_000,
/// <summary>
/// Event/Key items.
/// </summary>
EventItem = 2_000_000,
}
/// <summary> /// <summary>
/// Utilities related to Items. /// Utilities related to Items.
/// </summary> /// </summary>