diff --git a/include/ui/game_screen.hpp b/include/ui/game_screen.hpp index 4d41ea86..229ab28d 100644 --- a/include/ui/game_screen.hpp +++ b/include/ui/game_screen.hpp @@ -365,6 +365,9 @@ private: // Vendor search filter char vendorSearchFilter_[128] = ""; + // Trainer search filter + char trainerSearchFilter_[128] = ""; + // Auction house UI state char auctionSearchName_[256] = ""; int auctionLevelMin_ = 0; diff --git a/src/ui/game_screen.cpp b/src/ui/game_screen.cpp index 19d55fda..d48a9f07 100644 --- a/src/ui/game_screen.cpp +++ b/src/ui/game_screen.cpp @@ -8003,9 +8003,12 @@ void GameScreen::renderTrainerWindow(game::GameHandler& gameHandler) { uint32_t mc = static_cast(money % 100); ImGui::Text("Your money: %ug %us %uc", mg, ms, mc); - // Filter checkbox + // Filter controls static bool showUnavailable = false; ImGui::Checkbox("Show unavailable spells", &showUnavailable); + ImGui::SameLine(); + ImGui::SetNextItemWidth(-1.0f); + ImGui::InputTextWithHint("##TrainerSearch", "Search...", trainerSearchFilter_, sizeof(trainerSearchFilter_)); ImGui::Separator(); if (trainer.spells.empty()) { @@ -8055,6 +8058,20 @@ void GameScreen::renderTrainerWindow(game::GameHandler& gameHandler) { continue; } + // Apply text search filter + if (trainerSearchFilter_[0] != '\0') { + std::string trainerFilter(trainerSearchFilter_); + for (char& c : trainerFilter) c = static_cast(std::tolower(static_cast(c))); + const std::string& spellName = gameHandler.getSpellName(spell->spellId); + std::string nameLC = spellName.empty() ? std::to_string(spell->spellId) : spellName; + for (char& c : nameLC) c = static_cast(std::tolower(static_cast(c))); + if (nameLC.find(trainerFilter) == std::string::npos) { + ImGui::PushID(static_cast(spell->spellId)); + ImGui::PopID(); + continue; + } + } + ImGui::TableNextRow(); ImGui::PushID(static_cast(spell->spellId));