mirror of
https://github.com/Kelsidavis/WoWee.git
synced 2026-03-26 00:40:15 +00:00
Add Sell All Junk button to vendor window
Scans the backpack and all bags for grey (POOR quality) items with a sell price and shows a 'Sell All Junk (N items)' button at the top of the vendor window. Clicking it sells all matching items in one action. Button only appears when there are sellable junk items.
This commit is contained in:
parent
b2d1edc9db
commit
823e2bcec6
1 changed files with 35 additions and 0 deletions
|
|
@ -8148,6 +8148,41 @@ void GameScreen::renderVendorWindow(game::GameHandler& gameHandler) {
|
|||
ImGui::Separator();
|
||||
|
||||
ImGui::TextColored(ImVec4(0.7f, 0.7f, 0.7f, 1.0f), "Right-click bag items to sell");
|
||||
|
||||
// Count grey (POOR quality) sellable items across backpack and bags
|
||||
const auto& inv = gameHandler.getInventory();
|
||||
int junkCount = 0;
|
||||
for (int i = 0; i < inv.getBackpackSize(); ++i) {
|
||||
const auto& sl = inv.getBackpackSlot(i);
|
||||
if (!sl.empty() && sl.item.quality == game::ItemQuality::POOR && sl.item.sellPrice > 0)
|
||||
++junkCount;
|
||||
}
|
||||
for (int b = 0; b < game::Inventory::NUM_BAG_SLOTS; ++b) {
|
||||
for (int s = 0; s < inv.getBagSize(b); ++s) {
|
||||
const auto& sl = inv.getBagSlot(b, s);
|
||||
if (!sl.empty() && sl.item.quality == game::ItemQuality::POOR && sl.item.sellPrice > 0)
|
||||
++junkCount;
|
||||
}
|
||||
}
|
||||
if (junkCount > 0) {
|
||||
char junkLabel[64];
|
||||
snprintf(junkLabel, sizeof(junkLabel), "Sell All Junk (%d item%s)",
|
||||
junkCount, junkCount == 1 ? "" : "s");
|
||||
if (ImGui::Button(junkLabel, ImVec2(-1, 0))) {
|
||||
for (int i = 0; i < inv.getBackpackSize(); ++i) {
|
||||
const auto& sl = inv.getBackpackSlot(i);
|
||||
if (!sl.empty() && sl.item.quality == game::ItemQuality::POOR && sl.item.sellPrice > 0)
|
||||
gameHandler.sellItemBySlot(i);
|
||||
}
|
||||
for (int b = 0; b < game::Inventory::NUM_BAG_SLOTS; ++b) {
|
||||
for (int s = 0; s < inv.getBagSize(b); ++s) {
|
||||
const auto& sl = inv.getBagSlot(b, s);
|
||||
if (!sl.empty() && sl.item.quality == game::ItemQuality::POOR && sl.item.sellPrice > 0)
|
||||
gameHandler.sellItemInBag(b, s);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
ImGui::Separator();
|
||||
|
||||
const auto& buyback = gameHandler.getBuybackItems();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue