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
set(PLUGIN_SDK_DIR $ENV{PLUGIN_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/game"
"${DIRECTX9_SDK_DIR}/include"
# "${VULKAN_SDK_DIR}/Include"
"deps"
)
@ -182,7 +180,6 @@ Depend
target_link_directories(${PROJECT_NAME} PUBLIC
"${PLUGIN_SDK_DIR}/output/lib/"
"${DIRECTX9_SDK_DIR}/lib/x86/"
# "${VULKAN_SDK_DIR}/lib32"
"$<$<CONFIG: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_dx11.cpp"
"imgui/imgui_impl_dx11.h"
# "imgui/imgui_impl_vulkan.cpp"
# "imgui/imgui_impl_vulkan.h"
"imgui/imgui_impl_win32.cpp"
"imgui/imgui_impl_win32.h"
"imgui/imgui_internal.h"
@ -67,8 +65,6 @@ include_directories(
"$ENV{PLUGIN_SDK_DIR}/shared"
"$ENV{PLUGIN_SDK_DIR}/shared/game"
"$ENV{DIRECTX9_SDK_DIR}/include"
# "${VULKAN_SDK_DIR}/Include"
# "${VULKAN_SDK_DIR}/lib32"
)
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);
}
void Animation::Main()
void Animation::Draw()
{
if (ImGui::BeginTabBar("Animation", ImGuiTabBarFlags_NoTooltip + ImGuiTabBarFlags_FittingPolicyScroll))
{
@ -70,7 +70,7 @@ void Animation::Main()
if (Ui::ListBox("Fighting", fighting_vec, fighting_selected))
{
Command<Commands::GIVE_MELEE_ATTACK_TO_CHAR>(hplayer, fighting_selected + 4, 6);
CHud::SetHelpMessage("Fighting anim set",false,false,false);
CHud::SetHelpMessage("Fighting anim set", false, false, false);
}
if (Ui::ListBoxStr("Walking", walking_vec, walking_selected))
{
@ -140,7 +140,8 @@ void Animation::RemoveAnimation(std::string& ifp, std::string& anim, std::string
json.data["Custom"].erase(anim);
json.WriteToDisk();
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() {};
public:
static void Main();
static void Draw();
static void PlayAnimation(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"
unsortedMap CheatMenu::header{
{ "Teleport", &Teleport::Main },{ "Player", &Player::Main },{ "Ped", &Ped::Main },
{ "Animation", &Animation::Main },{ "Vehicle", &Vehicle::Main },{ "Weapon", &Weapon::Main },
{ "Game", &Game::Main },{ "Visual", &Visual::Main },{ "Menu", &Menu::Main }
{ "Teleport", &Teleport::Draw },{ "Player", &Player::Draw },{ "Ped", &Ped::Draw },
{ "Animation", &Animation::Draw },{ "Vehicle", &Vehicle::Draw },{ "Weapon", &Weapon::Draw },
{ "Game", &Game::Draw },{ "Visual", &Visual::Draw },{ "Menu", &Menu::Draw }
};
void CheatMenu::ProcessMenu()
void CheatMenu::DrawMenu()
{
ImGui::SetNextWindowSize(Globals::menu_size);
if (ImGui::Begin(MENU_TITLE, &Globals::show_menu, ImGuiWindowFlags_NoCollapse))
@ -32,12 +32,15 @@ void CheatMenu::ProcessWindow()
{
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)
ProcessMenu();
DrawMenu();
else
Menu::ProcessShortcutsWindow();
Menu::DrawShortcutsWindow();
}
Menu::ProcessOverlay();
@ -45,19 +48,16 @@ void CheatMenu::ProcessWindow()
CheatMenu::CheatMenu()
{
ApplyImGuiStyle();
ApplyStyle();
Hook::window_callback = std::bind(&ProcessWindow);
Events::initRwEvent += []()
{
// 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.y = config.GetValue("window.sizeY", screen::GetScreenHeight() / 1.2f);
srand(CTimer::m_snTimeInMilliseconds);
};
Events::processScriptsEvent += [this]
Events::processScriptsEvent += []
{
if (Globals::init_done && !FrontEndMenuManager.m_bMenuActive)
{
@ -69,7 +69,7 @@ CheatMenu::CheatMenu()
if (Menu::commands::show_menu)
{
Menu::ProcessCommands();
strcpy(commands::input_buffer,"");
strcpy(commands::input_buffer, "");
}
Menu::commands::show_menu = !Menu::commands::show_menu;
}
@ -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::ApplyImGuiStyle()
void CheatMenu::ApplyStyle()
{
ImGuiStyle* style = &ImGui::GetStyle();
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_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:
static unsortedMap header;
static void ProcessMenu();
static void DrawMenu();
static void ProcessWindow();
static void ApplyImGuiStyle();
static void ApplyStyle();
public:
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 "Events.h"
namespace plugin
{
namespace Events
{
decltype(vehicleResetAfterRender) vehicleResetAfterRender;
decltype(renderscence) renderscence;
}
}

View File

@ -5,6 +5,5 @@ namespace plugin
namespace Events
{
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

@ -32,7 +32,7 @@ float Game::freecam::mouseX = 0;
float Game::freecam::mouseY = 0;
int Game::freecam::hped = -1;
float Game::freecam::fov = -1;
CPed *Game::freecam::ped = nullptr;
CPed* Game::freecam::ped = nullptr;
bool Game::hard_mode::state = false;
float Game::hard_mode::prev_armour = 0.0f;
@ -63,15 +63,15 @@ void RealTimeClock(void)
{
static int lastday;
time_t tmp = time(NULL);
struct tm *now = localtime(&tmp);
struct tm* now = localtime(&tmp);
if(now->tm_yday != lastday)
if (now->tm_yday != lastday)
CStats::SetStatValue(0x86, CStats::GetStatValue(0x86) + 1.0f);
lastday = now->tm_yday;
CClock::ms_nGameClockMonth = now->tm_mon+1;
CClock::ms_nGameClockMonth = now->tm_mon + 1;
CClock::ms_nGameClockDays = now->tm_mday;
CClock::CurrentDay = now->tm_wday+1;
CClock::CurrentDay = now->tm_wday + 1;
CClock::ms_nGameClockHours = now->tm_hour;
CClock::ms_nGameClockMinutes = now->tm_min;
CClock::ms_nGameClockSeconds = now->tm_sec;
@ -79,8 +79,6 @@ void RealTimeClock(void)
Game::Game()
{
Events::initGameEvent += []
{
json.LoadData(search_categories, selected_item);
stat::json.LoadData(stat::search_categories, stat::selected_item);
freecam::fov = TheCamera.FindCamFOV();
@ -96,12 +94,11 @@ Game::Game()
random_cheats::enabled_cheats[std::stoi(element.key())][0] = element.value().get<std::string>();
random_cheats::enabled_cheats[std::stoi(element.key())][1] = "true";
}
};
Events::processScriptsEvent += []
{
uint timer = CTimer::m_snTimeInMilliseconds;
static CPlayerPed *player = FindPlayerPed();
static CPlayerPed* player = FindPlayerPed();
static int hplayer = CPools::GetPedRef(player);
if (ss_shortcut)
@ -135,9 +132,9 @@ Game::Game()
if (solid_water_object == 0)
{
Command<Commands::CREATE_OBJECT>(3095, pos.x, pos.y, water_height, &solid_water_object);
Command<Commands::SET_OBJECT_VISIBLE>(solid_water_object,false);
if (pos.z < (water_height+1))
player->SetPosn(pos.x,pos.y,water_height+1);
Command<Commands::SET_OBJECT_VISIBLE>(solid_water_object, false);
if (pos.z < (water_height + 1))
player->SetPosn(pos.x, pos.y, water_height + 1);
}
else
Command<Commands::SET_OBJECT_COORDINATES>(solid_water_object, pos.x, pos.y, water_height);
@ -165,9 +162,9 @@ Game::Game()
}
if (random_cheats::enable
&& (timer - random_cheats::timer) > (uint(random_cheats::enable_wait_time)*1000))
&& (timer - random_cheats::timer) > (uint(random_cheats::enable_wait_time) * 1000))
{
int id = Random(0,91);
int id = Random(0, 91);
for (int i = 0; i < 92; i++)
{
@ -198,19 +195,15 @@ Game::Game()
};
}
Game::~Game()
{
}
void SetPlayerMission(std::string& rootkey, std::string& name, std::string& id)
{
CPlayerPed *player = FindPlayerPed();
CPlayerPed* player = FindPlayerPed();
uint hplayer = CPools::GetPedRef(player);
int interior = 0;
Command<0x09E8>(hplayer,&interior);
Command<0x09E8>(hplayer, &interior);
if ( Util::IsOnMission() && interior == 0)
if (Util::IsOnMission() && interior == 0)
{
player->SetWantedLevel(0);
Command<Commands::LOAD_AND_LAUNCH_MISSION_INTERNAL>(std::stoi(id));
@ -225,18 +218,18 @@ void Game::FreeCam()
if (!freecam::init_done)
{
CPlayerPed *player = FindPlayerPed(-1);
CPlayerPed* player = FindPlayerPed(-1);
Command<Commands::SET_EVERYONE_IGNORE_PLAYER>(0, true);
CHud::bScriptDontDisplayRadar = true;
CHud::m_Wants_To_Draw_Hud = false;
CVector player_pos = player->GetPosition();
CPad::GetPad(0)->DisablePlayerControls = true;
Command<Commands::CREATE_RANDOM_CHAR>(player_pos.x,player_pos.y,player_pos.z, &freecam::hped);
Command<Commands::CREATE_RANDOM_CHAR>(player_pos.x, player_pos.y, player_pos.z, &freecam::hped);
freecam::ped = CPools::GetPed(freecam::hped);
freecam::ped->m_bIsVisible = false;
Command<Commands::FREEZE_CHAR_POSITION_AND_DONT_LOAD_COLLISION>(freecam::hped,true);
Command<Commands::FREEZE_CHAR_POSITION_AND_DONT_LOAD_COLLISION>(freecam::hped, true);
Command<Commands::SET_CHAR_COLLISION>(freecam::hped, false);
Command<Commands::SET_LOAD_COLLISION_FOR_CHAR_FLAG>(freecam::hped, false);
@ -247,15 +240,15 @@ void Game::FreeCam()
player_pos.z -= 20;
freecam::ped->SetPosn(player_pos);
TheCamera.LerpFOV(TheCamera.FindCamFOV(),freecam::fov,1000,true);
TheCamera.LerpFOV(TheCamera.FindCamFOV(), freecam::fov, 1000, true);
Command<Commands::CAMERA_PERSIST_FOV>(true);
}
CVector pos = freecam::ped->GetPosition();
Command<Commands::GET_PC_MOUSE_MOVEMENT>(&freecam::mouseX, &freecam::mouseY);
freecam::tmouseX = freecam::tmouseX - freecam::mouseX/250;
freecam::tmouseY = freecam::tmouseY + freecam::mouseY/3;
freecam::tmouseX = freecam::tmouseX - freecam::mouseX / 250;
freecam::tmouseY = freecam::tmouseY + freecam::mouseY / 3;
if (freecam::tmouseY > 150)
freecam::tmouseY = 150;
@ -265,16 +258,16 @@ void Game::FreeCam()
if (Ui::HotKeyPressed(Menu::hotkeys::free_cam_tp_player))
{
CPlayerPed *player = FindPlayerPed(-1);
CPlayerPed* player = FindPlayerPed(-1);
CVector pos = freecam::ped->GetPosition();
CEntity* player_entity = FindPlayerEntity(-1);
pos.z = CWorld::FindGroundZFor3DCoord(pos.x, pos.y, 1000, 0, &player_entity) + 0.5f;
Command<Commands::SET_CHAR_COORDINATES>(CPools::GetPedRef(player),pos.x,pos.y,pos.z);
Command<Commands::SET_CHAR_COORDINATES>(CPools::GetPedRef(player), pos.x, pos.y, pos.z);
// disble them again cause they get enabled
CHud::bScriptDontDisplayRadar = true;
CHud::m_Wants_To_Draw_Hud = false;
CHud::SetHelpMessage((char*)"Player telported",false,false,false);
CHud::SetHelpMessage((char*)"Player telported", false, false, false);
}
if (KeyPressed(VK_RCONTROL))
@ -289,10 +282,10 @@ void Game::FreeCam()
delta_speed *= -1;
float angle;
Command<Commands::GET_CHAR_HEADING>(freecam::hped,&angle);
pos.x += delta_speed * cos(angle * 3.14159f/180.0f);
pos.y += delta_speed * sin(angle * 3.14159f/180.0f);
pos.z += delta_speed* 2 * sin(freecam::tmouseY/3* 3.14159f/180.0f);
Command<Commands::GET_CHAR_HEADING>(freecam::hped, &angle);
pos.x += delta_speed * cos(angle * 3.14159f / 180.0f);
pos.y += delta_speed * sin(angle * 3.14159f / 180.0f);
pos.z += delta_speed * 2 * sin(freecam::tmouseY / 3 * 3.14159f / 180.0f);
}
if (KeyPressed(VK_KEY_J) || KeyPressed(VK_KEY_L))
@ -301,33 +294,33 @@ void Game::FreeCam()
delta_speed *= -1;
float angle;
Command<Commands::GET_CHAR_HEADING>(freecam::hped,&angle);
Command<Commands::GET_CHAR_HEADING>(freecam::hped, &angle);
angle -= 90;
pos.x += delta_speed * cos(angle * 3.14159f/180.0f);
pos.y += delta_speed * sin(angle * 3.14159f/180.0f);
pos.x += delta_speed * cos(angle * 3.14159f / 180.0f);
pos.y += delta_speed * sin(angle * 3.14159f / 180.0f);
}
if ( CPad::NewMouseControllerState.wheelUp)
if (CPad::NewMouseControllerState.wheelUp)
{
if (freecam::fov > 10.0f)
freecam::fov -= 2.0f * delta_speed;
TheCamera.LerpFOV(TheCamera.FindCamFOV(),freecam::fov,250,true);
TheCamera.LerpFOV(TheCamera.FindCamFOV(), freecam::fov, 250, true);
Command<Commands::CAMERA_PERSIST_FOV>(true);
}
if ( CPad::NewMouseControllerState.wheelDown)
if (CPad::NewMouseControllerState.wheelDown)
{
if (freecam::fov < 115.0f)
freecam::fov += 2.0f * delta_speed;
TheCamera.LerpFOV(TheCamera.FindCamFOV(),freecam::fov,250,true);
TheCamera.LerpFOV(TheCamera.FindCamFOV(), freecam::fov, 250, true);
Command<Commands::CAMERA_PERSIST_FOV>(true);
}
freecam::ped->SetHeading(freecam::tmouseX);
Command<Commands::ATTACH_CAMERA_TO_CHAR>(freecam::hped,0.0,0.0,20.0,90.0,180,freecam::tmouseY,0.0,2);
Command<Commands::ATTACH_CAMERA_TO_CHAR>(freecam::hped, 0.0, 0.0, 20.0, 90.0, 180, freecam::tmouseY, 0.0, 2);
freecam::ped->SetPosn(pos);
CIplStore::AddIplsNeededAtPosn(pos);
}
@ -346,10 +339,10 @@ void Game::ClearFreecamStuff()
Command<Commands::RESTORE_CAMERA_JUMPCUT>();
}
void Game::Main()
void Game::Draw()
{
ImGui::Spacing();
static CPlayerPed *player = FindPlayerPed();
static CPlayerPed* player = FindPlayerPed();
static int hplayer = CPools::GetPedRef(player);
if (ImGui::BeginTabBar("Game", ImGuiTabBarFlags_NoTooltip + ImGuiTabBarFlags_FittingPolicyScroll))
@ -402,7 +395,7 @@ of LS without completing missions"))
if (Ui::CheckboxWithHint("Hard mode", &hard_mode::state, "Makes the game more challanging to play. \n\
Lowers armour, health, stamina etc."))
{
CPlayerPed *player = FindPlayerPed();
CPlayerPed* player = FindPlayerPed();
if (hard_mode::state)
{
@ -415,7 +408,7 @@ Lowers armour, health, stamina etc."))
else
{
player->m_fArmour = hard_mode::prev_armour;
CStats::SetStatValue(STAT_STAMINA,hard_mode::prev_stamina);
CStats::SetStatValue(STAT_STAMINA, hard_mode::prev_stamina);
CStats::SetStatValue(STAT_MAX_HEALTH, hard_mode::prev_max_health);
player->m_fHealth = hard_mode::prev_health;
CWeaponInfo::LoadWeaponData();
@ -452,9 +445,9 @@ Lowers armour, health, stamina etc."))
{
if (ImGui::CollapsingHeader("Current day"))
{
int day = CClock::CurrentDay-1;
int day = CClock::CurrentDay - 1;
if (Ui::ListBox("Select day", day_names, day))
CClock::CurrentDay = day+1;
CClock::CurrentDay = day + 1;
ImGui::Spacing();
ImGui::Separator();
}
@ -472,7 +465,7 @@ Lowers armour, health, stamina etc."))
if (ImGui::SliderFloat("Field of view", &freecam::fov, 5.0f, 120.0f))
{
TheCamera.LerpFOV(TheCamera.FindCamFOV(),freecam::fov,250.0f,true);
TheCamera.LerpFOV(TheCamera.FindCamFOV(), freecam::fov, 250.0f, true);
Command<Commands::CAMERA_PERSIST_FOV>(true);
}
ImGui::SliderFloat("Movement Speed", &freecam::speed, 0.0f, 0.5f);
@ -481,7 +474,7 @@ Lowers armour, health, stamina etc."))
ImGui::Spacing();
ImGui::Separator();
}
Ui::EditReference("Game speed", CTimer::ms_fTimeScale,1, 1, 10);
Ui::EditReference("Game speed", CTimer::ms_fTimeScale, 1, 1, 10);
Ui::EditFloat("Gravity", 0x863984, -1.0f, 0.008f, 1.0f);
if (ImGui::CollapsingHeader("Set time"))
@ -507,13 +500,13 @@ Lowers armour, health, stamina etc."))
ImGui::Separator();
}
static std::vector<Ui::NamedMemory> themes { { "Beach", 0x969159 }, { "Country" ,0x96917D }, { "Fun house" ,0x969176 }, { "Ninja" ,0x96915C }};
static std::vector<Ui::NamedMemory> themes{ { "Beach", 0x969159 }, { "Country" ,0x96917D }, { "Fun house" ,0x969176 }, { "Ninja" ,0x96915C } };
Ui::EditRadioButtonAddress("Themes", themes);
if (ImGui::CollapsingHeader("Weather"))
{
typedef void func(void);
if (ImGui::Button("Foggy",Ui::GetSize(3)))
if (ImGui::Button("Foggy", Ui::GetSize(3)))
((func*)0x438F80)();
ImGui::SameLine();

View File

@ -25,7 +25,7 @@ public:
static float speed;
static float fov;
static bool init_done;
static CPed *ped;
static CPed* ped;
static int hped;
static float mouseX, mouseY, tmouseX, tmouseY;
};
@ -60,8 +60,7 @@ public:
};
Game();
~Game();
static void Main();
static void Draw();
static void FreeCam();
static void ClearFreecamStuff();
};

View File

@ -37,14 +37,14 @@ LRESULT Hook::WndProc(const HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
return CallWindowProc(oWndProc, hWnd, uMsg, wParam, lParam);
}
HRESULT Hook::Reset(IDirect3DDevice9 * pDevice, D3DPRESENT_PARAMETERS * pPresentationParameters)
HRESULT Hook::Reset(IDirect3DDevice9* pDevice, D3DPRESENT_PARAMETERS* pPresentationParameters)
{
ImGui_ImplDX9_InvalidateDeviceObjects();
return oReset9(pDevice, pPresentationParameters);
}
void Hook::Present(void *ptr)
void Hook::Present(void* ptr)
{
ImGuiIO& io = ImGui::GetIO();
@ -53,7 +53,7 @@ void Hook::Present(void *ptr)
Hook::ShowMouse(show_mouse);
// handle window scaling here
ImVec2 size(screen::GetScreenWidth(),screen::GetScreenHeight());
ImVec2 size(screen::GetScreenWidth(), screen::GetScreenHeight());
if (Globals::screen_size.x != size.x && Globals::screen_size.y != size.y)
{
int font_size = int(size.y / 54.85f); // manually tested
@ -68,8 +68,8 @@ void Hook::Present(void *ptr)
if (Globals::screen_size.x != -1 && Globals::screen_size.y != -1)
{
Globals::menu_size.x += (size.x-Globals::screen_size.x) / 4.0f;
Globals::menu_size.y += (size.y-Globals::screen_size.y) / 1.2f;
Globals::menu_size.x += (size.x - Globals::screen_size.x) / 4.0f;
Globals::menu_size.y += (size.y - Globals::screen_size.y) / 1.2f;
}
ImGuiStyle* style = &ImGui::GetStyle();
@ -80,7 +80,7 @@ void Hook::Present(void *ptr)
style->ItemSpacing = ImVec2(8 * scale_x, 4 * scale_y);
style->ScrollbarSize = 12 * scale_x;
style->IndentSpacing = 20 * scale_x;
style->ItemInnerSpacing = ImVec2(4 * scale_x,4 * scale_y);
style->ItemInnerSpacing = ImVec2(4 * scale_x, 4 * scale_y);
Globals::screen_size = size;
}
@ -114,7 +114,7 @@ void Hook::Present(void *ptr)
ImGui_ImplWin32_Init(RsGlobal.ps->window);
// shift trigger fix
patch::Nop(0x00531155,5);
patch::Nop(0x00531155, 5);
if (Globals::renderer == Render_DirectX9)
{
@ -143,7 +143,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);
return oPresent9(pDevice, pSourceRect, pDestRect, hDestWindowOverride, pDirtyRegion);;
@ -183,11 +183,10 @@ void Hook::ShowMouse(bool state)
{
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::SetRaw(0x53F41F, (void*)"\x85\xC0\x0F\x8C", 4); // xor eax, eax -> test eax, eax , enable camera mouse movement
// jz loc_53F526 -> jl loc_53F526
patch::SetUChar(0x6194A0, 0xE9); // jmp setup
}
}
@ -196,7 +195,9 @@ void Hook::ShowMouse(bool state)
CPad::ClearMouseHistory();
CPad::UpdatePads();
// TODO: Replace this with windows cursor
ImGui::GetIO().MouseDrawCursor = state;
CPad::NewMouseControllerState.X = 0;
CPad::NewMouseControllerState.Y = 0;
mouse_visibility = show_mouse;
@ -206,8 +207,7 @@ void Hook::ShowMouse(bool state)
Hook::Hook()
{
ImGui::CreateContext();
Events::initRwEvent += []()
{
if (kiero::init(kiero::RenderType::D3D9) == kiero::Status::Success)
{
Globals::renderer = Render_DirectX9;
@ -222,15 +222,7 @@ Hook::Hook()
Globals::renderer = Render_DirectX11;
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()

View File

@ -1,9 +1,9 @@
#pragma once
#include "pch.h"
typedef HRESULT(CALLBACK *f_Present9)(IDirect3DDevice9*, RECT*, RECT*, HWND, RGNDATA*);
typedef HRESULT(CALLBACK *f_Present11)(IDXGISwapChain*, UINT, UINT);
typedef HRESULT(CALLBACK *f_Reset)(IDirect3DDevice9*, D3DPRESENT_PARAMETERS*);
typedef HRESULT(CALLBACK* f_Present9)(IDirect3DDevice9*, RECT*, RECT*, HWND, RGNDATA*);
typedef HRESULT(CALLBACK* f_Present11)(IDXGISwapChain*, UINT, UINT);
typedef HRESULT(CALLBACK* f_Reset)(IDirect3DDevice9*, D3DPRESENT_PARAMETERS*);
extern IMGUI_IMPL_API LRESULT ImGui_ImplWin32_WndProcHandler(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
@ -16,10 +16,10 @@ private:
static f_Reset oReset9;
static bool mouse_visibility;
static void CALLBACK Present(void *ptr);
static HRESULT CALLBACK PresentDx9Handler(IDirect3DDevice9 *pDevice, RECT* pSourceRect, RECT* pDestRect, HWND hDestWindowOverride, RGNDATA* pDirtyRegion);
static void CALLBACK Present(void* ptr);
static HRESULT CALLBACK PresentDx9Handler(IDirect3DDevice9* pDevice, RECT* pSourceRect, RECT* pDestRect, HWND hDestWindowOverride, RGNDATA* pDirtyRegion);
static HRESULT CALLBACK PresentDx11Handler(IDXGISwapChain* pSwapChain, UINT SyncInterval, UINT Flags);
static HRESULT CALLBACK Reset(IDirect3DDevice9 * pDevice, D3DPRESENT_PARAMETERS * pPresentationParameters);
static HRESULT CALLBACK Reset(IDirect3DDevice9* pDevice, D3DPRESENT_PARAMETERS* pPresentationParameters);
static LRESULT CALLBACK WndProc(const HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
static void ShowMouse(bool state);

View File

@ -3,7 +3,7 @@
CJson::CJson(const char* name)
{
file_path = "./CheatMenu/json/"+ std::string(name) +".json";
file_path = "./CheatMenu/json/" + std::string(name) + ".json";
if (fs::exists(file_path))
{
@ -29,7 +29,7 @@ CJson::CJson(const char* name)
void CJson::WriteToDisk()
{
std::ofstream file(file_path);
file << data.dump(4,' ',false, nlohmann::json::error_handler_t::replace) << std::endl;
file << data.dump(4, ' ', false, nlohmann::json::error_handler_t::replace) << std::endl;
file.close();
}

View File

@ -22,7 +22,7 @@ public:
std::stringstream ss(key);
std::string line;
nlohmann::json *json = &data;
nlohmann::json* json = &data;
while (getline(ss, line, '.'))
json = &((*json)[line]);
@ -47,7 +47,7 @@ public:
std::stringstream ss(key);
std::string line;
nlohmann::json *json = &data;
nlohmann::json* json = &data;
while (getline(ss, line, '.'))
json = &((*json)[line]);
@ -70,7 +70,7 @@ public:
std::stringstream ss(key);
std::string line;
nlohmann::json *json = &data;
nlohmann::json* json = &data;
while (getline(ss, line, '.'))
json = &((*json)[line]);
@ -88,7 +88,7 @@ public:
std::stringstream ss(key);
std::string line;
nlohmann::json *json = &data;
nlohmann::json* json = &data;
while (getline(ss, line, '.'))
json = &((*json)[line]);

View File

@ -23,7 +23,7 @@ HotKeyData Menu::hotkeys::freecam{};
HotKeyData Menu::hotkeys::command_window{};
HotKeyData Menu::hotkeys::flip_veh{};
HotKeyData Menu::hotkeys::fix_veh{};
HotKeyData Menu::hotkeys::free_cam_tp_player{VK_RETURN,VK_RETURN};
HotKeyData Menu::hotkeys::free_cam_tp_player{ VK_RETURN,VK_RETURN };
HotKeyData Menu::hotkeys::god_mode{};
HotKeyData Menu::hotkeys::menu_open{};
HotKeyData Menu::hotkeys::quick_ss{};
@ -37,9 +37,7 @@ char Menu::commands::input_buffer[INPUT_BUFFER_SIZE] = "";
Menu::Menu()
{
Events::initGameEvent += []
{
// improve these later, use struct
// TODO: use structs
// Load config data
overlay::coord = config.GetValue("overlay.coord", false);
overlay::fps = config.GetValue("overlay.fps", false);
@ -87,16 +85,11 @@ Menu::Menu()
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);
};
}
Menu::~Menu()
{
}
void Menu::ProcessOverlay()
{
CPlayerPed *player = FindPlayerPed();
CPlayerPed* player = FindPlayerPed();
bool show_menu = overlay::coord || overlay::fps || overlay::loc_name ||
((overlay::veh_health || overlay::veh_speed) && player->m_pVehicle && player->m_pVehicle->IsDriver(player));
@ -126,7 +119,7 @@ void Menu::ProcessOverlay()
if (show_menu && ImGui::Begin("Overlay", NULL, window_flags))
{
CPlayerPed *player = FindPlayerPed();
CPlayerPed* player = FindPlayerPed();
if (overlay::coord)
{
@ -151,7 +144,7 @@ void Menu::ProcessOverlay()
if (overlay::veh_speed)
{
int speed = player->m_pVehicle->m_vecMoveSpeed.Magnitude()*50; // 02E3 - GET_CAR_SPEED
int speed = player->m_pVehicle->m_vecMoveSpeed.Magnitude() * 50; // 02E3 - GET_CAR_SPEED
ImGui::Text((std::string("Veh Speed: ") + std::to_string(speed)).c_str());
}
}
@ -164,7 +157,7 @@ void Menu::ProcessOverlay()
}
}
void Menu::ProcessShortcutsWindow()
void Menu::DrawShortcutsWindow()
{
int resX = int(screen::GetScreenWidth());
int resY = int(screen::GetScreenHeight());
@ -187,7 +180,7 @@ void Menu::ProcessShortcutsWindow()
{
ProcessCommands();
commands::show_menu = false;
strcpy(commands::input_buffer,"");
strcpy(commands::input_buffer, "");
}
ImGui::PopStyleVar(2);
@ -300,7 +293,7 @@ void Menu::ProcessCommands()
}
}
void Menu::Main()
void Menu::Draw()
{
if (ImGui::BeginTabBar("Menu", ImGuiTabBarFlags_NoTooltip + ImGuiTabBarFlags_FittingPolicyScroll))
{
@ -358,7 +351,7 @@ void Menu::Main()
config.SetValue("hotkey.command_window.key2", hotkeys::command_window.key2);
}
ImGui::Dummy(ImVec2(0,10));
ImGui::Dummy(ImVec2(0, 10));
if (Ui::HotKey("Activate aim skin changer", hotkeys::aim_skin_changer))
{
@ -381,7 +374,7 @@ void Menu::Main()
config.SetValue("hotkey.quick_tp.key2", hotkeys::quick_tp.key2);
}
ImGui::Dummy(ImVec2(0,10));
ImGui::Dummy(ImVec2(0, 10));
if (Ui::HotKey("Fix current vehicle", hotkeys::fix_veh))
{

View File

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

View File

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

View File

@ -7,17 +7,13 @@ RwTexture* Neon::neon_texture = nullptr;
Neon::Neon()
{
Events::initGameEvent += [this]
{
neon_texture = Util::LoadTextureFromPngFile(PLUGIN_PATH((char*)"CheatMenu\\vehicles\\neon_mask.png"));
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)
{
NeonData *data = &VehNeon.Get(pVeh);
NeonData* data = &VehNeon.Get(pVeh);
if (data->neon_installed && !pVeh->IsUpsideDown())
{
CVector Pos = CModelInfo::GetModelInfo(pVeh->m_nModelIndex)->m_pColModel->m_boundBox.m_vecMin;
@ -53,24 +49,24 @@ Neon::~Neon()
delete neon_texture;
}
bool Neon::IsNeonInstalled(CVehicle *pVeh)
bool Neon::IsNeonInstalled(CVehicle* pVeh)
{
return VehNeon.Get(pVeh).neon_installed;
}
bool Neon::IsPulsingEnabled(CVehicle *pVeh)
bool Neon::IsPulsingEnabled(CVehicle* pVeh)
{
return VehNeon.Get(pVeh).pulsing;
}
void Neon::SetPulsing(CVehicle *pVeh, bool state)
void Neon::SetPulsing(CVehicle* pVeh, bool state)
{
VehNeon.Get(pVeh).pulsing = state;
}
void Neon::InstallNeon(CVehicle *pVeh, int red, int green, int blue)
void Neon::InstallNeon(CVehicle* pVeh, int red, int green, int blue)
{
CRGBA &color = VehNeon.Get(pVeh).color;
CRGBA& color = VehNeon.Get(pVeh).color;
color.r = red;
color.g = green;
@ -80,7 +76,7 @@ void Neon::InstallNeon(CVehicle *pVeh, int red, int green, int blue)
VehNeon.Get(pVeh).neon_installed = true;
}
void Neon::RemoveNeon(CVehicle *pVeh)
void Neon::RemoveNeon(CVehicle* pVeh)
{
VehNeon.Get(pVeh).neon_installed = false;
}

View File

@ -14,7 +14,7 @@ private:
bool increment;
bool pulsing;
NeonData(CVehicle *pVeh)
NeonData(CVehicle* pVeh)
{
neon_installed = false;
val = 0.0;
@ -28,10 +28,10 @@ private:
public:
Neon();
~Neon();
static void InstallNeon(CVehicle *veh, int red, int green, int blue);
static bool IsNeonInstalled(CVehicle *veh);
static bool IsPulsingEnabled(CVehicle *veh);
static void SetPulsing(CVehicle *veh, bool state);
static void RemoveNeon(CVehicle *veh);
static void InstallNeon(CVehicle* veh, int red, int green, int blue);
static bool IsNeonInstalled(CVehicle* veh);
static bool IsPulsingEnabled(CVehicle* veh);
static void SetPulsing(CVehicle* veh, bool state);
static void RemoveNeon(CVehicle* veh);
};

View File

@ -36,17 +36,14 @@ std::map<std::string, std::shared_ptr<RwTexture>> Paint::textures;
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\\")))
{
if (p.path().extension() == ".png")
{
std::string file_name = p.path().stem().string();
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)
{
@ -104,16 +101,11 @@ Paint::Paint()
};
}
Paint::~Paint()
{
}
void Paint::VehData::setMaterialColor(RpMaterial* material, RpGeometry* geometry, RwRGBA color, bool filter_mat)
{
auto& matProps = materialProperties[material];
if ( !filter_mat
if (!filter_mat
|| (material->color.red == 0x3C && material->color.green == 0xFF && material->color.blue == 0x00)
|| (material->color.red == 0xFF && material->color.green == 0x00 && material->color.blue == 0xAF))
{
@ -140,7 +132,7 @@ void Paint::VehData::resetMaterialColor(RpMaterial* material)
{
auto& matProps = materialProperties[material];
matProps._recolor = false;
matProps._color = {0, 0, 0, 0};
matProps._color = { 0, 0, 0, 0 };
}
void Paint::VehData::resetMaterialTexture(RpMaterial* material)
@ -150,15 +142,15 @@ void Paint::VehData::resetMaterialTexture(RpMaterial* material)
matProps._texture.reset();
}
void Paint::NodeWrapperRecursive(RwFrame *frame, CVehicle* pVeh, std::function<void(RwFrame*)> func)
void Paint::NodeWrapperRecursive(RwFrame* frame, CVehicle* pVeh, std::function<void(RwFrame*)> func)
{
if (frame)
{
func(frame);
if (RwFrame * newFrame = frame->child)
if (RwFrame* newFrame = frame->child)
NodeWrapperRecursive(newFrame, pVeh, func);
if (RwFrame * newFrame = frame->next)
if (RwFrame* newFrame = frame->next)
NodeWrapperRecursive(newFrame, pVeh, func);
}
return;
@ -166,9 +158,9 @@ void Paint::NodeWrapperRecursive(RwFrame *frame, CVehicle* pVeh, std::function<v
void Paint::UpdateNodeListRecursive(CVehicle* pVeh)
{
RwFrame *frame = (RwFrame *)pVeh->m_pRwClump->object.parent;
RwFrame* frame = (RwFrame*)pVeh->m_pRwClump->object.parent;
NodeWrapperRecursive(frame, pVeh, [](RwFrame *frame)
NodeWrapperRecursive(frame, pVeh, [](RwFrame* frame)
{
const std::string name = GetFrameNodeName(frame);
@ -179,9 +171,9 @@ void Paint::UpdateNodeListRecursive(CVehicle* pVeh)
void Paint::SetNodeColor(CVehicle* pVeh, std::string node_name, CRGBA color, bool filter_mat)
{
RwFrame *frame = (RwFrame *)pVeh->m_pRwClump->object.parent;
RwFrame* frame = (RwFrame*)pVeh->m_pRwClump->object.parent;
NodeWrapperRecursive(frame, pVeh, [&](RwFrame *frame)
NodeWrapperRecursive(frame, pVeh, [&](RwFrame* frame)
{
const std::string name = GetFrameNodeName(frame);
@ -199,7 +191,7 @@ void Paint::SetNodeColor(CVehicle* pVeh, std::string node_name, CRGBA color, boo
RwFrameForAllObjects(frame, [](RwObject* object, void* data) -> RwObject* {
if (object->type == rpATOMIC)
{
RpAtomic *atomic = reinterpret_cast<RpAtomic*>(object);
RpAtomic* atomic = reinterpret_cast<RpAtomic*>(object);
ST* st = reinterpret_cast<ST*>(data);
CRGBA* color = &st->_color;
@ -219,8 +211,8 @@ void Paint::SetNodeColor(CVehicle* pVeh, std::string node_name, CRGBA color, boo
void Paint::SetNodeTexture(CVehicle* pVeh, std::string node_name, std::string texturename, bool filter_mat)
{
RwFrame *frame = (RwFrame *)pVeh->m_pRwClump->object.parent;
NodeWrapperRecursive(frame, pVeh, [&](RwFrame *frame)
RwFrame* frame = (RwFrame*)pVeh->m_pRwClump->object.parent;
NodeWrapperRecursive(frame, pVeh, [&](RwFrame* frame)
{
const std::string name = GetFrameNodeName(frame);
@ -241,7 +233,7 @@ void Paint::SetNodeTexture(CVehicle* pVeh, std::string node_name, std::string te
if (object->type == rpATOMIC)
{
RpAtomic *atomic = reinterpret_cast<RpAtomic*>(object);
RpAtomic* atomic = reinterpret_cast<RpAtomic*>(object);
ST* st = reinterpret_cast<ST*>(data);
VehData& data = vehdata.Get(FindPlayerPed()->m_pVehicle);
@ -255,11 +247,11 @@ void Paint::SetNodeTexture(CVehicle* pVeh, std::string node_name, std::string te
});
}
void Paint::ResetNodeColor(CVehicle *pVeh, std::string node_name)
void Paint::ResetNodeColor(CVehicle* pVeh, std::string node_name)
{
RwFrame *frame = (RwFrame *)pVeh->m_pRwClump->object.parent;
RwFrame* frame = (RwFrame*)pVeh->m_pRwClump->object.parent;
NodeWrapperRecursive(frame, pVeh, [&](RwFrame *frame)
NodeWrapperRecursive(frame, pVeh, [&](RwFrame* frame)
{
const std::string name = GetFrameNodeName(frame);
@ -268,7 +260,7 @@ void Paint::ResetNodeColor(CVehicle *pVeh, std::string node_name)
RwFrameForAllObjects(frame, [](RwObject* object, void* data) -> RwObject* {
if (object->type == rpATOMIC)
{
RpAtomic *atomic = reinterpret_cast<RpAtomic*>(object);
RpAtomic* atomic = reinterpret_cast<RpAtomic*>(object);
VehData& data = vehdata.Get(FindPlayerPed()->m_pVehicle);
for (int i = 0; i < atomic->geometry->matList.numMaterials; ++i)
@ -280,11 +272,11 @@ void Paint::ResetNodeColor(CVehicle *pVeh, std::string node_name)
});
}
void Paint::ResetNodeTexture(CVehicle *pVeh, std::string node_name)
void Paint::ResetNodeTexture(CVehicle* pVeh, std::string node_name)
{
RwFrame *frame = (RwFrame *)pVeh->m_pRwClump->object.parent;
RwFrame* frame = (RwFrame*)pVeh->m_pRwClump->object.parent;
NodeWrapperRecursive(frame, pVeh, [&](RwFrame *frame)
NodeWrapperRecursive(frame, pVeh, [&](RwFrame* frame)
{
const std::string name = GetFrameNodeName(frame);
@ -294,7 +286,7 @@ void Paint::ResetNodeTexture(CVehicle *pVeh, std::string node_name)
if (object->type == rpATOMIC)
{
RpAtomic *atomic = reinterpret_cast<RpAtomic*>(object);
RpAtomic* atomic = reinterpret_cast<RpAtomic*>(object);
VehData& data = vehdata.Get(FindPlayerPed()->m_pVehicle);

View File

@ -36,10 +36,10 @@ private:
struct MaterialProperties
{
MaterialProperties() :
_color{0, 0, 0, 0},
_color{ 0, 0, 0, 0 },
_recolor(false),
_retexture(false),
_originalColor{0, 0, 0, 0},
_originalColor{ 0, 0, 0, 0 },
_originalTexture(nullptr),
_originalGeometryFlags(0),
_geometry(nullptr)
@ -85,12 +85,11 @@ protected:
};
Paint();
~Paint();
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 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 ResetNodeTexture(CVehicle *pVeh, std::string node_name);
static void ResetNodeColor(CVehicle* veh, std::string node_name);
static void ResetNodeTexture(CVehicle* pVeh, std::string node_name);
};

View File

@ -7,6 +7,7 @@ ImGuiTextFilter Ped::filter = "";
std::string Ped::selected_item = "All";
std::vector<std::string> Ped::search_categories;
std::vector<std::unique_ptr<TextureStructure>> Ped::peds_vec;
bool Ped::images_loaded = false;
CJson Ped::ped_json = CJson("ped");
CJson Ped::pedspecial_json = CJson("ped special");
@ -25,18 +26,21 @@ bool Ped::spawn_ped::dont_move = false;
bool Ped::spawn_ped::ped_bleed = false;
int Ped::spawn_ped::weapon_id = 0;
std::vector<std::string> Ped::spawn_ped::ped_type = {"Civ male","Civ female","Cop","Ballas","Grove Street Families","Los Santos Vagos",
std::vector<std::string> Ped::spawn_ped::ped_type = { "Civ male","Civ female","Cop","Ballas","Grove Street Families","Los Santos Vagos",
"San Fierro Rifa","Da Nang Boys","Mafia","Mountain Cloud Triads","Varrio Los Aztecas",
"Gang 9","Medic","Dealer","Criminal","Fireman","Prostitute"};
"Gang 9","Medic","Dealer","Criminal","Fireman","Prostitute" };
Ped::Ped()
{
Events::initGameEvent += []
{
Util::LoadTexturesInDirRecursive(PLUGIN_PATH((char*)"CheatMenu\\peds\\"), ".jpg", search_categories, peds_vec);
if (LoadLibraryW(L"ExGangWars.asi"))
if (GetModuleHandle("ExGangWars.asi"))
exgangwars_installed = true;
Events::processScriptsEvent += []
{
if (!images_loaded)
{
Util::LoadTexturesInDirRecursive(PLUGIN_PATH((char*)"CheatMenu\\peds\\"), ".jpg", search_categories, peds_vec);
images_loaded = true;
}
};
}
@ -59,11 +63,11 @@ void Ped::SpawnPed(std::string& model)
if (Ped::ped_json.data.contains(model))
{
CPlayerPed *player = FindPlayerPed();
CPlayerPed* player = FindPlayerPed();
CVector pos = player->GetPosition();
pos.y += 1;
CPed *ped;
CPed* ped;
int hplayer;
if (Ped::pedspecial_json.data.contains(model))
@ -86,7 +90,7 @@ void Ped::SpawnPed(std::string& model)
CStreaming::RequestModel(imodel, eStreamingFlags::PRIORITY_REQUEST);
CStreaming::LoadAllRequestedModels(false);
Command <Commands::CREATE_CHAR>(spawn_ped::selected_ped_type + 4,imodel,pos.x,pos.y,pos.z+1,&hplayer);
Command <Commands::CREATE_CHAR>(spawn_ped::selected_ped_type + 4, imodel, pos.x, pos.y, pos.z + 1, &hplayer);
CStreaming::SetModelIsDeletable(imodel);
}
@ -113,7 +117,7 @@ void Ped::SpawnPed(std::string& model)
}
}
void Ped::Main()
void Ped::Draw()
{
if (ImGui::BeginTabBar("Ped", ImGuiTabBarFlags_NoTooltip + ImGuiTabBarFlags_FittingPolicyScroll))
{
@ -170,9 +174,9 @@ void Ped::Main()
{
CVector pos = FindPlayerPed()->GetPosition();
CZone szone = CZone();
CZone *pZone = &szone;
CZone* pZone = &szone;
CZoneExtraInfo *zone_info = CTheZones::GetZoneInfo(&pos, &pZone);
CZoneExtraInfo* zone_info = CTheZones::GetZoneInfo(&pos, &pZone);
int density = zone_info->m_nGangDensity[i];
if (ImGui::SliderInt(Ped::gang_names[i].c_str(), &density, 0, 127))
@ -201,7 +205,7 @@ void Ped::Main()
if (ImGui::CollapsingHeader("Recruit anyone"))
{
static std::vector<Ui::NamedMemory> select_weapon{ {"9mm", 0x96917C}, { "AK47", 0x96917D }, { "Rockets", 0x96917E }};
static std::vector<Ui::NamedMemory> select_weapon{ {"9mm", 0x96917C}, { "AK47", 0x96917D }, { "Rockets", 0x96917E } };
Ui::RadioButtonAddress("Select weapon", select_weapon);
ImGui::Spacing();
ImGui::Separator();
@ -210,12 +214,12 @@ void Ped::Main()
{
ImGui::InputInt("Radius", &ped_remove_radius);
ImGui::Spacing();
if (ImGui::Button("Remove peds",Ui::GetSize(1)))
if (ImGui::Button("Remove peds", Ui::GetSize(1)))
{
CPlayerPed *player = FindPlayerPed();
for (CPed *ped : CPools::ms_pPedPool)
CPlayerPed* player = FindPlayerPed();
for (CPed* ped : CPools::ms_pPedPool)
{
if (DistanceBetweenPoints(ped->GetPosition(),player->GetPosition()) < ped_remove_radius
if (DistanceBetweenPoints(ped->GetPosition(), player->GetPosition()) < ped_remove_radius
&& ped->m_pVehicle == nullptr && ped != player)
Command<Commands::DELETE_CHAR>(CPools::GetPedRef(ped));
}

View File

@ -9,6 +9,7 @@ private:
static std::string selected_item;
static std::vector<std::string> search_categories;
static std::vector<std::unique_ptr<TextureStructure>> peds_vec;
static bool images_loaded;
static CJson ped_json;
static CJson pedspecial_json;
@ -34,7 +35,7 @@ private:
public:
Ped();
~Ped();
static void Main();
static void Draw();
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::unique_ptr<TextureStructure>> Player::clothes_vec;
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::vector<std::string> Player::custom_skins::store_vec;
@ -24,28 +25,25 @@ bool Player::modloader_installed = false;
static void PlayerModelBrokenFix()
{
CPlayerPed *player = FindPlayerPed();
CPlayerPed* player = FindPlayerPed();
if (player->m_nModelIndex == 0)
Call<0x5A81E0>(0, player->m_pPlayerData->m_pPedClothesDesc,0xBC1C78,false);
Call<0x5A81E0>(0, player->m_pPlayerData->m_pPedClothesDesc, 0xBC1C78, false);
}
Player::Player()
{
Events::initGameEvent += []
{
// Fix player model being broken after rebuild
patch::RedirectCall(0x5A834D,&PlayerModelBrokenFix);
patch::RedirectCall(0x5A834D, &PlayerModelBrokenFix);
aim_skin_changer = config.GetValue("aim_skin_changer", false);
Util::LoadTexturesInDirRecursive(PLUGIN_PATH((char*)"CheatMenu\\clothes\\"), ".jpg", search_categories, clothes_vec);
// Custom skins setup
if (LoadLibraryW(L"modloader.asi"))
if (GetModuleHandle("modloader.asi"))
{
if (fs::is_directory(custom_skins::dir))
{
for (auto &p : fs::recursive_directory_iterator(custom_skins::dir))
for (auto& p : fs::recursive_directory_iterator(custom_skins::dir))
{
if (p.path().extension() == ".dff")
{
@ -54,7 +52,7 @@ Player::Player()
if (file_name.size() < 9)
custom_skins::store_vec.push_back(file_name);
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;
}
};
Events::processScriptsEvent += []
{
uint timer = CTimer::m_snTimeInMilliseconds;
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 (!player->IsAlive())
@ -100,7 +103,7 @@ Player::Player()
if (aim_skin_changer && Ui::HotKeyPressed(Menu::hotkeys::aim_skin_changer))
{
CPed *target_ped = player->m_pPlayerTargettedPed;
CPed* target_ped = player->m_pPlayerTargettedPed;
if (target_ped)
{
player->SetModelIndex(target_ped->m_nModelIndex);
@ -112,7 +115,7 @@ Player::Player()
{
if (god_mode)
{
CHud::SetHelpMessage("God mode disabled",false,false,false);
CHud::SetHelpMessage("God mode disabled", false, false, false);
patch::Set<bool>(0x96916D, god_mode, false);
player->m_nPhysicalFlags.bBulletProof = false;
@ -124,19 +127,14 @@ Player::Player()
}
else
{
CHud::SetHelpMessage("God mode enabled",false,false,false);
CHud::SetHelpMessage("God mode enabled", false, false, false);
god_mode = true;
}
}
};
}
Player::~Player()
{
}
void Player::ChangePlayerCloth(std::string &name)
void Player::ChangePlayerCloth(std::string& name)
{
std::stringstream ss(name);
std::string temp;
@ -150,7 +148,7 @@ void Player::ChangePlayerCloth(std::string &name)
getline(ss, temp, '$');
std::string texture9 = temp.c_str();
CPlayerPed *player = FindPlayerPed();
CPlayerPed* player = FindPlayerPed();
if (texture9 == "cutoffchinosblue")
{
@ -178,7 +176,7 @@ void Player::ChangePlayerModel(std::string& model)
bool custom_skin = std::find(custom_skins::store_vec.begin(), custom_skins::store_vec.end(), model) != custom_skins::store_vec.end();
if (Ped::ped_json.data.contains(model) || custom_skin)
{
CPlayerPed *player = FindPlayerPed();
CPlayerPed* player = FindPlayerPed();
if (Ped::pedspecial_json.data.contains(model) || custom_skin)
{
std::string name;
@ -198,7 +196,7 @@ void Player::ChangePlayerModel(std::string& model)
{
int imodel = std::stoi(model);
CStreaming::RequestModel(imodel,eStreamingFlags::PRIORITY_REQUEST);
CStreaming::RequestModel(imodel, eStreamingFlags::PRIORITY_REQUEST);
CStreaming::LoadAllRequestedModels(false);
player->SetModelIndex(imodel);
CStreaming::SetModelIsDeletable(imodel);
@ -206,7 +204,7 @@ void Player::ChangePlayerModel(std::string& model)
}
}
void Player::Main()
void Player::Draw()
{
static CPlayerPed* player = FindPlayerPed();
static int hplayer = CPools::GetPedRef(player);
@ -317,7 +315,7 @@ void Player::Main()
Ui::EditStat("Fat", STAT_FAT);
Ui::EditReference("Health", player->m_fHealth, 0, 100, static_cast<int>(player->m_fMaxHealth));
Ui::EditStat("Lung capacity", STAT_LUNG_CAPACITY);
Ui::EditStat("Max health", STAT_MAX_HEALTH,0,569,1450);
Ui::EditStat("Max health", STAT_MAX_HEALTH, 0, 569, 1450);
Ui::EditAddress<int>("Money", 0xB7CE50, -99999999, 0, 99999999);
Ui::EditStat("Muscle", STAT_MUSCLE);
Ui::EditStat("Respect", STAT_RESPECT);
@ -332,7 +330,7 @@ void Player::Main()
ImGui::NextColumn();
ImGui::Text("Def: 0");
ImGui::NextColumn();
ImGui::Text("Max: %d",max_wl);
ImGui::Text("Max: %d", max_wl);
ImGui::Columns(1);
ImGui::Spacing();
@ -365,7 +363,7 @@ void Player::Main()
if (ImGui::BeginTabItem("Appearance"))
{
ImGui::Spacing();
if (Ui::CheckboxWithHint("Aim skin changer", &aim_skin_changer,(("Activate using Aim ped + ") + Ui::GetHotKeyNameString(Menu::hotkeys::aim_skin_changer)).c_str()))
if (Ui::CheckboxWithHint("Aim skin changer", &aim_skin_changer, (("Activate using Aim ped + ") + Ui::GetHotKeyNameString(Menu::hotkeys::aim_skin_changer)).c_str()))
config.SetValue("aim_skin_changer", aim_skin_changer);
if (ImGui::BeginTabBar("AppearanceTabBar"))
@ -378,7 +376,7 @@ void Player::Main()
{
if (ImGui::Button("Remove clothes", ImVec2(Ui::GetSize())))
{
CPlayerPed *player = FindPlayerPed();
CPlayerPed* player = FindPlayerPed();
int temp = 0;
for (uint i = 0; i < 18; i++)

View File

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

View File

@ -56,12 +56,7 @@ void Teleport::FetchRadarSpriteData()
Teleport::Teleport()
{
json.LoadData(search_categories, selected_item);
Events::initGameEvent += []
{
// Load config data
quick_teleport = config.GetValue("quick_teleport", false);
};
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);
}
void Teleport::Main()
void Teleport::Draw()
{
if (ImGui::BeginTabBar("Teleport",ImGuiTabBarFlags_NoTooltip+ImGuiTabBarFlags_FittingPolicyScroll))
{

View File

@ -33,8 +33,8 @@ protected:
Teleport();
public:
static void Main();
static void TeleportPlayer(bool get_marker = false, CVector pos = CVector(0,0,0), short interior_id = 0);
static void Draw();
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 RemoveTeleportEntry(std::string& rootkey, std::string& key, std::string& val);

View File

@ -49,7 +49,7 @@ bool Ui::ListBoxStr(const char* label, std::vector<std::string>& all_items, std:
return rtn;
}
ImVec2 Ui::GetSize(short count,bool spacing)
ImVec2 Ui::GetSize(short count, bool spacing)
{
if (count == 1)
spacing = false;
@ -65,14 +65,14 @@ ImVec2 Ui::GetSize(short count,bool spacing)
else
x = ImGui::GetWindowContentRegionWidth() / count;
return ImVec2(x, ImGui::GetFrameHeight()*1.3f);
return ImVec2(x, ImGui::GetFrameHeight() * 1.3f);
}
void Ui::CenterdText(const std::string& text)
{
float font_size = ImGui::GetFontSize() * text.size() / 2;
ImGui::NewLine();
ImGui::SameLine(ImGui::GetWindowSize().x / 2 -font_size + (font_size / 1.8));
ImGui::SameLine(ImGui::GetWindowSize().x / 2 - font_size + (font_size / 1.8));
ImGui::Text(text.c_str());
}
@ -138,7 +138,7 @@ void Ui::DrawHeaders(unsortedMap& data)
}
else
{
if ( func != nullptr && ImGui::BeginChild("TABSBAR"))
if (func != nullptr && ImGui::BeginChild("TABSBAR"))
{
((void(*)(void))func)();
ImGui::EndChild();
@ -159,14 +159,14 @@ void Ui::ShowTooltip(const char* text)
}
}
bool Ui::CheckboxWithHint(const char* label, bool *v, const char * hint, bool is_disabled)
bool Ui::CheckboxWithHint(const char* label, bool* v, const char* hint, bool is_disabled)
{
// set things up
bool pressed = false;
const ImGuiStyle& style = ImGui::GetStyle();
const ImVec2 text_size = ImGui::CalcTextSize(label, NULL, true);
float square_sz = ImGui::GetFrameHeight();
ImDrawList *drawlist = ImGui::GetWindowDrawList();
ImDrawList* drawlist = ImGui::GetWindowDrawList();
ImU32 color = ImGui::GetColorU32(ImGuiCol_FrameBg);
std::string slabel = "##InvCheckboxBtn" + std::string(label);
@ -248,7 +248,7 @@ bool Ui::CheckboxWithHint(const char* label, bool *v, const char * hint, bool is
bool Ui::CheckboxAddress(const char* label, const int addr, const char* hint)
{
bool rtn = false;
bool state = patch::Get<bool>(addr,false);
bool state = patch::Get<bool>(addr, false);
if (CheckboxWithHint(label, &state, hint) && addr != NULL)
{
@ -312,7 +312,7 @@ bool Ui::CheckboxAddressVarEx(const char* label, bool val, int addr, int enabled
return rtn;
}
bool Ui::CheckboxBitFlag(const char* label,uint flag, const char* hint)
bool Ui::CheckboxBitFlag(const char* label, uint flag, const char* hint)
{
bool rtn = false;
bool state = (flag == 1) ? true : false;
@ -325,16 +325,16 @@ bool Ui::CheckboxBitFlag(const char* label,uint flag, const char* hint)
return rtn;
}
void Ui::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)
void Ui::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)
{
ImGui::PushItemWidth(ImGui::GetContentRegionAvailWidth()/2 - 5);
ImGui::PushItemWidth(ImGui::GetContentRegionAvailWidth() / 2 - 5);
ListBoxStr("##Categories", combo_items, selected_item);
ImGui::SameLine();
filter.Draw("##Filter");
if (strlen(filter.InputBuf) == 0)
{
ImDrawList *drawlist = ImGui::GetWindowDrawList();
ImDrawList* drawlist = ImGui::GetWindowDrawList();
ImVec2 min = ImGui::GetItemRectMin();
min.x += ImGui::GetStyle().FramePadding.x;
@ -368,7 +368,7 @@ void Ui::DrawJSON(CJson& json, std::vector<std::string>& combo_items, std::strin
std::string data_key = _data.key();
std::string data_val = _data.value();
func_left_click(root_key,data_key,data_val);
func_left_click(root_key, data_key, data_val);
}
if (ImGui::IsItemClicked(1) && func_right_click != nullptr)
@ -390,7 +390,7 @@ void Ui::DrawJSON(CJson& json, std::vector<std::string>& combo_items, std::strin
ImGui::Text(json_popup.key.c_str());
ImGui::Separator();
if (ImGui::MenuItem("Remove"))
json_popup.function(json_popup.root_key,json_popup.key,json_popup.value);
json_popup.function(json_popup.root_key, json_popup.key, json_popup.value);
if (ImGui::MenuItem("Close"))
@ -403,7 +403,7 @@ void Ui::DrawJSON(CJson& json, std::vector<std::string>& combo_items, std::strin
}
void Ui::EditStat(const char *label, const int stat_id, const int min, const int def, const int max)
void Ui::EditStat(const char* label, const int stat_id, const int min, const int def, const int max)
{
if (ImGui::CollapsingHeader(label))
{
@ -448,7 +448,7 @@ void Ui::FilterWithHint(const char* label, ImGuiTextFilter& filter, const char*
if (strlen(filter.InputBuf) == 0)
{
ImDrawList *drawlist = ImGui::GetWindowDrawList();
ImDrawList* drawlist = ImGui::GetWindowDrawList();
ImVec2 min = ImGui::GetItemRectMin();
min.x += ImGui::GetStyle().FramePadding.x;
@ -459,8 +459,8 @@ void Ui::FilterWithHint(const char* label, ImGuiTextFilter& filter, const char*
}
// clean up the code someday
void Ui::DrawImages(std::vector<std::unique_ptr<TextureStructure>> &img_vec, ImVec2 image_size,
std::vector<std::string>& category_vec,std::string& selected_item, ImGuiTextFilter& filter,
void Ui::DrawImages(std::vector<std::unique_ptr<TextureStructure>>& 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, std::function<bool(std::string&)> verify_func)
{
@ -470,7 +470,7 @@ void Ui::DrawImages(std::vector<std::unique_ptr<TextureStructure>> &img_vec, ImV
image_size.y *= screen::GetScreenHeight() / 768.0f;
int images_in_row = static_cast<int>(ImGui::GetWindowContentRegionWidth() / image_size.x);
image_size.x = ImGui::GetWindowContentRegionWidth() / images_in_row - int(ImGuiStyleVar_ItemSpacing)*0.65f;
image_size.x = ImGui::GetWindowContentRegionWidth() / images_in_row - int(ImGuiStyleVar_ItemSpacing) * 0.65f;
int images_count = 1;
@ -508,7 +508,7 @@ void Ui::DrawImages(std::vector<std::unique_ptr<TextureStructure>> &img_vec, ImV
if (ImGui::IsItemHovered())
{
ImDrawList *drawlist = ImGui::GetWindowDrawList();
ImDrawList* drawlist = ImGui::GetWindowDrawList();
ImVec2 btn_min = ImGui::GetItemRectMin();
ImVec2 btn_max = ImGui::GetItemRectMax();
@ -565,9 +565,9 @@ void Ui::DrawImages(std::vector<std::unique_ptr<TextureStructure>> &img_vec, ImV
ImGui::EndChild();
}
void Ui::RadioButtonAddress(const char* label, std::vector<NamedMemory> &named_mem)
void Ui::RadioButtonAddress(const char* label, std::vector<NamedMemory>& named_mem)
{
size_t btn_in_column = named_mem.size() / 2 -1;
size_t btn_in_column = named_mem.size() / 2 - 1;
ImGui::Text(label);
ImGui::Columns(2, 0, false);
@ -604,7 +604,7 @@ void Ui::RadioButtonAddress(const char* label, std::vector<NamedMemory> &named_m
ImGui::Columns(1);
}
void Ui::RadioButtonAddressEx(const char* label, int addr, std::vector<NamedValue> &named_val)
void Ui::RadioButtonAddressEx(const char* label, int addr, std::vector<NamedValue>& named_val)
{
size_t btn_in_column = named_val.size() / 2;
@ -625,7 +625,7 @@ void Ui::RadioButtonAddressEx(const char* label, int addr, std::vector<NamedValu
ImGui::Columns(1);
}
void Ui::EditRadioButtonAddress(const char* label, std::vector<NamedMemory> &named_mem)
void Ui::EditRadioButtonAddress(const char* label, std::vector<NamedMemory>& named_mem)
{
if (ImGui::CollapsingHeader(label))
{
@ -635,11 +635,11 @@ void Ui::EditRadioButtonAddress(const char* label, std::vector<NamedMemory> &nam
}
}
void Ui::EditRadioButtonAddressEx(const char* label, int addr, std::vector<NamedValue> &named_val)
void Ui::EditRadioButtonAddressEx(const char* label, int addr, std::vector<NamedValue>& named_val)
{
if (ImGui::CollapsingHeader(label))
{
RadioButtonAddressEx(label,addr,named_val);
RadioButtonAddressEx(label, addr, named_val);
ImGui::Spacing();
ImGui::Separator();
}
@ -653,7 +653,7 @@ void Ui::ColorPickerAddress(const char* label, int base_addr, ImVec4&& default_c
cur_color[0] = patch::Get<BYTE>(base_addr, false);
cur_color[1] = patch::Get<BYTE>(base_addr + 1, false);
cur_color[2] = patch::Get<BYTE>(base_addr + 2, false);
cur_color[3] = patch::Get<BYTE>(base_addr + 3,false);
cur_color[3] = patch::Get<BYTE>(base_addr + 3, false);
// 0-255 -> 0-1
cur_color[0] /= 255;
@ -670,9 +670,9 @@ void Ui::ColorPickerAddress(const char* label, int base_addr, ImVec4&& default_c
cur_color[3] *= 255;
patch::Set<BYTE>(base_addr, cur_color[0], false);
patch::Set<BYTE>(base_addr+1, cur_color[1], false);
patch::Set<BYTE>(base_addr+2, cur_color[2], false);
patch::Set<BYTE>(base_addr+3, cur_color[3], false);
patch::Set<BYTE>(base_addr + 1, cur_color[1], false);
patch::Set<BYTE>(base_addr + 2, cur_color[2], false);
patch::Set<BYTE>(base_addr + 3, cur_color[3], false);
}
ImGui::Spacing();
@ -689,9 +689,9 @@ void Ui::ColorPickerAddress(const char* label, int base_addr, ImVec4&& default_c
}
}
void Ui::EditBits(const char *label, const int address, const std::vector<std::string>& names)
void Ui::EditBits(const char* label, const int address, const std::vector<std::string>& names)
{
int *mem_val = (int*)address;
int* mem_val = (int*)address;
if (ImGui::CollapsingHeader(label))
{
@ -715,11 +715,11 @@ void Ui::EditBits(const char *label, const int address, const std::vector<std::s
}
}
void Ui::EditFloat(const char *label, const int address, const float min, const float def, const float max, const float mul)
void Ui::EditFloat(const char* label, const int address, const float min, const float def, const float max, const float mul)
{
if (ImGui::CollapsingHeader(label))
{
float val = patch::Get<float>(address, false)*mul;
float val = patch::Get<float>(address, false) * mul;
int items = 3;
@ -748,13 +748,13 @@ void Ui::EditFloat(const char *label, const int address, const float min, const
patch::SetFloat(address, val / mul, false);
ImGui::SameLine(0.0, 4.0);
if (ImGui::Button("-",ImVec2(size, size)) && val > min)
if (ImGui::Button("-", ImVec2(size, size)) && val > min)
{
val -= 1;
patch::SetFloat(address, val / mul, false);
}
ImGui::SameLine(0.0, 4.0);
if (ImGui::Button("+",ImVec2(size, size)) && val < max)
if (ImGui::Button("+", ImVec2(size, size)) && val < max)
{
val += 1;
patch::SetFloat(address, val / mul, false);
@ -766,20 +766,20 @@ void Ui::EditFloat(const char *label, const int address, const float min, const
ImGui::Spacing();
if (ImGui::Button(("Minimum##" + std::string(label)).c_str(), Ui::GetSize(items)))
patch::Set<float>(address, min/mul, false);
patch::Set<float>(address, min / mul, false);
if (items == 3)
{
ImGui::SameLine();
if (ImGui::Button(("Default##" + std::string(label)).c_str(), Ui::GetSize(items)))
patch::Set<float>(address, def/mul, false);
patch::Set<float>(address, def / mul, false);
}
ImGui::SameLine();
if (ImGui::Button(("Maximum##" + std::string(label)).c_str(), Ui::GetSize(items)))
patch::Set<float>(address, max/mul, false);
patch::Set<float>(address, max / mul, false);
ImGui::Spacing();
ImGui::Separator();
@ -819,12 +819,12 @@ bool Ui::HotKey(const char* label, HotKeyData& key_data)
std::string text;
if (key_data.key1 != VK_NONE)
text = key_names[key_data.key1-1];
text = key_names[key_data.key1 - 1];
else
text = "None";
if (key_data.key1 != key_data.key2)
text += (" + " + key_names[key_data.key2-1]);
text += (" + " + key_names[key_data.key2 - 1]);
if (ImGui::Button((text + std::string("##") + std::string(label)).c_str(), ImVec2(ImGui::GetWindowContentRegionWidth() / 3.5, ImGui::GetFrameHeight())))
if (!active)
@ -878,7 +878,7 @@ std::string Ui::GetHotKeyNameString(HotKeyData& hotkey)
std::string text;
if (hotkey.key1 != VK_NONE)
text = key_names[hotkey.key1-1];
text = key_names[hotkey.key1 - 1];
else
text = "None";
@ -888,7 +888,7 @@ std::string Ui::GetHotKeyNameString(HotKeyData& hotkey)
return text;
}
bool Ui::ColorButton(int color_id, std::vector<float> &color, ImVec2 size)
bool Ui::ColorButton(int color_id, std::vector<float>& color, ImVec2 size)
{
bool rtn = false;
std::string label = "Color " + std::to_string(color_id);
@ -898,7 +898,7 @@ bool Ui::ColorButton(int color_id, std::vector<float> &color, ImVec2 size)
if (ImGui::IsItemHovered())
{
ImDrawList *drawlist = ImGui::GetWindowDrawList();
ImDrawList* drawlist = ImGui::GetWindowDrawList();
drawlist->AddRectFilled(ImGui::GetItemRectMin(), ImGui::GetItemRectMax(), ImGui::GetColorU32(ImGuiCol_ModalWindowDimBg));
}

View File

@ -31,7 +31,7 @@ public:
std::string value;
};
static void CenterdText(const std::string& text);
static bool ColorButton(int color_id, std::vector<float> &color, ImVec2 size);
static bool ColorButton(int color_id, std::vector<float>& color, ImVec2 size);
static bool CheckboxAddress(const char* label, const int addr = NULL, const char* hint = nullptr);
static bool CheckboxAddressEx(const char* label, const int addr = NULL, int enabled_val = 1, int disabled_val = 0, const char* hint = nullptr);
static bool CheckboxAddressVar(const char* label, bool val, int addr, const char* hint = nullptr);
@ -42,20 +42,20 @@ public:
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);
static void DrawImages(std::vector<std::unique_ptr<TextureStructure>> &img_vec, ImVec2 image_size,
static void DrawImages(std::vector<std::unique_ptr<TextureStructure>>& 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, std::function<bool(std::string&)> verify_func = nullptr);
template <typename T>
static void EditAddress(const char *label,const int address, const int min = 0, const int def = 0, const int max = 100);
static void EditBits(const char *label, const int address, const std::vector<std::string>& names);
static void EditFloat(const char *label, const int address, const float min, const float def, const float max, const float mul = 1);
static void EditAddress(const char* label, const int address, const int min = 0, const int def = 0, const int max = 100);
static void EditBits(const char* label, const int address, const std::vector<std::string>& names);
static void EditFloat(const char* label, const int address, const float min, const float def, const float max, const float mul = 1);
template <typename T>
static void EditReference(const char *label,T &address, const int min = 0, const int def = 0, const int max = 100);
static void EditRadioButtonAddress(const char* label, std::vector<NamedMemory> &named_mem);
static void EditRadioButtonAddressEx(const char* label, int addr, std::vector<NamedValue> &named_val);
static void EditStat(const char *label, const int stat_id, const int min = 0, const int def = 0, const int max = 1000);
static void EditReference(const char* label, T& address, const int min = 0, const int def = 0, const int max = 100);
static void EditRadioButtonAddress(const char* label, std::vector<NamedMemory>& named_mem);
static void EditRadioButtonAddressEx(const char* label, int addr, std::vector<NamedValue>& named_val);
static void EditStat(const char* label, const int stat_id, const int min = 0, const int def = 0, const int max = 1000);
static void FilterWithHint(const char* label, ImGuiTextFilter& filter, const char* hint);
@ -68,15 +68,15 @@ public:
static bool ListBox(const char* label, std::vector<std::string>& all_items, int& selected);
static bool ListBoxStr(const char* label, std::vector<std::string>& all_items, std::string& selected);
static void RadioButtonAddress(const char* label, std::vector<NamedMemory> &named_mem);
static void RadioButtonAddressEx(const char* label, int addr, std::vector<NamedValue> &named_val);
static void RadioButtonAddress(const char* label, std::vector<NamedMemory>& named_mem);
static void RadioButtonAddressEx(const char* label, int addr, std::vector<NamedValue>& named_val);
static void ColorPickerAddress(const char* label, int base_addr, ImVec4&& default_color);
static void ShowTooltip(const char* text);
};
template <typename T>
void Ui::EditAddress(const char *label, const int address, const int min, const int def, const int max)
void Ui::EditAddress(const char* label, const int address, const int min, const int def, const int max)
{
if (ImGui::CollapsingHeader(label))
{
@ -87,7 +87,7 @@ void Ui::EditAddress(const char *label, const int address, const int min, const
if (min == def)
items = 2;
ImGui::Columns(items,0,false);
ImGui::Columns(items, 0, false);
ImGui::Text(("Min: " + std::to_string(min)).c_str());
if (items == 3)
@ -135,7 +135,7 @@ void Ui::EditAddress(const char *label, const int address, const int min, const
}
template <typename T>
void Ui::EditReference(const char *label,T &address, const int min, const int def, const int max)
void Ui::EditReference(const char* label, T& address, const int min, const int def, const int max)
{
if (ImGui::CollapsingHeader(label))
{

View File

@ -23,10 +23,10 @@ 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 = "";
for (auto &p : fs::recursive_directory_iterator(path))
for (auto& p : fs::recursive_directory_iterator(path))
{
if (p.path().extension() == file_ext)
{
@ -41,7 +41,6 @@ void Util::LoadTexturesInDirRecursive(const char *path, const char *file_ext,std
hr = S_OK;
}
if (hr == S_OK)
{
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
{
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();
}
}
@ -83,7 +82,7 @@ bool Util::LoadTextureFromFileDx11(const char* filename, ID3D11ShaderResourceVie
desc.BindFlags = D3D11_BIND_SHADER_RESOURCE;
desc.CPUAccessFlags = 0;
ID3D11Texture2D *pTexture = NULL;
ID3D11Texture2D* pTexture = NULL;
D3D11_SUBRESOURCE_DATA subResource;
subResource.pSysMem = image_data;
subResource.SysMemPitch = desc.Width * 4;
@ -111,7 +110,7 @@ bool Util::IsOnMission()
return FindPlayerPed()->CanPlayerStartMission() && !*(patch::Get<char*>(0x5D5380, false) + CTheScripts::OnAMissionFlag);
}
std::string Util::GetLocationName(CVector *pos)
std::string Util::GetLocationName(CVector* pos)
{
int hplayer = CPools::GetPedRef(FindPlayerPed());
int interior = 0;
@ -151,9 +150,9 @@ int Util::GetLargestGangInZone()
for (int i = 0; i != 10; ++i)
{
CVector pos = FindPlayerPed()->GetPosition();
CZone *zone = new CZone();
CZone* zone = new CZone();
CZoneExtraInfo *zone_info = CTheZones::GetZoneInfo(&pos, &zone);
CZoneExtraInfo* zone_info = CTheZones::GetZoneInfo(&pos, &zone);
int density = zone_info->m_nGangDensity[i];
if (density > max_density)
@ -171,11 +170,11 @@ int Util::GetLargestGangInZone()
// https://github.com/cleolibrary/CLEO4/blob/916d400f4a731ba1dd0ff16e52bdb056f42b7038/source/CCustomOpcodeSystem.cpp#L1671
CVehicle* Util::GetClosestVehicle()
{
CPlayerPed *player = FindPlayerPed();
CPedIntelligence *pedintel;
CPlayerPed* player = FindPlayerPed();
CPedIntelligence* pedintel;
if (player && (pedintel = player->m_pIntelligence))
{
CVehicle *veh = nullptr;
CVehicle* veh = nullptr;
for (int i = 0; i < 16; i++)
{
veh = (CVehicle*)pedintel->m_vehicleScanner.m_apEntities[i];
@ -191,11 +190,11 @@ CVehicle* Util::GetClosestVehicle()
CPed* Util::GetClosestPed()
{
CPlayerPed *player = FindPlayerPed();
CPedIntelligence * pedintel;
CPlayerPed* player = FindPlayerPed();
CPedIntelligence* pedintel;
if (player && (pedintel = player->m_pIntelligence))
{
CPed *ped = nullptr;
CPed* ped = nullptr;
for (int i = 0; i < 16; i++)
{
@ -210,9 +209,9 @@ CPed* Util::GetClosestPed()
return nullptr;
}
void Util::RainbowValues(int &r, int&g, int &b, float speed)
void Util::RainbowValues(int& r, int& g, int& b, float speed)
{
int timer = CTimer::m_snTimeInMilliseconds/150;
int timer = CTimer::m_snTimeInMilliseconds / 150;
r = sin(timer * speed) * 127 + 128;
g = sin(timer * speed + 2) * 127 + 128;
b = sin(timer * speed + 4) * 127 + 128;

View File

@ -14,31 +14,6 @@ public:
static bool IsOnMission();
static std::string GetLocationName(CVector *pos);
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 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::unique_ptr<TextureStructure>> Vehicle::tune::image_vec;
std::string Vehicle::tune::selected_item = "All";
bool Vehicle::images_loaded = false;
float Vehicle::neon::color_picker[3]{ 0,0,0 };
bool Vehicle::neon::rainbow = false;
@ -70,22 +71,23 @@ static std::vector<std::string>(model_flag_names) = // 32 flags
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\\components\\"), ".jpg", tune::search_categories, tune::image_vec);
Util::LoadTexturesInDirRecursive(PLUGIN_PATH((char*)"CheatMenu\\vehicles\\paintjobs\\"), ".png", texture9::search_categories, texture9::image_vec);
ParseVehiclesIDE();
ParseCarcolsDAT();
};
images_loaded = true;
}
Events::processScriptsEvent += [this]
{
uint timer = CTimer::m_snTimeInMilliseconds;
CPlayerPed *player = FindPlayerPed();
CVehicle *veh = player->m_pVehicle;
CPlayerPed* player = FindPlayerPed();
CVehicle* veh = player->m_pVehicle;
if (player && veh)
{
@ -104,7 +106,7 @@ Vehicle::Vehicle()
{
player->m_pVehicle->Fix();
player->m_pVehicle->m_fHealth = 1000.0f;
CHud::SetHelpMessage("Vehicle fixed",false,false,false);
CHud::SetHelpMessage("Vehicle fixed", false, false, false);
}
if (Ui::HotKeyPressed(Menu::hotkeys::veh_engine))
@ -112,9 +114,9 @@ Vehicle::Vehicle()
bool state = !veh->m_nVehicleFlags.bEngineBroken || veh->m_nVehicleFlags.bEngineOn;
if (state)
CHud::SetHelpMessage("Vehicle engine off",false,false,false);
CHud::SetHelpMessage("Vehicle engine off", false, false, false);
else
CHud::SetHelpMessage("Vehicle engine on",false,false,false);
CHud::SetHelpMessage("Vehicle engine on", false, false, false);
veh->m_nVehicleFlags.bEngineBroken = state;
veh->m_nVehicleFlags.bEngineOn = !state;
@ -179,21 +181,21 @@ Vehicle::Vehicle()
// Traffic neons
if (neon::traffic && timer - neon::traffic_timer > 1000)
{
for (CVehicle *veh : CPools::ms_pVehiclePool)
for (CVehicle* veh : CPools::ms_pVehiclePool)
{
int chance = 0;
if (veh->m_nVehicleClass == CLASS_NORMAL) // Normal
chance = Random(1,20);
chance = Random(1, 20);
if (veh->m_nVehicleClass == CLASS_RICHFAMILY) // Rich family
chance = Random(1,4);
chance = Random(1, 4);
if (veh->m_nVehicleClass == CLASS_EXECUTIVE) // Executive
chance = Random(1,3);
chance = Random(1, 3);
if (chance == 1 && !IsNeonInstalled(veh) && veh->m_pDriver != player)
InstallNeon(veh, Random(0,255), Random(0,255), Random(0,255));
InstallNeon(veh, Random(0, 255), Random(0, 255), Random(0, 255));
}
neon::traffic_timer = timer;
}
@ -202,7 +204,7 @@ Vehicle::Vehicle()
{
if (veh->m_nVehicleSubClass == VEHICLE_BIKE || veh->m_nVehicleSubClass == VEHICLE_BMX)
{
if (sqrt( veh->m_vecMoveSpeed.x * veh->m_vecMoveSpeed.x
if (sqrt(veh->m_vecMoveSpeed.x * veh->m_vecMoveSpeed.x
+ veh->m_vecMoveSpeed.y * veh->m_vecMoveSpeed.y
+ veh->m_vecMoveSpeed.z * veh->m_vecMoveSpeed.z
) > 0.0
@ -218,11 +220,11 @@ Vehicle::Vehicle()
void Vehicle::AddComponent(const std::string& component, const bool display_message)
{
try {
CPlayerPed *player = FindPlayerPed();
CPlayerPed* player = FindPlayerPed();
int icomp = std::stoi(component);
int hveh = CPools::GetVehicleRef(player->m_pVehicle);
CStreaming::RequestModel(icomp,eStreamingFlags::PRIORITY_REQUEST);
CStreaming::RequestModel(icomp, eStreamingFlags::PRIORITY_REQUEST);
CStreaming::LoadAllRequestedModels(true);
player->m_pVehicle->AddVehicleUpgrade(icomp);
CStreaming::SetModelIsDeletable(icomp);
@ -240,7 +242,7 @@ void Vehicle::AddComponent(const std::string& component, const bool display_mess
void Vehicle::RemoveComponent(const std::string& component, const bool display_message)
{
try {
CPlayerPed *player = FindPlayerPed();
CPlayerPed* player = FindPlayerPed();
int icomp = std::stoi(component);
int hveh = CPools::GetVehicleRef(player->m_pVehicle);
@ -283,7 +285,7 @@ int Vehicle::GetRandomTrainIdForModel(int model)
CHud::SetHelpMessage("Invalid train model", false, false, false);
return -1;
}
int id = Random(_start,_end);
int id = Random(_start, _end);
return train_ids[id];
}
@ -410,7 +412,7 @@ void Vehicle::ParseCarcolsDAT()
{
try
{
std::for_each(name.begin(), name.end(), [](char & c) {
std::for_each(name.begin(), name.end(), [](char& c) {
c = ::toupper(c);
});
@ -431,13 +433,13 @@ void Vehicle::ParseCarcolsDAT()
else flog << "Vehicle.ide file not found";
}
void Vehicle::SpawnVehicle(std::string &smodel)
void Vehicle::SpawnVehicle(std::string& smodel)
{
CPlayerPed *player = FindPlayerPed();
CPlayerPed* player = FindPlayerPed();
int hplayer = CPools::GetPedRef(player);
int imodel = std::stoi(smodel);
CVehicle *veh = nullptr;
CVehicle* veh = nullptr;
int interior = player->m_nAreaCode;
@ -450,7 +452,7 @@ void Vehicle::SpawnVehicle(std::string &smodel)
{
int hveh = 0;
Command<Commands::GET_CAR_CHAR_IS_USING>(hplayer, &hveh);
CVehicle *pveh = CPools::GetVehicle(hveh);
CVehicle* pveh = CPools::GetVehicle(hveh);
pos = pveh->GetPosition();
Command<Commands::GET_CAR_SPEED>(hveh, &speed);
@ -489,11 +491,11 @@ void Vehicle::SpawnVehicle(std::string &smodel)
CStreaming::LoadAllRequestedModels(false);
CTrain *train = nullptr;
CTrain *carraige = nullptr;
int track = Random(0,1);
int node = CTrain::FindClosestTrackNode(pos,&track);
CTrain::CreateMissionTrain(pos,(Random(0,1)) == 1 ? true : false,train_id,&train,&carraige,node,track,false);
CTrain* train = nullptr;
CTrain* carraige = nullptr;
int track = Random(0, 1);
int node = CTrain::FindClosestTrackNode(pos, &track);
CTrain::CreateMissionTrain(pos, (Random(0, 1)) == 1 ? true : false, train_id, &train, &carraige, node, track, false);
veh = (CVehicle*)train;
hveh = CPools::GetVehicleRef(veh);
@ -537,7 +539,7 @@ void Vehicle::SpawnVehicle(std::string &smodel)
Command<Commands::CREATE_CAR>(imodel, pos.x, pos.y, pos.z + 3.0f, &hveh);
veh = CPools::GetVehicle(hveh);
veh->SetHeading(player->GetHeading()+55.0f);
veh->SetHeading(player->GetHeading() + 55.0f);
}
veh->m_nDoorLock = CARLOCK_UNLOCKED;
veh->m_nAreaCode = interior;
@ -550,7 +552,7 @@ void Vehicle::SpawnVehicle(std::string &smodel)
std::string Vehicle::GetNameFromModel(int model)
{
CBaseModelInfo *info = CModelInfo::GetModelInfo(model);
CBaseModelInfo* info = CModelInfo::GetModelInfo(model);
return (const char*)info + 0x32;
}
@ -558,7 +560,7 @@ std::string Vehicle::GetNameFromModel(int model)
int Vehicle::GetModelFromName(const char* name)
{
int model = 0;
CBaseModelInfo* model_info = CModelInfo::GetModelInfo((char*)name,&model);
CBaseModelInfo* model_info = CModelInfo::GetModelInfo((char*)name, &model);
if (model > 0 && model < 1000000 && GetNameFromModel(model) != "")
return model;
@ -573,7 +575,7 @@ Vehicle::~Vehicle()
void Vehicle::GenerateHandlingDataFile(int phandling)
{
FILE *fp = fopen("handling.txt", "w");
FILE* fp = fopen("handling.txt", "w");
std::string handlingId = vehicle_ide[FindPlayerPed()->m_pVehicle->m_nModelIndex];
float fMass = patch::Get<float>(phandling + 0x4);
@ -626,10 +628,10 @@ void Vehicle::GenerateHandlingDataFile(int phandling)
}
void Vehicle::Main()
void Vehicle::Draw()
{
ImGui::Spacing();
static CPlayerPed *player = FindPlayerPed();
static CPlayerPed* player = FindPlayerPed();
static int hplayer = CPools::GetPedRef(player);
if (ImGui::Button("Blow up cars", ImVec2(Ui::GetSize(3))))
@ -667,7 +669,7 @@ void Vehicle::Main()
if (ImGui::BeginTabBar("Vehicle", ImGuiTabBarFlags_NoTooltip + ImGuiTabBarFlags_FittingPolicyScroll))
{
CVehicle *pVeh = player->m_pVehicle;
CVehicle* pVeh = player->m_pVehicle;
bool is_driver = pVeh && player->m_pVehicle->IsDriver(player);
ImGui::Spacing();
@ -808,9 +810,9 @@ void Vehicle::Main()
Ui::EditFloat("Density multiplier", 0x8A5B20, 0, 1, 10);
if (ImGui::CollapsingHeader("Enter nearest vehicle as"))
{
CPlayerPed *player = FindPlayerPed();
CPlayerPed* player = FindPlayerPed();
int hplayer = CPools::GetPedRef(player);
CVehicle *veh = Util::GetClosestVehicle();
CVehicle* veh = Util::GetClosestVehicle();
if (veh)
{
@ -847,12 +849,12 @@ void Vehicle::Main()
{
ImGui::InputInt("Radius", &veh_remove_radius);
ImGui::Spacing();
if (ImGui::Button("Remove vehicles",Ui::GetSize(1)))
if (ImGui::Button("Remove vehicles", Ui::GetSize(1)))
{
CPlayerPed *player = FindPlayerPed();
for (CVehicle *veh : CPools::ms_pVehiclePool)
CPlayerPed* player = FindPlayerPed();
for (CVehicle* veh : CPools::ms_pVehiclePool)
{
if (DistanceBetweenPoints(veh->GetPosition(),player->GetPosition()) < veh_remove_radius
if (DistanceBetweenPoints(veh->GetPosition(), player->GetPosition()) < veh_remove_radius
&& player->m_pVehicle != veh)
Command<Commands::DELETE_CAR>(CPools::GetVehicleRef(veh));
}
@ -874,7 +876,7 @@ void Vehicle::Main()
if (player && player->m_pVehicle)
{
CVehicle *veh = player->m_pVehicle;
CVehicle* veh = player->m_pVehicle;
int hveh = CPools::GetVehicleRef(veh);
Ui::EditFloat("Dirt level", (int)veh + 0x4B0, 0, 7.5, 15);
@ -994,7 +996,7 @@ void Vehicle::Main()
}
if (player->m_pVehicle && player->m_nPedFlags.bInVehicle)
{
CVehicle *veh = FindPlayerPed()->m_pVehicle;
CVehicle* veh = FindPlayerPed()->m_pVehicle;
int hveh = CPools::GetVehicleRef(veh);
if (ImGui::BeginTabItem("Color"))
{
@ -1036,15 +1038,15 @@ void Vehicle::Main()
ImVec2 size = Ui::GetSize();
int btns_in_row = ImGui::GetWindowContentRegionWidth() / (size.y * 2);
int btn_size = (ImGui::GetWindowContentRegionWidth() - int(ImGuiStyleVar_ItemSpacing)*(btns_in_row - 0.6*btns_in_row)) / btns_in_row;
int btn_size = (ImGui::GetWindowContentRegionWidth() - int(ImGuiStyleVar_ItemSpacing) * (btns_in_row - 0.6 * btns_in_row)) / btns_in_row;
ImGui::BeginChild("Colorss");
if (color::show_all)
for (int color_id = 0; color_id < count; ++color_id)
{
if (Ui::ColorButton(color_id, carcols_color_values[color_id], ImVec2(btn_size,btn_size)))
*(uint8_replacement *)(int(veh) + 0x433 + color::radio_btn) = color_id;
if (Ui::ColorButton(color_id, carcols_color_values[color_id], ImVec2(btn_size, btn_size)))
*(uint8_replacement*)(int(veh) + 0x433 + color::radio_btn) = color_id;
if ((color_id + 1) % btns_in_row != 0)
ImGui::SameLine(0.0, 4.0);
@ -1060,7 +1062,7 @@ void Vehicle::Main()
for (int color_id : entry.second)
{
if (Ui::ColorButton(color_id, carcols_color_values[color_id], ImVec2(btn_size, btn_size)))
*(uint8_replacement *)(int(veh) + 0x433 + color::radio_btn) = color_id;
*(uint8_replacement*)(int(veh) + 0x433 + color::radio_btn) = color_id;
if (count % btns_in_row != 0)
ImGui::SameLine(0.0, 4.0);
@ -1089,7 +1091,7 @@ void Vehicle::Main()
bool pulsing = IsPulsingEnabled(veh);
if (Ui::CheckboxWithHint("Pulsing neons", &pulsing))
SetPulsing(veh,pulsing);
SetPulsing(veh, pulsing);
Ui::CheckboxWithHint("Rainbow neons", &neon::rainbow, "Rainbow effect to neon lights");
ImGui::NextColumn();
@ -1108,7 +1110,7 @@ Only some vehicles will have them.");
int count = (int)carcols_color_values.size();
ImVec2 size = Ui::GetSize();
int btns_in_row = ImGui::GetWindowContentRegionWidth() / (size.y * 2);
int btn_size = (ImGui::GetWindowContentRegionWidth() - int(ImGuiStyleVar_ItemSpacing)*(btns_in_row - 0.6*btns_in_row)) / btns_in_row;
int btn_size = (ImGui::GetWindowContentRegionWidth() - int(ImGuiStyleVar_ItemSpacing) * (btns_in_row - 0.6 * btns_in_row)) / btns_in_row;
ImGui::BeginChild("Neonss");
@ -1116,8 +1118,8 @@ Only some vehicles will have them.");
{
if (Ui::ColorButton(color_id, carcols_color_values[color_id], ImVec2(btn_size, btn_size)))
{
std::vector<float> &color = carcols_color_values[color_id];
InstallNeon(veh, color[0]*255, color[1]*255, color[2]*255);
std::vector<float>& color = carcols_color_values[color_id];
InstallNeon(veh, color[0] * 255, color[1] * 255, color[2] * 255);
}
if ((color_id + 1) % btns_in_row != 0)
@ -1154,7 +1156,7 @@ Only some vehicles will have them.");
if (curpjob > maxpjob)
curpjob = -1;
if (curpjob < -1)
curpjob = maxpjob-1;
curpjob = maxpjob - 1;
Command<Commands::GIVE_VEHICLE_PAINTJOB>(hveh, curpjob);
}
@ -1183,10 +1185,10 @@ Only some vehicles will have them.");
Ui::DrawImages(tune::image_vec, ImVec2(100, 80), tune::search_categories, tune::selected_item, tune::filter,
[](std::string& str) {AddComponent(str);},
[](std::string& str) {RemoveComponent(str); },
[](std::string& str){return str;},
[](std::string& str) {return str;},
[](std::string& str)
{
return ((bool(*)(int,CVehicle*))0x49B010)(std::stoi(str), player->m_pVehicle);
return ((bool(*)(int, CVehicle*))0x49B010)(std::stoi(str), player->m_pVehicle);
}
);
@ -1196,8 +1198,8 @@ Only some vehicles will have them.");
{
ImGui::Spacing();
CBaseModelInfo *info = CModelInfo::GetModelInfo(player->m_pVehicle->m_nModelIndex);
int phandling = patch::Get<WORD>((int)info+0x4A,false);
CBaseModelInfo* info = CModelInfo::GetModelInfo(player->m_pVehicle->m_nModelIndex);
int phandling = patch::Get<WORD>((int)info + 0x4A, false);
phandling *= 0xE0;
phandling += 0xC2B9DC;
@ -1224,29 +1226,29 @@ Only some vehicles will have them.");
ImGui::BeginChild("HandlingChild");
static std::vector<Ui::NamedValue> abs{{ "On", 1 }, { "Off", 0 }};
static std::vector<Ui::NamedValue> abs{ { "On", 1 }, { "Off", 0 } };
Ui::EditRadioButtonAddressEx("Abs", phandling + 0x9C, abs);
Ui::EditFloat("Anti dive multiplier", phandling + 0xC4, 0.0f, 0.0f, 1.0f);
Ui::EditFloat("Brake bias", phandling + 0x98, 0.0f, 0.0f, 1.0f);
Ui::EditFloat("Brake deceleration", phandling + 0x94, 0.0f, 0.0f, 20.0f, 2500.0f);
Ui::EditFloat("Centre of mass X", phandling + 0x14,-10.0f,-10.0f, 10.0f);
Ui::EditFloat("Centre of mass Y", phandling + 0x18,-10.0f,-10.0f, 10.0f);
Ui::EditFloat("Centre of mass Z", phandling + 0x1C,-10.0f,-10.0f, 10.0f);
Ui::EditFloat("Centre of mass X", phandling + 0x14, -10.0f, -10.0f, 10.0f);
Ui::EditFloat("Centre of mass Y", phandling + 0x18, -10.0f, -10.0f, 10.0f);
Ui::EditFloat("Centre of mass Z", phandling + 0x1C, -10.0f, -10.0f, 10.0f);
Ui::EditFloat("Collision damage multiplier", phandling + 0xC8, 0.0f, 0.0f, 1.0f, 0.3381f);
Ui::EditFloat("Damping level", phandling + 0xB0, -10.0f, -10.0f, 10.0f); // test later
Ui::EditFloat("Drag mult", phandling + 0x10, 0.0f, 0.0f, 30.0f);
static std::vector<Ui::NamedValue> drive_type{ { "Front wheel drive", 70 }, { "Rear wheel drive", 82 }, { "Four wheel drive", 52 }};
static std::vector<Ui::NamedValue> drive_type{ { "Front wheel drive", 70 }, { "Rear wheel drive", 82 }, { "Four wheel drive", 52 } };
Ui::EditRadioButtonAddressEx("Drive type", phandling + 0x74, drive_type);
Ui::EditFloat("Engine acceleration", phandling + 0x7C, 0.0f, 0.0f, 49.0f, 12500.0f);
Ui::EditFloat("Engine inertia", phandling + 0x80, 0.0f, 0.0f, 400.0f);
static std::vector<Ui::NamedValue> engine_type{ { "Petrol", 80 }, { "Diseal", 68 }, { "Electric", 69 }};
static std::vector<Ui::NamedValue> engine_type{ { "Petrol", 80 }, { "Diseal", 68 }, { "Electric", 69 } };
Ui::EditRadioButtonAddressEx("Engine type", phandling + 0x75, engine_type);
std::vector<Ui::NamedValue> front_lights{ { "Long", 0 }, { "Small", 1 }, { "Big", 2 }, { "Tall", 3 }};
std::vector<Ui::NamedValue> front_lights{ { "Long", 0 }, { "Small", 1 }, { "Big", 2 }, { "Tall", 3 } };
Ui::EditRadioButtonAddressEx("Front lights", phandling + 0xDC, front_lights);
Ui::EditFloat("Force level", phandling + 0xAC, -10.0f, -10.0f, 10.0f); // test later
@ -1265,7 +1267,7 @@ Only some vehicles will have them.");
Ui::EditAddress<BYTE>("Number of gears", phandling + 0x76, 1, 1, 10);
Ui::EditAddress<BYTE>("Percent submerged", phandling + 0x20, 10, 10, 120);
static std::vector<Ui::NamedValue> rear_lights{ { "Long", 0 }, { "Small", 1 }, { "Big", 2 }, { "Tall", 3 }};
static std::vector<Ui::NamedValue> rear_lights{ { "Long", 0 }, { "Small", 1 }, { "Big", 2 }, { "Tall", 3 } };
Ui::EditRadioButtonAddressEx("Rear lights", phandling + 0xDD, rear_lights);
Ui::EditFloat("Seat offset distance", phandling + 0xD4, 0.0f, 0.0f, 1.0f);

View File

@ -56,6 +56,7 @@ private:
static std::vector<std::string> search_categories;
static std::vector<std::unique_ptr<TextureStructure>> image_vec;
};
static bool images_loaded;
struct tune
{
@ -75,13 +76,13 @@ public:
static void RemoveComponent(const std::string& component, const bool display_message = true);
static std::string GetNameFromModel(int model);
static int GetModelFromName(const char* name);
static void SpawnVehicle(std::string &name);
static void SpawnVehicle(std::string& name);
static int GetRandomTrainIdForModel(int model);
static void ParseVehiclesIDE();
static void ParseCarcolsDAT();
static void GenerateHandlingDataFile(int phandling);
Vehicle();
~Vehicle();
static void Main();
static void Draw();
};

View File

@ -28,15 +28,12 @@ static bool init_patches = false;
Visual::Visual()
{
Events::initGameEvent += []
{
if (LoadLibraryW(L"timecycle24.asi"))
if (GetModuleHandle("timecycle24.asi"))
timecyc_hour = 24;
};
Events::processScriptsEvent += []
{
// Improve this later
// TODO: Needs improvement
if (lock_weather)
{
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))
{
@ -271,7 +268,7 @@ void Visual::Main()
Ui::ColorPickerAddress("Armour bar", *(int*)0x5890FC, 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));
static std::vector<Ui::NamedValue> font_outline{{ "No outline", 0 }, { "Thin outline" ,1 }, { "Default outline" ,2 }};
Ui::EditRadioButtonAddressEx("Money font outline", 0x58F58D, font_outline);

View File

@ -11,21 +11,21 @@ private:
static void GenerateTimecycFile();
static int GetCurrentHourTimeId();
static bool TimeCycColorEdit3(const char* label, uchar *r, uchar *g, uchar *b, ImGuiColorEditFlags flags = 0);
static bool TimeCycColorEdit4(const char* label, uchar *r, uchar *g, uchar *b, uchar *a, ImGuiColorEditFlags flags = 0);
static bool TimeCycColorEdit3(const char* label, uchar* r, uchar* g, uchar* b, ImGuiColorEditFlags flags = 0);
static bool TimeCycColorEdit4(const char* label, uchar* r, uchar* g, uchar* b, uchar* a, ImGuiColorEditFlags flags = 0);
template<typename T>
static void TimecycSlider(const char* label, T* data, int min, int max);
public:
Visual();
~Visual();
static void Main();
static void Draw();
};
template<typename T>
void Visual::TimecycSlider(const char* label, T* ptr, int min, int max)
{
int val = 23 * GetCurrentHourTimeId() + CWeather::OldWeatherType;
T *arr = (T*)patch::GetPointer(int(ptr));
T* arr = (T*)patch::GetPointer(int(ptr));
int a = arr[val];
if (ImGui::SliderInt(label, &a, min, max))

View File

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

View File

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

View File

@ -1,12 +1,13 @@
#include "pch.h"
std::string Globals::header_id = "";
ImVec2 Globals::menu_size = ImVec2(screen::GetScreenWidth()/4, screen::GetScreenHeight()/1.2);
ImVec2 Globals::menu_size = ImVec2(screen::GetScreenWidth() / 4, screen::GetScreenHeight() / 1.2);
ImVec2 Globals::screen_size = ImVec2(-1, -1);
bool Globals::show_menu = false;
bool Globals::init_done = false;
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");
CJson config = CJson("config");

View File

@ -56,7 +56,6 @@
#include "imgui/imgui_internal.h"
#include "imgui/imgui_impl_dx9.h"
#include "imgui/imgui_impl_dx11.h"
// #include "imgui/imgui_impl_vulkan.h"
#include "imgui/imgui_impl_win32.h"
#include "Events.h"
@ -86,6 +85,7 @@ struct Globals
static ImVec2 screen_size;
static bool show_menu;
static bool init_done;
static bool game_init;
static Renderer renderer;
static void* device;
};
@ -94,7 +94,7 @@ struct TextureStructure
{
std::string file_name;
std::string category_name;
void *texture = nullptr;
void* texture = nullptr;
};
struct HotKeyData