Add radio test, reorganze code, make menus mostly not static.

Add more seperators for ImGui, remove extra code.
Add Train testing and radio testing, add corona test.
This commit is contained in:
kelson8 2024-06-17 12:46:16 -04:00
parent 8f469d1c9e
commit c3f56a3c25
Signed by: kelson8
GPG Key ID: 3D738D9DD7239E13
3 changed files with 220 additions and 258 deletions

View File

@ -18,10 +18,22 @@
https://github.com/user-grinch/Cheat-Menu
*/
// TODO Figure out how to get the coordniates of where the player is looking at, I think that should be possible.
// TODO Try to get this working on VC and 3 sometime, the menu normally works on those games I would just have to make sure I don't have any SA specific
// memory addresses or anything in it.
// Well this was working with the Visual Studio 2022 debugger now it says cannot find gta_sa.exe or gta-vc.exe.
// It still seems to work if I launch the games directly though.
// 6-17-2024 @ 2:51AM
// I fixed it to work with the Visual Studio 2022 debugger again
// Useful functions:
// Force all cars to be the specified model: https://library.sannybuilder.com/#/sa/default/09BF
// Set ped density multiplier: https://library.sannybuilder.com/#/sa/default/03DE
// Set ped vehicle multipler: https://library.sannybuilder.com/#/sa/default/01EB
//
#ifdef GTASA
#include "CExplosion.h"
// New
@ -48,6 +60,13 @@
#include "CGame.h"
#include "CWaterLevel.h"
#include "CWeather.h"
// Radio Test
#include "CAERadioTrackManager.h"
#include "CAudioEngine.h"
// I can disable the radio and change its type using this
#include "CAEVehicleAudioEntity.h"
#endif
#define _TEST
@ -67,11 +86,13 @@
#include "test_hud.h"
#include "test_ped.h"
#include "test_world.h"
#include "player_functions.h"
// Well I had this working but then broke it 6-14-2024 @ 3:51PM...
// I fixed it 3:53PM.
// TODO Fix this to use translations from the English.toml file instead of hardcoding the values.
// TODO Seperate these out into multiple tabs within my test tab, so have a Player, Vehicle, Sounds, World, Misc, Test Features and more tabs.
TestPage& testPage = TestPage::Get();
TestPage::TestPage()
@ -79,7 +100,10 @@ TestPage::TestPage()
}
// Booleans
bool test = false;
bool enterCrane = false;
bool toggleRadio = true;
//void TestPage::PlayerTest() {
// CPlayerPed* player = FindPlayerPed();
@ -88,6 +112,27 @@ TestPage::TestPage()
//}
/// <summary>
/// Train test functions.
/// </summary>
static void TrainTestMenu()
{
ImGui::Text("Train testing.");
// This works.
if (ImGui::Button("Are you in a train?"))
{
if (PlayerFunctions::IsPlayerInTrain())
{
Util::SetMessage("You are in a train.");
}
else
{
Util::SetMessage("You are not in a train.");
}
}
}
void PlayerTestFeatures()
{
CPlayerPed* player = FindPlayerPed();
@ -124,24 +169,41 @@ void PlayerTestFeatures()
CVector pos = player->GetPosition();
}
bool test = false;
bool enterCrane = false;
void TestPage::Draw()
{
// I am testing moving everything from static to not using static.
#ifdef _TEST
// Init for the menu
WorldTestPage* worldTestPage = new WorldTestPage();
HudTestPage* hudTestPage = new HudTestPage();
PedTestPage* pedTestPage = new PedTestPage();
VehicleTestPage* vehicleTestPage = new VehicleTestPage();
// Misc items
#ifdef GTASA
CAERadioTrackManager* cAERadioTrackManager = new CAERadioTrackManager();
CAudioEngine* cAudioEngine = new CAudioEngine();
CAEVehicleAudioEntity* cAEVehicleAudioEntity = new CAEVehicleAudioEntity();
#endif // GTASA
#endif //_TEST
CPlayerPed* player = FindPlayerPed();
//ImGui::BeginChild("Test");
// Test
ImGui::Text("Hello from KCNet");
if (ImGui::BeginTabBar("Test", ImGuiTabBarFlags_NoTooltip + ImGuiTabBarFlags_FittingPolicyScroll))
{
ImGui::Separator();
if (ImGui::BeginTabItem(TEXT("Test.TestVehicle")))
{
// This works for seperating out the menus!
// 6-15-2024 @ 2:05PM
ImGui::Text("Hello from KCNet");
//ImGui::Text("Hello from KCNet");
ImGui::Text("Vehicle Tab");
VehicleTestPage::VehicleTestMenu();
//static int selected = Locale::GetCurrentLocaleIndex();
//static std::vector<std::string>& vec = Locale::GetLocaleList();
vehicleTestPage->VehicleTestMenu();
ImGui::EndTabItem();
}
@ -149,7 +211,12 @@ void TestPage::Draw()
if (ImGui::BeginTabItem("Player"))
{
// Incomplete
#ifdef _TEST
pedTestPage->PlayerTestMenu();
#else
PedTestPage::PlayerTestMenu();
#endif //_TEST
// This is needed, I think it should fix a crash.
ImGui::EndTabItem();
@ -159,45 +226,6 @@ void TestPage::Draw()
{
// Incomplete
/*PedTestPage::PlayerTestMenu();*/
//
//if (ImGui::Button("Suicide"))
//{
// //CPlayerPed* player = FindPlayerPed();
// int hplayer = CPools::GetPedRef(player);
// Command<Commands::EXPLODE_CHAR_HEAD>(hplayer);
//}
//if (ImGui::Button("Bomb")) {
// CPlayerPed* player = FindPlayerPed();
// int hplayer = CPools::GetPedRef(player);
// CVector playerPos = player->GetPosition();
// // https://library.sannybuilder.com/#/sa/default/020C
// // x, y, z, EXPLOSION_CAR
// Command<Commands::ADD_EXPLOSION>(playerPos.x, playerPos.y, playerPos.z, EXPLOSION_CAR);
//}
//if (ImGui::Button("Show coords"))
//{
// CVector playerCoords = player->GetPosition();
// //std::string text = std::to_string(pos.x) + ", " + std::to_string(pos.y) + ", " + std::to_string(pos.z);
// //int playerX = playerCoords.x;
// //int playerY = playerCoords.y;
// //int playerZ = playerCoords.z;
// std::string playerX = std::to_string(playerCoords.x);
// std::string playerY = std::to_string(playerCoords.y);
// std::string playerZ = std::to_string(playerCoords.z);
// // This works for showing just the X coord, I cannot concatenate these values though
// //Util::SetMessage(playerXChar);
// // Taken idea from freecam_sa.cpp on line 156
// // This works!!
// // 6-14-2024 @ 2:34PM
// Util::SetMessage(std::format("X: {} Y: {} Z: {}", playerX, playerY, playerZ).c_str());
// //Util::SetMessage("X: " + playerXChar + " Y: " + playerYChar + " Z: " + playerZChar);
//}
//if (ImGui::Button("Show Marker Coords"))
//{
@ -244,30 +272,11 @@ void TestPage::Draw()
}
ImGui::Separator();
// Not sure how this one works
//CCheckpoints::PlaceMarker();
//if (ImGui::Button("Create Checkpoint"))
//{
//}
//ImGui::SameLine();
//ImGui::Text("Doesn't work!");
//if (ImGui::Button("Remove checkpoint"))
//{
//
//}
//ImGui::SameLine();
//ImGui::Text("Doesn't work!");
// Hud functions
HudTestPage::HudTestMenu();
// Not sure how these work.
// https://library.sannybuilder.com/#/sa/classes/Crane
if (ImGui::Checkbox("Enter Crane", &enterCrane))
{
if(enterCrane)
if (enterCrane)
{
// https://library.sannybuilder.com/#/sa/default/079D
Command<Commands::PLAYER_ENTERED_DOCK_CRANE>();
@ -287,201 +296,76 @@ void TestPage::Draw()
//bool isFlyingActive = CCheat::m_aCheatsActive);
//Util::SetMessage(std::format("Is Flying Active: {}", isFlyingActive).c_str());
}
// Move into vehicle functions.
if (ImGui::Button("Current Radio Station"))
{
int hplayer = CPools::GetPedRef(player);
CVehicle* pVeh = nullptr;
bool bInVehicle = Command<Commands::IS_CHAR_IN_ANY_CAR>(hplayer);
if (bInVehicle) {
CVehicle* pVeh = player->m_pVehicle;
if (cAERadioTrackManager->IsVehicleRadioActive())
{
// How would I set this to get the current radio station?
// I'll just use the command version of it for now instead of the cAERadioTrackManager
// Wow this works fine, I noticed the method was using char* so I decided to put it into it's own field.
const char* currentRadioStationName = cAERadioTrackManager->GetRadioStationName(cAudioEngine->GetCurrentRadioStationID());
//int radioChannel = 0;
//Command<Commands::GET_RADIO_CHANNEL>();
//Util::SetMessage(cAERadioTrackManager->GetRadioStationName(Command<Commands::GET_RADIO_CHANNEL>()));
// This works!! I figured it out
// 6-17-2024 @ 12:27AM
//Util::SetMessage(cAERadioTrackManager->GetRadioStationName(cAudioEngine->GetCurrentRadioStationID()));
Util::SetMessage(currentRadioStationName);
//
}
}
}
//////
// New
ImGui::Separator();
TrainTestMenu();
//////
// Clothes
// World functions
WorldTestPage::WorldTestMenu();
#endif
//#ifdef GTASA
// // Weather
// // Will these work?
//
// int defaultWeatherType;
// //eWeatherType defaultWeatherType = WEATHER_CLOUDY_COUNTRYSIDE;
// //std::string defaultWeatherType = "WEATHER_CLOUDY_COUNTRYSIDE";
//
// //static std::vector<eWeatherType> cloudyWeatherTypes = {
// // WEATHER_CLOUDY_COUNTRYSIDE, WEATHER_CLOUDY_LA, WEATHER_CLOUDY_SF,
// // WEATHER_CLOUDY_VEGAS
// //};
//
// static std::vector<std::string> allWeatherTypes = {
// "Extra Sunny LA", "Sunny LA", "Smog LA", "Sunny Smog LA",
// "Cloudy LA", "Sunny SF", "Extra Sunny SF", "Cloudy SF", "Rainy SF",
// "Foggy SF", "Sunny LV", "Cloudy LV", "Extra Sunny Countryside", "Cloudy Countryside",
// "Rainy Countryside", "Extra Sunny Desert", "Sunny Desert", "Sandstorm Desert",
// "Underwater", "Extra Colors 1", "Extra Colors 2"
//
// //"WEATHER_EXTRASUNNY_COUNTRYSIDE", "WEATHER_EXTRASUNNY_SMOG_LA", "WEATHER_EXTRASUNNY_SMOG_LA",
// //"WEATHER_EXTRASUNNY_VEGAS", "WEATHER_EXTRACOLOURS_1", "WEATHER_EXTRACOLOURS_2",
// //"WEATHER_RAINY_COUNTRYSIDE", "WEATHER_RAINY_SF", "WEATHER_FOGGY_SF",
// //"WEATHER_REGION_DEFAULT", "WEATHER_REGION_DESERT",
// //"WEATHER_REGION_LA", "WEATHER_REGION_LV", "WEATHER_REGION_SF",
// };
//
// static std::vector<std::string> cloudyWeatherTypes = {
// "WEATHER_CLOUDY_COUNTRYSIDE", "WEATHER_CLOUDY_LA", "WEATHER_CLOUDY_SF",
// "WEATHER_CLOUDY_VEGAS", "WEATHER_EXTRASUNNY_LA", "WEATHER_EXTRASUNNY_DESERT", "WEATHER_EXTRASUNNY_LA",
// "WEATHER_EXTRASUNNY_COUNTRYSIDE", "WEATHER_EXTRASUNNY_SMOG_LA", "WEATHER_EXTRASUNNY_SMOG_LA",
// "WEATHER_EXTRASUNNY_VEGAS", "WEATHER_EXTRACOLOURS_1", "WEATHER_EXTRACOLOURS_2"
// };
//
// static std::vector<eWeatherType> sunnyWeatherTypes = {
// WEATHER_EXTRASUNNY_LA, WEATHER_EXTRASUNNY_DESERT, WEATHER_EXTRASUNNY_LA,
// WEATHER_EXTRASUNNY_COUNTRYSIDE, WEATHER_EXTRASUNNY_SMOG_LA, WEATHER_EXTRASUNNY_SMOG_LA,
// WEATHER_EXTRASUNNY_VEGAS, WEATHER_EXTRACOLOURS_1, WEATHER_EXTRACOLOURS_2
// };
//
// static std::vector<eWeatherType> rainyWeatherTypes = {
// WEATHER_RAINY_COUNTRYSIDE, WEATHER_RAINY_SF,
// };
//
// //static std::vector<eWeatherType> otherWeatherTypes = {
// // WEATHER_FOGGY_SF, WEATHER_REGION_DEFAULT, WEATHER_REGION_DESERT,
// // WEATHER_REGION_LA, WEATHER_REGION_LV, WEATHER_REGION_SF,
// //};
//
// //
//
//
//
// // TODO Setup to where this sets the Las Venturas weather instaed of the LA weather in the Los Venturas area.
// // TODO Setup drop down menu for this.
// // Get players current zone if possible, I know it's in the code somewhere.
// ImGui::Separator();
// ImGui::Text("Weather");
//
// if (ImGui::Button("Rain")) {
// // Will this work?
// CWeather::ForceWeatherNow(WEATHER_RAINY_COUNTRYSIDE);
// Util::SetMessage("Weather set to rain.");
// }
//
// if (ImGui::Button("Clear")) {
// // Will this work?
// CWeather::ForceWeatherNow(WEATHER_EXTRASUNNY_LA);
// Util::SetMessage("Weather set to rain.");
// }
//
// // This seems to work but the weather types aren't the right ones that I have listed.
// // They are out of order.
// //if (ImGui::Combo("Cloudy Weather", &defaultWeatherType, cloudyWeatherTypes))
// if (Widget::ListBox("Cloudy Weather", allWeatherTypes, defaultWeatherType))
// {
// CWeather::ForceWeatherNow(defaultWeatherType);
// }
//
// //if (ImGui::Combo("Cloudy Weather", &defaultWeatherType, cloudyWeatherTypes))
// {
// // How would I store the value for this?
// //CWeather::ForceWeatherNow();
// }
//
//#endif //GTASA
ImGui::EndTabItem();
}
//ImGui::EndChild();
ImGui::EndTabBar();
}
}
// This doesn't do anything yet, I would like to add a custom tab to the Cheat menu
// Hud menu and Hud functions.
// Comment out this define if this crashes.
#ifdef _TEST
if (ImGui::BeginTabItem("Hud")) {
hudTestPage->HudTestMenu();
ImGui::EndTabItem();
}
#else
HudTestPage::HudTestMenu();
#endif //_TEST
#ifdef _DISABLED_CODE
// These weren't needed, leaving here for future reference.
// //////////////
// https://www.geeksforgeeks.org/convert-string-char-array-cpp/
//const char* playerXChar = playerX.c_str();
//const char* playerYChar = playerY.c_str();
//const char* playerZChar = playerZ.c_str();
//const char* playerXTest = static_cast<char>(char_array);
// World Menu & World Functions
#ifdef _TEST
//https://www.tutorialspoint.com/How-to-convert-an-std-string-to-const-char-or-char-in-Cplusplus
//const char* test = new char[playerCoords.x];
//
//https://cplusplus.com/forum/general/268793/
//const char* s = new[std::strlen(playerXChar) + std::strlen(playerYChar) + 1];
//https://stackoverflow.com/questions/347949/how-to-convert-a-stdstring-to-const-char-or-char
//
//const char* playerMessage = std::to_string(playerCoords.x) + ", " + std::to_string(playerCoords.y) + ", " + std::to_string(playerCoords.z);
//const char* playerMessage = std::to_string(playerXChar) + ", " + std::to_string(playerCoords.y) + ", " + std::to_string(playerCoords.z);
//const char* playerMessage(test);
//Util::SetMessage("X: " + *playerXChar);
//Util::SetMessage(std::to_string(playerCoords.x));
//Util::SetMessage(playerMessage);
//////////////////
// Old
/*
if (ImGui::BeginTabBar("Test", ImGuiTabBarFlags_NoTooltip + ImGuiTabBarFlags_FittingPolicyScroll))
{
if (ImGui::BeginTabItem(TEXT("Test.TestVehicle")))
{
ImGui::Text("Vehicle Tab");
//static int selected = Locale::GetCurrentLocaleIndex();
//static std::vector<std::string>& vec = Locale::GetLocaleList();
ImGui::Text("Hello from KCNet");
//}
ImGui::EndTabItem();
if (ImGui::BeginTabItem("World")) {
worldTestPage->WorldTestMenu();
ImGui::EndTabItem();
// Use original code.
#else
WorldTestPage::WorldTestMenu();
#endif //TEST
}
ImGui::EndTabBar();
}
if (ImGui::BeginTabItem(TEXT("Test.TestFeatures")))
{
ImGui::Text("Test Features");
// ImGui::Text("Test Features");
// //if (ImGui::BeginChild("CommandsChild"))
// //{
// // ImGui::Text("Hello from KCNet");
// // //
// // //if (ImGui::CollapsingHeader(TEXT("Menu.QuickVehSpawnerCMD")))
// // //{
// // // ImGui::Spacing();
// // // ImGui::TextWrapped(TEXT("Menu.QuickVehSpawnerCMDText"));
// // // ImGui::Spacing();
// // // ImGui::Separator();
// // //}
// // //if (ImGui::CollapsingHeader(TEXT("Menu.QuickWepSpawnerCMD")))
// // //{
// // // ImGui::Spacing();
// // // ImGui::TextWrapped(TEXT("Menu.QuickWepSpawnerCMDText"));
// // // ImGui::Spacing();
// // // ImGui::Separator();
//}
// // //
ImGui::EndChild();
ImGui::EndTabItem();
ImGui::EndTabBar();
}
*/
//}
// Get config data
/*
Events::initGameEvent += [this]()
{
};
*/
#endif //_DISABLED_CODE
}
#endif //_TEST

View File

@ -2,11 +2,23 @@
#include "test_world.h"
#include "utils/widget.h"
#ifdef GTASA
#include "CCoronas.h"
#include "CGeneral.h"
#endif //GTASA
// This is needed so it doesn't get unresvoled external symbol errors without using static.
WorldTestPage::WorldTestPage()
{
}
void WeatherMenu()
{
// Weather
// Will these work?
#ifdef GTASA
// Will giving this a default value fix the crashing? I think the weather is crashing it.
int defaultWeatherType = 0;
//eWeatherType defaultWeatherType = WEATHER_CLOUDY_COUNTRYSIDE;
@ -17,6 +29,7 @@ void WeatherMenu()
// WEATHER_CLOUDY_VEGAS
//};
static std::vector<std::string> allWeatherTypes = {
"Extra Sunny LA", "Sunny LA", "Smog LA", "Sunny Smog LA",
"Cloudy LA", "Sunny SF", "Extra Sunny SF", "Cloudy SF", "Rainy SF",
@ -89,6 +102,7 @@ void WeatherMenu()
// How would I store the value for this?
//CWeather::ForceWeatherNow();
}
#endif //GTASA
}
static void CreateCheckpointMenu()
@ -115,8 +129,69 @@ static void RemoveCheckpointMenu()
void CreateCoronaTestMenu()
{
CPlayerPed* player = FindPlayerPed();
CVector playerCoords = player->GetPosition();
// Obtained from Entity.cpp on lines 580-602 in the Reversed gta sa project.
// This doesn't work at all.
#ifdef _TEST
//auto fRand = static_cast<float>(CGeneral::GetRandomNumberInRange() % 16) / 16.0F;
// CVector vecPos = CPlaceable::GetPosition();
//fRand = std::max(fRand, 0.5F);
int fRand = rand();
CCoronas::RegisterCorona(
// Idk how to use this.
reinterpret_cast<uint32_t>(this),
nullptr,
static_cast<uint8_t>(fRand * 255.0F),
static_cast<uint8_t>(fRand * 220.0F),
static_cast<uint8_t>(fRand * 190.0F),
255,
playerCoords,
fRand * 6.0F,
300.0F,
gpCoronaTexture[0],
eCoronaFlareType::FLARETYPE_NONE,
true,
false,
0,
0.0F,
false,
1.5F,
0,
15.0F,
false,
false
);
#endif //_TEST
}
static void RemoveCoronaTestMenu()
{
}
/// <summary>
/// Main code for WorldTestMenu
/// </summary>
void WorldTestPage::WorldTestMenu()
{
// This doesn't seem to crash it being empty in here.
Events::initScriptsEvent += [this]()
{
};
/*
Events::processScriptsEvent += [this]()
{
};
*/
/*
Refactor these to have the tabs in each file instead of in the test.cpp file
// TEXT(Test.TestWorldMenu) - Test World Menu

View File

@ -4,9 +4,12 @@
class WorldTestPage
{
private:
WorldTestPage();
WorldTestPage(const WorldTestPage&);
void Draw();
public:
static void WorldTestMenu();
// I had to change these two values to public for this to work, even though they arent in use.
WorldTestPage();
WorldTestPage(const WorldTestPage&);
//
//static void WorldTestMenu();
void WorldTestMenu();
};