diff --git a/XivCommon/Functions/ContextMenu/BaseContextMenuArgs.cs b/XivCommon/Functions/ContextMenu/BaseContextMenuArgs.cs
index 31ef8e5..47b9ee1 100755
--- a/XivCommon/Functions/ContextMenu/BaseContextMenuArgs.cs
+++ b/XivCommon/Functions/ContextMenu/BaseContextMenuArgs.cs
@@ -1,4 +1,5 @@
using System;
+using Dalamud.Game.Text.SeStringHandling;
namespace XivCommon.Functions.ContextMenu {
///
@@ -33,14 +34,14 @@ namespace XivCommon.Functions.ContextMenu {
///
/// The text related to this context menu, usually an actor name.
///
- public string? Text { get; }
+ public SeString? Text { get; }
///
/// The world of the actor this context menu is for, if any.
///
public ushort ActorWorld { get; }
- internal BaseContextMenuArgs(IntPtr addon, IntPtr agent, string? parentAddonName, uint actorId, uint contentIdLower, string? text, ushort actorWorld) {
+ internal BaseContextMenuArgs(IntPtr addon, IntPtr agent, string? parentAddonName, uint actorId, uint contentIdLower, SeString? text, ushort actorWorld) {
this.Addon = addon;
this.Agent = agent;
this.ParentAddonName = parentAddonName;
diff --git a/XivCommon/Functions/ContextMenu/ContextMenu.cs b/XivCommon/Functions/ContextMenu/ContextMenu.cs
index 13c2001..11a2ceb 100755
--- a/XivCommon/Functions/ContextMenu/ContextMenu.cs
+++ b/XivCommon/Functions/ContextMenu/ContextMenu.cs
@@ -6,7 +6,7 @@ using System.Runtime.InteropServices;
using System.Text;
using Dalamud;
using Dalamud.Game;
-using Dalamud.Game.Internal.Gui;
+using Dalamud.Game.Text.SeStringHandling;
using Dalamud.Hooking;
using FFXIVClientStructs.FFXIV.Component.GUI;
using XivCommon.Functions.ContextMenu.Inventory;
@@ -135,15 +135,15 @@ namespace XivCommon.Functions.ContextMenu {
private GameFunctions Functions { get; }
private ClientLanguage Language { get; }
- private GameGui Gui { get; }
+ private SeStringManager SeStringManager { get; }
private IntPtr Agent { get; set; } = IntPtr.Zero;
private List Items { get; } = new();
private int NormalSize { get; set; }
- internal ContextMenu(GameFunctions functions, SigScanner scanner, GameGui gui, ClientLanguage language, Hooks hooks) {
+ internal ContextMenu(GameFunctions functions, SigScanner scanner, SeStringManager manager, ClientLanguage language, Hooks hooks) {
this.Functions = functions;
this.Language = language;
- this.Gui = gui;
+ this.SeStringManager = manager;
if (!hooks.HasFlag(Hooks.ContextMenu)) {
return;
@@ -244,11 +244,11 @@ namespace XivCommon.Functions.ContextMenu {
return Encoding.UTF8.GetString(Util.ReadTerminated(parentAddon + 8));
}
- private static unsafe (uint actorId, uint contentIdLower, string? text, ushort actorWorld) GetAgentInfo(IntPtr agent) {
+ private unsafe (uint actorId, uint contentIdLower, SeString? text, ushort actorWorld) GetAgentInfo(IntPtr agent) {
var actorId = *(uint*) (agent + ActorIdOffset);
var contentIdLower = *(uint*) (agent + ContentIdLowerOffset);
var textBytes = Util.ReadTerminated(Marshal.ReadIntPtr(agent + TextPointerOffset));
- var text = textBytes.Length == 0 ? null : Encoding.UTF8.GetString(textBytes);
+ var text = textBytes.Length == 0 ? null : this.SeStringManager.Parse(textBytes);
var actorWorld = *(ushort*) (agent + WorldOffset);
return (actorId, contentIdLower, text, actorWorld);
}
@@ -301,8 +301,7 @@ namespace XivCommon.Functions.ContextMenu {
for (var i = 0; i < this.NormalSize; i++) {
var atkItem = &atkValueArgs[offset + i];
- var nameBytes = Util.ReadTerminated((IntPtr) atkItem->String);
- var name = Encoding.UTF8.GetString(nameBytes);
+ var name = Util.ReadSeString((IntPtr) atkItem->String, this.SeStringManager);
var enabled = true;
if (hasGameDisabled) {
@@ -347,7 +346,7 @@ namespace XivCommon.Functions.ContextMenu {
this.Items.AddRange(args.Items);
} else {
- var info = GetAgentInfo(agent);
+ var info = this.GetAgentInfo(agent);
var args = new ContextMenuOpenArgs(
addon,
@@ -426,7 +425,7 @@ namespace XivCommon.Functions.ContextMenu {
NativeContextMenuItem native => native.Name,
_ => "Invalid context menu item",
};
- var nameBytes = Encoding.UTF8.GetBytes(name).Terminate();
+ var nameBytes = name.Encode().Terminate();
fixed (byte* nameBytesPtr = nameBytes) {
this._atkValueSetString(newItem, nameBytesPtr);
}
@@ -452,7 +451,7 @@ namespace XivCommon.Functions.ContextMenu {
// a custom item is being clicked
case NormalContextMenuItem custom: {
var addonName = this.GetParentAddonName(addon);
- var info = GetAgentInfo(custom.Agent);
+ var info = this.GetAgentInfo(custom.Agent);
var args = new ContextMenuItemSelectedArgs(
addon,
diff --git a/XivCommon/Functions/ContextMenu/ContextMenuItemSelectedArgs.cs b/XivCommon/Functions/ContextMenu/ContextMenuItemSelectedArgs.cs
index 1e15256..18bacbe 100755
--- a/XivCommon/Functions/ContextMenu/ContextMenuItemSelectedArgs.cs
+++ b/XivCommon/Functions/ContextMenu/ContextMenuItemSelectedArgs.cs
@@ -1,11 +1,12 @@
using System;
+using Dalamud.Game.Text.SeStringHandling;
namespace XivCommon.Functions.ContextMenu {
///
/// Arguments for the context menu item selected delegate.
///
public class ContextMenuItemSelectedArgs : BaseContextMenuArgs {
- internal ContextMenuItemSelectedArgs(IntPtr addon, IntPtr agent, string? parentAddonName, uint actorId, uint contentIdLower, string? text, ushort actorWorld) : base(addon, agent, parentAddonName, actorId, contentIdLower, text, actorWorld) {
+ internal ContextMenuItemSelectedArgs(IntPtr addon, IntPtr agent, string? parentAddonName, uint actorId, uint contentIdLower, SeString? text, ushort actorWorld) : base(addon, agent, parentAddonName, actorId, contentIdLower, text, actorWorld) {
}
}
}
diff --git a/XivCommon/Functions/ContextMenu/ContextMenuOpenArgs.cs b/XivCommon/Functions/ContextMenu/ContextMenuOpenArgs.cs
index 46a98d7..aa3a14a 100755
--- a/XivCommon/Functions/ContextMenu/ContextMenuOpenArgs.cs
+++ b/XivCommon/Functions/ContextMenu/ContextMenuOpenArgs.cs
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
+using Dalamud.Game.Text.SeStringHandling;
namespace XivCommon.Functions.ContextMenu {
///
@@ -11,7 +12,7 @@ namespace XivCommon.Functions.ContextMenu {
///
public List Items { get; } = new();
- internal ContextMenuOpenArgs(IntPtr addon, IntPtr agent, string? parentAddonName, uint actorId, uint contentIdLower, string? text, ushort actorWorld) : base(addon, agent, parentAddonName, actorId, contentIdLower, text, actorWorld) {
+ internal ContextMenuOpenArgs(IntPtr addon, IntPtr agent, string? parentAddonName, uint actorId, uint contentIdLower, SeString? text, ushort actorWorld) : base(addon, agent, parentAddonName, actorId, contentIdLower, text, actorWorld) {
}
}
}
diff --git a/XivCommon/Functions/ContextMenu/CustomContextMenuItem.cs b/XivCommon/Functions/ContextMenu/CustomContextMenuItem.cs
index e7a7a7d..c70a356 100755
--- a/XivCommon/Functions/ContextMenu/CustomContextMenuItem.cs
+++ b/XivCommon/Functions/ContextMenu/CustomContextMenuItem.cs
@@ -1,4 +1,5 @@
using System;
+using Dalamud.Game.Text.SeStringHandling;
namespace XivCommon.Functions.ContextMenu {
///
@@ -11,22 +12,22 @@ namespace XivCommon.Functions.ContextMenu {
///
/// The name of the context item to be shown for English clients.
///
- public string NameEnglish { get; set; }
+ public SeString NameEnglish { get; set; }
///
/// The name of the context item to be shown for Japanese clients.
///
- public string NameJapanese { get; set; }
+ public SeString NameJapanese { get; set; }
///
/// The name of the context item to be shown for French clients.
///
- public string NameFrench { get; set; }
+ public SeString NameFrench { get; set; }
///
/// The name of the context item to be shown for German clients.
///
- public string NameGerman { get; set; }
+ public SeString NameGerman { get; set; }
///
/// The action to perform when this item is clicked.
@@ -38,7 +39,7 @@ namespace XivCommon.Functions.ContextMenu {
///
/// the English name of the item, copied to other languages
/// the action to perform on click
- internal CustomContextMenuItem(string name, T action) {
+ internal CustomContextMenuItem(SeString name, T action) {
this.NameEnglish = name;
this.NameJapanese = name;
this.NameFrench = name;
diff --git a/XivCommon/Functions/ContextMenu/Inventory/InventoryContextMenuItem.cs b/XivCommon/Functions/ContextMenu/Inventory/InventoryContextMenuItem.cs
index 3d3514c..74aa045 100755
--- a/XivCommon/Functions/ContextMenu/Inventory/InventoryContextMenuItem.cs
+++ b/XivCommon/Functions/ContextMenu/Inventory/InventoryContextMenuItem.cs
@@ -1,4 +1,6 @@
-namespace XivCommon.Functions.ContextMenu.Inventory {
+using Dalamud.Game.Text.SeStringHandling;
+
+namespace XivCommon.Functions.ContextMenu.Inventory {
///
/// A custom context menu item for inventory items.
///
@@ -8,7 +10,7 @@
///
/// the English name of the item, copied to other languages
/// the action to perform on click
- public InventoryContextMenuItem(string name, ContextMenu.InventoryContextMenuItemSelectedDelegate action) : base(name, action) {
+ public InventoryContextMenuItem(SeString name, ContextMenu.InventoryContextMenuItemSelectedDelegate action) : base(name, action) {
}
}
}
diff --git a/XivCommon/Functions/ContextMenu/NativeContextMenuItem.cs b/XivCommon/Functions/ContextMenu/NativeContextMenuItem.cs
index 4843ae3..0b88ea4 100755
--- a/XivCommon/Functions/ContextMenu/NativeContextMenuItem.cs
+++ b/XivCommon/Functions/ContextMenu/NativeContextMenuItem.cs
@@ -1,4 +1,6 @@
-namespace XivCommon.Functions.ContextMenu {
+using Dalamud.Game.Text.SeStringHandling;
+
+namespace XivCommon.Functions.ContextMenu {
///
/// A native context menu item
///
@@ -11,9 +13,9 @@
///
/// The name of the context item.
///
- public string Name { get; set; }
+ public SeString Name { get; set; }
- internal NativeContextMenuItem(byte action, string name, bool enabled) {
+ internal NativeContextMenuItem(byte action, SeString name, bool enabled) {
this.Name = name;
this.InternalAction = action;
this.Enabled = enabled;
diff --git a/XivCommon/Functions/ContextMenu/NormalContextMenuItem.cs b/XivCommon/Functions/ContextMenu/NormalContextMenuItem.cs
index 31bde81..ceac073 100755
--- a/XivCommon/Functions/ContextMenu/NormalContextMenuItem.cs
+++ b/XivCommon/Functions/ContextMenu/NormalContextMenuItem.cs
@@ -1,4 +1,6 @@
-namespace XivCommon.Functions.ContextMenu {
+using Dalamud.Game.Text.SeStringHandling;
+
+namespace XivCommon.Functions.ContextMenu {
///
/// A custom normal context menu item
///
@@ -11,7 +13,7 @@
///
/// the English name of the item, copied to other languages
/// the action to perform on click
- public NormalContextMenuItem(string name, ContextMenu.ContextMenuItemSelectedDelegate action) : base(name, action) {
+ public NormalContextMenuItem(SeString name, ContextMenu.ContextMenuItemSelectedDelegate action) : base(name, action) {
}
}
}
diff --git a/XivCommon/GameFunctions.cs b/XivCommon/GameFunctions.cs
index dba04da..d49124c 100755
--- a/XivCommon/GameFunctions.cs
+++ b/XivCommon/GameFunctions.cs
@@ -84,7 +84,7 @@ namespace XivCommon {
this.Examine = new Examine(this, scanner);
this.Talk = new Talk(scanner, seStringManager, hooks.HasFlag(Hooks.Talk));
this.ChatBubbles = new ChatBubbles(dalamud, scanner, seStringManager, hooks.HasFlag(Hooks.ChatBubbles));
- this.ContextMenu = new ContextMenu(this, scanner, @interface.Framework.Gui, @interface.ClientState.ClientLanguage, hooks);
+ this.ContextMenu = new ContextMenu(this, scanner, seStringManager, @interface.ClientState.ClientLanguage, hooks);
this.Tooltips = new Tooltips(scanner, @interface.Framework, @interface.Framework.Gui, seStringManager, hooks.HasFlag(Hooks.Tooltips));
if (scanner.TryScanText(Signatures.GetAgentByInternalId, out var byInternalIdPtr, "GetAgentByInternalId")) {