mirror of
https://github.com/Kelsidavis/WoWee.git
synced 2026-03-22 23:30:14 +00:00
Add item search filter to vendor window
This commit is contained in:
parent
7ab0b036c7
commit
bbf4806fe8
2 changed files with 25 additions and 2 deletions
|
|
@ -362,6 +362,9 @@ private:
|
||||||
char mailBodyBuffer_[2048] = "";
|
char mailBodyBuffer_[2048] = "";
|
||||||
int mailComposeMoney_[3] = {0, 0, 0}; // gold, silver, copper
|
int mailComposeMoney_[3] = {0, 0, 0}; // gold, silver, copper
|
||||||
|
|
||||||
|
// Vendor search filter
|
||||||
|
char vendorSearchFilter_[128] = "";
|
||||||
|
|
||||||
// Auction house UI state
|
// Auction house UI state
|
||||||
char auctionSearchName_[256] = "";
|
char auctionSearchName_[256] = "";
|
||||||
int auctionLevelMin_ = 0;
|
int auctionLevelMin_ = 0;
|
||||||
|
|
|
||||||
|
|
@ -7862,6 +7862,10 @@ void GameScreen::renderVendorWindow(game::GameHandler& gameHandler) {
|
||||||
if (vendor.items.empty()) {
|
if (vendor.items.empty()) {
|
||||||
ImGui::TextDisabled("This vendor has nothing for sale.");
|
ImGui::TextDisabled("This vendor has nothing for sale.");
|
||||||
} else {
|
} else {
|
||||||
|
ImGui::SetNextItemWidth(-1.0f);
|
||||||
|
ImGui::InputTextWithHint("##VendorSearch", "Search...", vendorSearchFilter_, sizeof(vendorSearchFilter_));
|
||||||
|
ImGui::Spacing();
|
||||||
|
|
||||||
if (ImGui::BeginTable("VendorTable", 5, ImGuiTableFlags_Borders | ImGuiTableFlags_RowBg | ImGuiTableFlags_ScrollY)) {
|
if (ImGui::BeginTable("VendorTable", 5, ImGuiTableFlags_Borders | ImGuiTableFlags_RowBg | ImGuiTableFlags_ScrollY)) {
|
||||||
ImGui::TableSetupColumn("##icon", ImGuiTableColumnFlags_WidthFixed, 22.0f);
|
ImGui::TableSetupColumn("##icon", ImGuiTableColumnFlags_WidthFixed, 22.0f);
|
||||||
ImGui::TableSetupColumn("Item", ImGuiTableColumnFlags_WidthStretch);
|
ImGui::TableSetupColumn("Item", ImGuiTableColumnFlags_WidthStretch);
|
||||||
|
|
@ -7870,15 +7874,31 @@ void GameScreen::renderVendorWindow(game::GameHandler& gameHandler) {
|
||||||
ImGui::TableSetupColumn("Buy", ImGuiTableColumnFlags_WidthFixed, 50.0f);
|
ImGui::TableSetupColumn("Buy", ImGuiTableColumnFlags_WidthFixed, 50.0f);
|
||||||
ImGui::TableHeadersRow();
|
ImGui::TableHeadersRow();
|
||||||
|
|
||||||
|
std::string vendorFilter(vendorSearchFilter_);
|
||||||
|
// Lowercase filter for case-insensitive match
|
||||||
|
for (char& c : vendorFilter) c = static_cast<char>(std::tolower(static_cast<unsigned char>(c)));
|
||||||
|
|
||||||
for (int vi = 0; vi < static_cast<int>(vendor.items.size()); ++vi) {
|
for (int vi = 0; vi < static_cast<int>(vendor.items.size()); ++vi) {
|
||||||
const auto& item = vendor.items[vi];
|
const auto& item = vendor.items[vi];
|
||||||
ImGui::TableNextRow();
|
|
||||||
ImGui::PushID(vi);
|
|
||||||
|
|
||||||
// Proactively ensure vendor item info is loaded
|
// Proactively ensure vendor item info is loaded
|
||||||
gameHandler.ensureItemInfo(item.itemId);
|
gameHandler.ensureItemInfo(item.itemId);
|
||||||
auto* info = gameHandler.getItemInfo(item.itemId);
|
auto* info = gameHandler.getItemInfo(item.itemId);
|
||||||
|
|
||||||
|
// Apply search filter
|
||||||
|
if (!vendorFilter.empty()) {
|
||||||
|
std::string nameLC = info && info->valid ? info->name : ("Item " + std::to_string(item.itemId));
|
||||||
|
for (char& c : nameLC) c = static_cast<char>(std::tolower(static_cast<unsigned char>(c)));
|
||||||
|
if (nameLC.find(vendorFilter) == std::string::npos) {
|
||||||
|
ImGui::PushID(vi);
|
||||||
|
ImGui::PopID();
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ImGui::TableNextRow();
|
||||||
|
ImGui::PushID(vi);
|
||||||
|
|
||||||
// Icon column
|
// Icon column
|
||||||
ImGui::TableSetColumnIndex(0);
|
ImGui::TableSetColumnIndex(0);
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue