From 5b9ca4f5f8e5c2011ed97ae579288505f7316833 Mon Sep 17 00:00:00 2001 From: Haselnussbomber Date: Fri, 4 Apr 2025 15:32:52 +0200 Subject: [PATCH 1/3] Strip soft hyphens --- Craftimizer/SimulatorUtils.cs | 4 ++-- Craftimizer/Utils/ReadOnlySeStringExtensions.cs | 12 ++++++++++++ Craftimizer/Windows/MacroEditor.cs | 12 ++++++------ Craftimizer/Windows/RecipeNote.cs | 6 +++--- Craftimizer/Windows/SynthHelper.cs | 2 +- 5 files changed, 24 insertions(+), 12 deletions(-) create mode 100644 Craftimizer/Utils/ReadOnlySeStringExtensions.cs diff --git a/Craftimizer/SimulatorUtils.cs b/Craftimizer/SimulatorUtils.cs index 0fa6995..7637d45 100644 --- a/Craftimizer/SimulatorUtils.cs +++ b/Craftimizer/SimulatorUtils.cs @@ -14,7 +14,7 @@ using Craftimizer.Utils; using Lumina.Text.ReadOnly; using Lumina.Text.Payloads; using Lumina.Excel.Sheets; -using FFXIVClientStructs.FFXIV.Client.Game.Event; +using Dalamud.Utility; namespace Craftimizer.Plugin; @@ -162,7 +162,7 @@ internal static class ClassJobUtils public static string GetName(this ClassJob me) { var job = LuminaSheets.ClassJobSheet.GetRow(me.GetClassJobIndex()); - return job.Name.ExtractText().ToLowerInvariant(); + return job.Name.ExtractCleanText(); } public static string GetNameArticle(this ClassJob me) diff --git a/Craftimizer/Utils/ReadOnlySeStringExtensions.cs b/Craftimizer/Utils/ReadOnlySeStringExtensions.cs new file mode 100644 index 0000000..13f35ee --- /dev/null +++ b/Craftimizer/Utils/ReadOnlySeStringExtensions.cs @@ -0,0 +1,12 @@ +using Dalamud.Utility; +using Lumina.Text.ReadOnly; + +namespace Craftimizer.Utils; + +public static class ReadOnlySeStringExtensions +{ + public static string ExtractCleanText(this ReadOnlySeString self) + { + return self.ExtractText().StripSoftHyphen(); + } +} diff --git a/Craftimizer/Windows/MacroEditor.cs b/Craftimizer/Windows/MacroEditor.cs index 173c7ab..85fbc5d 100644 --- a/Craftimizer/Windows/MacroEditor.cs +++ b/Craftimizer/Windows/MacroEditor.cs @@ -572,7 +572,7 @@ public sealed class MacroEditor : Window, IDisposable if (input.ItemId == 0) return "None"; - var name = LuminaSheets.ItemSheet.GetRowOrDefault(input.ItemId)?.Name.ExtractText() ?? $"Unknown ({input.ItemId})"; + var name = LuminaSheets.ItemSheet.GetRowOrDefault(input.ItemId)?.Name.ExtractCleanText() ?? $"Unknown ({input.ItemId})"; return input.IsHQ ? $"{name} (HQ)" : name; } @@ -778,11 +778,11 @@ public sealed class MacroEditor : Window, IDisposable searchableRecipes, fontHandle, ImGui.GetContentRegionAvail().X - rightSideWidth, - r => r.Recipe.ItemResult.Value.Name.ExtractText(), + r => r.Recipe.ItemResult.Value.Name.ExtractCleanText(), r => r.Recipe.RowId.ToString(), r => { - ImGui.TextUnformatted($"{r.Recipe.ItemResult.Value.Name.ExtractText()}"); + ImGui.TextUnformatted($"{r.Recipe.ItemResult.Value.Name.ExtractCleanText()}"); var classJob = (ClassJob)r.Recipe.CraftType.RowId; var textLevel = SqText.LevelPrefix.ToIconChar() + SqText.ToLevelString(r.Recipe.RecipeLevelTable.Value!.ClassJobLevel); @@ -964,10 +964,10 @@ public sealed class MacroEditor : Window, IDisposable { var perItem = RecipeData.CalculateItemStartingQuality(idx, 1); var total = RecipeData.CalculateItemStartingQuality(idx, hqCount); - ImGuiUtils.Tooltip($"{ingredient.Item.Name.ExtractText()} {SeIconChar.HighQuality.ToIconString()}\n+{perItem} Quality/Item{(total > 0 ? $"\n+{total} Quality" : "")}"); + ImGuiUtils.Tooltip($"{ingredient.Item.Name.ExtractCleanText()} {SeIconChar.HighQuality.ToIconString()}\n+{perItem} Quality/Item{(total > 0 ? $"\n+{total} Quality" : "")}"); } else if (ingredient.Amount != 0) - ImGuiUtils.Tooltip($"{ingredient.Item.Name.ExtractText()}"); + ImGuiUtils.Tooltip($"{ingredient.Item.Name.ExtractCleanText()}"); } ImGui.SameLine(0, 5); ImGui.SetNextItemWidth(ImGui.GetContentRegionAvail().X - (5 + ImGui.CalcTextSize("/").X + 5 + ImGui.CalcTextSize($"99").X)); @@ -1240,7 +1240,7 @@ public sealed class MacroEditor : Window, IDisposable { var status = effect.Status(); using var _reset = ImRaii.DefaultFont(); - ImGuiUtils.Tooltip($"{status.Name.ExtractText()}\n{status.Description.ExtractText()}"); + ImGuiUtils.Tooltip($"{status.Name.ExtractCleanText()}\n{status.Description.ExtractCleanText()}"); } ImGui.SameLine(); } diff --git a/Craftimizer/Windows/RecipeNote.cs b/Craftimizer/Windows/RecipeNote.cs index be797c9..32534d9 100644 --- a/Craftimizer/Windows/RecipeNote.cs +++ b/Craftimizer/Windows/RecipeNote.cs @@ -630,7 +630,7 @@ public sealed unsafe class RecipeNote : Window, IDisposable case CraftableStatus.RequiredItem: { var item = RecipeData.Recipe.ItemRequired.Value!; - var itemName = item.Name.ExtractText(); + var itemName = item.Name.ExtractCleanText(); var imageSize = ImGui.GetFrameHeight(); ImGuiUtils.TextCentered($"You are missing the required equipment."); @@ -644,7 +644,7 @@ public sealed unsafe class RecipeNote : Window, IDisposable case CraftableStatus.RequiredStatus: { var status = RecipeData.Recipe.StatusRequired.Value!; - var statusName = status.Name.ExtractText(); + var statusName = status.Name.ExtractCleanText(); var statusIcon = Service.IconManager.GetIconCached(status.Icon); var imageSize = new Vector2(ImGui.GetFrameHeight() * (statusIcon.AspectRatio ?? 1), ImGui.GetFrameHeight()); @@ -1158,7 +1158,7 @@ public sealed unsafe class RecipeNote : Window, IDisposable private static (string NpcName, string Territory, Vector2 MapLocation, MapLinkPayload Payload) ResolveLevelData(uint levelRowId) { var level = LuminaSheets.LevelSheet.GetRow(levelRowId); - var territory = level.Territory.Value.PlaceName.Value.Name.ExtractText(); + var territory = level.Territory.Value.PlaceName.Value.Name.ExtractCleanText(); var location = WorldToMap2(new(level.X, level.Z), level.Map.Value!); return (ResolveNpcResidentName(level.Object.RowId), territory, location, new(level.Territory.RowId, level.Map.RowId, location.X, location.Y)); diff --git a/Craftimizer/Windows/SynthHelper.cs b/Craftimizer/Windows/SynthHelper.cs index c703f6c..6f2824e 100644 --- a/Craftimizer/Windows/SynthHelper.cs +++ b/Craftimizer/Windows/SynthHelper.cs @@ -392,7 +392,7 @@ public sealed unsafe class SynthHelper : Window, IDisposable { var status = effect.Status(); using var _reset = ImRaii.DefaultFont(); - ImGuiUtils.Tooltip($"{status.Name.ExtractText()}\n{status.Description.ExtractText()}"); + ImGuiUtils.Tooltip($"{status.Name.ExtractCleanText()}\n{status.Description.ExtractCleanText()}"); } ImGui.SameLine(); } From 4f6c10d1703ed947e18f66dd385873e96e734f66 Mon Sep 17 00:00:00 2001 From: Haselnussbomber Date: Fri, 4 Apr 2025 15:42:13 +0200 Subject: [PATCH 2/3] Resolve names via SeStringEvaluator --- Craftimizer/LuminaSheets.cs | 2 -- Craftimizer/Service.cs | 3 +++ Craftimizer/Windows/RecipeNote.cs | 24 +++++++++++++++++------- 3 files changed, 20 insertions(+), 9 deletions(-) diff --git a/Craftimizer/LuminaSheets.cs b/Craftimizer/LuminaSheets.cs index 28e0af2..53a58e2 100644 --- a/Craftimizer/LuminaSheets.cs +++ b/Craftimizer/LuminaSheets.cs @@ -16,13 +16,11 @@ public static class LuminaSheets public static readonly ExcelSheet ClassJobSheet = Module.GetSheet(); public static readonly ExcelSheet ItemSheet = Module.GetSheet(); public static readonly ExcelSheet ItemSheetEnglish = Module.GetSheet(Language.English)!; - public static readonly ExcelSheet ENpcResidentSheet = Module.GetSheet(); public static readonly ExcelSheet LevelSheet = Module.GetSheet(); public static readonly ExcelSheet QuestSheet = Module.GetSheet(); public static readonly ExcelSheet MateriaSheet = Module.GetSheet(); public static readonly ExcelSheet BaseParamSheet = Module.GetSheet(); public static readonly ExcelSheet ItemFoodSheet = Module.GetSheet(); - public static readonly SubrowExcelSheet SatisfactionSupplySheet = Module.GetSubrowSheet(); public static readonly ExcelSheet WKSMissionToDoEvalutionRefinSheet = Module.GetSheet(); public static readonly ExcelSheet RecipeLevelTableSheet = Module.GetSheet(); public static readonly ExcelSheet GathererCrafterLvAdjustTableSheet = Module.GetSheet(); diff --git a/Craftimizer/Service.cs b/Craftimizer/Service.cs index 18a1b4f..f38dad0 100644 --- a/Craftimizer/Service.cs +++ b/Craftimizer/Service.cs @@ -9,6 +9,8 @@ using Dalamud.Storage.Assets; namespace Craftimizer.Plugin; +#pragma warning disable SeStringEvaluator + public sealed class Service { #pragma warning disable CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable. @@ -27,6 +29,7 @@ public sealed class Service [PluginService] public static IPluginLog PluginLog { get; private set; } [PluginService] public static IGameInteropProvider GameInteropProvider { get; private set; } [PluginService] public static INotificationManager NotificationManager { get; private set; } + [PluginService] public static ISeStringEvaluator SeStringEvaluator { get; private set; } public static Plugin Plugin { get; private set; } public static Configuration Configuration => Plugin.Configuration; diff --git a/Craftimizer/Windows/RecipeNote.cs b/Craftimizer/Windows/RecipeNote.cs index 32534d9..9276a4e 100644 --- a/Craftimizer/Windows/RecipeNote.cs +++ b/Craftimizer/Windows/RecipeNote.cs @@ -3,6 +3,7 @@ using Craftimizer.Simulator; using Craftimizer.Simulator.Actions; using Craftimizer.Solver; using Craftimizer.Utils; +using Dalamud.Game.ClientState.Objects.Enums; using Dalamud.Game.Text; using Dalamud.Game.Text.SeStringHandling.Payloads; using Dalamud.Interface; @@ -17,12 +18,12 @@ using Dalamud.Utility; using FFXIVClientStructs.FFXIV.Client.Game; using FFXIVClientStructs.FFXIV.Client.Game.UI; using FFXIVClientStructs.FFXIV.Client.System.String; -using FFXIVClientStructs.FFXIV.Client.UI; using FFXIVClientStructs.FFXIV.Client.UI.Misc; using FFXIVClientStructs.FFXIV.Component.GUI; using ImGuiNET; using System; using System.Collections.Generic; +using System.Globalization; using System.Linq; using System.Numerics; using System.Runtime.InteropServices; @@ -589,7 +590,7 @@ public sealed unsafe class RecipeNote : Window, IDisposable if (ImGui.IsItemHovered()) ImGuiUtils.Tooltip("Open in map"); - ImGuiUtils.TextCentered($"{questTerritory} ({questLocation.X:0.0}, {questLocation.Y:0.0})"); + ImGuiUtils.TextCentered($"{questTerritory} ({GetCoordinatesString(questLocation)})"); } break; case CraftableStatus.WrongClassJob: @@ -624,7 +625,7 @@ public sealed unsafe class RecipeNote : Window, IDisposable if (ImGui.IsItemHovered()) ImGuiUtils.Tooltip("Open in map"); - ImGuiUtils.TextCentered($"{vendorTerritory} ({vendorLoation.X:0.0}, {vendorLoation.Y:0.0})"); + ImGuiUtils.TextCentered($"{vendorTerritory} ({GetCoordinatesString(vendorLoation)})"); } break; case CraftableStatus.RequiredItem: @@ -1158,10 +1159,10 @@ public sealed unsafe class RecipeNote : Window, IDisposable private static (string NpcName, string Territory, Vector2 MapLocation, MapLinkPayload Payload) ResolveLevelData(uint levelRowId) { var level = LuminaSheets.LevelSheet.GetRow(levelRowId); - var territory = level.Territory.Value.PlaceName.Value.Name.ExtractCleanText(); + var placeName = ResolvePlaceName(level.Territory.Value.PlaceName.RowId); var location = WorldToMap2(new(level.X, level.Z), level.Map.Value!); - return (ResolveNpcResidentName(level.Object.RowId), territory, location, new(level.Territory.RowId, level.Map.RowId, location.X, location.Y)); + return (ResolveNpcResidentName(level.Object.RowId), placeName, location, new(level.Territory.RowId, level.Map.RowId, location.X, location.Y)); } private static Vector2 WorldToMap2(Vector2 worldCoordinates, Lumina.Excel.Sheets.Map map) @@ -1171,8 +1172,17 @@ public sealed unsafe class RecipeNote : Window, IDisposable private static string ResolveNpcResidentName(uint npcRowId) { - var resident = LuminaSheets.ENpcResidentSheet.GetRow(npcRowId); - return resident.Singular.ExtractText(); + return Service.SeStringEvaluator.EvaluateObjStr(ObjectKind.EventNpc, npcRowId); + } + + private static string ResolvePlaceName(uint placeNameId) + { + return Service.SeStringEvaluator.EvaluateFromAddon(1337, [placeNameId]).ExtractText().StripSoftHyphen(); + } + + private static string GetCoordinatesString(Vector2 pos) + { + return $"{pos.X.ToString("0.0", CultureInfo.InvariantCulture)}, {pos.Y.ToString("0.0", CultureInfo.InvariantCulture)}"; } private static int? GetGearsetForJob(ClassJob job) From 02138bde78141e09b259ea604d686659d8a2c1c3 Mon Sep 17 00:00:00 2001 From: Haselnussbomber Date: Thu, 24 Apr 2025 20:18:20 +0200 Subject: [PATCH 3/3] Revert evaluating PlaceName --- Craftimizer/Windows/RecipeNote.cs | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/Craftimizer/Windows/RecipeNote.cs b/Craftimizer/Windows/RecipeNote.cs index 9276a4e..c7e9209 100644 --- a/Craftimizer/Windows/RecipeNote.cs +++ b/Craftimizer/Windows/RecipeNote.cs @@ -1159,7 +1159,7 @@ public sealed unsafe class RecipeNote : Window, IDisposable private static (string NpcName, string Territory, Vector2 MapLocation, MapLinkPayload Payload) ResolveLevelData(uint levelRowId) { var level = LuminaSheets.LevelSheet.GetRow(levelRowId); - var placeName = ResolvePlaceName(level.Territory.Value.PlaceName.RowId); + var placeName = level.Territory.Value.PlaceName.Value.Name.ExtractCleanText(); var location = WorldToMap2(new(level.X, level.Z), level.Map.Value!); return (ResolveNpcResidentName(level.Object.RowId), placeName, location, new(level.Territory.RowId, level.Map.RowId, location.X, location.Y)); @@ -1175,11 +1175,6 @@ public sealed unsafe class RecipeNote : Window, IDisposable return Service.SeStringEvaluator.EvaluateObjStr(ObjectKind.EventNpc, npcRowId); } - private static string ResolvePlaceName(uint placeNameId) - { - return Service.SeStringEvaluator.EvaluateFromAddon(1337, [placeNameId]).ExtractText().StripSoftHyphen(); - } - private static string GetCoordinatesString(Vector2 pos) { return $"{pos.X.ToString("0.0", CultureInfo.InvariantCulture)}, {pos.Y.ToString("0.0", CultureInfo.InvariantCulture)}";