From 4f6c10d1703ed947e18f66dd385873e96e734f66 Mon Sep 17 00:00:00 2001 From: Haselnussbomber Date: Fri, 4 Apr 2025 15:42:13 +0200 Subject: [PATCH] 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)