Compare commits

..

2 Commits
v5.7 ... master

Author SHA1 Message Date
a992a841e8
Show when items have unobtained folklore books in 'Locked Items' tab 2024-10-28 22:43:19 +01:00
23e29c4cc6
Fix 2024-10-28 21:33:32 +01:00
7 changed files with 112 additions and 5 deletions

View File

@ -1,6 +1,6 @@
<Project Sdk="Dalamud.NET.Sdk/9.0.2"> <Project Sdk="Dalamud.NET.Sdk/9.0.2">
<PropertyGroup> <PropertyGroup>
<Version>5.7</Version> <Version>5.8</Version>
<OutputPath>dist</OutputPath> <OutputPath>dist</OutputPath>
</PropertyGroup> </PropertyGroup>

View File

@ -44,6 +44,16 @@ partial class AutoRetainerControlPlugin
save = true; save = true;
} }
if (_clientState.LocalContentId == registeredCharacterId)
{
var unlockedFolkloreBooks = _gameCache.FolkloreBooks.Values.Where(x => x.IsUnlocked()).Select(x => x.ItemId).ToHashSet();
if (character.UnlockedFolkloreBooks != unlockedFolkloreBooks)
{
character.UnlockedFolkloreBooks = unlockedFolkloreBooks;
save = true;
}
}
// remove retainers without name // remove retainers without name
save |= character.Retainers.RemoveAll(x => string.IsNullOrEmpty(x.Name)) > 0; save |= character.Retainers.RemoveAll(x => string.IsNullOrEmpty(x.Name)) > 0;

View File

@ -81,6 +81,7 @@ internal sealed class Configuration : IPluginConfiguration
public List<RetainerConfiguration> Retainers { get; set; } = new(); public List<RetainerConfiguration> Retainers { get; set; } = new();
public HashSet<uint> GatheredItems { get; set; } = new(); public HashSet<uint> GatheredItems { get; set; } = new();
public HashSet<uint> UnlockedFolkloreBooks { get; set; } = new();
public override string ToString() => $"{CharacterName} @ {WorldName}"; public override string ToString() => $"{CharacterName} @ {WorldName}";
} }

View File

@ -0,0 +1,18 @@
using System.Collections.Generic;
using FFXIVClientStructs.FFXIV.Client.Game.UI;
namespace ARControl.GameData;
internal sealed class FolkloreBook
{
public required uint ItemId { get; init; }
public required string Name { get; init; }
public required IReadOnlyList<ushort> GatheringSubCategories { get; init; }
public List<uint> GatheringItemIds { get; } = [];
public ushort TomeId { get; set; }
public unsafe bool IsUnlocked()
{
return PlayerState.Instance()->IsFolkloreBookUnlocked(TomeId);
}
}

View File

@ -22,9 +22,74 @@ internal sealed class GameCache
.OrderBy(x => x.Name) .OrderBy(x => x.Name)
.ToList() .ToList()
.AsReadOnly(); .AsReadOnly();
FolkloreBooks = dataManager.GetExcelSheet<GatheringSubCategory>()!
.Where(x => x.RowId > 0)
.Where(x => x.Item.Row != 0)
.Select(x => new
{
x.RowId,
ItemId = x.Item.Row,
ItemName = x.Item.Value!.Name.ToString()
})
.GroupBy(x => (x.ItemId, x.ItemName))
.Select(x =>
new FolkloreBook
{
ItemId = x.Key.ItemId,
Name = x.Key.ItemName,
GatheringSubCategories = x.Select(y => (ushort)y.RowId).ToList(),
})
.ToDictionary(x => x.ItemId, x => x);
var gatheringNodes = dataManager.GetExcelSheet<GatheringPointBase>()!
.Where(x => x.RowId > 0 && x.GatheringType.Row <= 3)
.Select(x =>
new
{
GatheringPointBaseId = x.RowId,
GatheringPoint =
dataManager.GetExcelSheet<GatheringPoint>()!.FirstOrDefault(y =>
y.GatheringPointBase.Row == x.RowId),
Items = x.Item.Where(y => y > 0).ToList()
})
.Where(x => x.GatheringPoint != null)
.Select(x =>
new
{
x.GatheringPointBaseId,
CategoryId = (ushort)x.GatheringPoint!.GatheringSubCategory.Row,
x.Items,
})
.ToList();
var itemsWithoutTomes = gatheringNodes
.Where(x => !FolkloreBooks.Values.Any(y => y.GatheringSubCategories.Contains(x.CategoryId)))
.SelectMany(x => x.Items)
.ToList();
var itemsWithTomes = gatheringNodes
.SelectMany(x => x.Items
.Where(y => !itemsWithoutTomes.Contains(y))
.Select(
y =>
new
{
x.CategoryId,
ItemId = (uint)y
}))
.GroupBy(x => x.CategoryId)
.ToDictionary(x => x.Key, x => x.Select(y => y.ItemId).ToList());
foreach (var book in FolkloreBooks.Values)
{
book.TomeId = dataManager.GetExcelSheet<Item>()!.GetRow(book.ItemId)!.ItemAction.Value!.Data[0];
foreach (var category in book.GatheringSubCategories)
{
if (itemsWithTomes.TryGetValue(category, out var itemsInCategory))
book.GatheringItemIds.AddRange(itemsInCategory);
}
}
} }
public IReadOnlyDictionary<uint, string> Jobs { get; } public IReadOnlyDictionary<uint, string> Jobs { get; }
public IReadOnlyList<Venture> Ventures { get; } public IReadOnlyList<Venture> Ventures { get; }
public IReadOnlyList<ItemToGather> ItemsToGather { get; } public IReadOnlyList<ItemToGather> ItemsToGather { get; }
public Dictionary<uint, FolkloreBook> FolkloreBooks { get; }
} }

View File

@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Numerics; using System.Numerics;
using ARControl.GameData; using ARControl.GameData;
using Dalamud.Game.Text;
using Dalamud.Interface; using Dalamud.Interface;
using Dalamud.Interface.Colors; using Dalamud.Interface.Colors;
using Dalamud.Interface.Components; using Dalamud.Interface.Components;
@ -114,10 +115,16 @@ internal sealed class LockedItemsTab : ITab
var color = ch.Items[item.ItemId]; var color = ch.Items[item.ItemId];
if (color != ColorGrey) if (color != ColorGrey)
{ {
string itemName = item.GatheredItem.Name;
var folkloreBook = _gameCache.FolkloreBooks.Values.FirstOrDefault(x =>
x.GatheringItemIds.Contains(item.GatheredItem.GatheredItemId));
if (folkloreBook != null && !ch.Character.UnlockedFolkloreBooks.Contains(folkloreBook.ItemId))
itemName += $" ({SeIconChar.Prohibited.ToIconString()} {folkloreBook.Name})";
ImGui.PushStyleColor(ImGuiCol.Text, color); ImGui.PushStyleColor(ImGuiCol.Text, color);
if (currentCharacter && color == ColorRed) if (currentCharacter && color == ColorRed)
{ {
ImGui.Selectable(item.GatheredItem.Name); ImGui.Selectable(itemName);
if (ImGui.IsItemClicked(ImGuiMouseButton.Left)) if (ImGui.IsItemClicked(ImGuiMouseButton.Left))
{ {
uint classJob = _clientState.LocalPlayer!.ClassJob.Id; uint classJob = _clientState.LocalPlayer!.ClassJob.Id;
@ -133,7 +140,7 @@ internal sealed class LockedItemsTab : ITab
} }
else else
{ {
ImGui.Text(item.GatheredItem.Name); ImGui.Text(itemName);
} }
ImGui.PopStyleColor(); ImGui.PopStyleColor();
@ -149,6 +156,8 @@ internal sealed class LockedItemsTab : ITab
foreach (var item in itemsToCheck.Where(x => foreach (var item in itemsToCheck.Where(x =>
charactersToCheck.Any(y => y.ToCheck(onlyShowMissing).ContainsKey(x.ItemId)))) charactersToCheck.Any(y => y.ToCheck(onlyShowMissing).ContainsKey(x.ItemId))))
{ {
var folkloreBook = _gameCache.FolkloreBooks.Values.FirstOrDefault(x =>
x.GatheringItemIds.Contains(item.GatheredItem.GatheredItemId));
if (ImGui.CollapsingHeader($"{item.GatheredItem.Name}##Gathered{item.GatheredItem.ItemId}")) if (ImGui.CollapsingHeader($"{item.GatheredItem.Name}##Gathered{item.GatheredItem.ItemId}"))
{ {
ImGui.Indent(_configWindow.MainIndentSize + ImGui.GetStyle().FramePadding.X); ImGui.Indent(_configWindow.MainIndentSize + ImGui.GetStyle().FramePadding.X);
@ -171,8 +180,12 @@ internal sealed class LockedItemsTab : ITab
ImGui.PopFont(); ImGui.PopFont();
} }
string characterName = ch.Character.ToString();
if (folkloreBook != null && !ch.Character.UnlockedFolkloreBooks.Contains(folkloreBook.ItemId))
characterName += $" ({SeIconChar.Prohibited.ToIconString()} {folkloreBook.Name})";
ImGui.PushStyleColor(ImGuiCol.Text, color); ImGui.PushStyleColor(ImGuiCol.Text, color);
ImGui.TextUnformatted(ch.Character.ToString()); ImGui.TextUnformatted(characterName);
ImGui.PopStyleColor(); ImGui.PopStyleColor();
} }
} }

View File

@ -294,7 +294,7 @@ internal sealed class VentureListTab : ITab
ImGui.GetWindowDrawList().AddRect(topLeft, bottomRight, ImGui.GetColorU32(ImGuiColors.DalamudGrey), 3f, ImGui.GetWindowDrawList().AddRect(topLeft, bottomRight, ImGui.GetColorU32(ImGuiColors.DalamudGrey), 3f,
ImDrawFlags.RoundCornersAll); ImDrawFlags.RoundCornersAll);
int newIndex = itemPositions.IndexOf(x => ImGui.IsMouseHoveringRect(x.TopLeft, x.BottomRight, true)); int newIndex = itemPositions.FindIndex(x => ImGui.IsMouseHoveringRect(x.TopLeft, x.BottomRight, true));
if (newIndex >= 0 && oldIndex != newIndex) if (newIndex >= 0 && oldIndex != newIndex)
{ {
itemToAdd = list.Items.Single(x => x.InternalId == _draggedItem.Value.Item2); itemToAdd = list.Items.Single(x => x.InternalId == _draggedItem.Value.Item2);