2022-07-10 06:33:14 +08:00
|
|
|
#include "views/view.hpp"
|
|
|
|
#include "fiber_pool.hpp"
|
|
|
|
#include "natives.hpp"
|
|
|
|
#include "services/mobile/mobile_service.hpp"
|
|
|
|
#include "services/vehicle_preview/vehicle_preview_service.hpp"
|
|
|
|
#include "util/vehicle.hpp"
|
|
|
|
|
|
|
|
namespace big
|
|
|
|
{
|
|
|
|
void view::pv() {
|
|
|
|
ImGui::SetWindowSize({ 0.f, (float)*g_pointers->m_resolution_y }, ImGuiCond_Always);
|
|
|
|
|
|
|
|
ImGui::Checkbox("Preview", &g->clone_pv.preview_vehicle);
|
|
|
|
ImGui::SameLine();
|
|
|
|
ImGui::Checkbox("Spawn In", &g->clone_pv.spawn_inside);
|
|
|
|
ImGui::SameLine();
|
|
|
|
|
|
|
|
static char plate[9] = { 0 };
|
2022-07-15 20:54:23 +08:00
|
|
|
int num_of_rows = 3;
|
2022-07-10 06:33:14 +08:00
|
|
|
|
|
|
|
ImGui::Checkbox("Spawn Clone", &g->clone_pv.spawn_clone);
|
|
|
|
if (g->clone_pv.spawn_clone)
|
|
|
|
{
|
2022-07-15 20:54:23 +08:00
|
|
|
num_of_rows = 5;
|
2022-07-10 06:33:14 +08:00
|
|
|
|
|
|
|
ImGui::Checkbox("Spawn Maxed", &g->clone_pv.spawn_maxed);
|
|
|
|
|
|
|
|
ImGui::SameLine();
|
|
|
|
strncpy(plate, g->clone_pv.plate.c_str(), 9);
|
|
|
|
ImGui::Checkbox("Clone PV Plate", &g->clone_pv.clone_plate);
|
|
|
|
if (g->clone_pv.clone_plate)
|
|
|
|
{
|
2022-07-15 20:54:23 +08:00
|
|
|
num_of_rows = 4;
|
2022-07-10 06:33:14 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ImGui::SetNextItemWidth(300.f);
|
|
|
|
|
|
|
|
components::input_text_with_hint("Plate", "Plate Number", plate, sizeof(plate), ImGuiInputTextFlags_None, [] {
|
|
|
|
g->clone_pv.plate = plate;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-07-15 20:54:23 +08:00
|
|
|
|
|
|
|
static int selected_class = -1;
|
2022-07-19 18:19:19 +08:00
|
|
|
auto class_arr = g_gta_data_service->get_vehicle_class_arr();
|
2022-07-15 20:54:23 +08:00
|
|
|
|
|
|
|
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();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-07-10 06:33:14 +08:00
|
|
|
static char search[64];
|
|
|
|
|
|
|
|
ImGui::SetNextItemWidth(300.f);
|
2022-07-19 18:19:19 +08:00
|
|
|
components::input_text_with_hint("Model Name", "Search", search, sizeof(search), ImGuiInputTextFlags_None);
|
2022-07-10 06:33:14 +08:00
|
|
|
|
|
|
|
g_mobile_service->refresh_personal_vehicles();
|
2022-07-12 22:42:07 +08:00
|
|
|
if (ImGui::ListBoxHeader("###personal_veh_list", { 300, static_cast<float>(*g_pointers->m_resolution_y - 184 - 38 * num_of_rows) }))
|
2022-07-10 06:33:14 +08:00
|
|
|
{
|
|
|
|
if (g_mobile_service->personal_vehicles().empty())
|
|
|
|
{
|
|
|
|
ImGui::Text("No personal vehicles found, \nare you online?");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2022-07-19 18:19:19 +08:00
|
|
|
std::string lower_search = search;
|
|
|
|
std::transform(lower_search.begin(), lower_search.end(), lower_search.begin(), tolower);
|
|
|
|
|
2022-07-10 06:33:14 +08:00
|
|
|
for (const auto& it : g_mobile_service->personal_vehicles())
|
|
|
|
{
|
|
|
|
const auto& label = it.first;
|
|
|
|
const auto& personal_veh = it.second;
|
2022-07-19 18:19:19 +08:00
|
|
|
auto item = g_gta_data_service->find_vehicle_by_hash(personal_veh->get_hash());
|
2022-07-10 06:33:14 +08:00
|
|
|
|
2022-07-15 20:54:23 +08:00
|
|
|
std::string clazz = item.clazz;
|
2022-07-10 06:33:14 +08:00
|
|
|
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);
|
|
|
|
|
2022-07-15 20:54:23 +08:00
|
|
|
if ((
|
|
|
|
selected_class == -1 || class_arr[selected_class] == clazz
|
|
|
|
) && (
|
2022-07-10 06:33:14 +08:00
|
|
|
display_name.find(lower_search) != std::string::npos ||
|
|
|
|
display_manufacturer.find(lower_search) != std::string::npos
|
2022-07-15 20:54:23 +08:00
|
|
|
)) {
|
2022-07-10 06:33:14 +08:00
|
|
|
|
2022-07-28 01:42:15 +08:00
|
|
|
ImGui::PushID('v' << 24 & personal_veh->get_id());
|
2022-07-12 22:42:07 +08:00
|
|
|
components::selectable(label, false, [&personal_veh] {
|
2022-07-10 06:33:14 +08:00
|
|
|
if (g->clone_pv.spawn_clone)
|
|
|
|
{
|
2022-07-28 01:42:15 +08:00
|
|
|
Vector3 spawn_location = vehicle::get_spawn_location(g->spawn.spawn_inside);
|
2022-07-12 22:42:07 +08:00
|
|
|
float spawn_heading = ENTITY::GET_ENTITY_HEADING(self::ped);
|
|
|
|
|
2022-07-28 01:42:15 +08:00
|
|
|
auto vehicle_idx = personal_veh->get_vehicle_idx();
|
|
|
|
auto owned_mods = vehicle::get_owned_mods_from_vehicle_idx(vehicle_idx);
|
|
|
|
|
2022-07-12 22:42:07 +08:00
|
|
|
const char* spawn_plate = plate;
|
|
|
|
if (g->clone_pv.clone_plate)
|
|
|
|
{
|
|
|
|
spawn_plate = personal_veh->get_plate();
|
|
|
|
}
|
|
|
|
|
2022-07-28 01:42:15 +08:00
|
|
|
auto veh = vehicle::clone_from_owned_mods(owned_mods, spawn_location, spawn_heading);
|
2022-07-12 22:42:07 +08:00
|
|
|
|
2022-07-28 01:42:15 +08:00
|
|
|
if (veh == 0)
|
2022-07-12 22:42:07 +08:00
|
|
|
{
|
2022-07-28 01:42:15 +08:00
|
|
|
g_notification_service->push_error("Vehicle", "Unable to spawn vehicle");
|
2022-07-12 22:42:07 +08:00
|
|
|
}
|
2022-07-28 01:42:15 +08:00
|
|
|
else
|
|
|
|
{
|
|
|
|
if (g->clone_pv.spawn_maxed)
|
|
|
|
{
|
|
|
|
vehicle::max_vehicle(veh);
|
|
|
|
}
|
2022-07-12 22:42:07 +08:00
|
|
|
|
2022-07-28 01:42:15 +08:00
|
|
|
vehicle::set_plate(veh, plate);
|
2022-07-17 04:36:05 +08:00
|
|
|
|
2022-07-28 01:42:15 +08:00
|
|
|
if (g->clone_pv.spawn_inside)
|
|
|
|
{
|
|
|
|
vehicle::teleport_into_vehicle(veh);
|
|
|
|
}
|
2022-07-17 04:36:05 +08:00
|
|
|
}
|
2022-07-10 06:33:14 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
strcpy(search, "");
|
2022-07-12 22:42:07 +08:00
|
|
|
personal_veh->summon();
|
2022-07-10 06:33:14 +08:00
|
|
|
}
|
2022-07-12 22:42:07 +08:00
|
|
|
|
|
|
|
g_vehicle_preview_service->stop_preview();
|
|
|
|
});
|
2022-07-10 06:33:14 +08:00
|
|
|
ImGui::PopID();
|
|
|
|
|
|
|
|
if (g->clone_pv.preview_vehicle && ImGui::IsItemHovered())
|
|
|
|
{
|
2022-07-28 01:42:15 +08:00
|
|
|
g_fiber_pool->queue_job([&personal_veh] {
|
|
|
|
g_vehicle_preview_service->set_preview_vehicle(
|
|
|
|
vehicle::get_owned_mods_from_vehicle_idx(personal_veh->get_vehicle_idx()),
|
|
|
|
g->clone_pv.spawn_maxed
|
|
|
|
);
|
|
|
|
});
|
2022-07-10 06:33:14 +08:00
|
|
|
}
|
|
|
|
else if (g->clone_pv.preview_vehicle && !ImGui::IsAnyItemHovered())
|
|
|
|
{
|
|
|
|
g_vehicle_preview_service->stop_preview();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ImGui::ListBoxFooter();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|