Added filter vehicle by class feature. (#336)
This commit is contained in:
@ -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<float>(*g_pointers->m_resolution_y - 184 - 38 * 3) }))
|
||||
if (ImGui::ListBoxHeader("###vehicles", { 300, static_cast<float>(*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] {
|
||||
|
||||
|
Reference in New Issue
Block a user