2023-10-04 22:57:44 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
2023-10-01 20:50:21 +00:00
|
|
|
|
using Dalamud.Configuration;
|
2024-05-11 12:02:25 +00:00
|
|
|
|
using LLib.ImGui;
|
2023-10-04 22:57:44 +00:00
|
|
|
|
using Workshoppa.GameData;
|
2023-10-01 20:50:21 +00:00
|
|
|
|
|
|
|
|
|
namespace Workshoppa;
|
|
|
|
|
|
|
|
|
|
internal sealed class Configuration : IPluginConfiguration
|
|
|
|
|
{
|
|
|
|
|
public int Version { get; set; } = 1;
|
|
|
|
|
|
2024-03-20 18:52:54 +00:00
|
|
|
|
public CurrentItem? CurrentlyCraftedItem { get; set; }
|
2023-10-13 20:08:22 +00:00
|
|
|
|
public List<QueuedItem> ItemQueue { get; set; } = new();
|
|
|
|
|
public bool EnableRepairKitCalculator { get; set; } = true;
|
2023-10-24 22:19:42 +00:00
|
|
|
|
public bool EnableCeruleumTankCalculator { get; set; } = true;
|
2024-01-19 08:41:04 +00:00
|
|
|
|
public List<Preset> Presets { get; set; } = new();
|
2023-10-01 20:50:21 +00:00
|
|
|
|
|
2024-05-11 12:02:25 +00:00
|
|
|
|
public WindowConfig MainWindowConfig { get; } = new();
|
|
|
|
|
public WindowConfig ConfigWindowConfig { get; } = new();
|
|
|
|
|
|
2023-10-01 20:50:21 +00:00
|
|
|
|
internal sealed class QueuedItem
|
|
|
|
|
{
|
|
|
|
|
public uint WorkshopItemId { get; set; }
|
|
|
|
|
public int Quantity { get; set; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
internal sealed class CurrentItem
|
|
|
|
|
{
|
|
|
|
|
public uint WorkshopItemId { get; set; }
|
|
|
|
|
public bool StartedCrafting { get; set; }
|
2023-10-04 22:57:44 +00:00
|
|
|
|
|
2024-03-20 18:52:54 +00:00
|
|
|
|
public uint PhasesComplete { get; set; }
|
2023-10-04 22:57:44 +00:00
|
|
|
|
public List<PhaseItem> ContributedItemsInCurrentPhase { get; set; } = new();
|
|
|
|
|
|
|
|
|
|
public bool UpdateFromCraftState(CraftState craftState)
|
|
|
|
|
{
|
|
|
|
|
bool changed = false;
|
|
|
|
|
if (PhasesComplete != craftState.StepsComplete)
|
|
|
|
|
{
|
|
|
|
|
PhasesComplete = craftState.StepsComplete;
|
|
|
|
|
changed = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (ContributedItemsInCurrentPhase.Count != craftState.Items.Count)
|
|
|
|
|
{
|
|
|
|
|
ContributedItemsInCurrentPhase = craftState.Items.Select(x => new PhaseItem
|
|
|
|
|
{
|
|
|
|
|
ItemId = x.ItemId,
|
|
|
|
|
QuantityComplete = x.QuantityComplete,
|
|
|
|
|
}).ToList();
|
|
|
|
|
changed = true;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
for (int i = 0; i < ContributedItemsInCurrentPhase.Count; ++i)
|
|
|
|
|
{
|
|
|
|
|
var contributedItem = ContributedItemsInCurrentPhase[i];
|
|
|
|
|
var craftItem = craftState.Items[i];
|
|
|
|
|
if (contributedItem.ItemId != craftItem.ItemId)
|
|
|
|
|
{
|
|
|
|
|
contributedItem.ItemId = craftItem.ItemId;
|
|
|
|
|
changed = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (contributedItem.QuantityComplete != craftItem.QuantityComplete)
|
|
|
|
|
{
|
|
|
|
|
contributedItem.QuantityComplete = craftItem.QuantityComplete;
|
|
|
|
|
changed = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return changed;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
internal sealed class PhaseItem
|
|
|
|
|
{
|
|
|
|
|
public uint ItemId { get; set; }
|
|
|
|
|
public uint QuantityComplete { get; set; }
|
2023-10-01 20:50:21 +00:00
|
|
|
|
}
|
2024-01-19 08:41:04 +00:00
|
|
|
|
|
|
|
|
|
internal sealed class Preset
|
|
|
|
|
{
|
|
|
|
|
public required Guid Id { get; set; }
|
|
|
|
|
public required string Name { get; set; }
|
|
|
|
|
public List<QueuedItem> ItemQueue { get; set; } = new();
|
|
|
|
|
}
|
2023-10-01 20:50:21 +00:00
|
|
|
|
}
|