F.A.R.T. Interface (#104)

Co-authored-by: Yimura <andreas.maerten@scarlet.be>
This commit is contained in:
LiamD-Flop
2022-05-22 16:38:28 +02:00
committed by GitHub
parent b525638fa2
commit 794a84e149
17 changed files with 413 additions and 29 deletions

View File

@ -4,16 +4,10 @@
#include "util/math.hpp"
#include "gta_util.hpp"
#include "util/misc.hpp"
#include "services/context_menu_service.hpp"
namespace big
{
float esp::calculate_distance(rage::fvector3 player_position)
{
const Vector3 plyr_coords = { player_position.x, player_position.y, player_position.z };
const Vector3 cam_coords = g_pointers->m_get_gamplay_cam_coords();
return (float)math::distance_between_vectors(plyr_coords, cam_coords);
}
void esp::draw() {
if (!g->esp.enabled) return;
@ -43,7 +37,7 @@ namespace big
float screen_x, screen_y;
const float distance = calculate_distance(player_pos);
const float distance = math::calculate_distance_from_game_cam(player_pos);
const float multplr = distance > g->esp.global_render_distance[1] ? -1.f : 6.17757f / distance;
if (multplr == -1.f || g->esp.global_render_distance[0] > distance) continue;

View File

@ -6,7 +6,6 @@ namespace big
class esp
{
static float calculate_distance(rage::fvector3);
public:
static void draw();
};

View File

@ -43,10 +43,12 @@ namespace big
static void view_player();
static void players();
static void weapons();
static void context_menu();
static void always()
{
esp::draw();
context_menu();
notifications();
}
};

View File

@ -0,0 +1,44 @@
#include "view.hpp"
#include "services/context_menu_service.hpp"
namespace big
{
void view::context_menu()
{
if (const auto draw_list = ImGui::GetBackgroundDrawList(); draw_list)
{
if (g_context_menu_service->enabled &&
g_context_menu_service->m_pointer &&
g_context_menu_service->m_pointer->m_navigation)
{
float context_screen_x;
float context_screen_y;
auto& context_target_pos = g_context_menu_service->m_pointer->m_navigation->m_position;
const auto context_target_distance = math::calculate_distance_from_game_cam(context_target_pos);
const auto context_target_multplr = context_target_distance > g->esp.global_render_distance[1] ? -1.f : 6.17757f / context_target_distance;
if (g_pointers->m_get_screen_coords_for_world_coords(context_target_pos.data, &context_screen_x, &context_screen_y))
{
const auto cm = g_context_menu_service->get_context_menu();
if (cm == nullptr)
return;
const auto cm_start_x = static_cast<float>(*g_pointers->m_resolution_x) * context_screen_x + (67.5f * context_target_multplr);
const auto cm_start_y = static_cast<float>(*g_pointers->m_resolution_y) * context_screen_y - (175.f * context_target_multplr);
const auto cm_col = ImGui::ColorConvertFloat4ToU32({ 0.549f, 0.639f, 0.710f, 0.3f });
draw_list->AddRectFilled({ cm_start_x - 2.f , cm_start_y }, { cm_start_x + 2.f + cm->menu_size.x, cm_start_y + cm->menu_size.y }, cm_col, 5.f);
for (std::uint32_t i = 0; i < cm->options.size(); i++)
{
const auto co = cm->options.at(i);
draw_list->AddText({ cm_start_x + 7.f, cm_start_y + (20.f * static_cast<float>(i)) + 5.f }, cm->current_option == i ? ImGui::ColorConvertFloat4ToU32({ 0.f, 1.f, 0.f, 1.f }) : ImGui::ColorConvertFloat4ToU32({ 1.f, 1.f, 1.f, 1.f }), co.name.c_str());
}
}
}
}
}
}