diff --git a/Deliveroo/GameData/GameStrings.cs b/Deliveroo/GameData/GameStrings.cs index 1d621b9..007c777 100644 --- a/Deliveroo/GameData/GameStrings.cs +++ b/Deliveroo/GameData/GameStrings.cs @@ -1,32 +1,24 @@ using System; -using System.Linq; using System.Text.RegularExpressions; using Dalamud.Plugin.Services; +using LLib; using Lumina.Excel; using Lumina.Excel.CustomSheets; using Lumina.Excel.GeneratedSheets; -using Lumina.Text; -using Lumina.Text.Payloads; namespace Deliveroo.GameData; internal sealed class GameStrings { - private readonly IDataManager _dataManager; - private readonly IPluginLog _pluginLog; - public GameStrings(IDataManager dataManager, IPluginLog pluginLog) { - _dataManager = dataManager; - _pluginLog = pluginLog; - UndertakeSupplyAndProvisioningMission = - GetDialogue("TEXT_COMDEFGRANDCOMPANYOFFICER_00073_A4_002"); + dataManager.GetDialogue("TEXT_COMDEFGRANDCOMPANYOFFICER_00073_A4_002", pluginLog); ClosePersonnelOfficerTalk = - GetDialogue("TEXT_COMDEFGRANDCOMPANYOFFICER_00073_A4_004"); - ExchangeItems = GetRegex(4928, addon => addon.Text) + dataManager.GetDialogue("TEXT_COMDEFGRANDCOMPANYOFFICER_00073_A4_004", pluginLog); + ExchangeItems = dataManager.GetRegex(4928, addon => addon.Text, pluginLog) ?? throw new Exception($"Unable to resolve {nameof(ExchangeItems)}"); - TradeHighQualityItem = GetString(102434, addon => addon.Text) + TradeHighQualityItem = dataManager.GetString(102434, addon => addon.Text, pluginLog) ?? throw new Exception($"Unable to resolve {nameof(TradeHighQualityItem)}"); } @@ -36,51 +28,6 @@ internal sealed class GameStrings public Regex ExchangeItems { get; } public string TradeHighQualityItem { get; } - private string GetDialogue(string key) - where T : QuestDialogueText - { - string result = _dataManager.GetExcelSheet()! - .Single(x => x.Key == key) - .Value - .ToString(); - _pluginLog.Verbose($"{typeof(T).Name}.{key} => {result}"); - return result; - } - - private SeString? GetSeString(uint rowId, Func mapper) - where T : ExcelRow - { - var row = _dataManager.GetExcelSheet()?.GetRow(rowId); - if (row == null) - return null; - - return mapper(row); - } - - private string? GetString(uint rowId, Func mapper) - where T : ExcelRow - { - string? text = GetSeString(rowId, mapper)?.ToString(); - - _pluginLog.Verbose($"{typeof(T).Name}.{rowId} => {text}"); - return text; - } - - private Regex? GetRegex(uint rowId, Func mapper) - where T : ExcelRow - { - SeString? text = GetSeString(rowId, mapper); - string regex = string.Join("", text.Payloads.Select(payload => - { - if (payload is TextPayload) - return Regex.Escape(payload.RawString); - else - return ".*"; - })); - _pluginLog.Verbose($"{typeof(T).Name}.{rowId} => /{regex}/"); - return new Regex(regex); - } - [Sheet("custom/000/ComDefGrandCompanyOfficer_00073")] private class ComDefGrandCompanyOfficer : QuestDialogueText { diff --git a/LLib b/LLib index abbbec4..e59d291 160000 --- a/LLib +++ b/LLib @@ -1 +1 @@ -Subproject commit abbbec4f26b1a8903b0cd7aa04f00d557602eaf3 +Subproject commit e59d291f04473eae0b76712397733e2e25349953