diff --git a/Dalamud/Game/Text/SeStringHandling/SeString.cs b/Dalamud/Game/Text/SeStringHandling/SeString.cs index 6132d0910..8cce5c286 100644 --- a/Dalamud/Game/Text/SeStringHandling/SeString.cs +++ b/Dalamud/Game/Text/SeStringHandling/SeString.cs @@ -254,10 +254,22 @@ public class SeString /// The raw x-coordinate for this link. /// The raw y-coordinate for this link.. /// An SeString containing all of the payloads necessary to display a map link in the chat log. - public static SeString CreateMapLink(uint territoryId, uint mapId, int rawX, int rawY) + public static SeString CreateMapLink(uint territoryId, uint mapId, int rawX, int rawY) => + CreateMapLinkWithInstance(territoryId, mapId, null, rawX, rawY); + + /// + /// Creates an SeString representing an entire Payload chain that can be used to link a map position in the chat log. + /// + /// The id of the TerritoryType for this map link. + /// The id of the Map for this map link. + /// An optional area instance number to be included in this link. + /// The raw x-coordinate for this link. + /// The raw y-coordinate for this link.. + /// An SeString containing all of the payloads necessary to display a map link in the chat log. + public static SeString CreateMapLinkWithInstance(uint territoryId, uint mapId, int? instance, int rawX, int rawY) { var mapPayload = new MapLinkPayload(territoryId, mapId, rawX, rawY); - var nameString = $"{mapPayload.PlaceName} {mapPayload.CoordinateString}"; + var nameString = GetMapLinkNameString(mapPayload.PlaceName, instance, mapPayload.CoordinateString); var payloads = new List(new Payload[] { @@ -280,10 +292,24 @@ public class SeString /// The human-readable y-coordinate for this link. /// An optional offset to account for rounding and truncation errors; it is best to leave this untouched in most cases. /// An SeString containing all of the payloads necessary to display a map link in the chat log. - public static SeString CreateMapLink(uint territoryId, uint mapId, float xCoord, float yCoord, float fudgeFactor = 0.05f) + public static SeString CreateMapLink( + uint territoryId, uint mapId, float xCoord, float yCoord, float fudgeFactor = 0.05f) => + CreateMapLinkWithInstance(territoryId, mapId, null, xCoord, yCoord, fudgeFactor); + + /// + /// Creates an SeString representing an entire Payload chain that can be used to link a map position in the chat log. + /// + /// The id of the TerritoryType for this map link. + /// The id of the Map for this map link. + /// An optional area instance number to be included in this link. + /// The human-readable x-coordinate for this link. + /// The human-readable y-coordinate for this link. + /// An optional offset to account for rounding and truncation errors; it is best to leave this untouched in most cases. + /// An SeString containing all of the payloads necessary to display a map link in the chat log. + public static SeString CreateMapLinkWithInstance(uint territoryId, uint mapId, int? instance, float xCoord, float yCoord, float fudgeFactor = 0.05f) { var mapPayload = new MapLinkPayload(territoryId, mapId, xCoord, yCoord, fudgeFactor); - var nameString = $"{mapPayload.PlaceName} {mapPayload.CoordinateString}"; + var nameString = GetMapLinkNameString(mapPayload.PlaceName, instance, mapPayload.CoordinateString); var payloads = new List(new Payload[] { @@ -306,7 +332,20 @@ public class SeString /// The human-readable y-coordinate for this link. /// An optional offset to account for rounding and truncation errors; it is best to leave this untouched in most cases. /// An SeString containing all of the payloads necessary to display a map link in the chat log. - public static SeString? CreateMapLink(string placeName, float xCoord, float yCoord, float fudgeFactor = 0.05f) + public static SeString? CreateMapLink(string placeName, float xCoord, float yCoord, float fudgeFactor = 0.05f) => + CreateMapLinkWithInstance(placeName, null, xCoord, yCoord, fudgeFactor); + + /// + /// Creates an SeString representing an entire Payload chain that can be used to link a map position in the chat log, matching a specified zone name. + /// Returns null if no corresponding PlaceName was found. + /// + /// The name of the location for this link. This should be exactly the name as seen in a displayed map link in-game for the same zone. + /// An optional area instance number to be included in this link. + /// The human-readable x-coordinate for this link. + /// The human-readable y-coordinate for this link. + /// An optional offset to account for rounding and truncation errors; it is best to leave this untouched in most cases. + /// An SeString containing all of the payloads necessary to display a map link in the chat log. + public static SeString? CreateMapLinkWithInstance(string placeName, int? instance, float xCoord, float yCoord, float fudgeFactor = 0.05f) { var data = Service.Get(); @@ -321,7 +360,7 @@ public class SeString var map = mapSheet.FirstOrDefault(row => row.PlaceName.Row == place.RowId); if (map != null && map.TerritoryType.Row != 0) { - return CreateMapLink(map.TerritoryType.Row, map.RowId, xCoord, yCoord, fudgeFactor); + return CreateMapLinkWithInstance(map.TerritoryType.Row, map.RowId, instance, xCoord, yCoord, fudgeFactor); } } @@ -329,6 +368,17 @@ public class SeString return null; } + private static string GetMapLinkNameString(string placeName, int? instance, string coordinateString) + { + var instanceString = string.Empty; + if (instance is > 0 and < 10) + { + instanceString = (SeIconChar.Instance1 + instance.Value - 1).ToIconString(); + } + + return $"{placeName}{instanceString} {coordinateString}"; + } + /// /// Creates an SeString representing an entire payload chain that can be used to link party finder listings in the chat log. ///