diff --git a/Deliveroo/Configuration.cs b/Deliveroo/Configuration.cs index fef7aae..764d830 100644 --- a/Deliveroo/Configuration.cs +++ b/Deliveroo/Configuration.cs @@ -14,6 +14,7 @@ internal sealed class Configuration : IPluginConfiguration public int ReservedSealCount { get; set; } public bool ReserveDifferentSealCountAtMaxRank { get; set; } public int ReservedSealCountAtMaxRank { get; set; } + public int PauseAtRank { get; set; } /// /// A config-only setting, not exposed in the UI. diff --git a/Deliveroo/Deliveroo.csproj b/Deliveroo/Deliveroo.csproj index 9e591a9..0331b61 100644 --- a/Deliveroo/Deliveroo.csproj +++ b/Deliveroo/Deliveroo.csproj @@ -1,7 +1,7 @@ net7.0-windows - 2.12 + 2.13 11.0 enable true diff --git a/Deliveroo/DeliverooPlugin.cs b/Deliveroo/DeliverooPlugin.cs index 9811369..3091d18 100644 --- a/Deliveroo/DeliverooPlugin.cs +++ b/Deliveroo/DeliverooPlugin.cs @@ -6,6 +6,8 @@ using Dalamud.Game.ClientState.Conditions; using Dalamud.Game.ClientState.Objects; using Dalamud.Game.ClientState.Objects.Types; using Dalamud.Game.Command; +using Dalamud.Game.Text; +using Dalamud.Game.Text.SeStringHandling; using Dalamud.Interface.Windowing; using Dalamud.Plugin; using Dalamud.Plugin.Services; @@ -87,6 +89,7 @@ public sealed partial class DeliverooPlugin : IDalamudPlugin _pluginInterface.UiBuilder.OpenConfigUi += _configWindow.Toggle; _clientState.Login += Login; _clientState.Logout += Logout; + _chatGui.ChatMessage += ChatMessage; _commandManager.AddHandler("/deliveroo", new CommandInfo(ProcessCommand) { HelpMessage = "Open the configuration" @@ -102,6 +105,30 @@ public sealed partial class DeliverooPlugin : IDalamudPlugin _addonLifecycle.RegisterListener(AddonEvent.PostSetup, "SelectYesno", SelectYesNoPostSetup); } + private void ChatMessage(XivChatType type, uint senderId, ref SeString sender, ref SeString message, ref bool isHandled) + { + if (_configuration.PauseAtRank <= 0) + return; + + if (type != _gameStrings.RankUpFcType) + return; + + var match = _gameStrings.RankUpFc.Match(message.ToString()); + if (!match.Success) + return; + + foreach (var group in match.Groups.Values) + { + if (int.TryParse(group.Value, out int rank) && rank == _configuration.PauseAtRank) + { + _turnInWindow.State = false; + _pluginLog.Information($"Pausing GC delivery, FC reached rank {rank}"); + _chatGui.Print($"Pausing Deliveroo, your FC reached rank {rank}."); + return; + } + } + } + internal CharacterConfiguration? CharacterConfiguration { get; set; } @@ -305,6 +332,7 @@ public sealed partial class DeliverooPlugin : IDalamudPlugin _addonLifecycle.UnregisterListener(AddonEvent.PostSetup, "SelectString", SelectStringPostSetup); _commandManager.RemoveHandler("/deliveroo"); + _chatGui.ChatMessage -= ChatMessage; _clientState.Logout -= Logout; _clientState.Login -= Login; _pluginInterface.UiBuilder.OpenConfigUi -= _configWindow.Toggle; diff --git a/Deliveroo/GameData/GameStrings.cs b/Deliveroo/GameData/GameStrings.cs index 007c777..3a4a1ad 100644 --- a/Deliveroo/GameData/GameStrings.cs +++ b/Deliveroo/GameData/GameStrings.cs @@ -1,5 +1,6 @@ using System; using System.Text.RegularExpressions; +using Dalamud.Game.Text; using Dalamud.Plugin.Services; using LLib; using Lumina.Excel; @@ -13,13 +14,20 @@ internal sealed class GameStrings public GameStrings(IDataManager dataManager, IPluginLog pluginLog) { UndertakeSupplyAndProvisioningMission = - dataManager.GetDialogue("TEXT_COMDEFGRANDCOMPANYOFFICER_00073_A4_002", pluginLog); + dataManager.GetString("TEXT_COMDEFGRANDCOMPANYOFFICER_00073_A4_002", pluginLog) + ?? throw new Exception($"Unable to resolve {nameof(UndertakeSupplyAndProvisioningMission)}"); ClosePersonnelOfficerTalk = - dataManager.GetDialogue("TEXT_COMDEFGRANDCOMPANYOFFICER_00073_A4_004", pluginLog); + dataManager.GetString("TEXT_COMDEFGRANDCOMPANYOFFICER_00073_A4_004", pluginLog) + ?? throw new Exception($"Unable to resolve {nameof(ClosePersonnelOfficerTalk)}"); ExchangeItems = dataManager.GetRegex(4928, addon => addon.Text, pluginLog) ?? throw new Exception($"Unable to resolve {nameof(ExchangeItems)}"); TradeHighQualityItem = dataManager.GetString(102434, addon => addon.Text, pluginLog) ?? throw new Exception($"Unable to resolve {nameof(TradeHighQualityItem)}"); + + var rankUpFc = dataManager.GetExcelSheet()!.GetRow(3123)!; + RankUpFc = rankUpFc.GetRegex(logMessage => logMessage.Text, pluginLog) + ?? throw new Exception($"Unable to resolve {nameof(RankUpFc)}"); + RankUpFcType = (XivChatType)rankUpFc.LogKind; } @@ -27,6 +35,8 @@ internal sealed class GameStrings public string ClosePersonnelOfficerTalk { get; } public Regex ExchangeItems { get; } public string TradeHighQualityItem { get; } + public Regex RankUpFc { get; } + public XivChatType RankUpFcType { get; } [Sheet("custom/000/ComDefGrandCompanyOfficer_00073")] private class ComDefGrandCompanyOfficer : QuestDialogueText diff --git a/Deliveroo/Windows/ConfigWindow.cs b/Deliveroo/Windows/ConfigWindow.cs index a6a2fa3..48468f7 100644 --- a/Deliveroo/Windows/ConfigWindow.cs +++ b/Deliveroo/Windows/ConfigWindow.cs @@ -291,6 +291,18 @@ internal sealed class ConfigWindow : Window } ImGui.EndDisabled(); + ImGui.SetNextItemWidth(ImGuiHelpers.GlobalScale * 120); + List<(int Rank, string Name)> rankUpComboValues = Enumerable.Range(1, 30) + .Select(x => x == 1 ? (0, "---") : (x, $"Rank {x}")) + .ToList(); + int pauseAtRank = Math.Max(rankUpComboValues.FindIndex(x => x.Rank == _configuration.PauseAtRank), 0); + if (ImGui.Combo("Pause when reaching selected FC Rank", ref pauseAtRank, rankUpComboValues.Select(x => x.Name).ToArray(), + rankUpComboValues.Count)) + { + _configuration.PauseAtRank = rankUpComboValues[pauseAtRank].Rank; + Save(); + } + ImGui.EndTabItem(); } } diff --git a/LLib b/LLib index 2f6ef35..8944883 160000 --- a/LLib +++ b/LLib @@ -1 +1 @@ -Subproject commit 2f6ef354c401a9f1bb9b807327acad7e98662a2e +Subproject commit 89448838a1295041293bbd5dd69501ad934bdf03