Replicate some ReVC functions I have created for testing.

Add link for imgui demo I used, move some preprocessors.
Update gitignore and project files.
This commit is contained in:
kelson8 2025-03-13 06:23:10 -04:00
parent afd62ebc5f
commit affa0dbe3f
7 changed files with 183 additions and 7 deletions

1
.gitignore vendored
View File

@ -1,6 +1,7 @@
# Added by kelson8 # Added by kelson8
Main - Copy.cpp Main - Copy.cpp
old/** old/**
asm/
# ---> C++ # ---> C++
# Prerequisites # Prerequisites

View File

@ -180,8 +180,8 @@
<PreprocessorDefinitions>_DEBUG;_CONSOLE;_OPENGL;%(PreprocessorDefinitions)</PreprocessorDefinitions> <PreprocessorDefinitions>_DEBUG;_CONSOLE;_OPENGL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode> <ConformanceMode>true</ConformanceMode>
<LanguageStandard>stdcpplatest</LanguageStandard> <LanguageStandard>stdcpplatest</LanguageStandard>
<AdditionalIncludeDirectories>lib\imgui\;lib\imgui\backends;include\;.\src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <AdditionalIncludeDirectories>lib\imgui\;lib\imgui\backends;include\;.\src;.\src\util;.\src\functions;.\src\menus;.\src\test;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<LanguageStandard_C>stdc17</LanguageStandard_C> <LanguageStandard_C>stdclatest</LanguageStandard_C>
<AssemblerOutput>AssemblyCode</AssemblerOutput> <AssemblerOutput>AssemblyCode</AssemblerOutput>
<AssemblerListingLocation>$(SolutionDir)asm\</AssemblerListingLocation> <AssemblerListingLocation>$(SolutionDir)asm\</AssemblerListingLocation>
</ClCompile> </ClCompile>

View File

@ -37,6 +37,8 @@
// Boolean values // Boolean values
// DirectX9Test // DirectX9Test
// TODO Make this file compatible with DirectX9 and OpenGL.
#ifdef _DIRECTX9
bool DirectX9Test::show_demo_window = false; bool DirectX9Test::show_demo_window = false;
bool DirectX9Test::button1_clicked = false; bool DirectX9Test::button1_clicked = false;
bool DirectX9Test::show_app_main_menu_bar = false; bool DirectX9Test::show_app_main_menu_bar = false;
@ -415,3 +417,4 @@ void MainMenu::MainMenuTest() {
//} //}
} }
#endif

View File

@ -22,8 +22,16 @@ bool showMainMenuBar = false;
bool pedsEnabled = true; bool pedsEnabled = true;
bool vehiclesEnabled = true; bool vehiclesEnabled = true;
bool neverWanted = false;
// Vehicle
bool infiniteHealth = false;
bool highVehicleMass = false;
bool vehicleInvincible = false;
int vehicleMin = 130; int vehicleMin = 130;
// Test for code in here.
int wantedLevel = 0;
enum Vehicles { enum Vehicles {
Rhino = 0, Rhino = 0,
@ -31,6 +39,95 @@ enum Vehicles {
Infernus = 2 Infernus = 2
}; };
/// <summary>
/// Toggle infinite health, moved out of main menu
/// and refactored the checkbox to be under an if statement.
/// </summary>
void
toggleInfiniteHealth()
{
if (infiniteHealth) {
std::cout << "Infinite health enabled" << std::endl;
}
else {
std::cout << "Infinite health disabled" << std::endl;
}
}
void
toggleVehicleInvincible()
{
//CPlayerPed* pPed = FindPlayerPed();
//VehicleFunctions vehicleFunctions = VehicleFunctions();
//if (vehicleFunctions.IsPlayerInVehicle()) {
//CVehicle* currentVeh = pPed->m_pMyVehicle;
if (vehicleInvincible) {
std::cout << "Vehicle invincibility enabled" << std::endl;
//VehicleCheats::EnableVehicleInvincibility(currentVeh);
}
else {
std::cout << "Vehicle invincibility disabled" << std::endl;
//VehicleCheats::DisableVehicleInvincibility(currentVeh);
}
//}
}
/// <summary>
/// Well, I created a bug with the high mass. I made a fun effect
/// TODO Figure out how to reset this back to default
/// TODO Figure out how to get these values from lua... Use my lua_test.cpp
/// This is fun, although it does crash after a minute since I can't turn it off.
/// </summary>
void
toggleHighVehicleMass()
{
// This makes the vehicle super strong
float vehicleMass = 30000.0f;
// Well I created the spinny effect but sadly it crashes after a minute.
// This creates the spinny effect like from the reddit post I saw.
float vehicleTurnMass = 4.0f;
//VehicleFunctions vehicleFunctions = VehicleFunctions();
//if (vehicleFunctions.IsPlayerInVehicle()) {
//CVehicle* currentVeh = pPed->m_pMyVehicle;
if (highVehicleMass)
{
std::cout << "Vehicle mass set to " << vehicleMass << std::endl;
std::cout << "Vehicle turn mass set to " << vehicleTurnMass << std::endl;
//currentVeh->m_fMass = 10000000.0f;
//currentVeh->m_fMass = 10000.0f;
// This makes the vehicle super strong
//currentVeh->m_fMass = vehicleMass;
// Spinny effect
//currentVeh->m_fTurnMass = vehicleTurnMass;
}
//}
}
void toggleNeverWanted()
{
//neverWanted = !neverWanted;
if (neverWanted) {
std::cout << "Never wanted enabled" << std::endl;
}
else {
std::cout << "Never wanted disabled" << std::endl;
}
}
void VC::Menus::MainMenu() void VC::Menus::MainMenu()
{ {
@ -56,6 +153,12 @@ void VC::Menus::MainMenu()
//PlayerCheats::SuicideCheat(); //PlayerCheats::SuicideCheat();
} }
if (ImGui::Checkbox("Infinite health", &infiniteHealth)) {
toggleInfiniteHealth();
}
// TODO Come up with a solution for this. // TODO Come up with a solution for this.
// Possibly use ImGui::ListBox, need to test it some more and mess around with it. // Possibly use ImGui::ListBox, need to test it some more and mess around with it.
//ImGui::Text("Warps"); //ImGui::Text("Warps");
@ -120,10 +223,33 @@ void VC::Menus::MainMenu()
ImGui::EndListBox(); ImGui::EndListBox();
} }
} }
// ReVC specific functions that I have created.
if (ImGui::Button("Spawn Vehicle")) {
if (spawnInCar) {
std::cout << "Cheetah spawned, removed old vehicle and warped player into it." << std::endl;
//VehicleFunctions::SpawnVehicle(VehicleModels::CHEETAH, true, true);
}
else {
std::cout << "Cheetah spawned." << std::endl;
//VehicleFunctions::SpawnVehicle(VehicleModels::CHEETAH, false, false);
}
}
if (ImGui::Checkbox("Toggle high mass", &highVehicleMass)) {
toggleHighVehicleMass();
}
if (ImGui::Checkbox("Toggle invincibility", &vehicleInvincible)) {
toggleVehicleInvincible();
}
// //
// Moved to above // Moved to above, this is the original function
//if (showVehicleListBox) //if (showVehicleListBox)
//{ //{
// ImGui::ListBox("Vehicles", &currentItem, vehicles, 3); // ImGui::ListBox("Vehicles", &currentItem, vehicles, 3);
@ -151,6 +277,43 @@ void VC::Menus::MainMenu()
std::cout << "Weapon set 3 given" << std::endl; std::cout << "Weapon set 3 given" << std::endl;
} }
// Police cheats
ImGui::Text("Police");
if (ImGui::Button("Raise Wanted Level")) {
//PlayerCheats::RaiseWantedLevel();
if (wantedLevel < 1 || wantedLevel > 6) {
std::cout << "Error, wanted level cannot be less then 1 or more then 6" << std::endl;
}
else {
wantedLevel++;
std::cout << "Wanted level raised by 1, new wanted level: " << wantedLevel << std::endl;
}
std::cout << "Wanted level raised by 1, new wanted level: " << wantedLevel << std::endl;
}
if (ImGui::Button("Lower Wanted Level")) {
//PlayerCheats::LowerWantedLevel();
if (wantedLevel < 1 || wantedLevel > 6) {
std::cout << "Error, wanted level cannot be less then 1 or more then 6" << std::endl;
}
else {
wantedLevel--;
std::cout << "Wanted level lowered by 1, new wanted level: " << wantedLevel << std::endl;
}
}
//ImGui::Checkbox("Never wanted", &neverWanted);
if (ImGui::Checkbox("Never wanted", &neverWanted)) {
toggleNeverWanted();
}
//
// These two below mimic the change that happens in ReVC with my ImGui menu. // These two below mimic the change that happens in ReVC with my ImGui menu.
if (ImGui::Button("Toggle peds")) { if (ImGui::Button("Toggle peds")) {
pedsEnabled = !pedsEnabled; pedsEnabled = !pedsEnabled;

View File

@ -5,6 +5,7 @@
#endif #endif
// //
// TODO Fix this to work in the OpenGL test
#ifdef _WIN32 #ifdef _WIN32
class Defines { class Defines {
private: private:

View File

@ -19,6 +19,13 @@
#ifdef _TEST #ifdef _TEST
// Dear ImGui: standalone example application for DirectX 9 // Dear ImGui: standalone example application for DirectX 9
// Modified by kelson8, now mostly everything is separated into it's own file to make this cleaner.
// I have moved most imgui functions into imgui_functions.cpp, and most Directx stuff into helpers.cpp.
// Most of this code came from the example here:
// https://github.com/ocornut/imgui/blob/master/examples/example_win32_directx9/main.cpp
// You can use that example above for an ImGui base like I did in this project.
// Learn about Dear ImGui: // Learn about Dear ImGui:
// - FAQ https://dearimgui.com/faq // - FAQ https://dearimgui.com/faq
// - Getting Started https://dearimgui.com/getting-started // - Getting Started https://dearimgui.com/getting-started

View File

@ -2,11 +2,9 @@
#ifdef _WIN32 #ifdef _WIN32
#include <Windows.h> #include <Windows.h>
#ifdef _DIRECTX9 #ifdef _DIRECTX9
#include <d3d9.h> #include <d3d9.h>
#endif
#endif
class DirectX9Test { class DirectX9Test {
public: public:
@ -30,4 +28,7 @@ public:
static LPDIRECT3DDEVICE9 g_pd3dDevice; static LPDIRECT3DDEVICE9 g_pd3dDevice;
static UINT g_ResizeWidth, g_ResizeHeight; static UINT g_ResizeWidth, g_ResizeHeight;
static D3DPRESENT_PARAMETERS g_d3dpp; static D3DPRESENT_PARAMETERS g_d3dpp;
}; };
#endif // _DIRECTX9
#endif //_WIN32