fix: use SeString for PF text

This commit is contained in:
Anna Clemens 2021-03-03 21:08:45 -05:00
parent 186b8ed62c
commit 66b4d19603
No known key found for this signature in database
GPG key ID: 0B391D8F06FCD9E0
2 changed files with 9 additions and 26 deletions

View file

@ -79,7 +79,7 @@ namespace Dalamud.Game.Internal.Gui {
continue; 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(); var args = new PartyFinderListingEventArgs();
ReceiveListing?.Invoke(listing, args); ReceiveListing?.Invoke(listing, args);

View file

@ -2,8 +2,8 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Text;
using Dalamud.Data; using Dalamud.Data;
using Dalamud.Game.Chat.SeStringHandling;
using Lumina.Excel.GeneratedSheets; using Lumina.Excel.GeneratedSheets;
namespace Dalamud.Game.Internal.Gui.Structs { 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#. // 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)] [MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)]
private readonly byte[] name; internal readonly byte[] name;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 192)] [MarshalAs(UnmanagedType.ByValArray, SizeConst = 192)]
private readonly byte[] description; internal 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<byte> 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 bool IsNull() { internal bool IsNull() {
// a valid party finder must have at least one slot set // a valid party finder must have at least one slot set
@ -142,11 +125,11 @@ namespace Dalamud.Game.Internal.Gui.Structs {
/// <summary> /// <summary>
/// The name of the player hosting this listing. /// The name of the player hosting this listing.
/// </summary> /// </summary>
public string Name { get; } public SeString Name { get; }
/// <summary> /// <summary>
/// The description of this listing as set by the host. May be multiple lines. /// The description of this listing as set by the host. May be multiple lines.
/// </summary> /// </summary>
public string Description { get; } public SeString Description { get; }
/// <summary> /// <summary>
/// The world that this listing was created on. /// The world that this listing was created on.
/// </summary> /// </summary>
@ -263,7 +246,7 @@ namespace Dalamud.Game.Internal.Gui.Structs {
#endregion #endregion
internal PartyFinderListing(PartyFinder.Listing listing, DataManager dataManager) { internal PartyFinderListing(PartyFinder.Listing listing, DataManager dataManager, SeStringManager seStringManager) {
this.objective = listing.objective; this.objective = listing.objective;
this.conditions = listing.conditions; this.conditions = listing.conditions;
this.dutyFinderSettings = listing.dutyFinderSettings; this.dutyFinderSettings = listing.dutyFinderSettings;
@ -273,8 +256,8 @@ namespace Dalamud.Game.Internal.Gui.Structs {
this.jobsPresent = listing.jobsPresent; this.jobsPresent = listing.jobsPresent;
Id = listing.id; Id = listing.id;
Name = listing.Name(); Name = seStringManager.Parse(listing.name);
Description = listing.Description(); Description = seStringManager.Parse(listing.description);
World = new Lazy<World>(() => dataManager.GetExcelSheet<World>().GetRow(listing.world)); World = new Lazy<World>(() => dataManager.GetExcelSheet<World>().GetRow(listing.world));
HomeWorld = new Lazy<World>(() => dataManager.GetExcelSheet<World>().GetRow(listing.homeWorld)); HomeWorld = new Lazy<World>(() => dataManager.GetExcelSheet<World>().GetRow(listing.homeWorld));
CurrentWorld = new Lazy<World>(() => dataManager.GetExcelSheet<World>().GetRow(listing.currentWorld)); CurrentWorld = new Lazy<World>(() => dataManager.GetExcelSheet<World>().GetRow(listing.currentWorld));