Added vehicles menu (vc) and improvements

This commit is contained in:
Grinch_ 2021-08-13 09:28:19 +06:00
parent 916eed8556
commit 45f033f2d2
28 changed files with 485 additions and 420 deletions

View File

@ -6,21 +6,20 @@
Animation::Animation()
{
m_AnimData.m_Json.LoadData(m_AnimData.m_Categories, m_AnimData.m_Selected);
m_Cutscene::m_Data.m_Json.LoadData(m_Cutscene::m_Data.m_Categories, m_Cutscene::m_Data.m_Selected);
Events::processScriptsEvent += [this]
{
if (m_Cutscene::m_bRunning)
{
if (Command<Commands::HAS_CUTSCENE_FINISHED>())
{
Command<Commands::CLEAR_CUTSCENE>();
m_Cutscene::m_bRunning = false;
m_Cutscene::m_SceneName = "";
CPlayerPed* player = FindPlayerPed();
player->m_nAreaCode = m_Cutscene::m_nInterior;
Command<Commands::SET_AREA_VISIBLE>(player->m_nAreaCode);
CPlayerPed* pPlayer = FindPlayerPed();
if (!pPlayer)
{
return;
}
pPlayer->m_nAreaCode = m_Cutscene::m_nInterior;
Command<Commands::SET_AREA_VISIBLE>(pPlayer->m_nAreaCode);
m_Cutscene::m_nInterior = 0;
TheCamera.Fade(0, 1);
}
@ -43,10 +42,14 @@ void Animation::PlayCutscene(std::string& rootKey, std::string& cutsceneId, std:
SetHelpMessage("Another cutscene is running", false, false, false);
return;
}
CPlayerPed* pPlayer = FindPlayerPed();
if (!pPlayer)
{
return;
}
m_Cutscene::m_SceneName = cutsceneId;
Command<Commands::LOAD_CUTSCENE>(cutsceneId.c_str());
CPlayerPed* pPlayer = FindPlayerPed();
m_Cutscene::m_nInterior = pPlayer->m_nAreaCode;
pPlayer->m_nAreaCode = std::stoi(interior);
Command<Commands::SET_AREA_VISIBLE>(pPlayer->m_nAreaCode);
@ -68,7 +71,9 @@ void Animation::Draw()
if (ImGui::Button("Stop animation", Ui::GetSize()))
{
if (hPlayer)
{
Command<Commands::CLEAR_CHAR_TASKS>(hPlayer);
}
}
ImGui::Spacing();
@ -126,8 +131,8 @@ void Animation::Draw()
ImGui::Spacing();
if (ImGui::Button("Add animation", Ui::GetSize()))
{
m_AnimData.m_Json.m_Data["Custom"][m_nAnimBuffer] = ("0, " + std::string(m_nIfpBuffer));
m_AnimData.m_Json.WriteToDisk();
m_AnimData.m_pJson->m_Data["Custom"][m_nAnimBuffer] = ("0, " + std::string(m_nIfpBuffer));
m_AnimData.m_pJson->WriteToDisk();
}
ImGui::EndTabItem();
}
@ -174,23 +179,31 @@ void Animation::PlayAnimation(std::string& ifp, std::string& anim, std::string&
Command<Commands::CLEAR_CHAR_TASKS>(hplayer);
if (m_bSecondary)
{
Command<Commands::TASK_PLAY_ANIM_SECONDARY>(hplayer, anim.c_str(), ifp.c_str(), 4.0, m_Loop, 0, 0, 0, -1);
}
else
{
Command<Commands::TASK_PLAY_ANIM>(hplayer, anim.c_str(), ifp.c_str(), 4.0, m_Loop, 0, 0, 0, -1);
}
if (ifp != "PED")
{
Command<Commands::REMOVE_ANIMATION>(ifp.c_str());
}
}
void Animation::RemoveAnimation(std::string& ifp, std::string& anim, std::string& ifpRepeat)
{
if (ifp == "Custom")
{
m_AnimData.m_Json.m_Data["Custom"].erase(anim);
m_AnimData.m_Json.WriteToDisk();
m_AnimData.m_pJson->m_Data["Custom"].erase(anim);
m_AnimData.m_pJson->WriteToDisk();
SetHelpMessage("Animation removed", false, false, false);
}
else
{
SetHelpMessage("You can only remove custom anims", false, false, false);
}
}
#endif

View File

@ -6,10 +6,10 @@ class Animation
{
private:
inline static char m_nAnimBuffer[INPUT_BUFFER_SIZE];
inline static SSearchData m_AnimData{ "animation" };
inline static ResourceStore m_AnimData{ "animation", eResourceType::TYPE_TEXT };
struct m_Cutscene
{
inline static SSearchData m_Data{ "cutscene" };
inline static ResourceStore m_Data{ "cutscene", eResourceType::TYPE_TEXT };
inline static std::string m_SceneName;
inline static int m_nInterior;
inline static bool m_bRunning;
@ -38,5 +38,6 @@ public:
};
#else
// Dummy Class for GTAVC
class Animation{};
#endif

View File

@ -192,14 +192,16 @@ void MenuThread(void* param)
Hook::ApplyMouseFix();
#endif
// Wait till the game is initialized
// Wait till game init
Events::initRwEvent += []
{
bGameInit = true;
};
while (!bGameInit)
{
Sleep(1000);
}
if (GetModuleHandle("SAMP.dll"))
{
@ -212,7 +214,7 @@ void MenuThread(void* param)
CFastman92limitAdjuster::Init();
CheatMenu menu;
time_t now = time(0);
time_t now = time(0);
struct tm tstruct = *localtime(&now);
int last_check_date = config.GetValue("config.last_update_checked", 0);
@ -227,7 +229,9 @@ void MenuThread(void* param)
Sleep(5000);
if (Updater::m_State == UPDATER_CHECKING)
{
Updater::CheckForUpdate();
}
}
}
@ -246,6 +250,8 @@ BOOL WINAPI DllMain(HINSTANCE hDllHandle, DWORD nReason, LPVOID Reserved)
MessageBox(HWND_DESKTOP, "Unknown game version. GTA SA v1.0 US is required.", "CheatMenu", MB_ICONERROR);
}
#elif GTAVC
MessageBox(RsGlobal.ps->window, "Unknown game version. GTA VC v1.0 EN is required.", "CheatMenu", MB_ICONERROR);
if (gameVersion == GAME_10EN)
{
CreateThread(nullptr, NULL, (LPTHREAD_START_ROUTINE)&MenuThread, nullptr, NULL, nullptr);

View File

@ -28,9 +28,6 @@ void Game::RealTimeClock()
Game::Game()
{
m_MissionData.m_Json.LoadData(m_MissionData.m_Categories, m_MissionData.m_Selected);
m_StatData.m_Json.LoadData(m_StatData.m_Categories, m_StatData.m_Selected);
// Generate enabled cheats vector
for (auto element : m_RandomCheats::m_Json.m_Data.items())
{
@ -605,7 +602,7 @@ It's recommanded not to save after using the mission loader. Use it at your own
ImGui::Spacing();
ImGui::BeginChild("STATCHILD");
for (auto root : m_StatData.m_Json.m_Data.items())
for (auto root : m_StatData.m_pJson->m_Data.items())
{
if (root.key() == m_StatData.m_Selected || m_StatData.m_Selected == "All")
{

View File

@ -1,8 +1,9 @@
#pragma once
#include "pch.h"
class Game
{
public:
inline static SSearchData m_MissionData{ "mission" };
inline static ResourceStore m_MissionData{ "mission", eResourceType::TYPE_TEXT };
inline static std::vector<std::string> m_DayNames =
{
"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"
@ -49,7 +50,7 @@ public:
inline static uint m_nSolidWaterObj;
inline static bool m_bMissionLoaderWarningShown;
inline static SSearchData m_StatData{ "stat" };
inline static ResourceStore m_StatData{ "stat", eResourceType::TYPE_TEXT };
Game();
static void Draw();

View File

@ -4,7 +4,9 @@
CJson::CJson(const char* name)
{
if (name == "" || !fs::is_directory(PLUGIN_PATH((char*)"CheatMenu")))
{
return;
}
m_FilePath = PLUGIN_PATH((char*)"/CheatMenu/json/") + std::string(name) + ".json";
@ -27,9 +29,13 @@ CJson::CJson(const char* name)
m_Data = "{}"_json;
if (m_FilePath.find("config"))
{
flog << "Creating config.json file" << std::endl;
}
else
{
flog << "Failed to locate file " << m_FilePath << std::endl;
}
}
}
@ -39,9 +45,3 @@ void CJson::WriteToDisk()
file << m_Data.dump(4, ' ', false, nlohmann::json::error_handler_t::replace) << std::endl;
file.close();
}
void CJson::LoadData(std::vector<std::string>& vec, std::string& selected) // Test
{
for (auto element : m_Data.items())
vec.push_back(element.key());
}

View File

@ -1,6 +1,10 @@
#pragma once
#include "../Depend/json.hpp"
/*
Wrapper class for nlohmann::json
Contains helper methods
*/
class CJson
{
private:
@ -26,7 +30,9 @@ public:
nlohmann::json* json = &m_Data;
while (getline(ss, line, '.'))
{
json = &((*json)[line]);
}
// json library bugs with bool, using int instead
if (typeid(T) == typeid(bool))
@ -52,7 +58,9 @@ public:
nlohmann::json* json = &m_Data;
while (getline(ss, line, '.'))
{
json = &((*json)[line]);
}
return json->get<std::string>();
}
@ -66,7 +74,6 @@ public:
Allows to save values in json hierarchy using '.'
Example: "Menu.Window.X"
*/
template <typename T>
void SetValue(std::string&& key, T& val)
{
@ -76,13 +83,20 @@ public:
nlohmann::json* json = &m_Data;
while (getline(ss, line, '.'))
{
json = &((*json)[line]);
}
// json library bugs with bool, using int instead
if (typeid(T) == typeid(bool))
{
*json = (val ? 1 : 0);
}
else
{
*json = val;
}
}
template <>
@ -94,17 +108,13 @@ public:
nlohmann::json* json = &m_Data;
while (getline(ss, line, '.'))
{
json = &((*json)[line]);
}
*json = val;
}
/*
Loads the section names into a category vector.
Used to create drop down category menus
*/
void LoadData(std::vector<std::string>& vec, std::string& selected);
/*
Saves json data to disk
*/

View File

@ -86,14 +86,6 @@ void Paint::ResetAfterRenderEvent(CVehicle* pVeh)
Paint::Paint()
{
Events::processScriptsEvent += []
{
if (!m_bImagesLoaded)
{
Util::LoadTextureDirectory(m_TextureData, PLUGIN_PATH((char*)"CheatMenu\\textures.txd"));
m_bImagesLoaded = true;
}
};
Events::vehicleRenderEvent.before += RenderEvent;
Events::vehicleResetAfterRender += ResetAfterRenderEvent;
}

View File

@ -70,11 +70,10 @@ private:
void resetMaterialColor(RpMaterial* material);
void resetMaterialTexture(RpMaterial* material);
};
inline static bool m_bImagesLoaded;
inline static VehicleExtendedData<VehData> m_VehData;
protected:
inline static SSearchData m_TextureData;
inline static ResourceStore m_TextureData { "textures" };
struct veh_nodes
{

View File

@ -11,17 +11,6 @@ Ped::Ped()
{
m_bExGangWarsInstalled = true;
}
Events::processScriptsEvent += []
{
if (!m_bImagesLoaded)
{
Util::LoadTextureDirectory(m_PedData, PLUGIN_PATH((char*)"CheatMenu\\peds.txd"));
m_bImagesLoaded = true;
}
};
#elif GTAVC
m_PedData.m_Json.LoadData(m_PedData.m_Categories, m_PedData.m_Selected);
#endif
}
@ -46,7 +35,7 @@ void Ped::SpawnPed(std::string& cat, std::string& name, std::string& model)
return;
}
if (BY_GAME(m_PedData.m_Json.m_Data.contains(model), true))
if (BY_GAME(m_PedData.m_pJson->m_Data.contains(model), true))
{
CPlayerPed* player = FindPlayerPed();
CVector pos = player->GetPosition();
@ -273,7 +262,7 @@ void Ped::Draw()
#ifdef GTASA
Ui::DrawImages(m_PedData.m_ImagesList, ImVec2(65, 110), m_PedData.m_Categories, m_PedData.m_Selected,
m_PedData.m_Filter, SpawnPed, nullptr,
[](std::string str) { return m_PedData.m_Json.m_Data[str].get<std::string>(); });
[](std::string str) { return m_PedData.m_pJson->m_Data[str].get<std::string>(); });
#elif GTAVC
Ui::DrawJSON(m_PedData, SpawnPed, nullptr);
#endif
@ -303,7 +292,7 @@ void Ped::Draw()
#ifdef GTASA
ImGui::Spacing();
ImGui::Text("Selected weapon: %s",
Weapon::m_WeaponData.m_Json.m_Data[std::to_string(m_SpawnPed::m_nWeaponId)].get<std::string>().c_str());
Weapon::m_WeaponData.m_pJson->m_Data[std::to_string(m_SpawnPed::m_nWeaponId)].get<std::string>().c_str());
ImGui::Spacing();
Ui::DrawImages(Weapon::m_WeaponData.m_ImagesList, ImVec2(65, 65), Weapon::m_WeaponData.m_Categories,
@ -312,7 +301,7 @@ void Ped::Draw()
nullptr,
[](std::string str)
{
return Weapon::m_WeaponData.m_Json.m_Data[str].get<std::string>();
return Weapon::m_WeaponData.m_pJson->m_Data[str].get<std::string>();
},
[](std::string str) { return str != "-1"; /*Jetpack*/ }
);

View File

@ -1,4 +1,5 @@
#pragma once
#include "pch.h"
#include "Player.h"
#ifdef GTASA
#include "Weapon.h"
@ -10,7 +11,7 @@ private:
inline static CJson m_SpecialPedJson = CJson("ped special");
#endif
inline static SSearchData m_PedData{"ped"};
inline static ResourceStore m_PedData{"ped", eResourceType::TYPE_TEXT};
inline static bool m_bImagesLoaded;
inline static bool m_bExGangWarsInstalled;
inline static int m_nPedRemoveRadius = 5;

View File

@ -81,19 +81,6 @@ Player::Player()
CPlayerPed* player = FindPlayerPed();
int hplayer = CPools::GetPedRef(player);
if (!m_bImagesLoaded)
{
#ifdef GTASA
Util::LoadTextureDirectory(m_ClothData, PLUGIN_PATH((char*)"CheatMenu\\clothes.txd"), true);
#elif GTAVC
skinData.m_Json.LoadData(skinData.m_Categories, skinData.m_Selected);
#endif
m_bImagesLoaded = true;
}
if (m_KeepPosition::m_bEnabled)
{
if (Command<Commands::IS_CHAR_DEAD>(hplayer))
@ -220,7 +207,7 @@ void Player::ChangePlayerModel(std::string& model)
bool custom_skin = std::find(m_CustomSkins::m_List.begin(), m_CustomSkins::m_List.end(), model) !=
m_CustomSkins::m_List.end();
if (Ped::m_PedData.m_Json.m_Data.contains(model) || custom_skin)
if (Ped::m_PedData.m_pJson->m_Data.contains(model) || custom_skin)
{
CPlayerPed* player = FindPlayerPed();
if (Ped::m_SpecialPedJson.m_Data.contains(model) || custom_skin)
@ -611,7 +598,7 @@ void Player::Draw()
{
Ui::DrawImages(Ped::m_PedData.m_ImagesList, ImVec2(65, 110), Ped::m_PedData.m_Categories,
Ped::m_PedData.m_Selected, Ped::m_PedData.m_Filter, ChangePlayerModel, nullptr,
[](std::string str) { return Ped::m_PedData.m_Json.m_Data[str].get<std::string>(); });
[](std::string str) { return Ped::m_PedData.m_pJson->m_Data[str].get<std::string>(); });
ImGui::EndTabItem();
}
if (ImGui::BeginTabItem("Custom skins"))

View File

@ -5,7 +5,6 @@ class Player
{
private:
inline static bool m_bGodMode;
inline static bool m_bImagesLoaded;
inline static bool m_bModloaderInstalled;
struct m_KeepPosition
{
@ -16,7 +15,7 @@ private:
#ifdef GTASA
inline static bool m_bAimSkinChanger;
inline static int m_nUiBodyState;
inline static SSearchData m_ClothData;
inline static ResourceStore m_ClothData { "clothes" };
struct m_CustomSkins
{
inline static std::string m_Path = paths::GetGameDirPathA() + std::string("\\modloader\\Custom Skins\\");;
@ -24,7 +23,7 @@ private:
inline static std::vector<std::string> m_List;
};
#elif GTAVC
inline static SSearchData skinData{ "skin" };
inline static ResourceStore skinData{ "skin", eResourceType::TYPE_TEXT };
#endif
public:

85
src/ResourceStore.cpp Normal file
View File

@ -0,0 +1,85 @@
#include "pch.h"
#include "CFileLoader.h"
#include "extensions/Paths.h"
ResourceStore::ResourceStore(const char* text, eResourceType type)
{
if (type == eResourceType::TYPE_IMAGE)
{
Events::processScriptsEvent += [text, this]()
{
if (!m_bTexturesLoaded)
{
// LoadTextureDirectory(ResourceStore& data, char* path, bool pass_full_name)
LoadTextureResource(text);
m_bTexturesLoaded = true;
}
};
}
else
{
m_pJson = std::make_unique<CJson>(text);
// Generate categories
for (auto element : m_pJson->m_Data.items())
{
m_Categories.push_back(element.key());
}
}
}
static void* GetTextureFromRaster(RwTexture* pTexture)
{
RwRasterEx* raster = (RwRasterEx*)(&pTexture->raster->parent);
return (&raster->m_pRenderResource->texture);
}
void ResourceStore::LoadTextureResource(std::string&& name)
{
std::string fullPath = PLUGIN_PATH((char*)"CheatMenu\\") + name + ".txd";
RwTexDictionary* pRwTexDictionary = CFileLoader::LoadTexDictionary(fullPath.c_str());
if (pRwTexDictionary)
{
RwLinkList *pRLL = (RwLinkList*)pRwTexDictionary->texturesInDict.link.next;
RwTexDictionary *pEndDic;
do
{
pEndDic = (RwTexDictionary*)pRLL->link.next;
RwTexture *pTex = (RwTexture*)&pRLL[-1];
m_ImagesList.push_back(std::make_unique<STextureResource>());
m_ImagesList.back().get()->m_pRwTexture = pTex;
// Fetch IDirec9Texture9* from RwTexture*
m_ImagesList.back().get()->m_pTexture = GetTextureFromRaster(pTex);
// Naming format in Txd `Category$TextureName`
std::stringstream ss(pTex->name);
std::string str;
getline(ss, str, '$');
m_ImagesList.back().get()->m_CategoryName = str;
if (name == "clothes")
{
// pass full name
m_ImagesList.back().get()->m_FileName = pTex->name;
}
else
{
getline(ss, str, '$');
m_ImagesList.back().get()->m_FileName = str;
}
// Genereate categories
std::string itemNames;
if (!std::count(m_Categories.begin(), m_Categories.end(), itemNames))
{
m_Categories.push_back(itemNames);
}
pRLL = (RwLinkList*)pEndDic;
}
while ( pEndDic != (RwTexDictionary*)&pRwTexDictionary->texturesInDict );
}
}

60
src/ResourceStore.h Normal file
View File

@ -0,0 +1,60 @@
#include <string>
#include <rw/rwcore.h>
#include "Json.h"
#include "../depend/imgui/imgui.h"
#include "d3d9.h"
struct RwD3D9Raster
{
union
{
IDirect3DTexture9* texture;
IDirect3DSurface9* surface;
};
unsigned char* palette;
unsigned char alpha;
unsigned char cubeTextureFlags; /* 0x01 IS_CUBEMAP_TEX */
unsigned char textureFlags; /* 0x10 IS_COMPRESSED */
unsigned char lockedLevel;
IDirect3DSurface9* lockedSurface;
D3DLOCKED_RECT lockedRect;
D3DFORMAT format;
IDirect3DSwapChain9* swapChain;
HWND* hwnd;
};
struct RwRasterEx : public RwRaster
{
RwD3D9Raster *m_pRenderResource;
};
struct STextureResource
{
std::string m_FileName;
std::string m_CategoryName;
RwTexture *m_pRwTexture = nullptr;
void *m_pTexture = nullptr;
};
enum eResourceType
{
TYPE_IMAGE,
TYPE_TEXT,
};
using TextureResourceList = std::vector<std::unique_ptr<STextureResource>>;
class ResourceStore
{
private:
void LoadTextureResource(std::string&& path);
public:
ImGuiTextFilter m_Filter = "";
std::vector<std::string> m_Categories = {"All"};
std::string m_Selected = "All";
std::unique_ptr<CJson> m_pJson;
TextureResourceList m_ImagesList;
bool m_bTexturesLoaded = false;
ResourceStore(const char* text, eResourceType type = TYPE_IMAGE);
};

View File

@ -15,9 +15,11 @@ void Teleport::FetchRadarSpriteData()
// Update the radar list each 5 seconds
if (cur_timer - timer < 5000)
{
return;
}
tp_data.m_Json.m_Data.erase("Radar");
tp_data.m_pJson->m_Data.erase("Radar");
// 175 is the max number of sprites, FLA can increase this limit, might need to update this
for (int i = 0; i != 175; ++i)
@ -27,7 +29,7 @@ void Teleport::FetchRadarSpriteData()
auto sprite_name = m_SpriteJson.m_Data[std::to_string(sprite)].get<std::string>();
std::string key_name = sprite_name + ", " + Util::GetLocationName(&pos);
tp_data.m_Json.m_Data["Radar"][key_name] = "0, " + std::to_string(pos.x) + ", " + std::to_string(pos.y) + ", " +
tp_data.m_pJson->m_Data["Radar"][key_name] = "0, " + std::to_string(pos.x) + ", " + std::to_string(pos.y) + ", " +
std::to_string(pos.z);
/*
@ -41,7 +43,6 @@ void Teleport::FetchRadarSpriteData()
Teleport::Teleport()
{
tp_data.m_Json.LoadData(tp_data.m_Categories, tp_data.m_Selected);
m_bQuickTeleport = config.GetValue("quick_teleport", false);
Events::processScriptsEvent += []
@ -61,9 +62,13 @@ Teleport::Teleport()
CVehicle* pVeh = player->m_pVehicle;
if (pVeh && BY_GAME(player->m_nPedFlags.bInVehicle, player->m_pVehicle))
{
BY_GAME(pVeh->Teleport(m_Teleport::m_fPos, false), pVeh->Teleport(m_Teleport::m_fPos));
}
else
{
BY_GAME(player->Teleport(m_Teleport::m_fPos, false), player->Teleport(m_Teleport::m_fPos));
}
m_Teleport::m_bEnabled = false;
Command<Commands::FREEZE_CHAR_POSITION_AND_DONT_LOAD_COLLISION>(CPools::GetPedRef(player), false);
@ -83,7 +88,7 @@ Teleport::Teleport()
};
}
void Teleport::TeleportPlayer(bool get_marker, CVector pos, short interior_id)
void Teleport::TeleportPlayer(bool get_marker, CVector pos, int interior_id)
{
CPlayerPed* pPlayer = FindPlayerPed();
CVehicle* pVeh = pPlayer->m_pVehicle;
@ -150,24 +155,10 @@ void Teleport::TeleportToLocation(std::string& rootkey, std::string& bLocName, s
{
try
{
int interior = 0;
int dimension = 0;
CVector pos;
std::stringstream ss(loc);
std::string temp;
std::getline(ss, temp, ',');
interior = std::stoi(temp);
std::getline(ss, temp, ',');
pos.x = std::stof(temp);
std::getline(ss, temp, ',');
pos.y = std::stof(temp);
std::getline(ss, temp, ',');
pos.z = std::stof(temp);
TeleportPlayer(false, pos, static_cast<short>(interior));
sscanf(loc.c_str(), "%d,%f,%f,%f", &dimension, &pos.x, &pos.y, &pos.z);
TeleportPlayer(false, pos, dimension);
}
catch (...)
{
@ -179,11 +170,14 @@ void Teleport::RemoveTeleportEntry(std::string& category, std::string& key, std:
{
if (category == "Custom")
{
tp_data.m_Json.m_Data["Custom"].erase(key);
tp_data.m_pJson->m_Data["Custom"].erase(key);
SetHelpMessage("Location removed", false, false, false);
tp_data.m_Json.WriteToDisk();
tp_data.m_pJson->WriteToDisk();
}
else
{
SetHelpMessage("You can only remove custom location", false, false, false);
}
else SetHelpMessage("You can only remove custom location", false, false, false);
}
void Teleport::Draw()
@ -225,21 +219,12 @@ void Teleport::Draw()
if (ImGui::Button("Teleport to coord", Ui::GetSize(2)))
{
std::stringstream ss(m_nInputBuffer);
std::string temp;
CVector pos(0, 0, 0);
CVector pos;
try
{
getline(ss, temp, ',');
pos.x = std::stof(temp);
getline(ss, temp, ',');
pos.y = std::stof(temp);
getline(ss, temp, ',');
pos.z = std::stof(temp) + 1.0f;
sscanf(m_nInputBuffer,"%f,%f,%f", &pos.x, &pos.y, &pos.z);
pos.z += 1.0f;
TeleportPlayer(false, pos);
}
catch (...)
@ -283,15 +268,15 @@ void Teleport::Draw()
ImGui::Spacing();
if (ImGui::Button("Add location", Ui::GetSize()))
{
tp_data.m_Json.m_Data["Custom"][m_nLocationBuffer] = ("0, " + std::string(m_nInputBuffer));
tp_data.m_pJson->m_Data["Custom"][m_nLocationBuffer] = ("0, " + std::string(m_nInputBuffer));
#ifdef GTASA
// Clear the Radar coordinates
tp_data.m_Json.m_Data.erase("Radar");
tp_data.m_Json.m_Data["Radar"] = {};
tp_data.m_pJson->m_Data.erase("Radar");
tp_data.m_pJson->m_Data["Radar"] = {};
#endif
tp_data.m_Json.WriteToDisk();
tp_data.m_pJson->WriteToDisk();
}
ImGui::EndTabItem();
}

View File

@ -8,7 +8,7 @@ private:
inline static bool m_bInsertCoord;
inline static bool m_bQuickTeleport;
inline static char m_nInputBuffer[INPUT_BUFFER_SIZE];
inline static SSearchData tp_data{ "teleport" };
inline static ResourceStore tp_data{ "teleport", eResourceType::TYPE_TEXT };
inline static char m_nLocationBuffer[INPUT_BUFFER_SIZE];
inline static uint m_nQuickTeleportTimer;
@ -36,7 +36,7 @@ protected:
Teleport();
public:
static void Draw();
static void TeleportPlayer(bool get_marker = false, CVector pos = CVector(0, 0, 0), short interior_id = 0);
static void TeleportPlayer(bool get_marker = false, CVector pos = CVector(0, 0, 0), int interior_id = 0);
static void TeleportToLocation(std::string& rootkey, std::string& bLocName, std::string& loc);
static void RemoveTeleportEntry(std::string& rootkey, std::string& key, std::string& val);
};

View File

@ -347,7 +347,7 @@ bool Ui::CheckboxBitFlag(const char* label, uint flag, const char* hint)
return rtn;
}
void Ui::DrawJSON(SSearchData& data,
void Ui::DrawJSON(ResourceStore& data,
std::function<void(std::string&, std::string&, std::string&)> func_left_click,
std::function<void(std::string&, std::string&, std::string&)> func_right_click)
{
@ -376,7 +376,7 @@ void Ui::DrawJSON(SSearchData& data,
ImGui::BeginChild(1);
for (auto root : data.m_Json.m_Data.items())
for (auto root : data.m_pJson->m_Data.items())
{
if (root.key() == data.m_Selected || data.m_Selected == "All")
{
@ -483,7 +483,7 @@ void Ui::FilterWithHint(const char* label, ImGuiTextFilter& filter, const char*
}
// clean up the code someday
void Ui::DrawImages(std::vector<std::unique_ptr<STextureStructure>>& img_vec, ImVec2 image_size,
void Ui::DrawImages(std::vector<std::unique_ptr<STextureResource>>& img_vec, ImVec2 image_size,
std::vector<std::string>& category_vec, std::string& selected_item, ImGuiTextFilter& filter,
std::function<void(std::string&)> on_left_click, std::function<void(std::string&)> on_right_click,
std::function<std::string(std::string&)> get_name_func,

View File

@ -48,10 +48,10 @@ public:
static bool CheckboxWithHint(const char* label, bool* state, const char* hint = nullptr, bool is_disabled = false);
static void DrawHeaders(CallbackTable& data);
static void DrawJSON(SSearchData& data,
static void DrawJSON(ResourceStore& data,
std::function<void(std::string&, std::string&, std::string&)> func_left_click,
std::function<void(std::string&, std::string&, std::string&)> func_right_click);
static void DrawImages(std::vector<std::unique_ptr<STextureStructure>>& img_vec, ImVec2 image_size,
static void DrawImages(std::vector<std::unique_ptr<STextureResource>>& img_vec, ImVec2 image_size,
std::vector<std::string>& category_vec, std::string& selected_item, ImGuiTextFilter& filter,
std::function<void(std::string&)> on_left_click,
std::function<void(std::string&)> on_right_click,

View File

@ -1,75 +1,6 @@
#include "pch.h"
#include "Util.h"
#include "psapi.h"
#include "CFileLoader.h"
void Util::LoadTextureDirectory(SSearchData& data, char* path, bool pass_full_name)
{
RwTexDictionary* pRwTexDictionary = &data.txd;
// allow SA textures for VC
pRwTexDictionary = CFileLoader::LoadTexDictionary(path);
if (pRwTexDictionary)
{
// FIX ME
if (pass_full_name)
{
RwTexDictionaryForAllTextures(pRwTexDictionary, [](RwTexture* tex, void* data)
{
SSearchData* sdata = reinterpret_cast<SSearchData*>(data);
sdata->m_ImagesList.push_back(std::make_unique<STextureStructure>());
sdata->m_ImagesList.back().get()->m_pRwTexture = tex;
sdata->m_ImagesList.back().get()->m_pTexture = Util::GetTextureFromRaster(tex);
std::stringstream ss(tex->name);
std::string str;
getline(ss, str, '$');
sdata->m_ImagesList.back().get()->m_CategoryName = str;
if (!std::count(sdata->m_Categories.begin(), sdata->m_Categories.end(), str))
{
sdata->m_Categories.push_back(str);
}
sdata->m_ImagesList.back().get()->m_FileName = tex->name;
return tex;
}, &data);
}
else
{
RwTexDictionaryForAllTextures(pRwTexDictionary, [](RwTexture* tex, void* data)
{
SSearchData* sdata = reinterpret_cast<SSearchData*>(data);
sdata->m_ImagesList.push_back(std::make_unique<STextureStructure>());
sdata->m_ImagesList.back().get()->m_pRwTexture = tex;
sdata->m_ImagesList.back().get()->m_pTexture = Util::GetTextureFromRaster(tex);
std::stringstream ss(tex->name);
std::string str;
getline(ss, str, '$');
sdata->m_ImagesList.back().get()->m_CategoryName = str;
if (!std::count(sdata->m_Categories.begin(), sdata->m_Categories.end(), str))
{
sdata->m_Categories.push_back(str);
}
getline(ss, str);
sdata->m_ImagesList.back().get()->m_FileName = str;
return tex;
}, &data);
}
}
}
void* Util::GetTextureFromRaster(RwTexture* pTexture)
{
RwRasterEx* raster = (RwRasterEx*)(&pTexture->raster->parent);
return (&raster->renderResource->texture);
}
std::string Util::GetLocationName(CVector* pos)
{

View File

@ -26,6 +26,4 @@ public:
static void RainbowValues(int& r, int& g, int& b, float speed);
static void GetCPUUsageInit();
static double GetCurrentCPUUsage();
static void* GetTextureFromRaster(RwTexture* pTexture);
static void LoadTextureDirectory(SSearchData& data, char* path, bool pass_full_name = false);
};

View File

@ -33,19 +33,10 @@ Vehicle::Vehicle()
#ifdef GTASA
ParseVehiclesIDE();
#endif
ParseCarcolsDAT();
Events::processScriptsEvent += [this]
{
#ifdef GTASA
if (!m_bImagesLoaded)
{
Util::LoadTextureDirectory(m_Spawner::m_VehData, PLUGIN_PATH((char*)"CheatMenu\\vehicles.txd"));
Util::LoadTextureDirectory(m_TuneData, PLUGIN_PATH((char*)"CheatMenu\\components.txd"));
m_bImagesLoaded = true;
}
#endif
ParseCarcolsDAT();
uint timer = CTimer::m_snTimeInMilliseconds;
CPlayerPed* pPlayer = FindPlayerPed();
CVehicle* pVeh = pPlayer->m_pVehicle;
@ -326,11 +317,72 @@ void Vehicle::ParseVehiclesIDE()
}
else flog << "Vehicle.ide file not found";
}
void Vehicle::GenerateHandlingDataFile(int phandling)
{
FILE* fp = fopen("handling.txt", "w");
std::string handlingId = m_VehicleIDE[FindPlayerPed()->m_pVehicle->m_nModelIndex];
float fMass = patch::Get<float>(phandling + 0x4);
float fTurnMass = patch::Get<float>(phandling + 0xC);
float fDragMult = patch::Get<float>(phandling + 0x10);
float CentreOfMassX = patch::Get<float>(phandling + 0x14);
float CentreOfMassY = patch::Get<float>(phandling + 0x18);
float CentreOfMassZ = patch::Get<float>(phandling + 0x1C);
int nPercentSubmerged = patch::Get<int>(phandling + 0x20);
float fTractionMultiplier = patch::Get<float>(phandling + 0x28);
float fTractionLoss = patch::Get<float>(phandling + 0xA4);
float TractionBias = patch::Get<float>(phandling + 0xA8);
float fEngineAcceleration = patch::Get<float>(phandling + 0x7C) * 12500;
float fEngineInertia = patch::Get<float>(phandling + 0x80);
int nDriveType = patch::Get<BYTE>(phandling + 0x74);
int nEngineType = patch::Get<BYTE>(phandling + 0x75);
float BrakeDeceleration = patch::Get<float>(phandling + 0x94) * 2500;
float BrakeBias = patch::Get<float>(phandling + 0x98);
int ABS = patch::Get<BYTE>(phandling + 0x9C);
float SteeringLock = patch::Get<float>(phandling + 0xA0);
float SuspensionForceLevel = patch::Get<float>(phandling + 0xAC);
float SuspensionDampingLevel = patch::Get<float>(phandling + 0xB0);
float SuspensionHighSpdComDamp = patch::Get<float>(phandling + 0xB4);
float Suspension_upper_limit = patch::Get<float>(phandling + 0xB8);
float Suspension_lower_limit = patch::Get<float>(phandling + 0xBC);
float Suspension_bias = patch::Get<float>(phandling + 0xC0);
float Suspension_anti_dive_multiplier = patch::Get<float>(phandling + 0xC4);
float fCollisionDamageMultiplier = patch::Get<float>(phandling + 0xC8) * 0.338;
int nMonetaryValue = patch::Get<int>(phandling + 0xD8);
int MaxVelocity = patch::Get<float>(phandling + 0x84);
MaxVelocity = MaxVelocity * 206 + (MaxVelocity - 0.918668) * 1501;
int modelFlags = patch::Get<int>(phandling + 0xCC);
int handlingFlags = patch::Get<int>(phandling + 0xD0);
int front_lights = patch::Get<BYTE>(phandling + 0xDC);
int rear_lights = patch::Get<BYTE>(phandling + 0xDD);
int vehicle_anim_group = patch::Get<BYTE>(phandling + 0xDE);
int nNumberOfGears = patch::Get<BYTE>(phandling + 0x76);
float fSeatOffsetDistance = patch::Get<float>(phandling + 0xD4);
fprintf(
fp,
"\n%s\t%.5g\t%.5g\t%.5g\t%.5g\t%.5g\t%.5g\t%d\t%.5g\t%.5g\t%.5g\t%d\t%d\t%.5g\t%.5g\t%c\t%c\t%.5g\t%.5g\t%d\t%.5g\t%.5g\t%.5g\t%.5g\t%.5g\t%.5g\t%.5g\t%.5g\t%.5g\t%.5g\t%d\t%d\t%d\t%d\t%d\t%d",
handlingId.c_str(), fMass, fTurnMass, fDragMult, CentreOfMassX, CentreOfMassY, CentreOfMassZ, nPercentSubmerged,
fTractionMultiplier, fTractionLoss, TractionBias, nNumberOfGears,
MaxVelocity, fEngineAcceleration, fEngineInertia, nDriveType, nEngineType, BrakeDeceleration, BrakeBias, ABS,
SteeringLock, SuspensionForceLevel, SuspensionDampingLevel,
SuspensionHighSpdComDamp, Suspension_upper_limit, Suspension_lower_limit, Suspension_bias,
Suspension_anti_dive_multiplier, fSeatOffsetDistance,
fCollisionDamageMultiplier, nMonetaryValue, modelFlags, handlingFlags, front_lights, rear_lights,
vehicle_anim_group);
fclose(fp);
}
#endif
void Vehicle::ParseCarcolsDAT()
{
std::string m_FilePath = std::string(paths::GetGameDirPathA()) + "/data/carcols.dat";
std::string m_FilePath = GAME_PATH((char*)"/data/carcols.dat");
if (fs::exists(m_FilePath))
{
@ -431,9 +483,12 @@ void Vehicle::ParseCarcolsDAT()
}
}
void Vehicle::SpawnVehicle(std::string& smodel)
{
#ifdef GTASA
void Vehicle::SpawnVehicle(std::string& smodel)
#elif GTAVC
void Vehicle::SpawnVehicle(std::string& rootkey, std::string& vehName, std::string& smodel)
#endif
{
CPlayerPed* player = FindPlayerPed();
int hplayer = CPools::GetPedRef(player);
@ -458,6 +513,7 @@ void Vehicle::SpawnVehicle(std::string& smodel)
Command<Commands::WARP_CHAR_FROM_CAR_TO_COORD>(hplayer, pos.x, pos.y, pos.z);
#ifdef GTASA
if (pveh->m_nVehicleClass == VEHICLE_TRAIN)
{
Command<Commands::DELETE_MISSION_TRAIN>(hveh);
@ -466,6 +522,9 @@ void Vehicle::SpawnVehicle(std::string& smodel)
{
Command<Commands::DELETE_CAR>(hveh);
}
#elif GTAVC
Command<Commands::DELETE_CAR>(hveh);
#endif
}
if (interior == 0)
@ -480,6 +539,7 @@ void Vehicle::SpawnVehicle(std::string& smodel)
}
}
#ifdef GTASA
if (CModelInfo::IsTrainModel(imodel))
{
int train_id = GetRandomTrainIdForModel(imodel);
@ -527,38 +587,58 @@ void Vehicle::SpawnVehicle(std::string& smodel)
}
else
{
#endif
CStreaming::RequestModel(imodel, PRIORITY_REQUEST);
CStreaming::LoadAllRequestedModels(false);
#ifdef GTASA
if (m_Spawner::m_nLicenseText[0] != '\0')
{
Command<Commands::CUSTOM_PLATE_FOR_NEXT_CAR>(imodel, m_Spawner::m_nLicenseText);
}
#endif
int hveh = 0;
if (m_Spawner::m_bSpawnInside)
{
Command<Commands::CREATE_CAR>(imodel, pos.x, pos.y, pos.z + 4.0f, &hveh);
veh = CPools::GetVehicle(hveh);
#ifdef GTASA
veh->SetHeading(player->GetHeading());
#elif GTAVC
float x,y,z;
player->m_placement.GetOrientation(x, y, z);
veh->m_placement.SetOrientation(x, y, z);
#endif
Command<Commands::WARP_CHAR_INTO_CAR>(hplayer, hveh);
Command<Commands::SET_CAR_FORWARD_SPEED>(hveh, speed);
}
else
{
#ifdef GTASA
player->TransformFromObjectSpace(pos, CVector(0, 10, 0));
#elif GTAVC
player->TransformFromObjectSpace(pos);
#endif
Command<Commands::CREATE_CAR>(imodel, pos.x, pos.y, pos.z + 3.0f, &hveh);
veh = CPools::GetVehicle(hveh);
#ifdef GTASA
veh->SetHeading(player->GetHeading() + 55.0f);
#elif GTAVC
float x,y,z;
player->m_placement.GetOrientation(x, y, z);
veh->m_placement.SetOrientation(x, y, z);
#endif
}
BY_GAME(veh->m_nDoorLock, veh->m_nLockStatus) = CARLOCK_UNLOCKED;
BY_GAME(veh->m_nAreaCode, veh->m_nInterior) = interior;
Command<Commands::MARK_CAR_AS_NO_LONGER_NEEDED>(CPools::GetVehicleRef(veh));
CStreaming::SetModelIsDeletable(imodel);
#ifdef GTASA
}
veh->m_nVehicleFlags.bHasBeenOwnedByPlayer = true;
}
#elif GTAVC
Command<Commands::RESTORE_CAMERA_JUMPCUT>();
#endif
}
}
std::string Vehicle::GetNameFromModel(int model)
@ -583,67 +663,6 @@ int Vehicle::GetModelFromName(const char* name)
}
}
void Vehicle::GenerateHandlingDataFile(int phandling)
{
FILE* fp = fopen("handling.txt", "w");
std::string handlingId = m_VehicleIDE[FindPlayerPed()->m_pVehicle->m_nModelIndex];
float fMass = patch::Get<float>(phandling + 0x4);
float fTurnMass = patch::Get<float>(phandling + 0xC);
float fDragMult = patch::Get<float>(phandling + 0x10);
float CentreOfMassX = patch::Get<float>(phandling + 0x14);
float CentreOfMassY = patch::Get<float>(phandling + 0x18);
float CentreOfMassZ = patch::Get<float>(phandling + 0x1C);
int nPercentSubmerged = patch::Get<int>(phandling + 0x20);
float fTractionMultiplier = patch::Get<float>(phandling + 0x28);
float fTractionLoss = patch::Get<float>(phandling + 0xA4);
float TractionBias = patch::Get<float>(phandling + 0xA8);
float fEngineAcceleration = patch::Get<float>(phandling + 0x7C) * 12500;
float fEngineInertia = patch::Get<float>(phandling + 0x80);
int nDriveType = patch::Get<BYTE>(phandling + 0x74);
int nEngineType = patch::Get<BYTE>(phandling + 0x75);
float BrakeDeceleration = patch::Get<float>(phandling + 0x94) * 2500;
float BrakeBias = patch::Get<float>(phandling + 0x98);
int ABS = patch::Get<BYTE>(phandling + 0x9C);
float SteeringLock = patch::Get<float>(phandling + 0xA0);
float SuspensionForceLevel = patch::Get<float>(phandling + 0xAC);
float SuspensionDampingLevel = patch::Get<float>(phandling + 0xB0);
float SuspensionHighSpdComDamp = patch::Get<float>(phandling + 0xB4);
float Suspension_upper_limit = patch::Get<float>(phandling + 0xB8);
float Suspension_lower_limit = patch::Get<float>(phandling + 0xBC);
float Suspension_bias = patch::Get<float>(phandling + 0xC0);
float Suspension_anti_dive_multiplier = patch::Get<float>(phandling + 0xC4);
float fCollisionDamageMultiplier = patch::Get<float>(phandling + 0xC8) * 0.338;
int nMonetaryValue = patch::Get<int>(phandling + 0xD8);
int MaxVelocity = patch::Get<float>(phandling + 0x84);
MaxVelocity = MaxVelocity * 206 + (MaxVelocity - 0.918668) * 1501;
int modelFlags = patch::Get<int>(phandling + 0xCC);
int handlingFlags = patch::Get<int>(phandling + 0xD0);
int front_lights = patch::Get<BYTE>(phandling + 0xDC);
int rear_lights = patch::Get<BYTE>(phandling + 0xDD);
int vehicle_anim_group = patch::Get<BYTE>(phandling + 0xDE);
int nNumberOfGears = patch::Get<BYTE>(phandling + 0x76);
float fSeatOffsetDistance = patch::Get<float>(phandling + 0xD4);
fprintf(
fp,
"\n%s\t%.5g\t%.5g\t%.5g\t%.5g\t%.5g\t%.5g\t%d\t%.5g\t%.5g\t%.5g\t%d\t%d\t%.5g\t%.5g\t%c\t%c\t%.5g\t%.5g\t%d\t%.5g\t%.5g\t%.5g\t%.5g\t%.5g\t%.5g\t%.5g\t%.5g\t%.5g\t%.5g\t%d\t%d\t%d\t%d\t%d\t%d",
handlingId.c_str(), fMass, fTurnMass, fDragMult, CentreOfMassX, CentreOfMassY, CentreOfMassZ, nPercentSubmerged,
fTractionMultiplier, fTractionLoss, TractionBias, nNumberOfGears,
MaxVelocity, fEngineAcceleration, fEngineInertia, nDriveType, nEngineType, BrakeDeceleration, BrakeBias, ABS,
SteeringLock, SuspensionForceLevel, SuspensionDampingLevel,
SuspensionHighSpdComDamp, Suspension_upper_limit, Suspension_lower_limit, Suspension_bias,
Suspension_anti_dive_multiplier, fSeatOffsetDistance,
fCollisionDamageMultiplier, nMonetaryValue, modelFlags, handlingFlags, front_lights, rear_lights,
vehicle_anim_group);
fclose(fp);
}
void Vehicle::Draw()
{
ImGui::Spacing();
@ -653,14 +672,10 @@ void Vehicle::Draw()
if (ImGui::Button("Blow up cars", ImVec2(Ui::GetSize(BY_GAME(3,2)))))
{
#ifdef GTASA
Call<0x439D80>();
#elif GTAVC
for (CVehicle *pVeh : CPools::ms_pVehiclePool)
{
pVeh->BlowUpCar(pPlayer);
BY_GAME(pVeh->BlowUpCar(pPlayer, false), pVeh->BlowUpCar(pPlayer));
}
#endif
}
ImGui::SameLine();
@ -705,15 +720,17 @@ void Vehicle::Draw()
ImGui::Spacing();
ImGui::BeginChild("CheckboxesChild");
ImGui::Columns(2, 0, false);
#ifdef GTASA
Ui::CheckboxAddress("Aggressive drivers", 0x96914F);
Ui::CheckboxAddress("Aim while driving", 0x969179);
Ui::CheckboxAddress("All cars have nitro", 0x969165);
Ui::CheckboxAddress("All taxis have nitro", 0x96918B);
#endif
Ui::CheckboxAddress("All taxis have nitro", BY_GAME(0x96918B,0xA10B3A));
Ui::CheckboxWithHint("Bikes fly", &m_bBikeFly);
Ui::CheckboxAddress("Boats fly", 0x969153);
Ui::CheckboxAddress("Cars fly", 0x969160);
Ui::CheckboxAddress("Boats fly", BY_GAME(0x969153,0xA10B11));
Ui::CheckboxAddress("Cars fly", BY_GAME(0x969160,0xA10B28));
Ui::CheckboxWithHint("Cars heavy", &m_bVehHeavy);
if (Ui::CheckboxWithHint("Damage proof", &m_bNoDamage,
"Every vehicle entered will be damage proof\nBullet, Collision, Explosion, Fire, Meele etc"))
{
@ -735,21 +752,28 @@ void Vehicle::Draw()
#endif
}
}
#ifdef GTASA
Ui::CheckboxAddress("Decreased traffic", 0x96917A);
#endif
ImGui::NextColumn();
#ifdef GTASA
Ui::CheckboxWithHint("Don't fall off bike", &m_bDontFallBike);
Ui::CheckboxAddress("Drive on water", 0x969152);
#endif
Ui::CheckboxAddress("Drive on water", BY_GAME(0x969152,0xA10B81));
#ifdef GTASA
Ui::CheckboxAddressEx("Lock train camera", 0x52A52F, 171, 6);
Ui::CheckboxAddress("Float away when hit", 0x969166);
Ui::CheckboxAddress("Green traffic lights", 0x96914E);
#endif
Ui::CheckboxAddress("Green traffic lights", BY_GAME(0x96914E,0xA10ADC));
#ifdef GTASA
Ui::CheckboxAddress("Perfect handling", 0x96914C);
Ui::CheckboxAddress("Tank mode", 0x969164);
Ui::CheckboxWithHint("Unlimited nitro", &m_UnlimitedNitro::m_bEnabled, "Nitro will activate when left clicked\n\
\nEnabling this would disable\nAll cars have nitro\nAll taxis have nitro");
#endif
Ui::CheckboxWithHint("Watertight car", &m_bVehWatertight);
Ui::CheckboxAddress("Wheels only", 0x96914B);
Ui::CheckboxAddress("Wheels only", BY_GAME(0x96914B,0xA10B70));
ImGui::Columns(1);
if (is_driver)
@ -947,6 +971,7 @@ void Vehicle::Draw()
ImGui::Spacing();
ImGui::Separator();
}
#ifdef GTASA
if (ImGui::CollapsingHeader("Traffic options"))
{
static std::vector<Ui::NamedMemory> color{ {"Black", 0x969151}, {"Pink", 0x969150} };
@ -960,14 +985,14 @@ void Vehicle::Draw()
ImGui::Spacing();
ImGui::Separator();
}
#endif
if (pPlayer && pPlayer->m_pVehicle)
{
CVehicle* pVeh = pPlayer->m_pVehicle;
int hVeh = CPools::GetVehicleRef(pVeh);
Ui::EditFloat("Dirt level", (int)pVeh + 0x4B0, 0, 7.5, 15);
#ifdef GTASA
Ui::EditFloat("Dirt level", (int)pVeh + 0x4B0, 0, 7.5, 15);
if (pVeh->m_nVehicleClass == VEHICLE_AUTOMOBILE && ImGui::CollapsingHeader("Doors"))
{
ImGui::Columns(2, 0, false);
@ -1077,6 +1102,7 @@ void Vehicle::Draw()
ImGui::Spacing();
#ifdef GTASA
ImGui::SetNextItemWidth(ImGui::GetWindowContentRegionWidth() - 2.5);
ImGui::InputTextWithHint("##LicenseText", "License plate text", m_Spawner::m_nLicenseText, 9);
@ -1086,16 +1112,19 @@ void Vehicle::Draw()
{
return GetNameFromModel(std::stoi(str));
});
#elif GTAVC
Ui::DrawJSON(m_Spawner::m_VehData, SpawnVehicle, nullptr);
#endif
ImGui::EndTabItem();
}
#ifdef GTASA
if (pPlayer->m_pVehicle && pPlayer->m_nPedFlags.bInVehicle)
if (pPlayer->m_pVehicle && Command<Commands::IS_CHAR_IN_ANY_CAR>(hplayer))
{
CVehicle* veh = FindPlayerPed()->m_pVehicle;
int hveh = CPools::GetVehicleRef(veh);
if (ImGui::BeginTabItem("Color"))
{
#ifdef GTASA
Paint::UpdateNodeListRecursive(veh);
ImGui::Spacing();
@ -1115,7 +1144,7 @@ void Vehicle::Draw()
uchar b = m_Color::m_fColorPicker[2] * 255;
Paint::SetNodeColor(veh, Paint::veh_nodes::selected, { r, g, b, 255 }, m_Color::m_bMatFilter);
}
#endif
ImGui::Spacing();
ImGui::Columns(2, NULL, false);
ImGui::Checkbox("Material filter", &m_Color::m_bMatFilter);
@ -1140,14 +1169,20 @@ void Vehicle::Draw()
ImGui::BeginChild("Colorss");
if (m_Color::bShowAll)
{
for (int colorId = 0; colorId < count; ++colorId)
{
if (Ui::ColorButton(colorId, m_CarcolsColorData[colorId], ImVec2(btnSize, btnSize)))
{
*(uint8_replacement*)(int(veh) + 0x433 + m_Color::m_nRadioButton) = colorId;
}
if ((colorId + 1) % btnsInRow != 0)
{
ImGui::SameLine(0.0, 4.0);
}
}
}
else
{
std::string vehName = GetNameFromModel(pPlayer->m_pVehicle->m_nModelIndex);
@ -1160,10 +1195,14 @@ void Vehicle::Draw()
{
if (Ui::ColorButton(colorId, m_CarcolsColorData[colorId],
ImVec2(btnSize, btnSize)))
{
*(uint8_replacement*)(int(veh) + 0x433 + m_Color::m_nRadioButton) = colorId;
}
if (count % btnsInRow != 0)
{
ImGui::SameLine(0.0, 4.0);
}
++count;
}
@ -1175,6 +1214,7 @@ void Vehicle::Draw()
ImGui::EndChild();
ImGui::EndTabItem();
}
#ifdef GTASA
if (Globals::renderer != Render_DirectX11)
{
if (ImGui::BeginTabItem("Neons"))
@ -1395,8 +1435,8 @@ void Vehicle::Draw()
ImGui::EndTabItem();
}
}
#endif
}
ImGui::EndTabBar();
}
}

View File

@ -1,4 +1,5 @@
#pragma once
#include "pch.h"
#ifdef GTASA
#include "Neon.h"
#include "Paint.h"
@ -20,7 +21,6 @@ private:
inline static int m_nVehRemoveRadius;
inline static bool m_bLockSpeed;
inline static float m_fLockSpeed;
inline static std::map<int, std::string> m_VehicleIDE;
inline static std::vector<std::vector<float>> m_CarcolsColorData;
inline static std::map<std::string, std::vector<int>> m_CarcolsCarData;
struct m_Color
@ -30,6 +30,9 @@ private:
inline static bool bShowAll;
inline static float m_fColorPicker[3]{ 0, 0, 0 };
};
#ifdef GTASA
inline static std::map<int, std::string> m_VehicleIDE;
struct m_Neon
{
inline static float m_fColorPicker[3]{ 0, 0, 0 };
@ -38,21 +41,27 @@ private:
inline static bool m_bApplyOnTraffic;
inline static uint m_bTrafficTimer;
};
inline static ResourceStore m_TuneData { "components" };
#endif
struct m_Spawner
{
inline static SSearchData m_VehData;
#ifdef GTASA
inline static ResourceStore m_VehData { "vehicles" };
#elif GTAVC
inline static ResourceStore m_VehData{"vehicle", eResourceType::TYPE_TEXT};
#endif
inline static bool m_bSpawnInside = true;
inline static bool m_bSpawnInAir = true;
inline static char m_nLicenseText[9];
};
inline static SSearchData m_TuneData;
inline static bool m_bImagesLoaded;
struct m_UnlimitedNitro
{
inline static bool m_bEnabled;
inline static bool m_bCompAdded;
};
#ifdef GTASA
inline static std::vector<std::string>(m_HandlingFlagNames) = // 32 flags
{
"1G_BOOST", "2G_BOOST", "NPC_ANTI_ROLL", "NPC_NEUTRAL_HANDL", "NO_HANDBRAKE", "STEER_REARWHEELS",
@ -75,20 +84,28 @@ private:
"IS_PLANE", "IS_BOAT", "BOUNCE_PANELS",
"DOUBLE_RWHEELS", "FORCE_GROUND_CLEARANCE", "IS_HATCHBAC1K"
};
#endif
private:
static void FixVehicle(CVehicle *pVeh);
public:
#ifdef GTASA
static void AddComponent(const std::string& component, bool display_message = true);
static void RemoveComponent(const std::string& component, bool display_message = true);
static std::string GetNameFromModel(int model);
static int GetModelFromName(const char* name);
static void SpawnVehicle(std::string& name);
static int GetRandomTrainIdForModel(int model);
static void ParseVehiclesIDE();
static void ParseCarcolsDAT();
static void GenerateHandlingDataFile(int phandling);
#endif
static void ParseCarcolsDAT();
public:
#ifdef GTASA
static void SpawnVehicle(std::string& name);
#elif GTAVC
static void SpawnVehicle(std::string& rootkey, std::string& vehName, std::string& model);
#endif
static std::string GetNameFromModel(int model);
static int GetModelFromName(const char* name);
static void Draw();
Vehicle();
~Vehicle();
static void Draw();
};

View File

@ -8,12 +8,6 @@ Weapon::Weapon()
{
Events::processScriptsEvent += []
{
if (!m_bImagesLoaded)
{
Util::LoadTextureDirectory(m_WeaponData, PLUGIN_PATH((char*)"CheatMenu\\weapons.txd"));
m_bImagesLoaded = true;
}
CPlayerPed* player = FindPlayerPed();
if (m_bAutoAim)
{
@ -233,12 +227,12 @@ void Weapon::Draw()
ImGui::Spacing();
ImGui::Text("Current weapon: %s",
m_WeaponData.m_Json.m_Data[std::to_string(m_nGangWeaponList[m_nSelectedGang][m_nSelectedWeapon])].get<
m_WeaponData.m_pJson->m_Data[std::to_string(m_nGangWeaponList[m_nSelectedGang][m_nSelectedWeapon])].get<
std::string>().c_str());
ImGui::Spacing();
Ui::DrawImages(m_WeaponData.m_ImagesList, ImVec2(65, 65), m_WeaponData.m_Categories, m_WeaponData.m_Selected,
m_WeaponData.m_Filter, SetGangWeapon, nullptr,
[](std::string str) { return m_WeaponData.m_Json.m_Data[str].get<std::string>(); },
[](std::string str) { return m_WeaponData.m_pJson->m_Data[str].get<std::string>(); },
[](std::string str) { return str != "-1"; /*Jetpack*/ }
);
ImGui::EndTabItem();
@ -253,7 +247,7 @@ void Weapon::Draw()
}
Ui::DrawImages(m_WeaponData.m_ImagesList, ImVec2(65, 65), m_WeaponData.m_Categories, m_WeaponData.m_Selected,
m_WeaponData.m_Filter, GiveWeaponToPlayer, nullptr,
[](std::string str) { return m_WeaponData.m_Json.m_Data[str].get<std::string>(); },
[](std::string str) { return m_WeaponData.m_pJson->m_Data[str].get<std::string>(); },
[](std::string str) { return str != "0"; /*Unarmed*/ }
);
ImGui::EndTabItem();

View File

@ -3,8 +3,7 @@
class Weapon
{
public:
inline static SSearchData m_WeaponData{ "weapon" };
inline static bool m_bImagesLoaded;
inline static ResourceStore m_WeaponData{ "weapon", eResourceType::TYPE_TEXT };
inline static bool m_bAutoAim;
inline static bool m_bFastReload;
inline static bool m_bHugeDamage;

57
src/header_includes.h Normal file
View File

@ -0,0 +1,57 @@
#include <d3d9.h>
#include <d3d11.h>
#include <d3d11Shader.h>
#include <filesystem>
#include <fstream>
#include <functional>
#include <memory>
#include <iostream>
#include <sstream>
#include <vector>
#include <windows.h>
#include "plugin.h"
#include "CBike.h"
#include "CCamera.h"
#include "CClock.h"
#include "CCivilianPed.h"
#include "CGangs.h"
#include "cHandlingDataMgr.h"
#include "CHud.h"
#include "CMenuManager.h"
#include "CModelInfo.h"
#include "RenderWare.h"
#include "CStats.h"
#include "CStreaming.h"
#include "CTheScripts.h"
#include "CTheZones.h"
#include "CTimer.h"
#include "CTimeCycle.h"
#include "CTrain.h"
#include "CWeather.h"
#include "CWorld.h"
#include "extensions/ScriptCommands.h"
#include "extensions/Screen.h"
#include "extensions/Paths.h"
#ifdef GTASA
#include "CCheat.h"
#include "CClothes.h"
#include "CCutsceneMgr.h"
#include "CRadar.h"
#include "CShadows.h"
#include "eVehicleClass.h"
#include "CGangWars.h"
#endif
#include "../Depend/fla/IDaccess.h"
#include "../Depend/imgui/imgui.h"
#include "../Depend/imgui/imgui_internal.h"
#include "../Depend/imgui/imgui_impl_dx9.h"
#include "../Depend/imgui/imgui_impl_dx11.h"
#include "../Depend/imgui/imgui_impl_win32.h"
#include "MoreEvents.h"
#include "Json.h"
#include "VKeys.h"
#include "ResourceStore.h"

100
src/pch.h
View File

@ -12,62 +12,7 @@
#define BY_GAME(sa, vc) vc
#endif
#include <d3d9.h>
#include <d3d11.h>
#include <d3d11Shader.h>
#include <filesystem>
#include <fstream>
#include <functional>
#include <memory>
#include <iostream>
#include <sstream>
#include <vector>
#include <windows.h>
#include "plugin.h"
#include "CBike.h"
#include "CCamera.h"
#include "CClock.h"
#include "CCivilianPed.h"
#include "CGangs.h"
#include "cHandlingDataMgr.h"
#include "CHud.h"
#include "CMenuManager.h"
#include "CModelInfo.h"
#include "RenderWare.h"
#include "CStats.h"
#include "CStreaming.h"
#include "CTheScripts.h"
#include "CTheZones.h"
#include "CTimer.h"
#include "CTimeCycle.h"
#include "CTrain.h"
#include "CWeather.h"
#include "CWorld.h"
#include "extensions/ScriptCommands.h"
#include "extensions/Screen.h"
#include "extensions/Paths.h"
#ifdef GTASA
#include "CCheat.h"
#include "CClothes.h"
#include "CCutsceneMgr.h"
#include "CRadar.h"
#include "CShadows.h"
#include "eVehicleClass.h"
#include "CGangWars.h"
#endif
#include "../Depend/fla/IDaccess.h"
#include "../Depend/imgui/imgui.h"
#include "../Depend/imgui/imgui_internal.h"
#include "../Depend/imgui/imgui_impl_dx9.h"
#include "../Depend/imgui/imgui_impl_dx11.h"
#include "../Depend/imgui/imgui_impl_win32.h"
#include "MoreEvents.h"
#include "Json.h"
#include "VKeys.h"
#include "header_includes.h"
// Globals
using CallbackTable = std::vector<std::pair<std::string, void(*)()>>;
@ -102,49 +47,6 @@ struct HotKeyData
bool m_bPressed;
};
struct RwD3D9Raster
{
union
{
IDirect3DTexture9* texture;
IDirect3DSurface9* surface;
};
unsigned char* palette;
unsigned char alpha;
unsigned char cubeTextureFlags; /* 0x01 IS_CUBEMAP_TEX */
unsigned char textureFlags; /* 0x10 IS_COMPRESSED */
unsigned char lockedLevel;
IDirect3DSurface9* lockedSurface;
D3DLOCKED_RECT lockedRect;
D3DFORMAT format;
IDirect3DSwapChain9* swapChain;
HWND* hwnd;
};
struct RwRasterEx : public RwRaster
{
RwD3D9Raster *renderResource;
};
struct STextureStructure
{
std::string m_FileName;
std::string m_CategoryName;
RwTexture *m_pRwTexture = nullptr;
void *m_pTexture = nullptr;
};
struct SSearchData
{
CJson m_Json;
RwTexDictionary txd;
ImGuiTextFilter m_Filter = "";
std::vector<std::string> m_Categories = {"All"};
std::string m_Selected = "All";
std::vector<std::unique_ptr<STextureStructure>> m_ImagesList;
};
// Common defines
static void SetHelpMessage(const char *message, bool b1, bool b2, bool b3)
{

View File

@ -78,7 +78,9 @@ project "CheatMenuVC"
"../src/Util.h",
"../src/Util.cpp",
"../src/Menu.h",
"../src/Menu.cpp"
"../src/Menu.cpp",
"../src/ResourceStore.h",
"../src/ResourceStore.cpp"
}
includedirs {
PSDK_DIR .. "/plugin_vc/",