Xml vehicles (Menyoo) (#1594)

This commit is contained in:
DayibBaba
2023-07-07 11:11:54 +02:00
committed by GitHub
parent c121e72eb6
commit 5ffe6c7d3b
7 changed files with 340 additions and 2 deletions

View File

@ -0,0 +1,32 @@
#include "pointers.hpp"
#include "pugixml.hpp"
#include "services/vehicle/xml_vehicles_service.hpp"
#include "util/vehicle.hpp"
#include "views/view.hpp"
namespace big
{
void view::xml_vehicles()
{
ImGui::BeginGroup();
components::button("Reload", [] {
g_xml_vehicles_service->fetch_xml_files();
});
if (ImGui::BeginListBox("##xmllist", {300, static_cast<float>(*g_pointers->m_gta.m_resolution_y - 188 - 38 * 4)}))
{
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);
});
}
ImGui::EndListBox();
}
ImGui::EndGroup();
}
}

View File

@ -59,13 +59,11 @@ namespace big
ImGui::EndCombo();
}
static char search[64];
ImGui::SetNextItemWidth(300.f);
components::input_text_with_hint("MODEL_NAME"_T, "SEARCH"_T, search, sizeof(search), ImGuiInputTextFlags_None);
if (ImGui::BeginListBox("###vehicles", {300, static_cast<float>(*g_pointers->m_gta.m_resolution_y - 188 - 38 * 4)}))
{
if (self::veh)
@ -205,12 +203,15 @@ namespace big
ImGui::RadioButton("Personal", &spawn_type, 1);
ImGui::SameLine();
ImGui::RadioButton("Persistent", &spawn_type, 2);
ImGui::SameLine();
ImGui::RadioButton("Xml", &spawn_type, 3);
switch (spawn_type)
{
case 0: render_spawn_new_vehicle(); break;
case 1: view::pv(); break;
case 2: view::persist_car(); break;
case 3: view::xml_vehicles(); break;
}
}
}