feat(TabVehicle): Added a speedo meter (km/h & mph)

This commit is contained in:
Yimura 2020-12-29 23:18:09 +01:00
parent 80aeb4f943
commit 5e2ec981c9
No known key found for this signature in database
GPG Key ID: 54EFAD29393A6E78
3 changed files with 71 additions and 0 deletions

View File

@ -0,0 +1,48 @@
#include "features.hpp"
namespace big
{
void features::speedo_meter()
{
static const float x = .9f;
static const float y = .72f;
int64_t speedo_type = g_settings.options["speedo_type"].get<int64_t>();
if (speedo_type == 0 || HUD::IS_PAUSE_MENU_ACTIVE()) return;
Vehicle veh = PED::GET_VEHICLE_PED_IS_IN(PLAYER::GET_PLAYER_PED_SCRIPT_INDEX(g_playerId), false);
if (veh == 0) return;
char speed_type[16], speed[32];
float veh_speed = ENTITY::GET_ENTITY_SPEED(veh);
switch (speedo_type)
{
case 1:
veh_speed *= 3.6;
strcpy(speed_type, "kph");
break;
case 2:
veh_speed *= 2.2369;
strcpy(speed_type, "mph");
break;
}
sprintf(speed, "%d", (int)veh_speed);
HUD::SET_TEXT_FONT(2);
HUD::SET_TEXT_SCALE(.9f, .9f);
HUD::SET_TEXT_OUTLINE();
HUD::BEGIN_TEXT_COMMAND_DISPLAY_TEXT("STRING");
HUD::ADD_TEXT_COMPONENT_SUBSTRING_PLAYER_NAME(speed);
HUD::END_TEXT_COMMAND_DISPLAY_TEXT(x, y + .04f, 1);
HUD::SET_TEXT_FONT(2);
HUD::SET_TEXT_SCALE(.91f, .91f);
HUD::SET_TEXT_OUTLINE();
HUD::BEGIN_TEXT_COMMAND_DISPLAY_TEXT("STRING");
HUD::ADD_TEXT_COMPONENT_SUBSTRING_PLAYER_NAME(speed_type);
HUD::END_TEXT_COMMAND_DISPLAY_TEXT(x, y, 1);
}
}

View File

@ -7,6 +7,28 @@ namespace big
{
if (ImGui::BeginTabItem("Vehicle"))
{
ImGui::Text("Speedometer:");
ImGui::SameLine();
static const char* speedo_options[] = { "None", "km/h", "mph" };
if (ImGui::BeginCombo("##speedometer", speedo_options[g_settings.options["speedo_type"].get<int64_t>()]))
{
for (uint8_t i = 0; i < IM_ARRAYSIZE(speedo_options); i++)
{
bool is_selected = (g_settings.options["speedo_type"].get<int64_t>() == i);
if (ImGui::Selectable(speedo_options[i], is_selected))
{
*g_settings.options["speedo_type"].get<int64_t*>() = i;
g_settings.save();
}
if (is_selected)
ImGui::SetItemDefaultFocus();
}
ImGui::EndCombo();
}
ImGui::Separator();
if (ImGui::Button("Auto Pilot"))
{
QUEUE_JOB_BEGIN_CLAUSE()

View File

@ -25,6 +25,7 @@ namespace big
"ragdoll": false,
"rank": 6969,
"reveal_players": false,
"speedo_type": 0,
"spoof_rank": false,
"sticky_tyres": false,
"super_sprint": false,