feat(GUI): Simplifying the gui (#118)
Co-authored-by: Maddy <59680197+xM4ddy@users.noreply.github.com> Co-authored-by: Yimura <andreas.maerten@scarlet.be>
This commit is contained in:
92
BigBaseV2/src/views/vehicle/view_spawn.cpp
Normal file
92
BigBaseV2/src/views/vehicle/view_spawn.cpp
Normal file
@ -0,0 +1,92 @@
|
||||
#include "views/view.hpp"
|
||||
#include "fiber_pool.hpp"
|
||||
#include "natives.hpp"
|
||||
#include "services/vehicle_preview_service.hpp"
|
||||
#include "util/vehicle.hpp"
|
||||
|
||||
namespace big
|
||||
{
|
||||
static char model[12] = "";
|
||||
|
||||
bool does_search_match(std::string& input, const std::string& search)
|
||||
{
|
||||
std::transform(input.begin(), input.end(), input.begin(), ::tolower);
|
||||
|
||||
return input.find(search) != std::string::npos;
|
||||
}
|
||||
|
||||
void view::spawn() {
|
||||
ImGui::SetWindowSize({ 0.f, (float)*g_pointers->m_resolution_y }, ImGuiCond_Always);
|
||||
|
||||
ImGui::Checkbox("Preview", &g->spawn.preview_vehicle);
|
||||
ImGui::SameLine();
|
||||
ImGui::Checkbox("Spawn In", &g->spawn.spawn_inside);
|
||||
ImGui::SameLine();
|
||||
ImGui::Checkbox("Spawn Maxed", &g->spawn.spawn_maxed);
|
||||
|
||||
components::input_text_with_hint("Model Name", "Search", model, sizeof(model), ImGuiInputTextFlags_EnterReturnsTrue, []
|
||||
{
|
||||
const auto location = ENTITY::GET_OFFSET_FROM_ENTITY_IN_WORLD_COORDS(PLAYER::PLAYER_PED_ID(), 2.f, 2.f, 0.f);
|
||||
const Vehicle veh = vehicle::spawn(model, location, g_local_player->m_player_info->m_ped->m_navigation->m_heading + 90.f);
|
||||
|
||||
if (g->spawn.spawn_inside)
|
||||
PED::SET_PED_INTO_VEHICLE(PLAYER::PLAYER_PED_ID(), veh, -1);
|
||||
|
||||
if (g->spawn.spawn_maxed)
|
||||
{
|
||||
vehicle::max_vehicle(veh);
|
||||
}
|
||||
|
||||
});
|
||||
if (ImGui::ListBoxHeader("###vehicles"))
|
||||
{
|
||||
if (!g_vehicle_preview_service->get_vehicle_list().is_null())
|
||||
{
|
||||
for (auto& item : g_vehicle_preview_service->get_vehicle_list())
|
||||
{
|
||||
if (item["Name"].is_null() || item["DisplayName"].is_null())
|
||||
continue;
|
||||
|
||||
std::string name = item["Name"];
|
||||
std::string display_name = item["DisplayName"];
|
||||
|
||||
std::string manufacturer;
|
||||
std::string search = model;
|
||||
std::transform(search.begin(), search.end(), search.begin(), ::tolower);
|
||||
|
||||
if (!item["ManufacturerDisplayName"].is_null())
|
||||
manufacturer = item["ManufacturerDisplayName"];
|
||||
|
||||
if (search.empty() ||
|
||||
does_search_match(name, search) ||
|
||||
does_search_match(display_name, search) ||
|
||||
does_search_match(manufacturer, search))
|
||||
{
|
||||
components::selectable(item["DisplayName"], item["Name"] == search, [&item]
|
||||
{
|
||||
const auto location = ENTITY::GET_ENTITY_COORDS(PLAYER::PLAYER_PED_ID(), true);
|
||||
const Vehicle veh = vehicle::spawn(item["Name"], location, 0.f);
|
||||
|
||||
if (g->spawn.spawn_inside)
|
||||
{
|
||||
vehicle::telport_into_veh(veh);
|
||||
}
|
||||
|
||||
if (g->spawn.spawn_maxed)
|
||||
{
|
||||
vehicle::max_vehicle(veh);
|
||||
}
|
||||
|
||||
g_vehicle_preview_service->stop_preview();
|
||||
});
|
||||
|
||||
if (g->spawn.preview_vehicle && ImGui::IsItemHovered())
|
||||
g_vehicle_preview_service->set_preview_vehicle(item);
|
||||
}
|
||||
}
|
||||
ImGui::ListBoxFooter();
|
||||
}
|
||||
else ImGui::Text("No vehicles in registry.");
|
||||
}
|
||||
}
|
||||
}
|
84
BigBaseV2/src/views/vehicle/view_vehicle.cpp
Normal file
84
BigBaseV2/src/views/vehicle/view_vehicle.cpp
Normal file
@ -0,0 +1,84 @@
|
||||
#include "views/view.hpp"
|
||||
#include "core/data/speedo_meters.hpp"
|
||||
#include "gui/handling/handling_tabs.hpp"
|
||||
#include "script.hpp"
|
||||
#include "util/vehicle.hpp"
|
||||
|
||||
namespace big
|
||||
{
|
||||
void view::vehicle() {
|
||||
ImGui::BeginGroup();
|
||||
ImGui::Checkbox("Can Be Targeted", &g->vehicle.is_targetable);
|
||||
ImGui::Checkbox("God Mode", &g->vehicle.god_mode);
|
||||
ImGui::Checkbox("Horn Boost", &g->vehicle.horn_boost);
|
||||
ImGui::Checkbox("Drive On Water", &g->vehicle.drive_on_water);
|
||||
|
||||
ImGui::EndGroup();
|
||||
ImGui::SameLine();
|
||||
ImGui::BeginGroup();
|
||||
|
||||
components::button("Repair", [] {
|
||||
Vehicle veh = PED::GET_VEHICLE_PED_IS_IN(PLAYER::PLAYER_PED_ID(), false);
|
||||
|
||||
vehicle::repair(veh);
|
||||
});
|
||||
|
||||
if (ImGui::TreeNode("Paint"))
|
||||
{
|
||||
ImGui::ListBox("RGB Type", &g->vehicle.rainbow_paint, vehicle::rgb_types, 3);
|
||||
|
||||
if (g->vehicle.rainbow_paint)
|
||||
{
|
||||
ImGui::SliderInt("RGB Speed", &g->rgb.speed, 1, 10);
|
||||
}
|
||||
|
||||
ImGui::TreePop();
|
||||
}
|
||||
|
||||
ImGui::EndGroup();
|
||||
|
||||
ImGui::Separator();
|
||||
|
||||
components::small_text("LS Customs");
|
||||
|
||||
components::button("Start LS Customs", [] {
|
||||
g->vehicle.ls_customs = true;
|
||||
});
|
||||
|
||||
ImGui::Separator();
|
||||
|
||||
components::small_text("Speedo Meter");
|
||||
|
||||
SpeedoMeter selected = g->vehicle.speedo_meter.type;
|
||||
|
||||
ImGui::Text("Type:");
|
||||
if (ImGui::BeginCombo("###speedo_type", speedo_meters[(int)selected].name))
|
||||
{
|
||||
for (const speedo_meter& speedo : speedo_meters)
|
||||
{
|
||||
if (ImGui::Selectable(speedo.name, speedo.id == selected))
|
||||
{
|
||||
g->vehicle.speedo_meter.type = speedo.id;
|
||||
}
|
||||
|
||||
if (speedo.id == selected)
|
||||
ImGui::SetItemDefaultFocus();
|
||||
}
|
||||
|
||||
ImGui::EndCombo();
|
||||
}
|
||||
|
||||
ImGui::Text("Position");
|
||||
|
||||
float pos[2];
|
||||
pos[0] = g->vehicle.speedo_meter.x;
|
||||
pos[1] = g->vehicle.speedo_meter.y;
|
||||
if (ImGui::SliderFloat2("###speedo_pos", pos, .001f, .999f, "%.3f"))
|
||||
{
|
||||
g->vehicle.speedo_meter.x = pos[0];
|
||||
g->vehicle.speedo_meter.y = pos[1];
|
||||
}
|
||||
|
||||
ImGui::Checkbox("Left Sided", &g->vehicle.speedo_meter.left_side);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user