diff --git a/Deliveroo/Configuration.cs b/Deliveroo/Configuration.cs index 8678367..31dd5af 100644 --- a/Deliveroo/Configuration.cs +++ b/Deliveroo/Configuration.cs @@ -1,5 +1,6 @@ using System.Collections.Generic; using Dalamud.Configuration; +using Deliveroo.GameData; namespace Deliveroo; @@ -19,4 +20,14 @@ internal sealed class Configuration : IPluginConfiguration public int Limit { get; set; } } + public bool AddVentureIfNoItemToPurchaseSelected() + { + if (ItemsAvailableForPurchase.Count == 0) + { + ItemsAvailableForPurchase.Add(ItemIds.Venture); + return true; + } + + return false; + } } diff --git a/Deliveroo/DeliverooPlugin.cs b/Deliveroo/DeliverooPlugin.cs index c901834..ad0d33f 100644 --- a/Deliveroo/DeliverooPlugin.cs +++ b/Deliveroo/DeliverooPlugin.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.IO; using System.Linq; using Dalamud.Data; using Dalamud.Game; @@ -19,7 +18,6 @@ using Deliveroo.Windows; using FFXIVClientStructs.FFXIV.Client.UI; using FFXIVClientStructs.FFXIV.Component.GUI; using Lumina.Excel.GeneratedSheets; -using Newtonsoft.Json; using Condition = Dalamud.Game.ClientState.Conditions.Condition; namespace Deliveroo; @@ -93,6 +91,9 @@ public sealed partial class DeliverooPlugin : IDalamudPlugin if (_clientState.IsLoggedIn) Login(this, EventArgs.Empty); + + if (_configuration.AddVentureIfNoItemToPurchaseSelected()) + _pluginInterface.SavePluginConfig(_configuration); } public string Name => "Deliveroo"; diff --git a/Deliveroo/Windows/ConfigWindow.cs b/Deliveroo/Windows/ConfigWindow.cs index c51de0c..e44d081 100644 --- a/Deliveroo/Windows/ConfigWindow.cs +++ b/Deliveroo/Windows/ConfigWindow.cs @@ -52,11 +52,8 @@ internal sealed class ConfigWindow : Window public override void Draw() { - if (_configuration.ItemsAvailableForPurchase.Count == 0) - { - _configuration.ItemsAvailableForPurchase.Add(ItemIds.Venture); + if (_configuration.AddVentureIfNoItemToPurchaseSelected()) Save(); - } if (ImGui.BeginTabBar("DeliverooConfigTabs")) {