From 41b08af00886325cc9cab6cd9bc5215e93bfd455 Mon Sep 17 00:00:00 2001 From: NostraThomas99 <34015422+NostraThomas99@users.noreply.github.com> Date: Sat, 1 Feb 2025 22:23:30 -0600 Subject: [PATCH] Add option to display individual market board listings This update introduces a new configuration toggle to show individual market board listings in the shopping list feature. When enabled, users can now view detailed item listings, including quantity and total price, with travel options via LifeStream integration. The default behavior remains unchanged unless the option is explicitly enabled. --- .../MBShoppingList/MBShoppingList.Config.cs | 1 + .../MBShoppingList/MBShoppingList.UI.cs | 64 ++++++++++++++++--- 2 files changed, 56 insertions(+), 9 deletions(-) diff --git a/RebornToolbox/Features/MBShoppingList/MBShoppingList.Config.cs b/RebornToolbox/Features/MBShoppingList/MBShoppingList.Config.cs index 392daf7..2117466 100644 --- a/RebornToolbox/Features/MBShoppingList/MBShoppingList.Config.cs +++ b/RebornToolbox/Features/MBShoppingList/MBShoppingList.Config.cs @@ -10,4 +10,5 @@ public class MBShoppingList_Config public bool UseVnavPathing { get; set; } = false; public bool RemoveQuantityAutomatically { get; set; } = false; public bool AllCharactersInventory { get; set; } = false; + public bool ShowIndividualListings { get; set; } = false; } \ No newline at end of file diff --git a/RebornToolbox/Features/MBShoppingList/MBShoppingList.UI.cs b/RebornToolbox/Features/MBShoppingList/MBShoppingList.UI.cs index 1696328..502e193 100644 --- a/RebornToolbox/Features/MBShoppingList/MBShoppingList.UI.cs +++ b/RebornToolbox/Features/MBShoppingList/MBShoppingList.UI.cs @@ -1,6 +1,7 @@ using System.Numerics; using System.Text.RegularExpressions; using Dalamud.Game.Text.SeStringHandling; +using Dalamud.Interface; using Dalamud.Interface.Colors; using Dalamud.Interface.ImGuiFileDialog; using Dalamud.Interface.ImGuiSeStringRenderer; @@ -215,19 +216,39 @@ private void DrawWantedItem(ShoppingListItem? item) ImGui.Text("This item cannot be purchased on the Market Board"); } + var individualItem = Plugin.Configuration.ShoppingListConfig.ShowIndividualListings; + if (ImGui.Checkbox("Show individual listings", ref individualItem)) + { + Plugin.Configuration.ShoppingListConfig.ShowIndividualListings = individualItem; + Plugin.Configuration.SaveConfig(); + } + // If data is present, display it if (item.MarketDataResponse != null && !item.IsFetchingData) { - OtterGui.ImGuiTable.DrawTable( - $"Market Availability##{item.ItemId}", - item.WorldListings, - DrawRow, - ImGuiTableFlags.Borders | ImGuiTableFlags.Sortable, - "World", - "Lowest Price", - "Total Listings"); + if (Plugin.Configuration.ShoppingListConfig.ShowIndividualListings) + { + OtterGui.ImGuiTable.DrawTable( + $"Market Availability##{item.ItemId}", + item.MarketDataResponse.Listings.OrderBy(l => l.Total), + DrawIndividualRow, + ImGuiTableFlags.Borders | ImGuiTableFlags.Sortable, + "World", + "Quantity", + "Total Price"); + } + else + { + OtterGui.ImGuiTable.DrawTable( + $"Market Availability##{item.ItemId}", + item.WorldListings, + DrawRow, + ImGuiTableFlags.Borders | ImGuiTableFlags.Sortable, + "World", + "Lowest Price", + "Total Listings"); + } } - ImGui.EndChild(); } @@ -256,6 +277,31 @@ private void DrawRow(ShoppingListItem.WorldListing obj) ImGui.Text($"{obj.Count}"); } + private void DrawIndividualRow(MarketDataListing obj) + { + ImGui.TableSetColumnIndex(0); + if (ImGui.Selectable($"{obj.WorldName}")) + { + if (!Lifestream_IPCSubscriber.IsEnabled) + { + Svc.Chat.PrintError($"[Reborn Toolbox] LifeStream is required to move between servers"); + return; + } + + _manager.TaskManager.Enqueue(() => Lifestream_IPCSubscriber.ExecuteCommand(obj.WorldName), + _manager.LifeStreamTaskConfig); + _manager.TaskManager.Enqueue(() => !Lifestream_IPCSubscriber.IsBusy(), _manager.LifeStreamTaskConfig); + _manager.TaskManager.Enqueue(GenericHelpers.IsScreenReady); + _manager.TaskManager.Enqueue(_manager.QueueMoveToMarketboardTasks); + } + + ImGuiEx.Tooltip("Travel using LifeStream"); + ImGui.TableSetColumnIndex(1); + ImGui.Text($"{obj.Quantity}"); + ImGui.TableSetColumnIndex(2); + ImGui.Text($"{obj.Total}"); + } + private unsafe void DrawItemSearch(ShoppingListItem item) { AddonItemSearch* addonItemSearch = (AddonItemSearch*)Svc.GameGui.GetAddonByName("ItemSearch");