Add showmodelinfo & showpedtasks to overlay

This commit is contained in:
Grinch_ 2022-07-31 03:57:09 +06:00
parent 4d4e3b28f6
commit 3cf3e8dd5a
23 changed files with 2545 additions and 617 deletions

View File

@ -5,7 +5,6 @@
"includePath": [ "includePath": [
"${workspaceFolder}/**", "${workspaceFolder}/**",
"${PLUGIN_SDK_DIR}/*", "${PLUGIN_SDK_DIR}/*",
"${DIRECTX9_SDK_DIR}/Include/*",
"${PLUGIN_SDK_DIR}/plugin_sa/*", "${PLUGIN_SDK_DIR}/plugin_sa/*",
"${PLUGIN_SDK_DIR}/plugin_sa/game_sa/*", "${PLUGIN_SDK_DIR}/plugin_sa/game_sa/*",
"${PLUGIN_SDK_DIR}/shared/*", "${PLUGIN_SDK_DIR}/shared/*",

View File

@ -35,6 +35,9 @@ SecondaryCheckboxText = "Player can move while playing the animation"
StopAnimation = "Stop Animation" StopAnimation = "Stop Animation"
StopCutscene = "Stop cutscene" StopCutscene = "Stop cutscene"
Styles = "Styles" Styles = "Styles"
Tasks = "Tasks"
PrimaryTasks = "Primary tasks"
SecondaryTasks = "Secondary tasks"
WalkingStyle = "Walking style" WalkingStyle = "Walking style"
WalkingStyleSet = "Walking style set" WalkingStyleSet = "Walking style set"
@ -223,6 +226,8 @@ ShowCoords = "Show coordinates"
ShowCPU = "Show CPU usage" ShowCPU = "Show CPU usage"
ShowFPS = "Show FPS" ShowFPS = "Show FPS"
ShowLocation = "Show location" ShowLocation = "Show location"
ShowModelInfo = "Show model info"
ShowPedTasks = "Show ped tasks"
ShowRAM = "Show RAM usage" ShowRAM = "Show RAM usage"
ShowVehHealth = "Show veh health" ShowVehHealth = "Show veh health"
ShowVehSpeed = "Show veh speed" ShowVehSpeed = "Show veh speed"
@ -704,7 +709,6 @@ RadioStationColor = "Radio station color"
ResetTimecyc = "Reset timecyc" ResetTimecyc = "Reset timecyc"
ShadowStrength = "Shadow strength" ShadowStrength = "Shadow strength"
ShowHud = "Show HUD" ShowHud = "Show HUD"
ShowModelInfo = "Show model info"
ShowRadar = "Show radar" ShowRadar = "Show radar"
SkyBottom = "Sky bottom" SkyBottom = "Sky bottom"
SkyTop = "Sky top" SkyTop = "Sky top"
@ -779,6 +783,7 @@ to every ped weapon type"""
AddNew = "Add new" AddNew = "Add new"
AnimationPage = "Animation" AnimationPage = "Animation"
CheckboxTab = "Checkboxes" CheckboxTab = "Checkboxes"
CopiedToClipboard = "Copied to clipboard"
Default = "Def" Default = "Def"
Enabled = "Enabled" Enabled = "Enabled"
GamePage = "Game" GamePage = "Game"

View File

@ -20,11 +20,13 @@
#endif #endif
#ifdef GTASA #ifdef GTASA
#include "overlay.h"
void Cutscene::Play(std::string& rootKey, std::string& cutsceneId, std::string& interior) void Cutscene::Play(std::string& rootKey, std::string& cutsceneId, std::string& interior)
{ {
if (Util::IsOnCutscene()) if (Util::IsOnCutscene())
{ {
SetHelpMessage(TEXT("Animation.CutsceneRunning")); Util::SetMessage(TEXT("Animation.CutsceneRunning"));
return; return;
} }
@ -73,11 +75,11 @@ void Particle::Remove(std::string& ifp, std::string& particle, std::string& dumm
{ {
Particle::m_Data.m_pData->RemoveKey("Custom", particle.c_str()); Particle::m_Data.m_pData->RemoveKey("Custom", particle.c_str());
Particle::m_Data.m_pData->Save(); Particle::m_Data.m_pData->Save();
SetHelpMessage(TEXT("Animation.ParticleRemoved")); Util::SetMessage(TEXT("Animation.ParticleRemoved"));
} }
else else
{ {
SetHelpMessage(TEXT("Animation.CustomParticlesOnly")); Util::SetMessage(TEXT("Animation.CustomParticlesOnly"));
} }
} }
@ -234,11 +236,11 @@ void Animation::Remove(std::string& ifp, std::string& anim, std::string& ifpRepe
{ {
m_AnimData.m_pData->RemoveKey("Custom", anim.c_str()); m_AnimData.m_pData->RemoveKey("Custom", anim.c_str());
m_AnimData.m_pData->Save(); m_AnimData.m_pData->Save();
SetHelpMessage(TEXT("Animation.AnimationRemoved")); Util::SetMessage(TEXT("Animation.AnimationRemoved"));
} }
else else
{ {
SetHelpMessage(TEXT("Animation.CustomAnimsOnly")); Util::SetMessage(TEXT("Animation.CustomAnimsOnly"));
} }
} }
@ -365,6 +367,52 @@ void Animation::ShowPage()
ImGui::EndTabItem(); ImGui::EndTabItem();
} }
#ifdef GTASA #ifdef GTASA
if (ImGui::BeginTabItem(TEXT("Animation.Tasks")))
{
ImGui::Spacing();
Widget::Checkbox(TEXT("Menu.ShowPedTasks"), &Overlay::m_bPedTasks);
ImGui::Spacing();
CPlayerPed* player = FindPlayerPed();
if (player)
{
ImGui::BeginChild("TasksList");
ImGui::Text(TEXT("Animation.PrimaryTasks"));
ImGui::Separator();
for (size_t i = 0; i != TASK_PRIMARY_MAX; ++i)
{
CTask *pTask = player->m_pIntelligence->m_TaskMgr.m_aPrimaryTasks[i];
if (pTask)
{
const char *name = taskNames[pTask->GetId()];
if (ImGui::MenuItem(name))
{
ImGui::SetClipboardText(name);
Util::SetMessage(TEXT("Window.CopiedToClipboard"));
}
}
}
ImGui::Dummy(ImVec2(0, 25));
ImGui::Text(TEXT("Animation.SecondaryTasks"));
ImGui::Separator();
for (size_t i = 0; i != TASK_SECONDARY_MAX; ++i)
{
CTask *pTask = player->m_pIntelligence->m_TaskMgr.m_aSecondaryTasks[i];
if (pTask)
{
const char *name = taskNames[pTask->GetId()];
if (ImGui::MenuItem(name))
{
ImGui::SetClipboardText(name);
Util::SetMessage(TEXT("Window.CopiedToClipboard"));
}
}
}
ImGui::EndChild();
}
ImGui::EndTabItem();
}
if (ImGui::BeginTabItem(TEXT("Animation.CutsceneTab"))) if (ImGui::BeginTabItem(TEXT("Animation.CutsceneTab")))
{ {
ImGui::Spacing(); ImGui::Spacing();
@ -464,7 +512,7 @@ void Animation::ShowPage()
if (ImGui::Combo(TEXT("Animation.FightingStyle"), &fightStyle, fightStyles)) if (ImGui::Combo(TEXT("Animation.FightingStyle"), &fightStyle, fightStyles))
{ {
Command<Commands::GIVE_MELEE_ATTACK_TO_CHAR>(hPlayer, fightStyle + 4, 6); Command<Commands::GIVE_MELEE_ATTACK_TO_CHAR>(hPlayer, fightStyle + 4, 6);
SetHelpMessage(TEXT("Animation.FightingStyleSet")); Util::SetMessage(TEXT("Animation.FightingStyleSet"));
} }
if (Widget::ListBox(TEXT("Animation.WalkingStyle"), walkStyles, walkStyle)) if (Widget::ListBox(TEXT("Animation.WalkingStyle"), walkStyles, walkStyle))
{ {
@ -481,7 +529,7 @@ void Animation::ShowPage()
Command<Commands::SET_ANIM_GROUP_FOR_CHAR>(hPlayer, walkStyle.c_str()); Command<Commands::SET_ANIM_GROUP_FOR_CHAR>(hPlayer, walkStyle.c_str());
Command<Commands::REMOVE_ANIMATION>(walkStyle.c_str()); Command<Commands::REMOVE_ANIMATION>(walkStyle.c_str());
} }
SetHelpMessage(TEXT("Animation.WalkingStyleSet")); Util::SetMessage(TEXT("Animation.WalkingStyleSet"));
} }
ImGui::EndTabItem(); ImGui::EndTabItem();
} }

View File

@ -38,6 +38,10 @@ private:
static void Play(std::string& rootKey, std::string& anim, std::string& ifp); static void Play(std::string& rootKey, std::string& anim, std::string& ifp);
static void Remove(std::string& rootKey, std::string& anim, std::string& ifp); static void Remove(std::string& rootKey, std::string& anim, std::string& ifp);
#ifdef GTASA
static void DrawPedTasks();
#endif
public: public:
Animation() = delete; Animation() = delete;
Animation(const Animation&) = delete; Animation(const Animation&) = delete;

View File

@ -15,6 +15,7 @@
#include "vehicle.h" #include "vehicle.h"
#include "visual.h" #include "visual.h"
#include "weapon.h" #include "weapon.h"
#include "overlay.h"
static bool DrawTitleBar() static bool DrawTitleBar()
{ {
@ -76,8 +77,6 @@ void CheatMenu::DrawWindow()
else else
{ {
bRunning = true; bRunning = true;
if (m_bShowMenu || BY_GAME(Menu::Commands::m_bShowMenu, true, true))
{
if (m_bShowMenu) if (m_bShowMenu)
{ {
ImGui::SetNextWindowSize(m_fMenuSize); ImGui::SetNextWindowSize(m_fMenuSize);
@ -103,16 +102,8 @@ void CheatMenu::DrawWindow()
ImGui::End(); ImGui::End();
} }
} }
#ifdef GTASA
else
{
Menu::DrawCommandWindow();
} }
#endif Overlay::Draw();
}
}
Menu::DrawOverlay();
ShowModelInfo::Draw();
} }
void CheatMenu::ProcessPages() void CheatMenu::ProcessPages()
@ -271,6 +262,7 @@ void CheatMenu::Init()
Vehicle::Init(); Vehicle::Init();
Visual::Init(); Visual::Init();
Weapon::Init(); Weapon::Init();
Overlay::Init();
Events::processScriptsEvent += []() Events::processScriptsEvent += []()
{ {
@ -283,12 +275,7 @@ void CheatMenu::Init()
if (commandWindow.Pressed()) if (commandWindow.Pressed())
{ {
if (Menu::Commands::m_bShowMenu) Overlay::m_bCmdBar = !Overlay::m_bCmdBar;
{
Menu::ProcessCommands();
strcpy(Menu::Commands::m_nInputBuffer, "");
}
Menu::Commands::m_bShowMenu = !Menu::Commands::m_bShowMenu;
} }
bool mouseState = D3dHook::GetMouseState(); bool mouseState = D3dHook::GetMouseState();

View File

@ -30,7 +30,7 @@ private:
static void ApplyStyle(); static void ApplyStyle();
// Draws the window ui each frame // Draws the window ui each frame
// Also handles drawing overlay & command window // Also handles drawing info, overlay, command window
static void DrawWindow(); static void DrawWindow();
static void ShowAnniversaryPage(); static void ShowAnniversaryPage();

View File

@ -79,7 +79,7 @@ void Freecam::Process()
// disble them again cause they get enabled // disble them again cause they get enabled
CHud::bScriptDontDisplayRadar = true; CHud::bScriptDontDisplayRadar = true;
CHud::m_Wants_To_Draw_Hud = false; CHud::m_Wants_To_Draw_Hud = false;
SetHelpMessage(TEXT("Game.PlayerTeleported")); Util::SetMessage(TEXT("Game.PlayerTeleported"));
} }
if (KeyPressed(VK_MENU) && m_nMul > 1) if (KeyPressed(VK_MENU) && m_nMul > 1)
@ -150,7 +150,7 @@ void Freecam::Process()
if (m_nMul < 10) if (m_nMul < 10)
{ {
++m_nMul; ++m_nMul;
SetHelpMessage(std::format("Speed: {}", m_nMul).c_str()); Util::SetMessage(std::format("Speed: {}", m_nMul).c_str());
} }
} }
} }
@ -172,8 +172,8 @@ void Freecam::Process()
if (m_nMul > 1) if (m_nMul > 1)
{ {
--m_nMul; --m_nMul;
SetHelpMessage(std::to_string(m_nMul).c_str()); Util::SetMessage(std::to_string(m_nMul).c_str());
SetHelpMessage(std::format("Speed: {}", m_nMul).c_str()); Util::SetMessage(std::format("Speed: {}", m_nMul).c_str());
} }
} }
} }
@ -353,7 +353,7 @@ void Game::Init()
if (quickSceenShot.Pressed()) if (quickSceenShot.Pressed())
{ {
Command<Commands::TAKE_PHOTO>(); Command<Commands::TAKE_PHOTO>();
SetHelpMessage(TEXT("Game.ScreenshotTaken")); Util::SetMessage(TEXT("Game.ScreenshotTaken"));
} }
} }
@ -444,7 +444,7 @@ void SetPlayerMission(std::string& rootkey, std::string& name, std::string& id)
} }
else else
{ {
SetHelpMessage(TEXT("Game.MissionStartFailed")); Util::SetMessage(TEXT("Game.MissionStartFailed"));
} }
} }
@ -1037,7 +1037,7 @@ void Game::ShowPage()
CStats::SetStatValue((unsigned short)i, 1000); CStats::SetStatValue((unsigned short)i, 1000);
} }
CHud::GetRidOfAllHudMessages(true); CHud::GetRidOfAllHudMessages(true);
SetHelpMessage(TEXT("Game.MaxWepSkillsText")); Util::SetMessage(TEXT("Game.MaxWepSkillsText"));
} }
ImGui::SameLine(); ImGui::SameLine();
if (ImGui::Button(TEXT("Game.MaxVehSkills"), Widget::CalcSize(2))) if (ImGui::Button(TEXT("Game.MaxVehSkills"), Widget::CalcSize(2)))
@ -1047,7 +1047,7 @@ void Game::ShowPage()
CStats::SetStatValue(229, 1000); CStats::SetStatValue(229, 1000);
CStats::SetStatValue(230, 1000); CStats::SetStatValue(230, 1000);
CHud::GetRidOfAllHudMessages(true); CHud::GetRidOfAllHudMessages(true);
SetHelpMessage(TEXT("Game.MaxVehSkillsText")); Util::SetMessage(TEXT("Game.MaxVehSkillsText"));
} }
ImGui::Spacing(); ImGui::Spacing();

View File

@ -5,333 +5,20 @@
#include "updater.h" #include "updater.h"
#include "cheatmenu.h" #include "cheatmenu.h"
#include "rpc.h" #include "rpc.h"
#include "overlay.h"
#ifdef GTASA
#include "teleport.h"
#include "weapon.h"
#include "vehicle.h"
#endif
void Menu::Init() void Menu::Init()
{ {
// TODO: use structs
// Load config data
Overlay::bCoord = gConfig.Get("Overlay.ShowCoordinates", false);
Overlay::bCpuUsage = gConfig.Get("Overlay.ShowCPUUsage", false);
Overlay::bFPS = gConfig.Get("Overlay.ShowFPS", false);
Overlay::bLocName = gConfig.Get("Overlay.ShowLocationName", false);
Overlay::bTransparent = gConfig.Get("Overlay.Transparent", false);
Overlay::bMemUsage = gConfig.Get("Overlay.ShowMemoryUsage", false);
Overlay::bVehHealth = gConfig.Get("Overlay.ShowVehicleHealth", false);
Overlay::bVehSpeed = gConfig.Get("Overlay.ShowVehicleSpeed", false);
Overlay::mSelectedPos = (DisplayPos)gConfig.Get("Overlay.SelectedPosition", (int)DisplayPos::BOTTOM_RIGHT);
Overlay::fPosX = gConfig.Get("Overlay.PosX", 0);
Overlay::fPosY = gConfig.Get("Overlay.PosY", 0);
Overlay::textColor[0] = gConfig.Get("Overlay.TextColor.Red", 1.0f);
Overlay::textColor[1] = gConfig.Get("Overlay.TextColor.Green", 1.0f);
Overlay::textColor[2] = gConfig.Get("Overlay.TextColor.Blue", 1.0f);
Overlay::textColor[3] = gConfig.Get("Overlay.TextColor.Alpha", 1.0f);
m_bDiscordRPC = gConfig.Get("Menu.DiscordRPC", false); m_bDiscordRPC = gConfig.Get("Menu.DiscordRPC", false);
m_bAutoCheckUpdate = gConfig.Get("Menu.AutoCheckUpdate", true); m_bAutoCheckUpdate = gConfig.Get("Menu.AutoCheckUpdate", true);
m_bTextOnlyMode = gConfig.Get("Menu.TextOnlyMode", false); m_bTextOnlyMode = gConfig.Get("Menu.TextOnlyMode", false);
Util::GetCPUUsageInit();
MEMORYSTATUSEX memInfo;
memInfo.dwLength = sizeof(MEMORYSTATUSEX);
GlobalMemoryStatusEx(&memInfo);
Overlay::mTotalRam = static_cast<int>(memInfo.ullTotalPhys * 1e-6); // Bytes -> MegaBytes
if (m_bDiscordRPC) if (m_bDiscordRPC)
{ {
RPC::Init(); RPC::Init();
} }
} }
void Menu::DrawOverlay()
{
CPlayerPed* pPlayer = FindPlayerPed();
if (pPlayer)
{
bool m_bShowMenu = Overlay::bCoord || Overlay::bFPS || Overlay::bLocName || Overlay::bCpuUsage || Overlay::bMemUsage ||
((Overlay::bVehHealth || Overlay::bVehSpeed) && pPlayer && pPlayer->m_pVehicle && pPlayer->m_pVehicle->m_pDriver == pPlayer);
const float offset = 10.0f;
ImGuiIO& io = ImGui::GetIO();
ImGuiWindowFlags window_flags = ImGuiWindowFlags_NoDecoration | ImGuiWindowFlags_AlwaysAutoResize |
ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_NoFocusOnAppearing | ImGuiWindowFlags_NoNav;
if (Overlay::mSelectedPos == DisplayPos::CUSTOM)
{
if (Overlay::fPosX != NULL && Overlay::fPosY != NULL)
{
gConfig.Set("Overlay.PosX", Overlay::fPosX);
gConfig.Set("Overlay.PosY", Overlay::fPosY);
ImGui::SetNextWindowPos(ImVec2(Overlay::fPosX, Overlay::fPosY), ImGuiCond_Once);
}
}
else
{
window_flags |= ImGuiWindowFlags_NoMove;
ImVec2 pos, pivot;
if (Overlay::mSelectedPos == DisplayPos::TOP_LEFT)
{
pos = ImVec2(offset, offset);
pivot = ImVec2(0.0f, 0.0f);
}
if (Overlay::mSelectedPos == DisplayPos::TOP_RIGHT)
{
pos = ImVec2(io.DisplaySize.x - offset, offset);
pivot = ImVec2(1.0f, 0.0f);
}
if (Overlay::mSelectedPos == DisplayPos::BOTTOM_LEFT)
{
pos = ImVec2(offset, io.DisplaySize.y - offset);
pivot = ImVec2(0.0f, 1.0f);
}
if (Overlay::mSelectedPos == DisplayPos::BOTTOM_RIGHT)
{
pos = ImVec2(io.DisplaySize.x - offset, io.DisplaySize.y - offset);
pivot = ImVec2(1.0f, 1.0f);
}
ImGui::SetNextWindowPos(pos, ImGuiCond_Always, pivot);
}
ImGui::SetNextWindowBgAlpha(Overlay::bTransparent ? 0.0f : 0.5f);
ImGui::PushStyleColor(ImGuiCol_Text, *(ImVec4*)&Overlay::textColor);
if (m_bShowMenu && ImGui::Begin("Overlay", nullptr, window_flags))
{
CVector pos{0,0,0};
pos = pPlayer->GetPosition();
size_t game_ms = CTimer::m_snTimeInMilliseconds;
static size_t interval = 0;
if (game_ms - interval > 1000)
{
Overlay::fCpuUsage = static_cast<float>(Util::GetCurrentCPUUsage());
MEMORYSTATUSEX memInfo;
memInfo.dwLength = sizeof(MEMORYSTATUSEX);
GlobalMemoryStatusEx(&memInfo);
int mUsedRam = static_cast<int>((memInfo.ullTotalPhys - memInfo.ullAvailPhys) * 1e-6);
Overlay::fMemUsage = 100.0f * (static_cast<float>(mUsedRam) / static_cast<float>(Overlay::mTotalRam));
Overlay::mFPS = static_cast<size_t>(BY_GAME(CTimer::game_FPS, io.Framerate, io.Framerate));
interval = game_ms;
}
if (Overlay::bCoord)
{
ImGui::Text(TEXT("Menu.Coords"), pos.x, pos.y, pos.z);
}
if (Overlay::bCpuUsage)
{
ImGui::Text(TEXT("Menu.CPUUsage"), Overlay::fCpuUsage);
}
if (Overlay::bFPS)
{
ImGui::Text(TEXT("Menu.Frames"), Overlay::mFPS);
}
if (Overlay::bLocName)
{
ImGui::Text(TEXT("Menu.Location"), Util::GetLocationName(&pos).c_str());
}
if (Overlay::bMemUsage)
{
ImGui::Text(TEXT("Menu.RAMUsage"), Overlay::fMemUsage);
}
if (pPlayer->m_pVehicle && pPlayer->m_pVehicle->m_pDriver == pPlayer)
{
if (Overlay::bVehHealth)
{
ImGui::Text((TEXT_S("Menu.VehHealth") + ": %.f").c_str(), pPlayer->m_pVehicle->m_fHealth);
}
if (Overlay::bVehSpeed)
{
int speed = pPlayer->m_pVehicle->m_vecMoveSpeed.Magnitude() * 50.0f; // 02E3 - GET_CAR_SPEED
ImGui::Text(TEXT("Menu.VehSpeed"), speed);
}
}
ImVec2 windowPos = ImGui::GetWindowPos();
Overlay::fPosX = windowPos.x;
Overlay::fPosY = windowPos.y;
ImGui::End();
}
ImGui::PopStyleColor();
}
}
void Menu::DrawCommandWindow()
{
int resX = static_cast<int>(screen::GetScreenWidth());
int resY = static_cast<int>(screen::GetScreenHeight());
ImGui::SetNextWindowPos(ImVec2(0, resY - 40), ImGuiCond_Always);
ImGui::SetNextWindowSize(ImVec2(resX, 40));
ImGuiWindowFlags flags = ImGuiWindowFlags_NoDecoration + ImGuiWindowFlags_AlwaysAutoResize +
ImGuiWindowFlags_NoSavedSettings
+ ImGuiWindowFlags_NoMove;
if (ImGui::Begin("Shortcuts window", nullptr, flags))
{
ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(ImGui::GetStyle().FramePadding.x, resY / 130));
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(3, 3));
ImGui::SetNextItemWidth(ImGui::GetContentRegionMax().x);
if (ImGui::InputTextWithHint("##TEXTFIELD", "Enter command", Commands::m_nInputBuffer, INPUT_BUFFER_SIZE,
ImGuiInputTextFlags_EnterReturnsTrue))
{
ProcessCommands();
Commands::m_bShowMenu = false;
strcpy(Commands::m_nInputBuffer, "");
}
if (!ImGui::IsAnyItemActive())
{
ImGui::SetKeyboardFocusHere(-1);
}
ImGui::PopStyleVar(2);
ImGui::End();
}
}
void Menu::ProcessCommands()
{
std::stringstream ss(Commands::m_nInputBuffer);
std::string command;
ss >> command;
if (command == "armour")
{
try
{
std::string temp;
ss >> temp;
FindPlayerPed()->m_fArmour = std::stof(temp);
}
catch (...)
{
SetHelpMessage(TEXT("Menu.InvalidValue"));
}
}
if (command == "hp")
{
try
{
std::string temp;
ss >> temp;
FindPlayerPed()->m_fHealth = std::stof(temp);
}
catch (...)
{
SetHelpMessage(TEXT("Menu.InvalidValue"));
}
}
if (command == "time")
{
try
{
std::string temp;
ss >> temp;
CClock::ms_nGameClockHours = std::stoi(temp);
ss >> temp;
CClock::ms_nGameClockMinutes = std::stoi(temp);
}
catch (...)
{
SetHelpMessage(TEXT("Menu.InvalidValue"));
}
}
#ifdef GTASA
if (command == "tp")
{
try
{
CVector pos;
std::string temp;
ss >> temp;
pos.x = std::stof(temp);
ss >> temp;
pos.y = std::stof(temp);
ss >> temp;
pos.z = std::stof(temp);
Teleport::WarpPlayer(pos);
}
catch (...)
{
SetHelpMessage(TEXT("Menu.InvalidLocation"));
}
}
if (command == "wep")
{
std::string wep_name;
ss >> wep_name;
if (wep_name == "jetpack")
{
std::string weapon = "-1";
Weapon::GiveWeaponToPlayer(weapon);
SetHelpMessage(TEXT("Menu.WeaponSpawned"));
}
else
{
eWeaponType weapon = CWeaponInfo::FindWeaponType((char*)wep_name.c_str());
std::string weapon_name = std::to_string(weapon);
CWeaponInfo* pweaponinfo = CWeaponInfo::GetWeaponInfo(weapon, 1);
if (wep_name != "" && pweaponinfo->m_nModelId1 != -1)
{
Weapon::GiveWeaponToPlayer(weapon_name);
SetHelpMessage(TEXT("Menu.WeaponSpawned"));
}
else
SetHelpMessage(TEXT("Menu.InvalidComamnd"));
}
return;
}
if (command == "veh")
{
std::string veh_name;
ss >> veh_name;
int model = Vehicle::GetModelFromName(veh_name.c_str());
if (model != 0)
{
std::string smodel = std::to_string(model);
Vehicle::SpawnVehicle(smodel);
SetHelpMessage(TEXT("Menu.VehicleSpawned"));
}
else
SetHelpMessage(TEXT("Menu.InvalidComamnd"));
}
#endif
}
void Menu::ShowPage() void Menu::ShowPage()
{ {
if (ImGui::BeginTabBar("Menu", ImGuiTabBarFlags_NoTooltip + ImGuiTabBarFlags_FittingPolicyScroll)) if (ImGui::BeginTabBar("Menu", ImGuiTabBarFlags_NoTooltip + ImGuiTabBarFlags_FittingPolicyScroll))
@ -359,7 +46,7 @@ void Menu::ShowPage()
} }
else else
{ {
SetHelpMessage(TEXT("Menu.LanguageChangeFailed")); Util::SetMessage(TEXT("Menu.LanguageChangeFailed"));
} }
} }
} }
@ -399,64 +86,74 @@ void Menu::ShowPage()
ImGui::Spacing(); ImGui::Spacing();
ImGui::Spacing(); ImGui::Spacing();
ImGui::SameLine(); ImGui::SameLine();
if (Widget::ListBox(TEXT("Menu.Position"), Overlay::posNames, (int&)Overlay::mSelectedPos)) if (ImGui::Combo(TEXT("Menu.Position"), (int*)&Overlay::m_nSelectedPos, "Custom\0Top left\0Top right\0Bottom left\0Bottom right\0"))
{ {
gConfig.Set<int>("Overlay.SelectedPosition", static_cast<int>(Overlay::mSelectedPos)); gConfig.Set<int>("Overlay.SelectedPosition", static_cast<int>(Overlay::m_nSelectedPos));
} }
ImGui::Spacing(); ImGui::Spacing();
ImGui::SameLine(); ImGui::SameLine();
if (ImGui::ColorEdit4(TEXT("Menu.TextColor"), Overlay::textColor)) if (ImGui::ColorEdit4(TEXT("Menu.TextColor"), Overlay::m_fTextCol))
{ {
gConfig.Set("Overlay.TextColor.Red", Overlay::textColor[0]); gConfig.Set("Overlay.TextColor.Red", Overlay::m_fTextCol[0]);
gConfig.Set("Overlay.TextColor.Green", Overlay::textColor[1]); gConfig.Set("Overlay.TextColor.Green", Overlay::m_fTextCol[1]);
gConfig.Set("Overlay.TextColor.Blue", Overlay::textColor[2]); gConfig.Set("Overlay.TextColor.Blue", Overlay::m_fTextCol[2]);
gConfig.Set("Overlay.TextColor.Alpha", Overlay::textColor[3]); gConfig.Set("Overlay.TextColor.Alpha", Overlay::m_fTextCol[3]);
} }
ImGui::Spacing(); ImGui::Spacing();
ImGui::Columns(2, nullptr, false); ImGui::Columns(2, nullptr, false);
if (ImGui::Checkbox(TEXT("Menu.NoBG"), &Overlay::bTransparent)) if (ImGui::Checkbox(TEXT("Menu.NoBG"), &Overlay::m_bTransparent))
{ {
gConfig.Set("Overlay.Transparent", Overlay::bTransparent); gConfig.Set("Overlay.Transparent", Overlay::m_bTransparent);
} }
if (ImGui::Checkbox(TEXT("Menu.ShowCoords"), &Overlay::bCoord)) if (ImGui::Checkbox(TEXT("Menu.ShowCoords"), &Overlay::m_bCoord))
{ {
gConfig.Set("Overlay.ShowCoordinates", Overlay::bCoord); gConfig.Set("Overlay.ShowCoordinates", Overlay::m_bCoord);
} }
if (ImGui::Checkbox(TEXT("Menu.ShowCPU"), &Overlay::bCpuUsage)) if (ImGui::Checkbox(TEXT("Menu.ShowCPU"), &Overlay::m_bCpuUsage))
{ {
gConfig.Set("Overlay.ShowCPUUsage", Overlay::bCpuUsage); gConfig.Set("Overlay.ShowCPUUsage", Overlay::m_bCpuUsage);
} }
if (ImGui::Checkbox(TEXT("Menu.ShowFPS"), &Overlay::bFPS)) if (ImGui::Checkbox(TEXT("Menu.ShowFPS"), &Overlay::m_bFPS))
{ {
gConfig.Set("Overlay.ShowFPS", Overlay::bFPS); gConfig.Set("Overlay.ShowFPS", Overlay::m_bFPS);
}
if (ImGui::Checkbox(TEXT("Menu.ShowLocation"), &Overlay::m_bLocName))
{
gConfig.Set("Overlay.ShowLocationName", Overlay::m_bLocName);
}
if (ImGui::Checkbox(TEXT("Menu.ShowModelInfo"), &Overlay::m_bModelInfo))
{
gConfig.Set("Overlay.ShowModelInfo", Overlay::m_bModelInfo);
} }
ImGui::NextColumn(); ImGui::NextColumn();
if (ImGui::Checkbox(TEXT("Menu.ShowLocation"), &Overlay::bLocName)) if (ImGui::Checkbox(TEXT("Menu.ShowPedTasks"), &Overlay::m_bPedTasks))
{ {
gConfig.Set("Overlay.ShowLocationName", Overlay::bLocName); gConfig.Set("Overlay.ShowPedTasks", Overlay::m_bPedTasks);
} }
if (ImGui::Checkbox(TEXT("Menu.ShowRAM"), &Overlay::bMemUsage)) if (ImGui::Checkbox(TEXT("Menu.ShowRAM"), &Overlay::m_bMemUsage))
{ {
gConfig.Set("Overlay.ShowMemoryUsage", Overlay::bMemUsage); gConfig.Set("Overlay.ShowMemoryUsage", Overlay::m_bMemUsage);
} }
if (ImGui::Checkbox(TEXT("Menu.ShowVehHealth"), &Overlay::bVehHealth)) if (ImGui::Checkbox(TEXT("Menu.ShowVehHealth"), &Overlay::m_bVehHealth))
{ {
gConfig.Set("Overlay.ShowVehicleHealth", Overlay::bVehHealth); gConfig.Set("Overlay.ShowVehicleHealth", Overlay::m_bVehHealth);
} }
if (ImGui::Checkbox(TEXT("Menu.ShowVehSpeed"), &Overlay::bVehSpeed)) if (ImGui::Checkbox(TEXT("Menu.ShowVehSpeed"), &Overlay::m_bVehSpeed))
{ {
gConfig.Set("Overlay.ShowVehicleSpeed", Overlay::bVehSpeed); gConfig.Set("Overlay.ShowVehicleSpeed", Overlay::m_bVehSpeed);
} }
ImGui::Columns(1); ImGui::Columns(1);

View File

@ -3,47 +3,7 @@
class Menu class Menu
{ {
private:
enum DisplayPos
{
CUSTOM,
TOP_LEFT,
TOP_RIGHT,
BOTTOM_LEFT,
BOTTOM_RIGHT
};
struct Overlay
{
static inline bool bCoord;
static inline bool bFPS;
static inline int mFPS;
static inline bool bLocName;
static inline bool bTransparent;
static inline bool bVehHealth;
static inline bool bVehSpeed;
static inline bool bCpuUsage;
static inline float fCpuUsage;
static inline bool bMemUsage;
static inline float fMemUsage;
static inline std::vector<std::string> posNames =
{
"Custom", "Top left", "Top right", "Bottom left", "Bottom right"
};
static inline DisplayPos mSelectedPos = DisplayPos::BOTTOM_RIGHT;
static inline float fPosX;
static inline float fPosY;
static inline int mTotalRam = 0;
static inline float textColor[4] = {1.0f, 1.0f, 1.0f, 1.0f};
};
public: public:
struct Commands
{
static inline bool m_bShowMenu;
static inline char m_nInputBuffer[INPUT_BUFFER_SIZE] = "";
};
static inline bool m_bAutoCheckUpdate; static inline bool m_bAutoCheckUpdate;
static inline bool m_bDiscordRPC; static inline bool m_bDiscordRPC;
static inline bool m_bTextOnlyMode; static inline bool m_bTextOnlyMode;
@ -53,7 +13,4 @@ public:
static void Init(); static void Init();
static void ShowPage(); static void ShowPage();
static void DrawOverlay();
static void DrawCommandWindow();
static void ProcessCommands();
}; };

489
src/overlay.cpp Normal file
View File

@ -0,0 +1,489 @@
#include "pch.h"
#include "vehicle.h"
#include <CSprite.h>
#include "overlay.h"
#ifdef GTASA
#include "teleport.h"
#include "weapon.h"
#include "vehicle.h"
#endif
void Overlay::Init()
{
// TODO: use structs
// Load config data
m_bCoord = gConfig.Get("Overlay.ShowCoordinates", false);
m_bCpuUsage = gConfig.Get("Overlay.ShowCPUUsage", false);
m_bFPS = gConfig.Get("Overlay.ShowFPS", false);
m_bLocName = gConfig.Get("Overlay.ShowLocationName", false);
m_bModelInfo = gConfig.Get("Overlay.ShowModelInfo", false);
m_bPedTasks = gConfig.Get("Overlay.ShowPedTasks", false);
m_bTransparent = gConfig.Get("Overlay.Transparent", false);
m_bMemUsage = gConfig.Get("Overlay.ShowMemoryUsage", false);
m_bVehHealth = gConfig.Get("Overlay.ShowVehicleHealth", false);
m_bVehSpeed = gConfig.Get("Overlay.ShowVehicleSpeed", false);
m_nSelectedPos = (DisplayPos)gConfig.Get("Overlay.SelectedPosition", (int)DisplayPos::BOTTOM_RIGHT);
m_fPos.x = gConfig.Get("Overlay.PosX", 0);
m_fPos.y = gConfig.Get("Overlay.PosY", 0);
m_fTextCol[0] = gConfig.Get("Overlay.TextColor.Red", 1.0f);
m_fTextCol[1] = gConfig.Get("Overlay.TextColor.Green", 1.0f);
m_fTextCol[2] = gConfig.Get("Overlay.TextColor.Blue", 1.0f);
m_fTextCol[3] = gConfig.Get("Overlay.TextColor.Alpha", 1.0f);
Util::GetCPUUsageInit();
MEMORYSTATUSEX memInfo;
memInfo.dwLength = sizeof(MEMORYSTATUSEX);
GlobalMemoryStatusEx(&memInfo);
m_nTotalMem = static_cast<int>(memInfo.ullTotalPhys * 1e-6); // Bytes -> MegaBytes
ThiscallEvent<AddressList<BY_GAME(0x5343B2, 0x48882E, 0x474BC0), H_CALL>, PRIORITY_BEFORE, ArgPickN<CEntity*, 0>, void(CEntity*)> preRenderEntityEvent;
#ifndef GTASA
patch::Nop(BY_GAME(NULL, 0x488828, 0x474BBA), 4);
#endif
// Directly drawing here seems to crash renderer?
preRenderEntityEvent += [](CEntity *pEnt)
{
CPlayerPed *player = FindPlayerPed();
if (player != pEnt)
{
CVector coord = pEnt->GetPosition();
CVector plaPos = player->GetPosition();
CColPoint outColPoint;
if (BY_GAME(pEnt->m_bIsVisible, pEnt->IsVisible(), pEnt->IsVisible()))
{
m_EntityList.push_back(pEnt);
}
#ifdef GTAVC
if (CModelInfo::GetModelInfo(pEnt->m_nModelIndex)->m_nNum2dEffects > 0)
{
pEnt->ProcessLightsForEntity();
}
#elif GTA3
// if (CModelInfo::ms_modelInfoPtrs[pEnt->m_nModelIndex]->m_nNum2dEffects > 0)
// {
// pEnt->ProcessLightsForEntity();
// }
#endif
}
};
}
void Overlay::ProcessModelInfo()
{
if (m_bModelInfo)
{
ImDrawList *pDrawList = ImGui::GetWindowDrawList();
CPlayerPed *player = FindPlayerPed();
for (CEntity *pEnt : m_EntityList)
{
if (pEnt == player)
{
continue;
}
CVector coord = BY_GAME(,,*)pEnt->GetBoundCentre();
float distance = DistanceBetweenPoints(coord, player->GetPosition());
RwV3d screen;
CVector2D size;
if (distance < m_fMaxDistance &&
#ifdef GTASA
CSprite::CalcScreenCoors(coord.ToRwV3d(), &screen, &size.x, &size.y, true, true)
#else
CSprite::CalcScreenCoors(coord.ToRwV3d(), &screen, &size.x, &size.y, true)
#endif
)
{
bool skip = false;
uint model = pEnt->m_nModelIndex;
std::string text = std::to_string(model);
ImU32 col = ImGui::ColorConvertFloat4ToU32(distance < m_fMaxDistance/2 ? ImVec4(1.0f, 1.0f, 1.0f, 1.00f) : ImVec4(0.35f, 0.33f, 0.3f, 1.00f));
#ifdef GTASA
if (pEnt->m_nType == ENTITY_TYPE_VEHICLE)
{
text = std::format("{}\n{}", model, Vehicle::GetNameFromModel(model));
}
else if (pEnt->m_nType == ENTITY_TYPE_PED)
{
CPed *ped = static_cast<CPed*>(pEnt);
if (BY_GAME(ped->m_nPedFlags.bInVehicle, ped->m_bInVehicle, ped->m_bInVehicle))
{
skip = true;
}
}
#endif
if (!skip)
{
pDrawList->AddText(ImVec2(screen.x, screen.y), col, text.c_str());
}
}
}
}
}
void Overlay::ProcessPedTasks()
{
if (m_bPedTasks)
{
ImDrawList *pDrawList = ImGui::GetWindowDrawList();
CPlayerPed *player = FindPlayerPed();
for (CEntity *pEnt : m_EntityList)
{
if (pEnt == player || pEnt->m_nType != ENTITY_TYPE_PED)
{
continue;
}
CPed *pPed = static_cast<CPed*>(pEnt);
CVector coord = BY_GAME(,,*)pPed->GetBoundCentre();
float distance = DistanceBetweenPoints(coord, player->GetPosition());
RwV3d screen;
CVector2D size;
if (distance < m_fMaxDistance
&& CSprite::CalcScreenCoors(coord.ToRwV3d(), &screen, &size.x, &size.y, true, true))
{
ImU32 col = ImGui::ColorConvertFloat4ToU32(distance < m_fMaxDistance/2 ? ImVec4(1.0f, 1.0f, 1.0f, 1.00f) : ImVec4(0.35f, 0.33f, 0.3f, 1.00f));
float height = ImGui::GetTextLineHeight();
screen.y -= 2 * height;
for (size_t i = 0; i != TASK_SECONDARY_MAX; ++i)
{
CTask *pTask = pPed->m_pIntelligence->m_TaskMgr.m_aSecondaryTasks[i];
if (pTask)
{
const char *name = taskNames[pTask->GetId()];
pDrawList->AddText(ImVec2(screen.x, screen.y), col, name);
screen.y -= height;
}
}
for (size_t i = 0; i != TASK_PRIMARY_MAX; ++i)
{
CTask *pTask = pPed->m_pIntelligence->m_TaskMgr.m_aPrimaryTasks[i];
if (pTask)
{
const char *name = taskNames[pTask->GetId()];
pDrawList->AddText(ImVec2(screen.x, screen.y), col, name);
screen.y -= height;
}
}
}
}
}
}
void Overlay::Draw()
{
if (FrontEndMenuManager.m_bMenuActive)
{
return;
}
ImGuiWindowFlags flags = ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoMove
| ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoNavFocus
| ImGuiWindowFlags_NoBringToFrontOnFocus | ImGuiWindowFlags_NoFocusOnAppearing;
ImGui::SetNextWindowPos(ImVec2(0, 0));
ImGui::SetNextWindowSize(ImVec2(screen::GetScreenWidth(), screen::GetScreenHeight()));
ImGui::SetNextWindowBgAlpha(0.0f);
if (ImGui::Begin("##Overlay", NULL, flags))
{
ProcessModelInfo();
ProcessPedTasks();
ImGui::End();
}
ProcessInfoBox();
ProcessCmdBar();
// clear the list here
m_EntityList.clear();
}
void Overlay::ProcessCmdBar()
{
if (m_bCmdBar)
{
int resX = static_cast<int>(screen::GetScreenWidth());
int resY = static_cast<int>(screen::GetScreenHeight());
ImGui::SetNextWindowPos(ImVec2(0, resY - 40), ImGuiCond_Always);
ImGui::SetNextWindowSize(ImVec2(resX, 40));
ImGuiWindowFlags flags = ImGuiWindowFlags_NoDecoration + ImGuiWindowFlags_AlwaysAutoResize +
ImGuiWindowFlags_NoSavedSettings
+ ImGuiWindowFlags_NoMove;
if (ImGui::Begin("CmdBar", nullptr, flags))
{
ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(ImGui::GetStyle().FramePadding.x, resY / 130));
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(3, 3));
ImGui::SetNextItemWidth(ImGui::GetContentRegionMax().x);
static char buf[INPUT_BUFFER_SIZE] = "";
if (ImGui::InputTextWithHint("##TEXTFIELD", "Enter command", buf, INPUT_BUFFER_SIZE, ImGuiInputTextFlags_EnterReturnsTrue))
{
ProcessCommands(std::string(buf));
m_bCmdBar = false;
strcpy(buf, "");
}
if (!ImGui::IsAnyItemActive())
{
ImGui::SetKeyboardFocusHere(-1);
}
ImGui::PopStyleVar(2);
ImGui::End();
}
}
}
void Overlay::ProcessCommands(std::string&& str)
{
std::stringstream ss(str);
std::string command;
ss >> command;
if (command == "armour")
{
try
{
std::string temp;
ss >> temp;
FindPlayerPed()->m_fArmour = std::stof(temp);
}
catch (...)
{
Util::SetMessage(TEXT("Menu.InvalidValue"));
}
}
if (command == "hp")
{
try
{
std::string temp;
ss >> temp;
FindPlayerPed()->m_fHealth = std::stof(temp);
}
catch (...)
{
Util::SetMessage(TEXT("Menu.InvalidValue"));
}
}
if (command == "time")
{
try
{
std::string temp;
ss >> temp;
CClock::ms_nGameClockHours = std::stoi(temp);
ss >> temp;
CClock::ms_nGameClockMinutes = std::stoi(temp);
}
catch (...)
{
Util::SetMessage(TEXT("Menu.InvalidValue"));
}
}
#ifdef GTASA
if (command == "tp")
{
try
{
CVector pos;
std::string temp;
ss >> temp;
pos.x = std::stof(temp);
ss >> temp;
pos.y = std::stof(temp);
ss >> temp;
pos.z = std::stof(temp);
Teleport::WarpPlayer(pos);
}
catch (...)
{
Util::SetMessage(TEXT("Menu.InvalidLocation"));
}
}
if (command == "wep")
{
std::string wep_name;
ss >> wep_name;
if (wep_name == "jetpack")
{
std::string weapon = "-1";
Weapon::GiveWeaponToPlayer(weapon);
Util::SetMessage(TEXT("Menu.WeaponSpawned"));
}
else
{
eWeaponType weapon = CWeaponInfo::FindWeaponType((char*)wep_name.c_str());
std::string weapon_name = std::to_string(weapon);
CWeaponInfo* pweaponinfo = CWeaponInfo::GetWeaponInfo(weapon, 1);
if (wep_name != "" && pweaponinfo->m_nModelId1 != -1)
{
Weapon::GiveWeaponToPlayer(weapon_name);
Util::SetMessage(TEXT("Menu.WeaponSpawned"));
}
else
Util::SetMessage(TEXT("Menu.InvalidComamnd"));
}
return;
}
if (command == "veh")
{
std::string veh_name;
ss >> veh_name;
int model = Vehicle::GetModelFromName(veh_name.c_str());
if (model != 0)
{
std::string smodel = std::to_string(model);
Vehicle::SpawnVehicle(smodel);
Util::SetMessage(TEXT("Menu.VehicleSpawned"));
}
else
Util::SetMessage(TEXT("Menu.InvalidComamnd"));
}
#endif
}
void Overlay::ProcessInfoBox()
{
CPlayerPed* pPlayer = FindPlayerPed();
if (pPlayer)
{
bool m_bShowMenu = m_bCoord || m_bFPS || m_bLocName || m_bCpuUsage || m_bMemUsage ||
((m_bVehHealth || m_bVehSpeed) && pPlayer && pPlayer->m_pVehicle && pPlayer->m_pVehicle->m_pDriver == pPlayer);
const float offset = 10.0f;
ImGuiIO& io = ImGui::GetIO();
ImGuiWindowFlags window_flags = ImGuiWindowFlags_NoDecoration | ImGuiWindowFlags_AlwaysAutoResize |
ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_NoFocusOnAppearing | ImGuiWindowFlags_NoNav;
if (m_nSelectedPos == DisplayPos::CUSTOM)
{
if (m_fPos.x != NULL && m_fPos.y != NULL)
{
gConfig.Set("Overlay.PosX", m_fPos.x);
gConfig.Set("Overlay.PosY", m_fPos.y);
ImGui::SetNextWindowPos(m_fPos, ImGuiCond_Once);
}
}
else
{
window_flags |= ImGuiWindowFlags_NoMove;
ImVec2 pos, pivot;
if (m_nSelectedPos == DisplayPos::TOP_LEFT)
{
pos = ImVec2(offset, offset);
pivot = ImVec2(0.0f, 0.0f);
}
if (m_nSelectedPos == DisplayPos::TOP_RIGHT)
{
pos = ImVec2(io.DisplaySize.x - offset, offset);
pivot = ImVec2(1.0f, 0.0f);
}
if (m_nSelectedPos == DisplayPos::BOTTOM_LEFT)
{
pos = ImVec2(offset, io.DisplaySize.y - offset);
pivot = ImVec2(0.0f, 1.0f);
}
if (m_nSelectedPos == DisplayPos::BOTTOM_RIGHT)
{
pos = ImVec2(io.DisplaySize.x - offset, io.DisplaySize.y - offset);
pivot = ImVec2(1.0f, 1.0f);
}
ImGui::SetNextWindowPos(pos, ImGuiCond_Always, pivot);
}
ImGui::SetNextWindowBgAlpha(m_bTransparent ? 0.0f : 0.5f);
ImGui::PushStyleColor(ImGuiCol_Text, *(ImVec4*)&m_fTextCol);
if (m_bShowMenu && ImGui::Begin("Overlay", nullptr, window_flags))
{
CVector pos{0,0,0};
pos = pPlayer->GetPosition();
size_t game_ms = CTimer::m_snTimeInMilliseconds;
static size_t interval = 0;
static float cpuUsage = 0, memUsage = 0;
if (game_ms - interval > 1000)
{
cpuUsage = static_cast<float>(Util::GetCurrentCPUUsage());
MEMORYSTATUSEX memInfo;
memInfo.dwLength = sizeof(MEMORYSTATUSEX);
GlobalMemoryStatusEx(&memInfo);
int mUsedRam = static_cast<int>((memInfo.ullTotalPhys - memInfo.ullAvailPhys) * 1e-6);
memUsage = 100.0f * (static_cast<float>(mUsedRam) / static_cast<float>(m_nTotalMem));
m_nFPS = static_cast<size_t>(BY_GAME(CTimer::game_FPS, io.Framerate, io.Framerate));
interval = game_ms;
}
if (m_bCoord)
{
ImGui::Text(TEXT("Menu.Coords"), pos.x, pos.y, pos.z);
}
if (m_bCpuUsage)
{
ImGui::Text(TEXT("Menu.CPUUsage"), cpuUsage);
}
if (m_bFPS)
{
ImGui::Text(TEXT("Menu.Frames"), m_nFPS);
}
if (m_bLocName)
{
ImGui::Text(TEXT("Menu.Location"), Util::GetLocationName(&pos).c_str());
}
if (m_bMemUsage)
{
ImGui::Text(TEXT("Menu.RAMUsage"), memUsage);
}
if (pPlayer->m_pVehicle && pPlayer->m_pVehicle->m_pDriver == pPlayer)
{
if (m_bVehHealth)
{
ImGui::Text((TEXT_S("Menu.VehHealth") + ": %.f").c_str(), pPlayer->m_pVehicle->m_fHealth);
}
if (m_bVehSpeed)
{
int speed = pPlayer->m_pVehicle->m_vecMoveSpeed.Magnitude() * 50.0f; // 02E3 - GET_CAR_SPEED
ImGui::Text(TEXT("Menu.VehSpeed"), speed);
}
}
ImVec2 windowPos = ImGui::GetWindowPos();
m_fPos = windowPos;
ImGui::End();
}
ImGui::PopStyleColor();
}
}

64
src/overlay.h Normal file
View File

@ -0,0 +1,64 @@
#pragma once
#include <vector>
#include <string.h>
/*
CheatMenu Overlay Class
Handles drawing overlay windows on the screen
This is seprate from the menu window
*/
class Overlay
{
private:
enum DisplayPos
{
CUSTOM,
TOP_LEFT,
TOP_RIGHT,
BOTTOM_LEFT,
BOTTOM_RIGHT
};
static inline std::vector<CEntity*> m_EntityList;
static inline const float m_fMaxDistance = 50.0f;
static inline ImVec2 m_fPos;
static inline int m_nTotalMem = 0;
// Draws model & it's name on screen (peds, objects, vehicles)
static void ProcessModelInfo();
// Processes current ped tasks & draws them ons creen
static void ProcessPedTasks();
// Processes commad bar & commands
static void ProcessCmdBar();
static void ProcessCommands(std::string&& str);
// Displays fps, health, veh speed etc
static void ProcessInfoBox();
public:
static inline bool m_bCmdBar;
static inline bool m_bCoord;
static inline bool m_bCpuUsage;
static inline bool m_bFPS;
static inline int m_nFPS;
static inline bool m_bLocName;
static inline bool m_bMemUsage;
static inline bool m_bModelInfo;
static inline bool m_bPedTasks;
static inline bool m_bTransparent;
static inline bool m_bVehHealth;
static inline bool m_bVehSpeed;
static inline float m_fTextCol[4] = {1.0f, 1.0f, 1.0f, 1.0f};
static inline DisplayPos m_nSelectedPos = DisplayPos::BOTTOM_RIGHT;
Overlay() = delete;
Overlay(Overlay&) = delete;
// Injects necessary hooks into the game
static void Init();
// Draws the actual overlay on screen
static void Draw();
};

View File

@ -61,6 +61,7 @@
#include "resourcestore.h" #include "resourcestore.h"
#include "fontmgr.h" #include "fontmgr.h"
#include "locale.h" #include "locale.h"
#include "util.h"
#define TEXT(x) Locale::GetText(x).c_str() #define TEXT(x) Locale::GetText(x).c_str()
#define TEXT_S(x) Locale::GetText(x) #define TEXT_S(x) Locale::GetText(x)
@ -82,22 +83,9 @@ typedef void(*ArgCallback)(std::string&);
typedef std::string(*ArgCallbackRtn)(std::string&); typedef std::string(*ArgCallbackRtn)(std::string&);
typedef bool(*ArgCallbackRtnBool)(std::string&); typedef bool(*ArgCallbackRtnBool)(std::string&);
// Fix function clashes #ifdef GTASA
static void SetHelpMessage(const char *message, bool b1 = false, bool b2 = false, bool b3 = false) extern const char* taskNames[1802];
{
#if GTASA
CHud::SetHelpMessage(message, b1, b2, b3);
#elif GTAVC
CHud::SetHelpMessage(message, b1, b2);
#else
const size_t size = strlen(message)+1;
wchar_t* wc = new wchar_t[size];
mbstowcs(wc, message, size);
CHud::SetHelpMessage(wc, b1);
delete wc;
#endif #endif
}
extern Hotkey aimSkinChanger; extern Hotkey aimSkinChanger;
extern Hotkey freeCam; extern Hotkey freeCam;
extern Hotkey freeCamForward; extern Hotkey freeCamForward;

View File

@ -94,7 +94,7 @@ void Ped::SpawnPed(std::string& cat, std::string& name, std::string& model)
{ {
if (Spawner::m_List.size() == SPAWN_PED_LIMIT) if (Spawner::m_List.size() == SPAWN_PED_LIMIT)
{ {
SetHelpMessage(TEXT("Ped.MaxLimit")); Util::SetMessage(TEXT("Ped.MaxLimit"));
return; return;
} }
@ -138,7 +138,7 @@ void Ped::SpawnPed(std::string& cat, std::string& name, std::string& model)
if (cat == "Special") // Special model if (cat == "Special") // Special model
{ {
#ifdef GTA3 #ifdef GTA3
SetHelpMessage(TEXT("Player.SpecialNotImplement")); Util::SetMessage(TEXT("Player.SpecialNotImplement"));
return; return;
#else #else
Command<Commands::LOAD_SPECIAL_CHARACTER>(currentSlot, model.c_str()); Command<Commands::LOAD_SPECIAL_CHARACTER>(currentSlot, model.c_str());

View File

@ -255,7 +255,7 @@ void Player::Init()
{ {
if (m_bGodMode) if (m_bGodMode)
{ {
SetHelpMessage(TEXT("Player.GodDisabled")); Util::SetMessage(TEXT("Player.GodDisabled"));
#ifdef GTASA #ifdef GTASA
patch::Set<bool>(0x96916D, m_bGodMode, false); patch::Set<bool>(0x96916D, m_bGodMode, false);
player->m_nPhysicalFlags.bBulletProof = 0; player->m_nPhysicalFlags.bBulletProof = 0;
@ -280,7 +280,7 @@ void Player::Init()
} }
else else
{ {
SetHelpMessage(TEXT("Player.GodEnabled")); Util::SetMessage(TEXT("Player.GodEnabled"));
m_bGodMode = true; m_bGodMode = true;
} }
} }
@ -381,7 +381,7 @@ void Player::ChangePlayerModel(std::string& cat, std::string& key, std::string&
// CStreaming::LoadAllRequestedModels(true); // CStreaming::LoadAllRequestedModels(true);
// player->SetModelIndex(109); // player->SetModelIndex(109);
// CStreaming::SetMissionDoesntRequireSpecialChar(109); // CStreaming::SetMissionDoesntRequireSpecialChar(109);
SetHelpMessage(TEXT("Player.SpecialNotImplement")); Util::SetMessage(TEXT("Player.SpecialNotImplement"));
} }
else else
{ {
@ -411,7 +411,7 @@ void Player::ShowPage()
std::string text = std::to_string(pos.x) + ", " + std::to_string(pos.y) + ", " + std::to_string(pos.z); std::string text = std::to_string(pos.x) + ", " + std::to_string(pos.y) + ", " + std::to_string(pos.z);
ImGui::SetClipboardText(text.c_str()); ImGui::SetClipboardText(text.c_str());
SetHelpMessage(TEXT("Player.CoordCopied")); Util::SetMessage(TEXT("Player.CoordCopied"));
} }
ImGui::SameLine(); ImGui::SameLine();
if (ImGui::Button(TEXT("Player.Suicide"), ImVec2(Widget::CalcSize(2)))) if (ImGui::Button(TEXT("Player.Suicide"), ImVec2(Widget::CalcSize(2))))

1806
src/tasknames.cpp Normal file

File diff suppressed because it is too large Load Diff

View File

@ -138,7 +138,7 @@ void Teleport::WarpPlayer(CVector pos, int interiorID)
tRadarTrace targetBlip = CRadar::ms_RadarTrace[LOWORD(FrontEndMenuManager.m_nTargetBlipIndex)]; tRadarTrace targetBlip = CRadar::ms_RadarTrace[LOWORD(FrontEndMenuManager.m_nTargetBlipIndex)];
if (targetBlip.m_nRadarSprite != RADAR_SPRITE_WAYPOINT) if (targetBlip.m_nRadarSprite != RADAR_SPRITE_WAYPOINT)
{ {
SetHelpMessage(TEXT("Teleport.TargetBlipText")); Util::SetMessage(TEXT("Teleport.TargetBlipText"));
return; return;
} }
pos = targetBlip.m_vecPos; pos = targetBlip.m_vecPos;
@ -209,7 +209,7 @@ void Teleport::WarpPlayer(CVector pos, int interiorID)
if (pVeh && pPlayer->m_pVehicle) if (pVeh && pPlayer->m_pVehicle)
{ {
#ifdef GTAVC #ifdef GTAVC
pPlayer->m_nAreaCode = interior_id; pPlayer->m_nAreaCode = interiorID;
#endif #endif
pVeh->Teleport(pos); pVeh->Teleport(pos);
} }
@ -236,7 +236,7 @@ void Teleport::TeleportToLocation(std::string& rootkey, std::string& bLocName, s
} }
catch (...) catch (...)
{ {
SetHelpMessage(TEXT("Teleport.InvalidLocation")); Util::SetMessage(TEXT("Teleport.InvalidLocation"));
} }
} }
@ -245,12 +245,12 @@ void Teleport::RemoveTeleportEntry(std::string& category, std::string& key, std:
if (category == "Custom") if (category == "Custom")
{ {
m_locData.m_pData->RemoveKey("Custom", key.c_str()); m_locData.m_pData->RemoveKey("Custom", key.c_str());
SetHelpMessage(TEXT("Teleport.LocationRemoved")); Util::SetMessage(TEXT("Teleport.LocationRemoved"));
m_locData.m_pData->Save(); m_locData.m_pData->Save();
} }
else else
{ {
SetHelpMessage(TEXT("Teleport.CustomLocationRemoveOnly")); Util::SetMessage(TEXT("Teleport.CustomLocationRemoveOnly"));
} }
} }
@ -311,7 +311,7 @@ void Teleport::ShowPage()
} }
catch (...) catch (...)
{ {
SetHelpMessage(TEXT("Teleport.InvalidCoord")); Util::SetMessage(TEXT("Teleport.InvalidCoord"));
} }
} }
ImGui::SameLine(); ImGui::SameLine();
@ -323,7 +323,7 @@ void Teleport::ShowPage()
#else #else
if (ImGui::Button(TEXT("Teleport.TeleportCenter"), Widget::CalcSize(2))) if (ImGui::Button(TEXT("Teleport.TeleportCenter"), Widget::CalcSize(2)))
{ {
TeleportPlayer(CVector(0, 0, 23), eTeleportType::Coordinate); WarpPlayer<eTeleportType::Coordinate>(CVector(0, 0, 23));
} }
#endif #endif
ImGui::EndChild(); ImGui::EndChild();

View File

@ -37,7 +37,7 @@ void Updater::Process()
if (res == E_OUTOFMEMORY || res == INET_E_DOWNLOAD_FAILURE) if (res == E_OUTOFMEMORY || res == INET_E_DOWNLOAD_FAILURE)
{ {
SetHelpMessage(TEXT("Updater.Failed")); Util::SetMessage(TEXT("Updater.Failed"));
return; return;
} }
@ -64,12 +64,12 @@ void Updater::Process()
if (latestVer > MENU_VERSION_NUMBER) if (latestVer > MENU_VERSION_NUMBER)
{ {
SetHelpMessage(TEXT("Updater.Found")); Util::SetMessage(TEXT("Updater.Found"));
curState = States::FOUND; curState = States::FOUND;
} }
else else
{ {
SetHelpMessage(TEXT("Updater.NotFound")); Util::SetMessage(TEXT("Updater.NotFound"));
Updater::curState = States::IDLE; Updater::curState = States::IDLE;
} }
} }

View File

@ -3,6 +3,21 @@
#include "psapi.h" #include "psapi.h"
#include <math.h> #include <math.h>
void Util::SetMessage(const char *message, bool b1, bool b2, bool b3)
{
#if GTASA
CHud::SetHelpMessage(message, b1, b2, b3);
#elif GTAVC
CHud::SetHelpMessage(message, b1, b2);
#else
const size_t size = strlen(message)+1;
wchar_t* wc = new wchar_t[size];
mbstowcs(wc, message, size);
CHud::SetHelpMessage(wc, b1);
delete wc;
#endif
}
float Util::RoundFloat(float val) float Util::RoundFloat(float val)
{ {
return roundf(val * 100) / 100; return roundf(val * 100) / 100;

View File

@ -23,7 +23,6 @@ public:
static void ClearCharTasksVehCheck(CPed* ped); static void ClearCharTasksVehCheck(CPed* ped);
static bool IsOnMission(); static bool IsOnMission();
#endif #endif
static void UnFlipVehicle(CVehicle *pVeh); static void UnFlipVehicle(CVehicle *pVeh);
static void FixVehicle(CVehicle *pVeh); static void FixVehicle(CVehicle *pVeh);
static CPed* GetClosestPed(); static CPed* GetClosestPed();
@ -35,5 +34,6 @@ public:
static bool IsInVehicle(CPed *pPed = FindPlayerPed()); static bool IsInVehicle(CPed *pPed = FindPlayerPed());
static void RainbowValues(int& r, int& g, int& b, float speed); static void RainbowValues(int& r, int& g, int& b, float speed);
static void SetCarForwardSpeed(CVehicle *pVeh, float speed); static void SetCarForwardSpeed(CVehicle *pVeh, float speed);
static void SetMessage(const char *message, bool b1 = false, bool b2 = false, bool b3 = false);
static float RoundFloat(float val); static float RoundFloat(float val);
}; };

View File

@ -51,7 +51,7 @@ void Vehicle::Init()
if (fixVeh.Pressed()) if (fixVeh.Pressed())
{ {
Util::FixVehicle(pVeh); Util::FixVehicle(pVeh);
SetHelpMessage("Vehicle fixed"); Util::SetMessage("Vehicle fixed");
} }
if (vehEngine.Pressed()) if (vehEngine.Pressed())
@ -60,11 +60,11 @@ void Vehicle::Init()
if (state) if (state)
{ {
SetHelpMessage("Vehicle engine off"); Util::SetMessage("Vehicle engine off");
} }
else else
{ {
SetHelpMessage("Vehicle engine on"); Util::SetMessage("Vehicle engine on");
} }
#ifdef GTASA #ifdef GTASA
pVeh->m_nVehicleFlags.bEngineBroken = state; pVeh->m_nVehicleFlags.bEngineBroken = state;
@ -215,7 +215,7 @@ void Vehicle::AddComponent(const std::string& component, const bool display_mess
if (display_message) if (display_message)
{ {
SetHelpMessage("Component added"); Util::SetMessage("Component added");
} }
} }
catch (...) catch (...)
@ -237,7 +237,7 @@ void Vehicle::RemoveComponent(const std::string& component, const bool display_m
if (display_message) if (display_message)
{ {
SetHelpMessage("Component removed"); Util::SetMessage("Component removed");
} }
} }
catch (...) catch (...)
@ -272,7 +272,7 @@ int Vehicle::GetRandomTrainIdForModel(int model)
_end = 10; _end = 10;
break; break;
default: default:
SetHelpMessage("Invalid train model"); Util::SetMessage("Invalid train model");
return -1; return -1;
} }
int id = Random(_start, _end); int id = Random(_start, _end);
@ -515,7 +515,7 @@ static void StartAutoDrive(CVehicle *pVeh, const char *buf = nullptr)
pos = targetBlip.m_vecPos; pos = targetBlip.m_vecPos;
if (targetBlip.m_nRadarSprite != RADAR_SPRITE_WAYPOINT) if (targetBlip.m_nRadarSprite != RADAR_SPRITE_WAYPOINT)
{ {
SetHelpMessage(TEXT("Teleport.TargetBlipText")); Util::SetMessage(TEXT("Teleport.TargetBlipText"));
return; return;
} }
#else #else
@ -1128,12 +1128,12 @@ void Vehicle::ShowPage()
} }
else else
{ {
SetHelpMessage(TEXT("Vehicle.InvalidID")); Util::SetMessage(TEXT("Vehicle.InvalidID"));
} }
} }
catch(...) catch(...)
{ {
SetHelpMessage(TEXT("Vehicle.InvalidID")); Util::SetMessage(TEXT("Vehicle.InvalidID"));
} }
} }
#ifdef GTASA #ifdef GTASA
@ -1210,7 +1210,7 @@ void Vehicle::ShowPage()
if (ImGui::Button(TEXT("Vehicle.ResetColor"), ImVec2(Widget::CalcSize()))) if (ImGui::Button(TEXT("Vehicle.ResetColor"), ImVec2(Widget::CalcSize())))
{ {
Paint::ResetNodeColor(veh, PaintData::m_Selected); Paint::ResetNodeColor(veh, PaintData::m_Selected);
SetHelpMessage(TEXT("Vehicle.ResetColorMSG")); Util::SetMessage(TEXT("Vehicle.ResetColorMSG"));
} }
ImGui::Spacing(); ImGui::Spacing();
@ -1281,7 +1281,7 @@ void Vehicle::ShowPage()
if (ImGui::Button(TEXT("Vehicle.RemoveNeon"), ImVec2(Widget::CalcSize()))) if (ImGui::Button(TEXT("Vehicle.RemoveNeon"), ImVec2(Widget::CalcSize())))
{ {
Neon::Remove(veh); Neon::Remove(veh);
SetHelpMessage(TEXT("Vehicle.RemoveNeonMSG")); Util::SetMessage(TEXT("Vehicle.RemoveNeonMSG"));
} }
ImGui::Spacing(); ImGui::Spacing();
@ -1350,7 +1350,7 @@ void Vehicle::ShowPage()
if (ImGui::Button(TEXT("Vehicle.ResetTexture"), ImVec2(Widget::CalcSize()))) if (ImGui::Button(TEXT("Vehicle.ResetTexture"), ImVec2(Widget::CalcSize())))
{ {
Paint::ResetNodeTexture(veh, PaintData::m_Selected); Paint::ResetNodeTexture(veh, PaintData::m_Selected);
SetHelpMessage(TEXT("Vehicle.ResetTextureMSG")); Util::SetMessage(TEXT("Vehicle.ResetTextureMSG"));
} }
ImGui::Spacing(); ImGui::Spacing();
@ -1442,7 +1442,7 @@ void Vehicle::ShowPage()
if (ImGui::Button(TEXT("Vehicle.ResetHandling"), ImVec2(Widget::CalcSize(3)))) if (ImGui::Button(TEXT("Vehicle.ResetHandling"), ImVec2(Widget::CalcSize(3))))
{ {
gHandlingDataMgr.LoadHandlingData(); gHandlingDataMgr.LoadHandlingData();
SetHelpMessage(TEXT("Vehicle.ResetHandlingMSG")); Util::SetMessage(TEXT("Vehicle.ResetHandlingMSG"));
} }
ImGui::SameLine(); ImGui::SameLine();
@ -1450,7 +1450,7 @@ void Vehicle::ShowPage()
if (ImGui::Button(TEXT("Vehicle.SaveFile"), ImVec2(Widget::CalcSize(3)))) if (ImGui::Button(TEXT("Vehicle.SaveFile"), ImVec2(Widget::CalcSize(3))))
{ {
FileHandler::GenerateHandlingFile(pHandlingData, m_VehicleIDE); FileHandler::GenerateHandlingFile(pHandlingData, m_VehicleIDE);
SetHelpMessage(TEXT("Vehicle.SaveFileMSG")); Util::SetMessage(TEXT("Vehicle.SaveFileMSG"));
} }
ImGui::SameLine(); ImGui::SameLine();

View File

@ -4,8 +4,6 @@
#include "util.h" #include "util.h"
#include "game.h" #include "game.h"
#include "timecycle.h" #include "timecycle.h"
#include "CSprite.h"
#include "CFont.h"
#include "CWorld.h" #include "CWorld.h"
#include "vehicle.h" #include "vehicle.h"
@ -158,7 +156,6 @@ void Visual::Init()
m_nBacWeatherType = CWeather::OldWeatherType; m_nBacWeatherType = CWeather::OldWeatherType;
} }
}; };
ShowModelInfo::Init();
} }
template <typename T> template <typename T>
@ -525,103 +522,6 @@ static void ColorPickerAddr(const char* label, int addr, ImVec4&& default_color)
} }
} }
void ShowModelInfo::Init()
{
ThiscallEvent<AddressList<BY_GAME(0x5343B2, 0x48882E, 0x474BC0), H_CALL>, PRIORITY_BEFORE, ArgPickN<CEntity*, 0>, void(CEntity*)> preRenderEntityEvent;
#ifndef GTASA
patch::Nop(BY_GAME(NULL, 0x488828, 0x474BBA), 4);
#endif
// Directly drawing here seems to crash renderer?
preRenderEntityEvent += [](CEntity *pEnt)
{
CPlayerPed *player = FindPlayerPed();
if (m_bEnable)
{
CVector coord = pEnt->GetPosition();
CVector plaPos = player->GetPosition();
CColPoint outColPoint;
if (BY_GAME(pEnt->m_bIsVisible, pEnt->IsVisible(), pEnt->IsVisible()))
{
ShowModelInfo::m_EntityList.push_back(pEnt);
}
}
#ifdef GTAVC
if (CModelInfo::GetModelInfo(pEnt->m_nModelIndex)->m_nNum2dEffects > 0)
{
pEnt->ProcessLightsForEntity();
}
#elif GTA3
// if (CModelInfo::ms_modelInfoPtrs[pEnt->m_nModelIndex]->m_nNum2dEffects > 0)
// {
// pEnt->ProcessLightsForEntity();
// }
#endif
};
}
void ShowModelInfo::Draw()
{
if (m_bEnable)
{
ImGuiWindowFlags flags = ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoMove
| ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoNavFocus
| ImGuiWindowFlags_NoBringToFrontOnFocus | ImGuiWindowFlags_NoFocusOnAppearing;
ImGui::SetNextWindowPos(ImVec2(0, 0));
ImGui::SetNextWindowSize(ImVec2(screen::GetScreenWidth(), screen::GetScreenHeight()));
ImGui::SetNextWindowBgAlpha(0.0f);
if (ImGui::Begin("##Overlay", NULL, flags))
{
ImDrawList *pDrawList = ImGui::GetWindowDrawList();
for (CEntity *pEnt : m_EntityList)
{
CVector coord = BY_GAME(,,*)pEnt->GetBoundCentre();
float distance = DistanceBetweenPoints(coord, FindPlayerPed()->GetPosition());
RwV3d screen;
CVector2D size;
if (distance < m_nDistance &&
#ifdef GTASA
CSprite::CalcScreenCoors(coord.ToRwV3d(), &screen, &size.x, &size.y, true, true)
#else
CSprite::CalcScreenCoors(coord.ToRwV3d(), &screen, &size.x, &size.y, true)
#endif
)
{
bool skip = false;
uint model = pEnt->m_nModelIndex;
std::string text = std::to_string(model);
ImU32 col = ImGui::ColorConvertFloat4ToU32(distance < m_nDistance/2 ? ImVec4(1.0f, 1.0f, 1.0f, 1.00f) : ImVec4(0.35f, 0.33f, 0.3f, 1.00f));
#ifdef GTASA
if (pEnt->m_nType == ENTITY_TYPE_VEHICLE)
{
text = std::format("{}\n{}", model, Vehicle::GetNameFromModel(model));
}
else if (pEnt->m_nType == ENTITY_TYPE_PED)
{
CPed *ped = static_cast<CPed*>(pEnt);
if (BY_GAME(ped->m_nPedFlags.bInVehicle, ped->m_bInVehicle, ped->m_bInVehicle))
{
skip = true;
}
}
#endif
if (!skip)
{
pDrawList->AddText(ImVec2(screen.x, screen.y), col, text.c_str());
}
}
}
m_EntityList.clear();
ImGui::End();
}
}
}
void Visual::ShowPage() void Visual::ShowPage()
{ {
if (ImGui::BeginTabBar("Visual", ImGuiTabBarFlags_NoTooltip + ImGuiTabBarFlags_FittingPolicyScroll)) if (ImGui::BeginTabBar("Visual", ImGuiTabBarFlags_NoTooltip + ImGuiTabBarFlags_FittingPolicyScroll))
@ -803,7 +703,6 @@ void Visual::ShowPage()
plugin::patch::SetRaw(0x6E8580, (char*)"\x51\xD9\x44", 3); plugin::patch::SetRaw(0x6E8580, (char*)"\x51\xD9\x44", 3);
} }
} }
bool radar_state = (patch::Get<BYTE>(0xBA676C) != 2); bool radar_state = (patch::Get<BYTE>(0xBA676C) != 2);
if (Widget::Checkbox(TEXT("Visual.ShowRadar"), &radar_state)) if (Widget::Checkbox(TEXT("Visual.ShowRadar"), &radar_state))
{ {
@ -958,22 +857,6 @@ void Visual::ShowPage()
#endif #endif
if (ImGui::BeginChild("VisualsChild")) if (ImGui::BeginChild("VisualsChild"))
{ {
if(ImGui::CollapsingHeader(TEXT("Visual.ShowModelInfo")))
{
Widget::Checkbox(TEXT("Window.Enabled"), &ShowModelInfo::m_bEnable);
ImGui::Spacing();
if (ImGui::InputInt(TEXT("Visual.Distance"), &ShowModelInfo::m_nDistance))
{
if (ShowModelInfo::m_nDistance < 0.0f)
{
ShowModelInfo::m_nDistance = 0.0f;
}
}
ImGui::Spacing();
ImGui::Separator();
}
#ifdef GTASA #ifdef GTASA
ColorPickerAddr(TEXT("Visual.ArmourbarColor"), *(int*)0x5890FC, ImVec4(225, 225, 225, 255)); ColorPickerAddr(TEXT("Visual.ArmourbarColor"), *(int*)0x5890FC, ImVec4(225, 225, 225, 255));
Widget::EditAddr<float>(TEXT("Visual.ArmourbarPosX"), 0x866B78, -999, 94, 999); Widget::EditAddr<float>(TEXT("Visual.ArmourbarPosX"), 0x866B78, -999, 94, 999);
@ -1041,13 +924,13 @@ void Visual::ShowPage()
if (ImGui::Button(TEXT("Visual.GenerateFile"), Widget::CalcSize(2))) if (ImGui::Button(TEXT("Visual.GenerateFile"), Widget::CalcSize(2)))
{ {
GenerateTimecycFile(); GenerateTimecycFile();
SetHelpMessage(TEXT("Visual.FileGenerated")); Util::SetMessage(TEXT("Visual.FileGenerated"));
} }
ImGui::SameLine(); ImGui::SameLine();
if (ImGui::Button(TEXT("Visual.ResetTimecyc"), Widget::CalcSize(2))) if (ImGui::Button(TEXT("Visual.ResetTimecyc"), Widget::CalcSize(2)))
{ {
CTimeCycle::Initialise(); CTimeCycle::Initialise();
SetHelpMessage(TEXT("Visual.TimecycReset")); Util::SetMessage(TEXT("Visual.TimecycReset"));
} }
ImGui::Spacing(); ImGui::Spacing();

View File

@ -1,24 +1,10 @@
#pragma once #pragma once
#include "pch.h" #include "pch.h"
struct ShowModelInfo
{
private:
static inline std::vector<CEntity*> m_EntityList;
public:
static inline bool m_bEnable;
static inline int m_nDistance = 50.0f;
static void Init();
static void Draw();
};
class Visual class Visual
{ {
private: private:
static inline bool m_bLockWeather; static inline bool m_bLockWeather;
static inline bool m_bModelInfo;
#ifdef GTASA #ifdef GTASA
static inline bool m_bInvisibleWater; static inline bool m_bInvisibleWater;

View File

@ -137,7 +137,7 @@ void Widget::DataList(ResourceStore& data, ArgCallback3 clickFunc, ArgCallback3
{ {
data.m_pData->Set(std::format("Favourites.{}", contextMenu.key).c_str(), contextMenu.val); data.m_pData->Set(std::format("Favourites.{}", contextMenu.key).c_str(), contextMenu.val);
data.m_pData->Save(); data.m_pData->Save();
SetHelpMessage(TEXT("Menu.FavouritesText")); Util::SetMessage(TEXT("Menu.FavouritesText"));
} }
if (contextMenu.func && ImGui::MenuItem(TEXT("Menu.Remove"))) if (contextMenu.func && ImGui::MenuItem(TEXT("Menu.Remove")))
{ {
@ -194,7 +194,7 @@ void Widget::DataList(ResourceStore& data, ArgCallback3 clickFunc, ArgCallback3
{ {
data.m_pData->RemoveKey("Favourites", contextMenu.key.c_str()); data.m_pData->RemoveKey("Favourites", contextMenu.key.c_str());
data.m_pData->Save(); data.m_pData->Save();
SetHelpMessage(TEXT("Menu.FavouritesRemoveText")); Util::SetMessage(TEXT("Menu.FavouritesRemoveText"));
} }
if (ImGui::MenuItem(TEXT("Menu.Close"))) if (ImGui::MenuItem(TEXT("Menu.Close")))
{ {
@ -364,7 +364,7 @@ void Widget::ImageList(ResourceStore &store, ArgCallback clickFunc, ArgCallbackR
{ {
store.m_pData->Set(std::format("Favourites.{}", contextMenu.val).c_str(), contextMenu.key); store.m_pData->Set(std::format("Favourites.{}", contextMenu.val).c_str(), contextMenu.key);
store.m_pData->Save(); store.m_pData->Save();
SetHelpMessage(TEXT("Menu.FavouritesText")); Util::SetMessage(TEXT("Menu.FavouritesText"));
} }
if (ImGui::MenuItem(TEXT("Menu.Close"))) if (ImGui::MenuItem(TEXT("Menu.Close")))
{ {
@ -450,7 +450,7 @@ void Widget::ImageList(ResourceStore &store, ArgCallback clickFunc, ArgCallbackR
{ {
store.m_pData->RemoveKey("Favourites", contextMenu.val.c_str()); store.m_pData->RemoveKey("Favourites", contextMenu.val.c_str());
store.m_pData->Save(); store.m_pData->Save();
SetHelpMessage(TEXT("Menu.FavouritesRemoveText")); Util::SetMessage(TEXT("Menu.FavouritesRemoveText"));
} }
if (ImGui::MenuItem(TEXT("Menu.Close"))) if (ImGui::MenuItem(TEXT("Menu.Close")))
{ {