mirror of
https://github.com/Kelsidavis/WoWee.git
synced 2026-03-23 07:40: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
|
|
@ -7862,6 +7862,10 @@ void GameScreen::renderVendorWindow(game::GameHandler& gameHandler) {
|
|||
if (vendor.items.empty()) {
|
||||
ImGui::TextDisabled("This vendor has nothing for sale.");
|
||||
} 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)) {
|
||||
ImGui::TableSetupColumn("##icon", ImGuiTableColumnFlags_WidthFixed, 22.0f);
|
||||
ImGui::TableSetupColumn("Item", ImGuiTableColumnFlags_WidthStretch);
|
||||
|
|
@ -7870,15 +7874,31 @@ void GameScreen::renderVendorWindow(game::GameHandler& gameHandler) {
|
|||
ImGui::TableSetupColumn("Buy", ImGuiTableColumnFlags_WidthFixed, 50.0f);
|
||||
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) {
|
||||
const auto& item = vendor.items[vi];
|
||||
ImGui::TableNextRow();
|
||||
ImGui::PushID(vi);
|
||||
|
||||
// Proactively ensure vendor item info is loaded
|
||||
gameHandler.ensureItemInfo(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
|
||||
ImGui::TableSetColumnIndex(0);
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue