Add an option to pause delivery when reaching a certain FC rank

This commit is contained in:
Liza 2023-10-21 12:49:47 +02:00
parent fc31d8041c
commit 3931330a36
Signed by: liza
GPG Key ID: 7199F8D727D55F67
6 changed files with 55 additions and 4 deletions

View File

@ -14,6 +14,7 @@ internal sealed class Configuration : IPluginConfiguration
public int ReservedSealCount { get; set; } public int ReservedSealCount { get; set; }
public bool ReserveDifferentSealCountAtMaxRank { get; set; } public bool ReserveDifferentSealCountAtMaxRank { get; set; }
public int ReservedSealCountAtMaxRank { get; set; } public int ReservedSealCountAtMaxRank { get; set; }
public int PauseAtRank { get; set; }
/// <summary> /// <summary>
/// A config-only setting, not exposed in the UI. /// A config-only setting, not exposed in the UI.

View File

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<TargetFramework>net7.0-windows</TargetFramework> <TargetFramework>net7.0-windows</TargetFramework>
<Version>2.12</Version> <Version>2.13</Version>
<LangVersion>11.0</LangVersion> <LangVersion>11.0</LangVersion>
<Nullable>enable</Nullable> <Nullable>enable</Nullable>
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies> <CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>

View File

@ -6,6 +6,8 @@ using Dalamud.Game.ClientState.Conditions;
using Dalamud.Game.ClientState.Objects; using Dalamud.Game.ClientState.Objects;
using Dalamud.Game.ClientState.Objects.Types; using Dalamud.Game.ClientState.Objects.Types;
using Dalamud.Game.Command; using Dalamud.Game.Command;
using Dalamud.Game.Text;
using Dalamud.Game.Text.SeStringHandling;
using Dalamud.Interface.Windowing; using Dalamud.Interface.Windowing;
using Dalamud.Plugin; using Dalamud.Plugin;
using Dalamud.Plugin.Services; using Dalamud.Plugin.Services;
@ -87,6 +89,7 @@ public sealed partial class DeliverooPlugin : IDalamudPlugin
_pluginInterface.UiBuilder.OpenConfigUi += _configWindow.Toggle; _pluginInterface.UiBuilder.OpenConfigUi += _configWindow.Toggle;
_clientState.Login += Login; _clientState.Login += Login;
_clientState.Logout += Logout; _clientState.Logout += Logout;
_chatGui.ChatMessage += ChatMessage;
_commandManager.AddHandler("/deliveroo", new CommandInfo(ProcessCommand) _commandManager.AddHandler("/deliveroo", new CommandInfo(ProcessCommand)
{ {
HelpMessage = "Open the configuration" HelpMessage = "Open the configuration"
@ -102,6 +105,30 @@ public sealed partial class DeliverooPlugin : IDalamudPlugin
_addonLifecycle.RegisterListener(AddonEvent.PostSetup, "SelectYesno", SelectYesNoPostSetup); _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; } internal CharacterConfiguration? CharacterConfiguration { get; set; }
@ -305,6 +332,7 @@ public sealed partial class DeliverooPlugin : IDalamudPlugin
_addonLifecycle.UnregisterListener(AddonEvent.PostSetup, "SelectString", SelectStringPostSetup); _addonLifecycle.UnregisterListener(AddonEvent.PostSetup, "SelectString", SelectStringPostSetup);
_commandManager.RemoveHandler("/deliveroo"); _commandManager.RemoveHandler("/deliveroo");
_chatGui.ChatMessage -= ChatMessage;
_clientState.Logout -= Logout; _clientState.Logout -= Logout;
_clientState.Login -= Login; _clientState.Login -= Login;
_pluginInterface.UiBuilder.OpenConfigUi -= _configWindow.Toggle; _pluginInterface.UiBuilder.OpenConfigUi -= _configWindow.Toggle;

View File

@ -1,5 +1,6 @@
using System; using System;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using Dalamud.Game.Text;
using Dalamud.Plugin.Services; using Dalamud.Plugin.Services;
using LLib; using LLib;
using Lumina.Excel; using Lumina.Excel;
@ -13,13 +14,20 @@ internal sealed class GameStrings
public GameStrings(IDataManager dataManager, IPluginLog pluginLog) public GameStrings(IDataManager dataManager, IPluginLog pluginLog)
{ {
UndertakeSupplyAndProvisioningMission = UndertakeSupplyAndProvisioningMission =
dataManager.GetDialogue<ComDefGrandCompanyOfficer>("TEXT_COMDEFGRANDCOMPANYOFFICER_00073_A4_002", pluginLog); dataManager.GetString<ComDefGrandCompanyOfficer>("TEXT_COMDEFGRANDCOMPANYOFFICER_00073_A4_002", pluginLog)
?? throw new Exception($"Unable to resolve {nameof(UndertakeSupplyAndProvisioningMission)}");
ClosePersonnelOfficerTalk = ClosePersonnelOfficerTalk =
dataManager.GetDialogue<ComDefGrandCompanyOfficer>("TEXT_COMDEFGRANDCOMPANYOFFICER_00073_A4_004", pluginLog); dataManager.GetString<ComDefGrandCompanyOfficer>("TEXT_COMDEFGRANDCOMPANYOFFICER_00073_A4_004", pluginLog)
?? throw new Exception($"Unable to resolve {nameof(ClosePersonnelOfficerTalk)}");
ExchangeItems = dataManager.GetRegex<Addon>(4928, addon => addon.Text, pluginLog) ExchangeItems = dataManager.GetRegex<Addon>(4928, addon => addon.Text, pluginLog)
?? throw new Exception($"Unable to resolve {nameof(ExchangeItems)}"); ?? throw new Exception($"Unable to resolve {nameof(ExchangeItems)}");
TradeHighQualityItem = dataManager.GetString<Addon>(102434, addon => addon.Text, pluginLog) TradeHighQualityItem = dataManager.GetString<Addon>(102434, addon => addon.Text, pluginLog)
?? throw new Exception($"Unable to resolve {nameof(TradeHighQualityItem)}"); ?? throw new Exception($"Unable to resolve {nameof(TradeHighQualityItem)}");
var rankUpFc = dataManager.GetExcelSheet<LogMessage>()!.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 string ClosePersonnelOfficerTalk { get; }
public Regex ExchangeItems { get; } public Regex ExchangeItems { get; }
public string TradeHighQualityItem { get; } public string TradeHighQualityItem { get; }
public Regex RankUpFc { get; }
public XivChatType RankUpFcType { get; }
[Sheet("custom/000/ComDefGrandCompanyOfficer_00073")] [Sheet("custom/000/ComDefGrandCompanyOfficer_00073")]
private class ComDefGrandCompanyOfficer : QuestDialogueText private class ComDefGrandCompanyOfficer : QuestDialogueText

View File

@ -291,6 +291,18 @@ internal sealed class ConfigWindow : Window
} }
ImGui.EndDisabled(); 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(); ImGui.EndTabItem();
} }
} }

2
LLib

@ -1 +1 @@
Subproject commit 2f6ef354c401a9f1bb9b807327acad7e98662a2e Subproject commit 89448838a1295041293bbd5dd69501ad934bdf03