Make menu unloadable
This commit is contained in:
parent
b9cc290603
commit
86431a9eac
3
deps/kiero/kiero.cpp
vendored
3
deps/kiero/kiero.cpp
vendored
@ -1,8 +1,9 @@
|
|||||||
/* Slightly modified version of https://github.com/Rebzzel/kiero
|
/* Modified version of https://github.com/Rebzzel/kiero
|
||||||
|
|
||||||
MIT License
|
MIT License
|
||||||
|
|
||||||
Copyright(c) 2014 - 2020 Rebzzel
|
Copyright(c) 2014 - 2020 Rebzzel
|
||||||
|
Copyright(c) 2021 Grinch_
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
of this software and associated documentation files(the "Software"), to deal
|
of this software and associated documentation files(the "Software"), to deal
|
||||||
|
3
deps/kiero/kiero.h
vendored
3
deps/kiero/kiero.h
vendored
@ -1,8 +1,9 @@
|
|||||||
/* Slightly modified version of https://github.com/Rebzzel/kiero
|
/* Modified version of https://github.com/Rebzzel/kiero
|
||||||
|
|
||||||
MIT License
|
MIT License
|
||||||
|
|
||||||
Copyright(c) 2014 - 2020 Rebzzel
|
Copyright(c) 2014 - 2020 Rebzzel
|
||||||
|
Copyright(c) 2021 Grinch_
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
of this software and associated documentation files(the "Software"), to deal
|
of this software and associated documentation files(the "Software"), to deal
|
||||||
|
@ -3,13 +3,22 @@
|
|||||||
#include "MenuInfo.h"
|
#include "MenuInfo.h"
|
||||||
#include "Ui.h"
|
#include "Ui.h"
|
||||||
|
|
||||||
unsortedMap CheatMenu::header{
|
CallbackTable CheatMenu::header{
|
||||||
{ "Teleport", &Teleport::Draw },{ "Player", &Player::Draw },{ "Ped", &Ped::Draw },
|
{ "Teleport", &Teleport::Draw },{ "Player", &Player::Draw },{ "Ped", &Ped::Draw },
|
||||||
{ "Animation", &Animation::Draw },{ "Vehicle", &Vehicle::Draw },{ "Weapon", &Weapon::Draw },
|
{ "Animation", &Animation::Draw },{ "Vehicle", &Vehicle::Draw },{ "Weapon", &Weapon::Draw },
|
||||||
{ "Game", &Game::Draw },{ "Visual", &Visual::Draw },{ "Menu", &Menu::Draw }
|
{ "Game", &Game::Draw },{ "Visual", &Visual::Draw },{ "Menu", &Menu::Draw }
|
||||||
};
|
};
|
||||||
|
|
||||||
void CheatMenu::DrawMenu()
|
void CheatMenu::DrawWindow()
|
||||||
|
{
|
||||||
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
|
|
||||||
|
if (FrontEndMenuManager.m_bMenuActive)
|
||||||
|
Hook::show_mouse = false;
|
||||||
|
else
|
||||||
|
if (Globals::show_menu || Menu::commands::show_menu)
|
||||||
|
{
|
||||||
|
if (Globals::show_menu)
|
||||||
{
|
{
|
||||||
ImGui::SetNextWindowSize(Globals::menu_size);
|
ImGui::SetNextWindowSize(Globals::menu_size);
|
||||||
if (ImGui::Begin(MENU_TITLE, &Globals::show_menu, ImGuiWindowFlags_NoCollapse))
|
if (ImGui::Begin(MENU_TITLE, &Globals::show_menu, ImGuiWindowFlags_NoCollapse))
|
||||||
@ -27,37 +36,14 @@ void CheatMenu::DrawMenu()
|
|||||||
ImGui::End();
|
ImGui::End();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CheatMenu::ProcessWindow()
|
|
||||||
{
|
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
|
||||||
|
|
||||||
if (FrontEndMenuManager.m_bMenuActive)
|
|
||||||
Hook::show_mouse = false;
|
|
||||||
else
|
|
||||||
if (Globals::show_menu || Menu::commands::show_menu)
|
|
||||||
{
|
|
||||||
if (Globals::show_menu)
|
|
||||||
DrawMenu();
|
|
||||||
else
|
else
|
||||||
Menu::DrawShortcutsWindow();
|
Menu::DrawShortcutsWindow();
|
||||||
}
|
}
|
||||||
|
|
||||||
Menu::ProcessOverlay();
|
Menu::DrawOverlay();
|
||||||
}
|
}
|
||||||
|
|
||||||
CheatMenu::CheatMenu()
|
void CheatMenu::ProcessEvent()
|
||||||
{
|
|
||||||
ApplyStyle();
|
|
||||||
Hook::window_callback = std::bind(&ProcessWindow);
|
|
||||||
|
|
||||||
// Load menu settings
|
|
||||||
Globals::header_id = config.GetValue("window.id", std::string(""));
|
|
||||||
Globals::menu_size.x = config.GetValue("window.sizeX", screen::GetScreenWidth() / 4.0f);
|
|
||||||
Globals::menu_size.y = config.GetValue("window.sizeY", screen::GetScreenHeight() / 1.2f);
|
|
||||||
srand(CTimer::m_snTimeInMilliseconds);
|
|
||||||
|
|
||||||
Events::processScriptsEvent += []
|
|
||||||
{
|
{
|
||||||
if (Globals::init_done && !FrontEndMenuManager.m_bMenuActive)
|
if (Globals::init_done && !FrontEndMenuManager.m_bMenuActive)
|
||||||
{
|
{
|
||||||
@ -82,7 +68,25 @@ CheatMenu::CheatMenu()
|
|||||||
Hook::show_mouse = Globals::show_menu;
|
Hook::show_mouse = Globals::show_menu;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
|
CheatMenu::CheatMenu()
|
||||||
|
{
|
||||||
|
ApplyStyle();
|
||||||
|
Hook::window_callback = std::bind(&DrawWindow);
|
||||||
|
|
||||||
|
// Load menu settings
|
||||||
|
Globals::header_id = config.GetValue("window.id", std::string(""));
|
||||||
|
Globals::menu_size.x = config.GetValue("window.sizeX", screen::GetScreenWidth() / 4.0f);
|
||||||
|
Globals::menu_size.y = config.GetValue("window.sizeY", screen::GetScreenHeight() / 1.2f);
|
||||||
|
srand(CTimer::m_snTimeInMilliseconds);
|
||||||
|
|
||||||
|
Events::processScriptsEvent += ProcessEvent;
|
||||||
|
}
|
||||||
|
|
||||||
|
CheatMenu::~CheatMenu()
|
||||||
|
{
|
||||||
|
Events::processScriptsEvent -= ProcessEvent;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CheatMenu::ApplyStyle()
|
void CheatMenu::ApplyStyle()
|
||||||
@ -159,16 +163,20 @@ void CheatMenu::ApplyStyle()
|
|||||||
colors[ImGuiCol_ModalWindowDimBg] = ImVec4(0.26f, 0.59f, 0.98f, 0.35f);
|
colors[ImGuiCol_ModalWindowDimBg] = ImVec4(0.26f, 0.59f, 0.98f, 0.35f);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MenuThread(void* param)
|
void HasGameInit()
|
||||||
{
|
|
||||||
// Wait till the game is initiallized
|
|
||||||
Events::initGameEvent.after += []()
|
|
||||||
{
|
{
|
||||||
Globals::game_init = true;
|
Globals::game_init = true;
|
||||||
};
|
}
|
||||||
|
|
||||||
|
void MenuThread(void* param)
|
||||||
|
{
|
||||||
|
// Wait till the game is initialized
|
||||||
|
Events::initGameEvent.after += HasGameInit;
|
||||||
|
|
||||||
while (!Globals::game_init)
|
while (!Globals::game_init)
|
||||||
Sleep(500);
|
Sleep(1000);
|
||||||
|
|
||||||
|
Events::initGameEvent.after -= HasGameInit;
|
||||||
|
|
||||||
if (GetModuleHandle("SAMP.dll"))
|
if (GetModuleHandle("SAMP.dll"))
|
||||||
{
|
{
|
||||||
@ -185,10 +193,25 @@ void MenuThread(void* param)
|
|||||||
|
|
||||||
flog << "Starting...\nVersion: " MENU_TITLE "\nAuthor: Grinch_\nDiscord: " DISCORD_INVITE "\nMore Info: " GITHUB_LINK "\n\n" << std::endl;
|
flog << "Starting...\nVersion: " MENU_TITLE "\nAuthor: Grinch_\nDiscord: " DISCORD_INVITE "\nMore Info: " GITHUB_LINK "\n\n" << std::endl;
|
||||||
CFastman92limitAdjuster::Init();
|
CFastman92limitAdjuster::Init();
|
||||||
CheatMenu cheatmenu;
|
CheatMenu *menu = new CheatMenu;
|
||||||
|
|
||||||
while (true)
|
while (true)
|
||||||
Sleep(5000);
|
{
|
||||||
|
Sleep(50);
|
||||||
|
|
||||||
|
if (KeyPressed(VK_TAB))
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
delete menu;
|
||||||
|
Sleep(100);
|
||||||
|
|
||||||
|
// reset mouse patches
|
||||||
|
patch::SetUChar(0x6194A0, 0xE9);
|
||||||
|
patch::SetUChar(0x746ED0, 0xA1);
|
||||||
|
patch::SetRaw(0x53F41F, (void*)"\x85\xC0\x0F\x8C", 4);
|
||||||
|
|
||||||
|
FreeLibraryAndExitThread(NULL,0);
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL WINAPI DllMain(HINSTANCE hDllHandle, DWORD nReason, LPVOID Reserved)
|
BOOL WINAPI DllMain(HINSTANCE hDllHandle, DWORD nReason, LPVOID Reserved)
|
||||||
|
@ -21,12 +21,14 @@
|
|||||||
class CheatMenu : Hook, Animation, Game, Menu, Ped, Player, Teleport, Vehicle, Visual, Weapon
|
class CheatMenu : Hook, Animation, Game, Menu, Ped, Player, Teleport, Vehicle, Visual, Weapon
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
static unsortedMap header;
|
static CallbackTable header;
|
||||||
static void DrawMenu();
|
|
||||||
static void ProcessWindow();
|
|
||||||
static void ApplyStyle();
|
static void ApplyStyle();
|
||||||
|
static void DrawWindow();
|
||||||
|
static void ProcessEvent();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CheatMenu();
|
CheatMenu();
|
||||||
|
~CheatMenu();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
36
src/Hook.cpp
36
src/Hook.cpp
@ -1,7 +1,6 @@
|
|||||||
#include "Hook.h"
|
#include "Hook.h"
|
||||||
#include "kiero/kiero.h"
|
#include "kiero/kiero.h"
|
||||||
#include "kiero/minhook/MinHook.h"
|
#include "kiero/minhook/MinHook.h"
|
||||||
// #include "vulkan/vulkan.h"
|
|
||||||
|
|
||||||
WNDPROC Hook::oWndProc = NULL;
|
WNDPROC Hook::oWndProc = NULL;
|
||||||
f_Present11 Hook::oPresent11 = NULL;
|
f_Present11 Hook::oPresent11 = NULL;
|
||||||
@ -46,6 +45,9 @@ HRESULT Hook::Reset(IDirect3DDevice9* pDevice, D3DPRESENT_PARAMETERS* pPresentat
|
|||||||
|
|
||||||
void Hook::Present(void* ptr)
|
void Hook::Present(void* ptr)
|
||||||
{
|
{
|
||||||
|
if (!ImGui::GetCurrentContext())
|
||||||
|
return;
|
||||||
|
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
|
|
||||||
if (Globals::init_done)
|
if (Globals::init_done)
|
||||||
@ -129,8 +131,6 @@ void Hook::Present(void* ptr)
|
|||||||
reinterpret_cast<ID3D11Device*>(Globals::device)->GetImmediateContext(&context);
|
reinterpret_cast<ID3D11Device*>(Globals::device)->GetImmediateContext(&context);
|
||||||
|
|
||||||
ImGui_ImplDX11_Init(reinterpret_cast<ID3D11Device*>(Globals::device), context);
|
ImGui_ImplDX11_Init(reinterpret_cast<ID3D11Device*>(Globals::device), context);
|
||||||
|
|
||||||
//ImGui_ImplVulkan_Init()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui_ImplWin32_EnableDpiAwareness();
|
ImGui_ImplWin32_EnableDpiAwareness();
|
||||||
@ -146,7 +146,7 @@ void Hook::Present(void* ptr)
|
|||||||
HRESULT Hook::PresentDx9Handler(IDirect3DDevice9* pDevice, RECT* pSourceRect, RECT* pDestRect, HWND hDestWindowOverride, RGNDATA* pDirtyRegion)
|
HRESULT Hook::PresentDx9Handler(IDirect3DDevice9* pDevice, RECT* pSourceRect, RECT* pDestRect, HWND hDestWindowOverride, RGNDATA* pDirtyRegion)
|
||||||
{
|
{
|
||||||
Present(pDevice);
|
Present(pDevice);
|
||||||
return oPresent9(pDevice, pSourceRect, pDestRect, hDestWindowOverride, pDirtyRegion);;
|
return oPresent9(pDevice, pSourceRect, pDestRect, hDestWindowOverride, pDirtyRegion);
|
||||||
}
|
}
|
||||||
|
|
||||||
HRESULT Hook::PresentDx11Handler(IDXGISwapChain* pSwapChain, UINT SyncInterval, UINT Flags)
|
HRESULT Hook::PresentDx11Handler(IDXGISwapChain* pSwapChain, UINT SyncInterval, UINT Flags)
|
||||||
@ -155,15 +155,6 @@ HRESULT Hook::PresentDx11Handler(IDXGISwapChain* pSwapChain, UINT SyncInterval,
|
|||||||
return oPresent11(pSwapChain, SyncInterval, Flags);
|
return oPresent11(pSwapChain, SyncInterval, Flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
// typedef void(*func_vkCmdDrawIndexed_t) (VkCommandBuffer commandBuffer, uint32_t vertexCount, uint32_t instanceCount, uint32_t firstVertex, uint32_t firstInstance);
|
|
||||||
// func_vkCmdDrawIndexed_t ovkCmdDrawIndexed;
|
|
||||||
|
|
||||||
// void hvkCmdDraw(VkCommandBuffer commandBuffer, uint32_t vertexCount, uint32_t instanceCount, uint32_t firstVertex, uint32_t firstInstance)
|
|
||||||
// {
|
|
||||||
|
|
||||||
// ovkCmdDrawIndexed(commandBuffer, vertexCount, instanceCount, firstVertex, firstInstance);
|
|
||||||
// }
|
|
||||||
|
|
||||||
// Thanks imring
|
// Thanks imring
|
||||||
void Hook::ShowMouse(bool state)
|
void Hook::ShowMouse(bool state)
|
||||||
{
|
{
|
||||||
@ -173,7 +164,7 @@ void Hook::ShowMouse(bool state)
|
|||||||
CPad::NewMouseControllerState.Y = 0;
|
CPad::NewMouseControllerState.Y = 0;
|
||||||
patch::SetUChar(0x6194A0, 0xC3);
|
patch::SetUChar(0x6194A0, 0xC3);
|
||||||
|
|
||||||
// Since Windowed mode by ThirteenAG hooks this too
|
// Don't nop this, WindowedMode uses it
|
||||||
// patch::Nop(0x53F417, 5); // don't call CPad__getMouseState
|
// patch::Nop(0x53F417, 5); // don't call CPad__getMouseState
|
||||||
patch::SetUChar(0x746ED0, 0xC3);
|
patch::SetUChar(0x746ED0, 0xC3);
|
||||||
|
|
||||||
@ -208,25 +199,26 @@ Hook::Hook()
|
|||||||
{
|
{
|
||||||
ImGui::CreateContext();
|
ImGui::CreateContext();
|
||||||
|
|
||||||
if (kiero::init(kiero::RenderType::D3D9) == kiero::Status::Success)
|
|
||||||
{
|
|
||||||
Globals::renderer = Render_DirectX9;
|
|
||||||
kiero::bind(16, (void**)&oReset9, Reset);
|
|
||||||
kiero::bind(17, (void**)&oPresent9, PresentDx9Handler);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// gtaRenderHook
|
// gtaRenderHook
|
||||||
if (kiero::init(kiero::RenderType::D3D11) == kiero::Status::Success)
|
if (kiero::init(kiero::RenderType::D3D11) == kiero::Status::Success)
|
||||||
{
|
{
|
||||||
Globals::renderer = Render_DirectX11;
|
Globals::renderer = Render_DirectX11;
|
||||||
kiero::bind(8, (void**)&oPresent11, PresentDx11Handler);
|
kiero::bind(8, (void**)&oPresent11, PresentDx11Handler);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (kiero::init(kiero::RenderType::D3D9) == kiero::Status::Success)
|
||||||
|
{
|
||||||
|
Globals::renderer = Render_DirectX9;
|
||||||
|
kiero::bind(16, (void**)&oReset9, Reset);
|
||||||
|
kiero::bind(17, (void**)&oPresent9, PresentDx9Handler);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Hook::~Hook()
|
Hook::~Hook()
|
||||||
{
|
{
|
||||||
|
SetWindowLongPtr(RsGlobal.ps->window, GWL_WNDPROC, (LRESULT)oWndProc);
|
||||||
ImGui_ImplDX9_Shutdown();
|
ImGui_ImplDX9_Shutdown();
|
||||||
ImGui_ImplWin32_Shutdown();
|
ImGui_ImplWin32_Shutdown();
|
||||||
ImGui::DestroyContext();
|
ImGui::DestroyContext();
|
||||||
|
@ -26,7 +26,6 @@ private:
|
|||||||
protected:
|
protected:
|
||||||
static bool show_mouse;
|
static bool show_mouse;
|
||||||
static std::function<void()> window_callback;
|
static std::function<void()> window_callback;
|
||||||
|
|
||||||
Hook();
|
Hook();
|
||||||
~Hook();
|
~Hook();
|
||||||
};
|
};
|
||||||
|
@ -15,7 +15,7 @@ CJson::CJson(const char* name)
|
|||||||
}
|
}
|
||||||
catch (...)
|
catch (...)
|
||||||
{
|
{
|
||||||
flog << "Error occured trying to read " << file_path << std::endl;
|
flog << "Error trying to read " << file_path << std::endl;
|
||||||
data = "{}"_json;
|
data = "{}"_json;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -38,8 +38,3 @@ void CJson::LoadData(std::vector<std::string>& vec, std::string& selected) // Te
|
|||||||
for (auto element : data.items())
|
for (auto element : data.items())
|
||||||
vec.push_back(element.key());
|
vec.push_back(element.key());
|
||||||
}
|
}
|
||||||
|
|
||||||
CJson::~CJson()
|
|
||||||
{
|
|
||||||
// Saving here won't work on crash
|
|
||||||
}
|
|
||||||
|
@ -106,7 +106,6 @@ public:
|
|||||||
*/
|
*/
|
||||||
void WriteToDisk();
|
void WriteToDisk();
|
||||||
CJson(const char* text);
|
CJson(const char* text);
|
||||||
~CJson();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -87,7 +87,7 @@ Menu::Menu()
|
|||||||
hotkeys::veh_instant_stop.key2 = config.GetValue("hotkey.veh_instant_stop.key2", VK_NONE);
|
hotkeys::veh_instant_stop.key2 = config.GetValue("hotkey.veh_instant_stop.key2", VK_NONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Menu::ProcessOverlay()
|
void Menu::DrawOverlay()
|
||||||
{
|
{
|
||||||
CPlayerPed* player = FindPlayerPed();
|
CPlayerPed* player = FindPlayerPed();
|
||||||
bool show_menu = overlay::coord || overlay::fps || overlay::loc_name ||
|
bool show_menu = overlay::coord || overlay::fps || overlay::loc_name ||
|
||||||
|
@ -41,9 +41,8 @@ public:
|
|||||||
|
|
||||||
Menu();
|
Menu();
|
||||||
static void Draw();
|
static void Draw();
|
||||||
static void ProcessOverlay();
|
static void DrawOverlay();
|
||||||
static void DrawShortcutsWindow();
|
static void DrawShortcutsWindow();
|
||||||
static void ProcessCommands();
|
static void ProcessCommands();
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
20
src/Neon.cpp
20
src/Neon.cpp
@ -5,13 +5,8 @@
|
|||||||
VehicleExtendedData<Neon::NeonData> Neon::VehNeon;
|
VehicleExtendedData<Neon::NeonData> Neon::VehNeon;
|
||||||
RwTexture* Neon::neon_texture = nullptr;
|
RwTexture* Neon::neon_texture = nullptr;
|
||||||
|
|
||||||
Neon::Neon()
|
|
||||||
{
|
|
||||||
neon_texture = Util::LoadTextureFromPngFile(PLUGIN_PATH((char*)"CheatMenu\\vehicles\\neon_mask.png"));
|
|
||||||
if (!neon_texture)
|
|
||||||
flog << "WARN: Failed to load neon mask" << std::endl;
|
|
||||||
|
|
||||||
Events::vehicleRenderEvent += [](CVehicle* pVeh)
|
void Neon::RenderEvent(CVehicle *pVeh)
|
||||||
{
|
{
|
||||||
NeonData* data = &VehNeon.Get(pVeh);
|
NeonData* data = &VehNeon.Get(pVeh);
|
||||||
if (data->neon_installed && !pVeh->IsUpsideDown())
|
if (data->neon_installed && !pVeh->IsUpsideDown())
|
||||||
@ -41,12 +36,21 @@ Neon::Neon()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
|
Neon::Neon()
|
||||||
|
{
|
||||||
|
neon_texture = Util::LoadTextureFromPngFile(PLUGIN_PATH((char*)"CheatMenu\\vehicles\\neon_mask.png"));
|
||||||
|
if (!neon_texture)
|
||||||
|
flog << "Failed to load neon mask" << std::endl;
|
||||||
|
|
||||||
|
Events::vehicleRenderEvent += RenderEvent;
|
||||||
}
|
}
|
||||||
|
|
||||||
Neon::~Neon()
|
Neon::~Neon()
|
||||||
{
|
{
|
||||||
delete neon_texture;
|
Events::vehicleRenderEvent -= RenderEvent;
|
||||||
|
RwTextureDestroy(neon_texture);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Neon::IsNeonInstalled(CVehicle* pVeh)
|
bool Neon::IsNeonInstalled(CVehicle* pVeh)
|
||||||
|
@ -33,5 +33,6 @@ public:
|
|||||||
static bool IsPulsingEnabled(CVehicle* veh);
|
static bool IsPulsingEnabled(CVehicle* veh);
|
||||||
static void SetPulsing(CVehicle* veh, bool state);
|
static void SetPulsing(CVehicle* veh, bool state);
|
||||||
static void RemoveNeon(CVehicle* veh);
|
static void RemoveNeon(CVehicle* veh);
|
||||||
|
static void RenderEvent(CVehicle* veh);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -34,30 +34,19 @@ VehicleExtendedData<Paint::VehData> Paint::vehdata;
|
|||||||
|
|
||||||
std::map<std::string, std::shared_ptr<RwTexture>> Paint::textures;
|
std::map<std::string, std::shared_ptr<RwTexture>> Paint::textures;
|
||||||
|
|
||||||
Paint::Paint()
|
void Paint::RenderEvent(CVehicle* pVeh)
|
||||||
{
|
{
|
||||||
for (auto& p : fs::recursive_directory_iterator(PLUGIN_PATH((char*)"\\CheatMenu\\vehicles\\paintjobs\\")))
|
VehData& data = vehdata.Get(pVeh);
|
||||||
{
|
|
||||||
if (p.path().extension() == ".png")
|
|
||||||
{
|
|
||||||
std::string file_name = p.path().stem().string();
|
|
||||||
textures[file_name] = std::make_shared<RwTexture>(*(Util::LoadTextureFromPngFile(p.path())));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Events::vehicleRenderEvent.before += [](CVehicle* veh)
|
|
||||||
{
|
|
||||||
VehData& data = vehdata.Get(veh);
|
|
||||||
|
|
||||||
// reset custom color if color id changed
|
// reset custom color if color id changed
|
||||||
if (veh->m_nPrimaryColor != data.primary_color
|
if (pVeh->m_nPrimaryColor != data.primary_color
|
||||||
|| veh->m_nSecondaryColor != data.secondary_color)
|
|| pVeh->m_nSecondaryColor != data.secondary_color)
|
||||||
{
|
{
|
||||||
for (auto& it : data.materialProperties)
|
for (auto& it : data.materialProperties)
|
||||||
data.resetMaterialColor(it.first);
|
data.resetMaterialColor(it.first);
|
||||||
|
|
||||||
data.primary_color = veh->m_nPrimaryColor;
|
data.primary_color = pVeh->m_nPrimaryColor;
|
||||||
data.secondary_color = veh->m_nSecondaryColor;
|
data.secondary_color = pVeh->m_nSecondaryColor;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto& it : data.materialProperties)
|
for (auto& it : data.materialProperties)
|
||||||
@ -83,10 +72,11 @@ Paint::Paint()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
Events::vehicleResetAfterRender += [](CVehicle* veh) {
|
void Paint::ResetAfterRenderEvent(CVehicle* pVeh)
|
||||||
for (auto& it : vehdata.Get(veh).materialProperties)
|
{
|
||||||
|
for (auto& it : vehdata.Get(pVeh).materialProperties)
|
||||||
{
|
{
|
||||||
if (it.second._recolor)
|
if (it.second._recolor)
|
||||||
{
|
{
|
||||||
@ -98,7 +88,27 @@ Paint::Paint()
|
|||||||
it.first->texture = it.second._originalTexture;
|
it.first->texture = it.second._originalTexture;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
|
Paint::Paint()
|
||||||
|
{
|
||||||
|
for (auto& p : fs::recursive_directory_iterator(PLUGIN_PATH((char*)"\\CheatMenu\\vehicles\\paintjobs\\")))
|
||||||
|
{
|
||||||
|
if (p.path().extension() == ".png")
|
||||||
|
{
|
||||||
|
std::string file_name = p.path().stem().string();
|
||||||
|
textures[file_name] = std::make_shared<RwTexture>(*(Util::LoadTextureFromPngFile(p.path())));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Events::vehicleRenderEvent.before += RenderEvent;
|
||||||
|
Events::vehicleResetAfterRender += ResetAfterRenderEvent;
|
||||||
|
}
|
||||||
|
|
||||||
|
Paint::~Paint()
|
||||||
|
{
|
||||||
|
Events::vehicleRenderEvent.before -= RenderEvent;
|
||||||
|
Events::vehicleResetAfterRender -= ResetAfterRenderEvent;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Paint::VehData::setMaterialColor(RpMaterial* material, RpGeometry* geometry, RwRGBA color, bool filter_mat)
|
void Paint::VehData::setMaterialColor(RpMaterial* material, RpGeometry* geometry, RwRGBA color, bool filter_mat)
|
||||||
|
@ -85,11 +85,14 @@ protected:
|
|||||||
};
|
};
|
||||||
|
|
||||||
Paint();
|
Paint();
|
||||||
|
~Paint();
|
||||||
static void UpdateNodeListRecursive(CVehicle* pVeh);
|
static void UpdateNodeListRecursive(CVehicle* pVeh);
|
||||||
static void NodeWrapperRecursive(RwFrame* frame, CVehicle* pVeh, std::function<void(RwFrame*)> func);
|
static void NodeWrapperRecursive(RwFrame* frame, CVehicle* pVeh, std::function<void(RwFrame*)> func);
|
||||||
static void SetNodeColor(CVehicle* pVeh, std::string node_name, CRGBA color, bool filter_mat = false);
|
static void SetNodeColor(CVehicle* pVeh, std::string node_name, CRGBA color, bool filter_mat = false);
|
||||||
static void SetNodeTexture(CVehicle* pVeh, std::string node_name, std::string texturename, bool filter_mat = false);
|
static void SetNodeTexture(CVehicle* pVeh, std::string node_name, std::string texturename, bool filter_mat = false);
|
||||||
static void ResetNodeColor(CVehicle* veh, std::string node_name);
|
static void ResetNodeColor(CVehicle* veh, std::string node_name);
|
||||||
static void ResetNodeTexture(CVehicle* pVeh, std::string node_name);
|
static void ResetNodeTexture(CVehicle* pVeh, std::string node_name);
|
||||||
|
static void RenderEvent(CVehicle* pVeh);
|
||||||
|
static void ResetAfterRenderEvent(CVehicle* pVeh);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -52,7 +52,7 @@ Player::Player()
|
|||||||
if (file_name.size() < 9)
|
if (file_name.size() < 9)
|
||||||
custom_skins::store_vec.push_back(file_name);
|
custom_skins::store_vec.push_back(file_name);
|
||||||
else
|
else
|
||||||
flog << "WARN: Custom Skin longer than 8 characters " << file_name << std::endl;
|
flog << "Custom Skin longer than 8 characters " << file_name << std::endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -76,7 +76,7 @@ void Ui::CenterdText(const std::string& text)
|
|||||||
ImGui::Text(text.c_str());
|
ImGui::Text(text.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
void Ui::DrawHeaders(unsortedMap& data)
|
void Ui::DrawHeaders(CallbackTable& data)
|
||||||
{
|
{
|
||||||
|
|
||||||
ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(0, 0));
|
ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(0, 0));
|
||||||
|
2
src/Ui.h
2
src/Ui.h
@ -38,7 +38,7 @@ public:
|
|||||||
static bool CheckboxAddressVarEx(const char* label, bool val, int addr, int enabled_val, int disabled_val, const char* hint = nullptr);
|
static bool CheckboxAddressVarEx(const char* label, bool val, int addr, int enabled_val, int disabled_val, const char* hint = nullptr);
|
||||||
static bool CheckboxBitFlag(const char* label, uint flag, const char* hint = nullptr);
|
static bool CheckboxBitFlag(const char* label, uint flag, const char* hint = nullptr);
|
||||||
static bool CheckboxWithHint(const char* label, bool* state, const char* hint = nullptr, const bool is_disabled = false);
|
static bool CheckboxWithHint(const char* label, bool* state, const char* hint = nullptr, const bool is_disabled = false);
|
||||||
static void DrawHeaders(unsortedMap& data);
|
static void DrawHeaders(CallbackTable& data);
|
||||||
|
|
||||||
static void DrawJSON(CJson& json, std::vector<std::string>& combo_items, std::string& selected_item, ImGuiTextFilter& filter,
|
static void DrawJSON(CJson& json, std::vector<std::string>& combo_items, std::string& selected_item, ImGuiTextFilter& filter,
|
||||||
std::function<void(std::string&, std::string&, std::string&)> func_left_click, std::function<void(std::string&, std::string&, std::string&)> func_right_click);
|
std::function<void(std::string&, std::string&, std::string&)> func_left_click, std::function<void(std::string&, std::string&, std::string&)> func_right_click);
|
||||||
|
@ -48,7 +48,7 @@ void Util::LoadTexturesInDirRecursive(const char* path, const char* file_ext, st
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
flog << "WARN: Failed to load " << p.path().stem().string() << std::endl;
|
flog << "Failed to load " << p.path().stem().string() << std::endl;
|
||||||
store_vec.pop_back();
|
store_vec.pop_back();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -234,7 +234,7 @@ void Vehicle::AddComponent(const std::string& component, const bool display_mess
|
|||||||
}
|
}
|
||||||
catch (...)
|
catch (...)
|
||||||
{
|
{
|
||||||
flog << "Failed to add " << component << " to vehicle." << std::endl;
|
flog << "Failed to component to vehicle " << component << std::endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -253,7 +253,7 @@ void Vehicle::RemoveComponent(const std::string& component, const bool display_m
|
|||||||
}
|
}
|
||||||
catch (...)
|
catch (...)
|
||||||
{
|
{
|
||||||
flog << "Failed to remove " << component << " from vehicle." << std::endl;
|
flog << "Failed to remove component from vehicle " << component << std::endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -326,7 +326,7 @@ void Vehicle::ParseVehiclesIDE()
|
|||||||
}
|
}
|
||||||
catch (...)
|
catch (...)
|
||||||
{
|
{
|
||||||
flog << "Error occured while parsing line, " << line << std::endl;
|
flog << "Error while parsing line, " << line << std::endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -397,7 +397,7 @@ void Vehicle::ParseCarcolsDAT()
|
|||||||
}
|
}
|
||||||
catch (...)
|
catch (...)
|
||||||
{
|
{
|
||||||
flog << "Error occured while parsing car line, " << line << std::endl;
|
flog << "Error while parsing car line, " << line << std::endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -422,7 +422,7 @@ void Vehicle::ParseCarcolsDAT()
|
|||||||
}
|
}
|
||||||
catch (...)
|
catch (...)
|
||||||
{
|
{
|
||||||
flog << "Error occured while parsing car line, " << line << std::endl;
|
flog << "Error while parsing car line, " << line << std::endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -430,7 +430,7 @@ void Vehicle::ParseCarcolsDAT()
|
|||||||
|
|
||||||
file.close();
|
file.close();
|
||||||
}
|
}
|
||||||
else flog << "Vehicle.ide file not found";
|
else flog << "Error locating Vehicle.ide";
|
||||||
}
|
}
|
||||||
|
|
||||||
void Vehicle::SpawnVehicle(std::string& smodel)
|
void Vehicle::SpawnVehicle(std::string& smodel)
|
||||||
|
@ -63,19 +63,15 @@
|
|||||||
#include "VKeys.h"
|
#include "VKeys.h"
|
||||||
|
|
||||||
// Globals
|
// Globals
|
||||||
typedef std::vector<std::pair<std::string, void(*)(void)>> unsortedMap;
|
typedef std::vector<std::pair<std::string, void(*)()>> CallbackTable;
|
||||||
using namespace plugin;
|
using namespace plugin;
|
||||||
namespace fs = std::filesystem;
|
namespace fs = std::filesystem;
|
||||||
|
|
||||||
enum Renderer
|
enum Renderer
|
||||||
{
|
{
|
||||||
Render_DirectX9,
|
Render_DirectX9,
|
||||||
Render_DirectX10,
|
|
||||||
Render_DirectX11,
|
Render_DirectX11,
|
||||||
Render_DirectX12,
|
Render_Unknown
|
||||||
Render_OpenGL,
|
|
||||||
Render_Unknown,
|
|
||||||
Render_Vulkan,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Globals
|
struct Globals
|
||||||
|
Loading…
Reference in New Issue
Block a user