From 9a2e85b7f5f3ac712e5835f3c5b29287a06bdd7b Mon Sep 17 00:00:00 2001 From: CringeArab Date: Sat, 1 Jun 2024 00:55:44 +0300 Subject: [PATCH] input for xml transport (#3207) --- src/views/vehicle/spawn/view_xml_vehicles.cpp | 20 ++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/src/views/vehicle/spawn/view_xml_vehicles.cpp b/src/views/vehicle/spawn/view_xml_vehicles.cpp index aa70c631..2801762b 100644 --- a/src/views/vehicle/spawn/view_xml_vehicles.cpp +++ b/src/views/vehicle/spawn/view_xml_vehicles.cpp @@ -8,6 +8,11 @@ namespace big { void view::xml_vehicles() { + static char search[64]; + components::input_text_with_hint("MODEL_NAME"_T, "SEARCH"_T, search, IM_ARRAYSIZE(search), ImGuiInputTextFlags_None); + std::string lower_search = search; + std::transform(lower_search.begin(), lower_search.end(), lower_search.begin(), tolower); + ImGui::BeginGroup(); components::button("Reload", [] { @@ -17,11 +22,16 @@ namespace big { for (auto& [name, doc] : g_xml_vehicles_service->m_all_xml_vehicles) { - components::selectable(name, false, [&doc] { - auto handle = g_xml_vehicles_service->spawn_from_xml(doc, self::pos); - if (g.spawn_vehicle.spawn_inside) - vehicle::teleport_into_vehicle(handle); - }); + std::string lower_name = name; + std::transform(lower_name.begin(), lower_name.end(), lower_name.begin(), tolower); + if (lower_name.find(lower_search) != std::string::npos) + { + components::selectable(name, false, [&doc] { + auto handle = g_xml_vehicles_service->spawn_from_xml(doc, self::pos); + if (g.spawn_vehicle.spawn_inside) + vehicle::teleport_into_vehicle(handle); + }); + } } ImGui::EndListBox();