diff --git a/Deliveroo/Configuration.cs b/Deliveroo/Configuration.cs index 764d830..1b8e888 100644 --- a/Deliveroo/Configuration.cs +++ b/Deliveroo/Configuration.cs @@ -15,6 +15,7 @@ internal sealed class Configuration : IPluginConfiguration public bool ReserveDifferentSealCountAtMaxRank { get; set; } public int ReservedSealCountAtMaxRank { get; set; } public int PauseAtRank { get; set; } + public EBehaviorOnOtherWorld BehaviorOnOtherWorld { get; set; } = EBehaviorOnOtherWorld.Warning; /// /// A config-only setting, not exposed in the UI. @@ -40,4 +41,11 @@ internal sealed class Configuration : IPluginConfiguration return false; } + + public enum EBehaviorOnOtherWorld + { + None, + Warning, + DisableTurnIn, + } } diff --git a/Deliveroo/DeliverooPlugin.cs b/Deliveroo/DeliverooPlugin.cs index 3978a18..b294860 100644 --- a/Deliveroo/DeliverooPlugin.cs +++ b/Deliveroo/DeliverooPlugin.cs @@ -82,7 +82,7 @@ public sealed partial class DeliverooPlugin : IDalamudPlugin _iconCache = new IconCache(textureProvider); _configWindow = new ConfigWindow(_pluginInterface, this, _configuration, _gcRewardsCache, _clientState, _pluginLog, _iconCache); _windowSystem.AddWindow(_configWindow); - _turnInWindow = new TurnInWindow(this, _pluginInterface, _configuration, _condition, _gcRewardsCache, _configWindow, _iconCache); + _turnInWindow = new TurnInWindow(this, _pluginInterface, _configuration, _condition, _clientState, _gcRewardsCache, _configWindow, _iconCache); _windowSystem.AddWindow(_turnInWindow); _sealCaps = dataManager.GetExcelSheet()!.Where(x => x.RowId > 0) .ToDictionary(x => x.RowId, x => x.MaxSeals); diff --git a/Deliveroo/Windows/ConfigWindow.cs b/Deliveroo/Windows/ConfigWindow.cs index 0159464..4a732ae 100644 --- a/Deliveroo/Windows/ConfigWindow.cs +++ b/Deliveroo/Windows/ConfigWindow.cs @@ -170,7 +170,9 @@ internal sealed class ConfigWindow : LImGui.LWindow ImGui.SetCursorPosY(ImGui.GetCursorPosY() + 3); } - bool addThis = ImGui.Selectable($"{item.Name}{(item.Limited ? $" {SeIconChar.Hyadelyn.ToIconString()}" : "")}##SelectVenture{item.IconId}"); + bool addThis = + ImGui.Selectable( + $"{item.Name}{(item.Limited ? $" {SeIconChar.Hyadelyn.ToIconString()}" : "")}##SelectVenture{item.IconId}"); if (addThis || addFirst) { _configuration.ItemsAvailableForPurchase.Add(item.ItemId); @@ -244,7 +246,8 @@ internal sealed class ConfigWindow : LImGui.LWindow } ImGui.SameLine(); - ImGuiComponents.HelpMarker("The default filter for all characters is 'Hide Gear Set Items', but you may want to override this to hide all Armoury Chest items (regardless of whether they're part of a gear set) e.g. for your main character."); + ImGuiComponents.HelpMarker( + "The default filter for all characters is 'Hide Gear Set Items', but you may want to override this to hide all Armoury Chest items (regardless of whether they're part of a gear set) e.g. for your main character."); bool ignoreMinimumSealsToKeep = charConfiguration.IgnoreMinimumSealsToKeep; if (ImGui.Checkbox("Ignore 'Minimum Seals to keep' setting", ref ignoreMinimumSealsToKeep)) @@ -254,7 +257,8 @@ internal sealed class ConfigWindow : LImGui.LWindow } ImGui.SameLine(); - ImGuiComponents.HelpMarker("When enabled, all GC seals will be spent. This is effectively the same as setting 'Minimum Seals to keep' to 0."); + ImGuiComponents.HelpMarker( + "When enabled, all GC seals will be spent. This is effectively the same as setting 'Minimum Seals to keep' to 0."); ImGui.EndDisabled(); ImGui.Spacing(); @@ -309,7 +313,8 @@ internal sealed class ConfigWindow : LImGui.LWindow int reservedSealCount = _configuration.ReservedSealCount; if (ImGui.InputInt("Minimum Seals to keep (e.g. for Squadron Missions)", ref reservedSealCount, 1000)) { - _configuration.ReservedSealCount = Math.Max(0, Math.Min((int)_plugin.GetMaxSealCap(), reservedSealCount)); + _configuration.ReservedSealCount = + Math.Max(0, Math.Min((int)_plugin.GetMaxSealCap(), reservedSealCount)); Save(); } @@ -328,11 +333,14 @@ internal sealed class ConfigWindow : LImGui.LWindow int reservedSealCountAtMaxRank = _configuration.ReservedSealCountAtMaxRank; if (ImGui.InputInt("Minimum seals to keep at max rank", ref reservedSealCountAtMaxRank)) { - _configuration.ReservedSealCountAtMaxRank = Math.Max(0, Math.Min((int)_plugin.GetMaxSealCap(), reservedSealCountAtMaxRank)); + _configuration.ReservedSealCountAtMaxRank = Math.Max(0, + Math.Min((int)_plugin.GetMaxSealCap(), reservedSealCountAtMaxRank)); Save(); } + ImGui.Unindent(); } + ImGui.EndDisabled(); ImGui.SetNextItemWidth(ImGuiHelpers.GlobalScale * 120); @@ -340,13 +348,24 @@ internal sealed class ConfigWindow : LImGui.LWindow .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(), + 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.SetNextItemWidth(ImGuiHelpers.GlobalScale * 120); + string[] behaviorOnOtherWorldNames = { "---", "Show Warning", "Disable Turn-In" }; + int behaviorOnOtherWorld = (int)_configuration.BehaviorOnOtherWorld; + if (ImGui.Combo("Behavior when not on Home World", ref behaviorOnOtherWorld, + behaviorOnOtherWorldNames, behaviorOnOtherWorldNames.Length)) + { + _configuration.BehaviorOnOtherWorld = (Configuration.EBehaviorOnOtherWorld)behaviorOnOtherWorld; + Save(); + } + ImGui.EndTabItem(); } } diff --git a/Deliveroo/Windows/TurnInWindow.cs b/Deliveroo/Windows/TurnInWindow.cs index 99b5a2b..76ee495 100644 --- a/Deliveroo/Windows/TurnInWindow.cs +++ b/Deliveroo/Windows/TurnInWindow.cs @@ -44,17 +44,20 @@ internal sealed class TurnInWindow : LImGui.LWindow private readonly DalamudPluginInterface _pluginInterface; private readonly Configuration _configuration; private readonly ICondition _condition; + private readonly IClientState _clientState; private readonly GcRewardsCache _gcRewardsCache; private readonly IconCache _iconCache; public TurnInWindow(DeliverooPlugin plugin, DalamudPluginInterface pluginInterface, Configuration configuration, - ICondition condition, GcRewardsCache gcRewardsCache, ConfigWindow configWindow, IconCache iconCache) + ICondition condition, IClientState clientState, GcRewardsCache gcRewardsCache, ConfigWindow configWindow, + IconCache iconCache) : base("GC Delivery###DeliverooTurnIn") { _plugin = plugin; _pluginInterface = pluginInterface; _configuration = configuration; _condition = condition; + _clientState = clientState; _gcRewardsCache = gcRewardsCache; _iconCache = iconCache; @@ -93,6 +96,10 @@ internal sealed class TurnInWindow : LImGui.LWindow private bool UseCharacterSpecificItemsToPurchase => _plugin.CharacterConfiguration is { OverrideItemsToPurchase: true }; + private bool IsOnHomeWorld => + _clientState.LocalPlayer == null || + _clientState.LocalPlayer.HomeWorld.Id == _clientState.LocalPlayer.CurrentWorld.Id; + private IItemsToPurchase ItemsWrapper => UseCharacterSpecificItemsToPurchase ? new CharacterSpecificItemsToPurchase(_plugin.CharacterConfiguration!, _pluginInterface) : new GlobalItemsToPurchase(_configuration, _pluginInterface); @@ -146,6 +153,12 @@ internal sealed class TurnInWindow : LImGui.LWindow ImGui.TextColored(ImGuiColors.DalamudRed, "You do not have the required rank for Expert Delivery."); return; } + else if (_configuration.BehaviorOnOtherWorld == Configuration.EBehaviorOnOtherWorld.DisableTurnIn && !IsOnHomeWorld) + { + State = false; + ImGui.TextColored(ImGuiColors.DalamudRed, "You are not on your home world."); + return; + } bool state = State; if (ImGui.Checkbox("Handle GC turn ins/exchange automatically", ref state)) @@ -160,6 +173,12 @@ internal sealed class TurnInWindow : LImGui.LWindow } else { + if (_configuration.BehaviorOnOtherWorld == Configuration.EBehaviorOnOtherWorld.Warning && !IsOnHomeWorld) + { + ImGui.TextColored(ImGuiColors.DalamudRed, + "Turn-In disabled, you are not on your home world and will not earn FC points."); + } + if (Multiplier == 1m) { ImGui.TextColored(ImGuiColors.DalamudYellow, "You do not have an active seal buff.");