Skip to content

Commit

Permalink
Add option to display individual market board listings
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
NostraThomas99 committed Feb 2, 2025
1 parent 278cb79 commit 41b08af
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
64 changes: 55 additions & 9 deletions RebornToolbox/Features/MBShoppingList/MBShoppingList.UI.cs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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<ShoppingListItem.WorldListing>(
$"Market Availability##{item.ItemId}",
item.WorldListings,
DrawRow,
ImGuiTableFlags.Borders | ImGuiTableFlags.Sortable,
"World",
"Lowest Price",
"Total Listings");
if (Plugin.Configuration.ShoppingListConfig.ShowIndividualListings)
{
OtterGui.ImGuiTable.DrawTable<MarketDataListing>(
$"Market Availability##{item.ItemId}",
item.MarketDataResponse.Listings.OrderBy(l => l.Total),
DrawIndividualRow,
ImGuiTableFlags.Borders | ImGuiTableFlags.Sortable,
"World",
"Quantity",
"Total Price");
}
else
{
OtterGui.ImGuiTable.DrawTable<ShoppingListItem.WorldListing>(
$"Market Availability##{item.ItemId}",
item.WorldListings,
DrawRow,
ImGuiTableFlags.Borders | ImGuiTableFlags.Sortable,
"World",
"Lowest Price",
"Total Listings");
}
}

ImGui.EndChild();
}

Expand Down Expand Up @@ -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");
Expand Down

0 comments on commit 41b08af

Please sign in to comment.