From 66b4d19603cb99ffaece286872374ea2f6d62db1 Mon Sep 17 00:00:00 2001 From: Anna Clemens Date: Wed, 3 Mar 2021 21:08:45 -0500 Subject: [PATCH] fix: use SeString for PF text --- Dalamud/Game/Internal/Gui/PartyFinderGui.cs | 2 +- .../Game/Internal/Gui/Structs/PartyFinder.cs | 33 +++++-------------- 2 files changed, 9 insertions(+), 26 deletions(-) diff --git a/Dalamud/Game/Internal/Gui/PartyFinderGui.cs b/Dalamud/Game/Internal/Gui/PartyFinderGui.cs index 678251212..20a66825e 100755 --- a/Dalamud/Game/Internal/Gui/PartyFinderGui.cs +++ b/Dalamud/Game/Internal/Gui/PartyFinderGui.cs @@ -79,7 +79,7 @@ namespace Dalamud.Game.Internal.Gui { continue; } - var listing = new PartyFinderListing(packet.listings[i], Dalamud.Data); + var listing = new PartyFinderListing(packet.listings[i], Dalamud.Data, Dalamud.SeStringManager); var args = new PartyFinderListingEventArgs(); ReceiveListing?.Invoke(listing, args); diff --git a/Dalamud/Game/Internal/Gui/Structs/PartyFinder.cs b/Dalamud/Game/Internal/Gui/Structs/PartyFinder.cs index 5688ca021..cd8f133e6 100755 --- a/Dalamud/Game/Internal/Gui/Structs/PartyFinder.cs +++ b/Dalamud/Game/Internal/Gui/Structs/PartyFinder.cs @@ -2,8 +2,8 @@ using System.Collections.Generic; using System.Linq; using System.Runtime.InteropServices; -using System.Text; using Dalamud.Data; +using Dalamud.Game.Chat.SeStringHandling; using Lumina.Excel.GeneratedSheets; namespace Dalamud.Game.Internal.Gui.Structs { @@ -101,27 +101,10 @@ namespace Dalamud.Game.Internal.Gui.Structs { // Note that ByValTStr will not work here because the strings are UTF-8 and there's only a CharSet for UTF-16 in C#. [MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)] - private readonly byte[] name; + internal readonly byte[] name; [MarshalAs(UnmanagedType.ByValArray, SizeConst = 192)] - private readonly byte[] description; - - // 128 (0x80) before name and desc - // 160 (0xA0) with name (32 bytes/0x20) - // 352 (0x160) with both (192 bytes/0xC0) - - private static string HandleString(IEnumerable bytes) { - var nonNull = bytes.TakeWhile(b => b != 0).ToArray(); - return Encoding.UTF8.GetString(nonNull); - } - - internal string Name() { - return HandleString(this.name); - } - - internal string Description() { - return HandleString(this.description); - } + internal readonly byte[] description; internal bool IsNull() { // a valid party finder must have at least one slot set @@ -142,11 +125,11 @@ namespace Dalamud.Game.Internal.Gui.Structs { /// /// The name of the player hosting this listing. /// - public string Name { get; } + public SeString Name { get; } /// /// The description of this listing as set by the host. May be multiple lines. /// - public string Description { get; } + public SeString Description { get; } /// /// The world that this listing was created on. /// @@ -263,7 +246,7 @@ namespace Dalamud.Game.Internal.Gui.Structs { #endregion - internal PartyFinderListing(PartyFinder.Listing listing, DataManager dataManager) { + internal PartyFinderListing(PartyFinder.Listing listing, DataManager dataManager, SeStringManager seStringManager) { this.objective = listing.objective; this.conditions = listing.conditions; this.dutyFinderSettings = listing.dutyFinderSettings; @@ -273,8 +256,8 @@ namespace Dalamud.Game.Internal.Gui.Structs { this.jobsPresent = listing.jobsPresent; Id = listing.id; - Name = listing.Name(); - Description = listing.Description(); + Name = seStringManager.Parse(listing.name); + Description = seStringManager.Parse(listing.description); World = new Lazy(() => dataManager.GetExcelSheet().GetRow(listing.world)); HomeWorld = new Lazy(() => dataManager.GetExcelSheet().GetRow(listing.homeWorld)); CurrentWorld = new Lazy(() => dataManager.GetExcelSheet().GetRow(listing.currentWorld));