Refactor code

This commit is contained in:
Grinch_ 2021-02-25 03:54:45 +06:00
parent 4a4847f417
commit b9cc290603
43 changed files with 750 additions and 2394 deletions

View File

@ -10,7 +10,6 @@ set(GTA_SA_DIR F:/GTASanAndreas)
# Can ignore the below paths if you got them in system paths # Can ignore the below paths if you got them in system paths
set(PLUGIN_SDK_DIR $ENV{PLUGIN_SDK_DIR}) set(PLUGIN_SDK_DIR $ENV{PLUGIN_SDK_DIR})
set(DIRECTX9_SDK_DIR $ENV{DIRECTX9_SDK_DIR}) set(DIRECTX9_SDK_DIR $ENV{DIRECTX9_SDK_DIR})
set(VULKAN_SDK_DIR $ENV{VK_SDK_PATH})
################################################################################ ################################################################################
################################################################################ ################################################################################
@ -94,7 +93,6 @@ include_directories(
"${PLUGIN_SDK_DIR}/shared" "${PLUGIN_SDK_DIR}/shared"
"${PLUGIN_SDK_DIR}/shared/game" "${PLUGIN_SDK_DIR}/shared/game"
"${DIRECTX9_SDK_DIR}/include" "${DIRECTX9_SDK_DIR}/include"
# "${VULKAN_SDK_DIR}/Include"
"deps" "deps"
) )
@ -182,7 +180,6 @@ Depend
target_link_directories(${PROJECT_NAME} PUBLIC target_link_directories(${PROJECT_NAME} PUBLIC
"${PLUGIN_SDK_DIR}/output/lib/" "${PLUGIN_SDK_DIR}/output/lib/"
"${DIRECTX9_SDK_DIR}/lib/x86/" "${DIRECTX9_SDK_DIR}/lib/x86/"
# "${VULKAN_SDK_DIR}/lib32"
"$<$<CONFIG:Release>:" "$<$<CONFIG:Release>:"
"deps/Release/" "deps/Release/"
">" ">"

4
deps/CMakeLists.txt vendored
View File

@ -21,8 +21,6 @@ set(depend_files
"imgui/imgui_impl_dx9.h" "imgui/imgui_impl_dx9.h"
"imgui/imgui_impl_dx11.cpp" "imgui/imgui_impl_dx11.cpp"
"imgui/imgui_impl_dx11.h" "imgui/imgui_impl_dx11.h"
# "imgui/imgui_impl_vulkan.cpp"
# "imgui/imgui_impl_vulkan.h"
"imgui/imgui_impl_win32.cpp" "imgui/imgui_impl_win32.cpp"
"imgui/imgui_impl_win32.h" "imgui/imgui_impl_win32.h"
"imgui/imgui_internal.h" "imgui/imgui_internal.h"
@ -67,8 +65,6 @@ include_directories(
"$ENV{PLUGIN_SDK_DIR}/shared" "$ENV{PLUGIN_SDK_DIR}/shared"
"$ENV{PLUGIN_SDK_DIR}/shared/game" "$ENV{PLUGIN_SDK_DIR}/shared/game"
"$ENV{DIRECTX9_SDK_DIR}/include" "$ENV{DIRECTX9_SDK_DIR}/include"
# "${VULKAN_SDK_DIR}/Include"
# "${VULKAN_SDK_DIR}/lib32"
) )
target_compile_options(${PROJECT_NAME} PRIVATE target_compile_options(${PROJECT_NAME} PRIVATE

File diff suppressed because it is too large Load Diff

View File

@ -1,148 +0,0 @@
// dear imgui: Renderer Backend for Vulkan
// This needs to be used along with a Platform Backend (e.g. GLFW, SDL, Win32, custom..)
// Implemented features:
// [X] Renderer: Support for large meshes (64k+ vertices) with 16-bit indices.
// Missing features:
// [ ] Renderer: User texture binding. Changes of ImTextureID aren't supported by this backend! See https://github.com/ocornut/imgui/pull/914
// You can copy and use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
// If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp.
// Read online: https://github.com/ocornut/imgui/tree/master/docs
// The aim of imgui_impl_vulkan.h/.cpp is to be usable in your engine without any modification.
// IF YOU FEEL YOU NEED TO MAKE ANY CHANGE TO THIS CODE, please share them and your feedback at https://github.com/ocornut/imgui/
// Important note to the reader who wish to integrate imgui_impl_vulkan.cpp/.h in their own engine/app.
// - Common ImGui_ImplVulkan_XXX functions and structures are used to interface with imgui_impl_vulkan.cpp/.h.
// You will use those if you want to use this rendering backend in your engine/app.
// - Helper ImGui_ImplVulkanH_XXX functions and structures are only used by this example (main.cpp) and by
// the backend itself (imgui_impl_vulkan.cpp), but should PROBABLY NOT be used by your own engine/app code.
// Read comments in imgui_impl_vulkan.h.
#pragma once
#include "imgui.h" // IMGUI_IMPL_API
// [Configuration] in order to use a custom Vulkan function loader:
// (1) You'll need to disable default Vulkan function prototypes.
// We provide a '#define IMGUI_IMPL_VULKAN_NO_PROTOTYPES' convenience configuration flag.
// In order to make sure this is visible from the imgui_impl_vulkan.cpp compilation unit:
// - Add '#define IMGUI_IMPL_VULKAN_NO_PROTOTYPES' in your imconfig.h file
// - Or as a compilation flag in your build system
// - Or uncomment here (not recommended because you'd be modifying imgui sources!)
// - Do not simply add it in a .cpp file!
// (2) Call ImGui_ImplVulkan_LoadFunctions() before ImGui_ImplVulkan_Init() with your custom function.
// If you have no idea what this is, leave it alone!
//#define IMGUI_IMPL_VULKAN_NO_PROTOTYPES
// Vulkan includes
#if defined(IMGUI_IMPL_VULKAN_NO_PROTOTYPES) && !defined(VK_NO_PROTOTYPES)
#define VK_NO_PROTOTYPES
#endif
#include <vulkan/vulkan.h>
// Initialization data, for ImGui_ImplVulkan_Init()
// [Please zero-clear before use!]
struct ImGui_ImplVulkan_InitInfo
{
VkInstance Instance;
VkPhysicalDevice PhysicalDevice;
VkDevice Device;
uint32_t QueueFamily;
VkQueue Queue;
VkPipelineCache PipelineCache;
VkDescriptorPool DescriptorPool;
uint32_t Subpass;
uint32_t MinImageCount; // >= 2
uint32_t ImageCount; // >= MinImageCount
VkSampleCountFlagBits MSAASamples; // >= VK_SAMPLE_COUNT_1_BIT
const VkAllocationCallbacks* Allocator;
void (*CheckVkResultFn)(VkResult err);
};
// Called by user code
IMGUI_IMPL_API bool ImGui_ImplVulkan_Init(ImGui_ImplVulkan_InitInfo* info, VkRenderPass render_pass);
IMGUI_IMPL_API void ImGui_ImplVulkan_Shutdown();
IMGUI_IMPL_API void ImGui_ImplVulkan_NewFrame();
IMGUI_IMPL_API void ImGui_ImplVulkan_RenderDrawData(ImDrawData* draw_data, VkCommandBuffer command_buffer, VkPipeline pipeline = VK_NULL_HANDLE);
IMGUI_IMPL_API bool ImGui_ImplVulkan_CreateFontsTexture(VkCommandBuffer command_buffer);
IMGUI_IMPL_API void ImGui_ImplVulkan_DestroyFontUploadObjects();
IMGUI_IMPL_API void ImGui_ImplVulkan_SetMinImageCount(uint32_t min_image_count); // To override MinImageCount after initialization (e.g. if swap chain is recreated)
// Optional: load Vulkan functions with a custom function loader
// This is only useful with IMGUI_IMPL_VULKAN_NO_PROTOTYPES / VK_NO_PROTOTYPES
IMGUI_IMPL_API bool ImGui_ImplVulkan_LoadFunctions(PFN_vkVoidFunction(*loader_func)(const char* function_name, void* user_data), void* user_data = NULL);
//-------------------------------------------------------------------------
// Internal / Miscellaneous Vulkan Helpers
// (Used by example's main.cpp. Used by multi-viewport features. PROBABLY NOT used by your own engine/app.)
//-------------------------------------------------------------------------
// You probably do NOT need to use or care about those functions.
// Those functions only exist because:
// 1) they facilitate the readability and maintenance of the multiple main.cpp examples files.
// 2) the upcoming multi-viewport feature will need them internally.
// Generally we avoid exposing any kind of superfluous high-level helpers in the backends,
// but it is too much code to duplicate everywhere so we exceptionally expose them.
//
// Your engine/app will likely _already_ have code to setup all that stuff (swap chain, render pass, frame buffers, etc.).
// You may read this code to learn about Vulkan, but it is recommended you use you own custom tailored code to do equivalent work.
// (The ImGui_ImplVulkanH_XXX functions do not interact with any of the state used by the regular ImGui_ImplVulkan_XXX functions)
//-------------------------------------------------------------------------
struct ImGui_ImplVulkanH_Frame;
struct ImGui_ImplVulkanH_Window;
// Helpers
IMGUI_IMPL_API void ImGui_ImplVulkanH_CreateOrResizeWindow(VkInstance instance, VkPhysicalDevice physical_device, VkDevice device, ImGui_ImplVulkanH_Window* wnd, uint32_t queue_family, const VkAllocationCallbacks* allocator, int w, int h, uint32_t min_image_count);
IMGUI_IMPL_API void ImGui_ImplVulkanH_DestroyWindow(VkInstance instance, VkDevice device, ImGui_ImplVulkanH_Window* wnd, const VkAllocationCallbacks* allocator);
IMGUI_IMPL_API VkSurfaceFormatKHR ImGui_ImplVulkanH_SelectSurfaceFormat(VkPhysicalDevice physical_device, VkSurfaceKHR surface, const VkFormat* request_formats, int request_formats_count, VkColorSpaceKHR request_color_space);
IMGUI_IMPL_API VkPresentModeKHR ImGui_ImplVulkanH_SelectPresentMode(VkPhysicalDevice physical_device, VkSurfaceKHR surface, const VkPresentModeKHR* request_modes, int request_modes_count);
IMGUI_IMPL_API int ImGui_ImplVulkanH_GetMinImageCountFromPresentMode(VkPresentModeKHR present_mode);
// Helper structure to hold the data needed by one rendering frame
// (Used by example's main.cpp. Used by multi-viewport features. Probably NOT used by your own engine/app.)
// [Please zero-clear before use!]
struct ImGui_ImplVulkanH_Frame
{
VkCommandPool CommandPool;
VkCommandBuffer CommandBuffer;
VkFence Fence;
VkImage Backbuffer;
VkImageView BackbufferView;
VkFramebuffer Framebuffer;
};
struct ImGui_ImplVulkanH_FrameSemaphores
{
VkSemaphore ImageAcquiredSemaphore;
VkSemaphore RenderCompleteSemaphore;
};
// Helper structure to hold the data needed by one rendering context into one OS window
// (Used by example's main.cpp. Used by multi-viewport features. Probably NOT used by your own engine/app.)
struct ImGui_ImplVulkanH_Window
{
int Width;
int Height;
VkSwapchainKHR Swapchain;
VkSurfaceKHR Surface;
VkSurfaceFormatKHR SurfaceFormat;
VkPresentModeKHR PresentMode;
VkRenderPass RenderPass;
VkPipeline Pipeline; // The window pipeline may uses a different VkRenderPass than the one passed in ImGui_ImplVulkan_InitInfo
bool ClearEnable;
VkClearValue ClearValue;
uint32_t FrameIndex; // Current frame being rendered to (0 <= FrameIndex < FrameInFlightCount)
uint32_t ImageCount; // Number of simultaneous in-flight frames (returned by vkGetSwapchainImagesKHR, usually derived from min_image_count)
uint32_t SemaphoreIndex; // Current set of swapchain wait semaphores we're using (needs to be distinct from per frame data)
ImGui_ImplVulkanH_Frame* Frames;
ImGui_ImplVulkanH_FrameSemaphores* FrameSemaphores;
ImGui_ImplVulkanH_Window()
{
memset(this, 0, sizeof(*this));
PresentMode = VK_PRESENT_MODE_MAX_ENUM_KHR;
ClearEnable = true;
}
};

View File

@ -28,7 +28,7 @@ Animation::Animation()
json.LoadData(search_categories, selected_item); json.LoadData(search_categories, selected_item);
} }
void Animation::Main() void Animation::Draw()
{ {
if (ImGui::BeginTabBar("Animation", ImGuiTabBarFlags_NoTooltip + ImGuiTabBarFlags_FittingPolicyScroll)) if (ImGui::BeginTabBar("Animation", ImGuiTabBarFlags_NoTooltip + ImGuiTabBarFlags_FittingPolicyScroll))
{ {
@ -140,7 +140,8 @@ void Animation::RemoveAnimation(std::string& ifp, std::string& anim, std::string
json.data["Custom"].erase(anim); json.data["Custom"].erase(anim);
json.WriteToDisk(); json.WriteToDisk();
CHud::SetHelpMessage("Animation removed", false, false, false); CHud::SetHelpMessage("Animation removed", false, false, false);
}else CHud::SetHelpMessage("You can only remove custom anims", false, false, false); }
else CHud::SetHelpMessage("You can only remove custom anims", false, false, false);
} }

View File

@ -18,7 +18,7 @@ protected:
~Animation() {}; ~Animation() {};
public: public:
static void Main(); static void Draw();
static void PlayAnimation(std::string& rootkey, std::string& anim, std::string& ifp); static void PlayAnimation(std::string& rootkey, std::string& anim, std::string& ifp);
static void RemoveAnimation(std::string& rootkey, std::string& anim, std::string& ifp); static void RemoveAnimation(std::string& rootkey, std::string& anim, std::string& ifp);
}; };

View File

@ -4,12 +4,12 @@
#include "Ui.h" #include "Ui.h"
unsortedMap CheatMenu::header{ unsortedMap CheatMenu::header{
{ "Teleport", &Teleport::Main },{ "Player", &Player::Main },{ "Ped", &Ped::Main }, { "Teleport", &Teleport::Draw },{ "Player", &Player::Draw },{ "Ped", &Ped::Draw },
{ "Animation", &Animation::Main },{ "Vehicle", &Vehicle::Main },{ "Weapon", &Weapon::Main }, { "Animation", &Animation::Draw },{ "Vehicle", &Vehicle::Draw },{ "Weapon", &Weapon::Draw },
{ "Game", &Game::Main },{ "Visual", &Visual::Main },{ "Menu", &Menu::Main } { "Game", &Game::Draw },{ "Visual", &Visual::Draw },{ "Menu", &Menu::Draw }
}; };
void CheatMenu::ProcessMenu() void CheatMenu::DrawMenu()
{ {
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))
@ -32,12 +32,15 @@ void CheatMenu::ProcessWindow()
{ {
ImGuiIO& io = ImGui::GetIO(); ImGuiIO& io = ImGui::GetIO();
if (!FrontEndMenuManager.m_bMenuActive && (Globals::show_menu || Menu::commands::show_menu)) if (FrontEndMenuManager.m_bMenuActive)
Hook::show_mouse = false;
else
if (Globals::show_menu || Menu::commands::show_menu)
{ {
if (Globals::show_menu) if (Globals::show_menu)
ProcessMenu(); DrawMenu();
else else
Menu::ProcessShortcutsWindow(); Menu::DrawShortcutsWindow();
} }
Menu::ProcessOverlay(); Menu::ProcessOverlay();
@ -45,19 +48,16 @@ void CheatMenu::ProcessWindow()
CheatMenu::CheatMenu() CheatMenu::CheatMenu()
{ {
ApplyImGuiStyle(); ApplyStyle();
Hook::window_callback = std::bind(&ProcessWindow); Hook::window_callback = std::bind(&ProcessWindow);
Events::initRwEvent += []()
{
// Load menu settings // Load menu settings
Globals::header_id = config.GetValue("window.id", std::string("")); Globals::header_id = config.GetValue("window.id", std::string(""));
Globals::menu_size.x = config.GetValue("window.sizeX", screen::GetScreenWidth() / 4.0f); Globals::menu_size.x = config.GetValue("window.sizeX", screen::GetScreenWidth() / 4.0f);
Globals::menu_size.y = config.GetValue("window.sizeY", screen::GetScreenHeight() / 1.2f); Globals::menu_size.y = config.GetValue("window.sizeY", screen::GetScreenHeight() / 1.2f);
srand(CTimer::m_snTimeInMilliseconds); srand(CTimer::m_snTimeInMilliseconds);
};
Events::processScriptsEvent += [this] Events::processScriptsEvent += []
{ {
if (Globals::init_done && !FrontEndMenuManager.m_bMenuActive) if (Globals::init_done && !FrontEndMenuManager.m_bMenuActive)
{ {
@ -83,27 +83,9 @@ CheatMenu::CheatMenu()
} }
} }
}; };
Events::drawMenuBackgroundEvent += [this]
{
if (Hook::show_mouse)
{
config.WriteToDisk();
Hook::show_mouse = false;
}
};
Events::shutdownRwEvent += []
{
flog << "Log Finished." << std::endl;
};
} }
CheatMenu::~CheatMenu() void CheatMenu::ApplyStyle()
{
}
void CheatMenu::ApplyImGuiStyle()
{ {
ImGuiStyle* style = &ImGui::GetStyle(); ImGuiStyle* style = &ImGui::GetStyle();
ImVec4* colors = style->Colors; ImVec4* colors = style->Colors;
@ -176,3 +158,49 @@ void CheatMenu::ApplyImGuiStyle()
colors[ImGuiCol_NavWindowingDimBg] = ImVec4(0.80f, 0.80f, 0.80f, 0.20f); colors[ImGuiCol_NavWindowingDimBg] = ImVec4(0.80f, 0.80f, 0.80f, 0.20f);
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)
{
// Wait till the game is initiallized
Events::initGameEvent.after += []()
{
Globals::game_init = true;
};
while (!Globals::game_init)
Sleep(500);
if (GetModuleHandle("SAMP.dll"))
{
MessageBox(RsGlobal.ps->window, "SAMP detected. Exiting CheatMenu.", "CheatMenu", MB_ICONERROR);
return;
}
// SP fixes some mouse issues
if (!GetModuleHandle("SilentPatchSA.asi"))
{
MessageBox(RsGlobal.ps->window, "SilentPatch isn't installed. Exiting CheatMenu.", "CheatMenu", MB_ICONERROR);
return;
}
flog << "Starting...\nVersion: " MENU_TITLE "\nAuthor: Grinch_\nDiscord: " DISCORD_INVITE "\nMore Info: " GITHUB_LINK "\n\n" << std::endl;
CFastman92limitAdjuster::Init();
CheatMenu cheatmenu;
while (true)
Sleep(5000);
}
BOOL WINAPI DllMain(HINSTANCE hDllHandle, DWORD nReason, LPVOID Reserved)
{
if (nReason == DLL_PROCESS_ATTACH)
{
uint gameVersion = GetGameVersion();
if (gameVersion == GAME_10US_HOODLUM || gameVersion == GAME_10US_COMPACT)
CreateThread(NULL, NULL, (LPTHREAD_START_ROUTINE)&MenuThread, NULL, NULL, NULL);
else
MessageBox(HWND_DESKTOP, "Unknown game version. GTA SA v1.0 US is required.", "CheatMenu", MB_ICONERROR);
}
return TRUE;
}

View File

@ -22,51 +22,11 @@ class CheatMenu : Hook, Animation, Game, Menu, Ped, Player, Teleport, Vehicle, V
{ {
private: private:
static unsortedMap header; static unsortedMap header;
static void ProcessMenu(); static void DrawMenu();
static void ProcessWindow(); static void ProcessWindow();
static void ApplyImGuiStyle(); static void ApplyStyle();
public: public:
CheatMenu(); CheatMenu();
~CheatMenu();
}; };
class Launcher
{
public:
Launcher()
{
Events::initRwEvent += []()
{
bool launch = true;
uint gameVersion = GetGameVersion();
if (gameVersion != GAME_10US_HOODLUM && gameVersion != GAME_10US_COMPACT) {
MessageBox(HWND_DESKTOP, "CheatMenu requires v1.0 US of the game.", "CheatMenu", MB_ICONERROR);
launch = false;
}
if (IsPluginInstalled("SAMP.dll")) {
MessageBox(HWND_DESKTOP, "SAMP detected. Exiting CheatMenu.", "CheatMenu", MB_ICONERROR);
launch = false;
}
/*
Mouse is extremely buggy without SilentPatch
Should have a better fix for this but everyone should have
SilentPatch installed so mehh...
*/
if (!IsPluginInstalled("SilentPatchSA.asi")) {
MessageBox(HWND_DESKTOP, "SilentPatch isn't installed. Exiting CheatMenu.", "CheatMenu", MB_ICONERROR);
launch = false;
}
if (launch)
{
flog << "Loading CheatMenu" << std::endl;
CFastman92limitAdjuster::Init();
static CheatMenu cheatmenu;
}
};
}
} launcher;

View File

@ -1,12 +1,10 @@
#include "pch.h" #include "pch.h"
#include "Events.h" #include "Events.h"
namespace plugin namespace plugin
{ {
namespace Events namespace Events
{ {
decltype(vehicleResetAfterRender) vehicleResetAfterRender; decltype(vehicleResetAfterRender) vehicleResetAfterRender;
decltype(renderscence) renderscence;
} }
} }

View File

@ -5,6 +5,5 @@ namespace plugin
namespace Events namespace Events
{ {
extern ThiscallEvent<AddressList<0x55332A, H_CALL>, PRIORITY_BEFORE, ArgPickN<CVehicle*, 0>, void(CVehicle*)> vehicleResetAfterRender; extern ThiscallEvent<AddressList<0x55332A, H_CALL>, PRIORITY_BEFORE, ArgPickN<CVehicle*, 0>, void(CVehicle*)> vehicleResetAfterRender;
extern ThiscallEvent<AddressList<0x53EABF, H_CALL>, PRIORITY_BEFORE, ArgPickNone, void()> renderscence;
} }
} }

View File

@ -78,8 +78,6 @@ void RealTimeClock(void)
} }
Game::Game() Game::Game()
{
Events::initGameEvent += []
{ {
json.LoadData(search_categories, selected_item); json.LoadData(search_categories, selected_item);
stat::json.LoadData(stat::search_categories, stat::selected_item); stat::json.LoadData(stat::search_categories, stat::selected_item);
@ -96,7 +94,6 @@ Game::Game()
random_cheats::enabled_cheats[std::stoi(element.key())][0] = element.value().get<std::string>(); random_cheats::enabled_cheats[std::stoi(element.key())][0] = element.value().get<std::string>();
random_cheats::enabled_cheats[std::stoi(element.key())][1] = "true"; random_cheats::enabled_cheats[std::stoi(element.key())][1] = "true";
} }
};
Events::processScriptsEvent += [] Events::processScriptsEvent += []
{ {
@ -198,10 +195,6 @@ Game::Game()
}; };
} }
Game::~Game()
{
}
void SetPlayerMission(std::string& rootkey, std::string& name, std::string& id) void SetPlayerMission(std::string& rootkey, std::string& name, std::string& id)
{ {
CPlayerPed* player = FindPlayerPed(); CPlayerPed* player = FindPlayerPed();
@ -346,7 +339,7 @@ void Game::ClearFreecamStuff()
Command<Commands::RESTORE_CAMERA_JUMPCUT>(); Command<Commands::RESTORE_CAMERA_JUMPCUT>();
} }
void Game::Main() void Game::Draw()
{ {
ImGui::Spacing(); ImGui::Spacing();
static CPlayerPed* player = FindPlayerPed(); static CPlayerPed* player = FindPlayerPed();

View File

@ -60,8 +60,7 @@ public:
}; };
Game(); Game();
~Game(); static void Draw();
static void Main();
static void FreeCam(); static void FreeCam();
static void ClearFreecamStuff(); static void ClearFreecamStuff();
}; };

View File

@ -183,11 +183,10 @@ void Hook::ShowMouse(bool state)
{ {
if (mouse_visibility != show_mouse) if (mouse_visibility != show_mouse)
{ {
patch::SetRaw(0x541DF5, (void*)"\xE8\x46\xF3\xFE\xFF", 5); // call CControllerConfigManager::AffectPadFromKeyBoard patch::SetUChar(0x6194A0, 0xE9); // jmp setup
patch::SetUChar(0x746ED0, 0xA1); patch::SetUChar(0x746ED0, 0xA1);
patch::SetRaw(0x53F41F, (void*)"\x85\xC0\x0F\x8C", 4); // xor eax, eax -> test eax, eax , enable camera mouse movement patch::SetRaw(0x53F41F, (void*)"\x85\xC0\x0F\x8C", 4); // xor eax, eax -> test eax, eax , enable camera mouse movement
// jz loc_53F526 -> jl loc_53F526 // jz loc_53F526 -> jl loc_53F526
patch::SetUChar(0x6194A0, 0xE9); // jmp setup
} }
} }
@ -196,7 +195,9 @@ void Hook::ShowMouse(bool state)
CPad::ClearMouseHistory(); CPad::ClearMouseHistory();
CPad::UpdatePads(); CPad::UpdatePads();
// TODO: Replace this with windows cursor
ImGui::GetIO().MouseDrawCursor = state; ImGui::GetIO().MouseDrawCursor = state;
CPad::NewMouseControllerState.X = 0; CPad::NewMouseControllerState.X = 0;
CPad::NewMouseControllerState.Y = 0; CPad::NewMouseControllerState.Y = 0;
mouse_visibility = show_mouse; mouse_visibility = show_mouse;
@ -206,8 +207,7 @@ void Hook::ShowMouse(bool state)
Hook::Hook() Hook::Hook()
{ {
ImGui::CreateContext(); ImGui::CreateContext();
Events::initRwEvent += []()
{
if (kiero::init(kiero::RenderType::D3D9) == kiero::Status::Success) if (kiero::init(kiero::RenderType::D3D9) == kiero::Status::Success)
{ {
Globals::renderer = Render_DirectX9; Globals::renderer = Render_DirectX9;
@ -222,15 +222,7 @@ Hook::Hook()
Globals::renderer = Render_DirectX11; Globals::renderer = Render_DirectX11;
kiero::bind(8, (void**)&oPresent11, PresentDx11Handler); kiero::bind(8, (void**)&oPresent11, PresentDx11Handler);
} }
// if (kiero::init(kiero::RenderType::Vulkan) == kiero::Status::Success)
// {
// Globals::renderer = Render_Vulkan;
// flog << "Vulkan detected!" << std::endl;
// kiero::bind(105, (void**)&hvkCmdDraw, PresentDx11Handler);
// }
} }
};
} }
Hook::~Hook() Hook::~Hook()

View File

@ -37,9 +37,7 @@ char Menu::commands::input_buffer[INPUT_BUFFER_SIZE] = "";
Menu::Menu() Menu::Menu()
{ {
Events::initGameEvent += [] // TODO: use structs
{
// improve these later, use struct
// Load config data // Load config data
overlay::coord = config.GetValue("overlay.coord", false); overlay::coord = config.GetValue("overlay.coord", false);
overlay::fps = config.GetValue("overlay.fps", false); overlay::fps = config.GetValue("overlay.fps", false);
@ -87,11 +85,6 @@ Menu::Menu()
hotkeys::veh_instant_stop.key1 = config.GetValue("hotkey.veh_instant_stop.key1", VK_NONE); hotkeys::veh_instant_stop.key1 = config.GetValue("hotkey.veh_instant_stop.key1", VK_NONE);
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);
};
}
Menu::~Menu()
{
} }
void Menu::ProcessOverlay() void Menu::ProcessOverlay()
@ -164,7 +157,7 @@ void Menu::ProcessOverlay()
} }
} }
void Menu::ProcessShortcutsWindow() void Menu::DrawShortcutsWindow()
{ {
int resX = int(screen::GetScreenWidth()); int resX = int(screen::GetScreenWidth());
int resY = int(screen::GetScreenHeight()); int resY = int(screen::GetScreenHeight());
@ -300,7 +293,7 @@ void Menu::ProcessCommands()
} }
} }
void Menu::Main() void Menu::Draw()
{ {
if (ImGui::BeginTabBar("Menu", ImGuiTabBarFlags_NoTooltip + ImGuiTabBarFlags_FittingPolicyScroll)) if (ImGui::BeginTabBar("Menu", ImGuiTabBarFlags_NoTooltip + ImGuiTabBarFlags_FittingPolicyScroll))
{ {

View File

@ -40,10 +40,9 @@ public:
}; };
Menu(); Menu();
~Menu(); static void Draw();
static void Main();
static void ProcessOverlay(); static void ProcessOverlay();
static void ProcessShortcutsWindow(); static void DrawShortcutsWindow();
static void ProcessCommands(); static void ProcessCommands();
}; };

View File

@ -1,5 +1,5 @@
#pragma once #pragma once
#define MENU_NAME "Cheat Menu" #define MENU_NAME "Cheat Menu"
#define MENU_VERSION "2.6-beta" #define MENU_VERSION "2.6-beta"
#define BUILD_NUMBER "20210221" #define BUILD_NUMBER "20210225"
#define MENU_TITLE MENU_NAME " v" MENU_VERSION "(" BUILD_NUMBER ")" #define MENU_TITLE MENU_NAME " v" MENU_VERSION "(" BUILD_NUMBER ")"

View File

@ -6,14 +6,10 @@ VehicleExtendedData<Neon::NeonData> Neon::VehNeon;
RwTexture* Neon::neon_texture = nullptr; RwTexture* Neon::neon_texture = nullptr;
Neon::Neon() Neon::Neon()
{
Events::initGameEvent += [this]
{ {
neon_texture = Util::LoadTextureFromPngFile(PLUGIN_PATH((char*)"CheatMenu\\vehicles\\neon_mask.png")); neon_texture = Util::LoadTextureFromPngFile(PLUGIN_PATH((char*)"CheatMenu\\vehicles\\neon_mask.png"));
if (!neon_texture) if (!neon_texture)
flog << "Failed to load neon mask" << std::endl; flog << "WARN: Failed to load neon mask" << std::endl;
};
Events::vehicleRenderEvent += [](CVehicle* pVeh) Events::vehicleRenderEvent += [](CVehicle* pVeh)
{ {

View File

@ -35,8 +35,6 @@ 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() Paint::Paint()
{
Events::initGameEvent += []
{ {
for (auto& p : fs::recursive_directory_iterator(PLUGIN_PATH((char*)"\\CheatMenu\\vehicles\\paintjobs\\"))) for (auto& p : fs::recursive_directory_iterator(PLUGIN_PATH((char*)"\\CheatMenu\\vehicles\\paintjobs\\")))
{ {
@ -46,7 +44,6 @@ Paint::Paint()
textures[file_name] = std::make_shared<RwTexture>(*(Util::LoadTextureFromPngFile(p.path()))); textures[file_name] = std::make_shared<RwTexture>(*(Util::LoadTextureFromPngFile(p.path())));
} }
} }
};
Events::vehicleRenderEvent.before += [](CVehicle* veh) Events::vehicleRenderEvent.before += [](CVehicle* veh)
{ {
@ -104,11 +101,6 @@ Paint::Paint()
}; };
} }
Paint::~Paint()
{
}
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)
{ {
auto& matProps = materialProperties[material]; auto& matProps = materialProperties[material];

View File

@ -85,7 +85,6 @@ 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);

View File

@ -7,6 +7,7 @@ ImGuiTextFilter Ped::filter = "";
std::string Ped::selected_item = "All"; std::string Ped::selected_item = "All";
std::vector<std::string> Ped::search_categories; std::vector<std::string> Ped::search_categories;
std::vector<std::unique_ptr<TextureStructure>> Ped::peds_vec; std::vector<std::unique_ptr<TextureStructure>> Ped::peds_vec;
bool Ped::images_loaded = false;
CJson Ped::ped_json = CJson("ped"); CJson Ped::ped_json = CJson("ped");
CJson Ped::pedspecial_json = CJson("ped special"); CJson Ped::pedspecial_json = CJson("ped special");
@ -30,13 +31,16 @@ std::vector<std::string> Ped::spawn_ped::ped_type = {"Civ male","Civ female","Co
"Gang 9","Medic","Dealer","Criminal","Fireman","Prostitute" }; "Gang 9","Medic","Dealer","Criminal","Fireman","Prostitute" };
Ped::Ped() Ped::Ped()
{ {
Events::initGameEvent += [] if (GetModuleHandle("ExGangWars.asi"))
{
Util::LoadTexturesInDirRecursive(PLUGIN_PATH((char*)"CheatMenu\\peds\\"), ".jpg", search_categories, peds_vec);
if (LoadLibraryW(L"ExGangWars.asi"))
exgangwars_installed = true; exgangwars_installed = true;
Events::processScriptsEvent += []
{
if (!images_loaded)
{
Util::LoadTexturesInDirRecursive(PLUGIN_PATH((char*)"CheatMenu\\peds\\"), ".jpg", search_categories, peds_vec);
images_loaded = true;
}
}; };
} }
@ -113,7 +117,7 @@ void Ped::SpawnPed(std::string& model)
} }
} }
void Ped::Main() void Ped::Draw()
{ {
if (ImGui::BeginTabBar("Ped", ImGuiTabBarFlags_NoTooltip + ImGuiTabBarFlags_FittingPolicyScroll)) if (ImGui::BeginTabBar("Ped", ImGuiTabBarFlags_NoTooltip + ImGuiTabBarFlags_FittingPolicyScroll))
{ {

View File

@ -9,6 +9,7 @@ private:
static std::string selected_item; static std::string selected_item;
static std::vector<std::string> search_categories; static std::vector<std::string> search_categories;
static std::vector<std::unique_ptr<TextureStructure>> peds_vec; static std::vector<std::unique_ptr<TextureStructure>> peds_vec;
static bool images_loaded;
static CJson ped_json; static CJson ped_json;
static CJson pedspecial_json; static CJson pedspecial_json;
@ -34,7 +35,7 @@ private:
public: public:
Ped(); Ped();
~Ped(); ~Ped();
static void Main(); static void Draw();
static void SpawnPed(std::string& model); static void SpawnPed(std::string& model);
}; };

View File

@ -15,6 +15,7 @@ ImGuiTextFilter Player::filter = "";
std::vector<std::string> Player::search_categories; std::vector<std::string> Player::search_categories;
std::vector<std::unique_ptr<TextureStructure>> Player::clothes_vec; std::vector<std::unique_ptr<TextureStructure>> Player::clothes_vec;
std::string Player::selected_item = "All"; std::string Player::selected_item = "All";
bool Player::images_loaded = false;
std::string Player::custom_skins::dir = paths::GetGameDirPathA() + std::string("\\modloader\\Custom Skins\\"); std::string Player::custom_skins::dir = paths::GetGameDirPathA() + std::string("\\modloader\\Custom Skins\\");
std::vector<std::string> Player::custom_skins::store_vec; std::vector<std::string> Player::custom_skins::store_vec;
@ -31,17 +32,14 @@ static void PlayerModelBrokenFix()
} }
Player::Player() Player::Player()
{
Events::initGameEvent += []
{ {
// Fix player model being broken after rebuild // Fix player model being broken after rebuild
patch::RedirectCall(0x5A834D, &PlayerModelBrokenFix); patch::RedirectCall(0x5A834D, &PlayerModelBrokenFix);
aim_skin_changer = config.GetValue("aim_skin_changer", false); aim_skin_changer = config.GetValue("aim_skin_changer", false);
Util::LoadTexturesInDirRecursive(PLUGIN_PATH((char*)"CheatMenu\\clothes\\"), ".jpg", search_categories, clothes_vec);
// Custom skins setup // Custom skins setup
if (LoadLibraryW(L"modloader.asi")) if (GetModuleHandle("modloader.asi"))
{ {
if (fs::is_directory(custom_skins::dir)) if (fs::is_directory(custom_skins::dir))
{ {
@ -54,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 << "Custom Skin '" << file_name << "' longer than 8 characters" << std::endl; flog << "WARN: Custom Skin longer than 8 characters " << file_name << std::endl;
} }
} }
} }
@ -62,13 +60,18 @@ Player::Player()
modloader_installed = true; modloader_installed = true;
} }
};
Events::processScriptsEvent += [] Events::processScriptsEvent += []
{ {
uint timer = CTimer::m_snTimeInMilliseconds; uint timer = CTimer::m_snTimeInMilliseconds;
static CPlayerPed* player = FindPlayerPed(); static CPlayerPed* player = FindPlayerPed();
if (!images_loaded)
{
Util::LoadTexturesInDirRecursive(PLUGIN_PATH((char*)"CheatMenu\\clothes\\"), ".jpg", search_categories, clothes_vec);
images_loaded = true;
}
if (keep_position::state) if (keep_position::state)
{ {
if (!player->IsAlive()) if (!player->IsAlive())
@ -131,11 +134,6 @@ Player::Player()
}; };
} }
Player::~Player()
{
}
void Player::ChangePlayerCloth(std::string& name) void Player::ChangePlayerCloth(std::string& name)
{ {
std::stringstream ss(name); std::stringstream ss(name);
@ -206,7 +204,7 @@ void Player::ChangePlayerModel(std::string& model)
} }
} }
void Player::Main() void Player::Draw()
{ {
static CPlayerPed* player = FindPlayerPed(); static CPlayerPed* player = FindPlayerPed();
static int hplayer = CPools::GetPedRef(player); static int hplayer = CPools::GetPedRef(player);

View File

@ -14,6 +14,7 @@ private:
static std::string selected_item; static std::string selected_item;
static std::vector<std::string> search_categories; static std::vector<std::string> search_categories;
static std::vector<std::unique_ptr<TextureStructure>> clothes_vec; static std::vector<std::unique_ptr<TextureStructure>> clothes_vec;
static bool images_loaded;
struct custom_skins struct custom_skins
{ {
@ -27,7 +28,6 @@ public:
static void ChangePlayerCloth(std::string& model); static void ChangePlayerCloth(std::string& model);
static void ChangePlayerModel(std::string& model); static void ChangePlayerModel(std::string& model);
Player(); Player();
~Player(); static void Draw();
static void Main();
}; };

View File

@ -56,12 +56,7 @@ void Teleport::FetchRadarSpriteData()
Teleport::Teleport() Teleport::Teleport()
{ {
json.LoadData(search_categories, selected_item); json.LoadData(search_categories, selected_item);
Events::initGameEvent += []
{
// Load config data
quick_teleport = config.GetValue("quick_teleport", false); quick_teleport = config.GetValue("quick_teleport", false);
};
Events::processScriptsEvent += [] Events::processScriptsEvent += []
{ {
@ -182,7 +177,7 @@ void Teleport::RemoveTeleportEntry(std::string& category, std::string& key, std:
else CHud::SetHelpMessage("You can only remove custom location", false, false, false); else CHud::SetHelpMessage("You can only remove custom location", false, false, false);
} }
void Teleport::Main() void Teleport::Draw()
{ {
if (ImGui::BeginTabBar("Teleport",ImGuiTabBarFlags_NoTooltip+ImGuiTabBarFlags_FittingPolicyScroll)) if (ImGui::BeginTabBar("Teleport",ImGuiTabBarFlags_NoTooltip+ImGuiTabBarFlags_FittingPolicyScroll))
{ {

View File

@ -33,7 +33,7 @@ protected:
Teleport(); Teleport();
public: public:
static void Main(); 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), short interior_id = 0);
static void TeleportToLocation(std::string& rootkey, std::string& loc_name, std::string& loc); static void TeleportToLocation(std::string& rootkey, std::string& loc_name, std::string& loc);
static void RemoveTeleportEntry(std::string& rootkey, std::string& key, std::string& val); static void RemoveTeleportEntry(std::string& rootkey, std::string& key, std::string& val);

View File

@ -41,7 +41,6 @@ void Util::LoadTexturesInDirRecursive(const char *path, const char *file_ext,std
hr = S_OK; hr = S_OK;
} }
if (hr == S_OK) if (hr == S_OK)
{ {
store_vec.back().get()->file_name = p.path().stem().string(); store_vec.back().get()->file_name = p.path().stem().string();
@ -49,7 +48,7 @@ void Util::LoadTexturesInDirRecursive(const char *path, const char *file_ext,std
} }
else else
{ {
flog << "Couldn't load image " << p.path().stem().string() << std::endl; flog << "WARN: Failed to load " << p.path().stem().string() << std::endl;
store_vec.pop_back(); store_vec.pop_back();
} }
} }

View File

@ -14,31 +14,6 @@ public:
static bool IsOnMission(); static bool IsOnMission();
static std::string GetLocationName(CVector *pos); static std::string GetLocationName(CVector *pos);
static void RainbowValues(int &r, int&g, int &b, float speed); static void RainbowValues(int &r, int&g, int &b, float speed);
// This below source is taken from MoonAdditions https://github.com/THE-FYP/MoonAdditions
// MIT License
// Copyright (c) 2012 DK22Pac
// Copyright (c) 2017 FYP
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
static RwTexture* LoadTextureFromPngFile(fs::path path); static RwTexture* LoadTextureFromPngFile(fs::path path);
static void UnloadTexture(RwTexture* texture9); static void UnloadTexture(RwTexture* texture9);
}; };

View File

@ -42,6 +42,7 @@ ImGuiTextFilter Vehicle::tune::filter = "";
std::vector<std::string> Vehicle::tune::search_categories; std::vector<std::string> Vehicle::tune::search_categories;
std::vector<std::unique_ptr<TextureStructure>> Vehicle::tune::image_vec; std::vector<std::unique_ptr<TextureStructure>> Vehicle::tune::image_vec;
std::string Vehicle::tune::selected_item = "All"; std::string Vehicle::tune::selected_item = "All";
bool Vehicle::images_loaded = false;
float Vehicle::neon::color_picker[3]{ 0,0,0 }; float Vehicle::neon::color_picker[3]{ 0,0,0 };
bool Vehicle::neon::rainbow = false; bool Vehicle::neon::rainbow = false;
@ -70,20 +71,21 @@ static std::vector<std::string>(model_flag_names) = // 32 flags
Vehicle::Vehicle() Vehicle::Vehicle()
{ {
Events::initGameEvent += [] ParseVehiclesIDE();
ParseCarcolsDAT();
Events::processScriptsEvent += [this]
{
if (!images_loaded)
{ {
Util::LoadTexturesInDirRecursive(PLUGIN_PATH((char*)"CheatMenu\\vehicles\\images\\"), ".jpg", spawner::search_categories, spawner::image_vec); Util::LoadTexturesInDirRecursive(PLUGIN_PATH((char*)"CheatMenu\\vehicles\\images\\"), ".jpg", spawner::search_categories, spawner::image_vec);
Util::LoadTexturesInDirRecursive(PLUGIN_PATH((char*)"CheatMenu\\vehicles\\components\\"), ".jpg", tune::search_categories, tune::image_vec); Util::LoadTexturesInDirRecursive(PLUGIN_PATH((char*)"CheatMenu\\vehicles\\components\\"), ".jpg", tune::search_categories, tune::image_vec);
Util::LoadTexturesInDirRecursive(PLUGIN_PATH((char*)"CheatMenu\\vehicles\\paintjobs\\"), ".png", texture9::search_categories, texture9::image_vec); Util::LoadTexturesInDirRecursive(PLUGIN_PATH((char*)"CheatMenu\\vehicles\\paintjobs\\"), ".png", texture9::search_categories, texture9::image_vec);
ParseVehiclesIDE(); images_loaded = true;
ParseCarcolsDAT(); }
};
Events::processScriptsEvent += [this]
{
uint timer = CTimer::m_snTimeInMilliseconds; uint timer = CTimer::m_snTimeInMilliseconds;
CPlayerPed* player = FindPlayerPed(); CPlayerPed* player = FindPlayerPed();
CVehicle* veh = player->m_pVehicle; CVehicle* veh = player->m_pVehicle;
@ -626,7 +628,7 @@ void Vehicle::GenerateHandlingDataFile(int phandling)
} }
void Vehicle::Main() void Vehicle::Draw()
{ {
ImGui::Spacing(); ImGui::Spacing();
static CPlayerPed* player = FindPlayerPed(); static CPlayerPed* player = FindPlayerPed();

View File

@ -56,6 +56,7 @@ private:
static std::vector<std::string> search_categories; static std::vector<std::string> search_categories;
static std::vector<std::unique_ptr<TextureStructure>> image_vec; static std::vector<std::unique_ptr<TextureStructure>> image_vec;
}; };
static bool images_loaded;
struct tune struct tune
{ {
@ -82,6 +83,6 @@ public:
static void GenerateHandlingDataFile(int phandling); static void GenerateHandlingDataFile(int phandling);
Vehicle(); Vehicle();
~Vehicle(); ~Vehicle();
static void Main(); static void Draw();
}; };

View File

@ -28,15 +28,12 @@ static bool init_patches = false;
Visual::Visual() Visual::Visual()
{ {
Events::initGameEvent += [] if (GetModuleHandle("timecycle24.asi"))
{
if (LoadLibraryW(L"timecycle24.asi"))
timecyc_hour = 24; timecyc_hour = 24;
};
Events::processScriptsEvent += [] Events::processScriptsEvent += []
{ {
// Improve this later // TODO: Needs improvement
if (lock_weather) if (lock_weather)
{ {
CWeather::OldWeatherType = weather_type_backup; CWeather::OldWeatherType = weather_type_backup;
@ -190,7 +187,7 @@ void Visual::GenerateTimecycFile()
} }
} }
void Visual::Main() void Visual::Draw()
{ {
if (ImGui::BeginTabBar("Visual", ImGuiTabBarFlags_NoTooltip + ImGuiTabBarFlags_FittingPolicyScroll)) if (ImGui::BeginTabBar("Visual", ImGuiTabBarFlags_NoTooltip + ImGuiTabBarFlags_FittingPolicyScroll))
{ {
@ -271,7 +268,7 @@ void Visual::Main()
Ui::ColorPickerAddress("Armour bar", *(int*)0x5890FC, ImVec4(180,25,29,255)); Ui::ColorPickerAddress("Armour bar", *(int*)0x5890FC, ImVec4(180,25,29,255));
Ui::ColorPickerAddress("Health bar", *(int*)0x589331, ImVec4(180,25,29,255)); Ui::ColorPickerAddress("Health bar", *(int*)0x589331, ImVec4(180,25,29,255));
Ui::ColorPickerAddress("Main menu title border color", 0xBAB240, ImVec4(0,0,0,255)); Ui::ColorPickerAddress("Draw menu title border color", 0xBAB240, ImVec4(0,0,0,255));
Ui::ColorPickerAddress("Money color", 0xBAB230, ImVec4(54,104,44,255)); Ui::ColorPickerAddress("Money color", 0xBAB230, ImVec4(54,104,44,255));
static std::vector<Ui::NamedValue> font_outline{{ "No outline", 0 }, { "Thin outline" ,1 }, { "Default outline" ,2 }}; static std::vector<Ui::NamedValue> font_outline{{ "No outline", 0 }, { "Thin outline" ,1 }, { "Default outline" ,2 }};
Ui::EditRadioButtonAddressEx("Money font outline", 0x58F58D, font_outline); Ui::EditRadioButtonAddressEx("Money font outline", 0x58F58D, font_outline);

View File

@ -18,7 +18,7 @@ private:
public: public:
Visual(); Visual();
~Visual(); ~Visual();
static void Main(); static void Draw();
}; };
template<typename T> template<typename T>

View File

@ -7,6 +7,7 @@ ImGuiTextFilter Weapon::filter = "";
std::string Weapon::selected_item = "All"; std::string Weapon::selected_item = "All";
std::vector<std::string> Weapon::search_categories; std::vector<std::string> Weapon::search_categories;
std::vector<std::unique_ptr<TextureStructure>> Weapon::weapon_vec; std::vector<std::unique_ptr<TextureStructure>> Weapon::weapon_vec;
bool Weapon::images_loaded = false;
CJson Weapon::weapon_json = CJson("weapon"); CJson Weapon::weapon_json = CJson("weapon");
bool Weapon::auto_aim = false; bool Weapon::auto_aim = false;
@ -40,13 +41,14 @@ int Weapon::gang_weapons[10][3] =
Weapon::Weapon() Weapon::Weapon()
{ {
Events::initGameEvent += []
{
Util::LoadTexturesInDirRecursive(PLUGIN_PATH((char*)"CheatMenu\\weapons\\"), ".jpg", Weapon::search_categories, Weapon::weapon_vec);
};
Events::processScriptsEvent += [] Events::processScriptsEvent += []
{ {
if (!images_loaded)
{
Util::LoadTexturesInDirRecursive(PLUGIN_PATH((char*)"CheatMenu\\weapons\\"), ".jpg", Weapon::search_categories, Weapon::weapon_vec);
images_loaded = true;
}
CPlayerPed *player = FindPlayerPed(); CPlayerPed *player = FindPlayerPed();
if (auto_aim) if (auto_aim)
{ {
@ -134,7 +136,7 @@ void Weapon::GiveWeaponToPlayer(std::string& weapon_type)
} }
} }
void Weapon::Main() void Weapon::Draw()
{ {
CPlayerPed *player = FindPlayerPed(); CPlayerPed *player = FindPlayerPed();
uint hplayer = CPools::GetPedRef(player); uint hplayer = CPools::GetPedRef(player);

View File

@ -7,6 +7,7 @@ private:
static std::string selected_item; static std::string selected_item;
static std::vector<std::string> search_categories; static std::vector<std::string> search_categories;
static std::vector<std::unique_ptr<TextureStructure>> weapon_vec; static std::vector<std::unique_ptr<TextureStructure>> weapon_vec;
static bool images_loaded;
static CJson weapon_json; static CJson weapon_json;
@ -32,7 +33,7 @@ public:
Weapon(); Weapon();
~Weapon(); ~Weapon();
static void Main(); static void Draw();
static void GiveWeaponToPlayer(std::string& weapon_type); static void GiveWeaponToPlayer(std::string& weapon_type);
static void SetGangWeapon(std::string& weapon_type); static void SetGangWeapon(std::string& weapon_type);
}; };

View File

@ -7,6 +7,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;
void* Globals::device = nullptr; void* Globals::device = nullptr;
bool Globals::game_init = false;
std::ofstream flog = std::ofstream("CheatMenu.log"); std::ofstream flog = std::ofstream("CheatMenu.log");
CJson config = CJson("config"); CJson config = CJson("config");

View File

@ -56,7 +56,6 @@
#include "imgui/imgui_internal.h" #include "imgui/imgui_internal.h"
#include "imgui/imgui_impl_dx9.h" #include "imgui/imgui_impl_dx9.h"
#include "imgui/imgui_impl_dx11.h" #include "imgui/imgui_impl_dx11.h"
// #include "imgui/imgui_impl_vulkan.h"
#include "imgui/imgui_impl_win32.h" #include "imgui/imgui_impl_win32.h"
#include "Events.h" #include "Events.h"
@ -86,6 +85,7 @@ struct Globals
static ImVec2 screen_size; static ImVec2 screen_size;
static bool show_menu; static bool show_menu;
static bool init_done; static bool init_done;
static bool game_init;
static Renderer renderer; static Renderer renderer;
static void* device; static void* device;
}; };