Fixed crashes with trains, modloader
Added options to set vehicle damage flags Fixed saving issue #42
This commit is contained in:
parent
5b1903df0c
commit
b14d43caac
3
.gitignore
vendored
3
.gitignore
vendored
@ -1,2 +1,5 @@
|
|||||||
.vs/
|
.vs/
|
||||||
build/
|
build/
|
||||||
|
.vscode/.BROWSE.VC.DB
|
||||||
|
.gitignore
|
||||||
|
.vscode/BROWSE.VC.DB
|
||||||
|
5
.vscode/c_cpp_properties.json
vendored
5
.vscode/c_cpp_properties.json
vendored
@ -3,8 +3,7 @@
|
|||||||
{
|
{
|
||||||
"name": "Win32",
|
"name": "Win32",
|
||||||
"includePath": [
|
"includePath": [
|
||||||
"${workspaceFolder}/**",
|
"${workspaceFolder}/src/",
|
||||||
"C:\\Program Files (x86)\\Windows Kits\\10\\Include\\10.0.10240.0\\ucrt",
|
|
||||||
"${DIRECTX9_SDK_DIR}/include",
|
"${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",
|
||||||
@ -20,7 +19,7 @@
|
|||||||
"windowsSdkVersion": "10.0.10240.0",
|
"windowsSdkVersion": "10.0.10240.0",
|
||||||
"compilerPath": "C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/cl.exe",
|
"compilerPath": "C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/cl.exe",
|
||||||
"cStandard": "c99",
|
"cStandard": "c99",
|
||||||
"cppStandard": "c++17",
|
"cppStandard": "c++14",
|
||||||
"intelliSenseMode": "msvc-x86",
|
"intelliSenseMode": "msvc-x86",
|
||||||
"configurationProvider": "ms-vscode.cmake-tools"
|
"configurationProvider": "ms-vscode.cmake-tools"
|
||||||
}
|
}
|
||||||
|
4
.vscode/settings.json
vendored
4
.vscode/settings.json
vendored
@ -63,5 +63,7 @@
|
|||||||
"xstddef": "cpp",
|
"xstddef": "cpp",
|
||||||
"xtr1common": "cpp",
|
"xtr1common": "cpp",
|
||||||
"xtree": "cpp"
|
"xtree": "cpp"
|
||||||
}
|
},
|
||||||
|
"C_Cpp.errorSquiggles": "Enabled",
|
||||||
|
"C_Cpp.intelliSenseEngineFallback": "Enabled"
|
||||||
}
|
}
|
@ -23,7 +23,7 @@ std::string walking_selected = "default";
|
|||||||
|
|
||||||
Animation::Animation()
|
Animation::Animation()
|
||||||
{
|
{
|
||||||
json.LoadJsonData(search_categories, selected_item);
|
json.LoadData(search_categories, selected_item);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Animation::Main()
|
void Animation::Main()
|
||||||
@ -102,6 +102,7 @@ void Animation::Main()
|
|||||||
if (ImGui::Button("Add animation", Ui::GetSize()))
|
if (ImGui::Button("Add animation", Ui::GetSize()))
|
||||||
{
|
{
|
||||||
json.data["Custom"][anim_buffer] = ("0, " + std::string(ifp_buffer));
|
json.data["Custom"][anim_buffer] = ("0, " + std::string(ifp_buffer));
|
||||||
|
json.WriteToDisk();
|
||||||
}
|
}
|
||||||
ImGui::EndTabItem();
|
ImGui::EndTabItem();
|
||||||
}
|
}
|
||||||
|
@ -85,6 +85,7 @@ CheatMenu::CheatMenu()
|
|||||||
config.SetValue("window.sizeX", Globals::menu_size.x);
|
config.SetValue("window.sizeX", Globals::menu_size.x);
|
||||||
config.SetValue("window.sizeY", Globals::menu_size.y);
|
config.SetValue("window.sizeY", Globals::menu_size.y);
|
||||||
|
|
||||||
|
config.WriteToDisk();
|
||||||
flog << "Log Finished." << std::endl;
|
flog << "Log Finished." << std::endl;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -47,8 +47,8 @@ Game::Game()
|
|||||||
{
|
{
|
||||||
Events::initGameEvent += []
|
Events::initGameEvent += []
|
||||||
{
|
{
|
||||||
json.LoadJsonData(search_categories, selected_item);
|
json.LoadData(search_categories, selected_item);
|
||||||
stat::json.LoadJsonData(stat::search_categories, stat::selected_item);
|
stat::json.LoadData(stat::search_categories, stat::selected_item);
|
||||||
|
|
||||||
// Generate enabled cheats vector
|
// Generate enabled cheats vector
|
||||||
for (auto element : random_cheats::name_json.data.items())
|
for (auto element : random_cheats::name_json.data.items())
|
||||||
|
15
src/Json.cpp
15
src/Json.cpp
@ -4,7 +4,7 @@
|
|||||||
CJson::CJson(const char* name,bool create_new)
|
CJson::CJson(const char* name,bool create_new)
|
||||||
{
|
{
|
||||||
file_path = "./CheatMenu/json/"+ std::string(name) +".json";
|
file_path = "./CheatMenu/json/"+ std::string(name) +".json";
|
||||||
|
|
||||||
if (std::experimental::filesystem::exists(file_path))
|
if (std::experimental::filesystem::exists(file_path))
|
||||||
{
|
{
|
||||||
std::ifstream file(file_path);
|
std::ifstream file(file_path);
|
||||||
@ -23,7 +23,14 @@ CJson::CJson(const char* name,bool create_new)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CJson::LoadJsonData(std::vector<std::string>& vec, std::string& selected) // Test
|
void CJson::WriteToDisk()
|
||||||
|
{
|
||||||
|
std::ofstream file(file_path);
|
||||||
|
file << 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 : data.items())
|
for (auto element : data.items())
|
||||||
vec.push_back(element.key());
|
vec.push_back(element.key());
|
||||||
@ -31,7 +38,5 @@ void CJson::LoadJsonData(std::vector<std::string>& vec, std::string& selected) /
|
|||||||
|
|
||||||
CJson::~CJson()
|
CJson::~CJson()
|
||||||
{
|
{
|
||||||
std::ofstream file(file_path);
|
// Saving here won't work on crash
|
||||||
file << data.dump(4,' ',false, nlohmann::json::error_handler_t::replace) << std::endl;
|
|
||||||
file.close();
|
|
||||||
}
|
}
|
||||||
|
@ -64,9 +64,14 @@ public:
|
|||||||
Loads the section names into a category vector.
|
Loads the section names into a category vector.
|
||||||
Used to create drop down category menus
|
Used to create drop down category menus
|
||||||
*/
|
*/
|
||||||
void LoadJsonData(std::vector<std::string>& vec, std::string& selected);
|
void LoadData(std::vector<std::string>& vec, std::string& selected);
|
||||||
|
|
||||||
|
/*
|
||||||
|
Saves json data to disk
|
||||||
|
*/
|
||||||
|
void WriteToDisk();
|
||||||
CJson(const char* text, bool create_new = false);
|
CJson(const char* text, bool create_new = false);
|
||||||
virtual ~CJson();
|
~CJson();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -31,7 +31,7 @@ Ped::Ped()
|
|||||||
{
|
{
|
||||||
Events::initGameEvent += []
|
Events::initGameEvent += []
|
||||||
{
|
{
|
||||||
std::string dir_path = (std::string(".\\CheatMenu\\peds\\")).c_str();
|
std::string dir_path = Globals::menu_path +"\\CheatMenu\\peds\\";
|
||||||
Util::LoadTexturesInDirRecursive(dir_path.c_str(), ".jpg", search_categories, peds_vec);
|
Util::LoadTexturesInDirRecursive(dir_path.c_str(), ".jpg", search_categories, peds_vec);
|
||||||
|
|
||||||
if (LoadLibraryW(L"ExGangWars.asi"))
|
if (LoadLibraryW(L"ExGangWars.asi"))
|
||||||
|
@ -50,7 +50,7 @@ void Teleport::FetchRadarSpriteData()
|
|||||||
|
|
||||||
Teleport::Teleport()
|
Teleport::Teleport()
|
||||||
{
|
{
|
||||||
json.LoadJsonData(search_categories, selected_item);
|
json.LoadData(search_categories, selected_item);
|
||||||
|
|
||||||
Events::initGameEvent += []
|
Events::initGameEvent += []
|
||||||
{
|
{
|
||||||
@ -255,6 +255,7 @@ void Teleport::Main()
|
|||||||
if (ImGui::Button("Add location", Ui::GetSize()))
|
if (ImGui::Button("Add location", Ui::GetSize()))
|
||||||
{
|
{
|
||||||
json.data["Custom"][location_buffer] = ("0, " + std::string(input_buffer));
|
json.data["Custom"][location_buffer] = ("0, " + std::string(input_buffer));
|
||||||
|
json.WriteToDisk();
|
||||||
}
|
}
|
||||||
ImGui::EndTabItem();
|
ImGui::EndTabItem();
|
||||||
}
|
}
|
||||||
|
@ -23,7 +23,7 @@ void Util::ClearCharTasksVehCheck(CPed* ped)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Util::LoadTexturesInDirRecursive(const char * path, const char * file_ext,std::vector<std::string>& category_vec, std::vector<std::unique_ptr<TextureStructure>> &store_vec)
|
void Util::LoadTexturesInDirRecursive(const char *path, const char *file_ext,std::vector<std::string>& category_vec, std::vector<std::unique_ptr<TextureStructure>> &store_vec)
|
||||||
{
|
{
|
||||||
std::string folder = "";
|
std::string folder = "";
|
||||||
for (auto &p : std::experimental::filesystem::recursive_directory_iterator(path))
|
for (auto &p : std::experimental::filesystem::recursive_directory_iterator(path))
|
||||||
@ -33,7 +33,7 @@ void Util::LoadTexturesInDirRecursive(const char * path, const char * file_ext,s
|
|||||||
{
|
{
|
||||||
store_vec.push_back(std::make_unique<TextureStructure>());
|
store_vec.push_back(std::make_unique<TextureStructure>());
|
||||||
HRESULT hr = -1;
|
HRESULT hr = -1;
|
||||||
|
flog << p.path().string() << std::endl;
|
||||||
if (Globals::renderer == Render_DirectX9)
|
if (Globals::renderer == Render_DirectX9)
|
||||||
hr = D3DXCreateTextureFromFileA(GetD3DDevice(), p.path().string().c_str(), &store_vec.back().get()->texture9);
|
hr = D3DXCreateTextureFromFileA(GetD3DDevice(), p.path().string().c_str(), &store_vec.back().get()->texture9);
|
||||||
|
|
||||||
|
@ -68,13 +68,13 @@ Vehicle::Vehicle()
|
|||||||
{
|
{
|
||||||
Events::initGameEvent += []
|
Events::initGameEvent += []
|
||||||
{
|
{
|
||||||
std::string dir_path = (std::string(".\\CheatMenu\\vehicles\\images\\")).c_str();
|
std::string dir_path = std::string(Globals::menu_path + "\\CheatMenu\\vehicles\\images\\");
|
||||||
Util::LoadTexturesInDirRecursive(dir_path.c_str(), ".jpg", spawner::search_categories, spawner::image_vec);
|
Util::LoadTexturesInDirRecursive(dir_path.c_str(), ".jpg", spawner::search_categories, spawner::image_vec);
|
||||||
|
|
||||||
dir_path = (std::string(".\\CheatMenu\\vehicles\\components\\")).c_str();
|
dir_path = std::string(Globals::menu_path + "\\CheatMenu\\vehicles\\components\\");
|
||||||
Util::LoadTexturesInDirRecursive(dir_path.c_str(), ".jpg", tune::search_categories, tune::image_vec);
|
Util::LoadTexturesInDirRecursive(dir_path.c_str(), ".jpg", tune::search_categories, tune::image_vec);
|
||||||
|
|
||||||
dir_path = (std::string(".\\CheatMenu\\vehicles\\paintjobs\\")).c_str();
|
dir_path = std::string(Globals::menu_path + "\\CheatMenu\\vehicles\\paintjobs\\");
|
||||||
Util::LoadTexturesInDirRecursive(dir_path.c_str(), ".png", texture9::search_categories, texture9::image_vec);
|
Util::LoadTexturesInDirRecursive(dir_path.c_str(), ".png", texture9::search_categories, texture9::image_vec);
|
||||||
|
|
||||||
ParseVehiclesIDE();
|
ParseVehiclesIDE();
|
||||||
@ -211,7 +211,7 @@ void Vehicle::RemoveComponent(const std::string& component, const bool display_m
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Why did I do this shit?
|
// Why did I do this shit? Guess it was the weather
|
||||||
int Vehicle::GetRandomTrainIdForModel(int model)
|
int Vehicle::GetRandomTrainIdForModel(int model)
|
||||||
{
|
{
|
||||||
static int train_ids[] = {
|
static int train_ids[] = {
|
||||||
@ -239,8 +239,8 @@ int Vehicle::GetRandomTrainIdForModel(int model)
|
|||||||
CHud::SetHelpMessage("Invalid train model", false, false, false);
|
CHud::SetHelpMessage("Invalid train model", false, false, false);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
int id = rand() % (_end + 1 - _start) + _start;
|
||||||
return train_ids[rand() % _end + _start];
|
return train_ids[id];
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get vehicle HandlingId
|
// Get vehicle HandlingId
|
||||||
@ -727,7 +727,7 @@ void Vehicle::Main()
|
|||||||
ImGui::Spacing();
|
ImGui::Spacing();
|
||||||
ImGui::Separator();
|
ImGui::Separator();
|
||||||
}
|
}
|
||||||
if (Command<Commands::IS_CHAR_IN_ANY_CAR>(hplayer))
|
if (player && player->m_pVehicle)
|
||||||
{
|
{
|
||||||
CVehicle *veh = player->m_pVehicle;
|
CVehicle *veh = player->m_pVehicle;
|
||||||
int hveh = CPools::GetVehicleRef(veh);
|
int hveh = CPools::GetVehicleRef(veh);
|
||||||
@ -735,6 +735,50 @@ void Vehicle::Main()
|
|||||||
Ui::EditFloat("Density multiplier", 0x8A5B20, 0, 1, 10);
|
Ui::EditFloat("Density multiplier", 0x8A5B20, 0, 1, 10);
|
||||||
Ui::EditFloat("Dirt level", (int)veh + 0x4B0, 0, 7.5, 15);
|
Ui::EditFloat("Dirt level", (int)veh + 0x4B0, 0, 7.5, 15);
|
||||||
|
|
||||||
|
if (ImGui::CollapsingHeader("Damage flags"))
|
||||||
|
{
|
||||||
|
ImGui::Spacing();
|
||||||
|
ImGui::TextWrapped("Flags apply to this vehicle only");
|
||||||
|
ImGui::Spacing();
|
||||||
|
|
||||||
|
bool no_dmg_flag = veh->m_nVehicleFlags.bCanBeDamaged;
|
||||||
|
|
||||||
|
bool state = is_driver && (!no_dmg_flag);
|
||||||
|
ImGui::Spacing();
|
||||||
|
ImGui::SameLine();
|
||||||
|
if (Ui::CheckboxWithHint("No damage", &state, nullptr, !is_driver))
|
||||||
|
veh->m_nVehicleFlags.bCanBeDamaged = !state;
|
||||||
|
|
||||||
|
ImGui::Spacing();
|
||||||
|
|
||||||
|
ImGui::Columns(2, 0, false);
|
||||||
|
|
||||||
|
state = is_driver && (veh->m_nPhysicalFlags.bBulletProof);
|
||||||
|
if (Ui::CheckboxWithHint("Bullet proof", &state, nullptr, !no_dmg_flag))
|
||||||
|
veh->m_nPhysicalFlags.bBulletProof = state;
|
||||||
|
|
||||||
|
state = is_driver && (veh->m_nPhysicalFlags.bCollisionProof);
|
||||||
|
if (Ui::CheckboxWithHint("Collision proof", &state, nullptr, !no_dmg_flag))
|
||||||
|
veh->m_nPhysicalFlags.bCollisionProof = state;
|
||||||
|
|
||||||
|
state = is_driver && (veh->m_nPhysicalFlags.bExplosionProof);
|
||||||
|
if (Ui::CheckboxWithHint("Explosion proof", &state, nullptr, !no_dmg_flag))
|
||||||
|
veh->m_nPhysicalFlags.bExplosionProof = state;
|
||||||
|
|
||||||
|
ImGui::NextColumn();
|
||||||
|
|
||||||
|
state = is_driver && (veh->m_nPhysicalFlags.bFireProof);
|
||||||
|
if (Ui::CheckboxWithHint("Fire proof", &state, nullptr, !no_dmg_flag))
|
||||||
|
veh->m_nPhysicalFlags.bFireProof = state;
|
||||||
|
|
||||||
|
state = is_driver && (veh->m_nPhysicalFlags.bMeeleProof);
|
||||||
|
if (Ui::CheckboxWithHint("Melee proof", &state, nullptr, !no_dmg_flag))
|
||||||
|
veh->m_nPhysicalFlags.bMeeleProof = state;
|
||||||
|
|
||||||
|
ImGui::Columns(1);
|
||||||
|
ImGui::Spacing();
|
||||||
|
ImGui::Separator();
|
||||||
|
}
|
||||||
if (veh->m_nVehicleClass == VEHICLE_AUTOMOBILE && ImGui::CollapsingHeader("Doors"))
|
if (veh->m_nVehicleClass == VEHICLE_AUTOMOBILE && ImGui::CollapsingHeader("Doors"))
|
||||||
{
|
{
|
||||||
ImGui::Columns(2, 0, false);
|
ImGui::Columns(2, 0, false);
|
||||||
|
@ -35,7 +35,7 @@ Weapon::Weapon()
|
|||||||
{
|
{
|
||||||
Events::initGameEvent += []
|
Events::initGameEvent += []
|
||||||
{
|
{
|
||||||
std::string dir_path = (std::string(".\\CheatMenu\\weapons\\")).c_str();
|
std::string dir_path = Globals::menu_path + "\\CheatMenu\\weapons\\";
|
||||||
Util::LoadTexturesInDirRecursive(dir_path.c_str(), ".jpg", Weapon::search_categories, Weapon::weapon_vec);
|
Util::LoadTexturesInDirRecursive(dir_path.c_str(), ".jpg", Weapon::search_categories, Weapon::weapon_vec);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -9,6 +9,7 @@ bool Globals::show_menu = false;
|
|||||||
bool Globals::init_done = false;
|
bool Globals::init_done = false;
|
||||||
Renderer Globals::renderer = Render_Unknown;
|
Renderer Globals::renderer = Render_Unknown;
|
||||||
ID3D11Device *Globals::device11 = nullptr;
|
ID3D11Device *Globals::device11 = nullptr;
|
||||||
|
std::string Globals::menu_path = paths::GetPluginDirPathA();
|
||||||
|
|
||||||
CJson config = CJson("config", true);
|
CJson config = CJson("config", true);
|
||||||
std::ofstream flog = std::ofstream("CheatMenu.log");
|
std::ofstream flog = std::ofstream("CheatMenu.log");
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
#define INPUT_BUFFER_SIZE 64
|
#define INPUT_BUFFER_SIZE 64
|
||||||
#define SPAWN_PED_LIMIT 20
|
#define SPAWN_PED_LIMIT 20
|
||||||
#define MENU_VERSION "2.5-beta"
|
#define MENU_VERSION "2.5-beta"
|
||||||
#define BUILD_NUMBER "20201209"
|
#define BUILD_NUMBER "20201220"
|
||||||
#define STB_IMAGE_IMPLEMENTATION
|
#define STB_IMAGE_IMPLEMENTATION
|
||||||
|
|
||||||
#include <d3d9.h>
|
#include <d3d9.h>
|
||||||
@ -46,6 +46,7 @@
|
|||||||
#include "extensions/ScriptCommands.h"
|
#include "extensions/ScriptCommands.h"
|
||||||
#include "extensions/Screen.h"
|
#include "extensions/Screen.h"
|
||||||
#include "eVehicleClass.h"
|
#include "eVehicleClass.h"
|
||||||
|
#include "extensions\Paths.h"
|
||||||
|
|
||||||
#include "external/imgui/imgui.h"
|
#include "external/imgui/imgui.h"
|
||||||
#include "external/imgui/imgui_impl_dx9.h"
|
#include "external/imgui/imgui_impl_dx9.h"
|
||||||
@ -83,6 +84,7 @@ struct Globals
|
|||||||
static bool init_done;
|
static bool init_done;
|
||||||
static Renderer renderer;
|
static Renderer renderer;
|
||||||
static ID3D11Device* device11;
|
static ID3D11Device* device11;
|
||||||
|
static std::string menu_path;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct TextureStructure
|
struct TextureStructure
|
||||||
|
Loading…
Reference in New Issue
Block a user