Resolve names via SeStringEvaluator

This commit is contained in:
Haselnussbomber
2025-04-04 15:42:13 +02:00
parent 5b9ca4f5f8
commit 4f6c10d170
3 changed files with 20 additions and 9 deletions
-2
View File
@@ -16,13 +16,11 @@ public static class LuminaSheets
public static readonly ExcelSheet<ClassJob> ClassJobSheet = Module.GetSheet<ClassJob>(); public static readonly ExcelSheet<ClassJob> ClassJobSheet = Module.GetSheet<ClassJob>();
public static readonly ExcelSheet<Item> ItemSheet = Module.GetSheet<Item>(); public static readonly ExcelSheet<Item> ItemSheet = Module.GetSheet<Item>();
public static readonly ExcelSheet<Item> ItemSheetEnglish = Module.GetSheet<Item>(Language.English)!; public static readonly ExcelSheet<Item> ItemSheetEnglish = Module.GetSheet<Item>(Language.English)!;
public static readonly ExcelSheet<ENpcResident> ENpcResidentSheet = Module.GetSheet<ENpcResident>();
public static readonly ExcelSheet<Level> LevelSheet = Module.GetSheet<Level>(); public static readonly ExcelSheet<Level> LevelSheet = Module.GetSheet<Level>();
public static readonly ExcelSheet<Quest> QuestSheet = Module.GetSheet<Quest>(); public static readonly ExcelSheet<Quest> QuestSheet = Module.GetSheet<Quest>();
public static readonly ExcelSheet<Materia> MateriaSheet = Module.GetSheet<Materia>(); public static readonly ExcelSheet<Materia> MateriaSheet = Module.GetSheet<Materia>();
public static readonly ExcelSheet<BaseParam> BaseParamSheet = Module.GetSheet<BaseParam>(); public static readonly ExcelSheet<BaseParam> BaseParamSheet = Module.GetSheet<BaseParam>();
public static readonly ExcelSheet<ItemFood> ItemFoodSheet = Module.GetSheet<ItemFood>(); public static readonly ExcelSheet<ItemFood> ItemFoodSheet = Module.GetSheet<ItemFood>();
public static readonly SubrowExcelSheet<SatisfactionSupply> SatisfactionSupplySheet = Module.GetSubrowSheet<SatisfactionSupply>();
public static readonly ExcelSheet<WKSMissionToDoEvalutionRefin> WKSMissionToDoEvalutionRefinSheet = Module.GetSheet<WKSMissionToDoEvalutionRefin>(); public static readonly ExcelSheet<WKSMissionToDoEvalutionRefin> WKSMissionToDoEvalutionRefinSheet = Module.GetSheet<WKSMissionToDoEvalutionRefin>();
public static readonly ExcelSheet<RecipeLevelTable> RecipeLevelTableSheet = Module.GetSheet<RecipeLevelTable>(); public static readonly ExcelSheet<RecipeLevelTable> RecipeLevelTableSheet = Module.GetSheet<RecipeLevelTable>();
public static readonly ExcelSheet<GathererCrafterLvAdjustTable> GathererCrafterLvAdjustTableSheet = Module.GetSheet<GathererCrafterLvAdjustTable>(); public static readonly ExcelSheet<GathererCrafterLvAdjustTable> GathererCrafterLvAdjustTableSheet = Module.GetSheet<GathererCrafterLvAdjustTable>();
+3
View File
@@ -9,6 +9,8 @@ using Dalamud.Storage.Assets;
namespace Craftimizer.Plugin; namespace Craftimizer.Plugin;
#pragma warning disable SeStringEvaluator
public sealed class Service public sealed class Service
{ {
#pragma warning disable CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable. #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 IPluginLog PluginLog { get; private set; }
[PluginService] public static IGameInteropProvider GameInteropProvider { get; private set; } [PluginService] public static IGameInteropProvider GameInteropProvider { get; private set; }
[PluginService] public static INotificationManager NotificationManager { 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 Plugin Plugin { get; private set; }
public static Configuration Configuration => Plugin.Configuration; public static Configuration Configuration => Plugin.Configuration;
+17 -7
View File
@@ -3,6 +3,7 @@ using Craftimizer.Simulator;
using Craftimizer.Simulator.Actions; using Craftimizer.Simulator.Actions;
using Craftimizer.Solver; using Craftimizer.Solver;
using Craftimizer.Utils; using Craftimizer.Utils;
using Dalamud.Game.ClientState.Objects.Enums;
using Dalamud.Game.Text; using Dalamud.Game.Text;
using Dalamud.Game.Text.SeStringHandling.Payloads; using Dalamud.Game.Text.SeStringHandling.Payloads;
using Dalamud.Interface; using Dalamud.Interface;
@@ -17,12 +18,12 @@ using Dalamud.Utility;
using FFXIVClientStructs.FFXIV.Client.Game; using FFXIVClientStructs.FFXIV.Client.Game;
using FFXIVClientStructs.FFXIV.Client.Game.UI; using FFXIVClientStructs.FFXIV.Client.Game.UI;
using FFXIVClientStructs.FFXIV.Client.System.String; using FFXIVClientStructs.FFXIV.Client.System.String;
using FFXIVClientStructs.FFXIV.Client.UI;
using FFXIVClientStructs.FFXIV.Client.UI.Misc; using FFXIVClientStructs.FFXIV.Client.UI.Misc;
using FFXIVClientStructs.FFXIV.Component.GUI; using FFXIVClientStructs.FFXIV.Component.GUI;
using ImGuiNET; using ImGuiNET;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Globalization;
using System.Linq; using System.Linq;
using System.Numerics; using System.Numerics;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
@@ -589,7 +590,7 @@ public sealed unsafe class RecipeNote : Window, IDisposable
if (ImGui.IsItemHovered()) if (ImGui.IsItemHovered())
ImGuiUtils.Tooltip("Open in map"); ImGuiUtils.Tooltip("Open in map");
ImGuiUtils.TextCentered($"{questTerritory} ({questLocation.X:0.0}, {questLocation.Y:0.0})"); ImGuiUtils.TextCentered($"{questTerritory} ({GetCoordinatesString(questLocation)})");
} }
break; break;
case CraftableStatus.WrongClassJob: case CraftableStatus.WrongClassJob:
@@ -624,7 +625,7 @@ public sealed unsafe class RecipeNote : Window, IDisposable
if (ImGui.IsItemHovered()) if (ImGui.IsItemHovered())
ImGuiUtils.Tooltip("Open in map"); ImGuiUtils.Tooltip("Open in map");
ImGuiUtils.TextCentered($"{vendorTerritory} ({vendorLoation.X:0.0}, {vendorLoation.Y:0.0})"); ImGuiUtils.TextCentered($"{vendorTerritory} ({GetCoordinatesString(vendorLoation)})");
} }
break; break;
case CraftableStatus.RequiredItem: 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) private static (string NpcName, string Territory, Vector2 MapLocation, MapLinkPayload Payload) ResolveLevelData(uint levelRowId)
{ {
var level = LuminaSheets.LevelSheet.GetRow(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!); 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) 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) private static string ResolveNpcResidentName(uint npcRowId)
{ {
var resident = LuminaSheets.ENpcResidentSheet.GetRow(npcRowId); return Service.SeStringEvaluator.EvaluateObjStr(ObjectKind.EventNpc, npcRowId);
return resident.Singular.ExtractText(); }
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) private static int? GetGearsetForJob(ClassJob job)