diff --git a/Dalamud/Game/Text/SeStringHandling/Payloads/MapLinkPayload.cs b/Dalamud/Game/Text/SeStringHandling/Payloads/MapLinkPayload.cs index 50945a7ce..667b52e36 100644 --- a/Dalamud/Game/Text/SeStringHandling/Payloads/MapLinkPayload.cs +++ b/Dalamud/Game/Text/SeStringHandling/Payloads/MapLinkPayload.cs @@ -130,7 +130,13 @@ public class MapLinkPayload : Payload var y = Math.Truncate((this.YCoord + fudge) * 10.0f) / 10.0f; // the formatting and spacing the game uses - return $"( {x:0.0} , {y:0.0} )"; + var clientState = Service.Get(); + return clientState.ClientLanguage switch + { + ClientLanguage.German => $"( {x:0.0}, {y:0.0} )", + ClientLanguage.Japanese => $"({x:0.0}, {y:0.0})", + _ => $"( {x:0.0} , {y:0.0} )", + }; } } diff --git a/Dalamud/Game/Text/SeStringHandling/SeString.cs b/Dalamud/Game/Text/SeStringHandling/SeString.cs index 6d0c8b0fb..2ddb73f12 100644 --- a/Dalamud/Game/Text/SeStringHandling/SeString.cs +++ b/Dalamud/Game/Text/SeStringHandling/SeString.cs @@ -52,14 +52,27 @@ public class SeString /// with the appropriate glow and coloring. /// /// A list of all the payloads required to insert the link marker. - public static IEnumerable TextArrowPayloads => new List(new Payload[] + public static IEnumerable TextArrowPayloads { - new UIForegroundPayload(0x01F4), - new UIGlowPayload(0x01F5), - new TextPayload($"{(char)SeIconChar.LinkMarker}"), - UIGlowPayload.UIGlowOff, - UIForegroundPayload.UIForegroundOff, - }); + get + { + var clientState = Service.Get(); + var markerSpace = clientState.ClientLanguage switch + { + ClientLanguage.German => " ", + ClientLanguage.French => " ", + _ => string.Empty, + }; + return new List + { + new UIForegroundPayload(500), + new UIGlowPayload(501), + new TextPayload($"{(char)SeIconChar.LinkMarker}{markerSpace}"), + UIGlowPayload.UIGlowOff, + UIForegroundPayload.UIForegroundOff, + }; + } + } /// /// Gets an empty SeString. @@ -171,6 +184,7 @@ public class SeString var data = Service.Get(); var displayName = displayNameOverride; + var rarity = 1; // default: white if (displayName == null) { switch (kind) @@ -178,7 +192,9 @@ public class SeString case ItemPayload.ItemKind.Normal: case ItemPayload.ItemKind.Collectible: case ItemPayload.ItemKind.Hq: - displayName = data.GetExcelSheet()?.GetRow(itemId)?.Name; + var item = data.GetExcelSheet()?.GetRow(itemId); + displayName = item?.Name; + rarity = item?.Rarity ?? 1; break; case ItemPayload.ItemKind.EventItem: displayName = data.GetExcelSheet()?.GetRow(itemId)?.Name; @@ -202,21 +218,20 @@ public class SeString displayName += $" {(char)SeIconChar.Collectible}"; } - // TODO: probably a cleaner way to build these than doing the bulk+insert - var payloads = new List(new Payload[] - { - new UIForegroundPayload(0x0225), - new UIGlowPayload(0x0226), - new ItemPayload(itemId, kind), - // arrow goes here - new TextPayload(displayName), - RawPayload.LinkTerminator, - // sometimes there is another set of uiglow/foreground off payloads here - // might be necessary when including additional text after the item name - }); - payloads.InsertRange(3, TextArrowPayloads); + var textColor = (ushort)(549 + ((rarity - 1) * 2)); + var textGlowColor = (ushort)(textColor + 1); - return new SeString(payloads); + // Note: `SeStringBuilder.AddItemLink` uses this function, so don't call it here! + return new SeStringBuilder() + .AddUiForeground(textColor) + .AddUiGlow(textGlowColor) + .Add(new ItemPayload(itemId, kind)) + .Append(TextArrowPayloads) + .AddText(displayName) + .AddUiGlowOff() + .AddUiForegroundOff() + .Add(RawPayload.LinkTerminator) + .Build(); } /// diff --git a/Dalamud/Game/Text/SeStringHandling/SeStringBuilder.cs b/Dalamud/Game/Text/SeStringHandling/SeStringBuilder.cs index 36bb10a2d..1fda9f9ae 100644 --- a/Dalamud/Game/Text/SeStringHandling/SeStringBuilder.cs +++ b/Dalamud/Game/Text/SeStringHandling/SeStringBuilder.cs @@ -1,3 +1,6 @@ +using System.Collections.Generic; +using System.Linq; + using Dalamud.Game.Text.SeStringHandling.Payloads; namespace Dalamud.Game.Text.SeStringHandling; @@ -30,6 +33,13 @@ public class SeStringBuilder /// The current builder. public SeStringBuilder Append(string text) => this.AddText(text); + /// + /// Append payloads to the builder. + /// + /// A list of payloads. + /// The current builder. + public SeStringBuilder Append(IEnumerable payloads) => this.Append(new SeString(payloads.ToList())); + /// /// Append raw text to the builder. /// @@ -104,7 +114,7 @@ public class SeStringBuilder /// Override for the item's name. /// The current builder. public SeStringBuilder AddItemLink(uint itemId, bool isHq, string? itemNameOverride = null) => - this.Add(new ItemPayload(itemId, isHq, itemNameOverride)); + this.Append(SeString.CreateItemLink(itemId, isHq, itemNameOverride)); /// /// Add an item link to the builder. @@ -113,14 +123,15 @@ public class SeStringBuilder /// Kind of item to encode. /// Override for the item's name. /// The current builder. - public SeStringBuilder AddItemLink(uint itemId, ItemPayload.ItemKind kind, string? itemNameOverride = null) => - this.Add(new ItemPayload(itemId, kind, itemNameOverride)); + public SeStringBuilder AddItemLink(uint itemId, ItemPayload.ItemKind kind = ItemPayload.ItemKind.Normal, string? itemNameOverride = null) => + this.Append(SeString.CreateItemLink(itemId, kind, itemNameOverride)); /// /// Add an item link to the builder. /// /// The raw item ID. /// The current builder. + /// To terminate this item link, add a . public SeStringBuilder AddItemLinkRaw(uint rawItemId) => this.Add(ItemPayload.FromRaw(rawItemId));