diff --git a/BigBaseV2/src/services/vehicle_preview/vehicle_preview_service.cpp b/BigBaseV2/src/services/vehicle_preview/vehicle_preview_service.cpp index 0fbc3b48..1568b993 100644 --- a/BigBaseV2/src/services/vehicle_preview/vehicle_preview_service.cpp +++ b/BigBaseV2/src/services/vehicle_preview/vehicle_preview_service.cpp @@ -14,6 +14,7 @@ namespace big this->name = ""; this->display_name = ""; this->display_manufacturer = ""; + this->clazz = ""; this->hash = 0; } @@ -22,6 +23,7 @@ namespace big this->name = item_json["Name"]; this->display_name = item_json["Name"]; this->display_manufacturer = ""; + this->clazz = ""; this->hash = item_json["Hash"]; if (!item_json["DisplayName"].is_null()) @@ -37,6 +39,16 @@ namespace big { this->display_manufacturer = item_json["Manufacturer"]; } + + if (!item_json["Class"].is_null()) + { + this->clazz = item_json["Class"]; + + if (this->clazz == "COMPACTS") + { + this->clazz = "COMPACT"; + } + } } vehicle_preview_service::vehicle_preview_service() : @@ -94,6 +106,11 @@ namespace big } } + std::vector& vehicle_preview_service::get_vehicle_class_arr() + { + return m_vehicle_class_arr; + } + std::vector& vehicle_preview_service::get_vehicle_preview_item_arr() { return m_vehicle_preview_item_arr; @@ -189,6 +206,7 @@ namespace big LOG(WARNING) << "Failed to load vehicles.json:\n" << ex.what(); } + for (auto& item_json : all_vehicles) { if ( @@ -201,8 +219,18 @@ namespace big continue; } + auto item = vehicle_preview_item(item_json); + m_hash_idx_map[item_json["Hash"]] = (int)m_vehicle_preview_item_arr.size(); - m_vehicle_preview_item_arr.push_back(vehicle_preview_item(item_json)); + + m_vehicle_preview_item_arr.push_back(item); + + if (std::find(m_vehicle_class_arr.begin(), m_vehicle_class_arr.end(), item.clazz) == m_vehicle_class_arr.end()) + { + m_vehicle_class_arr.push_back(item.clazz); + } + + std::sort(m_vehicle_class_arr.begin(), m_vehicle_class_arr.end()); } } } diff --git a/BigBaseV2/src/services/vehicle_preview/vehicle_preview_service.hpp b/BigBaseV2/src/services/vehicle_preview/vehicle_preview_service.hpp index 6ae20b3a..7c70158a 100644 --- a/BigBaseV2/src/services/vehicle_preview/vehicle_preview_service.hpp +++ b/BigBaseV2/src/services/vehicle_preview/vehicle_preview_service.hpp @@ -12,6 +12,7 @@ namespace big std::string name; std::string display_name; std::string display_manufacturer; + std::string clazz; Hash hash; }; @@ -24,6 +25,7 @@ namespace big std::mutex m_mutex; std::map m_hash_idx_map; + std::vector m_vehicle_class_arr; std::vector m_vehicle_preview_item_arr; const vehicle_preview_item empty_item = vehicle_preview_item(); @@ -37,6 +39,7 @@ namespace big ~vehicle_preview_service(); const vehicle_preview_item& find_vehicle_item_by_hash(Hash hash); + std::vector& get_vehicle_class_arr(); std::vector& get_vehicle_preview_item_arr(); void set_preview_vehicle(const vehicle_preview_item& item); diff --git a/BigBaseV2/src/views/vehicle/view_pv.cpp b/BigBaseV2/src/views/vehicle/view_pv.cpp index 6d36e51c..ee422799 100644 --- a/BigBaseV2/src/views/vehicle/view_pv.cpp +++ b/BigBaseV2/src/views/vehicle/view_pv.cpp @@ -16,12 +16,12 @@ namespace big ImGui::SameLine(); static char plate[9] = { 0 }; - int num_of_rows = 2; + int num_of_rows = 3; ImGui::Checkbox("Spawn Clone", &g->clone_pv.spawn_clone); if (g->clone_pv.spawn_clone) { - num_of_rows = 4; + num_of_rows = 5; ImGui::Checkbox("Spawn Maxed", &g->clone_pv.spawn_maxed); @@ -30,7 +30,7 @@ namespace big ImGui::Checkbox("Clone PV Plate", &g->clone_pv.clone_plate); if (g->clone_pv.clone_plate) { - num_of_rows = 3; + num_of_rows = 4; } else { @@ -42,6 +42,35 @@ namespace big } } + + static int selected_class = -1; + auto class_arr = g_vehicle_preview_service->get_vehicle_class_arr(); + + ImGui::SetNextItemWidth(300.f); + if (ImGui::BeginCombo("Vehicle Class", selected_class == -1 ? "ALL" : class_arr[selected_class].c_str())) + { + if (ImGui::Selectable("ALL", selected_class == -1)) + { + selected_class = -1; + } + + for (int i = 0; i < class_arr.size(); i++) + { + if (ImGui::Selectable(class_arr[i].c_str(), selected_class == i)) + { + selected_class = i; + } + + if (selected_class == i) + { + ImGui::SetItemDefaultFocus(); + } + } + + ImGui::EndCombo(); + } + + static char search[64]; static std::string lower_search; @@ -61,22 +90,24 @@ namespace big } else { - for (const auto& it : g_mobile_service->personal_vehicles()) { const auto& label = it.first; const auto& personal_veh = it.second; auto item = g_vehicle_preview_service->find_vehicle_item_by_hash(personal_veh->get_hash()); + std::string clazz = item.clazz; std::string display_name = label; std::string display_manufacturer = item.display_manufacturer; std::transform(display_name.begin(), display_name.end(), display_name.begin(), ::tolower); std::transform(display_manufacturer.begin(), display_manufacturer.end(), display_manufacturer.begin(), ::tolower); - if ( + if (( + selected_class == -1 || class_arr[selected_class] == clazz + ) && ( display_name.find(lower_search) != std::string::npos || display_manufacturer.find(lower_search) != std::string::npos - ) { + )) { ImGui::PushID('v' << 24 & personal_veh->get_id()); components::selectable(label, false, [&personal_veh] { diff --git a/BigBaseV2/src/views/vehicle/view_spawn.cpp b/BigBaseV2/src/views/vehicle/view_spawn.cpp index d0001c8a..67954866 100644 --- a/BigBaseV2/src/views/vehicle/view_spawn.cpp +++ b/BigBaseV2/src/views/vehicle/view_spawn.cpp @@ -24,6 +24,35 @@ namespace big g->spawn.plate = plate; }); + + static int selected_class = -1; + auto class_arr = g_vehicle_preview_service->get_vehicle_class_arr(); + + ImGui::SetNextItemWidth(300.f); + if (ImGui::BeginCombo("Vehicle Class", selected_class == -1 ? "ALL" : class_arr[selected_class].c_str())) + { + if (ImGui::Selectable("ALL", selected_class == -1)) + { + selected_class = -1; + } + + for (int i = 0; i < class_arr.size(); i++) + { + if (ImGui::Selectable(class_arr[i].c_str(), selected_class == i)) + { + selected_class = i; + } + + if (selected_class == i) + { + ImGui::SetItemDefaultFocus(); + } + } + + ImGui::EndCombo(); + } + + static char search[64]; static std::string lower_search; @@ -34,7 +63,7 @@ namespace big }); // arbitrary subtraction this looked nice so idc, works for all resolutions as well - if (ImGui::ListBoxHeader("###vehicles", { 300, static_cast(*g_pointers->m_resolution_y - 184 - 38 * 3) })) + if (ImGui::ListBoxHeader("###vehicles", { 300, static_cast(*g_pointers->m_resolution_y - 184 - 38 * 4) })) { auto item_arr = g_vehicle_preview_service->get_vehicle_preview_item_arr(); @@ -45,14 +74,17 @@ namespace big for (auto& item : item_arr) { std::string display_name = item.display_name; std::string display_manufacturer = item.display_manufacturer; + std::string clazz = item.clazz; std::transform(display_name.begin(), display_name.end(), display_name.begin(), ::tolower); std::transform(display_manufacturer.begin(), display_manufacturer.end(), display_manufacturer.begin(), ::tolower); - if ( + if (( + selected_class == -1 || class_arr[selected_class] == clazz + ) && ( display_name.find(lower_search) != std::string::npos || display_manufacturer.find(lower_search) != std::string::npos - ) { + )) { ImGui::PushID(item.hash); components::selectable(item.display_name, false, [item] {