Skip to content

Commit

Permalink
The sample lists did not have any columns by default
Browse files Browse the repository at this point in the history
Critical-Impact committed Dec 4, 2024
1 parent 9d3a756 commit b21463a
Showing 10 changed files with 36 additions and 23 deletions.
12 changes: 8 additions & 4 deletions InventoryTools/InventoryToolsPlugin.cs
Original file line number Diff line number Diff line change
@@ -509,22 +509,26 @@ public override void PreBuild(IHostBuilder hostBuilder)

builder.Register<Func<ItemInfoType, GenericHasSourceFilter>>(c =>
{
return type => c.Resolve<GenericHasSourceFilter>(new NamedParameter("itemType", type));
var context = c.Resolve<IComponentContext>();
return type => context.Resolve<GenericHasSourceFilter>(new NamedParameter("itemType", type));
});

builder.Register<Func<ItemInfoType, GenericHasUseFilter>>(c =>
{
return type => c.Resolve<GenericHasUseFilter>(new NamedParameter("itemType", type));
var context = c.Resolve<IComponentContext>();
return type => context.Resolve<GenericHasUseFilter>(new NamedParameter("itemType", type));
});

builder.Register<Func<ItemInfoRenderCategory, GenericHasSourceCategoryFilter>>(c =>
{
return renderCategory => c.Resolve<GenericHasSourceCategoryFilter>(new NamedParameter("renderCategory", renderCategory));
var context = c.Resolve<IComponentContext>();
return renderCategory => context.Resolve<GenericHasSourceCategoryFilter>(new NamedParameter("renderCategory", renderCategory));
});

builder.Register<Func<ItemInfoRenderCategory, GenericHasUseCategoryFilter>>(c =>
{
return renderCategory => c.Resolve<GenericHasUseCategoryFilter>(new NamedParameter("renderCategory", renderCategory));
var context = c.Resolve<IComponentContext>();
return renderCategory => context.Resolve<GenericHasUseCategoryFilter>(new NamedParameter("renderCategory", renderCategory));
});

builder.Register<Func<int, IBackgroundTaskQueue>>(c =>
5 changes: 3 additions & 2 deletions InventoryTools/Logic/Columns/BuyFromVendorPriceColumn.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using AllaganLib.GameSheets.Caches;
using InventoryTools.Logic.Columns.Abstract;
using InventoryTools.Services;
using Microsoft.Extensions.Logging;
@@ -13,13 +14,13 @@ public BuyFromVendorPriceColumn(ILogger<BuyFromVendorPriceColumn> logger, ImGuiS

public override int? CurrentValue(ColumnConfiguration columnConfiguration, SearchResult searchResult)
{
if (searchResult.InventoryItem != null && searchResult.InventoryItem.Item.SpentGilShop)
if (searchResult.InventoryItem != null && searchResult.InventoryItem.Item.HasSourcesByType(ItemInfoType.GilShop, ItemInfoType.CalamitySalvagerShop))
{
int buyPrice = (int)searchResult.InventoryItem.BuyFromVendorPrice;
return buyPrice;
}

if (searchResult.Item.SpentGilShop)
if (searchResult.Item.HasSourcesByType(ItemInfoType.GilShop, ItemInfoType.CalamitySalvagerShop))
{
int buyPrice = (int)searchResult.Item.Base.PriceMid;
return buyPrice;
3 changes: 2 additions & 1 deletion InventoryTools/Logic/Columns/CanBePurchasedColumn.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using AllaganLib.GameSheets.Caches;
using InventoryTools.Logic.Columns.Abstract;
using InventoryTools.Services;
using Microsoft.Extensions.Logging;
@@ -12,7 +13,7 @@ public CanBePurchasedColumn(ILogger<CanBePurchasedColumn> logger, ImGuiService i
public override ColumnCategory ColumnCategory => ColumnCategory.Basic;
public override bool? CurrentValue(ColumnConfiguration columnConfiguration, SearchResult searchResult)
{
return searchResult.Item.SpentGilShop;
return searchResult.Item.HasSourcesByType(ItemInfoType.GilShop, ItemInfoType.CalamitySalvagerShop);
}
public override string Name { get; set; } = "Is Purchasable?";
public override float Width { get; set; } = 70.0f;
3 changes: 2 additions & 1 deletion InventoryTools/Logic/Columns/CraftMarketPriceColumn.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System.Collections.Generic;
using System.Numerics;
using AllaganLib.GameSheets.Caches;
using CriticalCommonLib.Crafting;
using CriticalCommonLib.Models;
using CriticalCommonLib.Services.Mediator;
@@ -46,7 +47,7 @@ public CraftMarketPriceColumn(ILogger<CraftMarketPriceColumn> logger, ImGuiServi
{
ImGui.Text($"{searchResult.CraftItem.MarketUnitPrice.Value:n0}" + SeIconChar.Gil.ToIconString() + " (" + $"{searchResult.CraftItem.MarketTotalPrice.Value:n0}" + SeIconChar.Gil.ToIconString() + ")");

if (searchResult.Item.SpentGilShop)
if (searchResult.Item.HasSourcesByType(ItemInfoType.GilShop, ItemInfoType.CalamitySalvagerShop))
{
var currentIndex = configuration.CraftList.IngredientPreferenceTypeOrder.IndexOf((
searchResult.CraftItem.IngredientPreference.Type,
3 changes: 2 additions & 1 deletion InventoryTools/Logic/Columns/CraftSimpleColumn.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System.Collections.Generic;
using System.Numerics;
using AllaganLib.GameSheets.Caches;
using CriticalCommonLib.Crafting;
using CriticalCommonLib.Models;
using CriticalCommonLib.Services.Mediator;
@@ -70,7 +71,7 @@ public CraftSimpleColumn(ILogger<CraftSimpleColumn> logger, ImGuiService imGuiSe
{
if (searchResult.CraftItem.MarketTotalPrice != null && searchResult.CraftItem.MarketUnitPrice != null)
{
if (searchResult.Item.SpentGilShop)
if (searchResult.Item.HasSourcesByType(ItemInfoType.GilShop, ItemInfoType.CalamitySalvagerShop))
{
var currentIndex = configuration.CraftList.IngredientPreferenceTypeOrder.IndexOf((
searchResult.CraftItem.IngredientPreference.Type,
5 changes: 3 additions & 2 deletions InventoryTools/Logic/Filters/BuyFromVendorPriceFilter.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using AllaganLib.GameSheets.Caches;
using AllaganLib.GameSheets.Sheets.Rows;
using AllaganLib.Shared.Extensions;
using CriticalCommonLib.Models;
@@ -21,7 +22,7 @@ public class BuyFromVendorPriceFilter : StringFilter
var currentValue = CurrentValue(configuration);
if (!string.IsNullOrEmpty(currentValue))
{
if (!item.Item.SpentGilShop)
if (!item.Item.HasSourcesByType(ItemInfoType.GilShop, ItemInfoType.CalamitySalvagerShop))
{
return false;
}
@@ -39,7 +40,7 @@ public class BuyFromVendorPriceFilter : StringFilter
var currentValue = CurrentValue(configuration);
if (!string.IsNullOrEmpty(currentValue))
{
if (!item.SpentGilShop)
if (!item.HasSourcesByType(ItemInfoType.GilShop, ItemInfoType.CalamitySalvagerShop))
{
return false;
}
7 changes: 0 additions & 7 deletions InventoryTools/Logic/SortingResult.cs
Original file line number Diff line number Diff line change
@@ -66,13 +66,6 @@ public SortingResult(ulong sourceRetainerId, InventoryType sourceBag, InventoryI

public Vector2 BagLocation => InventoryItem.BagLocation(_sourceBag);

public string GetExtraInformation()
{
string info = "";
info += (InventoryItem.Item.SpentGilShop ? "Can be bought" : "Can't be bought") + '\n';
return info;
}

public uint ItemId {
get => InventoryItem.ItemId;
set
11 changes: 8 additions & 3 deletions InventoryTools/PluginLogic.cs
Original file line number Diff line number Diff line change
@@ -44,6 +44,7 @@ public partial class PluginLogic : DisposableMediatorSubscriberBase, IHostedServ
private readonly IEnumerable<IHotkey> hotkeys;
private readonly ITooltipService _tooltipService;
private readonly Func<ItemInfoRenderCategory, GenericHasSourceCategoryFilter> _sourceCategoryFilterFactory;
private readonly BuyFromVendorPriceFilter _buyFromVendorPriceFilter;
private readonly Func<Type, IFilter> _filterFactory;
private readonly IMarketCache _marketCache;
private Dictionary<uint, InventoryMonitor.ItemChangesItem> _recentlyAddedSeen = new();
@@ -68,7 +69,7 @@ public bool WasRecentlySeen(uint itemId)

private DateTime? _nextSaveTime = null;

public PluginLogic(ConfigurationManagerService configurationManagerService, IChatUtilities chatUtilities, IListService listService, ILogger<PluginLogic> logger, IFramework framework, MediatorService mediatorService, HostedInventoryHistory hostedInventoryHistory, IInventoryMonitor inventoryMonitor, IInventoryScanner inventoryScanner, ICharacterMonitor characterMonitor, InventoryToolsConfiguration configuration, IMobTracker mobTracker, IHotkeyService hotkeyService, ICraftMonitor craftMonitor, IUnlockTrackerService unlockTrackerService,IEnumerable<BaseTooltip> tooltips, IEnumerable<IHotkey> hotkeys, Func<Type,IFilter> filterFactory, IMarketCache marketCache, ITooltipService tooltipService, Func<ItemInfoRenderCategory, GenericHasSourceCategoryFilter> sourceCategoryFilterFactory) : base(logger, mediatorService)
public PluginLogic(ConfigurationManagerService configurationManagerService, IChatUtilities chatUtilities, IListService listService, ILogger<PluginLogic> logger, IFramework framework, MediatorService mediatorService, HostedInventoryHistory hostedInventoryHistory, IInventoryMonitor inventoryMonitor, IInventoryScanner inventoryScanner, ICharacterMonitor characterMonitor, InventoryToolsConfiguration configuration, IMobTracker mobTracker, IHotkeyService hotkeyService, ICraftMonitor craftMonitor, IUnlockTrackerService unlockTrackerService,IEnumerable<BaseTooltip> tooltips, IEnumerable<IHotkey> hotkeys, Func<Type,IFilter> filterFactory, IMarketCache marketCache, ITooltipService tooltipService, Func<ItemInfoRenderCategory, GenericHasSourceCategoryFilter> sourceCategoryFilterFactory, BuyFromVendorPriceFilter buyFromVendorPriceFilter) : base(logger, mediatorService)
{
_configurationManagerService = configurationManagerService;
_chatUtilities = chatUtilities;
@@ -88,6 +89,7 @@ public PluginLogic(ConfigurationManagerService configurationManagerService, ICha
this.hotkeys = hotkeys;
_tooltipService = tooltipService;
_sourceCategoryFilterFactory = sourceCategoryFilterFactory;
_buyFromVendorPriceFilter = buyFromVendorPriceFilter;
_filterFactory = filterFactory;
_marketCache = marketCache;

@@ -322,9 +324,10 @@ public void AddSampleFilter100Gil(string newName = "100 gil or less")
sampleFilter.SourceAllCharacters = true;
sampleFilter.SourceAllRetainers = true;
sampleFilter.SourceAllFreeCompanies = true;
sampleFilter.CanBeBought = true;
sampleFilter.ShopBuyingPrice = "<=100";
_sourceCategoryFilterFactory.Invoke(ItemInfoRenderCategory.Shop).UpdateFilterConfiguration(sampleFilter, true);
_buyFromVendorPriceFilter.UpdateFilterConfiguration(sampleFilter, "<=100");
_listService.AddList(sampleFilter);
_listService.AddDefaultColumns(sampleFilter);
}

public void AddSampleFilterMaterials(string newName = "Put away materials")
@@ -338,6 +341,7 @@ public void AddSampleFilterMaterials(string newName = "Put away materials")
var gatherFilter = _sourceCategoryFilterFactory.Invoke(ItemInfoRenderCategory.Gathering);
gatherFilter.UpdateFilterConfiguration(sampleFilter, true);
_listService.AddList(sampleFilter);
_listService.AddDefaultColumns(sampleFilter);
}

public void AddSampleFilterDuplicatedItems(string newName = "Duplicated SortItems")
@@ -350,6 +354,7 @@ public void AddSampleFilterDuplicatedItems(string newName = "Duplicated SortItem
sampleFilter.DuplicatesOnly = true;
sampleFilter.HighlightWhen = "Always";
_listService.AddList(sampleFilter);
_listService.AddDefaultColumns(sampleFilter);
}


3 changes: 2 additions & 1 deletion InventoryTools/Ui/Pages/FilterPage.cs
Original file line number Diff line number Diff line change
@@ -6,6 +6,7 @@
using Dalamud.Interface.Colors;
using Dalamud.Interface.Utility.Raii;
using ImGuiNET;
using InventoryTools.Extensions;
using InventoryTools.Lists;
using InventoryTools.Logic;
using InventoryTools.Logic.Filters;
@@ -135,7 +136,7 @@ public override string Name
(filter.AvailableIn.HasFlag(FilterType.CuratedList) &&
filterConfiguration.FilterType.HasFlag(FilterType
.CuratedList)));
if (hasValues && ImGui.BeginTabItem(group.Key.ToString()))
if (hasValues && ImGui.BeginTabItem(group.Key.FormattedName()))
{
ImGui.PushStyleColor(ImGuiCol.Text, ImGuiColors.DalamudWhite);
if (group.Key == FilterCategory.CraftColumns)
7 changes: 6 additions & 1 deletion InventoryTools/Ui/Windows/ItemWindow.cs
Original file line number Diff line number Diff line change
@@ -284,10 +284,15 @@ public override void Draw()
ImGui.TextUnformatted("Sell to Vendor: " + Item.SellToVendorPrice + SeIconChar.Gil.ToIconString());
}

if (Item.BuyFromVendorPrice != 0 && Item.SpentGilShop)
if (Item.BuyFromVendorPrice != 0 && Item.HasSourcesByType(ItemInfoType.GilShop))
{
ImGui.TextUnformatted("Buy from Vendor: " + Item.BuyFromVendorPrice + SeIconChar.Gil.ToIconString());
}

if (Item.BuyFromVendorPrice != 0 && Item.HasSourcesByType(ItemInfoType.CalamitySalvagerShop))
{
ImGui.TextUnformatted("Buy from Calamity Salvager: " + Item.BuyFromVendorPrice + SeIconChar.Gil.ToIconString());
}
ImGui.Image(ImGuiService.GetIconTexture(Item.Icon).ImGuiHandle, new Vector2(100, 100) * ImGui.GetIO().FontGlobalScale);
if (ImGui.IsItemHovered(ImGuiHoveredFlags.AllowWhenDisabled &
ImGuiHoveredFlags.AllowWhenOverlapped &

0 comments on commit b21463a

Please sign in to comment.