Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to display individual market board listings #11

Merged
merged 1 commit into from
Feb 2, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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