Fix default config not having venture saved until you open the config window

This commit is contained in:
Liza 2023-09-28 10:12:26 +02:00
parent b4606c34d3
commit 64a0843b7f
Signed by: liza
GPG Key ID: 7199F8D727D55F67
3 changed files with 15 additions and 6 deletions

View File

@ -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;
}
}

View File

@ -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";

View File

@ -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"))
{