mirror of
https://github.com/Mr-X-GTA/YimMenu.git
synced 2024-12-22 20:17:24 +08:00
Add vehicle gears to speedo meter (#1236)
This commit is contained in:
parent
1794d9cad3
commit
b26c714d74
@ -3,7 +3,7 @@ include(FetchContent)
|
||||
FetchContent_Declare(
|
||||
gtav_classes
|
||||
GIT_REPOSITORY https://github.com/Yimura/GTAV-Classes.git
|
||||
GIT_TAG cf7c1a71b413788371000b56d40c4e8b81c47a2c
|
||||
GIT_TAG 4f76d41ff4c39c296606238cbfa9fd4bceee3a54
|
||||
GIT_PROGRESS TRUE
|
||||
CONFIGURE_COMMAND ""
|
||||
BUILD_COMMAND ""
|
||||
|
@ -77,7 +77,6 @@ namespace big
|
||||
looped::vehicle_auto_drive();
|
||||
looped::vehicle_boost_behavior();
|
||||
looped::vehicle_god_mode();
|
||||
looped::vehicle_speedo_meter();
|
||||
looped::derail_train();
|
||||
looped::drive_train();
|
||||
|
||||
|
@ -1,68 +1,67 @@
|
||||
#pragma once
|
||||
#include "common.hpp"
|
||||
#include "services/players/player_service.hpp"
|
||||
|
||||
namespace big
|
||||
{
|
||||
struct spawned_ped
|
||||
{
|
||||
Ped ped_handle;
|
||||
Player spawned_for_player;
|
||||
bool is_bodyguard;
|
||||
bool is_attacker;
|
||||
};
|
||||
|
||||
inline std::vector<spawned_ped> spawned_peds;
|
||||
|
||||
class looped
|
||||
{
|
||||
public:
|
||||
static void hud_transition_state();
|
||||
|
||||
static void player_good_options();
|
||||
static void player_toxic_options();
|
||||
static void player_spectate();
|
||||
static void player_remote_control_vehicle();
|
||||
|
||||
static void self_police();
|
||||
static void self_hud();
|
||||
static void self_dance_mode();
|
||||
|
||||
static void session_local_time();
|
||||
static void session_pop_multiplier_areas();
|
||||
static void session_force_thunder();
|
||||
static void session_block_jobs();
|
||||
static void session_randomize_ceo_colors();
|
||||
static void session_auto_kick_host();
|
||||
|
||||
static void system_self_globals();
|
||||
static void system_update_pointers();
|
||||
static void system_desync_kick_protection();
|
||||
static void system_spoofing();
|
||||
static void system_mission_creator();
|
||||
|
||||
static void vehicle_auto_drive();
|
||||
static void vehicle_boost_behavior();
|
||||
static void vehicle_fly();
|
||||
static void vehicle_god_mode();
|
||||
static void vehicle_ls_customs();
|
||||
static void vehicle_rainbow_paint();
|
||||
static void vehicle_speedo_meter();
|
||||
static void vehicle_turn_signals();
|
||||
|
||||
static void weapons_ammo_special_type();
|
||||
static void weapons_cage_gun();
|
||||
static void custom_gun_disable_control_action();
|
||||
static void weapons_delete_gun();
|
||||
static void weapons_gravity_gun();
|
||||
static void weapons_repair_gun();
|
||||
static void weapons_steal_vehicle_gun();
|
||||
static void weapons_vehicle_gun();
|
||||
static void weapons_c4_limit();
|
||||
|
||||
static void drive_train();
|
||||
static void derail_train();
|
||||
|
||||
static void world_spawn_ped();
|
||||
};
|
||||
}
|
||||
#pragma once
|
||||
#include "common.hpp"
|
||||
#include "services/players/player_service.hpp"
|
||||
|
||||
namespace big
|
||||
{
|
||||
struct spawned_ped
|
||||
{
|
||||
Ped ped_handle;
|
||||
Player spawned_for_player;
|
||||
bool is_bodyguard;
|
||||
bool is_attacker;
|
||||
};
|
||||
|
||||
inline std::vector<spawned_ped> spawned_peds;
|
||||
|
||||
class looped
|
||||
{
|
||||
public:
|
||||
static void hud_transition_state();
|
||||
|
||||
static void player_good_options();
|
||||
static void player_toxic_options();
|
||||
static void player_spectate();
|
||||
static void player_remote_control_vehicle();
|
||||
|
||||
static void self_police();
|
||||
static void self_hud();
|
||||
static void self_dance_mode();
|
||||
|
||||
static void session_local_time();
|
||||
static void session_pop_multiplier_areas();
|
||||
static void session_force_thunder();
|
||||
static void session_block_jobs();
|
||||
static void session_randomize_ceo_colors();
|
||||
static void session_auto_kick_host();
|
||||
|
||||
static void system_self_globals();
|
||||
static void system_update_pointers();
|
||||
static void system_desync_kick_protection();
|
||||
static void system_spoofing();
|
||||
static void system_mission_creator();
|
||||
|
||||
static void vehicle_auto_drive();
|
||||
static void vehicle_boost_behavior();
|
||||
static void vehicle_fly();
|
||||
static void vehicle_god_mode();
|
||||
static void vehicle_ls_customs();
|
||||
static void vehicle_rainbow_paint();
|
||||
static void vehicle_turn_signals();
|
||||
|
||||
static void weapons_ammo_special_type();
|
||||
static void weapons_cage_gun();
|
||||
static void custom_gun_disable_control_action();
|
||||
static void weapons_delete_gun();
|
||||
static void weapons_gravity_gun();
|
||||
static void weapons_repair_gun();
|
||||
static void weapons_steal_vehicle_gun();
|
||||
static void weapons_vehicle_gun();
|
||||
static void weapons_c4_limit();
|
||||
|
||||
static void drive_train();
|
||||
static void derail_train();
|
||||
|
||||
static void world_spawn_ped();
|
||||
};
|
||||
}
|
||||
|
@ -1,48 +1,70 @@
|
||||
#include "backend/looped/looped.hpp"
|
||||
#include "natives.hpp"
|
||||
#include "util/vehicle.hpp"
|
||||
|
||||
namespace big
|
||||
{
|
||||
void looped::vehicle_speedo_meter()
|
||||
{
|
||||
if (!g.vehicle.speedo_meter.enabled || self::veh == 0 || HUD::IS_PAUSE_MENU_ACTIVE() || HUD::IS_WARNING_MESSAGE_ACTIVE() || CAM::IS_SCREEN_FADED_OUT() || CAM::IS_SCREEN_FADING_OUT() || CAM::IS_SCREEN_FADING_IN())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
char speed_type[16], speed[16];
|
||||
int char_width = 3;
|
||||
|
||||
float veh_speed = vehicle::mps_to_speed(ENTITY::GET_ENTITY_SPEED(self::veh), g.vehicle.speed_unit);
|
||||
|
||||
switch (g.vehicle.speed_unit)
|
||||
{
|
||||
case SpeedUnit::KMPH:
|
||||
strcpy(speed_type, "kmph");
|
||||
char_width = 4;
|
||||
break;
|
||||
case SpeedUnit::MIPH: strcpy(speed_type, "mph"); break;
|
||||
case SpeedUnit::MPS: strcpy(speed_type, "mps"); break;
|
||||
}
|
||||
|
||||
sprintf(speed, "%*d", g.vehicle.speedo_meter.left_side ? 0 : char_width, (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_type);
|
||||
HUD::END_TEXT_COMMAND_DISPLAY_TEXT(g.vehicle.speedo_meter.x, g.vehicle.speedo_meter.y, 1);
|
||||
|
||||
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(g.vehicle.speedo_meter.x + (g.vehicle.speedo_meter.left_side ? 0 : .003f),
|
||||
g.vehicle.speedo_meter.y + .04f,
|
||||
1);
|
||||
}
|
||||
#include "backend/bool_command.hpp"
|
||||
#include "backend/looped/looped.hpp"
|
||||
#include "backend/looped_command.hpp"
|
||||
#include "natives.hpp"
|
||||
#include "util/vehicle.hpp"
|
||||
|
||||
|
||||
namespace big
|
||||
{
|
||||
class speedo_meter : looped_command
|
||||
{
|
||||
std::array<std::string_view, 3> m_speed_types = {"kmph", "miph", "mps"};
|
||||
|
||||
using looped_command::looped_command;
|
||||
|
||||
virtual void on_tick() override
|
||||
{
|
||||
if (!self::veh || !g_local_player->m_vehicle || HUD::IS_PAUSE_MENU_ACTIVE() || HUD::IS_WARNING_MESSAGE_ACTIVE() || CAM::IS_SCREEN_FADED_OUT() || CAM::IS_SCREEN_FADING_OUT() || CAM::IS_SCREEN_FADING_IN())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
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(m_speed_types[(int)g.vehicle.speed_unit].data());
|
||||
HUD::END_TEXT_COMMAND_DISPLAY_TEXT(g.vehicle.speedo_meter.x, g.vehicle.speedo_meter.y, 1);
|
||||
|
||||
const auto vehicle_speed = vehicle::mps_to_speed(g_local_player->m_vehicle->get_speed(), g.vehicle.speed_unit);
|
||||
auto char_width{0};
|
||||
if (!g.vehicle.speedo_meter.left_side)
|
||||
{
|
||||
char_width = g.vehicle.speed_unit == SpeedUnit::KMPH ? 4 : 3;
|
||||
}
|
||||
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(std::format("{1:>{0}.0f}", char_width, vehicle_speed).c_str());
|
||||
HUD::END_TEXT_COMMAND_DISPLAY_TEXT(g.vehicle.speedo_meter.x + (g.vehicle.speedo_meter.left_side ? 0 : .003f),
|
||||
g.vehicle.speedo_meter.y + .04f,
|
||||
1);
|
||||
|
||||
if (g.vehicle.speedo_meter.show_current_gear)
|
||||
{
|
||||
const auto& current_gear = g_local_player->m_vehicle->m_current_gear;
|
||||
std::string gear_str = std::to_string(current_gear);
|
||||
if (!current_gear)
|
||||
gear_str = "R";
|
||||
|
||||
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(std::format("{1:>{0}}", char_width, gear_str).c_str());
|
||||
HUD::END_TEXT_COMMAND_DISPLAY_TEXT(g.vehicle.speedo_meter.x + (g.vehicle.speedo_meter.left_side ? 0 : .003f),
|
||||
g.vehicle.speedo_meter.y + .08f,
|
||||
1);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
speedo_meter
|
||||
g_speedo_meter("speedometer", "Enabled", "Enable/disable the speedo meter for vehicles.", g.vehicle.speedo_meter.enabled);
|
||||
bool_command g_speedo_meter_gears("speedometergears", "Show current gear", "Adds the current gear the vehicle is in to the speedo meter.",
|
||||
g.vehicle.speedo_meter.show_current_gear);
|
||||
bool_command g_speedo_meter_left_side("speedometerleftside", "Align to left", "Aligns the speedo meter text to the left instead of to the right.",
|
||||
g.vehicle.speedo_meter.left_side);
|
||||
}
|
@ -560,8 +560,9 @@ namespace big
|
||||
|
||||
bool enabled = false;
|
||||
bool left_side = false;
|
||||
bool show_current_gear = true;
|
||||
|
||||
NLOHMANN_DEFINE_TYPE_INTRUSIVE(speedo_meter, x, y, enabled, left_side)
|
||||
NLOHMANN_DEFINE_TYPE_INTRUSIVE(speedo_meter, x, y, enabled, left_side, show_current_gear)
|
||||
} speedo_meter{};
|
||||
|
||||
struct fly
|
||||
|
@ -166,8 +166,7 @@ namespace big
|
||||
|
||||
components::sub_title("SPEEDO_METER"_T);
|
||||
{
|
||||
ImGui::Checkbox("ENABLED"_T.data(), &g.vehicle.speedo_meter.enabled);
|
||||
|
||||
components::command_checkbox<"speedometer">();
|
||||
if (g.vehicle.speedo_meter.enabled)
|
||||
{
|
||||
ImGui::Text("POS_X_Y"_T.data());
|
||||
@ -180,9 +179,9 @@ namespace big
|
||||
g.vehicle.speedo_meter.y = pos[1];
|
||||
}
|
||||
|
||||
components::command_checkbox<"speedometerleftside">();
|
||||
ImGui::SameLine();
|
||||
|
||||
ImGui::Checkbox("LEFT_SIDED"_T.data(), &g.vehicle.speedo_meter.left_side);
|
||||
components::command_checkbox<"speedometergears">();
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user