Added files
22
CheatMenu.sln
Normal file
@ -0,0 +1,22 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio 14
|
||||
VisualStudioVersion = 14.0.25420.1
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CheatMenu", "CheatMenu\CheatMenu.vcxproj.vcxproj", "{B212DDA4-2A8E-45B2-914D-7BEEB31D06B1}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
GTASA Release|x86 = GTASA Release|x86
|
||||
GTASA zDebug|x86 = GTASA zDebug|x86
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{B212DDA4-2A8E-45B2-914D-7BEEB31D06B1}.GTASA Release|x86.ActiveCfg = GTASA Release|Win32
|
||||
{B212DDA4-2A8E-45B2-914D-7BEEB31D06B1}.GTASA Release|x86.Build.0 = GTASA Release|Win32
|
||||
{B212DDA4-2A8E-45B2-914D-7BEEB31D06B1}.GTASA zDebug|x86.ActiveCfg = GTASA zDebug|Win32
|
||||
{B212DDA4-2A8E-45B2-914D-7BEEB31D06B1}.GTASA zDebug|x86.Build.0 = GTASA zDebug|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
EndGlobal
|
142
CheatMenu/Animation.cpp
Normal file
@ -0,0 +1,142 @@
|
||||
#include "pch.h"
|
||||
#include "Animation.h"
|
||||
|
||||
bool Animation::loop = false;
|
||||
bool Animation::secondary = false;
|
||||
char Animation::ifp_buffer[INPUT_BUFFER_SIZE] = "";
|
||||
char Animation::anim_buffer[INPUT_BUFFER_SIZE] = "";
|
||||
|
||||
ImGuiTextFilter Animation::filter = "";
|
||||
std::vector<std::string> Animation::search_categories;
|
||||
std::string Animation::selected_item = "All";
|
||||
|
||||
CJson Animation::json = CJson("animation");
|
||||
|
||||
std::vector<std::string> fighting_vec{ "Default","Boxing","Kung fu","Kick Boxing","Punch Kick" };
|
||||
int fighting_selected = 0;
|
||||
|
||||
std::vector<std::string> walking_vec{ "default", "man", "shuffle", "oldman", "gang1", "gang2",
|
||||
"oldfatman", "fatman", "jogger", "drunkman", "blindman", "swat", "woman", "shopping", "busywoman",
|
||||
"sexywoman", "pro", "oldwoman", "fatwoman", "jogwoman", "oldfatwoman", "skate" };
|
||||
|
||||
std::string walking_selected = "default";
|
||||
|
||||
Animation::Animation()
|
||||
{
|
||||
json.LoadJsonData(search_categories, selected_item);
|
||||
}
|
||||
|
||||
void Animation::Main()
|
||||
{
|
||||
if (ImGui::BeginTabBar("Animation", ImGuiTabBarFlags_NoTooltip + ImGuiTabBarFlags_FittingPolicyScroll))
|
||||
{
|
||||
ImGui::Spacing();
|
||||
int hplayer = CPools::GetPedRef(FindPlayerPed());
|
||||
|
||||
ImGui::Spacing();
|
||||
|
||||
if (ImGui::BeginTabItem("Anims"))
|
||||
{
|
||||
ImGui::Spacing();
|
||||
if (ImGui::Button("Stop animation", Ui::GetSize()))
|
||||
{
|
||||
if (hplayer)
|
||||
Command<Commands::CLEAR_CHAR_TASKS>(hplayer);
|
||||
}
|
||||
|
||||
ImGui::Spacing();
|
||||
|
||||
ImGui::Columns(2, 0, false);
|
||||
ImGui::Checkbox("Loop", &loop);
|
||||
ImGui::NextColumn();
|
||||
ImGui::Checkbox("Secondary", &secondary);
|
||||
ImGui::Columns(1);
|
||||
ImGui::Spacing();
|
||||
|
||||
if (ImGui::BeginChild("Anims Child"))
|
||||
{
|
||||
ImGui::Spacing();
|
||||
Ui::DrawJSON(json, search_categories, selected_item, filter, &PlayAnimation, &RemoveEntry);
|
||||
ImGui::EndChild();
|
||||
}
|
||||
ImGui::EndTabItem();
|
||||
}
|
||||
|
||||
if (ImGui::BeginTabItem("Misc"))
|
||||
{
|
||||
ImGui::Spacing();
|
||||
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);
|
||||
}
|
||||
if (Ui::ListBoxStr("Walking", walking_vec, walking_selected))
|
||||
{
|
||||
if (walking_selected == "default")
|
||||
{
|
||||
patch::Set<DWORD>(0x609A4E, 0x4D48689, false);
|
||||
patch::Set<WORD>(0x609A52, 0, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
const char* cwalking_selected = walking_selected.c_str();
|
||||
|
||||
patch::Set<DWORD>(0x609A4E, -0x6F6F6F70, false);
|
||||
patch::Nop(0x609A52, 2, false);
|
||||
|
||||
Command<Commands::REQUEST_ANIMATION>(cwalking_selected);
|
||||
Command<Commands::LOAD_ALL_MODELS_NOW>();
|
||||
Command<Commands::SET_ANIM_GROUP_FOR_CHAR>(hplayer, cwalking_selected);
|
||||
Command<Commands::REMOVE_ANIMATION>(cwalking_selected);
|
||||
}
|
||||
CHud::SetHelpMessage("Walking anim set", false, false, false);
|
||||
}
|
||||
ImGui::EndTabItem();
|
||||
}
|
||||
|
||||
if (ImGui::BeginTabItem("Custom"))
|
||||
{
|
||||
ImGui::InputTextWithHint("IFP name", "ped", ifp_buffer, INPUT_BUFFER_SIZE);
|
||||
ImGui::InputTextWithHint("Anim name", "cower", anim_buffer, INPUT_BUFFER_SIZE);
|
||||
ImGui::Spacing();
|
||||
if (ImGui::Button("Add animation", Ui::GetSize()))
|
||||
{
|
||||
json.data["Custom"][anim_buffer] = ("0, " + std::string(ifp_buffer));
|
||||
}
|
||||
ImGui::EndTabItem();
|
||||
}
|
||||
ImGui::EndTabBar();
|
||||
}
|
||||
}
|
||||
|
||||
void Animation::PlayAnimation(std::string& ifp, std::string& anim, std::string& ifp_repeat)
|
||||
{
|
||||
int hplayer = CPools::GetPedRef(FindPlayerPed());
|
||||
|
||||
if (ifp != "PED")
|
||||
{
|
||||
Command<Commands::REQUEST_ANIMATION>(ifp.c_str());
|
||||
Command<Commands::LOAD_ALL_MODELS_NOW>();
|
||||
}
|
||||
|
||||
Command<Commands::CLEAR_CHAR_TASKS>(hplayer);
|
||||
if (secondary)
|
||||
Command<Commands::TASK_PLAY_ANIM_SECONDARY>(hplayer, anim.c_str(), ifp.c_str(), 4.0, loop, 0, 0, 0, -1);
|
||||
else
|
||||
Command<Commands::TASK_PLAY_ANIM>(hplayer, anim.c_str(), ifp.c_str(), 4.0, loop, 0, 0, 0, -1);
|
||||
|
||||
if (ifp != "PED")
|
||||
Command<Commands::REMOVE_ANIMATION>(ifp.c_str());
|
||||
}
|
||||
|
||||
void Animation::RemoveEntry(std::string& ifp, std::string& anim, std::string& ifp_repeat)
|
||||
{
|
||||
flog << ifp << std::endl;
|
||||
if (ifp == "Custom")
|
||||
{
|
||||
json.data["Custom"].erase(anim);
|
||||
CHud::SetHelpMessage("Animation removed", false, false, false);
|
||||
}else CHud::SetHelpMessage("You can only remove custom anims", false, false, false);
|
||||
|
||||
}
|
||||
|
25
CheatMenu/Animation.h
Normal file
@ -0,0 +1,25 @@
|
||||
#pragma once
|
||||
class Animation
|
||||
{
|
||||
private:
|
||||
static bool loop;
|
||||
static bool secondary;
|
||||
|
||||
static CJson json;
|
||||
static ImGuiTextFilter filter;
|
||||
static std::vector<std::string> search_categories;
|
||||
static std::string selected_item;
|
||||
|
||||
static char ifp_buffer[INPUT_BUFFER_SIZE];
|
||||
static char anim_buffer[INPUT_BUFFER_SIZE];
|
||||
|
||||
protected:
|
||||
Animation();
|
||||
~Animation() {};
|
||||
public:
|
||||
static void Main();
|
||||
static void PlayAnimation(std::string& rootkey, std::string& anim, std::string& ifp);
|
||||
|
||||
static void RemoveEntry(std::string& rootkey, std::string& anim, std::string& ifp);
|
||||
};
|
||||
|
212
CheatMenu/CheatMenu.cpp
Normal file
@ -0,0 +1,212 @@
|
||||
#include "pch.h"
|
||||
#include "CheatMenu.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 }
|
||||
};
|
||||
|
||||
void CheatMenu::ProcessMenu()
|
||||
{
|
||||
ImGui::SetNextWindowSize(Globals::menu_size);
|
||||
if (ImGui::Begin(Globals::menu_title.c_str(), &Globals::show_menu, ImGuiWindowFlags_NoCollapse))
|
||||
{
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_WindowMinSize, ImVec2(250, 350));
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(ImGui::GetWindowWidth() / 85, ImGui::GetWindowHeight() / 200));
|
||||
|
||||
Ui::DrawHeaders(header);
|
||||
|
||||
Globals::menu_size = ImGui::GetWindowSize();
|
||||
ImGui::PopStyleVar(2);
|
||||
ImGui::End();
|
||||
}
|
||||
}
|
||||
|
||||
void CheatMenu::ProcessWindow()
|
||||
{
|
||||
ImGuiIO& io = ImGui::GetIO();
|
||||
|
||||
if (!FrontEndMenuManager.m_bMenuActive && (Globals::show_menu || Menu::commands::show_menu))
|
||||
{
|
||||
CPlayerPed* player = FindPlayerPed();
|
||||
CPad *pad = player->GetPadFromPlayer();
|
||||
pad->bPlayerSafe = 1;
|
||||
|
||||
if (Globals::show_menu)
|
||||
{
|
||||
ProcessMenu();
|
||||
|
||||
if (Globals::show_menu)
|
||||
patch::PutRetn(0x6194A0);
|
||||
else
|
||||
{
|
||||
patch::SetUChar(0x6194A0, 0xE9);
|
||||
pad->bPlayerSafe = 0;
|
||||
}
|
||||
|
||||
io.MouseDrawCursor = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
io.MouseDrawCursor = false;
|
||||
}
|
||||
|
||||
if (Menu::commands::show_menu)
|
||||
{
|
||||
Menu::ProcessShortcutsWindow();
|
||||
|
||||
if (!Menu::commands::show_menu)
|
||||
pad->bPlayerSafe = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
io.MouseDrawCursor = false;
|
||||
|
||||
Menu::ProcessOverlay();
|
||||
}
|
||||
|
||||
CheatMenu::CheatMenu()
|
||||
{
|
||||
ApplyImGuiStyle();
|
||||
Hook::window_func = std::bind(&ProcessWindow);
|
||||
|
||||
Events::initRwEvent += []()
|
||||
{
|
||||
flog << "Log Started." << std::endl;
|
||||
|
||||
// Load menu settings
|
||||
Globals::menu_size.x = config.GetValue<float>("window.sizeX", screen::GetScreenWidth() / 4.0f);
|
||||
Globals::menu_size.y = config.GetValue<float>("window.sizeY", screen::GetScreenHeight() / 1.2f);
|
||||
};
|
||||
|
||||
Events::processScriptsEvent += [this]
|
||||
{
|
||||
Hook::disable_controls = ImGui::GetIO().WantCaptureKeyboard || Menu::commands::show_menu;
|
||||
|
||||
if (Globals::init_done && !FrontEndMenuManager.m_bMenuActive && CTimer::m_snTimeInMilliseconds - Globals::last_key_timer > 250)
|
||||
{
|
||||
CPlayerPed* player = FindPlayerPed();
|
||||
CPad *pad = player->GetPadFromPlayer();
|
||||
|
||||
if (Ui::HotKeyPressed(hotkey::menu_open))
|
||||
{
|
||||
Globals::show_menu = !Globals::show_menu;
|
||||
|
||||
if (Globals::show_menu)
|
||||
Util::ClearCharTasksVehCheck(player);
|
||||
|
||||
pad->bPlayerSafe = Globals::show_menu;
|
||||
Globals::last_key_timer = CTimer::m_snTimeInMilliseconds;
|
||||
}
|
||||
|
||||
if (Ui::HotKeyPressed(hotkey::command_window))
|
||||
{
|
||||
Menu::commands::show_menu = !Menu::commands::show_menu;
|
||||
|
||||
if (Menu::commands::show_menu)
|
||||
Util::ClearCharTasksVehCheck(player);
|
||||
else
|
||||
{
|
||||
Menu::ProcessCommands();
|
||||
strcpy(Menu::commands::input_buffer, "");
|
||||
}
|
||||
|
||||
pad->bPlayerSafe = Menu::commands::show_menu;
|
||||
|
||||
Globals::last_key_timer = CTimer::m_snTimeInMilliseconds;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Events::shutdownRwEvent += []
|
||||
{
|
||||
// Save config data
|
||||
config.SetValue("window.sizeX", Globals::menu_size.x);
|
||||
config.SetValue("window.sizeY", Globals::menu_size.y);
|
||||
|
||||
flog << "Log Finished." << std::endl;
|
||||
};
|
||||
}
|
||||
|
||||
CheatMenu::~CheatMenu()
|
||||
{
|
||||
}
|
||||
|
||||
void CheatMenu::ApplyImGuiStyle()
|
||||
{
|
||||
ImGuiStyle* style = &ImGui::GetStyle();
|
||||
ImVec4* colors = style->Colors;
|
||||
|
||||
style->WindowRounding = 1;
|
||||
style->ScrollbarRounding = 1;
|
||||
style->GrabRounding = 1;
|
||||
style->WindowRounding = 1;
|
||||
style->ChildRounding = 1;
|
||||
style->ScrollbarSize = 12;
|
||||
style->ScrollbarRounding = 1;
|
||||
style->GrabRounding = 1;
|
||||
style->FrameRounding = 0;
|
||||
style->TabRounding = 1.0;
|
||||
style->IndentSpacing = 20;
|
||||
style->AntiAliasedLines = true;
|
||||
style->AntiAliasedFill = true;
|
||||
style->ItemSpacing = ImVec2(8, 4);
|
||||
style->FramePadding = ImVec2(5, 3);
|
||||
style->Alpha = 1;
|
||||
|
||||
style->FrameBorderSize = 0;
|
||||
style->ChildBorderSize = 0;
|
||||
style->TabBorderSize = 0;
|
||||
style->WindowBorderSize = 0;
|
||||
style->PopupBorderSize = 0;
|
||||
|
||||
colors[ImGuiCol_Text] = ImVec4(1.00f, 1.00f, 1.00f, 1.00f);
|
||||
colors[ImGuiCol_TextDisabled] = ImVec4(0.50f, 0.50f, 0.50f, 1.00f);
|
||||
colors[ImGuiCol_WindowBg] = ImVec4(0.06f, 0.06f, 0.06f, 0.94f);
|
||||
colors[ImGuiCol_ChildBg] = ImVec4(0.00f, 0.00f, 0.00f, 0.00f);
|
||||
colors[ImGuiCol_PopupBg] = ImVec4(0.08f, 0.08f, 0.08f, 0.94f);
|
||||
colors[ImGuiCol_Border] = ImVec4(0.43f, 0.43f, 0.50f, 0.50f);
|
||||
colors[ImGuiCol_BorderShadow] = ImVec4(0.00f, 0.00f, 0.00f, 0.00f);
|
||||
colors[ImGuiCol_FrameBg] = ImVec4(0.16f, 0.29f, 0.48f, 0.54f);
|
||||
colors[ImGuiCol_FrameBgHovered] = ImVec4(0.26f, 0.59f, 0.98f, 0.40f);
|
||||
colors[ImGuiCol_FrameBgActive] = ImVec4(0.26f, 0.59f, 0.98f, 0.67f);
|
||||
colors[ImGuiCol_TitleBg] = ImVec4(0.04f, 0.04f, 0.04f, 1.00f);
|
||||
colors[ImGuiCol_TitleBgActive] = ImVec4(0.16f, 0.29f, 0.48f, 1.00f);
|
||||
colors[ImGuiCol_TitleBgCollapsed] = ImVec4(0.00f, 0.00f, 0.00f, 0.51f);
|
||||
colors[ImGuiCol_MenuBarBg] = ImVec4(0.14f, 0.14f, 0.14f, 1.00f);
|
||||
colors[ImGuiCol_ScrollbarBg] = ImVec4(0.02f, 0.02f, 0.02f, 0.53f);
|
||||
colors[ImGuiCol_ScrollbarGrab] = ImVec4(0.31f, 0.31f, 0.31f, 1.00f);
|
||||
colors[ImGuiCol_ScrollbarGrabHovered] = ImVec4(0.41f, 0.41f, 0.41f, 1.00f);
|
||||
colors[ImGuiCol_ScrollbarGrabActive] = ImVec4(0.51f, 0.51f, 0.51f, 1.00f);
|
||||
colors[ImGuiCol_CheckMark] = ImVec4(0.26f, 0.59f, 0.98f, 1.00f);
|
||||
colors[ImGuiCol_SliderGrab] = ImVec4(0.24f, 0.52f, 0.88f, 1.00f);
|
||||
colors[ImGuiCol_SliderGrabActive] = ImVec4(0.26f, 0.59f, 0.98f, 1.00f);
|
||||
colors[ImGuiCol_Button] = ImVec4(0.26f, 0.59f, 0.98f, 0.40f);
|
||||
colors[ImGuiCol_ButtonHovered] = ImVec4(0.26f, 0.59f, 0.98f, 1.00f);
|
||||
colors[ImGuiCol_ButtonActive] = ImVec4(0.06f, 0.53f, 0.98f, 1.00f);
|
||||
colors[ImGuiCol_Header] = ImVec4(0.26f, 0.59f, 0.98f, 0.0f);
|
||||
colors[ImGuiCol_HeaderHovered] = ImVec4(0.26f, 0.59f, 0.98f, 0.80f);
|
||||
colors[ImGuiCol_HeaderActive] = ImVec4(0.26f, 0.59f, 0.98f, 1.00f);
|
||||
colors[ImGuiCol_Separator] = ImVec4(0.43f, 0.43f, 0.50f, 0.50f);
|
||||
colors[ImGuiCol_SeparatorHovered] = ImVec4(0.10f, 0.40f, 0.75f, 0.78f);
|
||||
colors[ImGuiCol_SeparatorActive] = ImVec4(0.10f, 0.40f, 0.75f, 1.00f);
|
||||
colors[ImGuiCol_ResizeGrip] = ImVec4(0.26f, 0.59f, 0.98f, 0.25f);
|
||||
colors[ImGuiCol_ResizeGripHovered] = ImVec4(0.26f, 0.59f, 0.98f, 0.67f);
|
||||
colors[ImGuiCol_ResizeGripActive] = ImVec4(0.26f, 0.59f, 0.98f, 0.95f);
|
||||
colors[ImGuiCol_Tab] = ImVec4(0.18f, 0.35f, 0.58f, 0.86f);
|
||||
colors[ImGuiCol_TabHovered] = ImVec4(0.26f, 0.59f, 0.98f, 0.80f);
|
||||
colors[ImGuiCol_TabActive] = ImVec4(0.20f, 0.41f, 0.68f, 1.00f);
|
||||
colors[ImGuiCol_TabUnfocused] = ImVec4(0.07f, 0.10f, 0.15f, 0.97f);
|
||||
colors[ImGuiCol_TabUnfocusedActive] = ImVec4(0.14f, 0.26f, 0.42f, 1.00f);
|
||||
colors[ImGuiCol_PlotLines] = ImVec4(0.61f, 0.61f, 0.61f, 1.00f);
|
||||
colors[ImGuiCol_PlotLinesHovered] = ImVec4(1.00f, 0.43f, 0.35f, 1.00f);
|
||||
colors[ImGuiCol_PlotHistogram] = ImVec4(0.90f, 0.70f, 0.00f, 1.00f);
|
||||
colors[ImGuiCol_PlotHistogramHovered] = ImVec4(1.00f, 0.60f, 0.00f, 1.00f);
|
||||
colors[ImGuiCol_TextSelectedBg] = ImVec4(0.26f, 0.59f, 0.98f, 0.35f);
|
||||
colors[ImGuiCol_DragDropTarget] = ImVec4(1.00f, 1.00f, 0.00f, 0.90f);
|
||||
colors[ImGuiCol_NavHighlight] = ImVec4(0.26f, 0.59f, 0.98f, 1.00f);
|
||||
colors[ImGuiCol_NavWindowingHighlight] = ImVec4(1.00f, 1.00f, 1.00f, 0.70f);
|
||||
colors[ImGuiCol_NavWindowingDimBg] = ImVec4(0.80f, 0.80f, 0.80f, 0.20f);
|
||||
colors[ImGuiCol_ModalWindowDimBg] = ImVec4(0.26f, 0.59f, 0.98f, 0.35f);
|
||||
}
|
61
CheatMenu/CheatMenu.h
Normal file
@ -0,0 +1,61 @@
|
||||
/*
|
||||
Required:
|
||||
Visual Studio 2015.3 (v140)
|
||||
Plugin SDK
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include "Animation.h"
|
||||
#include "Game.h"
|
||||
#include "Hook.h"
|
||||
#include "Menu.h"
|
||||
#include "Ped.h"
|
||||
#include "Player.h"
|
||||
#include "Teleport.h"
|
||||
#include "Vehicle.h"
|
||||
#include "Visual.h"
|
||||
#include "Weapon.h"
|
||||
|
||||
class CheatMenu : Hook, Animation, Game, Menu, Ped, Player, Teleport, Vehicle, Visual, Weapon
|
||||
{
|
||||
private:
|
||||
static unsortedMap header;
|
||||
static void ProcessMenu();
|
||||
static void ProcessWindow();
|
||||
static void ApplyImGuiStyle();
|
||||
|
||||
public:
|
||||
CheatMenu();
|
||||
~CheatMenu();
|
||||
};
|
||||
|
||||
class Launcher
|
||||
{
|
||||
public:
|
||||
Launcher()
|
||||
{
|
||||
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);
|
||||
flog << "Game version isn't 1.0" << std::endl;
|
||||
launch = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
Events::initRwEvent += [&launch]()
|
||||
{
|
||||
if (GetModuleHandleA("SAMP.dll")) {
|
||||
MessageBox(HWND_DESKTOP, "SAMP detected. Exiting CheatMenu.", "CheatMenu", MB_ICONERROR);
|
||||
flog << "SAMP detected. Exiting..." << std::endl;
|
||||
launch = false;
|
||||
}
|
||||
|
||||
if (launch)
|
||||
static CheatMenu cheatmenu;
|
||||
};
|
||||
}
|
||||
}
|
||||
} launcher;
|
||||
|
72
CheatMenu/CheatMenu.vcxproj.filters
Normal file
@ -0,0 +1,72 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<ClCompile Include="include\imgui\imgui.cpp">
|
||||
<Filter>include\imgui</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="include\imgui\imgui_demo.cpp">
|
||||
<Filter>include\imgui</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="include\imgui\imgui_draw.cpp">
|
||||
<Filter>include\imgui</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="include\imgui\imgui_impl_dx9.cpp">
|
||||
<Filter>include\imgui</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="include\imgui\imgui_impl_win32.cpp">
|
||||
<Filter>include\imgui</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="include\imgui\imgui_widgets.cpp">
|
||||
<Filter>include\imgui</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="CheatMenu.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="include\imgui\imconfig.h">
|
||||
<Filter>include\imgui</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="include\imgui\imgui.h">
|
||||
<Filter>include\imgui</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="include\imgui\imgui_impl_dx9.h">
|
||||
<Filter>include\imgui</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="include\imgui\imgui_impl_win32.h">
|
||||
<Filter>include\imgui</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="include\imgui\imgui_internal.h">
|
||||
<Filter>include\imgui</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="include\imgui\imstb_rectpack.h">
|
||||
<Filter>include\imgui</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="include\imgui\imstb_textedit.h">
|
||||
<Filter>include\imgui</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="include\imgui\imstb_truetype.h">
|
||||
<Filter>include\imgui</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="include\detours.h">
|
||||
<Filter>include</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="CheatMenu.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Filter Include="include">
|
||||
<UniqueIdentifier>{76d7c5f4-7966-4299-babe-1441756fd761}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="include\imgui">
|
||||
<UniqueIdentifier>{b4b37f77-034a-404c-9ec1-8fcec9d1052e}</UniqueIdentifier>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Library Include="include\detours.lib">
|
||||
<Filter>include</Filter>
|
||||
</Library>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="include\detours.pdb">
|
||||
<Filter>include</Filter>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
</Project>
|
224
CheatMenu/CheatMenu.vcxproj.vcxproj
Normal file
@ -0,0 +1,224 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="GTASA Release|Win32">
|
||||
<Configuration>GTASA Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="GTASA zDebug|Win32">
|
||||
<Configuration>GTASA zDebug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>{B212DDA4-2A8E-45B2-914D-7BEEB31D06B1}</ProjectGuid>
|
||||
<IgnoreWarnCompileDuplicatedFilename>true</IgnoreWarnCompileDuplicatedFilename>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
<RootNamespace>CheatMenu</RootNamespace>
|
||||
<ProjectName>CheatMenu</ProjectName>
|
||||
<WindowsTargetPlatformVersion>8.1</WindowsTargetPlatformVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='GTASA Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
<PlatformToolset>v140</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='GTASA zDebug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
<PlatformToolset>v140</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='GTASA Release|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='GTASA zDebug|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='GTASA Release|Win32'">
|
||||
<OutDir>F:\GTASanAndreas\</OutDir>
|
||||
<IntDir>$(ProjectDir).obj\GTASA\Release\</IntDir>
|
||||
<TargetExt>.asi</TargetExt>
|
||||
<IncludePath>$(IncludePath);$(DIRECTX9_SDK_DIR)\Include\</IncludePath>
|
||||
<LibraryPath>$(LibraryPath);$(DIRECTX9_SDK_DIR)\Lib\x86\</LibraryPath>
|
||||
<TargetName>$(ProjectName)</TargetName>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='GTASA zDebug|Win32'">
|
||||
<OutDir>F:\GTASanAndreas\</OutDir>
|
||||
<IntDir>$(ProjectDir).obj\GTASA\Debug\</IntDir>
|
||||
<TargetName>$(ProjectName)</TargetName>
|
||||
<TargetExt>.asi</TargetExt>
|
||||
<IncludePath>$(IncludePath);$(DIRECTX9_SDK_DIR)\Include\</IncludePath>
|
||||
<LibraryPath>$(LibraryPath);$(DIRECTX9_SDK_DIR)\Lib\x86\</LibraryPath>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='GTASA Release|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<SDLCheck>false</SDLCheck>
|
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
<AdditionalIncludeDirectories>$(PLUGIN_SDK_DIR)\plugin_sa\;$(PLUGIN_SDK_DIR)\plugin_sa\game_sa\;$(PLUGIN_SDK_DIR)\shared\;$(PLUGIN_SDK_DIR)\shared\game\;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>_NDEBUG;_CRT_SECURE_NO_WARNINGS;_CRT_NON_CONFORMING_SWPRINTFS;GTASA;GTAGAME_NAME="San Andreas";GTAGAME_ABBR="SA";GTAGAME_ABBRLOW="sa";GTAGAME_PROTAGONISTNAME="CJ";GTAGAME_CITYNAME="San Andreas";_LA_SUPPORT;_DX9_SDK_INSTALLED;PLUGIN_SGV_10US;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<LanguageStandard>stdcpplatest</LanguageStandard>
|
||||
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
|
||||
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<GenerateDebugInformation>No</GenerateDebugInformation>
|
||||
<LinkTimeCodeGeneration>UseLinkTimeCodeGeneration</LinkTimeCodeGeneration>
|
||||
<AdditionalLibraryDirectories>$(PLUGIN_SDK_DIR)\output\lib\;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
<AdditionalDependencies>plugin.lib;d3d9.lib;d3dx9.lib;d3d11.lib;d3dx11.lib;$(ProjectDir)external\kiero\minhook\lib\libMinHook-x86-v140-mt.lib;$(ProjectDir)external\kiero\minhook\lib\libMinHook-x86-v140-md.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<ImageHasSafeExceptionHandlers>false</ImageHasSafeExceptionHandlers>
|
||||
</Link>
|
||||
<PreBuildEvent>
|
||||
<Command>taskkill /f /fi "imagename eq gta_sa.exe"</Command>
|
||||
</PreBuildEvent>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='GTASA zDebug|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<SDLCheck>false</SDLCheck>
|
||||
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
||||
<AdditionalIncludeDirectories>$(PLUGIN_SDK_DIR)\plugin_sa\;$(PLUGIN_SDK_DIR)\plugin_sa\game_sa\;$(PLUGIN_SDK_DIR)\shared\;$(PLUGIN_SDK_DIR)\shared\game\;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>_DEBUG;_CRT_SECURE_NO_WARNINGS;_CRT_NON_CONFORMING_SWPRINTFS;GTASA;GTAGAME_NAME="San Andreas";GTAGAME_ABBR="SA";GTAGAME_ABBRLOW="sa";GTAGAME_PROTAGONISTNAME="CJ";GTAGAME_CITYNAME="San Andreas";_LA_SUPPORT;_DX9_SDK_INSTALLED;PLUGIN_SGV_10US;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<LanguageStandard>stdcpplatest</LanguageStandard>
|
||||
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
|
||||
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<GenerateDebugInformation>Debug</GenerateDebugInformation>
|
||||
<LinkTimeCodeGeneration>Default</LinkTimeCodeGeneration>
|
||||
<AdditionalLibraryDirectories>$(PLUGIN_SDK_DIR)\output\lib\;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
<AdditionalDependencies>plugin_d.lib;d3d9.lib;d3dx9.lib;d3d11.lib;d3dx11.lib;$(ProjectDir)external\kiero\minhook\lib\libMinHook-x86-v140-mtd.lib;$(ProjectDir)external\kiero\minhook\lib\libMinHook-x86-v140-mdd.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
</Link>
|
||||
<PreBuildEvent>
|
||||
<Command>taskkill /f /fi "imagename eq gta_sa.exe"</Command>
|
||||
</PreBuildEvent>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="Animation.cpp" />
|
||||
<ClCompile Include="external\imgui\imgui_impl_dx11.cpp">
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='GTASA zDebug|Win32'">NotUsing</PrecompiledHeader>
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='GTASA Release|Win32'">NotUsing</PrecompiledHeader>
|
||||
</ClCompile>
|
||||
<ClCompile Include="external\kiero\kiero.cpp">
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='GTASA zDebug|Win32'">NotUsing</PrecompiledHeader>
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='GTASA Release|Win32'">NotUsing</PrecompiledHeader>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Paint.cpp" />
|
||||
<ClCompile Include="Events.cpp" />
|
||||
<ClCompile Include="external\moon\texture_manager.cpp">
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='GTASA zDebug|Win32'">NotUsing</PrecompiledHeader>
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='GTASA Release|Win32'">NotUsing</PrecompiledHeader>
|
||||
</ClCompile>
|
||||
<ClCompile Include="external\moon\vehicle_renderer.cpp">
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='GTASA zDebug|Win32'">NotUsing</PrecompiledHeader>
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='GTASA Release|Win32'">NotUsing</PrecompiledHeader>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Game.cpp" />
|
||||
<ClCompile Include="Hook.cpp" />
|
||||
<ClCompile Include="Json.cpp" />
|
||||
<ClCompile Include="Menu.cpp" />
|
||||
<ClCompile Include="NeonAPI.cpp" />
|
||||
<ClCompile Include="Ped.cpp" />
|
||||
<ClCompile Include="Player.cpp" />
|
||||
<ClCompile Include="Teleport.cpp" />
|
||||
<ClCompile Include="Ui.cpp" />
|
||||
<ClCompile Include="external\imgui\imgui.cpp">
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='GTASA zDebug|Win32'">NotUsing</PrecompiledHeader>
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='GTASA Release|Win32'">NotUsing</PrecompiledHeader>
|
||||
</ClCompile>
|
||||
<ClCompile Include="external\imgui\imgui_demo.cpp">
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='GTASA zDebug|Win32'">NotUsing</PrecompiledHeader>
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='GTASA Release|Win32'">NotUsing</PrecompiledHeader>
|
||||
</ClCompile>
|
||||
<ClCompile Include="external\imgui\imgui_draw.cpp">
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='GTASA zDebug|Win32'">NotUsing</PrecompiledHeader>
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='GTASA Release|Win32'">NotUsing</PrecompiledHeader>
|
||||
</ClCompile>
|
||||
<ClCompile Include="external\imgui\imgui_impl_dx9.cpp">
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='GTASA zDebug|Win32'">NotUsing</PrecompiledHeader>
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='GTASA Release|Win32'">NotUsing</PrecompiledHeader>
|
||||
</ClCompile>
|
||||
<ClCompile Include="external\imgui\imgui_impl_win32.cpp">
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='GTASA zDebug|Win32'">NotUsing</PrecompiledHeader>
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='GTASA Release|Win32'">NotUsing</PrecompiledHeader>
|
||||
</ClCompile>
|
||||
<ClCompile Include="external\imgui\imgui_widgets.cpp">
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='GTASA zDebug|Win32'">NotUsing</PrecompiledHeader>
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='GTASA Release|Win32'">NotUsing</PrecompiledHeader>
|
||||
</ClCompile>
|
||||
<ClCompile Include="CheatMenu.cpp">
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='GTASA zDebug|Win32'">Use</PrecompiledHeader>
|
||||
<PrecompiledHeaderFile Condition="'$(Configuration)|$(Platform)'=='GTASA zDebug|Win32'">pch.h</PrecompiledHeaderFile>
|
||||
</ClCompile>
|
||||
<ClCompile Include="pch.cpp">
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='GTASA zDebug|Win32'">Create</PrecompiledHeader>
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='GTASA Release|Win32'">Create</PrecompiledHeader>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Util.cpp" />
|
||||
<ClCompile Include="Vehicle.cpp" />
|
||||
<ClCompile Include="Visual.cpp" />
|
||||
<ClCompile Include="Weapon.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="Events.h" />
|
||||
<ClInclude Include="Animation.h" />
|
||||
<ClInclude Include="external\imgui\imgui_impl_dx11.h" />
|
||||
<ClInclude Include="external\imgui\stb_image.h" />
|
||||
<ClInclude Include="external\json.hpp" />
|
||||
<ClInclude Include="external\kiero\kiero.h" />
|
||||
<ClInclude Include="external\kiero\minhook\include\MinHook.h" />
|
||||
<ClInclude Include="external\moon\pool_object_extender.h" />
|
||||
<ClInclude Include="external\moon\texture_manager.h" />
|
||||
<ClInclude Include="external\moon\vehicle_renderer.h" />
|
||||
<ClInclude Include="Game.h" />
|
||||
<ClInclude Include="Hook.h" />
|
||||
<ClInclude Include="Json.h" />
|
||||
<ClInclude Include="Menu.h" />
|
||||
<ClInclude Include="NeonAPI.h" />
|
||||
<ClInclude Include="Paint.h" />
|
||||
<ClInclude Include="Ped.h" />
|
||||
<ClInclude Include="Player.h" />
|
||||
<ClInclude Include="Teleport.h" />
|
||||
<ClInclude Include="Ui.h" />
|
||||
<ClInclude Include="external\imgui\imconfig.h" />
|
||||
<ClInclude Include="external\imgui\imgui.h" />
|
||||
<ClInclude Include="external\imgui\imgui_impl_dx9.h" />
|
||||
<ClInclude Include="external\imgui\imgui_impl_win32.h" />
|
||||
<ClInclude Include="external\imgui\imgui_internal.h" />
|
||||
<ClInclude Include="external\imgui\imstb_rectpack.h" />
|
||||
<ClInclude Include="external\imgui\imstb_textedit.h" />
|
||||
<ClInclude Include="external\imgui\imstb_truetype.h" />
|
||||
<ClInclude Include="CheatMenu.h" />
|
||||
<ClInclude Include="pch.h" />
|
||||
<ClInclude Include="Util.h" />
|
||||
<ClInclude Include="Vehicle.h" />
|
||||
<ClInclude Include="Visual.h" />
|
||||
<ClInclude Include="VKeys.h" />
|
||||
<ClInclude Include="Weapon.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Library Include="external\kiero\minhook\lib\libMinHook-x86-v140-md.lib" />
|
||||
<Library Include="external\kiero\minhook\lib\libMinHook-x86-v140-mdd.lib" />
|
||||
<Library Include="external\kiero\minhook\lib\libMinHook-x86-v140-mt.lib" />
|
||||
<Library Include="external\kiero\minhook\lib\libMinHook-x86-v140-mtd.lib" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
109
CheatMenu/CheatMenu.vcxproj.vcxproj.filters
Normal file
@ -0,0 +1,109 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<ClCompile Include="CheatMenu.cpp" />
|
||||
<ClCompile Include="external\imgui\imgui_widgets.cpp">
|
||||
<Filter>external</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="external\imgui\imgui.cpp">
|
||||
<Filter>external</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="external\imgui\imgui_demo.cpp">
|
||||
<Filter>external</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="external\imgui\imgui_draw.cpp">
|
||||
<Filter>external</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="external\imgui\imgui_impl_dx9.cpp">
|
||||
<Filter>external</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="external\imgui\imgui_impl_win32.cpp">
|
||||
<Filter>external</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="pch.cpp" />
|
||||
<ClCompile Include="Animation.cpp" />
|
||||
<ClCompile Include="Teleport.cpp" />
|
||||
<ClCompile Include="Json.cpp" />
|
||||
<ClCompile Include="Ui.cpp" />
|
||||
<ClCompile Include="Player.cpp" />
|
||||
<ClCompile Include="Util.cpp" />
|
||||
<ClCompile Include="Ped.cpp" />
|
||||
<ClCompile Include="Weapon.cpp" />
|
||||
<ClCompile Include="Visual.cpp" />
|
||||
<ClCompile Include="Game.cpp" />
|
||||
<ClCompile Include="Menu.cpp" />
|
||||
<ClCompile Include="Hook.cpp" />
|
||||
<ClCompile Include="Vehicle.cpp" />
|
||||
<ClCompile Include="NeonAPI.cpp" />
|
||||
<ClCompile Include="Events.cpp" />
|
||||
<ClCompile Include="external\moon\texture_manager.cpp" />
|
||||
<ClCompile Include="external\moon\vehicle_renderer.cpp" />
|
||||
<ClCompile Include="Paint.cpp" />
|
||||
<ClCompile Include="external\kiero\kiero.cpp" />
|
||||
<ClCompile Include="external\imgui\imgui_impl_dx11.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="CheatMenu.h" />
|
||||
<ClInclude Include="pch.h" />
|
||||
<ClInclude Include="external\imgui\imstb_truetype.h">
|
||||
<Filter>external</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="external\imgui\imconfig.h">
|
||||
<Filter>external</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="external\imgui\imgui.h">
|
||||
<Filter>external</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="external\imgui\imgui_impl_dx9.h">
|
||||
<Filter>external</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="external\imgui\imgui_impl_win32.h">
|
||||
<Filter>external</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="external\imgui\imgui_internal.h">
|
||||
<Filter>external</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="external\imgui\imstb_rectpack.h">
|
||||
<Filter>external</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="external\imgui\imstb_textedit.h">
|
||||
<Filter>external</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Animation.h" />
|
||||
<ClInclude Include="Teleport.h" />
|
||||
<ClInclude Include="Json.h" />
|
||||
<ClInclude Include="Ui.h" />
|
||||
<ClInclude Include="VKeys.h" />
|
||||
<ClInclude Include="Player.h" />
|
||||
<ClInclude Include="Util.h" />
|
||||
<ClInclude Include="Ped.h" />
|
||||
<ClInclude Include="Weapon.h" />
|
||||
<ClInclude Include="Visual.h" />
|
||||
<ClInclude Include="Game.h" />
|
||||
<ClInclude Include="Menu.h" />
|
||||
<ClInclude Include="Hook.h" />
|
||||
<ClInclude Include="Vehicle.h" />
|
||||
<ClInclude Include="NeonAPI.h" />
|
||||
<ClInclude Include="Events.h" />
|
||||
<ClInclude Include="external\json.hpp" />
|
||||
<ClInclude Include="external\moon\pool_object_extender.h" />
|
||||
<ClInclude Include="external\moon\texture_manager.h" />
|
||||
<ClInclude Include="external\moon\vehicle_renderer.h" />
|
||||
<ClInclude Include="Paint.h" />
|
||||
<ClInclude Include="external\kiero\kiero.h" />
|
||||
<ClInclude Include="external\kiero\minhook\include\MinHook.h" />
|
||||
<ClInclude Include="external\imgui\imgui_impl_dx11.h" />
|
||||
<ClInclude Include="external\imgui\stb_image.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Filter Include="external">
|
||||
<UniqueIdentifier>{f1569096-fe99-4d5d-871f-c0e55624f9d4}</UniqueIdentifier>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Library Include="external\kiero\minhook\lib\libMinHook-x86-v140-md.lib" />
|
||||
<Library Include="external\kiero\minhook\lib\libMinHook-x86-v140-mdd.lib" />
|
||||
<Library Include="external\kiero\minhook\lib\libMinHook-x86-v140-mt.lib" />
|
||||
<Library Include="external\kiero\minhook\lib\libMinHook-x86-v140-mtd.lib" />
|
||||
</ItemGroup>
|
||||
</Project>
|
12
CheatMenu/Events.cpp
Normal file
@ -0,0 +1,12 @@
|
||||
#include "pch.h"
|
||||
#include "Events.h"
|
||||
|
||||
|
||||
namespace plugin
|
||||
{
|
||||
namespace Events
|
||||
{
|
||||
decltype(vehicleResetAfterRender) vehicleResetAfterRender;
|
||||
decltype(renderscence) renderscence;
|
||||
}
|
||||
}
|
10
CheatMenu/Events.h
Normal file
@ -0,0 +1,10 @@
|
||||
#pragma once
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
478
CheatMenu/Game.cpp
Normal file
@ -0,0 +1,478 @@
|
||||
#include "pch.h"
|
||||
#include "Game.h"
|
||||
#include "Menu.h"
|
||||
|
||||
ImGuiTextFilter Game::filter = "";
|
||||
std::vector<std::string> Game::search_categories;
|
||||
std::string Game::selected_item = "All";
|
||||
std::vector<std::string> Game::day_names{ "Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday" };
|
||||
char Game::save_game_name[22] = "";
|
||||
|
||||
CJson Game::json = CJson("mission");
|
||||
|
||||
CJson Game::stat::json = CJson("stat");
|
||||
std::vector<std::string> Game::stat::search_categories;
|
||||
std::string Game::stat::selected_item = "All";
|
||||
ImGuiTextFilter Game::stat::filter = "";
|
||||
|
||||
bool Game::random_cheats::enable = false;
|
||||
int Game::random_cheats::enable_wait_time = 10;
|
||||
uint Game::random_cheats::timer = 0;
|
||||
std::string Game::random_cheats::enabled_cheats[92][2];
|
||||
|
||||
bool Game::airbreak::init_done = false;
|
||||
bool Game::airbreak::enable = false;
|
||||
float Game::airbreak::speed = 0.4f;
|
||||
float Game::airbreak::tmouseX = 0;
|
||||
float Game::airbreak::tmouseY = 0;
|
||||
|
||||
bool Game::disable_cheats = false;
|
||||
bool Game::disable_replay = false;
|
||||
bool Game::forbidden_area_wl = true;
|
||||
bool Game::freeze_mission_timer = false;
|
||||
bool Game::freeze_time = false;
|
||||
bool Game::keep_stuff = false;
|
||||
bool Game::solid_water = false;
|
||||
bool Game::ss_shortcut = false;
|
||||
bool Game::sync_time = false;
|
||||
|
||||
uint Game::ss_shotcut_timer = 0;
|
||||
uint Game::sync_time_timer = 0;
|
||||
|
||||
uint Game::solid_water_object = 0;
|
||||
|
||||
CJson Game::random_cheats::name_json = CJson("cheat name");
|
||||
|
||||
Game::Game()
|
||||
{
|
||||
Events::initGameEvent += []
|
||||
{
|
||||
json.LoadJsonData(search_categories, selected_item);
|
||||
stat::json.LoadJsonData(stat::search_categories, stat::selected_item);
|
||||
|
||||
// Generate enabled cheats vector
|
||||
for (auto element : random_cheats::name_json.data.items())
|
||||
{
|
||||
/*
|
||||
[
|
||||
cheat_id = [ cheat_name, state (true/false) ]
|
||||
]
|
||||
*/
|
||||
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 int hplayer = CPools::GetPedRef(player);
|
||||
|
||||
if (ss_shortcut)
|
||||
{
|
||||
if (Ui::HotKeyPressed(Menu::hotkey::quick_ss) && timer - ss_shotcut_timer > 1000)
|
||||
{
|
||||
Command<Commands::TAKE_PHOTO>();
|
||||
CHud::SetHelpMessage("Screenshot taken", false, false, false);
|
||||
ss_shotcut_timer = timer;
|
||||
}
|
||||
}
|
||||
|
||||
if (solid_water)
|
||||
{
|
||||
CVector pos = player->GetPosition();
|
||||
|
||||
float water_height = 0;
|
||||
Command<Commands::GET_WATER_HEIGHT_AT_COORDS>(pos.x, pos.y, false, &water_height);
|
||||
|
||||
if (!Command<Commands::IS_CHAR_IN_ANY_BOAT>(hplayer) && water_height != -1000.0f && pos.z > (water_height+1))
|
||||
{
|
||||
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);
|
||||
}
|
||||
else
|
||||
Command<Commands::SET_OBJECT_COORDINATES>(solid_water_object, pos.x, pos.y, water_height);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (solid_water_object != 0)
|
||||
{
|
||||
Command<Commands::DELETE_OBJECT>(solid_water_object);
|
||||
solid_water_object = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// improve this later
|
||||
if (sync_time && timer - sync_time_timer > 50)
|
||||
{
|
||||
std::time_t t = std::time(0);
|
||||
std::tm* now = std::localtime(&t);
|
||||
|
||||
CClock::ms_nGameClockHours = now->tm_hour;
|
||||
CClock::ms_nGameClockMinutes = now->tm_min;
|
||||
|
||||
sync_time_timer = timer;
|
||||
}
|
||||
|
||||
if (random_cheats::enable
|
||||
&& (timer - random_cheats::timer) > (uint(random_cheats::enable_wait_time)*1000))
|
||||
{
|
||||
int id = cheat_id(gen);
|
||||
|
||||
for (int i = 0; i < 92; i++)
|
||||
{
|
||||
if (i == id)
|
||||
{
|
||||
if (random_cheats::enabled_cheats[i][1] == "true")
|
||||
{
|
||||
((void(*)(int))0x00438370)(id); // cheatEnableLegimate(int CheatID)
|
||||
CHud::SetHelpMessage(random_cheats::enabled_cheats[i][0].c_str(), false, false, false);
|
||||
random_cheats::timer = timer;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (airbreak::enable)
|
||||
{
|
||||
AirbreakMode(player,hplayer);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
Game::~Game()
|
||||
{
|
||||
}
|
||||
|
||||
void SetPlayerMission(std::string& rootkey, std::string& name, std::string& id)
|
||||
{
|
||||
CPlayerPed *player = FindPlayerPed();
|
||||
uint hplayer = CPools::GetPedRef(player);
|
||||
int interior = 0;
|
||||
|
||||
Command<0x09E8>(hplayer,&interior);
|
||||
if ( Util::IsOnMission() && interior == 0)
|
||||
{
|
||||
player->SetWantedLevel(0);
|
||||
Command<Commands::LOAD_AND_LAUNCH_MISSION_INTERNAL>(std::stoi(id));
|
||||
}
|
||||
else CHud::SetHelpMessage("Can't start mission now", false, false, false);
|
||||
|
||||
}
|
||||
|
||||
void Game::AirbreakMode(CPlayerPed* player, int hplayer)
|
||||
{
|
||||
CVector pos = player->GetPosition();
|
||||
|
||||
if (!airbreak::init_done)
|
||||
{
|
||||
Command<Commands::SET_EVERYONE_IGNORE_PLAYER>(0, true);
|
||||
Command<Commands::FREEZE_CHAR_POSITION_AND_DONT_LOAD_COLLISION>(hplayer,true);
|
||||
Command<Commands::SET_CHAR_COLLISION>(hplayer, false);
|
||||
Command<Commands::SET_LOAD_COLLISION_FOR_CHAR_FLAG>(hplayer, false);
|
||||
player->m_nPedFlags.bDontRender = true;
|
||||
|
||||
CHud::bScriptDontDisplayRadar = true;
|
||||
CHud::m_Wants_To_Draw_Hud = false;
|
||||
|
||||
airbreak::tmouseX = TheCamera.GetHeading() + (90.0f * 3.1416f / 180.0f);
|
||||
airbreak::tmouseY = 0;
|
||||
airbreak::init_done = true;
|
||||
}
|
||||
|
||||
float mul = 1.0f;
|
||||
|
||||
airbreak::tmouseX -= (CPad::NewMouseControllerState.X / 6.0f);
|
||||
airbreak::tmouseY += (CPad::NewMouseControllerState.Y / 3.0f);
|
||||
|
||||
airbreak::tmouseY = (airbreak::tmouseY > 17.1887f) ? 17.1887f : airbreak::tmouseY;
|
||||
airbreak::tmouseY = (airbreak::tmouseY < -17.1887f) ? -17.1887f : airbreak::tmouseY;
|
||||
|
||||
TheCamera.m_fOrientation = airbreak::tmouseY * (3.1416 / 180);
|
||||
|
||||
if (KeyPressed(VK_RCONTROL))
|
||||
mul /= 2;
|
||||
|
||||
if (KeyPressed(VK_RSHIFT))
|
||||
mul *= 2;
|
||||
|
||||
if (KeyPressed(VK_KEY_I) || KeyPressed(VK_KEY_K))
|
||||
{
|
||||
if (KeyPressed(VK_KEY_K))
|
||||
mul *= -1;
|
||||
|
||||
float angle = TheCamera.GetHeading() + (90.0f * 3.1416f / 180.0f);
|
||||
|
||||
pos.x += airbreak::speed * cos(angle) * mul;
|
||||
pos.y += airbreak::speed * sin(angle) * mul;
|
||||
pos.z += airbreak::speed * sin(TheCamera.m_fOrientation*2) * mul;
|
||||
}
|
||||
|
||||
if (KeyPressed(VK_KEY_J) || KeyPressed(VK_KEY_L))
|
||||
{
|
||||
if (KeyPressed(VK_KEY_J))
|
||||
mul *= -1;
|
||||
|
||||
float angle = TheCamera.GetHeading() + (90.0f * 3.1416f / 180.0f);
|
||||
|
||||
pos.x += airbreak::speed * cos(angle) * mul;
|
||||
pos.y += airbreak::speed * sin(angle) * mul;
|
||||
}
|
||||
|
||||
player->SetPosn(pos);
|
||||
}
|
||||
|
||||
void Game::Main()
|
||||
{
|
||||
ImGui::Spacing();
|
||||
static CPlayerPed *player = FindPlayerPed();
|
||||
static int hplayer = CPools::GetPedRef(player);
|
||||
|
||||
if (ImGui::BeginTabBar("Game", ImGuiTabBarFlags_NoTooltip + ImGuiTabBarFlags_FittingPolicyScroll))
|
||||
{
|
||||
if (ImGui::BeginTabItem("Checkboxes"))
|
||||
{
|
||||
ImGui::Spacing();
|
||||
ImGui::Columns(2, 0, false);
|
||||
if (ImGui::Checkbox("Disable cheats", &disable_cheats))
|
||||
{
|
||||
if (disable_cheats)
|
||||
{
|
||||
patch::Set<BYTE>(0x4384D0, 0xE9, false);
|
||||
patch::SetInt(0x4384D1, 0xD0, false);
|
||||
patch::Nop(0x4384D5, 4, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
patch::Set<BYTE>(0x4384D0, 0x83, false);
|
||||
patch::SetInt(0x4384D1, -0x7DF0F908, false);
|
||||
patch::SetInt(0x4384D5, 0xCC, false);
|
||||
}
|
||||
}
|
||||
if (ImGui::Checkbox("Disable F1 & F3 replay", &disable_replay))
|
||||
{
|
||||
if (disable_replay)
|
||||
patch::SetInt(0x460500, 0xC3, false);
|
||||
else
|
||||
patch::SetInt(0x460500, 0xBD844BB, false);
|
||||
}
|
||||
|
||||
Ui::CheckboxAddress("Faster clock", 0x96913B);
|
||||
|
||||
if (Ui::CheckboxWithHint("Forbidden area wl", &forbidden_area_wl, "Wanted levels that appears outside\
|
||||
of LS without completing missions"))
|
||||
{
|
||||
if (forbidden_area_wl)
|
||||
patch::Set<BYTE>(0x441770, 0x83, false);
|
||||
else
|
||||
patch::Set<BYTE>(0x441770, 0xC3, false);
|
||||
}
|
||||
|
||||
Ui::CheckboxAddress("Free pay n spray", 0x96C009);
|
||||
|
||||
ImGui::NextColumn();
|
||||
|
||||
if (ImGui::Checkbox("Freeze misson timer", &freeze_mission_timer))
|
||||
Command<Commands::FREEZE_ONSCREEN_TIMER>(freeze_mission_timer);
|
||||
|
||||
if (Ui::CheckboxWithHint("Keep stuff", &keep_stuff, "Keep stuff after arrest/death"))
|
||||
{
|
||||
Command<Commands::SWITCH_ARREST_PENALTIES>(keep_stuff);
|
||||
Command<Commands::SWITCH_DEATH_PENALTIES>(keep_stuff);
|
||||
}
|
||||
Ui::CheckboxWithHint("Screenshot shortcut", &ss_shortcut, (("Take screenshot using ") + Ui::GetHotKeyNameString(Menu::hotkey::quick_ss)).c_str());
|
||||
if (Ui::CheckboxWithHint("Solid water", &solid_water, "Player can walk on water"))
|
||||
{
|
||||
if (!solid_water && solid_water_object != 0)
|
||||
{
|
||||
Command<Commands::DELETE_OBJECT>(solid_water_object);
|
||||
solid_water_object = 0;
|
||||
}
|
||||
}
|
||||
ImGui::Checkbox("Sync system time", &sync_time);
|
||||
|
||||
ImGui::Columns(1);
|
||||
ImGui::EndTabItem();
|
||||
}
|
||||
if (ImGui::BeginTabItem("Menus"))
|
||||
{
|
||||
if (ImGui::CollapsingHeader("Airbreak mode"))
|
||||
{
|
||||
if (Ui::CheckboxWithHint("Enable", &airbreak::enable, "Forward: I\tBackward: K\
|
||||
\nLeft: J\t\t Right: L\n\nSlower: RCtrl\tFaster: RShift"))
|
||||
{
|
||||
if (!airbreak::enable)
|
||||
{
|
||||
airbreak::init_done = false;
|
||||
Command<Commands::SET_EVERYONE_IGNORE_PLAYER>(0, false);
|
||||
Command<Commands::FREEZE_CHAR_POSITION_AND_DONT_LOAD_COLLISION>(hplayer, false);
|
||||
Command<Commands::SET_CHAR_COLLISION>(hplayer, true);
|
||||
Command<Commands::SET_LOAD_COLLISION_FOR_CHAR_FLAG>(hplayer, true);
|
||||
player->m_nPedFlags.bDontRender = false;
|
||||
|
||||
CHud::bScriptDontDisplayRadar = false;
|
||||
CHud::m_Wants_To_Draw_Hud = true;
|
||||
|
||||
CVector pos = player->GetPosition();
|
||||
CEntity* player_entity = FindPlayerEntity(-1);
|
||||
pos.z = CWorld::FindGroundZFor3DCoord(pos.x, pos.y, 1000, 0, &player_entity) + 0.5f;
|
||||
player->SetPosn(pos);
|
||||
Command<Commands::RESTORE_CAMERA_JUMPCUT>();
|
||||
}
|
||||
}
|
||||
ImGui::Spacing();
|
||||
|
||||
ImGui::SliderFloat("Movement Speed", &airbreak::speed, 0.0, 5.0);
|
||||
|
||||
ImGui::Spacing();
|
||||
ImGui::Separator();
|
||||
}
|
||||
if (ImGui::CollapsingHeader("Current day"))
|
||||
{
|
||||
int day = CClock::CurrentDay-1;
|
||||
if (Ui::ListBox("Select day", day_names, day))
|
||||
CClock::CurrentDay = day+1;
|
||||
ImGui::Spacing();
|
||||
ImGui::Separator();
|
||||
}
|
||||
Ui::EditAddress<int>("Days passed", 0xB79038, 0, 9999);
|
||||
Ui::EditReference("FPS limit", RsGlobal.frameLimit, 1, 30, 60);
|
||||
Ui::EditReference("Game speed", CTimer::ms_fTimeScale,0, 1, 10);
|
||||
Ui::EditFloat("Gravity", 0x863984, -1.0f, 0.008f, 1.0f);
|
||||
|
||||
if (ImGui::CollapsingHeader("Set time"))
|
||||
{
|
||||
int hour = CClock::ms_nGameClockHours;
|
||||
int minute = CClock::ms_nGameClockMinutes;
|
||||
|
||||
if (ImGui::InputInt("Hour", &hour))
|
||||
{
|
||||
if (hour < 0) hour = 23;
|
||||
if (hour > 23) hour = 0;
|
||||
CClock::ms_nGameClockHours = hour;
|
||||
}
|
||||
|
||||
if (ImGui::InputInt("Minute", &minute))
|
||||
{
|
||||
if (minute < 0) minute = 59;
|
||||
if (minute > 59) minute = 0;
|
||||
CClock::ms_nGameClockMinutes = minute;
|
||||
}
|
||||
|
||||
ImGui::Spacing();
|
||||
ImGui::Separator();
|
||||
}
|
||||
|
||||
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)))
|
||||
((func*)0x438F80)();
|
||||
|
||||
ImGui::SameLine();
|
||||
if (ImGui::Button("Overcast", Ui::GetSize(3)))
|
||||
((func*)0x438F60)();
|
||||
|
||||
ImGui::SameLine();
|
||||
if (ImGui::Button("Rainy", Ui::GetSize(3)))
|
||||
((func*)0x438F70)();
|
||||
|
||||
if (ImGui::Button("Sandstorm", Ui::GetSize(3)))
|
||||
((func*)0x439590)();
|
||||
|
||||
ImGui::SameLine();
|
||||
if (ImGui::Button("Thunderstorm", Ui::GetSize(3)))
|
||||
((func*)0x439570)();
|
||||
|
||||
ImGui::SameLine();
|
||||
if (ImGui::Button("Very sunny", Ui::GetSize(3)))
|
||||
((func*)0x438F50)();
|
||||
|
||||
ImGui::Spacing();
|
||||
ImGui::Separator();
|
||||
}
|
||||
ImGui::EndTabItem();
|
||||
}
|
||||
if (ImGui::BeginTabItem("Missions"))
|
||||
{
|
||||
ImGui::Spacing();
|
||||
|
||||
if (ImGui::Button("Fail current mission", ImVec2(Ui::GetSize())))
|
||||
{
|
||||
if (!CCutsceneMgr::ms_running)
|
||||
Command<Commands::FAIL_CURRENT_MISSION>();
|
||||
}
|
||||
|
||||
ImGui::Spacing();
|
||||
|
||||
Ui::DrawJSON(json, search_categories, selected_item, filter, SetPlayerMission, nullptr);
|
||||
ImGui::EndTabItem();
|
||||
}
|
||||
if (ImGui::BeginTabItem("Stats"))
|
||||
{
|
||||
// similat to Ui::DrawJSON()
|
||||
ImGui::Spacing();
|
||||
|
||||
ImGui::PushItemWidth(ImGui::GetContentRegionAvailWidth() / 2 - 5);
|
||||
Ui::ListBoxStr("##Categories", stat::search_categories, stat::selected_item);
|
||||
ImGui::SameLine();
|
||||
Ui::FilterWithHint("##Filter", stat::filter, "Search");
|
||||
ImGui::PopItemWidth();
|
||||
|
||||
ImGui::Spacing();
|
||||
|
||||
ImGui::BeginChild("STATCHILD");
|
||||
for (auto root : stat::json.data.items())
|
||||
{
|
||||
if (root.key() == stat::selected_item || stat::selected_item == "All")
|
||||
{
|
||||
for (auto _data : root.value().items())
|
||||
{
|
||||
std::string name = _data.value().get<std::string>();
|
||||
if (stat::filter.PassFilter(name.c_str()))
|
||||
Ui::EditStat(name.c_str(), std::stoi(_data.key()));
|
||||
}
|
||||
}
|
||||
}
|
||||
ImGui::EndChild();
|
||||
ImGui::EndTabItem();
|
||||
}
|
||||
if (ImGui::BeginTabItem("Random cheats"))
|
||||
{
|
||||
ImGui::Spacing();
|
||||
ImGui::Checkbox("Enable", &random_cheats::enable);
|
||||
ImGui::Spacing();
|
||||
|
||||
ImGui::PushItemWidth(ImGui::GetWindowContentRegionWidth() / 2);
|
||||
|
||||
ImGui::SliderInt("Activate cheat timer", &random_cheats::enable_wait_time, 5, 60);
|
||||
Ui::ShowTooltip("Wait time after a cheat is activated.");
|
||||
|
||||
ImGui::PopItemWidth();
|
||||
|
||||
ImGui::TextWrapped("Select cheats");
|
||||
ImGui::Separator();
|
||||
if (ImGui::BeginChild("Cheats list"))
|
||||
{
|
||||
for (auto element : random_cheats::enabled_cheats)
|
||||
{
|
||||
bool selected = (element[1] == "true") ? true : false;
|
||||
|
||||
if (ImGui::MenuItem(element[0].c_str(), 0, selected))
|
||||
element[1] = selected ? "false" : "true";
|
||||
}
|
||||
ImGui::EndChild();
|
||||
}
|
||||
ImGui::EndTabItem();
|
||||
}
|
||||
ImGui::EndTabBar();
|
||||
}
|
||||
}
|
58
CheatMenu/Game.h
Normal file
@ -0,0 +1,58 @@
|
||||
#pragma once
|
||||
class Game
|
||||
{
|
||||
private:
|
||||
static CJson json;
|
||||
static ImGuiTextFilter filter;
|
||||
static std::vector<std::string> search_categories;
|
||||
static std::string selected_item;
|
||||
static std::vector<std::string> day_names;
|
||||
|
||||
static char save_game_name[22];
|
||||
|
||||
struct random_cheats
|
||||
{
|
||||
static bool enable;
|
||||
static int enable_wait_time;
|
||||
static CJson name_json;
|
||||
static uint timer;
|
||||
static std::string enabled_cheats[92][2];
|
||||
};
|
||||
|
||||
struct airbreak
|
||||
{
|
||||
static bool enable;
|
||||
static float speed;
|
||||
static bool init_done;
|
||||
static float tmouseX, tmouseY;
|
||||
};
|
||||
|
||||
static bool disable_cheats;
|
||||
static bool disable_replay;
|
||||
static bool forbidden_area_wl;
|
||||
static bool freeze_mission_timer;
|
||||
static bool freeze_time;
|
||||
static bool keep_stuff;
|
||||
static bool solid_water;
|
||||
static bool ss_shortcut;
|
||||
static bool sync_time;
|
||||
|
||||
static uint ss_shotcut_timer;
|
||||
static uint sync_time_timer;
|
||||
static uint solid_water_object;
|
||||
|
||||
struct stat
|
||||
{
|
||||
static CJson json;
|
||||
static ImGuiTextFilter filter;
|
||||
static std::vector<std::string> search_categories;
|
||||
static std::string selected_item;
|
||||
};
|
||||
|
||||
public:
|
||||
Game();
|
||||
~Game();
|
||||
static void Main();
|
||||
static void AirbreakMode(CPlayerPed* player, int hplayer);
|
||||
};
|
||||
|
189
CheatMenu/Hook.cpp
Normal file
@ -0,0 +1,189 @@
|
||||
#include "pch.h"
|
||||
#include "Hook.h"
|
||||
#include "external\kiero\kiero.h"
|
||||
#include "external\kiero\minhook\include\MinHook.h"
|
||||
|
||||
WNDPROC Hook::oWndProc = NULL;
|
||||
f_Reset Hook::oReset9 = NULL;
|
||||
f_Present11 Hook::oPresent11 = NULL;
|
||||
f_Present9 Hook::oPresent9 = NULL;
|
||||
|
||||
bool Hook::disable_controls = false;
|
||||
std::function<void()> Hook::window_func = NULL;
|
||||
|
||||
LRESULT Hook::InputProc(const HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
ImGui_ImplWin32_WndProcHandler(hWnd, uMsg, wParam, lParam);
|
||||
|
||||
if (disable_controls)
|
||||
return 1;
|
||||
else
|
||||
return CallWindowProc(oWndProc, hWnd, uMsg, wParam, lParam);
|
||||
}
|
||||
|
||||
HRESULT Hook::ResetDx9(IDirect3DDevice9 * pDevice, D3DPRESENT_PARAMETERS * pPresentationParameters)
|
||||
{
|
||||
ImGui_ImplDX9_InvalidateDeviceObjects();
|
||||
long result = oReset9(pDevice, pPresentationParameters);
|
||||
ImGui_ImplDX9_CreateDeviceObjects();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
HRESULT Hook::PresentDx9(IDirect3DDevice9 *pDevice, RECT* pSourceRect, RECT* pDestRect, HWND hDestWindowOverride, RGNDATA* pDirtyRegion)
|
||||
{
|
||||
ImGuiIO& io = ImGui::GetIO();
|
||||
|
||||
if (Globals::init_done)
|
||||
{
|
||||
// Change font size if the game resolution changes
|
||||
if (Globals::font_screen_size.x != screen::GetScreenWidth()
|
||||
&& Globals::font_screen_size.y != screen::GetScreenHeight())
|
||||
{
|
||||
int font_size = int(screen::GetScreenHeight() / 54.85); // manually tested
|
||||
|
||||
io.FontDefault = io.Fonts->AddFontFromFileTTF("C:/Windows/Fonts/trebucbd.ttf", font_size);
|
||||
io.Fonts->Build();
|
||||
ImGui_ImplDX9_InvalidateDeviceObjects();
|
||||
|
||||
Globals::font_screen_size = ImVec2(screen::GetScreenWidth(), screen::GetScreenHeight());
|
||||
}
|
||||
|
||||
ImGui_ImplDX9_NewFrame();
|
||||
ImGui_ImplWin32_NewFrame();
|
||||
ImGui::NewFrame();
|
||||
|
||||
if (window_func != NULL)
|
||||
window_func();
|
||||
|
||||
ImGui::EndFrame();
|
||||
ImGui::Render();
|
||||
ImGui_ImplDX9_RenderDrawData(ImGui::GetDrawData());
|
||||
}
|
||||
else
|
||||
{
|
||||
Globals::init_done = true;
|
||||
|
||||
ImGui::CreateContext();
|
||||
|
||||
ImGuiStyle& style = ImGui::GetStyle();
|
||||
|
||||
ImGui_ImplWin32_Init(RsGlobal.ps->window);
|
||||
ImGui_ImplDX9_Init(pDevice);
|
||||
ImGui_ImplWin32_EnableDpiAwareness();
|
||||
|
||||
io.IniFilename = NULL;
|
||||
io.LogFilename = NULL;
|
||||
|
||||
style.WindowTitleAlign = ImVec2(0.5, 0.5);
|
||||
oWndProc = (WNDPROC)SetWindowLongPtr(RsGlobal.ps->window, GWL_WNDPROC, (LRESULT)InputProc);
|
||||
}
|
||||
|
||||
return oPresent9(pDevice, pSourceRect, pDestRect, hDestWindowOverride, pDirtyRegion);;
|
||||
}
|
||||
|
||||
HRESULT Hook::PresentDx11(IDXGISwapChain* pSwapChain, UINT SyncInterval, UINT Flags)
|
||||
{
|
||||
ImGuiIO& io = ImGui::GetIO();
|
||||
|
||||
if (Globals::init_done)
|
||||
{
|
||||
static RwBool fullscreen = RsGlobal.ps->fullScreen;
|
||||
|
||||
if (fullscreen != RsGlobal.ps->fullScreen)
|
||||
{
|
||||
fullscreen = RsGlobal.ps->fullScreen;
|
||||
ImGui_ImplDX11_InvalidateDeviceObjects();
|
||||
}
|
||||
|
||||
// Change font size if the game resolution changes
|
||||
if (Globals::font_screen_size.x != screen::GetScreenWidth()
|
||||
&& Globals::font_screen_size.y != screen::GetScreenHeight())
|
||||
{
|
||||
int font_size = int(screen::GetScreenHeight() / 54.85); // manually tested
|
||||
|
||||
io.FontDefault = io.Fonts->AddFontFromFileTTF("C:/Windows/Fonts/trebucbd.ttf", font_size);
|
||||
io.Fonts->Build();
|
||||
ImGui_ImplDX11_InvalidateDeviceObjects();
|
||||
|
||||
Globals::font_screen_size = ImVec2(screen::GetScreenWidth(), screen::GetScreenHeight());
|
||||
}
|
||||
|
||||
ImGui_ImplDX11_NewFrame();
|
||||
ImGui_ImplWin32_NewFrame();
|
||||
ImGui::NewFrame();
|
||||
|
||||
if (window_func != NULL)
|
||||
window_func();
|
||||
|
||||
ImGui::EndFrame();
|
||||
ImGui::Render();
|
||||
ImGui_ImplDX11_RenderDrawData(ImGui::GetDrawData());
|
||||
}
|
||||
else
|
||||
{
|
||||
Globals::init_done = true;
|
||||
|
||||
ImGuiStyle& style = ImGui::GetStyle();
|
||||
|
||||
DXGI_SWAP_CHAIN_DESC desc;
|
||||
pSwapChain->GetDesc(&desc);
|
||||
|
||||
pSwapChain->GetDevice(__uuidof(ID3D11Device), (void**)&Globals::device11);
|
||||
ID3D11DeviceContext* context;
|
||||
Globals::device11->GetImmediateContext(&context);
|
||||
|
||||
ImGui::CreateContext();
|
||||
ImGui_ImplWin32_Init(desc.OutputWindow);
|
||||
ImGui_ImplDX11_Init(Globals::device11, context);
|
||||
ImGui_ImplWin32_EnableDpiAwareness();
|
||||
|
||||
io.IniFilename = NULL;
|
||||
io.LogFilename = NULL;
|
||||
|
||||
style.WindowTitleAlign = ImVec2(0.5, 0.5);
|
||||
|
||||
oWndProc = (WNDPROC)SetWindowLongPtr(RsGlobal.ps->window, GWL_WNDPROC, (LONG)InputProc);
|
||||
}
|
||||
|
||||
return oPresent11(pSwapChain, SyncInterval, Flags);
|
||||
}
|
||||
|
||||
Hook::Hook()
|
||||
{
|
||||
ImGui::CreateContext();
|
||||
Events::initRwEvent += []()
|
||||
{
|
||||
if (kiero::init(kiero::RenderType::D3D9) == kiero::Status::Success)
|
||||
{
|
||||
assert(kiero::bind(16, (void**)&oReset9, ResetDx9) == kiero::Status::Success);
|
||||
assert(kiero::bind(17, (void**)&oPresent9, PresentDx9) == kiero::Status::Success);
|
||||
Globals::renderer = Render_DirectX9;
|
||||
|
||||
flog << "Successfully hooked dx9 device." << std::endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
// gtaRenderHook
|
||||
if (kiero::init(kiero::RenderType::D3D11) == kiero::Status::Success)
|
||||
{
|
||||
kiero::bind(8, (void**)&oPresent11, PresentDx11);
|
||||
Globals::renderer = Render_DirectX11;
|
||||
|
||||
flog << "Successfully hooked dx11 device." << std::endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
flog << "Failed to hook device" << std::endl;
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
Hook::~Hook()
|
||||
{
|
||||
ImGui_ImplDX9_Shutdown();
|
||||
ImGui_ImplWin32_Shutdown();
|
||||
ImGui::DestroyContext();
|
||||
kiero::shutdown();
|
||||
}
|
31
CheatMenu/Hook.h
Normal file
@ -0,0 +1,31 @@
|
||||
#pragma once
|
||||
|
||||
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);
|
||||
|
||||
extern IMGUI_IMPL_API LRESULT ImGui_ImplWin32_WndProcHandler(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
|
||||
|
||||
class Hook
|
||||
{
|
||||
private:
|
||||
static WNDPROC oWndProc;
|
||||
static f_Reset oReset9;
|
||||
static f_Present11 oPresent11;
|
||||
static f_Present9 oPresent9;
|
||||
|
||||
static HRESULT CALLBACK ResetDx9(IDirect3DDevice9 * pDevice, D3DPRESENT_PARAMETERS* pPresentationParameters);
|
||||
static HRESULT CALLBACK PresentDx9(IDirect3DDevice9 *pDevice, RECT* pSourceRect, RECT* pDestRect, HWND hDestWindowOverride, RGNDATA* pDirtyRegion);
|
||||
static HRESULT CALLBACK PresentDx11(IDXGISwapChain* pSwapChain, UINT SyncInterval, UINT Flags);
|
||||
static LRESULT CALLBACK InputProc(const HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
|
||||
|
||||
protected:
|
||||
static bool disable_controls;
|
||||
static std::function<void()> window_func;
|
||||
|
||||
public:
|
||||
Hook();
|
||||
~Hook();
|
||||
};
|
||||
|
||||
|
36
CheatMenu/Json.cpp
Normal file
@ -0,0 +1,36 @@
|
||||
#include "pch.h"
|
||||
#include "Json.h"
|
||||
|
||||
CJson::CJson(const char* name,bool create_new)
|
||||
{
|
||||
file_path = "./CheatMenu/json/"+ std::string(name) +".json";
|
||||
|
||||
if (std::experimental::filesystem::exists(file_path))
|
||||
{
|
||||
std::ifstream file(file_path);
|
||||
file >> data;
|
||||
file.close();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (create_new)
|
||||
{
|
||||
std::fstream new_file(file_path,std::fstream::out);
|
||||
data = "{}"_json;
|
||||
new_file.close();
|
||||
}
|
||||
else flog << "File doesn't exist " << file_path << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
void CJson::LoadJsonData(std::vector<std::string>& vec, std::string& selected)
|
||||
{
|
||||
for (auto element : data.items())
|
||||
vec.push_back(element.key());
|
||||
}
|
||||
|
||||
CJson::~CJson()
|
||||
{
|
||||
std::ofstream file(file_path);
|
||||
file << data.dump(4) << std::endl;
|
||||
}
|
57
CheatMenu/Json.h
Normal file
@ -0,0 +1,57 @@
|
||||
#pragma once
|
||||
#include "external\json.hpp"
|
||||
|
||||
class CJson
|
||||
{
|
||||
|
||||
private:
|
||||
std::string file_path;
|
||||
public:
|
||||
nlohmann::json data;
|
||||
template <typename T>
|
||||
T GetValue(std::string&& key, T&& default_val)
|
||||
{
|
||||
try {
|
||||
std::stringstream ss(key);
|
||||
std::string line;
|
||||
|
||||
nlohmann::json *json = &data;
|
||||
|
||||
while (getline(ss, line, '.'))
|
||||
json = &((*json)[line]);
|
||||
|
||||
// json library bugs with bool, using int instead
|
||||
if (typeid(T) == typeid(bool))
|
||||
{
|
||||
return ((json->get<int>() == 1) ? true : false);
|
||||
}
|
||||
else
|
||||
return json->get<T>();
|
||||
}
|
||||
catch (...) {
|
||||
return default_val;
|
||||
}
|
||||
}
|
||||
template <typename T>
|
||||
void SetValue(std::string&& key, T&& val)
|
||||
{
|
||||
std::stringstream ss(key);
|
||||
std::string line;
|
||||
|
||||
nlohmann::json *json = &data;
|
||||
|
||||
while (getline(ss, line, '.'))
|
||||
json = &((*json)[line]);
|
||||
|
||||
// json library bugs with bool, using int instead
|
||||
if (typeid(T) == typeid(bool))
|
||||
*json = (val ? 1 : 0);
|
||||
else
|
||||
*json = val;
|
||||
}
|
||||
void LoadJsonData(std::vector<std::string>& vec, std::string& selected);
|
||||
CJson(const char* text, bool create_new = false);
|
||||
virtual ~CJson();
|
||||
};
|
||||
|
||||
|
404
CheatMenu/Menu.cpp
Normal file
@ -0,0 +1,404 @@
|
||||
#include "pch.h"
|
||||
#include "Menu.h"
|
||||
#include "Teleport.h"
|
||||
#include "Weapon.h"
|
||||
|
||||
bool Menu::overlay::coord = false;
|
||||
bool Menu::overlay::fps = false;
|
||||
bool Menu::overlay::loc_name = false;
|
||||
bool Menu::overlay::transparent = false;
|
||||
bool Menu::overlay::veh_health = false;
|
||||
bool Menu::overlay::veh_speed = false;
|
||||
std::vector<std::string> Menu::overlay::pos_names{ "Custom", "Top left", "Top right", "Bottom left", "Bottom right" };
|
||||
int Menu::overlay::selected_pos = 4;
|
||||
float Menu::overlay::posX = NULL;
|
||||
float Menu::overlay::posY = NULL;
|
||||
|
||||
int Menu::hotkey::command_window[]{ VK_LMENU ,VK_KEY_C };
|
||||
int Menu::hotkey::menu_open[]{VK_LCONTROL ,VK_KEY_M};
|
||||
int Menu::hotkey::aim_skin_changer[]{ VK_RETURN ,VK_RETURN };
|
||||
int Menu::hotkey::quick_ss[]{ VK_LCONTROL ,VK_KEY_S };
|
||||
int Menu::hotkey::quick_tp[]{ VK_KEY_X ,VK_KEY_Y };
|
||||
|
||||
bool Menu::commands::show_menu = false;
|
||||
char Menu::commands::input_buffer[INPUT_BUFFER_SIZE] = "";
|
||||
|
||||
Menu::Menu()
|
||||
{
|
||||
Events::initGameEvent += []
|
||||
{
|
||||
// improve these later, use struct
|
||||
// Load config data
|
||||
overlay::coord = config.GetValue("overlay.coord", false);
|
||||
overlay::fps = config.GetValue("overlay.fps", false);
|
||||
overlay::loc_name = config.GetValue("overlay.loc_name", false);
|
||||
overlay::transparent = config.GetValue("overlay.transparent", false);
|
||||
overlay::veh_health = config.GetValue("overlay.veh_health", false);
|
||||
overlay::veh_speed = config.GetValue("overlay.veh_speed", false);
|
||||
overlay::selected_pos = config.GetValue("overlay.selected_pos", 4);
|
||||
overlay::posX = config.GetValue("overlay.posX", 0);
|
||||
overlay::posY = config.GetValue("overlay.posY", 0);
|
||||
|
||||
// Hotkeys
|
||||
hotkey::aim_skin_changer[0] = config.GetValue("hotkey.aim_skin_changer.key1", VK_RETURN);
|
||||
hotkey::aim_skin_changer[1] = config.GetValue("hotkey.aim_skin_changer.key2", VK_RETURN);
|
||||
|
||||
hotkey::quick_ss[0] = config.GetValue("hotkey.quick_screenshot.key1", VK_LCONTROL);
|
||||
hotkey::quick_ss[1] = config.GetValue("hotkey.quick_screenshot.key2", VK_KEY_S);
|
||||
|
||||
hotkey::quick_tp[0] = config.GetValue("hotkey.quick_tp.key1", VK_KEY_X);
|
||||
hotkey::quick_tp[1] = config.GetValue("hotkey.quick_tp.key2", VK_KEY_Y);
|
||||
|
||||
hotkey::menu_open[0] = config.GetValue("hotkey.menu_open.key1", VK_LCONTROL);
|
||||
hotkey::menu_open[1] = config.GetValue("hotkey.menu_open.key2", VK_KEY_M);
|
||||
|
||||
hotkey::command_window[0] = config.GetValue("hotkey.command_window.key1", VK_LMENU);
|
||||
hotkey::command_window[1] = config.GetValue("hotkey.command_window.key2", VK_KEY_C);
|
||||
};
|
||||
|
||||
Events::shutdownRwEvent += []
|
||||
{
|
||||
// save config data
|
||||
config.SetValue("overlay.coord", overlay::coord);
|
||||
config.SetValue("overlay.fps", overlay::fps);
|
||||
config.SetValue("overlay.loc_name", overlay::loc_name);
|
||||
config.SetValue("overlay.transparent", overlay::transparent);
|
||||
config.SetValue("overlay.veh_health", overlay::veh_health);
|
||||
config.SetValue("overlay.veh_speed", overlay::veh_speed);
|
||||
config.SetValue("overlay.selected_pos", overlay::selected_pos);
|
||||
config.SetValue("overlay.posX", overlay::posX);
|
||||
config.SetValue("overlay.posY", overlay::posY);
|
||||
|
||||
// Hotkeys
|
||||
config.SetValue("hotkey.aim_skin_changer.key1", hotkey::aim_skin_changer[0]);
|
||||
config.SetValue("hotkey.aim_skin_changer.key2", hotkey::aim_skin_changer[1]);
|
||||
|
||||
config.SetValue("hotkey.quick_screenshot.key1", hotkey::quick_ss[0]);
|
||||
config.SetValue("hotkey.quick_screenshot.key2", hotkey::quick_ss[1]);
|
||||
|
||||
config.SetValue("hotkey.quick_tp.key1", hotkey::quick_tp[0]);
|
||||
config.SetValue("hotkey.quick_tp.key2", hotkey::quick_tp[1]);
|
||||
|
||||
config.SetValue("hotkey.menu_open.key1", hotkey::menu_open[0]);
|
||||
config.SetValue("hotkey.menu_open.key2", hotkey::menu_open[1]);
|
||||
|
||||
config.SetValue("hotkey.command_window.key1", hotkey::command_window[0]);
|
||||
config.SetValue("hotkey.command_window.key2", hotkey::command_window[1]);
|
||||
};
|
||||
}
|
||||
|
||||
Menu::~Menu()
|
||||
{
|
||||
}
|
||||
|
||||
void Menu::ProcessOverlay()
|
||||
{
|
||||
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));
|
||||
|
||||
int corner = overlay::selected_pos - 1;
|
||||
const float offset = 10.0f;
|
||||
ImGuiIO& io = ImGui::GetIO();
|
||||
ImGuiWindowFlags window_flags = ImGuiWindowFlags_NoDecoration | ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_NoFocusOnAppearing | ImGuiWindowFlags_NoNav;
|
||||
|
||||
if (corner != -1)
|
||||
{
|
||||
window_flags |= ImGuiWindowFlags_NoMove;
|
||||
ImVec2 window_pos = ImVec2((corner & 1) ? io.DisplaySize.x - offset : offset, (corner & 2) ? io.DisplaySize.y - offset : offset);
|
||||
ImVec2 window_pos_pivot = ImVec2((corner & 1) ? 1.0f : 0.0f, (corner & 2) ? 1.0f : 0.0f);
|
||||
ImGui::SetNextWindowPos(window_pos, ImGuiCond_Always, window_pos_pivot);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (overlay::posX != NULL && overlay::posY != NULL)
|
||||
ImGui::SetNextWindowPos(ImVec2(overlay::posX, overlay::posY), ImGuiCond_Once);
|
||||
}
|
||||
|
||||
ImGui::SetNextWindowBgAlpha(overlay::transparent ? 0.0f : 0.5f);
|
||||
|
||||
if (show_menu && ImGui::Begin("Overlay", NULL, window_flags))
|
||||
{
|
||||
CPlayerPed *player = FindPlayerPed();
|
||||
|
||||
if (overlay::coord)
|
||||
{
|
||||
CVector pos = player->GetPosition();
|
||||
|
||||
std::string text = "Coord: " + std::to_string(int(pos.x)) + ", " + std::to_string(int(pos.y)) + ", "
|
||||
+ std::to_string(int(pos.z));
|
||||
|
||||
ImGui::Text(text.c_str());
|
||||
}
|
||||
|
||||
if (overlay::fps)
|
||||
ImGui::Text((std::string("Frames: ") + std::to_string(int(io.Framerate))).c_str());
|
||||
|
||||
if (overlay::loc_name)
|
||||
ImGui::Text((std::string("Location: ") + Util::GetLocationName(&player->GetPosition())).c_str());
|
||||
|
||||
if (player->m_pVehicle && player->m_pVehicle->IsDriver(player))
|
||||
{
|
||||
if (overlay::veh_health)
|
||||
ImGui::Text((std::string("Veh Health: ") + std::to_string(int(player->m_pVehicle->m_fHealth))).c_str());
|
||||
|
||||
if (overlay::veh_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());
|
||||
}
|
||||
}
|
||||
|
||||
ImVec2 pos = ImGui::GetWindowPos();
|
||||
overlay::posX = pos.x;
|
||||
overlay::posY = pos.y;
|
||||
|
||||
ImGui::End();
|
||||
}
|
||||
}
|
||||
|
||||
void Menu::ProcessShortcutsWindow()
|
||||
{
|
||||
int resX = int(screen::GetScreenWidth());
|
||||
int resY = int(screen::GetScreenHeight());
|
||||
|
||||
ImGui::SetNextWindowPos(ImVec2(0, resY - 40), ImGuiCond_Always);
|
||||
ImGui::SetNextWindowSize(ImVec2(resX, 40));
|
||||
|
||||
ImGuiWindowFlags flags = ImGuiWindowFlags_NoDecoration + ImGuiWindowFlags_AlwaysAutoResize + ImGuiWindowFlags_NoSavedSettings
|
||||
+ ImGuiWindowFlags_NoMove;
|
||||
|
||||
if (ImGui::Begin("Shortcuts window", NULL, flags))
|
||||
{
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(ImGui::GetStyle().FramePadding.x, resY / 130));
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(3, 3));
|
||||
|
||||
ImGui::SetNextItemWidth(resX);
|
||||
ImGui::SetKeyboardFocusHere(-1);
|
||||
|
||||
ImGui::InputTextWithHint("##TEXTFIELD", "Enter command", commands::input_buffer, INPUT_BUFFER_SIZE);
|
||||
|
||||
ImGui::PopStyleVar(2);
|
||||
ImGui::End();
|
||||
}
|
||||
}
|
||||
|
||||
void Menu::ProcessCommands()
|
||||
{
|
||||
std::stringstream ss(commands::input_buffer);
|
||||
|
||||
std::string command;
|
||||
ss >> command;
|
||||
|
||||
if (command == "hp")
|
||||
{
|
||||
try
|
||||
{
|
||||
std::string temp;
|
||||
ss >> temp;
|
||||
FindPlayerPed()->m_fHealth = std::stof(temp);
|
||||
}
|
||||
catch (...) {
|
||||
CHud::SetHelpMessage("Invalid value", false, false, false);
|
||||
}
|
||||
}
|
||||
|
||||
if (command == "time")
|
||||
{
|
||||
try
|
||||
{
|
||||
std::string temp;
|
||||
ss >> temp;
|
||||
CClock::ms_nGameClockHours = std::stoi(temp);
|
||||
|
||||
ss >> temp;
|
||||
CClock::ms_nGameClockMinutes = std::stoi(temp);
|
||||
}
|
||||
catch (...) {
|
||||
CHud::SetHelpMessage("Invalid value", false, false, false);
|
||||
}
|
||||
}
|
||||
|
||||
if (command == "tp")
|
||||
{
|
||||
try {
|
||||
CVector pos;
|
||||
std::string temp;
|
||||
|
||||
ss >> temp;
|
||||
pos.x = std::stof(temp);
|
||||
|
||||
ss >> temp;
|
||||
pos.y = std::stof(temp);
|
||||
|
||||
ss >> temp;
|
||||
pos.z = std::stof(temp);
|
||||
|
||||
Teleport::TeleportPlayer(false, &pos, 0);
|
||||
}
|
||||
catch (...) {
|
||||
CHud::SetHelpMessage("Invalid location", false, false, false);
|
||||
}
|
||||
}
|
||||
|
||||
if (command == "wep")
|
||||
{
|
||||
std::string wep_name;
|
||||
ss >> wep_name;
|
||||
|
||||
if (wep_name == "jetpack")
|
||||
{
|
||||
Weapon::GiveWeaponToPlayer(std::string("-1"));
|
||||
CHud::SetHelpMessage("Weapon given", false, false, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
eWeaponType weapon = CWeaponInfo::FindWeaponType((char*)wep_name.c_str());
|
||||
CWeaponInfo* pweaponinfo = CWeaponInfo::GetWeaponInfo(weapon, 1);
|
||||
|
||||
if (wep_name != "" && pweaponinfo->m_nModelId1 != -1)
|
||||
{
|
||||
Weapon::GiveWeaponToPlayer(std::to_string(weapon));
|
||||
CHud::SetHelpMessage("Weapon given", false, false, false);
|
||||
}
|
||||
else
|
||||
CHud::SetHelpMessage("Invalid command", false, false, false);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void Menu::Main()
|
||||
{
|
||||
if (ImGui::BeginTabBar("Menu", ImGuiTabBarFlags_NoTooltip + ImGuiTabBarFlags_FittingPolicyScroll))
|
||||
{
|
||||
if (ImGui::BeginTabItem("Overlay"))
|
||||
{
|
||||
ImGui::Spacing();
|
||||
ImGui::Spacing();
|
||||
ImGui::SameLine();
|
||||
Ui::ListBox("Overlay", overlay::pos_names, overlay::selected_pos);
|
||||
ImGui::Spacing();
|
||||
|
||||
ImGui::Columns(2, NULL, false);
|
||||
ImGui::Checkbox("No background", &overlay::transparent);
|
||||
ImGui::Checkbox("Show coordinates", &overlay::coord);
|
||||
ImGui::Checkbox("Show FPS", &overlay::fps);
|
||||
ImGui::NextColumn();
|
||||
|
||||
ImGui::Checkbox("Show location", &overlay::loc_name);
|
||||
ImGui::Checkbox("Show veh health", &overlay::veh_health);
|
||||
ImGui::Checkbox("Show veh speed", &overlay::veh_speed);
|
||||
ImGui::Columns(1);
|
||||
|
||||
ImGui::EndTabItem();
|
||||
}
|
||||
if (ImGui::BeginTabItem("Hotkeys"))
|
||||
{
|
||||
ImGui::Spacing();
|
||||
ImGui::BeginChild("Hotkeys");
|
||||
Ui::HotKey("Open/ close cheat menu", hotkey::menu_open);
|
||||
Ui::HotKey("Open/ close command window", hotkey::command_window);
|
||||
|
||||
ImGui::Dummy(ImVec2(0,10));
|
||||
|
||||
Ui::HotKey("Activate aim skin changer", hotkey::aim_skin_changer);
|
||||
Ui::HotKey("Take quick screenshot", hotkey::quick_ss);
|
||||
Ui::HotKey("Toggle quick teleport", hotkey::quick_tp);
|
||||
|
||||
ImGui::Dummy(ImVec2(0, 10));
|
||||
|
||||
ImGui::EndChild();
|
||||
ImGui::EndTabItem();
|
||||
}
|
||||
if (ImGui::BeginTabItem("Commands"))
|
||||
{
|
||||
if (ImGui::BeginChild("CommandsChild"))
|
||||
{
|
||||
ImGui::TextWrapped(std::string("Open or close command window using " + Ui::GetHotKeyNameString(hotkey::command_window)).c_str());
|
||||
ImGui::Spacing();
|
||||
if (ImGui::CollapsingHeader("Set health"))
|
||||
{
|
||||
ImGui::Spacing();
|
||||
ImGui::TextWrapped("Set player health.\nExample: hp (health).");
|
||||
ImGui::Spacing();
|
||||
ImGui::Separator();
|
||||
}
|
||||
if (ImGui::CollapsingHeader("Set time"))
|
||||
{
|
||||
ImGui::Spacing();
|
||||
ImGui::TextWrapped("Set current game time.\nExample: time (hour) (minute).\n");
|
||||
ImGui::TextWrapped("Writing something like 'time 12' would be interpreted as 'time 12 12'");
|
||||
ImGui::Spacing();
|
||||
ImGui::Separator();
|
||||
}
|
||||
if (ImGui::CollapsingHeader("Quick vehicle spawner"))
|
||||
{
|
||||
ImGui::Spacing();
|
||||
ImGui::TextWrapped("Spawn vehicles by typing their model names.\nExample: veh (veh_name)");
|
||||
ImGui::Spacing();
|
||||
ImGui::Separator();
|
||||
}
|
||||
if (ImGui::CollapsingHeader("Quick weapon spawner"))
|
||||
{
|
||||
ImGui::Spacing();
|
||||
ImGui::TextWrapped("Spawn weapons by typing their model names.\nExample: wep (wep_name)");
|
||||
ImGui::Spacing();
|
||||
ImGui::Separator();
|
||||
}
|
||||
|
||||
ImGui::EndChild();
|
||||
}
|
||||
ImGui::EndTabItem();
|
||||
}
|
||||
if (ImGui::BeginTabItem("About"))
|
||||
{
|
||||
ImGui::Spacing();
|
||||
|
||||
if (ImGui::Button("Discord server", ImVec2(Ui::GetSize(2))))
|
||||
ShellExecute(NULL, "open", "https://discord.gg/ZzW7kmf", NULL, NULL, SW_SHOWNORMAL);
|
||||
|
||||
ImGui::SameLine();
|
||||
|
||||
if (ImGui::Button("GitHub repo", ImVec2(Ui::GetSize(2))))
|
||||
ShellExecute(NULL, "open", "https://github.com/user-grinch/Cheat-Menu", NULL, NULL, SW_SHOWNORMAL);
|
||||
|
||||
ImGui::Spacing();
|
||||
|
||||
if (ImGui::BeginChild("AboutChild"))
|
||||
{
|
||||
ImGui::Columns(2, NULL, false);
|
||||
ImGui::Text("Author: Grinch_");
|
||||
|
||||
ImGui::Text((std::string("Version: ") + MENU_VERSION).c_str());
|
||||
|
||||
ImGui::NextColumn();
|
||||
ImGui::Text(std::string("Imgui: " + std::string(ImGui::GetVersion())).c_str());
|
||||
ImGui::Text((std::string("Build: ") + BUILD_NUMBER).c_str());
|
||||
|
||||
ImGui::Columns(1);
|
||||
|
||||
ImGui::Dummy(ImVec2(0, 10));
|
||||
ImGui::TextWrapped("Special thanks to,");
|
||||
ImGui::Columns(2, NULL, false);
|
||||
|
||||
ImGui::TextWrapped("Dowglas_");
|
||||
ImGui::TextWrapped("Israel");
|
||||
|
||||
ImGui::NextColumn();
|
||||
ImGui::TextWrapped("Junior-Djjr");
|
||||
|
||||
ImGui::Columns(1);
|
||||
|
||||
ImGui::Dummy(ImVec2(0, 10));
|
||||
ImGui::TextWrapped("Copyright GPLv3 2019-2020 Grinch_");
|
||||
|
||||
ImGui::EndChild();
|
||||
}
|
||||
|
||||
ImGui::EndTabItem();
|
||||
}
|
||||
ImGui::EndTabBar();
|
||||
}
|
||||
}
|
42
CheatMenu/Menu.h
Normal file
@ -0,0 +1,42 @@
|
||||
#pragma once
|
||||
|
||||
class Menu
|
||||
{
|
||||
private:
|
||||
struct overlay
|
||||
{
|
||||
static bool coord;
|
||||
static bool fps;
|
||||
static bool loc_name;
|
||||
static bool transparent;
|
||||
static bool veh_health;
|
||||
static bool veh_speed;
|
||||
static std::vector<std::string> pos_names;
|
||||
static int selected_pos;
|
||||
static float posX;
|
||||
static float posY;
|
||||
};
|
||||
public:
|
||||
struct hotkey
|
||||
{
|
||||
static int command_window[2];
|
||||
static int menu_open[2];
|
||||
static int aim_skin_changer[2];
|
||||
static int quick_ss[2];
|
||||
static int quick_tp[2];
|
||||
};
|
||||
struct commands
|
||||
{
|
||||
static bool show_menu;
|
||||
static char input_buffer[INPUT_BUFFER_SIZE];
|
||||
};
|
||||
|
||||
Menu();
|
||||
~Menu();
|
||||
static void Main();
|
||||
static void ProcessOverlay();
|
||||
static void ProcessShortcutsWindow();
|
||||
static void ProcessCommands();
|
||||
|
||||
};
|
||||
|
75
CheatMenu/NeonAPI.cpp
Normal file
@ -0,0 +1,75 @@
|
||||
#include "pch.h"
|
||||
#include "NeonAPI.h"
|
||||
|
||||
bool NeonAPI::api_installed = false;
|
||||
HMODULE NeonAPI::hapi = false;
|
||||
|
||||
extern "C"
|
||||
{
|
||||
static int(__cdecl *_installneon)(CVehicle*, uchar, uchar) = nullptr;
|
||||
static int(__cdecl *_setred)(CVehicle*, uchar) = nullptr;
|
||||
static int(__cdecl *_setgreen)(CVehicle*, uchar) = nullptr;
|
||||
static int(__cdecl *_setblue)(CVehicle*, uchar) = nullptr;
|
||||
static bool(__cdecl *_isneoninstalled)(CVehicle*) = nullptr;
|
||||
static bool(__cdecl *_removeneon)(CVehicle*) = nullptr;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
static inline void InitFun(T &fun, HMODULE lib, const char *name)
|
||||
{
|
||||
fun = (T)GetProcAddress(lib, name);
|
||||
}
|
||||
|
||||
NeonAPI::NeonAPI()
|
||||
{
|
||||
Events::initGameEvent += [this]
|
||||
{
|
||||
hapi = LoadLibraryW(L"neon_api.asi");
|
||||
if (hapi)
|
||||
{
|
||||
api_installed = true;
|
||||
|
||||
InitFun(_installneon,hapi,"InstallNeon");
|
||||
InitFun(_setred, hapi, "SetRed");
|
||||
InitFun(_setgreen, hapi, "SetGreen");
|
||||
InitFun(_setblue, hapi, "SetBlue");
|
||||
InitFun(_isneoninstalled, hapi, "IsNeonInstalled");
|
||||
InitFun(_removeneon, hapi, "RemoveNeon");
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
NeonAPI::~NeonAPI()
|
||||
{
|
||||
}
|
||||
|
||||
bool NeonAPI::IsNeonInstalled(CVehicle *veh)
|
||||
{
|
||||
return api_installed && _isneoninstalled(veh);
|
||||
}
|
||||
|
||||
bool NeonAPI::InstallNeon(CVehicle *veh, int red, int green, int blue)
|
||||
{
|
||||
if (api_installed)
|
||||
{
|
||||
_installneon(veh, 0, 0);
|
||||
_setred(veh, red);
|
||||
_setgreen(veh, green);
|
||||
_setblue(veh, blue);
|
||||
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool NeonAPI::RemoveNeon(CVehicle *veh)
|
||||
{
|
||||
if (api_installed)
|
||||
{
|
||||
_removeneon(veh);
|
||||
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
15
CheatMenu/NeonAPI.h
Normal file
@ -0,0 +1,15 @@
|
||||
#pragma once
|
||||
|
||||
class NeonAPI
|
||||
{
|
||||
private:
|
||||
static bool api_installed;
|
||||
static HMODULE hapi;
|
||||
public:
|
||||
NeonAPI();
|
||||
~NeonAPI();
|
||||
static bool InstallNeon(CVehicle *veh, int red, int green, int blue);
|
||||
static bool IsNeonInstalled(CVehicle *veh);
|
||||
static bool RemoveNeon(CVehicle *veh);
|
||||
};
|
||||
|
191
CheatMenu/Paint.cpp
Normal file
@ -0,0 +1,191 @@
|
||||
#include "pch.h"
|
||||
#include "Paint.h"
|
||||
#include "NodeName.h"
|
||||
#include "external/moon/texture_manager.h"
|
||||
|
||||
std::vector<std::string> Paint::veh_nodes::names_vec{ "Default" };
|
||||
std::string Paint::veh_nodes::selected = "Default";
|
||||
|
||||
std::map<std::string, std::shared_ptr<RwTexture>> Paint::textures;
|
||||
|
||||
Paint::Paint()
|
||||
{
|
||||
|
||||
Events::initGameEvent += []
|
||||
{
|
||||
std::string dir_path = std::string(".\\CheatMenu\\vehicles\\paintjobs\\").c_str();
|
||||
|
||||
for (auto &p : fs::recursive_directory_iterator(dir_path))
|
||||
{
|
||||
if (p.path().extension() == ".png")
|
||||
{
|
||||
std::string file_name = p.path().stem().string();
|
||||
textures[file_name]= std::make_shared<RwTexture>(*(texture_manager::loadTextureFromPngFile(p.path())));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Events::vehicleRenderEvent.before += [](CVehicle* veh) {
|
||||
if (veh)
|
||||
VehicleRenderer::get()->processRender(veh);
|
||||
};
|
||||
|
||||
Events::vehicleResetAfterRender += [](CVehicle* veh) {
|
||||
if (veh)
|
||||
VehicleRenderer::get()->postRender(veh);
|
||||
};
|
||||
}
|
||||
|
||||
Paint::~Paint()
|
||||
{
|
||||
}
|
||||
|
||||
void Paint::NodeWrapperRecursive(RwFrame *frame, CVehicle* pVeh, std::function<void(RwFrame*)> func)
|
||||
{
|
||||
if (frame)
|
||||
{
|
||||
func(frame);
|
||||
|
||||
if (RwFrame * newFrame = frame->child)
|
||||
NodeWrapperRecursive(newFrame, pVeh, func);
|
||||
if (RwFrame * newFrame = frame->next)
|
||||
NodeWrapperRecursive(newFrame, pVeh, func);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
void Paint::UpdateNodeListRecursive(CVehicle* pVeh)
|
||||
{
|
||||
RwFrame *frame = (RwFrame *)pVeh->m_pRwClump->object.parent;
|
||||
|
||||
NodeWrapperRecursive(frame, pVeh, [](RwFrame *frame)
|
||||
{
|
||||
const std::string name = GetFrameNodeName(frame);
|
||||
|
||||
if (!(std::find(veh_nodes::names_vec.begin(), veh_nodes::names_vec.end(), name) != veh_nodes::names_vec.end()))
|
||||
veh_nodes::names_vec.push_back(name);
|
||||
});
|
||||
}
|
||||
|
||||
void Paint::SetNodeColor(CVehicle* pVeh, std::string node_name, CRGBA color, bool filter_mat)
|
||||
{
|
||||
RwFrame *frame = (RwFrame *)pVeh->m_pRwClump->object.parent;
|
||||
|
||||
NodeWrapperRecursive(frame, pVeh, [&](RwFrame *frame)
|
||||
{
|
||||
const std::string name = GetFrameNodeName(frame);
|
||||
|
||||
struct ST
|
||||
{
|
||||
CRGBA _color;
|
||||
bool _filter;
|
||||
} st;
|
||||
|
||||
st._color = color;
|
||||
st._filter = filter_mat;
|
||||
|
||||
if (node_name == "Default" || node_name == name)
|
||||
{
|
||||
RwFrameForAllObjects(frame, [](RwObject* object, void* data) -> RwObject* {
|
||||
if (object->type == rpATOMIC)
|
||||
{
|
||||
RpAtomic *atomic = reinterpret_cast<RpAtomic*>(object);
|
||||
|
||||
ST* st = reinterpret_cast<ST*>(data);
|
||||
CRGBA* color = &st->_color;
|
||||
bool filter_mat = st->_filter;
|
||||
|
||||
for (int i = 0; i < atomic->geometry->matList.numMaterials; ++i)
|
||||
VehicleRenderer::get()->setMaterialColor(FindPlayerPed()->m_pVehicle, atomic->geometry->matList.materials[i], atomic->geometry, { color->r,color->g,color->b, 255 }, filter_mat);
|
||||
}
|
||||
return object;
|
||||
}, &st);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
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)
|
||||
{
|
||||
const std::string name = GetFrameNodeName(frame);
|
||||
|
||||
struct ST
|
||||
{
|
||||
std::string _texturename;
|
||||
std::map<std::string, std::shared_ptr<RwTexture>> _textures;
|
||||
bool _filter;
|
||||
} st;
|
||||
|
||||
st._textures = textures;
|
||||
st._texturename = texturename;
|
||||
st._filter = filter_mat;
|
||||
|
||||
if (node_name == "Default" || node_name == name)
|
||||
{
|
||||
RwFrameForAllObjects(frame, [](RwObject* object, void* data) -> RwObject* {
|
||||
|
||||
if (object->type == rpATOMIC)
|
||||
{
|
||||
RpAtomic *atomic = reinterpret_cast<RpAtomic*>(object);
|
||||
|
||||
ST* st = reinterpret_cast<ST*>(data);
|
||||
for (int i = 0; i < atomic->geometry->matList.numMaterials; ++i)
|
||||
VehicleRenderer::get()->setMaterialTexture(FindPlayerPed()->m_pVehicle, atomic->geometry->matList.materials[i], st->_textures[st->_texturename], st->_filter);
|
||||
}
|
||||
return object;
|
||||
}, &st);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void Paint::ResetNodeColor(CVehicle *pVeh, std::string node_name)
|
||||
{
|
||||
RwFrame *frame = (RwFrame *)pVeh->m_pRwClump->object.parent;
|
||||
|
||||
NodeWrapperRecursive(frame, pVeh, [&](RwFrame *frame)
|
||||
{
|
||||
const std::string name = GetFrameNodeName(frame);
|
||||
|
||||
if (node_name == "Default" || node_name == name)
|
||||
{
|
||||
RwFrameForAllObjects(frame, [](RwObject* object, void* data) -> RwObject* {
|
||||
if (object->type == rpATOMIC)
|
||||
{
|
||||
RpAtomic *atomic = reinterpret_cast<RpAtomic*>(object);
|
||||
|
||||
for (int i = 0; i < atomic->geometry->matList.numMaterials; ++i)
|
||||
VehicleRenderer::get()->resetMaterialColor(FindPlayerPed()->m_pVehicle, atomic->geometry->matList.materials[i]);
|
||||
}
|
||||
return object;
|
||||
}, nullptr);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void Paint::ResetNodeTexture(CVehicle *pVeh, std::string node_name)
|
||||
{
|
||||
RwFrame *frame = (RwFrame *)pVeh->m_pRwClump->object.parent;
|
||||
|
||||
NodeWrapperRecursive(frame, pVeh, [&](RwFrame *frame)
|
||||
{
|
||||
const std::string name = GetFrameNodeName(frame);
|
||||
|
||||
if (node_name == "Default" || node_name == name)
|
||||
{
|
||||
RwFrameForAllObjects(frame, [](RwObject* object, void* data) -> RwObject* {
|
||||
|
||||
if (object->type == rpATOMIC)
|
||||
{
|
||||
RpAtomic *atomic = reinterpret_cast<RpAtomic*>(object);
|
||||
|
||||
for (int i = 0; i < atomic->geometry->matList.numMaterials; ++i)
|
||||
VehicleRenderer::get()->resetMaterialTexture(FindPlayerPed()->m_pVehicle, atomic->geometry->matList.materials[i]);
|
||||
}
|
||||
return object;
|
||||
}, nullptr);
|
||||
}
|
||||
});
|
||||
}
|
26
CheatMenu/Paint.h
Normal file
@ -0,0 +1,26 @@
|
||||
#pragma once
|
||||
#include "external/moon/vehicle_renderer.h"
|
||||
|
||||
class Paint : VehicleRenderer
|
||||
{
|
||||
public:
|
||||
Paint();
|
||||
~Paint();
|
||||
|
||||
struct veh_nodes
|
||||
{
|
||||
static std::vector<std::string> names_vec;
|
||||
static std::string selected;
|
||||
};
|
||||
static std::map<std::string, std::shared_ptr<RwTexture>> textures;
|
||||
|
||||
protected:
|
||||
|
||||
static void UpdateNodeListRecursive(CVehicle* pVeh);
|
||||
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);
|
||||
};
|
||||
|
280
CheatMenu/Ped.cpp
Normal file
@ -0,0 +1,280 @@
|
||||
#include "pch.h"
|
||||
#include "Ped.h"
|
||||
|
||||
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;
|
||||
|
||||
CJson Ped::ped_json = CJson("ped");
|
||||
CJson Ped::pedspecial_json = CJson("ped special");
|
||||
|
||||
std::vector<std::string> Ped::gang_names = { "Ballas", "Grove street families", "Los santos vagos", "San fierro rifa",
|
||||
"Da nang boys", "Mafia", "Mountain cloud triad", "Varrio los aztecas", "Gang9", "Gang10" };
|
||||
|
||||
bool Ped::exgangwars_installed = false;
|
||||
|
||||
std::vector<CPed*> Ped::spawn_ped::list;
|
||||
int Ped::spawn_ped::accuracy = 50;
|
||||
int Ped::spawn_ped::health = 100;
|
||||
int Ped::spawn_ped::selected_ped_type = 0;
|
||||
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",
|
||||
"San Fierro Rifa","Da Nang Boys","Mafia","Mountain Cloud Triads","Varrio Los Aztecas",
|
||||
"Gang 9","Medic","Dealer","Criminal","Fireman","Prostitute"};
|
||||
|
||||
|
||||
Ped::Ped()
|
||||
{
|
||||
Events::initGameEvent += []
|
||||
{
|
||||
std::string dir_path = (std::string(".\\CheatMenu\\peds\\")).c_str();
|
||||
Util::LoadTexturesInDirRecursive(dir_path.c_str(), ".jpg", search_categories, peds_vec);
|
||||
|
||||
if (LoadLibraryW(L"ExGangWars.asi"))
|
||||
exgangwars_installed = true;
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
Ped::~Ped()
|
||||
{
|
||||
for (CPed* ped : spawn_ped::list)
|
||||
{
|
||||
CWorld::Remove(ped);
|
||||
ped->Remove();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Ped::SpawnPed(std::string& model)
|
||||
{
|
||||
if (spawn_ped::list.size() == SPAWN_PED_LIMIT)
|
||||
{
|
||||
CHud::SetHelpMessage("Max limit reached", false, false, false);
|
||||
return;
|
||||
}
|
||||
|
||||
if (Ped::ped_json.data.contains(model))
|
||||
{
|
||||
CPlayerPed *player = FindPlayerPed();
|
||||
CVector pos = player->GetPosition();
|
||||
pos.y += 1;
|
||||
|
||||
CPed *ped;
|
||||
int hplayer;
|
||||
|
||||
if (Ped::pedspecial_json.data.contains(model))
|
||||
{
|
||||
std::string name;
|
||||
if (Ped::pedspecial_json.data.contains(model))
|
||||
name = Ped::pedspecial_json.data[model].get<std::string>().c_str();
|
||||
else
|
||||
name = model;
|
||||
|
||||
CStreaming::RequestSpecialChar(1, name.c_str(), PRIORITY_REQUEST);
|
||||
CStreaming::LoadAllRequestedModels(true);
|
||||
|
||||
Command <Commands::CREATE_CHAR>(spawn_ped::selected_ped_type + 4, 291, pos.x, pos.y, pos.z + 1, &hplayer);
|
||||
CStreaming::SetSpecialCharIsDeletable(291);
|
||||
}
|
||||
else
|
||||
{
|
||||
int imodel = std::stoi(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);
|
||||
CStreaming::SetModelIsDeletable(imodel);
|
||||
}
|
||||
|
||||
ped = CPools::GetPed(hplayer);
|
||||
|
||||
if (spawn_ped::dont_move)
|
||||
spawn_ped::list.push_back(ped);
|
||||
else
|
||||
{
|
||||
Command<Commands::MARK_CHAR_AS_NO_LONGER_NEEDED>(hplayer);
|
||||
}
|
||||
ped->m_nPedFlags.bPedIsBleeding = spawn_ped::ped_bleed;
|
||||
ped->m_nWeaponAccuracy = spawn_ped::accuracy;
|
||||
ped->m_fHealth = spawn_ped::health;
|
||||
|
||||
if (spawn_ped::weapon_id != 0)
|
||||
{
|
||||
int model = 0;
|
||||
Command<Commands::GET_WEAPONTYPE_MODEL>(spawn_ped::weapon_id, &model);
|
||||
CStreaming::RequestModel(model, PRIORITY_REQUEST);
|
||||
CStreaming::LoadAllRequestedModels(false);
|
||||
Command<Commands::GIVE_WEAPON_TO_CHAR>(hplayer, spawn_ped::weapon_id, 999);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Ped::Main()
|
||||
{
|
||||
if (ImGui::BeginTabBar("Ped", ImGuiTabBarFlags_NoTooltip + ImGuiTabBarFlags_FittingPolicyScroll))
|
||||
{
|
||||
if (ImGui::BeginTabItem("Checkboxes"))
|
||||
{
|
||||
ImGui::Spacing();
|
||||
ImGui::BeginChild("CheckboxesChild");
|
||||
ImGui::Columns(2, 0, false);
|
||||
|
||||
Ui::CheckboxAddress("Elvis everywhere", 0x969157);
|
||||
Ui::CheckboxAddress("Everyone is armed", 0x969140);
|
||||
Ui::CheckboxAddress("Gangs control streets", 0x96915B);
|
||||
Ui::CheckboxAddress("Gangs everywhere", 0x96915A);
|
||||
Ui::CheckboxWithHint("Gang wars", &CGangWars::bGangWarsActive);
|
||||
|
||||
ImGui::NextColumn();
|
||||
|
||||
Ui::CheckboxAddress("Peds mayhem", 0x96913E);
|
||||
Ui::CheckboxAddress("Peds attack with rockets", 0x969158);
|
||||
Ui::CheckboxAddress("Peds riot", 0x969175);
|
||||
Ui::CheckboxAddress("Slut magnet", 0x96915D);
|
||||
|
||||
ImGui::Columns(1);
|
||||
ImGui::EndChild();
|
||||
|
||||
ImGui::EndTabItem();
|
||||
}
|
||||
if (ImGui::BeginTabItem("Menus"))
|
||||
{
|
||||
ImGui::Spacing();
|
||||
ImGui::BeginChild("MenusChild");
|
||||
|
||||
if (ImGui::CollapsingHeader("Gang wars"))
|
||||
{
|
||||
if (ImGui::Button("Start gang war", ImVec2(Ui::GetSize(2))))
|
||||
{
|
||||
if (Util::GetLargestGangInZone() == 1)
|
||||
CGangWars::StartDefensiveGangWar();
|
||||
else
|
||||
CGangWars::StartOffensiveGangWar();
|
||||
|
||||
CGangWars::bGangWarsActive = true;
|
||||
}
|
||||
ImGui::SameLine();
|
||||
if (ImGui::Button("End gang war", ImVec2(Ui::GetSize(2))))
|
||||
CGangWars::EndGangWar(true);
|
||||
|
||||
ImGui::Dummy(ImVec2(0, 20));
|
||||
ImGui::TextWrapped("Gang zone density:");
|
||||
ImGui::Spacing();
|
||||
|
||||
ImGui::PushItemWidth(ImGui::GetWindowContentRegionWidth() / 2);
|
||||
for (int i = 0; i != 10; ++i)
|
||||
{
|
||||
CVector pos = FindPlayerPed()->GetPosition();
|
||||
CZone *zone = &CZone();
|
||||
|
||||
CZoneExtraInfo *zone_info = CTheZones::GetZoneInfo(&pos, &zone);
|
||||
int density = zone_info->m_nGangDensity[i];
|
||||
|
||||
if (ImGui::SliderInt(Ped::gang_names[i].c_str(), &density, 0, 127))
|
||||
{
|
||||
zone_info->m_nGangDensity[i] = static_cast<char>(density);
|
||||
Command<Commands::CLEAR_SPECIFIC_ZONES_TO_TRIGGER_GANG_WAR>();
|
||||
CGangWars::bGangWarsActive = true;
|
||||
}
|
||||
}
|
||||
ImGui::PopItemWidth();
|
||||
ImGui::Spacing();
|
||||
|
||||
if (!exgangwars_installed)
|
||||
{
|
||||
ImGui::TextWrapped("You'll need ExGangWars plugin to display some turf colors");
|
||||
ImGui::Spacing();
|
||||
if (ImGui::Button("Download ExGangWars", Ui::GetSize(1)))
|
||||
ShellExecute(NULL, "open", "https://gtaforums.com/topic/682194-extended-gang-wars/", NULL, NULL, SW_SHOWNORMAL);
|
||||
}
|
||||
|
||||
ImGui::Spacing();
|
||||
ImGui::Separator();
|
||||
}
|
||||
|
||||
Ui::EditAddress<float>("Pedestrian density multiplier", 0x8D2530, 0, 1, 10);
|
||||
|
||||
if (ImGui::CollapsingHeader("Recruit anyone"))
|
||||
{
|
||||
Ui::RadioButtonAddress("Select weapon", std::vector<Ui::NamedMemory>{ {"9mm", 0x96917C}, { "AK47", 0x96917D }, { "Rockets", 0x96917E }});
|
||||
ImGui::Spacing();
|
||||
ImGui::Separator();
|
||||
}
|
||||
|
||||
ImGui::EndChild();
|
||||
ImGui::EndTabItem();
|
||||
}
|
||||
if (ImGui::BeginTabItem("Spawn"))
|
||||
{
|
||||
ImGui::Spacing();
|
||||
if (ImGui::Button("Remove frozen peds", Ui::GetSize(1)))
|
||||
{
|
||||
for (CPed* ped : spawn_ped::list)
|
||||
{
|
||||
CWorld::Remove(ped);
|
||||
ped->Remove();
|
||||
}
|
||||
spawn_ped::list.clear();
|
||||
}
|
||||
ImGui::Spacing();
|
||||
if (ImGui::BeginTabBar("SpawnPedBar"))
|
||||
{
|
||||
ImGui::Spacing();
|
||||
|
||||
if (ImGui::BeginTabItem("Spawner"))
|
||||
{
|
||||
ImGui::Spacing();
|
||||
|
||||
Ui::DrawImages(peds_vec, ImVec2(65, 110), search_categories, selected_item, filter, SpawnPed, nullptr,
|
||||
[](std::string str) {return ped_json.data[str].get<std::string>(); });
|
||||
ImGui::EndTabItem();
|
||||
}
|
||||
if (ImGui::BeginTabItem("Config"))
|
||||
{
|
||||
ImGui::Spacing();
|
||||
ImGui::BeginChild("PedCOnfig");
|
||||
ImGui::Columns(2, 0, false);
|
||||
Ui::CheckboxWithHint("Don't move", &spawn_ped::dont_move);
|
||||
ImGui::NextColumn();
|
||||
Ui::CheckboxWithHint("Ped bleed", &spawn_ped::ped_bleed);
|
||||
ImGui::Columns(1);
|
||||
|
||||
ImGui::Spacing();
|
||||
ImGui::SliderInt("Accuracy", &spawn_ped::accuracy, 0.0, 100.0);
|
||||
if (ImGui::InputInt("Health", &spawn_ped::health))
|
||||
{
|
||||
if (spawn_ped::health > 1000)
|
||||
spawn_ped::health = 1000;
|
||||
|
||||
if (spawn_ped::health < 0)
|
||||
spawn_ped::health = 0;
|
||||
}
|
||||
Ui::ListBox("Ped type", spawn_ped::ped_type, spawn_ped::selected_ped_type);
|
||||
|
||||
ImGui::Spacing();
|
||||
ImGui::Text((std::string("Selected weapon: ") + Weapon::weapon_json.data[std::to_string(spawn_ped::weapon_id)].get<std::string>()).c_str());
|
||||
ImGui::Spacing();
|
||||
Ui::DrawImages(Weapon::weapon_vec, ImVec2(65, 65), Weapon::search_categories, Weapon::selected_item, Weapon::filter,
|
||||
[](std::string str) { spawn_ped::weapon_id = std::stoi(str); },
|
||||
nullptr,
|
||||
[](std::string str) {return Weapon::weapon_json.data[str].get<std::string>(); },
|
||||
[](std::string str) {return str != "-1"; /*Jetpack*/ }
|
||||
);
|
||||
|
||||
ImGui::Spacing();
|
||||
ImGui::EndChild();
|
||||
ImGui::EndTabItem();
|
||||
}
|
||||
ImGui::EndTabBar();
|
||||
}
|
||||
ImGui::EndTabItem();
|
||||
}
|
||||
ImGui::EndTabBar();
|
||||
}
|
||||
}
|
||||
|
39
CheatMenu/Ped.h
Normal file
@ -0,0 +1,39 @@
|
||||
#pragma once
|
||||
#include "Player.h"
|
||||
#include "Weapon.h"
|
||||
|
||||
class Ped
|
||||
{
|
||||
private:
|
||||
static ImGuiTextFilter filter;
|
||||
static std::string selected_item;
|
||||
static std::vector<std::string> search_categories;
|
||||
static std::vector<std::unique_ptr<TextureStructure>> peds_vec;
|
||||
|
||||
static CJson ped_json;
|
||||
static CJson pedspecial_json;
|
||||
|
||||
static std::vector<std::string> gang_names;
|
||||
static bool exgangwars_installed;
|
||||
|
||||
|
||||
struct spawn_ped {
|
||||
static std::vector<CPed*> list;
|
||||
static int accuracy;
|
||||
static int health;
|
||||
static bool dont_move;
|
||||
static bool ped_bleed;
|
||||
static std::vector<std::string> ped_type;
|
||||
static int selected_ped_type;
|
||||
static int weapon_id;
|
||||
};
|
||||
|
||||
friend class Player;
|
||||
friend class Weapon;
|
||||
public:
|
||||
Ped();
|
||||
~Ped();
|
||||
static void Main();
|
||||
static void SpawnPed(std::string& model);
|
||||
};
|
||||
|
432
CheatMenu/Player.cpp
Normal file
@ -0,0 +1,432 @@
|
||||
#include "pch.h"
|
||||
#include "Player.h"
|
||||
#include "Ped.h"
|
||||
#include "CCheat.h"
|
||||
#include "Menu.h"
|
||||
|
||||
bool Player::keep_position::state = false;
|
||||
CVector Player::keep_position::pos = CVector();
|
||||
bool Player::god_mode = false;
|
||||
int Player::body = 0;
|
||||
bool Player::aim_skin_changer = false;
|
||||
|
||||
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";
|
||||
|
||||
std::string Player::custom_skins::dir = paths::GetGameDirPathA() + std::string("\\modloader\\Custom Skins\\");
|
||||
std::vector<std::string> Player::custom_skins::store_vec;
|
||||
ImGuiTextFilter Player::custom_skins::filter = "";
|
||||
|
||||
bool Player::modloader_installed = false;
|
||||
|
||||
Player::Player()
|
||||
{
|
||||
Events::initGameEvent += []
|
||||
{
|
||||
std::string dir_path = (std::string(".\\CheatMenu\\clothes\\")).c_str();
|
||||
aim_skin_changer = config.GetValue("aim_skin_changer", false);
|
||||
Util::LoadTexturesInDirRecursive(dir_path.c_str(), ".jpg", search_categories, clothes_vec);
|
||||
|
||||
// Custom skins setup
|
||||
if (LoadLibraryW(L"modloader.asi"))
|
||||
{
|
||||
if (std::experimental::filesystem::is_directory(custom_skins::dir))
|
||||
{
|
||||
for (auto &p : std::experimental::filesystem::recursive_directory_iterator(custom_skins::dir))
|
||||
{
|
||||
if (p.path().extension() == ".dff")
|
||||
{
|
||||
std::string file_name = p.path().stem().string();
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
else std::experimental::filesystem::create_directory(custom_skins::dir);
|
||||
|
||||
modloader_installed = true;
|
||||
}
|
||||
};
|
||||
|
||||
Events::shutdownRwEvent += []
|
||||
{
|
||||
config.SetValue("aim_skin_changer", aim_skin_changer);
|
||||
};
|
||||
|
||||
Events::processScriptsEvent += []
|
||||
{
|
||||
uint timer = CTimer::m_snTimeInMilliseconds;
|
||||
static CPlayerPed* player = FindPlayerPed();
|
||||
|
||||
if (keep_position::state)
|
||||
{
|
||||
if (!player->IsAlive())
|
||||
{
|
||||
keep_position::pos = player->GetPosition();
|
||||
}
|
||||
else
|
||||
{
|
||||
CVector cur_pos = player->GetPosition();
|
||||
|
||||
if (keep_position::pos.x != 0 && keep_position::pos.x != cur_pos.x
|
||||
&& keep_position::pos.y != 0 && keep_position::pos.y != cur_pos.y)
|
||||
{
|
||||
player->Teleport(keep_position::pos, false);
|
||||
keep_position::pos = CVector(0, 0, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (god_mode)
|
||||
{
|
||||
patch::Set<bool>(0x96916D, 1, false);
|
||||
player->m_nPhysicalFlags.bBulletProof = 1;
|
||||
player->m_nPhysicalFlags.bCollisionProof = 1;
|
||||
player->m_nPhysicalFlags.bExplosionProof = 1;
|
||||
player->m_nPhysicalFlags.bFireProof = 1;
|
||||
player->m_nPhysicalFlags.bMeeleProof = 1;
|
||||
}
|
||||
|
||||
if (aim_skin_changer && Ui::HotKeyPressed(Menu::hotkey::aim_skin_changer))
|
||||
{
|
||||
CPed *target_ped = player->m_pPlayerTargettedPed;
|
||||
if (target_ped)
|
||||
{
|
||||
player->SetModelIndex(target_ped->m_nModelIndex);
|
||||
Util::ClearCharTasksVehCheck(player);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Player::~Player()
|
||||
{
|
||||
}
|
||||
|
||||
void Player::ChangePlayerCloth(std::string &name)
|
||||
{
|
||||
std::stringstream ss(name);
|
||||
std::string temp;
|
||||
|
||||
getline(ss, temp, '$');
|
||||
int body_part = std::stoi(temp);
|
||||
|
||||
getline(ss, temp, '$');
|
||||
std::string model = temp.c_str();
|
||||
|
||||
getline(ss, temp, '$');
|
||||
std::string texture9 = temp.c_str();
|
||||
|
||||
CPlayerPed *player = FindPlayerPed();
|
||||
|
||||
if (texture9 == "cutoffchinosblue")
|
||||
{
|
||||
player->m_pPlayerData->m_pPedClothesDesc->SetTextureAndModel(-697413025, 744365350, body_part);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (texture9 == "sneakerbincblue")
|
||||
{
|
||||
player->m_pPlayerData->m_pPedClothesDesc->SetTextureAndModel(-915574819, 2099005073, body_part);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (texture9 == "12myfac")
|
||||
player->m_pPlayerData->m_pPedClothesDesc->SetTextureAndModel(-1750049245, 1393983095, body_part);
|
||||
else
|
||||
player->m_pPlayerData->m_pPedClothesDesc->SetTextureAndModel(texture9.c_str(), model.c_str(), body_part);
|
||||
}
|
||||
}
|
||||
CClothes::RebuildPlayer(player, false);
|
||||
}
|
||||
|
||||
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();
|
||||
if (Ped::pedspecial_json.data.contains(model) || custom_skin)
|
||||
{
|
||||
std::string name;
|
||||
if (Ped::pedspecial_json.data.contains(model))
|
||||
name = Ped::pedspecial_json.data[model].get<std::string>().c_str();
|
||||
else
|
||||
name = model;
|
||||
|
||||
CStreaming::RequestSpecialChar(1, name.c_str(), PRIORITY_REQUEST);
|
||||
CStreaming::LoadAllRequestedModels(true);
|
||||
|
||||
player->SetModelIndex(291);
|
||||
|
||||
CStreaming::SetSpecialCharIsDeletable(291);
|
||||
}
|
||||
else
|
||||
{
|
||||
int imodel = std::stoi(model);
|
||||
|
||||
CStreaming::RequestModel(imodel,eStreamingFlags::PRIORITY_REQUEST);
|
||||
CStreaming::LoadAllRequestedModels(false);
|
||||
player->SetModelIndex(imodel);
|
||||
CStreaming::SetModelIsDeletable(imodel);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Player::Main()
|
||||
{
|
||||
static CPlayerPed* player = FindPlayerPed();
|
||||
static int hplayer = CPools::GetPedRef(player);
|
||||
static CPad* pad = player->GetPadFromPlayer();
|
||||
|
||||
if (ImGui::Button("Copy coordinates", ImVec2(Ui::GetSize(2))))
|
||||
{
|
||||
CVector pos = player->GetPosition();
|
||||
std::string text = std::to_string(pos.x) + ", " + std::to_string(pos.y) + ", " + std::to_string(pos.z);
|
||||
|
||||
ImGui::SetClipboardText(text.c_str());
|
||||
CHud::SetHelpMessage("Coordinates copied", false, false, false);
|
||||
}
|
||||
ImGui::SameLine();
|
||||
if (ImGui::Button("Suicide", ImVec2(Ui::GetSize(2))))
|
||||
player->m_fHealth = 0.0;
|
||||
|
||||
ImGui::Spacing();
|
||||
|
||||
if (ImGui::BeginTabBar("Player", ImGuiTabBarFlags_NoTooltip + ImGuiTabBarFlags_FittingPolicyScroll))
|
||||
{
|
||||
if (ImGui::BeginTabItem("Checkboxes"))
|
||||
{
|
||||
ImGui::Spacing();
|
||||
|
||||
ImGui::BeginChild("CheckboxesChild");
|
||||
|
||||
ImGui::Columns(2, 0, false);
|
||||
|
||||
Ui::CheckboxAddress("Bounty on yourself", 0x96913F);
|
||||
if (Ui::CheckboxWithHint("God mode", &god_mode))
|
||||
{
|
||||
patch::Set<bool>(0x96916D, god_mode, false);
|
||||
player->m_nPhysicalFlags.bBulletProof = god_mode;
|
||||
player->m_nPhysicalFlags.bCollisionProof = god_mode;
|
||||
player->m_nPhysicalFlags.bExplosionProof = god_mode;
|
||||
player->m_nPhysicalFlags.bFireProof = god_mode;
|
||||
player->m_nPhysicalFlags.bMeeleProof = god_mode;
|
||||
}
|
||||
|
||||
Ui::CheckboxAddress("Higher cycle jumps", 0x969161);
|
||||
Ui::CheckboxAddress("Infinite oxygen", 0x96916E);
|
||||
Ui::CheckboxAddress("Infinite run", 0xB7CEE4);
|
||||
if (Ui::CheckboxBitFlag("Invisible player", player->m_nPedFlags.bDontRender))
|
||||
player->m_nPedFlags.bDontRender = (player->m_nPedFlags.bDontRender == 1) ? 0 : 1;
|
||||
|
||||
ImGui::NextColumn();
|
||||
|
||||
Ui::CheckboxWithHint("Keep position", &keep_position::state, "Teleport to the position you died from");
|
||||
if (Ui::CheckboxBitFlag("Lock control", pad->bPlayerSafe))
|
||||
pad->bPlayerSafe = (pad->bPlayerSafe == 1) ? 0 : 1;
|
||||
|
||||
Ui::CheckboxAddress("Mega jump", 0x96916C);
|
||||
Ui::CheckboxAddress("Mega punch", 0x969173);
|
||||
Ui::CheckboxAddress("Never get hungry", 0x969174);
|
||||
|
||||
bool never_wanted = patch::Get<bool>(0x969171, false);
|
||||
if (Ui::CheckboxWithHint("Never wanted", &never_wanted))
|
||||
CCheat::NotWantedCheat();
|
||||
|
||||
ImGui::Columns(1);
|
||||
|
||||
ImGui::EndChild();
|
||||
ImGui::EndTabItem();
|
||||
}
|
||||
|
||||
if (ImGui::BeginTabItem("Menus"))
|
||||
{
|
||||
ImGui::BeginChild("PlayerMenus");
|
||||
|
||||
Ui::EditReference("Armour", player->m_fArmour, 0, 100, 150);
|
||||
if (ImGui::CollapsingHeader("Body"))
|
||||
{
|
||||
if (player->m_nModelIndex == 0)
|
||||
{
|
||||
ImGui::Columns(3, 0, false);
|
||||
if (ImGui::RadioButton("Fat", &body, 2))
|
||||
CCheat::FatCheat();
|
||||
|
||||
ImGui::NextColumn();
|
||||
|
||||
if (ImGui::RadioButton("Muscle", &body, 1))
|
||||
CCheat::MuscleCheat();
|
||||
|
||||
ImGui::NextColumn();
|
||||
|
||||
if (ImGui::RadioButton("Skinny", &body, 0))
|
||||
CCheat::SkinnyCheat();
|
||||
|
||||
ImGui::Columns(1);
|
||||
}
|
||||
else
|
||||
{
|
||||
ImGui::TextWrapped("You need to be in CJ skin.");
|
||||
ImGui::Spacing();
|
||||
|
||||
if (ImGui::Button("Change to CJ skin", ImVec2(Ui::GetSize(1))))
|
||||
{
|
||||
player->SetModelIndex(0);
|
||||
Util::ClearCharTasksVehCheck(player);
|
||||
}
|
||||
}
|
||||
ImGui::Spacing();
|
||||
ImGui::Separator();
|
||||
}
|
||||
|
||||
Ui::EditStat("Energy", STAT_ENERGY);
|
||||
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::EditAddress<int>("Money", 0xB7CE50, -99999999, 0, 99999999);
|
||||
Ui::EditStat("Muscle", STAT_MUSCLE);
|
||||
Ui::EditStat("Respect", STAT_RESPECT);
|
||||
Ui::EditStat("Stamina", STAT_STAMINA);
|
||||
if (ImGui::CollapsingHeader("Wanted level"))
|
||||
{
|
||||
int val = player->m_pPlayerData->m_pWanted->m_nWantedLevel;
|
||||
|
||||
ImGui::Columns(3, 0, false);
|
||||
ImGui::Text("Min: 0");
|
||||
ImGui::NextColumn();
|
||||
ImGui::Text("Def: 0");
|
||||
ImGui::NextColumn();
|
||||
ImGui::Text("Max: 6");
|
||||
ImGui::Columns(1);
|
||||
|
||||
ImGui::Spacing();
|
||||
|
||||
if (ImGui::InputInt("Set value##Wanted level", &val))
|
||||
player->CheatWantedLevel(val);
|
||||
|
||||
ImGui::Spacing();
|
||||
|
||||
if (ImGui::Button("Minimum##Wanted level", Ui::GetSize(3)))
|
||||
player->CheatWantedLevel(0);
|
||||
|
||||
ImGui::SameLine();
|
||||
|
||||
if (ImGui::Button("Default##Wanted level", Ui::GetSize(3)))
|
||||
player->CheatWantedLevel(0);
|
||||
|
||||
ImGui::SameLine();
|
||||
|
||||
if (ImGui::Button("Maximum##Wanted level", Ui::GetSize(3)))
|
||||
player->CheatWantedLevel(6);
|
||||
|
||||
ImGui::Spacing();
|
||||
ImGui::Separator();
|
||||
}
|
||||
|
||||
ImGui::EndChild();
|
||||
ImGui::EndTabItem();
|
||||
}
|
||||
|
||||
if (ImGui::BeginTabItem("Appearance"))
|
||||
{
|
||||
ImGui::Spacing();
|
||||
Ui::CheckboxWithHint("Aim skin changer", &aim_skin_changer,
|
||||
(("Activate using Aim ped + ") + Ui::GetHotKeyNameString(Menu::hotkey::aim_skin_changer)).c_str());
|
||||
|
||||
if (ImGui::BeginTabBar("AppearanceTabBar"))
|
||||
{
|
||||
if (ImGui::BeginTabItem("Clothes"))
|
||||
{
|
||||
ImGui::Spacing();
|
||||
|
||||
if (player->m_nModelIndex == 0)
|
||||
{
|
||||
if (ImGui::Button("Remove clothes", ImVec2(Ui::GetSize())))
|
||||
{
|
||||
CPlayerPed *player = FindPlayerPed();
|
||||
|
||||
int temp = 0;
|
||||
for (uint i = 0; i < 18; i++)
|
||||
player->m_pPlayerData->m_pPedClothesDesc->SetTextureAndModel(temp, temp, i);
|
||||
|
||||
CClothes::RebuildPlayer(player, false);
|
||||
}
|
||||
ImGui::Spacing();
|
||||
|
||||
Ui::DrawImages(clothes_vec, ImVec2(70, 100), search_categories, selected_item, filter, ChangePlayerCloth, nullptr,
|
||||
[](std::string str)
|
||||
{
|
||||
std::stringstream ss(str);
|
||||
std::string temp;
|
||||
|
||||
getline(ss, temp, '$');
|
||||
getline(ss, temp, '$');
|
||||
|
||||
return temp;
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
ImGui::TextWrapped("You need to be in CJ skin.");
|
||||
ImGui::Spacing();
|
||||
|
||||
if (ImGui::Button("Change to CJ skin", ImVec2(Ui::GetSize(1))))
|
||||
{
|
||||
player->SetModelIndex(0);
|
||||
Util::ClearCharTasksVehCheck(player);
|
||||
}
|
||||
}
|
||||
ImGui::EndTabItem();
|
||||
}
|
||||
if (ImGui::BeginTabItem("Ped skins"))
|
||||
{
|
||||
Ui::DrawImages(Ped::peds_vec, ImVec2(65, 110), Ped::search_categories, Ped::selected_item, Ped::filter, ChangePlayerModel, nullptr,
|
||||
[](std::string str) {return Ped::ped_json.data[str].get<std::string>(); });
|
||||
ImGui::EndTabItem();
|
||||
}
|
||||
if (ImGui::BeginTabItem("Custom skins"))
|
||||
{
|
||||
ImGui::Spacing();
|
||||
Ui::FilterWithHint("Search", filter, std::string("Total skins: " + std::to_string(custom_skins::store_vec.size())).c_str());
|
||||
Ui::ShowTooltip("Place your dff & txd files inside 'modloader/Custom Skins'");
|
||||
ImGui::Spacing();
|
||||
ImGui::TextWrapped("Note: Your txd & dff names can't exceed 8 characters. Don't change names while the game is running.");
|
||||
ImGui::Spacing();
|
||||
if (modloader_installed)
|
||||
{
|
||||
for (std::string name : custom_skins::store_vec)
|
||||
{
|
||||
if (custom_skins::filter.PassFilter(name.c_str()))
|
||||
{
|
||||
if (ImGui::MenuItem(name.c_str()))
|
||||
{
|
||||
ChangePlayerModel(name);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ImGui::TextWrapped("Modloader is not installed. Please install modloader.");
|
||||
ImGui::Spacing();
|
||||
if (ImGui::Button("Download Modloader", ImVec2(Ui::GetSize(1))))
|
||||
ShellExecute(NULL, "open", "https://gtaforums.com/topic/669520-mod-loader/", NULL, NULL, SW_SHOWNORMAL);
|
||||
}
|
||||
ImGui::EndTabItem();
|
||||
}
|
||||
ImGui::EndTabBar();
|
||||
}
|
||||
ImGui::EndTabItem();
|
||||
}
|
||||
|
||||
ImGui::EndTabBar();
|
||||
}
|
||||
}
|
33
CheatMenu/Player.h
Normal file
@ -0,0 +1,33 @@
|
||||
#pragma once
|
||||
class Player
|
||||
{
|
||||
private:
|
||||
struct keep_position
|
||||
{
|
||||
static bool state;
|
||||
static CVector pos;
|
||||
};
|
||||
static bool god_mode;
|
||||
static int body;
|
||||
static bool aim_skin_changer;
|
||||
static ImGuiTextFilter filter;
|
||||
static std::string selected_item;
|
||||
static std::vector<std::string> search_categories;
|
||||
static std::vector<std::unique_ptr<TextureStructure>> clothes_vec;
|
||||
|
||||
struct custom_skins
|
||||
{
|
||||
static std::string dir;
|
||||
static ImGuiTextFilter filter;
|
||||
static std::vector<std::string> store_vec;
|
||||
};
|
||||
static bool modloader_installed;
|
||||
|
||||
public:
|
||||
static void ChangePlayerCloth(std::string& model);
|
||||
static void ChangePlayerModel(std::string& model);
|
||||
Player();
|
||||
~Player();
|
||||
static void Main();
|
||||
};
|
||||
|
239
CheatMenu/Teleport.cpp
Normal file
@ -0,0 +1,239 @@
|
||||
#include "pch.h"
|
||||
#include "Teleport.h"
|
||||
#include "Menu.h"
|
||||
|
||||
bool Teleport::insert_coord = false;
|
||||
bool Teleport::quick_teleport = false;
|
||||
char Teleport::input_buffer[INPUT_BUFFER_SIZE] = "";
|
||||
char Teleport::location_buffer[INPUT_BUFFER_SIZE] = "";
|
||||
|
||||
CVector Teleport::STeleport::pos{ -1, -1, -1 };
|
||||
bool Teleport::STeleport::_bool = false;
|
||||
uint Teleport::STeleport::timer = 0;
|
||||
ImGuiTextFilter Teleport::filter = "";
|
||||
std::vector<std::string> Teleport::search_categories;
|
||||
std::string Teleport::selected_item = "All";
|
||||
|
||||
uint quick_teleport_timer = 0;
|
||||
|
||||
CJson Teleport::json = CJson("teleport");
|
||||
|
||||
Teleport::Teleport()
|
||||
{
|
||||
|
||||
json.LoadJsonData(search_categories, selected_item);
|
||||
|
||||
Events::initGameEvent += []
|
||||
{
|
||||
// Load config data
|
||||
quick_teleport = config.GetValue("quick_teleport", false);
|
||||
};
|
||||
|
||||
Events::processScriptsEvent += []
|
||||
{
|
||||
if ((STeleport::_bool == true) && ((CTimer::m_snTimeInMilliseconds - STeleport::timer) > 500))
|
||||
{
|
||||
CPlayerPed *player = FindPlayerPed();
|
||||
|
||||
CEntity* player_entity = FindPlayerEntity(-1);
|
||||
STeleport::pos.z = CWorld::FindGroundZFor3DCoord(Teleport::STeleport::pos.x, Teleport::STeleport::pos.y, STeleport::pos.z + 100.0f, 0, &player_entity) + 1.0f;
|
||||
|
||||
if (player->m_pVehicle)
|
||||
{
|
||||
player->m_pVehicle->Teleport(STeleport::pos, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
player->Teleport(STeleport::pos, false);
|
||||
}
|
||||
|
||||
STeleport::_bool = false;
|
||||
Command<Commands::FREEZE_CHAR_POSITION_AND_DONT_LOAD_COLLISION>(CPools::GetPedRef(player), false);
|
||||
Command<Commands::SET_CAMERA_BEHIND_PLAYER>();
|
||||
}
|
||||
|
||||
if (quick_teleport)
|
||||
{
|
||||
if (Ui::HotKeyPressed(Menu::hotkey::quick_tp)
|
||||
&& ((CTimer::m_snTimeInMilliseconds - quick_teleport_timer) > 500))
|
||||
{
|
||||
quick_teleport_timer = CTimer::m_snTimeInMilliseconds;
|
||||
TeleportPlayer(true);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Events::shutdownRwEvent += []
|
||||
{
|
||||
config.SetValue("quick_teleport", quick_teleport);
|
||||
};
|
||||
}
|
||||
|
||||
void Teleport::TeleportPlayer(bool get_marker, CVector* pos, short interior_id)
|
||||
{
|
||||
CPlayerPed* player = FindPlayerPed();
|
||||
|
||||
if (get_marker)
|
||||
{
|
||||
auto target_blip = CRadar::ms_RadarTrace[LOWORD(FrontEndMenuManager.m_nTargetBlipIndex)];
|
||||
|
||||
|
||||
if (target_blip.m_nBlipSprite != RADAR_SPRITE_WAYPOINT)
|
||||
{
|
||||
CHud::SetHelpMessage("No blip found", false, false, false);
|
||||
return;
|
||||
}
|
||||
CEntity* player_entity = FindPlayerEntity(-1);
|
||||
pos = &(target_blip.m_vPosition);
|
||||
pos->z = CWorld::FindGroundZFor3DCoord(pos->x, pos->y, 1000, 0, &player_entity) + 50.f;
|
||||
|
||||
Teleport::STeleport::pos = *pos;
|
||||
Teleport::STeleport::timer = CTimer::m_snTimeInMilliseconds;
|
||||
Teleport::STeleport::_bool = true;
|
||||
|
||||
Command<Commands::FREEZE_CHAR_POSITION_AND_DONT_LOAD_COLLISION>(CPools::GetPedRef(player), true);
|
||||
}
|
||||
|
||||
CStreaming::LoadScene(&Teleport::STeleport::pos);
|
||||
CStreaming::LoadSceneCollision(&Teleport::STeleport::pos);
|
||||
CStreaming::LoadAllRequestedModels(false);
|
||||
|
||||
if (player->m_pVehicle)
|
||||
{
|
||||
player->m_pVehicle->Teleport(CVector(pos->x, pos->y, pos->z), false);
|
||||
Command<Commands::SET_VEHICLE_AREA_VISIBLE>(CPools::GetVehicleRef(player->m_pVehicle), interior_id); // setvehicleinterior
|
||||
}
|
||||
else
|
||||
{
|
||||
player->Teleport(CVector(pos->x, pos->y, pos->z), false);
|
||||
}
|
||||
|
||||
Command<Commands::SET_CHAR_AREA_VISIBLE>(CPools::GetPedRef(player), interior_id); // setcharinterior
|
||||
Command<Commands::SET_AREA_VISIBLE>(interior_id);
|
||||
}
|
||||
|
||||
void Teleport::TeleportToLocation(std::string& rootkey, std::string& loc_name,std::string& loc)
|
||||
{
|
||||
try {
|
||||
int interior = 0;
|
||||
CVector pos;
|
||||
std::stringstream ss(loc);
|
||||
std::string temp;
|
||||
|
||||
std::getline(ss, temp, ',');
|
||||
interior = std::stoi(temp);
|
||||
|
||||
std::getline(ss, temp, ',');
|
||||
pos.x = std::stof(temp);
|
||||
|
||||
std::getline(ss, temp, ',');
|
||||
pos.y = std::stof(temp);
|
||||
|
||||
std::getline(ss, temp, ',');
|
||||
pos.z = std::stof(temp);
|
||||
|
||||
Teleport::TeleportPlayer(false, &pos, static_cast<short>(interior));
|
||||
}
|
||||
catch (...) {
|
||||
CHud::SetHelpMessage("Invalid location", false, false, false);
|
||||
}
|
||||
}
|
||||
|
||||
void Teleport::RemoveTeleportEntry(std::string& category, std::string& key, std::string& val)
|
||||
{
|
||||
if (category == "Custom")
|
||||
{
|
||||
json.data["Custom"].erase(key);
|
||||
CHud::SetHelpMessage("Location removed", false, false, false);
|
||||
}
|
||||
else CHud::SetHelpMessage("You can only remove custom location", false, false, false);
|
||||
}
|
||||
|
||||
void Teleport::Main()
|
||||
{
|
||||
if (ImGui::BeginTabBar("Teleport",ImGuiTabBarFlags_NoTooltip+ImGuiTabBarFlags_FittingPolicyScroll))
|
||||
{
|
||||
ImGui::Spacing();
|
||||
if (ImGui::BeginTabItem("Teleport"))
|
||||
{
|
||||
ImGui::Spacing();
|
||||
if (ImGui::BeginChild("Teleport Child"))
|
||||
{
|
||||
ImGui::Columns(2, 0, false);
|
||||
ImGui::Checkbox("Insert coordinates", &insert_coord);
|
||||
ImGui::NextColumn();
|
||||
Ui::CheckboxWithHint("Quick teleport", &quick_teleport,
|
||||
(std::string("Teleport to marker using ") + Ui::GetHotKeyNameString(Menu::hotkey::quick_tp)).c_str());
|
||||
|
||||
ImGui::Columns(1);
|
||||
ImGui::Spacing();
|
||||
|
||||
if (insert_coord)
|
||||
{
|
||||
CVector pos = FindPlayerPed()->GetPosition();
|
||||
|
||||
strcpy(input_buffer,(std::to_string(int(pos.x)) + ", " + std::to_string(int(pos.y)) + ", " + std::to_string(int(pos.z))).c_str());
|
||||
}
|
||||
|
||||
ImGui::InputTextWithHint("Coordinates", "x, y, z", input_buffer, IM_ARRAYSIZE(input_buffer));
|
||||
|
||||
ImGui::Spacing();
|
||||
|
||||
if (ImGui::Button("Teleport to coord", Ui::GetSize(2)))
|
||||
{
|
||||
std::stringstream ss(input_buffer);
|
||||
std::string temp;
|
||||
CVector pos(0,0,0);
|
||||
|
||||
try {
|
||||
getline(ss, temp, ',');
|
||||
pos.x = std::stof(temp);
|
||||
|
||||
getline(ss, temp, ',');
|
||||
pos.y = std::stof(temp);
|
||||
|
||||
getline(ss, temp, ',');
|
||||
pos.z = std::stof(temp);
|
||||
|
||||
Teleport::TeleportPlayer(false,&pos);
|
||||
}
|
||||
catch (...) {
|
||||
CHud::SetHelpMessage("Invalid coordinate", false, false, false);
|
||||
}
|
||||
}
|
||||
ImGui::SameLine();
|
||||
if (ImGui::Button("Teleport to marker", Ui::GetSize(2)))
|
||||
Teleport::TeleportPlayer(true);
|
||||
|
||||
ImGui::EndChild();
|
||||
}
|
||||
ImGui::EndTabItem();
|
||||
}
|
||||
|
||||
if (ImGui::BeginTabItem("Search"))
|
||||
{
|
||||
ImGui::Spacing();
|
||||
Ui::DrawJSON(json, search_categories, selected_item, filter, &TeleportToLocation, &RemoveTeleportEntry);
|
||||
ImGui::EndTabItem();
|
||||
}
|
||||
|
||||
if (ImGui::BeginTabItem("Custom"))
|
||||
{
|
||||
ImGui::Spacing();
|
||||
ImGui::InputTextWithHint("Location", "Groove Street", location_buffer, IM_ARRAYSIZE(input_buffer));
|
||||
ImGui::InputTextWithHint("Coordinates", "x, y, z", input_buffer, IM_ARRAYSIZE(input_buffer));
|
||||
ImGui::Spacing();
|
||||
if (ImGui::Button("Add location", Ui::GetSize()))
|
||||
{
|
||||
json.data["Custom"][location_buffer] = ("0, " + std::string(input_buffer));
|
||||
}
|
||||
ImGui::EndTabItem();
|
||||
}
|
||||
ImGui::EndTabBar();
|
||||
}
|
||||
}
|
||||
|
||||
Teleport::~Teleport()
|
||||
{
|
||||
};
|
||||
|
34
CheatMenu/Teleport.h
Normal file
@ -0,0 +1,34 @@
|
||||
#pragma once
|
||||
#include <vector>
|
||||
#include "pch.h"
|
||||
|
||||
class Teleport
|
||||
{
|
||||
private:
|
||||
static bool insert_coord;
|
||||
static bool quick_teleport;
|
||||
static char input_buffer[INPUT_BUFFER_SIZE];
|
||||
static CJson json;
|
||||
static ImGuiTextFilter filter;
|
||||
static std::vector<std::string> search_categories;
|
||||
static std::string selected_item;
|
||||
static char location_buffer[INPUT_BUFFER_SIZE];
|
||||
|
||||
struct STeleport
|
||||
{
|
||||
static bool _bool;
|
||||
static CVector pos;
|
||||
static uint timer;
|
||||
};
|
||||
|
||||
protected:
|
||||
Teleport();
|
||||
virtual ~Teleport();
|
||||
public:
|
||||
|
||||
static void Main();
|
||||
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);
|
||||
|
||||
};
|
759
CheatMenu/Ui.cpp
Normal file
@ -0,0 +1,759 @@
|
||||
#include "pch.h"
|
||||
#include "Ui.h"
|
||||
|
||||
std::string Ui::current_hotkey = "";
|
||||
|
||||
static Ui::JsonPopUpData json_popup;
|
||||
static Ui::ImgPopUpData img_popup;
|
||||
|
||||
bool Ui::ListBox(const char* label, std::vector<std::string>& all_items, int& selected)
|
||||
{
|
||||
bool rtn = false;
|
||||
if (ImGui::BeginCombo(label, all_items[selected].c_str()))
|
||||
{
|
||||
for (size_t index = 0; index < all_items.size(); index++)
|
||||
{
|
||||
if (selected != index)
|
||||
{
|
||||
if (ImGui::MenuItem(all_items[index].c_str()))
|
||||
{
|
||||
selected = index;
|
||||
rtn = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
ImGui::EndCombo();
|
||||
}
|
||||
return rtn;
|
||||
}
|
||||
|
||||
bool Ui::ListBoxStr(const char* label, std::vector<std::string>& all_items, std::string& selected)
|
||||
{
|
||||
bool rtn = false;
|
||||
if (ImGui::BeginCombo(label, selected.c_str()))
|
||||
{
|
||||
for (std::string current_item : all_items)
|
||||
{
|
||||
if (current_item != label)
|
||||
{
|
||||
if (ImGui::MenuItem(current_item.c_str()))
|
||||
{
|
||||
selected = current_item;
|
||||
rtn = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
ImGui::EndCombo();
|
||||
}
|
||||
|
||||
return rtn;
|
||||
}
|
||||
|
||||
ImVec2 Ui::GetSize(short count,bool spacing)
|
||||
{
|
||||
if (count == 1)
|
||||
spacing = false;
|
||||
|
||||
float factor = ImGui::GetStyle().ItemSpacing.x / 2.0f;
|
||||
float x;
|
||||
|
||||
if (count == 3)
|
||||
factor = ImGui::GetStyle().ItemSpacing.x / 1.403f;
|
||||
|
||||
if (spacing)
|
||||
x = ImGui::GetWindowContentRegionWidth() / count - factor;
|
||||
else
|
||||
x = ImGui::GetWindowContentRegionWidth() / count;
|
||||
|
||||
return ImVec2(x, ImGui::GetFrameHeight()*1.3f);
|
||||
}
|
||||
|
||||
void Ui::DrawHeaders(unsortedMap& data)
|
||||
{
|
||||
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(0, 0));
|
||||
|
||||
short i = 1;
|
||||
auto colors = ImGui::GetStyle().Colors;
|
||||
ImVec4 btn_col = colors[ImGuiCol_Button];
|
||||
static void* func;
|
||||
for (auto it = data.begin(); it != data.end(); ++it)
|
||||
{
|
||||
const char* btn_text = it->first.c_str();
|
||||
|
||||
if (btn_text == Globals::header_id)
|
||||
colors[ImGuiCol_Button] = colors[ImGuiCol_ButtonActive];
|
||||
|
||||
|
||||
if (ImGui::Button(btn_text, GetSize(3, false)))
|
||||
{
|
||||
Globals::header_id = btn_text;
|
||||
func = it->second;
|
||||
}
|
||||
|
||||
colors[ImGuiCol_Button] = btn_col;
|
||||
|
||||
if (i % 3 != 0)
|
||||
ImGui::SameLine();
|
||||
i++;
|
||||
}
|
||||
ImGui::PopStyleVar();
|
||||
ImGui::Dummy(ImVec2(0, 10));
|
||||
|
||||
if (Globals::header_id != "" && func != nullptr)
|
||||
{
|
||||
if (ImGui::BeginChild("TABSBAR"))
|
||||
{
|
||||
((void(*)(void))func)();
|
||||
ImGui::EndChild();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Ui::ShowTooltip(const char* text)
|
||||
{
|
||||
ImGui::SameLine();
|
||||
ImGui::TextDisabled("?");
|
||||
|
||||
if (ImGui::IsItemHovered())
|
||||
{
|
||||
ImGui::BeginTooltip();
|
||||
ImGui::Text(text);
|
||||
ImGui::EndTooltip();
|
||||
}
|
||||
}
|
||||
|
||||
bool Ui::CheckboxWithHint(const char* label, bool* state, const char* hint)
|
||||
{
|
||||
bool rtn = false;
|
||||
|
||||
if (ImGui::Checkbox(label, state))
|
||||
rtn = true;
|
||||
|
||||
if (hint != nullptr)
|
||||
ShowTooltip(hint);
|
||||
|
||||
return rtn;
|
||||
}
|
||||
|
||||
bool Ui::CheckboxAddress(const char* label, const int addr, const char* hint)
|
||||
{
|
||||
bool rtn = false;
|
||||
bool state = patch::Get<bool>(addr,false);
|
||||
|
||||
if (CheckboxWithHint(label, &state, hint) && addr != NULL)
|
||||
{
|
||||
patch::Set<bool>(addr, state, false);
|
||||
rtn = true;
|
||||
}
|
||||
|
||||
return rtn;
|
||||
}
|
||||
|
||||
bool Ui::CheckboxAddressEx(const char* label, const int addr, int enabled_val, int disabled_val, const char* hint)
|
||||
{
|
||||
bool rtn = false;
|
||||
|
||||
bool state = false;
|
||||
int val = 0;
|
||||
patch::GetRaw(addr, &val, 1, false);
|
||||
|
||||
if (val == enabled_val)
|
||||
state = true;
|
||||
|
||||
if (CheckboxWithHint(label, &state, hint) && addr != NULL)
|
||||
{
|
||||
if (state)
|
||||
patch::SetRaw(addr, &enabled_val, 1, false);
|
||||
else
|
||||
patch::SetRaw(addr, &disabled_val, 1, false);
|
||||
rtn = true;
|
||||
}
|
||||
|
||||
return rtn;
|
||||
}
|
||||
|
||||
bool Ui::CheckboxAddressVar(const char* label, bool val, int addr, const char* hint)
|
||||
{
|
||||
bool rtn = false;
|
||||
bool state = val;
|
||||
if (CheckboxWithHint(label, &state, hint))
|
||||
{
|
||||
patch::Set<bool>(addr, state, false);
|
||||
rtn = true;
|
||||
}
|
||||
|
||||
return rtn;
|
||||
}
|
||||
|
||||
bool Ui::CheckboxAddressVarEx(const char* label, bool val, int addr, int enabled_val, int disabled_val, const char* hint)
|
||||
{
|
||||
bool rtn = false;
|
||||
bool state = val;
|
||||
if (CheckboxWithHint(label, &state, hint))
|
||||
{
|
||||
if (state)
|
||||
patch::SetRaw(addr, &enabled_val, 1, false);
|
||||
else
|
||||
patch::SetRaw(addr, &disabled_val, 1, false);
|
||||
|
||||
rtn = true;
|
||||
}
|
||||
|
||||
return rtn;
|
||||
}
|
||||
|
||||
bool Ui::CheckboxBitFlag(const char* label,uint flag, const char* hint)
|
||||
{
|
||||
bool rtn = false;
|
||||
bool state = (flag == 1) ? true : false;
|
||||
if (CheckboxWithHint(label, &state, hint))
|
||||
{
|
||||
flag = state ? 1 : 0;
|
||||
rtn = true;
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
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();
|
||||
|
||||
ImVec2 min = ImGui::GetItemRectMin();
|
||||
min.x += ImGui::GetStyle().FramePadding.x;
|
||||
min.y += ImGui::GetStyle().FramePadding.y;
|
||||
|
||||
drawlist->AddText(min, ImGui::GetColorU32(ImGuiCol_TextDisabled), "Search");
|
||||
}
|
||||
|
||||
ImGui::PopItemWidth();
|
||||
|
||||
ImGui::Spacing();
|
||||
|
||||
if (ImGui::IsMouseClicked(1))
|
||||
json_popup.function = nullptr;
|
||||
|
||||
|
||||
ImGui::BeginChild(1);
|
||||
for (auto root : json.data.items())
|
||||
{
|
||||
if (root.key() == selected_item || selected_item == "All")
|
||||
{
|
||||
for (auto _data : root.value().items())
|
||||
{
|
||||
|
||||
std::string name = _data.key();
|
||||
if (filter.PassFilter(name.c_str()))
|
||||
{
|
||||
if (ImGui::MenuItem(name.c_str()) && func_left_click != nullptr)
|
||||
{
|
||||
func_left_click(std::string(root.key()),std::string(_data.key()), std::string(_data.value()));
|
||||
}
|
||||
|
||||
if (ImGui::IsItemClicked(1) && func_right_click != nullptr)
|
||||
{
|
||||
json_popup.function = func_right_click;
|
||||
json_popup.root_key = root.key();
|
||||
json_popup.key = name;
|
||||
json_popup.value = _data.value();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (json_popup.function != nullptr)
|
||||
{
|
||||
if (ImGui::BeginPopupContextWindow())
|
||||
{
|
||||
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);
|
||||
|
||||
|
||||
if (ImGui::MenuItem("Close"))
|
||||
json_popup.function = nullptr;
|
||||
|
||||
ImGui::EndPopup();
|
||||
}
|
||||
}
|
||||
ImGui::EndChild();
|
||||
}
|
||||
|
||||
|
||||
void Ui::EditStat(const char *label, const int stat_id, const int min, const int def, const int max)
|
||||
{
|
||||
if (ImGui::CollapsingHeader(label))
|
||||
{
|
||||
int val = static_cast<int>(CStats::GetStatValue(stat_id));
|
||||
|
||||
ImGui::Columns(3, 0, false);
|
||||
ImGui::Text(("Min: " + std::to_string(min)).c_str());
|
||||
ImGui::NextColumn();
|
||||
ImGui::Text(("Def: " + std::to_string(def)).c_str());
|
||||
ImGui::NextColumn();
|
||||
ImGui::Text(("Max: " + std::to_string(max)).c_str());
|
||||
ImGui::Columns(1);
|
||||
|
||||
ImGui::Spacing();
|
||||
|
||||
if (ImGui::InputInt(("Set value##" + std::string(label)).c_str(), &val))
|
||||
CStats::SetStatValue(stat_id, static_cast<float>(val));
|
||||
|
||||
ImGui::Spacing();
|
||||
|
||||
if (ImGui::Button(("Minimum##" + std::string(label)).c_str(), Ui::GetSize(3)))
|
||||
CStats::SetStatValue(stat_id, static_cast<float>(min));
|
||||
|
||||
ImGui::SameLine();
|
||||
|
||||
if (ImGui::Button(("Default##" + std::string(label)).c_str(), Ui::GetSize(3)))
|
||||
CStats::SetStatValue(stat_id, static_cast<float>(def));
|
||||
|
||||
ImGui::SameLine();
|
||||
|
||||
if (ImGui::Button(("Maximum##" + std::string(label)).c_str(), Ui::GetSize(3)))
|
||||
CStats::SetStatValue(stat_id, static_cast<float>(max));
|
||||
|
||||
ImGui::Spacing();
|
||||
ImGui::Separator();
|
||||
}
|
||||
}
|
||||
|
||||
void Ui::FilterWithHint(const char* label, ImGuiTextFilter& filter, const char* hint)
|
||||
{
|
||||
filter.Draw(label);
|
||||
|
||||
if (strlen(filter.InputBuf) == 0)
|
||||
{
|
||||
ImDrawList *drawlist = ImGui::GetWindowDrawList();
|
||||
|
||||
ImVec2 min = ImGui::GetItemRectMin();
|
||||
min.x += ImGui::GetStyle().FramePadding.x;
|
||||
min.y += ImGui::GetStyle().FramePadding.y;
|
||||
|
||||
drawlist->AddText(min, ImGui::GetColorU32(ImGuiCol_TextDisabled), hint);
|
||||
}
|
||||
}
|
||||
|
||||
// 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,
|
||||
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)
|
||||
{
|
||||
|
||||
int images_in_row = static_cast<int>(ImGui::GetWindowContentRegionWidth() / image_size.x);
|
||||
image_size.x = ImGui::GetWindowContentRegionWidth() / images_in_row - ImGuiStyleVar_ItemSpacing*0.65f;
|
||||
|
||||
int images_count = 1;
|
||||
|
||||
ImGui::Spacing();
|
||||
|
||||
if (ImGui::IsMouseClicked(1))
|
||||
img_popup.function = nullptr;
|
||||
|
||||
ImGui::PushItemWidth(ImGui::GetContentRegionAvailWidth() / 2 - 5);
|
||||
ListBoxStr("##Categories", category_vec, selected_item);
|
||||
ImGui::SameLine();
|
||||
FilterWithHint("##Filter", filter, "Search");
|
||||
|
||||
ImGui::Spacing();
|
||||
|
||||
ImGui::BeginChild("DrawImages");
|
||||
for (uint i = 0; i < img_vec.size(); i++)
|
||||
{
|
||||
std::string text = img_vec[i]->file_name;
|
||||
std::string model_name = get_name_func(text);
|
||||
|
||||
if (filter.PassFilter(model_name.c_str())
|
||||
&& (img_vec[i]->category_name == selected_item || selected_item == "All")
|
||||
&& (verify_func == nullptr || verify_func(text))
|
||||
)
|
||||
{
|
||||
void *texture = nullptr;
|
||||
|
||||
if (Globals::renderer == Render_DirectX9)
|
||||
texture = img_vec[i]->texture9;
|
||||
else // consider 11
|
||||
texture = img_vec[i]->texture11;
|
||||
|
||||
if (ImGui::ImageButton(texture, image_size, ImVec2(0, 0), ImVec2(1, 1), 1, ImVec4(1, 1, 1, 1), ImVec4(1, 1, 1, 1)))
|
||||
on_left_click(text);
|
||||
|
||||
if (ImGui::IsItemClicked(1) && on_right_click != nullptr)
|
||||
{
|
||||
img_popup.function = on_right_click;
|
||||
img_popup.value = model_name;
|
||||
}
|
||||
|
||||
if (ImGui::IsItemHovered())
|
||||
{
|
||||
ImDrawList *drawlist = ImGui::GetWindowDrawList();
|
||||
|
||||
ImVec2 btn_min = ImGui::GetItemRectMin();
|
||||
ImVec2 btn_max = ImGui::GetItemRectMax();
|
||||
|
||||
drawlist->AddRectFilled(btn_min, btn_max, ImGui::GetColorU32(ImGuiCol_ModalWindowDimBg));
|
||||
|
||||
ImVec2 text_size = ImGui::CalcTextSize(model_name.c_str());
|
||||
if (text_size.x < image_size.x)
|
||||
{
|
||||
float offsetX = (ImGui::GetItemRectSize().x - text_size.x) / 2;
|
||||
drawlist->AddText(ImVec2(btn_min.x + offsetX, btn_min.y + 10), ImGui::GetColorU32(ImGuiCol_Text), model_name.c_str());
|
||||
}
|
||||
else
|
||||
{
|
||||
std::string buff = "";
|
||||
|
||||
std::stringstream ss(model_name);
|
||||
short count = 1;
|
||||
|
||||
while (ss >> buff)
|
||||
{
|
||||
text_size = ImGui::CalcTextSize(buff.c_str());
|
||||
float offsetX = (ImGui::GetItemRectSize().x - text_size.x) / 2;
|
||||
drawlist->AddText(ImVec2(btn_min.x + offsetX, btn_min.y + 10 * count), ImGui::GetColorU32(ImGuiCol_Text), buff.c_str());
|
||||
++count;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if (images_count % images_in_row != 0)
|
||||
ImGui::SameLine(0.0, 4.0);
|
||||
|
||||
images_count++;
|
||||
}
|
||||
}
|
||||
|
||||
if (img_popup.function != nullptr)
|
||||
{
|
||||
if (ImGui::BeginPopupContextWindow())
|
||||
{
|
||||
ImGui::Text(img_popup.value.c_str());
|
||||
ImGui::Separator();
|
||||
if (ImGui::MenuItem("Remove"))
|
||||
img_popup.function(img_popup.value);
|
||||
|
||||
|
||||
if (ImGui::MenuItem("Close"))
|
||||
img_popup.function = nullptr;
|
||||
|
||||
ImGui::EndPopup();
|
||||
}
|
||||
}
|
||||
ImGui::EndChild();
|
||||
}
|
||||
|
||||
void Ui::RadioButtonAddress(const char* label, std::vector<NamedMemory> &named_mem)
|
||||
{
|
||||
size_t btn_in_column = named_mem.size() / 2 -1;
|
||||
|
||||
ImGui::Text(label);
|
||||
ImGui::Columns(2, 0, false);
|
||||
|
||||
bool state = true;
|
||||
|
||||
for (size_t i = 0; i < named_mem.size(); i++)
|
||||
{
|
||||
if (patch::Get<bool>(named_mem[i].addr, false))
|
||||
state = false;
|
||||
}
|
||||
|
||||
if (ImGui::RadioButton("None", state))
|
||||
{
|
||||
for (size_t i = 0; i < named_mem.size(); i++)
|
||||
patch::Set<bool>(named_mem[i].addr, false);
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < named_mem.size(); i++)
|
||||
{
|
||||
state = patch::Get<bool>(named_mem[i].addr, false);
|
||||
|
||||
if (ImGui::RadioButton(named_mem[i].name.c_str(), state))
|
||||
{
|
||||
for (size_t i = 0; i < named_mem.size(); i++)
|
||||
patch::Set<bool>(named_mem[i].addr, false);
|
||||
|
||||
patch::Set<bool>(named_mem[i].addr, true);
|
||||
}
|
||||
|
||||
if (i == btn_in_column)
|
||||
ImGui::NextColumn();
|
||||
}
|
||||
ImGui::Columns(1);
|
||||
}
|
||||
|
||||
void Ui::RadioButtonAddressEx(const char* label, int addr, std::vector<NamedValue> &named_val)
|
||||
{
|
||||
size_t btn_in_column = named_val.size() / 2;
|
||||
|
||||
ImGui::Text(label);
|
||||
ImGui::Columns(2, 0, false);
|
||||
|
||||
int mem_val = 0;
|
||||
patch::GetRaw(addr, &mem_val, 1, false);
|
||||
|
||||
for (size_t i = 0; i < named_val.size(); i++)
|
||||
{
|
||||
if (ImGui::RadioButton(named_val[i].name.c_str(), &mem_val, named_val[i].value))
|
||||
patch::SetRaw(addr, &named_val[i].value, 1, false);
|
||||
|
||||
if (i == btn_in_column)
|
||||
ImGui::NextColumn();
|
||||
}
|
||||
ImGui::Columns(1);
|
||||
}
|
||||
|
||||
void Ui::EditRadioButtonAddress(const char* label, std::vector<NamedMemory> &named_mem)
|
||||
{
|
||||
if (ImGui::CollapsingHeader(label))
|
||||
{
|
||||
RadioButtonAddress(label, named_mem);
|
||||
ImGui::Spacing();
|
||||
ImGui::Separator();
|
||||
}
|
||||
}
|
||||
|
||||
void Ui::EditRadioButtonAddressEx(const char* label, int addr, std::vector<NamedValue> &named_val)
|
||||
{
|
||||
if (ImGui::CollapsingHeader(label))
|
||||
{
|
||||
RadioButtonAddressEx(label,addr,named_val);
|
||||
ImGui::Spacing();
|
||||
ImGui::Separator();
|
||||
}
|
||||
}
|
||||
|
||||
void Ui::ColorPickerAddress(const char* label, int base_addr, ImVec4&& default_color)
|
||||
{
|
||||
if (ImGui::CollapsingHeader(label))
|
||||
{
|
||||
float cur_color[4];
|
||||
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);
|
||||
|
||||
// 0-255 -> 0-1
|
||||
cur_color[0] /= 255;
|
||||
cur_color[1] /= 255;
|
||||
cur_color[2] /= 255;
|
||||
cur_color[3] /= 255;
|
||||
|
||||
if (ImGui::ColorPicker4(std::string("Pick color##" + std::string(label)).c_str(), cur_color))
|
||||
{
|
||||
// 0-1 -> 0-255
|
||||
cur_color[0] *= 255;
|
||||
cur_color[1] *= 255;
|
||||
cur_color[2] *= 255;
|
||||
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);
|
||||
}
|
||||
ImGui::Spacing();
|
||||
|
||||
if (ImGui::Button("Reset to default", Ui::GetSize()))
|
||||
{
|
||||
patch::SetRaw(base_addr, &default_color.w, 1, false);
|
||||
patch::SetRaw(base_addr + 1, &default_color.x, 1, false);
|
||||
patch::SetRaw(base_addr + 2, &default_color.y, 1, false);
|
||||
patch::SetRaw(base_addr + 3, &default_color.z, 1, false);
|
||||
}
|
||||
|
||||
ImGui::Spacing();
|
||||
ImGui::Separator();
|
||||
}
|
||||
}
|
||||
|
||||
void Ui::EditBits(const char *label, const int address, const std::vector<std::string>& names)
|
||||
{
|
||||
int *mem_val = (int*)address;
|
||||
|
||||
if (ImGui::CollapsingHeader(label))
|
||||
{
|
||||
ImGui::Columns(2, NULL, false);
|
||||
|
||||
for (int i = 0; i < 32; ++i)
|
||||
{
|
||||
int mask = 1 << i;
|
||||
bool state = static_cast<bool>(*mem_val & mask);
|
||||
|
||||
if (ImGui::Checkbox(names[i].c_str(), &state))
|
||||
*mem_val ^= mask;
|
||||
|
||||
if (i + 1 == 32 / 2)
|
||||
ImGui::NextColumn();
|
||||
}
|
||||
ImGui::Columns(1);
|
||||
|
||||
ImGui::Spacing();
|
||||
ImGui::Separator();
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
int items = 3;
|
||||
|
||||
if (min == def)
|
||||
items = 2;
|
||||
|
||||
ImGui::Columns(items, 0, false);
|
||||
|
||||
ImGui::Text(("Min: " + std::to_string(min)).c_str());
|
||||
|
||||
if (items == 3)
|
||||
{
|
||||
ImGui::NextColumn();
|
||||
ImGui::Text(("Def: " + std::to_string(def)).c_str());
|
||||
}
|
||||
|
||||
ImGui::NextColumn();
|
||||
ImGui::Text(("Max: " + std::to_string(max)).c_str());
|
||||
ImGui::Columns(1);
|
||||
|
||||
ImGui::Spacing();
|
||||
|
||||
int size = ImGui::GetFrameHeight();
|
||||
|
||||
if (ImGui::InputFloat(("##" + std::string(label)).c_str(), &val))
|
||||
patch::Set<float>(address, val/mul, false);
|
||||
|
||||
ImGui::SameLine(0.0, 4.0);
|
||||
if (ImGui::Button("-",ImVec2(size, size)))
|
||||
{
|
||||
val -= 1;
|
||||
patch::Set<float>(address, val / mul, false);
|
||||
}
|
||||
ImGui::SameLine(0.0, 4.0);
|
||||
if (ImGui::Button("+",ImVec2(size, size)))
|
||||
{
|
||||
val += 1;
|
||||
patch::Set<float>(address, val / mul, false);
|
||||
}
|
||||
ImGui::SameLine(0.0, 4.0);
|
||||
ImGui::Text("Set");
|
||||
|
||||
|
||||
ImGui::Spacing();
|
||||
|
||||
if (ImGui::Button(("Minimum##" + std::string(label)).c_str(), Ui::GetSize(items)))
|
||||
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);
|
||||
}
|
||||
|
||||
ImGui::SameLine();
|
||||
|
||||
if (ImGui::Button(("Maximum##" + std::string(label)).c_str(), Ui::GetSize(items)))
|
||||
patch::Set<float>(address, max/mul, false);
|
||||
|
||||
ImGui::Spacing();
|
||||
ImGui::Separator();
|
||||
}
|
||||
}
|
||||
|
||||
void Ui::HotKey(const char* label, int* key_array)
|
||||
{
|
||||
bool active = current_hotkey == label;
|
||||
|
||||
if (active)
|
||||
{
|
||||
ImGui::PushStyleColor(ImGuiCol_Button, ImGui::GetStyle().Colors[ImGuiCol_ButtonActive]);
|
||||
|
||||
for (int key = 2; key != 90; ++key)
|
||||
{
|
||||
if (KeyPressed(key))
|
||||
{
|
||||
key_array[0] = key;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
for (int key = 90; key != 2; --key)
|
||||
{
|
||||
if (KeyPressed(key))
|
||||
{
|
||||
key_array[1] = key;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
std::string text = key_names[key_array[0]-1];
|
||||
|
||||
if (key_array[0] != key_array[1])
|
||||
text += (" + " + key_names[key_array[1]-1]);
|
||||
|
||||
if (ImGui::Button((text + std::string("##") + std::string(label)).c_str(), ImVec2(ImGui::GetWindowContentRegionWidth() / 3, ImGui::GetFrameHeight())))
|
||||
{
|
||||
if (active)
|
||||
current_hotkey = "";
|
||||
else
|
||||
current_hotkey = label;;
|
||||
}
|
||||
ImGui::SameLine();
|
||||
ImGui::Text(label);
|
||||
|
||||
if (active)
|
||||
ImGui::PopStyleColor();
|
||||
|
||||
if (!(ImGui::IsWindowFocused() || ImGui::IsItemVisible()))
|
||||
current_hotkey = "";
|
||||
}
|
||||
|
||||
bool Ui::HotKeyPressed(int *hotkey)
|
||||
{
|
||||
return current_hotkey == "" && KeyPressed(hotkey[0]) && KeyPressed(hotkey[1]);
|
||||
}
|
||||
|
||||
std::string Ui::GetHotKeyNameString(int *hotkey)
|
||||
{
|
||||
std::string text = key_names[hotkey[0] - 1];
|
||||
|
||||
if (hotkey[0] != hotkey[1])
|
||||
text += (" + " + key_names[hotkey[1] - 1]);
|
||||
|
||||
return text;
|
||||
}
|
||||
|
||||
|
||||
bool Ui::ColorButton(int color_id, std::vector<float> &color, ImVec2 size)
|
||||
{
|
||||
bool rtn = false;
|
||||
std::string label = "Color " + std::to_string(color_id);
|
||||
|
||||
if (ImGui::ColorButton(label.c_str(), ImVec4(color[0], color[1], color[2], 1), 0, size))
|
||||
rtn = true;
|
||||
|
||||
if (ImGui::IsItemHovered())
|
||||
{
|
||||
ImDrawList *drawlist = ImGui::GetWindowDrawList();
|
||||
drawlist->AddRectFilled(ImGui::GetItemRectMin(), ImGui::GetItemRectMax(), ImGui::GetColorU32(ImGuiCol_ModalWindowDimBg));
|
||||
}
|
||||
|
||||
return rtn;
|
||||
}
|
169
CheatMenu/Ui.h
Normal file
@ -0,0 +1,169 @@
|
||||
#pragma once
|
||||
#include "pch.h"
|
||||
|
||||
class Ui
|
||||
{
|
||||
|
||||
private:
|
||||
static std::string current_hotkey;
|
||||
public:
|
||||
struct NamedMemory {
|
||||
std::string name;
|
||||
int addr;
|
||||
};
|
||||
|
||||
struct NamedValue {
|
||||
std::string name;
|
||||
int value;
|
||||
};
|
||||
|
||||
struct JsonPopUpData
|
||||
{
|
||||
std::function<void(std::string&, std::string&, std::string&)> function;
|
||||
std::string key;
|
||||
std::string root_key;
|
||||
std::string value;
|
||||
};
|
||||
|
||||
struct ImgPopUpData
|
||||
{
|
||||
std::function<void(std::string&)> function;
|
||||
std::string value;
|
||||
};
|
||||
|
||||
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);
|
||||
static bool CheckboxAddressVarEx(const char* label, bool val, int addr, int enabled_val, int disabled_val, const char* hint = nullptr);
|
||||
static bool CheckboxBitFlag(const char* label, uint flag, const char* hint = nullptr);
|
||||
static bool CheckboxWithHint(const char* label, bool* state, const char* hint = nullptr);
|
||||
static void DrawHeaders(unsortedMap& data);
|
||||
|
||||
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,
|
||||
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);
|
||||
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 FilterWithHint(const char* label, ImGuiTextFilter& filter, const char* hint);
|
||||
|
||||
static ImVec2 GetSize(short count = 1, bool spacing = true);
|
||||
|
||||
static void HotKey(const char* label, int* key_array);
|
||||
static bool HotKeyPressed(int *hotkey);
|
||||
static std::string GetHotKeyNameString(int *hotkey);
|
||||
|
||||
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 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)
|
||||
{
|
||||
if (ImGui::CollapsingHeader(label))
|
||||
{
|
||||
int val = patch::Get<T>(address, false);;
|
||||
|
||||
int items = 3;
|
||||
|
||||
if (min == def)
|
||||
items = 2;
|
||||
|
||||
ImGui::Columns(items,0,false);
|
||||
ImGui::Text(("Min: " + std::to_string(min)).c_str());
|
||||
|
||||
if (items == 3)
|
||||
{
|
||||
ImGui::NextColumn();
|
||||
ImGui::Text(("Def: " + std::to_string(def)).c_str());
|
||||
}
|
||||
|
||||
ImGui::NextColumn();
|
||||
ImGui::Text(("Max: " + std::to_string(max)).c_str());
|
||||
ImGui::Columns(1);
|
||||
|
||||
ImGui::Spacing();
|
||||
|
||||
if (ImGui::InputInt(("Set value##" + std::string(label)).c_str(), &val))
|
||||
patch::Set<T>(address, val, false);
|
||||
|
||||
ImGui::Spacing();
|
||||
|
||||
if (ImGui::Button(("Minimum##" + std::string(label)).c_str(), Ui::GetSize(items)))
|
||||
patch::Set<T>(address, min, false);
|
||||
|
||||
if (items == 3)
|
||||
{
|
||||
ImGui::SameLine();
|
||||
|
||||
if (ImGui::Button(("Default##" + std::string(label)).c_str(), Ui::GetSize(3)))
|
||||
patch::Set<T>(address, def, false);
|
||||
}
|
||||
|
||||
ImGui::SameLine();
|
||||
|
||||
if (ImGui::Button(("Maximum##" + std::string(label)).c_str(), Ui::GetSize(items)))
|
||||
patch::Set<T>(address, max, false);
|
||||
|
||||
ImGui::Spacing();
|
||||
ImGui::Separator();
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void Ui::EditReference(const char *label,T &address, const int min, const int def, const int max)
|
||||
{
|
||||
if (ImGui::CollapsingHeader(label))
|
||||
{
|
||||
int val = static_cast<int>(address);
|
||||
|
||||
ImGui::Columns(3, 0, false);
|
||||
ImGui::Text(("Min: " + std::to_string(min)).c_str());
|
||||
ImGui::NextColumn();
|
||||
ImGui::Text(("Def: " + std::to_string(def)).c_str());
|
||||
ImGui::NextColumn();
|
||||
ImGui::Text(("Max: " + std::to_string(max)).c_str());
|
||||
ImGui::Columns(1);
|
||||
|
||||
ImGui::Spacing();
|
||||
|
||||
if (ImGui::InputInt(("Set value##" + std::string(label)).c_str(), &val))
|
||||
address = static_cast<float>(val);
|
||||
|
||||
ImGui::Spacing();
|
||||
|
||||
if (ImGui::Button(("Minimum##" + std::string(label)).c_str(), Ui::GetSize(3)))
|
||||
address = static_cast<float>(min);
|
||||
|
||||
ImGui::SameLine();
|
||||
|
||||
if (ImGui::Button(("Default##" + std::string(label)).c_str(), Ui::GetSize(3)))
|
||||
address = static_cast<float>(def);
|
||||
|
||||
ImGui::SameLine();
|
||||
|
||||
if (ImGui::Button(("Maximum##" + std::string(label)).c_str(), Ui::GetSize(3)))
|
||||
address = static_cast<float>(max);
|
||||
|
||||
ImGui::Spacing();
|
||||
ImGui::Separator();
|
||||
}
|
||||
}
|
191
CheatMenu/Util.cpp
Normal file
@ -0,0 +1,191 @@
|
||||
#include "pch.h"
|
||||
#include "Util.h"
|
||||
#include "external/imgui/stb_image.h"
|
||||
|
||||
void Util::ClearCharTasksVehCheck(CPed* ped)
|
||||
{
|
||||
uint hped = CPools::GetPedRef(ped);
|
||||
uint hveh = NULL;
|
||||
|
||||
if (Command<Commands::IS_CHAR_IN_ANY_CAR>(hped))
|
||||
hveh = CPools::GetVehicleRef(ped->m_pVehicle);
|
||||
|
||||
Command<Commands::CLEAR_CHAR_TASKS_IMMEDIATELY>(hped);
|
||||
|
||||
if (hveh)
|
||||
Command<Commands::TASK_WARP_CHAR_INTO_CAR_AS_DRIVER>(hped, hveh);
|
||||
}
|
||||
|
||||
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 : std::experimental::filesystem::recursive_directory_iterator(path))
|
||||
{
|
||||
|
||||
if (p.path().extension() == file_ext)
|
||||
{
|
||||
store_vec.push_back(std::make_unique<TextureStructure>());
|
||||
HRESULT hr = -1;
|
||||
|
||||
if (Globals::renderer == Render_DirectX9)
|
||||
hr = D3DXCreateTextureFromFileA(GetD3DDevice(), p.path().string().c_str(), &store_vec.back().get()->texture9);
|
||||
|
||||
if (Globals::renderer == Render_DirectX11)
|
||||
{
|
||||
if (LoadTextureFromFileDx11(p.path().string().c_str(), &store_vec.back().get()->texture11))
|
||||
hr = S_OK;
|
||||
}
|
||||
|
||||
|
||||
if (hr == S_OK)
|
||||
{
|
||||
store_vec.back().get()->file_name = p.path().stem().string();
|
||||
store_vec.back().get()->category_name = folder;
|
||||
}
|
||||
else
|
||||
{
|
||||
flog << "Couldn't load image " << p.path().stem().string() << std::endl;
|
||||
store_vec.pop_back();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
folder = p.path().stem().string();
|
||||
category_vec.push_back(folder);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool Util::LoadTextureFromFileDx11(const char* filename, ID3D11ShaderResourceView** out_srv)
|
||||
{
|
||||
// Load from disk into a raw RGBA buffer
|
||||
int image_width = 0;
|
||||
int image_height = 0;
|
||||
unsigned char* image_data = stbi_load(filename, &image_width, &image_height, NULL, 4);
|
||||
if (image_data == NULL)
|
||||
return false;
|
||||
|
||||
// Create texture
|
||||
D3D11_TEXTURE2D_DESC desc;
|
||||
ZeroMemory(&desc, sizeof(desc));
|
||||
desc.Width = image_width;
|
||||
desc.Height = image_height;
|
||||
desc.MipLevels = 1;
|
||||
desc.ArraySize = 1;
|
||||
desc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
|
||||
desc.SampleDesc.Count = 1;
|
||||
desc.Usage = D3D11_USAGE_DEFAULT;
|
||||
desc.BindFlags = D3D11_BIND_SHADER_RESOURCE;
|
||||
desc.CPUAccessFlags = 0;
|
||||
|
||||
ID3D11Texture2D *pTexture = NULL;
|
||||
D3D11_SUBRESOURCE_DATA subResource;
|
||||
subResource.pSysMem = image_data;
|
||||
subResource.SysMemPitch = desc.Width * 4;
|
||||
subResource.SysMemSlicePitch = 0;
|
||||
|
||||
Globals::device11->CreateTexture2D(&desc, &subResource, &pTexture);
|
||||
|
||||
// Create texture view
|
||||
D3D11_SHADER_RESOURCE_VIEW_DESC srvDesc;
|
||||
ZeroMemory(&srvDesc, sizeof(srvDesc));
|
||||
srvDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
|
||||
srvDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2D;
|
||||
srvDesc.Texture2D.MipLevels = desc.MipLevels;
|
||||
srvDesc.Texture2D.MostDetailedMip = 0;
|
||||
Globals::device11->CreateShaderResourceView(pTexture, &srvDesc, out_srv);
|
||||
pTexture->Release();
|
||||
|
||||
stbi_image_free(image_data);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Util::IsOnMission()
|
||||
{
|
||||
return FindPlayerPed()->CanPlayerStartMission() && !*(patch::Get<char*>(0x5D5380, false) + CTheScripts::OnAMissionFlag);
|
||||
}
|
||||
|
||||
std::string Util::GetLocationName(CVector *pos)
|
||||
{
|
||||
int hplayer = CPools::GetPedRef(FindPlayerPed());
|
||||
int interior = 0;
|
||||
Command<Commands::GET_AREA_VISIBLE>(&interior);
|
||||
|
||||
std::string town = "San Andreas";
|
||||
int city;
|
||||
Command<Commands::GET_CITY_PLAYER_IS_IN>(&hplayer, &city);
|
||||
|
||||
switch (city)
|
||||
{
|
||||
case 0:
|
||||
town = "CS";
|
||||
break;
|
||||
case 1:
|
||||
town = "LS";
|
||||
break;
|
||||
case 2:
|
||||
town = "SF";
|
||||
break;
|
||||
case 3:
|
||||
town = "LV";
|
||||
break;
|
||||
}
|
||||
|
||||
if (interior == 0)
|
||||
return CTheZones::FindSmallestZoneForPosition(*pos, true)->GetTranslatedName() + std::string(", ") + town;
|
||||
else
|
||||
return std::string("Interior ") + std::to_string(interior) + ", " + town;
|
||||
|
||||
}
|
||||
|
||||
int Util::GetLargestGangInZone()
|
||||
{
|
||||
int gang_id = 0, max_density = 0;
|
||||
|
||||
for (int i = 0; i != 10; ++i)
|
||||
{
|
||||
CVector pos = FindPlayerPed()->GetPosition();
|
||||
CZone *zone = &CZone();
|
||||
|
||||
CZoneExtraInfo *zone_info = CTheZones::GetZoneInfo(&pos, &zone);
|
||||
int density = zone_info->m_nGangDensity[i];
|
||||
|
||||
if (density > max_density)
|
||||
{
|
||||
max_density = density;
|
||||
gang_id = i;
|
||||
}
|
||||
}
|
||||
|
||||
return gang_id;
|
||||
}
|
||||
|
||||
// partial implemention of opcode 0AB5 (STORE_CLOSEST_ENTITIES)
|
||||
// https://github.com/cleolibrary/CLEO4/blob/916d400f4a731ba1dd0ff16e52bdb056f42b7038/source/CCustomOpcodeSystem.cpp#L1671
|
||||
CVehicle* Util::GetClosestVehicle(CPlayerPed* player)
|
||||
{
|
||||
CPedIntelligence *pedintel;
|
||||
if (player && (pedintel = player->m_pIntelligence))
|
||||
{
|
||||
CVehicle *veh = nullptr;
|
||||
for (int i = 0; i < 16; i++)
|
||||
{
|
||||
veh = (CVehicle*)pedintel->m_vehicleScanner.m_apEntities[i];
|
||||
if (veh && !veh->m_nVehicleFlags.bFadeOut)
|
||||
break;
|
||||
veh = nullptr;
|
||||
}
|
||||
|
||||
return veh;
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void Util::RainbowValues(int &r, int&g, int &b, float speed)
|
||||
{
|
||||
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;
|
||||
}
|
16
CheatMenu/Util.h
Normal file
@ -0,0 +1,16 @@
|
||||
#pragma once
|
||||
class Util
|
||||
{
|
||||
private:
|
||||
static bool LoadTextureFromFileDx11(const char* filename, ID3D11ShaderResourceView** out_srv);
|
||||
|
||||
public:
|
||||
static void ClearCharTasksVehCheck(CPed* ped);
|
||||
static CVehicle* GetClosestVehicle(CPlayerPed* player);
|
||||
static int GetLargestGangInZone();
|
||||
static void LoadTexturesInDirRecursive(const char * path, const char * file_ext, std::vector<std::string>& category_vec, std::vector<std::unique_ptr<TextureStructure>> &store_vec);
|
||||
static bool IsOnMission();
|
||||
static std::string GetLocationName(CVector *pos);
|
||||
static void RainbowValues(int &r, int&g, int &b, float speed);
|
||||
};
|
||||
|
209
CheatMenu/VKeys.h
Normal file
@ -0,0 +1,209 @@
|
||||
#pragma once
|
||||
|
||||
#define VK_KEY_0 0x30
|
||||
#define VK_KEY_1 0x31
|
||||
#define VK_KEY_2 0x32
|
||||
#define VK_KEY_3 0x33
|
||||
#define VK_KEY_4 0x34
|
||||
#define VK_KEY_5 0x35
|
||||
#define VK_KEY_6 0x36
|
||||
#define VK_KEY_7 0x37
|
||||
#define VK_KEY_8 0x38
|
||||
#define VK_KEY_9 0x39
|
||||
#define VK_KEY_A 0x41
|
||||
#define VK_KEY_B 0x42
|
||||
#define VK_KEY_C 0x43
|
||||
#define VK_KEY_D 0x44
|
||||
#define VK_KEY_E 0x45
|
||||
#define VK_KEY_F 0x46
|
||||
#define VK_KEY_G 0x47
|
||||
#define VK_KEY_H 0x48
|
||||
#define VK_KEY_I 0x49
|
||||
#define VK_KEY_J 0x4A
|
||||
#define VK_KEY_K 0x4B
|
||||
#define VK_KEY_L 0x4C
|
||||
#define VK_KEY_M 0x4D
|
||||
#define VK_KEY_N 0x4E
|
||||
#define VK_KEY_O 0x4F
|
||||
#define VK_KEY_P 0x50
|
||||
#define VK_KEY_Q 0x51
|
||||
#define VK_KEY_R 0x52
|
||||
#define VK_KEY_S 0x53
|
||||
#define VK_KEY_T 0x54
|
||||
#define VK_KEY_U 0x55
|
||||
#define VK_KEY_V 0x56
|
||||
#define VK_KEY_W 0x57
|
||||
#define VK_KEY_X 0x58
|
||||
#define VK_KEY_Y 0x59
|
||||
#define VK_KEY_Z 0x5A
|
||||
|
||||
|
||||
static std::string key_names[]
|
||||
{
|
||||
"LMB",
|
||||
"RMB",
|
||||
"Cancel",
|
||||
"MMB",
|
||||
"X1MB",
|
||||
"X2MB",
|
||||
"Unknown1",
|
||||
"Back",
|
||||
"Tab",
|
||||
"Reserved1",
|
||||
"Reserved2",
|
||||
"Clear",
|
||||
"Enter",
|
||||
"Unknown2",
|
||||
"Unknown3",
|
||||
"Shift",
|
||||
"Ctrl",
|
||||
"Alt",
|
||||
"Pause",
|
||||
"Capslock",
|
||||
"IME",
|
||||
"IME2",
|
||||
"IME3",
|
||||
"Unknown4",
|
||||
"IME4",
|
||||
"Unknown5",
|
||||
"Esc",
|
||||
"IME5"
|
||||
"IME6",
|
||||
"IME7",
|
||||
"IME8",
|
||||
"IME9",
|
||||
"Space",
|
||||
"Pup",
|
||||
"Pdown",
|
||||
"End",
|
||||
"Home",
|
||||
"Left",
|
||||
"Up",
|
||||
"Right",
|
||||
"Down",
|
||||
"Select",
|
||||
"Print",
|
||||
"Execute",
|
||||
"Print Screen",
|
||||
"INS",
|
||||
"Del",
|
||||
"Help",
|
||||
"0",
|
||||
"1",
|
||||
"2",
|
||||
"3",
|
||||
"4",
|
||||
"5",
|
||||
"6",
|
||||
"7",
|
||||
"8",
|
||||
"9",
|
||||
"Unknown6",
|
||||
"Unknown7",
|
||||
"Unknown8",
|
||||
"Unknown9",
|
||||
"Unknown10",
|
||||
"Unknown11",
|
||||
"Unknown12",
|
||||
"A",
|
||||
"B",
|
||||
"C",
|
||||
"D",
|
||||
"E",
|
||||
"F",
|
||||
"G",
|
||||
"H",
|
||||
"I",
|
||||
"J",
|
||||
"K",
|
||||
"L",
|
||||
"M",
|
||||
"N",
|
||||
"O",
|
||||
"P",
|
||||
"Q",
|
||||
"R",
|
||||
"S",
|
||||
"T",
|
||||
"U",
|
||||
"V",
|
||||
"W",
|
||||
"X",
|
||||
"Y",
|
||||
"Z",
|
||||
"LWin",
|
||||
"RWin",
|
||||
"Apps",
|
||||
"Unknown11",
|
||||
"Sleep",
|
||||
"Numpad 0",
|
||||
"Numpad 1",
|
||||
"Numpad 2",
|
||||
"Numpad 3",
|
||||
"Numpad 4",
|
||||
"Numpad 5",
|
||||
"Numpad 6",
|
||||
"Numpad 7",
|
||||
"Numpad 8",
|
||||
"Numpad 9",
|
||||
"Multiply",
|
||||
"Add",
|
||||
"Separator",
|
||||
"Substract",
|
||||
"Decimal",
|
||||
"Divide",
|
||||
"F1",
|
||||
"F2",
|
||||
"F3",
|
||||
"F4",
|
||||
"F5",
|
||||
"F6",
|
||||
"F7",
|
||||
"F8",
|
||||
"F9",
|
||||
"F10",
|
||||
"F11",
|
||||
"F12",
|
||||
"F13",
|
||||
"F14",
|
||||
"F15",
|
||||
"F16",
|
||||
"F17",
|
||||
"F18",
|
||||
"F19",
|
||||
"F20",
|
||||
"F21",
|
||||
"F22",
|
||||
"F23",
|
||||
"F24",
|
||||
"Unknown12",
|
||||
"Unknown13",
|
||||
"Unknown14",
|
||||
"Unknown15",
|
||||
"Unknown16",
|
||||
"Unknown17",
|
||||
"Unknown18",
|
||||
"Numlock",
|
||||
"Scroll",
|
||||
"Unknown19",
|
||||
"Unknown20",
|
||||
"Unknown21",
|
||||
"Unknown22",
|
||||
"Unknown23",
|
||||
"Unknown24",
|
||||
"Unknown25",
|
||||
"Unknown26",
|
||||
"Unknown27",
|
||||
"Unknown28",
|
||||
"Unknown29",
|
||||
"Unknown30",
|
||||
"Unknown31",
|
||||
"Unknown32",
|
||||
"Unknown33",
|
||||
"LShift",
|
||||
"RShift",
|
||||
"LCtrl",
|
||||
"RCtrl",
|
||||
"LMenu",
|
||||
"RMenu"
|
||||
};
|
1144
CheatMenu/Vehicle.cpp
Normal file
91
CheatMenu/Vehicle.h
Normal file
@ -0,0 +1,91 @@
|
||||
#include "NeonAPI.h"
|
||||
#include "Paint.h"
|
||||
|
||||
#pragma once
|
||||
class Vehicle : NeonAPI, Paint
|
||||
{
|
||||
private:
|
||||
static bool dont_fall_bike;
|
||||
static bool veh_engine;
|
||||
static bool veh_heavy;
|
||||
static bool veh_invisible;
|
||||
static bool veh_lights;
|
||||
static bool veh_no_dmg;
|
||||
static bool veh_watertight;
|
||||
|
||||
static int door_menu_button;
|
||||
static std::string door_names[6];
|
||||
|
||||
static bool lock_speed;
|
||||
static float lock_speed_val;
|
||||
|
||||
static std::map<int, std::string> vehicle_ide;
|
||||
static std::vector<std::vector<float>> carcols_color_values;
|
||||
static std::map<std::string, std::vector<int>> carcols_car_data;
|
||||
|
||||
struct color
|
||||
{
|
||||
static bool material_filter;
|
||||
static int radio_btn;
|
||||
static bool show_all;
|
||||
static float color_picker[3];
|
||||
};
|
||||
|
||||
struct neon
|
||||
{
|
||||
static float color_picker[3];
|
||||
static bool rainbow;
|
||||
static uint rainbow_timer;
|
||||
static bool traffic;
|
||||
static uint traffic_timer;
|
||||
static std::uniform_int_distribution<> random_val;
|
||||
};
|
||||
|
||||
struct spawner
|
||||
{
|
||||
static ImGuiTextFilter filter;
|
||||
static std::string selected_item;
|
||||
static std::vector<std::string> search_categories;
|
||||
static std::vector<std::unique_ptr<TextureStructure>> image_vec;
|
||||
static bool spawn_inside;
|
||||
static bool spawn_in_air;
|
||||
static char license_text[9];
|
||||
};
|
||||
|
||||
struct texture9
|
||||
{
|
||||
static ImGuiTextFilter filter;
|
||||
static std::string selected_item;
|
||||
static std::vector<std::string> search_categories;
|
||||
static std::vector<std::unique_ptr<TextureStructure>> image_vec;
|
||||
};
|
||||
|
||||
struct tune
|
||||
{
|
||||
static ImGuiTextFilter filter;
|
||||
static std::string selected_item;
|
||||
static std::vector<std::string> search_categories;
|
||||
static std::vector<std::unique_ptr<TextureStructure>> image_vec;
|
||||
};
|
||||
|
||||
struct unlimited_nitro
|
||||
{
|
||||
static bool enabled;
|
||||
static bool comp_added;
|
||||
};
|
||||
|
||||
static void AddComponent(const std::string& component, const bool display_message = true);
|
||||
static void RemoveComponent(const std::string& component, const bool display_message = true);
|
||||
static std::string GetNameFromModel(int model);
|
||||
static void SpawnVehicle(std::string &name);
|
||||
static int GetRandomTrainIdForModel(int model);
|
||||
static void ParseVehiclesIDE();
|
||||
static void ParseCarcolsDAT();
|
||||
static void GenerateHandlingDataFile(int phandling);
|
||||
|
||||
public:
|
||||
Vehicle();
|
||||
~Vehicle();
|
||||
static void Main();
|
||||
};
|
||||
|
327
CheatMenu/Visual.cpp
Normal file
@ -0,0 +1,327 @@
|
||||
#include "pch.h"
|
||||
#include "Visual.h"
|
||||
|
||||
bool Visual::lock_weather = false;
|
||||
int Visual::weather_type_backup = 0;
|
||||
int Visual::timecyc_hour = 8;
|
||||
|
||||
std::vector<std::string> Visual::weather_names{
|
||||
"EXTRASUNNY LA","SUNNY LA","EXTRASUNNY SMOG LA","SUNNY SMOG LA","CLOUDY LA","SUNNY SF","EXTRASUNNY SF","CLOUDY SF","RAINY SF","FOGGY SF",
|
||||
"SUNNY VEGAS","EXTRASUNNY VEGAS","CLOUDY VEGAS","EXTRASUNNY COUNTRYSIDE","SUNNY COUNTRYSIDE","CLOUDY COUNTRYSIDE","RAINY COUNTRYSIDE",
|
||||
"EXTRASUNNY DESERT","SUNNY DESERT","SANDSTORM DESERT","UNDERWATER","EXTRACOLOURS 1","EXTRACOLOURS 2"
|
||||
};
|
||||
|
||||
Visual::Visual()
|
||||
{
|
||||
Events::initGameEvent += []
|
||||
{
|
||||
if (LoadLibraryW(L"timecycle24.asi"))
|
||||
timecyc_hour = 24;
|
||||
};
|
||||
|
||||
Events::processScriptsEvent += []
|
||||
{
|
||||
// Improve this later
|
||||
if (lock_weather)
|
||||
{
|
||||
CWeather::OldWeatherType = weather_type_backup;
|
||||
CWeather::NewWeatherType = weather_type_backup;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Visual::~Visual()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
int Visual::GetCurrentHourTimeId()
|
||||
{
|
||||
uchar hour = CClock::ms_nGameClockHours;
|
||||
|
||||
if (timecyc_hour == 24)
|
||||
return hour;
|
||||
|
||||
if (hour < 5) return 0;
|
||||
if (hour == 5) return 1;
|
||||
|
||||
if (hour == 6) return 2;
|
||||
|
||||
if (7 >= hour && hour < 12) return 2;
|
||||
if (12 >= hour && hour < 19) return 4;
|
||||
|
||||
if (hour == 19) return 5;
|
||||
if (hour == 20 || hour == 21) return 6;
|
||||
if (hour == 22 || hour == 23) return 7;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
bool Visual::TimeCycColorEdit3(const char* label, uchar *r, uchar *g, uchar *b, ImGuiColorEditFlags flags)
|
||||
{
|
||||
bool rtn = false;
|
||||
int val = 23 * GetCurrentHourTimeId() + CWeather::OldWeatherType;
|
||||
|
||||
float col[3]{ r[val] / 255.0f, g[val] / 255.0f, b[val] / 255.0f };
|
||||
|
||||
if (ImGui::ColorEdit3(label, col, flags))
|
||||
{
|
||||
r[val] = col[0] * 255;
|
||||
g[val] = col[1] * 255;
|
||||
b[val] = col[2] * 255;
|
||||
rtn = true;
|
||||
}
|
||||
|
||||
return rtn;
|
||||
}
|
||||
|
||||
bool Visual::TimeCycColorEdit4(const char* label, uchar *r, uchar *g, uchar *b, uchar *a, ImGuiColorEditFlags flags)
|
||||
{
|
||||
bool rtn = false;
|
||||
int val = 23 * GetCurrentHourTimeId() + CWeather::OldWeatherType;
|
||||
|
||||
float col[4]{ r[val] / 255.0f, g[val] / 255.0f, b[val] / 255.0f, a[val] / 255.0f };
|
||||
|
||||
if (ImGui::ColorEdit4(label, col, flags))
|
||||
{
|
||||
r[val] = col[0] * 255;
|
||||
g[val] = col[1] * 255;
|
||||
b[val] = col[2] * 255;
|
||||
a[val] = col[3] * 255;
|
||||
rtn = true;
|
||||
}
|
||||
|
||||
return rtn;
|
||||
}
|
||||
|
||||
void Visual::GenerateTimecycFile()
|
||||
{
|
||||
std::ofstream file;
|
||||
if (timecyc_hour == 24)
|
||||
file = std::ofstream("timecyc_24h.dat");
|
||||
else
|
||||
file = std::ofstream("timecyc.dat");
|
||||
|
||||
for (uint i = 0; i < weather_names.size(); ++i)
|
||||
{
|
||||
file << "\n\n//////////// " << weather_names[i] << "\n";
|
||||
file << "//\tAmb\t\t\t\t\tAmb Obj \t\t\t\tDir \t\t\t\t\tSky top\t\t\t\tSky bot\t\t\t\tSunCore\t\t\t\t\tSunCorona\t\t\tSunSz\tSprSz\tSprBght\t\tShdw\tLightShd\tPoleShd\t\tFarClp\t\tFogSt\tLightOnGround\tLowCloudsRGB\tBottomCloudRGB\t\tWaterRGBA\t\t\t\tARGB1\t\t\t\t\tARGB2\t\t\tCloudAlpha\t\tIntensityLimit\t\tWaterFogAlpha\tDirMult \n\n";
|
||||
|
||||
for (int j = 0; j < timecyc_hour; ++j)
|
||||
{
|
||||
if (timecyc_hour == 24)
|
||||
{
|
||||
if (j >= 12)
|
||||
file << "// " << j << " PM\n";
|
||||
else
|
||||
file << "// " << j << " AM\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
if (j == 0) file << "// Midnight\n";
|
||||
if (j == 1) file << "// 5 AM\n";
|
||||
if (j == 2) file << "// 6 AM\n";
|
||||
if (j == 3) file << "// 7 AM\n";
|
||||
if (j == 4) file << "// Midday\n";
|
||||
if (j == 5) file << "// 7 PM\n";
|
||||
if (j == 6) file << "// 8 PM\n";
|
||||
if (j == 7) file << "// 10 PM\n";
|
||||
}
|
||||
|
||||
int val = 23 * j + i;
|
||||
|
||||
file << "\t" << +CTimeCycle::m_nAmbientRed[val] << " " << +CTimeCycle::m_nAmbientGreen[val] << " " << +CTimeCycle::m_nAmbientBlue[val] << " \t\t"
|
||||
|
||||
<< "\t" << +CTimeCycle::m_nAmbientRed_Obj[val] << " " << +CTimeCycle::m_nAmbientGreen_Obj[val] << " " << +CTimeCycle::m_nAmbientBlue_Obj[val] << " \t\t"
|
||||
|
||||
<< "\t255 255 255\t\t" // unused
|
||||
|
||||
<< "\t" << +CTimeCycle::m_nSkyTopRed[val] << " " << +CTimeCycle::m_nSkyTopGreen[val] << " " << +CTimeCycle::m_nSkyTopBlue[val] << " \t\t"
|
||||
|
||||
<< "\t" << +CTimeCycle::m_nSkyBottomRed[val] << " " << +CTimeCycle::m_nSkyBottomGreen[val] << " " << +CTimeCycle::m_nSkyBottomBlue[val] << " \t\t"
|
||||
|
||||
<< "\t" << +CTimeCycle::m_nSunCoreRed[val] << " " << +CTimeCycle::m_nSunCoreGreen[val] << " " << +CTimeCycle::m_nSunCoreBlue[val] << " \t\t"
|
||||
|
||||
<< "\t" << +CTimeCycle::m_nSunCoronaRed[val] << " " << +CTimeCycle::m_nSunCoronaGreen[val] << " " << +CTimeCycle::m_nSunCoronaBlue[val] << " \t\t"
|
||||
|
||||
<< "\t" << (+CTimeCycle::m_fSunSize[val] - 0.5f) / 10.0f << " " << (+CTimeCycle::m_fSpriteSize[val] - 0.5f) / 10.0f << " " << (+CTimeCycle::m_fSpriteBrightness[val] - 0.5f) / 10.0f << " \t\t"
|
||||
|
||||
<< "\t" << +CTimeCycle::m_nShadowStrength[val] << " " << +CTimeCycle::m_nLightShadowStrength[val] << " " << +CTimeCycle::m_nPoleShadowStrength[val] << " \t\t"
|
||||
|
||||
<< "\t" << +CTimeCycle::m_fFarClip[val] << " " << +CTimeCycle::m_fFogStart[val] << " " << (+CTimeCycle::m_fLightsOnGroundBrightness[val] - 0.5) / 10.0f << " \t\t"
|
||||
|
||||
<< "\t" << +CTimeCycle::m_nLowCloudsRed[val] << " " << +CTimeCycle::m_nLowCloudsGreen[val] << " " << +CTimeCycle::m_nLowCloudsBlue[val] << " \t\t"
|
||||
|
||||
<< "\t" << +CTimeCycle::m_nFluffyCloudsBottomRed[val] << " " << +CTimeCycle::m_nFluffyCloudsBottomGreen[val] << " " << +CTimeCycle::m_nFluffyCloudsBottomBlue[val] << " \t\t"
|
||||
|
||||
<< "\t" << +CTimeCycle::m_fWaterRed[val] << " " << +CTimeCycle::m_fWaterGreen[val] << " " << +CTimeCycle::m_fWaterBlue[val] << " " << +CTimeCycle::m_fWaterAlpha[val] << " \t\t"
|
||||
|
||||
<< "\t" << +CTimeCycle::m_fPostFx1Alpha[val] << " " << +CTimeCycle::m_fPostFx1Red[val] << " " << +CTimeCycle::m_fPostFx1Green[val] << " " << +CTimeCycle::m_fPostFx1Blue[val] << " \t\t"
|
||||
|
||||
<< "\t" << +CTimeCycle::m_fPostFx2Alpha[val] << " " << +CTimeCycle::m_fPostFx2Red[val] << " " << +CTimeCycle::m_fPostFx2Green[val] << " " << +CTimeCycle::m_fPostFx2Blue[val] << " \t\t"
|
||||
|
||||
<< "\t" << +CTimeCycle::m_fCloudAlpha[val] << " " << +CTimeCycle::m_nHighLightMinIntensity[val] << " " << +CTimeCycle::m_nWaterFogAlpha[val] << " " << +CTimeCycle::m_nDirectionalMult[val] / 100.0 << " \t\t" << std::endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Visual::Main()
|
||||
{
|
||||
if (ImGui::BeginTabBar("Visual", ImGuiTabBarFlags_NoTooltip + ImGuiTabBarFlags_FittingPolicyScroll))
|
||||
{
|
||||
if (ImGui::BeginTabItem("Checkboxes"))
|
||||
{
|
||||
ImGui::Spacing();
|
||||
ImGui::Columns(2, 0, false);
|
||||
Ui::CheckboxAddress("Armour border", 0x589123);
|
||||
Ui::CheckboxAddress("Armour percentage", 0x589125);
|
||||
Ui::CheckboxAddress("Breath border", 0x589207);
|
||||
Ui::CheckboxAddress("Breath percentage", 0x589209);
|
||||
Ui::CheckboxAddress("Gray radar", 0xA444A4);
|
||||
Ui::CheckboxAddress("Health border", 0x589353);
|
||||
Ui::CheckboxAddress("Health percentage", 0x589355);
|
||||
|
||||
ImGui::NextColumn();
|
||||
|
||||
if (Ui::CheckboxWithHint("Hide area names", &CHud::bScriptDontDisplayAreaName))
|
||||
Command<Commands::DISPLAY_ZONE_NAMES>(!CHud::bScriptDontDisplayAreaName);
|
||||
|
||||
if (Ui::CheckboxWithHint("Hide hud", &CHud::m_Wants_To_Draw_Hud))
|
||||
Command<Commands::DISPLAY_HUD>(!CHud::m_Wants_To_Draw_Hud);
|
||||
|
||||
if (Ui::CheckboxWithHint("Hide veh names", &CHud::bScriptDontDisplayVehicleName))
|
||||
Command<Commands::DISPLAY_CAR_NAMES>(!CHud::bScriptDontDisplayVehicleName);
|
||||
|
||||
if (Ui::CheckboxWithHint("Hide radar", &CHud::bScriptDontDisplayRadar))
|
||||
Command<Commands::DISPLAY_RADAR>(!CHud::bScriptDontDisplayRadar);
|
||||
|
||||
Ui::CheckboxAddressEx("Hide wanted level", 0x58DD1B, 0x90, 1);
|
||||
if (Ui::CheckboxWithHint("Lock weather", &lock_weather))
|
||||
weather_type_backup = CWeather::OldWeatherType;
|
||||
|
||||
ImGui::Columns(1);
|
||||
ImGui::EndTabItem();
|
||||
}
|
||||
if (ImGui::BeginTabItem("Menus"))
|
||||
{
|
||||
Ui::ColorPickerAddress("Health bar + debt color", 0xBAB22C, ImVec4(180,25,29,255));
|
||||
Ui::ColorPickerAddress("Main menu title border color", 0xBAB240, ImVec4(0,0,0,255));
|
||||
Ui::ColorPickerAddress("Money color", 0xBAB230, ImVec4(54,104,44,255));
|
||||
Ui::EditRadioButtonAddressEx("Money font outline", 0x58F58D, std::vector<Ui::NamedValue>{{ "No outline", 0 }, { "Thin outline" ,1 }, { "Default outline" ,2 }});
|
||||
Ui::EditRadioButtonAddressEx("Money font style", 0x58F57F, std::vector<Ui::NamedValue>{ { "Style 1", 1 }, { "Style 2" ,2 }, { "Default style" ,3 }});
|
||||
Ui::EditAddress<float>("Radar Height", 0x866B74, 0, 76, 999);
|
||||
Ui::EditAddress<float>("Radar Width", 0x866B78, 0, 94, 999);
|
||||
Ui::EditAddress<float>("Radar X position", 0x858A10, -999, 40, 999);
|
||||
Ui::EditAddress<float>("Radar Y position", 0x866B70, -999, 104, 999);
|
||||
Ui::EditAddress<int>("Radar zoom", 0xA444A3, 0, 0, 170);
|
||||
Ui::ColorPickerAddress("Radio station color", 0xBAB24C, ImVec4(150,150,150,255));
|
||||
Ui::ColorPickerAddress("Styled text color", 0xBAB258, ImVec4(226,192,99,255));
|
||||
Ui::ColorPickerAddress("Text color", 0xBAB234, ImVec4(50,60,127,255));
|
||||
Ui::EditRadioButtonAddressEx("Wanted star border", 0x58DD41, std::vector<Ui::NamedValue>{ { "No border", 0 }, { "Default" ,1 }, { "Bold border" ,2 }});
|
||||
Ui::ColorPickerAddress("Wanted star color + some text", 0xBAB244, ImVec4(144,98,16,255));
|
||||
|
||||
ImGui::EndTabItem();
|
||||
}
|
||||
|
||||
if (ImGui::BeginTabItem("Timecyc"))
|
||||
{
|
||||
ImGui::Spacing();
|
||||
if (ImGui::Button("Generate timecyc file", Ui::GetSize(2)))
|
||||
{
|
||||
GenerateTimecycFile();
|
||||
CHud::SetHelpMessage("File generated", false, false, false);
|
||||
}
|
||||
ImGui::SameLine();
|
||||
if (ImGui::Button("Reset timecyc", Ui::GetSize(2)))
|
||||
{
|
||||
CTimeCycle::Initialise();
|
||||
CHud::SetHelpMessage("Timecyc reset", false, false, false);
|
||||
}
|
||||
ImGui::Spacing();
|
||||
|
||||
int weather = CWeather::OldWeatherType;
|
||||
if (Ui::ListBox("Current weather", weather_names, weather))
|
||||
CWeather::OldWeatherType = weather;
|
||||
|
||||
weather = CWeather::NewWeatherType;
|
||||
if (Ui::ListBox("Next weather", weather_names, weather))
|
||||
CWeather::NewWeatherType = weather;
|
||||
|
||||
ImGui::Spacing();
|
||||
int hour = CClock::ms_nGameClockHours;
|
||||
int minute = CClock::ms_nGameClockMinutes;
|
||||
|
||||
if (ImGui::InputInt("Hour", &hour))
|
||||
{
|
||||
if (hour < 0) hour = 23;
|
||||
if (hour > 23) hour = 0;
|
||||
CClock::ms_nGameClockHours = hour;
|
||||
}
|
||||
|
||||
if (ImGui::InputInt("Minute", &minute))
|
||||
{
|
||||
if (minute < 0) minute = 59;
|
||||
if (minute > 59) minute = 0;
|
||||
CClock::ms_nGameClockMinutes = minute;
|
||||
}
|
||||
ImGui::Spacing();
|
||||
if (ImGui::BeginTabBar("Timecyc subtab", ImGuiTabBarFlags_NoTooltip + ImGuiTabBarFlags_FittingPolicyScroll))
|
||||
{
|
||||
if (ImGui::BeginTabItem("Colors"))
|
||||
{
|
||||
ImGui::BeginChild("TimecycColors");
|
||||
ImGui::Spacing();
|
||||
|
||||
TimeCycColorEdit3("Ambient", CTimeCycle::m_nAmbientRed, CTimeCycle::m_nAmbientGreen, CTimeCycle::m_nAmbientBlue);
|
||||
TimeCycColorEdit3("Ambient obj", CTimeCycle::m_nAmbientRed_Obj, CTimeCycle::m_nAmbientGreen_Obj, CTimeCycle::m_nAmbientBlue_Obj);
|
||||
TimeCycColorEdit3("Fluffy clouds", CTimeCycle::m_nFluffyCloudsBottomRed , CTimeCycle::m_nFluffyCloudsBottomGreen, CTimeCycle::m_nFluffyCloudsBottomBlue);
|
||||
TimeCycColorEdit3("Low clouds", CTimeCycle::m_nLowCloudsRed, CTimeCycle::m_nLowCloudsGreen, CTimeCycle::m_nLowCloudsBlue);
|
||||
|
||||
TimeCycColorEdit4("Postfx 1", CTimeCycle::m_fPostFx1Red, CTimeCycle::m_fPostFx1Green, CTimeCycle::m_fPostFx1Blue, CTimeCycle::m_fPostFx1Alpha);
|
||||
TimeCycColorEdit4("Postfx 2", CTimeCycle::m_fPostFx2Red, CTimeCycle::m_fPostFx2Green, CTimeCycle::m_fPostFx2Blue, CTimeCycle::m_fPostFx1Alpha);
|
||||
|
||||
TimeCycColorEdit3("Sky bottom", CTimeCycle::m_nSkyBottomRed, CTimeCycle::m_nSkyBottomGreen, CTimeCycle::m_nSkyBottomBlue);
|
||||
TimeCycColorEdit3("Sun core", CTimeCycle::m_nSunCoreRed, CTimeCycle::m_nSunCoreGreen, CTimeCycle::m_nSunCoreBlue);
|
||||
TimeCycColorEdit3("Sun corona", CTimeCycle::m_nSunCoronaRed, CTimeCycle::m_nSunCoronaGreen, CTimeCycle::m_nSunCoronaBlue);
|
||||
TimeCycColorEdit3("Sky top", CTimeCycle::m_nSkyTopRed, CTimeCycle::m_nSkyTopGreen, CTimeCycle::m_nSkyTopBlue);
|
||||
|
||||
TimeCycColorEdit4("Water", CTimeCycle::m_fWaterRed, CTimeCycle::m_fWaterGreen, CTimeCycle::m_fWaterBlue, CTimeCycle::m_fWaterAlpha);
|
||||
|
||||
ImGui::EndChild();
|
||||
ImGui::EndTabItem();
|
||||
}
|
||||
if (ImGui::BeginTabItem("Misc"))
|
||||
{
|
||||
ImGui::BeginChild("TimecycMisc");
|
||||
|
||||
ImGui::PushItemWidth(ImGui::GetWindowContentRegionWidth() / 2);
|
||||
TimecycSlider("Cloud alpha", CTimeCycle::m_fCloudAlpha, 0, 255);
|
||||
TimecycSlider("Directional mult", CTimeCycle::m_nDirectionalMult , 0, 255);
|
||||
TimecycSlider("Far clip", CTimeCycle::m_fFarClip, 0, 2000);
|
||||
TimecycSlider("Fog start", CTimeCycle::m_fFogStart, 0, 2000);
|
||||
TimecycSlider("High light min intensity", CTimeCycle::m_nHighLightMinIntensity, 0, 255);
|
||||
TimecycSlider("Light on ground brightness", CTimeCycle::m_fLightsOnGroundBrightness, 0, 255);
|
||||
TimecycSlider("Light shadow strength", CTimeCycle::m_nLightShadowStrength, 0, 255);
|
||||
TimecycSlider("Pole shadow strength", CTimeCycle::m_nPoleShadowStrength, 0, 255);
|
||||
TimecycSlider("Shadow strength", CTimeCycle::m_nShadowStrength, 0, 255);
|
||||
TimecycSlider("Sprite brightness", CTimeCycle::m_fSpriteBrightness, -127, 127);
|
||||
TimecycSlider("Sprite size", CTimeCycle::m_fSpriteSize, -127, 127);
|
||||
TimecycSlider("Sun size", CTimeCycle::m_fSunSize, -127, 127);
|
||||
TimecycSlider("Water fog alpha", CTimeCycle::m_nWaterFogAlpha, 0, 255);
|
||||
ImGui::PopItemWidth();
|
||||
|
||||
ImGui::Spacing();
|
||||
ImGui::EndChild();
|
||||
ImGui::EndTabItem();
|
||||
}
|
||||
ImGui::EndTabBar();
|
||||
}
|
||||
|
||||
ImGui::EndTabItem();
|
||||
}
|
||||
|
||||
|
||||
ImGui::EndTabBar();
|
||||
}
|
||||
}
|
30
CheatMenu/Visual.h
Normal file
@ -0,0 +1,30 @@
|
||||
#pragma once
|
||||
class Visual
|
||||
{
|
||||
private:
|
||||
static bool lock_weather;
|
||||
static int weather_type_backup;
|
||||
|
||||
// Timecyc
|
||||
static std::vector<std::string> weather_names;
|
||||
static int timecyc_hour;
|
||||
|
||||
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);
|
||||
template<typename T>
|
||||
static void TimecycSlider(const char* label, T* data, int min, int max);
|
||||
public:
|
||||
Visual();
|
||||
~Visual();
|
||||
static void Main();
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
void Visual::TimecycSlider(const char* label, T* data, int min, int max)
|
||||
{
|
||||
int a = *data;
|
||||
if (ImGui::SliderInt(label, &a, min, max))
|
||||
*data = a;
|
||||
}
|
210
CheatMenu/Weapon.cpp
Normal file
@ -0,0 +1,210 @@
|
||||
#include "pch.h"
|
||||
#include "Weapon.h"
|
||||
|
||||
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;
|
||||
|
||||
CJson Weapon::weapon_json = CJson("weapon");
|
||||
bool Weapon::auto_aim = false;
|
||||
bool Weapon::fast_reload = false;
|
||||
bool Weapon::huge_damage = false;
|
||||
bool Weapon::long_range = false;
|
||||
uchar Weapon::cur_weapon_slot = -1;
|
||||
int Weapon::ammo_count = 99999;
|
||||
|
||||
int Weapon::selected_gang = 0;
|
||||
int Weapon::selected_weapon_count = 0;
|
||||
|
||||
int Weapon::gang_weapons[10][3] =
|
||||
{
|
||||
{WEAPON_PISTOL, WEAPON_MICRO_UZI, WEAPON_UNARMED }, // Ballas
|
||||
{WEAPON_PISTOL, WEAPON_UNARMED, WEAPON_UNARMED}, // Grove
|
||||
{WEAPON_PISTOL, WEAPON_UNARMED, WEAPON_UNARMED}, // Vagos
|
||||
{WEAPON_UNARMED, WEAPON_UNARMED, WEAPON_UNARMED}, // SF Rifa
|
||||
{WEAPON_PISTOL, WEAPON_MICRO_UZI, WEAPON_UNARMED}, // Da Nang Boys
|
||||
{WEAPON_DESERT_EAGLE , WEAPON_UNARMED, WEAPON_UNARMED}, // Mafia
|
||||
{WEAPON_PISTOL, WEAPON_AK47, WEAPON_UNARMED}, // Triads
|
||||
{WEAPON_PISTOL, WEAPON_MICRO_UZI, WEAPON_UNARMED}, // VLA
|
||||
{WEAPON_UNARMED, WEAPON_UNARMED, WEAPON_UNARMED}, // Gang 9
|
||||
{WEAPON_UNARMED, WEAPON_UNARMED, WEAPON_UNARMED}, // Gang 10
|
||||
};
|
||||
|
||||
Weapon::Weapon()
|
||||
{
|
||||
Events::initGameEvent += []
|
||||
{
|
||||
std::string dir_path = (std::string(".\\CheatMenu\\weapons\\")).c_str();
|
||||
Util::LoadTexturesInDirRecursive(dir_path.c_str(), ".jpg", Weapon::search_categories, Weapon::weapon_vec);
|
||||
};
|
||||
|
||||
Events::processScriptsEvent += []
|
||||
{
|
||||
CPlayerPed *player = FindPlayerPed();
|
||||
if (auto_aim)
|
||||
{
|
||||
float mouseX, mouseY;
|
||||
Command<Commands::GET_PC_MOUSE_MOVEMENT>(&mouseX, &mouseY);
|
||||
if (static_cast<int>(mouseY/2) == 0 || static_cast<int>(mouseX/2) == 0)
|
||||
{
|
||||
if (KeyPressed(2))
|
||||
CCamera::m_bUseMouse3rdPerson = false;
|
||||
}
|
||||
else
|
||||
CCamera::m_bUseMouse3rdPerson = true;
|
||||
}
|
||||
|
||||
uchar slot = player->m_nActiveWeaponSlot;
|
||||
if (cur_weapon_slot != slot)
|
||||
{
|
||||
auto weapon_type = player->m_aWeapons[slot].m_nType;
|
||||
CWeaponInfo *pweapon_info = CWeaponInfo::GetWeaponInfo(weapon_type, player->GetWeaponSkill(weapon_type));
|
||||
|
||||
if (huge_damage)
|
||||
pweapon_info->m_nDamage = 1000;
|
||||
|
||||
if (long_range)
|
||||
{
|
||||
pweapon_info->m_fTargetRange = 1000.0f;
|
||||
pweapon_info->m_fWeaponRange = 1000.0f;
|
||||
pweapon_info->m_fAccuracy = 1.0f;
|
||||
}
|
||||
|
||||
cur_weapon_slot = slot;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Weapon::~Weapon()
|
||||
{
|
||||
}
|
||||
|
||||
void Weapon::SetGangWeapon(std::string& weapon_type)
|
||||
{
|
||||
gang_weapons[selected_gang][selected_weapon_count] = std::stoi(weapon_type);
|
||||
CGangs::SetGangWeapons(selected_gang, gang_weapons[selected_gang][0], gang_weapons[selected_gang][1], gang_weapons[selected_gang][2]);
|
||||
}
|
||||
|
||||
void Weapon::GiveWeaponToPlayer(std::string& weapon_type)
|
||||
{
|
||||
CPlayerPed* player = FindPlayerPed();
|
||||
int hplayer = CPools::GetPedRef(player);
|
||||
|
||||
if (weapon_type == "-1") // Jetpack
|
||||
Command<Commands::TASK_JETPACK>(hplayer);
|
||||
else
|
||||
{
|
||||
int iweapon_type = std::stoi(weapon_type);
|
||||
|
||||
int model = NULL;
|
||||
Command<Commands::GET_WEAPONTYPE_MODEL>(iweapon_type, &model);
|
||||
|
||||
CStreaming::RequestModel(model,PRIORITY_REQUEST);
|
||||
CStreaming::LoadAllRequestedModels(false);
|
||||
|
||||
Command<Commands::GIVE_WEAPON_TO_CHAR>(hplayer, iweapon_type, ammo_count);
|
||||
Command<Commands::MARK_MODEL_AS_NO_LONGER_NEEDED>(model);
|
||||
}
|
||||
}
|
||||
|
||||
void Weapon::Main()
|
||||
{
|
||||
CPlayerPed *player = FindPlayerPed();
|
||||
uint hplayer = CPools::GetPedRef(player);
|
||||
|
||||
ImGui::Spacing();
|
||||
if (ImGui::Button("Drop weapon", Ui::GetSize(3)))
|
||||
{
|
||||
float x, y, z;
|
||||
Command<Commands::GET_OFFSET_FROM_CHAR_IN_WORLD_COORDS>(hplayer, 0.0, 3.0, 0.0, &x, &y, &z);
|
||||
auto type = player->m_aWeapons[player->m_nActiveWeaponSlot].m_nType;
|
||||
|
||||
if (type)
|
||||
{
|
||||
int model =0, pickup = 0;
|
||||
|
||||
Command<Commands::GET_WEAPONTYPE_MODEL>(type, &model);
|
||||
Command<Commands::CREATE_PICKUP_WITH_AMMO>(model, 3, 999, x, y, z, &pickup);
|
||||
|
||||
Command<Commands::REMOVE_WEAPON_FROM_CHAR>(hplayer, type);
|
||||
}
|
||||
}
|
||||
ImGui::SameLine();
|
||||
if (ImGui::Button("Remove all", Ui::GetSize(3)))
|
||||
Command<Commands::REMOVE_ALL_CHAR_WEAPONS>(hplayer);
|
||||
|
||||
ImGui::SameLine();
|
||||
if (ImGui::Button("Remove current", Ui::GetSize(3)))
|
||||
Command<Commands::REMOVE_WEAPON_FROM_CHAR>(hplayer, player->m_aWeapons[player->m_nActiveWeaponSlot].m_nType);
|
||||
|
||||
ImGui::Spacing();
|
||||
|
||||
if (ImGui::BeginTabBar("Ped", ImGuiTabBarFlags_NoTooltip + ImGuiTabBarFlags_FittingPolicyScroll))
|
||||
{
|
||||
if (ImGui::BeginTabItem("Checkboxes"))
|
||||
{
|
||||
ImGui::Spacing();
|
||||
ImGui::BeginChild("CheckboxesChild");
|
||||
ImGui::Columns(2, 0, false);
|
||||
|
||||
Ui::CheckboxWithHint("Auto aim", &auto_aim, "Enables aim assist on keyboard\n\nQ = left E = right");
|
||||
if (Ui::CheckboxWithHint("Huge damage", &huge_damage))
|
||||
{
|
||||
if (!huge_damage)
|
||||
CWeaponInfo::LoadWeaponData();
|
||||
}
|
||||
if (Ui::CheckboxWithHint("Fast reload", &fast_reload))
|
||||
Command<Commands::SET_PLAYER_FAST_RELOAD>(hplayer, fast_reload);
|
||||
|
||||
ImGui::NextColumn();
|
||||
Ui::CheckboxAddress("Infinite ammo", 0x969178);
|
||||
if (Ui::CheckboxWithHint("Long range", &long_range))
|
||||
{
|
||||
if (!long_range)
|
||||
CWeaponInfo::LoadWeaponData();
|
||||
}
|
||||
ImGui::Columns(1, 0, false);
|
||||
ImGui::EndChild();
|
||||
ImGui::EndTabItem();
|
||||
}
|
||||
if (ImGui::BeginTabItem("Gang weapon editor"))
|
||||
{
|
||||
ImGui::Spacing();
|
||||
Ui::ListBox("Select gang", Ped::gang_names, selected_gang);
|
||||
|
||||
ImGui::Columns(3, 0, false);
|
||||
ImGui::RadioButton("Weap 1", &selected_weapon_count, 0);
|
||||
ImGui::NextColumn();
|
||||
ImGui::RadioButton("Weap 2", &selected_weapon_count, 1);
|
||||
ImGui::NextColumn();
|
||||
ImGui::RadioButton("Weap 3", &selected_weapon_count, 2);
|
||||
ImGui::Columns(1);
|
||||
|
||||
ImGui::Spacing();
|
||||
ImGui::Text((std::string("Current weapon: ") + weapon_json.data[std::to_string(gang_weapons[selected_gang][selected_weapon_count])].get<std::string>()).c_str());
|
||||
ImGui::Spacing();
|
||||
Ui::DrawImages(weapon_vec, ImVec2(65, 65), search_categories, selected_item, filter, SetGangWeapon, nullptr,
|
||||
[](std::string str) {return weapon_json.data[str].get<std::string>(); },
|
||||
[](std::string str) {return str != "-1"; /*Jetpack*/ }
|
||||
);
|
||||
ImGui::EndTabItem();
|
||||
}
|
||||
if (ImGui::BeginTabItem("Spawn"))
|
||||
{
|
||||
ImGui::Spacing();
|
||||
if (ImGui::InputInt("Ammo", &ammo_count))
|
||||
{
|
||||
ammo_count = (ammo_count < 0) ? 0 : ammo_count;
|
||||
ammo_count = (ammo_count > 99999) ? 99999 : ammo_count;
|
||||
}
|
||||
Ui::DrawImages(weapon_vec, ImVec2(65, 65), search_categories, selected_item, filter, GiveWeaponToPlayer, nullptr,
|
||||
[](std::string str) {return weapon_json.data[str].get<std::string>(); },
|
||||
[](std::string str) {return str != "0"; /*Unarmed*/ }
|
||||
);
|
||||
ImGui::EndTabItem();
|
||||
}
|
||||
ImGui::EndTabBar();
|
||||
}
|
||||
}
|
35
CheatMenu/Weapon.h
Normal file
@ -0,0 +1,35 @@
|
||||
#pragma once
|
||||
#include "Ped.h"
|
||||
class Weapon
|
||||
{
|
||||
private:
|
||||
static ImGuiTextFilter filter;
|
||||
static std::string selected_item;
|
||||
static std::vector<std::string> search_categories;
|
||||
static std::vector<std::unique_ptr<TextureStructure>> weapon_vec;
|
||||
|
||||
static CJson weapon_json;
|
||||
|
||||
static bool auto_aim;
|
||||
static bool fast_reload;
|
||||
static bool huge_damage;
|
||||
static bool long_range;
|
||||
|
||||
static int ammo_count;
|
||||
static uchar cur_weapon_slot;
|
||||
|
||||
static int selected_gang;
|
||||
static int selected_weapon_count;
|
||||
static int cur_weapon;
|
||||
static int gang_weapons[10][3];
|
||||
|
||||
friend class Ped;
|
||||
public:
|
||||
Weapon();
|
||||
~Weapon();
|
||||
|
||||
static void Main();
|
||||
static void GiveWeaponToPlayer(std::string& weapon_type);
|
||||
static void SetGangWeapon(std::string& weapon_type);
|
||||
};
|
||||
|
109
CheatMenu/external/imgui/imconfig.h
vendored
Normal file
@ -0,0 +1,109 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
// COMPILE-TIME OPTIONS FOR DEAR IMGUI
|
||||
// Runtime options (clipboard callbacks, enabling various features, etc.) can generally be set via the ImGuiIO structure.
|
||||
// You can use ImGui::SetAllocatorFunctions() before calling ImGui::CreateContext() to rewire memory allocation functions.
|
||||
//-----------------------------------------------------------------------------
|
||||
// A) You may edit imconfig.h (and not overwrite it when updating Dear ImGui, or maintain a patch/rebased branch with your modifications to it)
|
||||
// B) or '#define IMGUI_USER_CONFIG "my_imgui_config.h"' in your project and then add directives in your own file without touching this template.
|
||||
//-----------------------------------------------------------------------------
|
||||
// You need to make sure that configuration settings are defined consistently _everywhere_ Dear ImGui is used, which include the imgui*.cpp
|
||||
// files but also _any_ of your code that uses Dear ImGui. This is because some compile-time options have an affect on data structures.
|
||||
// Defining those options in imconfig.h will ensure every compilation unit gets to see the same data structure layouts.
|
||||
// Call IMGUI_CHECKVERSION() from your .cpp files to verify that the data structures your files are using are matching the ones imgui.cpp is using.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#pragma once
|
||||
|
||||
//---- Define assertion handler. Defaults to calling assert().
|
||||
// If your macro uses multiple statements, make sure is enclosed in a 'do { .. } while (0)' block so it can be used as a single statement.
|
||||
//#define IM_ASSERT(_EXPR) MyAssert(_EXPR)
|
||||
//#define IM_ASSERT(_EXPR) ((void)(_EXPR)) // Disable asserts
|
||||
|
||||
//---- Define attributes of all API symbols declarations, e.g. for DLL under Windows
|
||||
// Using dear imgui via a shared library is not recommended, because of function call overhead and because we don't guarantee backward nor forward ABI compatibility.
|
||||
//#define IMGUI_API __declspec( dllexport )
|
||||
//#define IMGUI_API __declspec( dllimport )
|
||||
|
||||
//---- Don't define obsolete functions/enums/behaviors. Consider enabling from time to time after updating to avoid using soon-to-be obsolete function/names.
|
||||
//#define IMGUI_DISABLE_OBSOLETE_FUNCTIONS
|
||||
|
||||
//---- Disable all of Dear ImGui or don't implement standard windows.
|
||||
// It is very strongly recommended to NOT disable the demo windows during development. Please read comments in imgui_demo.cpp.
|
||||
//#define IMGUI_DISABLE // Disable everything: all headers and source files will be empty.
|
||||
//#define IMGUI_DISABLE_DEMO_WINDOWS // Disable demo windows: ShowDemoWindow()/ShowStyleEditor() will be empty. Not recommended.
|
||||
//#define IMGUI_DISABLE_METRICS_WINDOW // Disable debug/metrics window: ShowMetricsWindow() will be empty.
|
||||
|
||||
//---- Don't implement some functions to reduce linkage requirements.
|
||||
//#define IMGUI_DISABLE_WIN32_DEFAULT_CLIPBOARD_FUNCTIONS // [Win32] Don't implement default clipboard handler. Won't use and link with OpenClipboard/GetClipboardData/CloseClipboard etc.
|
||||
//#define IMGUI_DISABLE_WIN32_DEFAULT_IME_FUNCTIONS // [Win32] Don't implement default IME handler. Won't use and link with ImmGetContext/ImmSetCompositionWindow.
|
||||
//#define IMGUI_DISABLE_WIN32_FUNCTIONS // [Win32] Won't use and link with any Win32 function (clipboard, ime).
|
||||
//#define IMGUI_ENABLE_OSX_DEFAULT_CLIPBOARD_FUNCTIONS // [OSX] Implement default OSX clipboard handler (need to link with '-framework ApplicationServices', this is why this is not the default).
|
||||
//#define IMGUI_DISABLE_DEFAULT_FORMAT_FUNCTIONS // Don't implement ImFormatString/ImFormatStringV so you can implement them yourself (e.g. if you don't want to link with vsnprintf)
|
||||
//#define IMGUI_DISABLE_DEFAULT_MATH_FUNCTIONS // Don't implement ImFabs/ImSqrt/ImPow/ImFmod/ImCos/ImSin/ImAcos/ImAtan2 so you can implement them yourself.
|
||||
//#define IMGUI_DISABLE_DEFAULT_FILE_FUNCTIONS // Don't implement ImFileOpen/ImFileClose/ImFileRead/ImFileWrite so you can implement them yourself if you don't want to link with fopen/fclose/fread/fwrite. This will also disable the LogToTTY() function.
|
||||
//#define IMGUI_DISABLE_DEFAULT_ALLOCATORS // Don't implement default allocators calling malloc()/free() to avoid linking with them. You will need to call ImGui::SetAllocatorFunctions().
|
||||
|
||||
//---- Include imgui_user.h at the end of imgui.h as a convenience
|
||||
//#define IMGUI_INCLUDE_IMGUI_USER_H
|
||||
|
||||
//---- Pack colors to BGRA8 instead of RGBA8 (to avoid converting from one to another)
|
||||
//#define IMGUI_USE_BGRA_PACKED_COLOR
|
||||
|
||||
//---- Use 32-bit for ImWchar (default is 16-bit) to support full unicode code points.
|
||||
//#define IMGUI_USE_WCHAR32
|
||||
|
||||
//---- Avoid multiple STB libraries implementations, or redefine path/filenames to prioritize another version
|
||||
// By default the embedded implementations are declared static and not available outside of imgui cpp files.
|
||||
//#define IMGUI_STB_TRUETYPE_FILENAME "my_folder/stb_truetype.h"
|
||||
//#define IMGUI_STB_RECT_PACK_FILENAME "my_folder/stb_rect_pack.h"
|
||||
//#define IMGUI_DISABLE_STB_TRUETYPE_IMPLEMENTATION
|
||||
//#define IMGUI_DISABLE_STB_RECT_PACK_IMPLEMENTATION
|
||||
|
||||
//---- Unless IMGUI_DISABLE_DEFAULT_FORMAT_FUNCTIONS is defined, use the much faster STB sprintf library implementation of vsnprintf instead of the one from the default C library.
|
||||
// Note that stb_sprintf.h is meant to be provided by the user and available in the include path at compile time. Also, the compatibility checks of the arguments and formats done by clang and GCC will be disabled in order to support the extra formats provided by STB sprintf.
|
||||
// #define IMGUI_USE_STB_SPRINTF
|
||||
|
||||
//---- Define constructor and implicit cast operators to convert back<>forth between your math types and ImVec2/ImVec4.
|
||||
// This will be inlined as part of ImVec2 and ImVec4 class declarations.
|
||||
/*
|
||||
#define IM_VEC2_CLASS_EXTRA \
|
||||
ImVec2(const MyVec2& f) { x = f.x; y = f.y; } \
|
||||
operator MyVec2() const { return MyVec2(x,y); }
|
||||
|
||||
#define IM_VEC4_CLASS_EXTRA \
|
||||
ImVec4(const MyVec4& f) { x = f.x; y = f.y; z = f.z; w = f.w; } \
|
||||
operator MyVec4() const { return MyVec4(x,y,z,w); }
|
||||
*/
|
||||
|
||||
//---- Use 32-bit vertex indices (default is 16-bit) is one way to allow large meshes with more than 64K vertices.
|
||||
// Your renderer back-end will need to support it (most example renderer back-ends support both 16/32-bit indices).
|
||||
// Another way to allow large meshes while keeping 16-bit indices is to handle ImDrawCmd::VtxOffset in your renderer.
|
||||
// Read about ImGuiBackendFlags_RendererHasVtxOffset for details.
|
||||
//#define ImDrawIdx unsigned int
|
||||
|
||||
//---- Override ImDrawCallback signature (will need to modify renderer back-ends accordingly)
|
||||
//struct ImDrawList;
|
||||
//struct ImDrawCmd;
|
||||
//typedef void (*MyImDrawCallback)(const ImDrawList* draw_list, const ImDrawCmd* cmd, void* my_renderer_user_data);
|
||||
//#define ImDrawCallback MyImDrawCallback
|
||||
|
||||
//---- Debug Tools: Macro to break in Debugger
|
||||
// (use 'Metrics->Tools->Item Picker' to pick widgets with the mouse and break into them for easy debugging.)
|
||||
//#define IM_DEBUG_BREAK IM_ASSERT(0)
|
||||
//#define IM_DEBUG_BREAK __debugbreak()
|
||||
|
||||
//---- Debug Tools: Have the Item Picker break in the ItemAdd() function instead of ItemHoverable(),
|
||||
// (which comes earlier in the code, will catch a few extra items, allow picking items other than Hovered one.)
|
||||
// This adds a small runtime cost which is why it is not enabled by default.
|
||||
//#define IMGUI_DEBUG_TOOL_ITEM_PICKER_EX
|
||||
|
||||
//---- Debug Tools: Enable slower asserts
|
||||
//#define IMGUI_DEBUG_PARANOID
|
||||
|
||||
//---- Tip: You can add extra functions within the ImGui:: namespace, here or in your own headers files.
|
||||
/*
|
||||
namespace ImGui
|
||||
{
|
||||
void MyFunction(const char* name, const MyMatrix44& v);
|
||||
}
|
||||
*/
|
10860
CheatMenu/external/imgui/imgui.cpp
vendored
Normal file
2482
CheatMenu/external/imgui/imgui.h
vendored
Normal file
5593
CheatMenu/external/imgui/imgui_demo.cpp
vendored
Normal file
3804
CheatMenu/external/imgui/imgui_draw.cpp
vendored
Normal file
551
CheatMenu/external/imgui/imgui_impl_dx11.cpp
vendored
Normal file
@ -0,0 +1,551 @@
|
||||
// dear imgui: Renderer for DirectX11
|
||||
// This needs to be used along with a Platform Binding (e.g. Win32)
|
||||
|
||||
// Implemented features:
|
||||
// [X] Renderer: User texture binding. Use 'ID3D11ShaderResourceView*' as ImTextureID. Read the FAQ about ImTextureID!
|
||||
// [X] Renderer: Support for large meshes (64k+ vertices) with 16-bit indices.
|
||||
|
||||
// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this.
|
||||
// If you are new to dear imgui, read examples/README.txt and read the documentation at the top of imgui.cpp
|
||||
// https://github.com/ocornut/imgui
|
||||
|
||||
// CHANGELOG
|
||||
// (minor and older changes stripped away, please see git history for details)
|
||||
// 2019-08-01: DirectX11: Fixed code querying the Geometry Shader state (would generally error with Debug layer enabled).
|
||||
// 2019-07-21: DirectX11: Backup, clear and restore Geometry Shader is any is bound when calling ImGui_ImplDX10_RenderDrawData. Clearing Hull/Domain/Compute shaders without backup/restore.
|
||||
// 2019-05-29: DirectX11: Added support for large mesh (64K+ vertices), enable ImGuiBackendFlags_RendererHasVtxOffset flag.
|
||||
// 2019-04-30: DirectX11: Added support for special ImDrawCallback_ResetRenderState callback to reset render state.
|
||||
// 2018-12-03: Misc: Added #pragma comment statement to automatically link with d3dcompiler.lib when using D3DCompile().
|
||||
// 2018-11-30: Misc: Setting up io.BackendRendererName so it can be displayed in the About Window.
|
||||
// 2018-08-01: DirectX11: Querying for IDXGIFactory instead of IDXGIFactory1 to increase compatibility.
|
||||
// 2018-07-13: DirectX11: Fixed unreleased resources in Init and Shutdown functions.
|
||||
// 2018-06-08: Misc: Extracted imgui_impl_dx11.cpp/.h away from the old combined DX11+Win32 example.
|
||||
// 2018-06-08: DirectX11: Use draw_data->DisplayPos and draw_data->DisplaySize to setup projection matrix and clipping rectangle.
|
||||
// 2018-02-16: Misc: Obsoleted the io.RenderDrawListsFn callback and exposed ImGui_ImplDX11_RenderDrawData() in the .h file so you can call it yourself.
|
||||
// 2018-02-06: Misc: Removed call to ImGui::Shutdown() which is not available from 1.60 WIP, user needs to call CreateContext/DestroyContext themselves.
|
||||
// 2016-05-07: DirectX11: Disabling depth-write.
|
||||
|
||||
#include "imgui.h"
|
||||
#include "imgui_impl_dx11.h"
|
||||
|
||||
// DirectX
|
||||
#include <stdio.h>
|
||||
#include <d3d11.h>
|
||||
#include <d3dcompiler.h>
|
||||
#ifdef _MSC_VER
|
||||
#pragma comment(lib, "d3dcompiler") // Automatically link with d3dcompiler.lib as we are using D3DCompile() below.
|
||||
#endif
|
||||
|
||||
// DirectX data
|
||||
static ID3D11Device* g_pd3dDevice = NULL;
|
||||
static ID3D11DeviceContext* g_pd3dDeviceContext = NULL;
|
||||
static IDXGIFactory* g_pFactory = NULL;
|
||||
static ID3D11Buffer* g_pVB = NULL;
|
||||
static ID3D11Buffer* g_pIB = NULL;
|
||||
static ID3D11VertexShader* g_pVertexShader = NULL;
|
||||
static ID3D11InputLayout* g_pInputLayout = NULL;
|
||||
static ID3D11Buffer* g_pVertexConstantBuffer = NULL;
|
||||
static ID3D11PixelShader* g_pPixelShader = NULL;
|
||||
static ID3D11SamplerState* g_pFontSampler = NULL;
|
||||
static ID3D11ShaderResourceView*g_pFontTextureView = NULL;
|
||||
static ID3D11RasterizerState* g_pRasterizerState = NULL;
|
||||
static ID3D11BlendState* g_pBlendState = NULL;
|
||||
static ID3D11DepthStencilState* g_pDepthStencilState = NULL;
|
||||
static int g_VertexBufferSize = 5000, g_IndexBufferSize = 10000;
|
||||
|
||||
struct VERTEX_CONSTANT_BUFFER
|
||||
{
|
||||
float mvp[4][4];
|
||||
};
|
||||
|
||||
static void ImGui_ImplDX11_SetupRenderState(ImDrawData* draw_data, ID3D11DeviceContext* ctx)
|
||||
{
|
||||
// Setup viewport
|
||||
D3D11_VIEWPORT vp;
|
||||
memset(&vp, 0, sizeof(D3D11_VIEWPORT));
|
||||
vp.Width = draw_data->DisplaySize.x;
|
||||
vp.Height = draw_data->DisplaySize.y;
|
||||
vp.MinDepth = 0.0f;
|
||||
vp.MaxDepth = 1.0f;
|
||||
vp.TopLeftX = vp.TopLeftY = 0;
|
||||
ctx->RSSetViewports(1, &vp);
|
||||
|
||||
// Setup shader and vertex buffers
|
||||
unsigned int stride = sizeof(ImDrawVert);
|
||||
unsigned int offset = 0;
|
||||
ctx->IASetInputLayout(g_pInputLayout);
|
||||
ctx->IASetVertexBuffers(0, 1, &g_pVB, &stride, &offset);
|
||||
ctx->IASetIndexBuffer(g_pIB, sizeof(ImDrawIdx) == 2 ? DXGI_FORMAT_R16_UINT : DXGI_FORMAT_R32_UINT, 0);
|
||||
ctx->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST);
|
||||
ctx->VSSetShader(g_pVertexShader, NULL, 0);
|
||||
ctx->VSSetConstantBuffers(0, 1, &g_pVertexConstantBuffer);
|
||||
ctx->PSSetShader(g_pPixelShader, NULL, 0);
|
||||
ctx->PSSetSamplers(0, 1, &g_pFontSampler);
|
||||
ctx->GSSetShader(NULL, NULL, 0);
|
||||
ctx->HSSetShader(NULL, NULL, 0); // In theory we should backup and restore this as well.. very infrequently used..
|
||||
ctx->DSSetShader(NULL, NULL, 0); // In theory we should backup and restore this as well.. very infrequently used..
|
||||
ctx->CSSetShader(NULL, NULL, 0); // In theory we should backup and restore this as well.. very infrequently used..
|
||||
|
||||
// Setup blend state
|
||||
const float blend_factor[4] = { 0.f, 0.f, 0.f, 0.f };
|
||||
ctx->OMSetBlendState(g_pBlendState, blend_factor, 0xffffffff);
|
||||
ctx->OMSetDepthStencilState(g_pDepthStencilState, 0);
|
||||
ctx->RSSetState(g_pRasterizerState);
|
||||
}
|
||||
|
||||
// Render function
|
||||
// (this used to be set in io.RenderDrawListsFn and called by ImGui::Render(), but you can now call this directly from your main loop)
|
||||
void ImGui_ImplDX11_RenderDrawData(ImDrawData* draw_data)
|
||||
{
|
||||
// Avoid rendering when minimized
|
||||
if (draw_data->DisplaySize.x <= 0.0f || draw_data->DisplaySize.y <= 0.0f)
|
||||
return;
|
||||
|
||||
ID3D11DeviceContext* ctx = g_pd3dDeviceContext;
|
||||
|
||||
// Create and grow vertex/index buffers if needed
|
||||
if (!g_pVB || g_VertexBufferSize < draw_data->TotalVtxCount)
|
||||
{
|
||||
if (g_pVB) { g_pVB->Release(); g_pVB = NULL; }
|
||||
g_VertexBufferSize = draw_data->TotalVtxCount + 5000;
|
||||
D3D11_BUFFER_DESC desc;
|
||||
memset(&desc, 0, sizeof(D3D11_BUFFER_DESC));
|
||||
desc.Usage = D3D11_USAGE_DYNAMIC;
|
||||
desc.ByteWidth = g_VertexBufferSize * sizeof(ImDrawVert);
|
||||
desc.BindFlags = D3D11_BIND_VERTEX_BUFFER;
|
||||
desc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
|
||||
desc.MiscFlags = 0;
|
||||
if (g_pd3dDevice->CreateBuffer(&desc, NULL, &g_pVB) < 0)
|
||||
return;
|
||||
}
|
||||
if (!g_pIB || g_IndexBufferSize < draw_data->TotalIdxCount)
|
||||
{
|
||||
if (g_pIB) { g_pIB->Release(); g_pIB = NULL; }
|
||||
g_IndexBufferSize = draw_data->TotalIdxCount + 10000;
|
||||
D3D11_BUFFER_DESC desc;
|
||||
memset(&desc, 0, sizeof(D3D11_BUFFER_DESC));
|
||||
desc.Usage = D3D11_USAGE_DYNAMIC;
|
||||
desc.ByteWidth = g_IndexBufferSize * sizeof(ImDrawIdx);
|
||||
desc.BindFlags = D3D11_BIND_INDEX_BUFFER;
|
||||
desc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
|
||||
if (g_pd3dDevice->CreateBuffer(&desc, NULL, &g_pIB) < 0)
|
||||
return;
|
||||
}
|
||||
|
||||
// Upload vertex/index data into a single contiguous GPU buffer
|
||||
D3D11_MAPPED_SUBRESOURCE vtx_resource, idx_resource;
|
||||
if (ctx->Map(g_pVB, 0, D3D11_MAP_WRITE_DISCARD, 0, &vtx_resource) != S_OK)
|
||||
return;
|
||||
if (ctx->Map(g_pIB, 0, D3D11_MAP_WRITE_DISCARD, 0, &idx_resource) != S_OK)
|
||||
return;
|
||||
ImDrawVert* vtx_dst = (ImDrawVert*)vtx_resource.pData;
|
||||
ImDrawIdx* idx_dst = (ImDrawIdx*)idx_resource.pData;
|
||||
for (int n = 0; n < draw_data->CmdListsCount; n++)
|
||||
{
|
||||
const ImDrawList* cmd_list = draw_data->CmdLists[n];
|
||||
memcpy(vtx_dst, cmd_list->VtxBuffer.Data, cmd_list->VtxBuffer.Size * sizeof(ImDrawVert));
|
||||
memcpy(idx_dst, cmd_list->IdxBuffer.Data, cmd_list->IdxBuffer.Size * sizeof(ImDrawIdx));
|
||||
vtx_dst += cmd_list->VtxBuffer.Size;
|
||||
idx_dst += cmd_list->IdxBuffer.Size;
|
||||
}
|
||||
ctx->Unmap(g_pVB, 0);
|
||||
ctx->Unmap(g_pIB, 0);
|
||||
|
||||
// Setup orthographic projection matrix into our constant buffer
|
||||
// Our visible imgui space lies from draw_data->DisplayPos (top left) to draw_data->DisplayPos+data_data->DisplaySize (bottom right). DisplayPos is (0,0) for single viewport apps.
|
||||
{
|
||||
D3D11_MAPPED_SUBRESOURCE mapped_resource;
|
||||
if (ctx->Map(g_pVertexConstantBuffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &mapped_resource) != S_OK)
|
||||
return;
|
||||
VERTEX_CONSTANT_BUFFER* constant_buffer = (VERTEX_CONSTANT_BUFFER*)mapped_resource.pData;
|
||||
float L = draw_data->DisplayPos.x;
|
||||
float R = draw_data->DisplayPos.x + draw_data->DisplaySize.x;
|
||||
float T = draw_data->DisplayPos.y;
|
||||
float B = draw_data->DisplayPos.y + draw_data->DisplaySize.y;
|
||||
float mvp[4][4] =
|
||||
{
|
||||
{ 2.0f/(R-L), 0.0f, 0.0f, 0.0f },
|
||||
{ 0.0f, 2.0f/(T-B), 0.0f, 0.0f },
|
||||
{ 0.0f, 0.0f, 0.5f, 0.0f },
|
||||
{ (R+L)/(L-R), (T+B)/(B-T), 0.5f, 1.0f },
|
||||
};
|
||||
memcpy(&constant_buffer->mvp, mvp, sizeof(mvp));
|
||||
ctx->Unmap(g_pVertexConstantBuffer, 0);
|
||||
}
|
||||
|
||||
// Backup DX state that will be modified to restore it afterwards (unfortunately this is very ugly looking and verbose. Close your eyes!)
|
||||
struct BACKUP_DX11_STATE
|
||||
{
|
||||
UINT ScissorRectsCount, ViewportsCount;
|
||||
D3D11_RECT ScissorRects[D3D11_VIEWPORT_AND_SCISSORRECT_OBJECT_COUNT_PER_PIPELINE];
|
||||
D3D11_VIEWPORT Viewports[D3D11_VIEWPORT_AND_SCISSORRECT_OBJECT_COUNT_PER_PIPELINE];
|
||||
ID3D11RasterizerState* RS;
|
||||
ID3D11BlendState* BlendState;
|
||||
FLOAT BlendFactor[4];
|
||||
UINT SampleMask;
|
||||
UINT StencilRef;
|
||||
ID3D11DepthStencilState* DepthStencilState;
|
||||
ID3D11ShaderResourceView* PSShaderResource;
|
||||
ID3D11SamplerState* PSSampler;
|
||||
ID3D11PixelShader* PS;
|
||||
ID3D11VertexShader* VS;
|
||||
ID3D11GeometryShader* GS;
|
||||
UINT PSInstancesCount, VSInstancesCount, GSInstancesCount;
|
||||
ID3D11ClassInstance *PSInstances[256], *VSInstances[256], *GSInstances[256]; // 256 is max according to PSSetShader documentation
|
||||
D3D11_PRIMITIVE_TOPOLOGY PrimitiveTopology;
|
||||
ID3D11Buffer* IndexBuffer, *VertexBuffer, *VSConstantBuffer;
|
||||
UINT IndexBufferOffset, VertexBufferStride, VertexBufferOffset;
|
||||
DXGI_FORMAT IndexBufferFormat;
|
||||
ID3D11InputLayout* InputLayout;
|
||||
};
|
||||
BACKUP_DX11_STATE old;
|
||||
old.ScissorRectsCount = old.ViewportsCount = D3D11_VIEWPORT_AND_SCISSORRECT_OBJECT_COUNT_PER_PIPELINE;
|
||||
ctx->RSGetScissorRects(&old.ScissorRectsCount, old.ScissorRects);
|
||||
ctx->RSGetViewports(&old.ViewportsCount, old.Viewports);
|
||||
ctx->RSGetState(&old.RS);
|
||||
ctx->OMGetBlendState(&old.BlendState, old.BlendFactor, &old.SampleMask);
|
||||
ctx->OMGetDepthStencilState(&old.DepthStencilState, &old.StencilRef);
|
||||
ctx->PSGetShaderResources(0, 1, &old.PSShaderResource);
|
||||
ctx->PSGetSamplers(0, 1, &old.PSSampler);
|
||||
old.PSInstancesCount = old.VSInstancesCount = old.GSInstancesCount = 256;
|
||||
ctx->PSGetShader(&old.PS, old.PSInstances, &old.PSInstancesCount);
|
||||
ctx->VSGetShader(&old.VS, old.VSInstances, &old.VSInstancesCount);
|
||||
ctx->VSGetConstantBuffers(0, 1, &old.VSConstantBuffer);
|
||||
ctx->GSGetShader(&old.GS, old.GSInstances, &old.GSInstancesCount);
|
||||
|
||||
ctx->IAGetPrimitiveTopology(&old.PrimitiveTopology);
|
||||
ctx->IAGetIndexBuffer(&old.IndexBuffer, &old.IndexBufferFormat, &old.IndexBufferOffset);
|
||||
ctx->IAGetVertexBuffers(0, 1, &old.VertexBuffer, &old.VertexBufferStride, &old.VertexBufferOffset);
|
||||
ctx->IAGetInputLayout(&old.InputLayout);
|
||||
|
||||
// Setup desired DX state
|
||||
ImGui_ImplDX11_SetupRenderState(draw_data, ctx);
|
||||
|
||||
// Render command lists
|
||||
// (Because we merged all buffers into a single one, we maintain our own offset into them)
|
||||
int global_idx_offset = 0;
|
||||
int global_vtx_offset = 0;
|
||||
ImVec2 clip_off = draw_data->DisplayPos;
|
||||
for (int n = 0; n < draw_data->CmdListsCount; n++)
|
||||
{
|
||||
const ImDrawList* cmd_list = draw_data->CmdLists[n];
|
||||
for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++)
|
||||
{
|
||||
const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i];
|
||||
if (pcmd->UserCallback != NULL)
|
||||
{
|
||||
// User callback, registered via ImDrawList::AddCallback()
|
||||
// (ImDrawCallback_ResetRenderState is a special callback value used by the user to request the renderer to reset render state.)
|
||||
if (pcmd->UserCallback == ImDrawCallback_ResetRenderState)
|
||||
ImGui_ImplDX11_SetupRenderState(draw_data, ctx);
|
||||
else
|
||||
pcmd->UserCallback(cmd_list, pcmd);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Apply scissor/clipping rectangle
|
||||
const D3D11_RECT r = { (LONG)(pcmd->ClipRect.x - clip_off.x), (LONG)(pcmd->ClipRect.y - clip_off.y), (LONG)(pcmd->ClipRect.z - clip_off.x), (LONG)(pcmd->ClipRect.w - clip_off.y) };
|
||||
ctx->RSSetScissorRects(1, &r);
|
||||
|
||||
// Bind texture, Draw
|
||||
ID3D11ShaderResourceView* texture_srv = (ID3D11ShaderResourceView*)pcmd->TextureId;
|
||||
ctx->PSSetShaderResources(0, 1, &texture_srv);
|
||||
ctx->DrawIndexed(pcmd->ElemCount, pcmd->IdxOffset + global_idx_offset, pcmd->VtxOffset + global_vtx_offset);
|
||||
}
|
||||
}
|
||||
global_idx_offset += cmd_list->IdxBuffer.Size;
|
||||
global_vtx_offset += cmd_list->VtxBuffer.Size;
|
||||
}
|
||||
|
||||
// Restore modified DX state
|
||||
ctx->RSSetScissorRects(old.ScissorRectsCount, old.ScissorRects);
|
||||
ctx->RSSetViewports(old.ViewportsCount, old.Viewports);
|
||||
ctx->RSSetState(old.RS); if (old.RS) old.RS->Release();
|
||||
ctx->OMSetBlendState(old.BlendState, old.BlendFactor, old.SampleMask); if (old.BlendState) old.BlendState->Release();
|
||||
ctx->OMSetDepthStencilState(old.DepthStencilState, old.StencilRef); if (old.DepthStencilState) old.DepthStencilState->Release();
|
||||
ctx->PSSetShaderResources(0, 1, &old.PSShaderResource); if (old.PSShaderResource) old.PSShaderResource->Release();
|
||||
ctx->PSSetSamplers(0, 1, &old.PSSampler); if (old.PSSampler) old.PSSampler->Release();
|
||||
ctx->PSSetShader(old.PS, old.PSInstances, old.PSInstancesCount); if (old.PS) old.PS->Release();
|
||||
for (UINT i = 0; i < old.PSInstancesCount; i++) if (old.PSInstances[i]) old.PSInstances[i]->Release();
|
||||
ctx->VSSetShader(old.VS, old.VSInstances, old.VSInstancesCount); if (old.VS) old.VS->Release();
|
||||
ctx->VSSetConstantBuffers(0, 1, &old.VSConstantBuffer); if (old.VSConstantBuffer) old.VSConstantBuffer->Release();
|
||||
ctx->GSSetShader(old.GS, old.GSInstances, old.GSInstancesCount); if (old.GS) old.GS->Release();
|
||||
for (UINT i = 0; i < old.VSInstancesCount; i++) if (old.VSInstances[i]) old.VSInstances[i]->Release();
|
||||
ctx->IASetPrimitiveTopology(old.PrimitiveTopology);
|
||||
ctx->IASetIndexBuffer(old.IndexBuffer, old.IndexBufferFormat, old.IndexBufferOffset); if (old.IndexBuffer) old.IndexBuffer->Release();
|
||||
ctx->IASetVertexBuffers(0, 1, &old.VertexBuffer, &old.VertexBufferStride, &old.VertexBufferOffset); if (old.VertexBuffer) old.VertexBuffer->Release();
|
||||
ctx->IASetInputLayout(old.InputLayout); if (old.InputLayout) old.InputLayout->Release();
|
||||
}
|
||||
|
||||
static void ImGui_ImplDX11_CreateFontsTexture()
|
||||
{
|
||||
// Build texture atlas
|
||||
ImGuiIO& io = ImGui::GetIO();
|
||||
unsigned char* pixels;
|
||||
int width, height;
|
||||
io.Fonts->GetTexDataAsRGBA32(&pixels, &width, &height);
|
||||
|
||||
// Upload texture to graphics system
|
||||
{
|
||||
D3D11_TEXTURE2D_DESC desc;
|
||||
ZeroMemory(&desc, sizeof(desc));
|
||||
desc.Width = width;
|
||||
desc.Height = height;
|
||||
desc.MipLevels = 1;
|
||||
desc.ArraySize = 1;
|
||||
desc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
|
||||
desc.SampleDesc.Count = 1;
|
||||
desc.Usage = D3D11_USAGE_DEFAULT;
|
||||
desc.BindFlags = D3D11_BIND_SHADER_RESOURCE;
|
||||
desc.CPUAccessFlags = 0;
|
||||
|
||||
ID3D11Texture2D* pTexture = NULL;
|
||||
D3D11_SUBRESOURCE_DATA subResource;
|
||||
subResource.pSysMem = pixels;
|
||||
subResource.SysMemPitch = desc.Width * 4;
|
||||
subResource.SysMemSlicePitch = 0;
|
||||
g_pd3dDevice->CreateTexture2D(&desc, &subResource, &pTexture);
|
||||
|
||||
// Create texture view
|
||||
D3D11_SHADER_RESOURCE_VIEW_DESC srvDesc;
|
||||
ZeroMemory(&srvDesc, sizeof(srvDesc));
|
||||
srvDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
|
||||
srvDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2D;
|
||||
srvDesc.Texture2D.MipLevels = desc.MipLevels;
|
||||
srvDesc.Texture2D.MostDetailedMip = 0;
|
||||
g_pd3dDevice->CreateShaderResourceView(pTexture, &srvDesc, &g_pFontTextureView);
|
||||
pTexture->Release();
|
||||
}
|
||||
|
||||
// Store our identifier
|
||||
io.Fonts->TexID = (ImTextureID)g_pFontTextureView;
|
||||
|
||||
// Create texture sampler
|
||||
{
|
||||
D3D11_SAMPLER_DESC desc;
|
||||
ZeroMemory(&desc, sizeof(desc));
|
||||
desc.Filter = D3D11_FILTER_MIN_MAG_MIP_LINEAR;
|
||||
desc.AddressU = D3D11_TEXTURE_ADDRESS_WRAP;
|
||||
desc.AddressV = D3D11_TEXTURE_ADDRESS_WRAP;
|
||||
desc.AddressW = D3D11_TEXTURE_ADDRESS_WRAP;
|
||||
desc.MipLODBias = 0.f;
|
||||
desc.ComparisonFunc = D3D11_COMPARISON_ALWAYS;
|
||||
desc.MinLOD = 0.f;
|
||||
desc.MaxLOD = 0.f;
|
||||
g_pd3dDevice->CreateSamplerState(&desc, &g_pFontSampler);
|
||||
}
|
||||
}
|
||||
|
||||
bool ImGui_ImplDX11_CreateDeviceObjects()
|
||||
{
|
||||
if (!g_pd3dDevice)
|
||||
return false;
|
||||
if (g_pFontSampler)
|
||||
ImGui_ImplDX11_InvalidateDeviceObjects();
|
||||
|
||||
// By using D3DCompile() from <d3dcompiler.h> / d3dcompiler.lib, we introduce a dependency to a given version of d3dcompiler_XX.dll (see D3DCOMPILER_DLL_A)
|
||||
// If you would like to use this DX11 sample code but remove this dependency you can:
|
||||
// 1) compile once, save the compiled shader blobs into a file or source code and pass them to CreateVertexShader()/CreatePixelShader() [preferred solution]
|
||||
// 2) use code to detect any version of the DLL and grab a pointer to D3DCompile from the DLL.
|
||||
// See https://github.com/ocornut/imgui/pull/638 for sources and details.
|
||||
|
||||
// Create the vertex shader
|
||||
{
|
||||
static const char* vertexShader =
|
||||
"cbuffer vertexBuffer : register(b0) \
|
||||
{\
|
||||
float4x4 ProjectionMatrix; \
|
||||
};\
|
||||
struct VS_INPUT\
|
||||
{\
|
||||
float2 pos : POSITION;\
|
||||
float4 col : COLOR0;\
|
||||
float2 uv : TEXCOORD0;\
|
||||
};\
|
||||
\
|
||||
struct PS_INPUT\
|
||||
{\
|
||||
float4 pos : SV_POSITION;\
|
||||
float4 col : COLOR0;\
|
||||
float2 uv : TEXCOORD0;\
|
||||
};\
|
||||
\
|
||||
PS_INPUT main(VS_INPUT input)\
|
||||
{\
|
||||
PS_INPUT output;\
|
||||
output.pos = mul( ProjectionMatrix, float4(input.pos.xy, 0.f, 1.f));\
|
||||
output.col = input.col;\
|
||||
output.uv = input.uv;\
|
||||
return output;\
|
||||
}";
|
||||
|
||||
ID3DBlob* vertexShaderBlob;
|
||||
if (FAILED(D3DCompile(vertexShader, strlen(vertexShader), NULL, NULL, NULL, "main", "vs_4_0", 0, 0, &vertexShaderBlob, NULL)))
|
||||
return false; // NB: Pass ID3DBlob* pErrorBlob to D3DCompile() to get error showing in (const char*)pErrorBlob->GetBufferPointer(). Make sure to Release() the blob!
|
||||
if (g_pd3dDevice->CreateVertexShader(vertexShaderBlob->GetBufferPointer(), vertexShaderBlob->GetBufferSize(), NULL, &g_pVertexShader) != S_OK)
|
||||
{
|
||||
vertexShaderBlob->Release();
|
||||
return false;
|
||||
}
|
||||
|
||||
// Create the input layout
|
||||
D3D11_INPUT_ELEMENT_DESC local_layout[] =
|
||||
{
|
||||
{ "POSITION", 0, DXGI_FORMAT_R32G32_FLOAT, 0, (UINT)IM_OFFSETOF(ImDrawVert, pos), D3D11_INPUT_PER_VERTEX_DATA, 0 },
|
||||
{ "TEXCOORD", 0, DXGI_FORMAT_R32G32_FLOAT, 0, (UINT)IM_OFFSETOF(ImDrawVert, uv), D3D11_INPUT_PER_VERTEX_DATA, 0 },
|
||||
{ "COLOR", 0, DXGI_FORMAT_R8G8B8A8_UNORM, 0, (UINT)IM_OFFSETOF(ImDrawVert, col), D3D11_INPUT_PER_VERTEX_DATA, 0 },
|
||||
};
|
||||
if (g_pd3dDevice->CreateInputLayout(local_layout, 3, vertexShaderBlob->GetBufferPointer(), vertexShaderBlob->GetBufferSize(), &g_pInputLayout) != S_OK)
|
||||
{
|
||||
vertexShaderBlob->Release();
|
||||
return false;
|
||||
}
|
||||
vertexShaderBlob->Release();
|
||||
|
||||
// Create the constant buffer
|
||||
{
|
||||
D3D11_BUFFER_DESC desc;
|
||||
desc.ByteWidth = sizeof(VERTEX_CONSTANT_BUFFER);
|
||||
desc.Usage = D3D11_USAGE_DYNAMIC;
|
||||
desc.BindFlags = D3D11_BIND_CONSTANT_BUFFER;
|
||||
desc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
|
||||
desc.MiscFlags = 0;
|
||||
g_pd3dDevice->CreateBuffer(&desc, NULL, &g_pVertexConstantBuffer);
|
||||
}
|
||||
}
|
||||
|
||||
// Create the pixel shader
|
||||
{
|
||||
static const char* pixelShader =
|
||||
"struct PS_INPUT\
|
||||
{\
|
||||
float4 pos : SV_POSITION;\
|
||||
float4 col : COLOR0;\
|
||||
float2 uv : TEXCOORD0;\
|
||||
};\
|
||||
sampler sampler0;\
|
||||
Texture2D texture0;\
|
||||
\
|
||||
float4 main(PS_INPUT input) : SV_Target\
|
||||
{\
|
||||
float4 out_col = input.col * texture0.Sample(sampler0, input.uv); \
|
||||
return out_col; \
|
||||
}";
|
||||
|
||||
ID3DBlob* pixelShaderBlob;
|
||||
if (FAILED(D3DCompile(pixelShader, strlen(pixelShader), NULL, NULL, NULL, "main", "ps_4_0", 0, 0, &pixelShaderBlob, NULL)))
|
||||
return false; // NB: Pass ID3DBlob* pErrorBlob to D3DCompile() to get error showing in (const char*)pErrorBlob->GetBufferPointer(). Make sure to Release() the blob!
|
||||
if (g_pd3dDevice->CreatePixelShader(pixelShaderBlob->GetBufferPointer(), pixelShaderBlob->GetBufferSize(), NULL, &g_pPixelShader) != S_OK)
|
||||
{
|
||||
pixelShaderBlob->Release();
|
||||
return false;
|
||||
}
|
||||
pixelShaderBlob->Release();
|
||||
}
|
||||
|
||||
// Create the blending setup
|
||||
{
|
||||
D3D11_BLEND_DESC desc;
|
||||
ZeroMemory(&desc, sizeof(desc));
|
||||
desc.AlphaToCoverageEnable = false;
|
||||
desc.RenderTarget[0].BlendEnable = true;
|
||||
desc.RenderTarget[0].SrcBlend = D3D11_BLEND_SRC_ALPHA;
|
||||
desc.RenderTarget[0].DestBlend = D3D11_BLEND_INV_SRC_ALPHA;
|
||||
desc.RenderTarget[0].BlendOp = D3D11_BLEND_OP_ADD;
|
||||
desc.RenderTarget[0].SrcBlendAlpha = D3D11_BLEND_INV_SRC_ALPHA;
|
||||
desc.RenderTarget[0].DestBlendAlpha = D3D11_BLEND_ZERO;
|
||||
desc.RenderTarget[0].BlendOpAlpha = D3D11_BLEND_OP_ADD;
|
||||
desc.RenderTarget[0].RenderTargetWriteMask = D3D11_COLOR_WRITE_ENABLE_ALL;
|
||||
g_pd3dDevice->CreateBlendState(&desc, &g_pBlendState);
|
||||
}
|
||||
|
||||
// Create the rasterizer state
|
||||
{
|
||||
D3D11_RASTERIZER_DESC desc;
|
||||
ZeroMemory(&desc, sizeof(desc));
|
||||
desc.FillMode = D3D11_FILL_SOLID;
|
||||
desc.CullMode = D3D11_CULL_NONE;
|
||||
desc.ScissorEnable = true;
|
||||
desc.DepthClipEnable = true;
|
||||
g_pd3dDevice->CreateRasterizerState(&desc, &g_pRasterizerState);
|
||||
}
|
||||
|
||||
// Create depth-stencil State
|
||||
{
|
||||
D3D11_DEPTH_STENCIL_DESC desc;
|
||||
ZeroMemory(&desc, sizeof(desc));
|
||||
desc.DepthEnable = false;
|
||||
desc.DepthWriteMask = D3D11_DEPTH_WRITE_MASK_ALL;
|
||||
desc.DepthFunc = D3D11_COMPARISON_ALWAYS;
|
||||
desc.StencilEnable = false;
|
||||
desc.FrontFace.StencilFailOp = desc.FrontFace.StencilDepthFailOp = desc.FrontFace.StencilPassOp = D3D11_STENCIL_OP_KEEP;
|
||||
desc.FrontFace.StencilFunc = D3D11_COMPARISON_ALWAYS;
|
||||
desc.BackFace = desc.FrontFace;
|
||||
g_pd3dDevice->CreateDepthStencilState(&desc, &g_pDepthStencilState);
|
||||
}
|
||||
|
||||
ImGui_ImplDX11_CreateFontsTexture();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void ImGui_ImplDX11_InvalidateDeviceObjects()
|
||||
{
|
||||
if (!g_pd3dDevice)
|
||||
return;
|
||||
|
||||
if (g_pFontSampler) { g_pFontSampler->Release(); g_pFontSampler = NULL; }
|
||||
if (g_pFontTextureView) { g_pFontTextureView->Release(); g_pFontTextureView = NULL; ImGui::GetIO().Fonts->TexID = NULL; } // We copied g_pFontTextureView to io.Fonts->TexID so let's clear that as well.
|
||||
if (g_pIB) { g_pIB->Release(); g_pIB = NULL; }
|
||||
if (g_pVB) { g_pVB->Release(); g_pVB = NULL; }
|
||||
|
||||
if (g_pBlendState) { g_pBlendState->Release(); g_pBlendState = NULL; }
|
||||
if (g_pDepthStencilState) { g_pDepthStencilState->Release(); g_pDepthStencilState = NULL; }
|
||||
if (g_pRasterizerState) { g_pRasterizerState->Release(); g_pRasterizerState = NULL; }
|
||||
if (g_pPixelShader) { g_pPixelShader->Release(); g_pPixelShader = NULL; }
|
||||
if (g_pVertexConstantBuffer) { g_pVertexConstantBuffer->Release(); g_pVertexConstantBuffer = NULL; }
|
||||
if (g_pInputLayout) { g_pInputLayout->Release(); g_pInputLayout = NULL; }
|
||||
if (g_pVertexShader) { g_pVertexShader->Release(); g_pVertexShader = NULL; }
|
||||
}
|
||||
|
||||
bool ImGui_ImplDX11_Init(ID3D11Device* device, ID3D11DeviceContext* device_context)
|
||||
{
|
||||
// Setup back-end capabilities flags
|
||||
ImGuiIO& io = ImGui::GetIO();
|
||||
io.BackendRendererName = "imgui_impl_dx11";
|
||||
io.BackendFlags |= ImGuiBackendFlags_RendererHasVtxOffset; // We can honor the ImDrawCmd::VtxOffset field, allowing for large meshes.
|
||||
|
||||
// Get factory from device
|
||||
IDXGIDevice* pDXGIDevice = NULL;
|
||||
IDXGIAdapter* pDXGIAdapter = NULL;
|
||||
IDXGIFactory* pFactory = NULL;
|
||||
|
||||
if (device->QueryInterface(IID_PPV_ARGS(&pDXGIDevice)) == S_OK)
|
||||
if (pDXGIDevice->GetParent(IID_PPV_ARGS(&pDXGIAdapter)) == S_OK)
|
||||
if (pDXGIAdapter->GetParent(IID_PPV_ARGS(&pFactory)) == S_OK)
|
||||
{
|
||||
g_pd3dDevice = device;
|
||||
g_pd3dDeviceContext = device_context;
|
||||
g_pFactory = pFactory;
|
||||
}
|
||||
if (pDXGIDevice) pDXGIDevice->Release();
|
||||
if (pDXGIAdapter) pDXGIAdapter->Release();
|
||||
g_pd3dDevice->AddRef();
|
||||
g_pd3dDeviceContext->AddRef();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void ImGui_ImplDX11_Shutdown()
|
||||
{
|
||||
ImGui_ImplDX11_InvalidateDeviceObjects();
|
||||
if (g_pFactory) { g_pFactory->Release(); g_pFactory = NULL; }
|
||||
if (g_pd3dDevice) { g_pd3dDevice->Release(); g_pd3dDevice = NULL; }
|
||||
if (g_pd3dDeviceContext) { g_pd3dDeviceContext->Release(); g_pd3dDeviceContext = NULL; }
|
||||
}
|
||||
|
||||
void ImGui_ImplDX11_NewFrame()
|
||||
{
|
||||
if (!g_pFontSampler)
|
||||
ImGui_ImplDX11_CreateDeviceObjects();
|
||||
}
|
25
CheatMenu/external/imgui/imgui_impl_dx11.h
vendored
Normal file
@ -0,0 +1,25 @@
|
||||
// dear imgui: Renderer for DirectX11
|
||||
// This needs to be used along with a Platform Binding (e.g. Win32)
|
||||
|
||||
// Implemented features:
|
||||
// [X] Renderer: User texture binding. Use 'ID3D11ShaderResourceView*' as ImTextureID. Read the FAQ about ImTextureID!
|
||||
// [X] Renderer: Support for large meshes (64k+ vertices) with 16-bit indices.
|
||||
|
||||
// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this.
|
||||
// If you are new to dear imgui, read examples/README.txt and read the documentation at the top of imgui.cpp.
|
||||
// https://github.com/ocornut/imgui
|
||||
|
||||
#pragma once
|
||||
#include "imgui.h" // IMGUI_IMPL_API
|
||||
|
||||
struct ID3D11Device;
|
||||
struct ID3D11DeviceContext;
|
||||
|
||||
IMGUI_IMPL_API bool ImGui_ImplDX11_Init(ID3D11Device* device, ID3D11DeviceContext* device_context);
|
||||
IMGUI_IMPL_API void ImGui_ImplDX11_Shutdown();
|
||||
IMGUI_IMPL_API void ImGui_ImplDX11_NewFrame();
|
||||
IMGUI_IMPL_API void ImGui_ImplDX11_RenderDrawData(ImDrawData* draw_data);
|
||||
|
||||
// Use if you want to reset your rendering device without losing Dear ImGui state.
|
||||
IMGUI_IMPL_API void ImGui_ImplDX11_InvalidateDeviceObjects();
|
||||
IMGUI_IMPL_API bool ImGui_ImplDX11_CreateDeviceObjects();
|
284
CheatMenu/external/imgui/imgui_impl_dx9.cpp
vendored
Normal file
@ -0,0 +1,284 @@
|
||||
// dear imgui: Renderer for DirectX9
|
||||
// This needs to be used along with a Platform Binding (e.g. Win32)
|
||||
|
||||
// Implemented features:
|
||||
// [X] Renderer: User texture binding. Use 'LPDIRECT3DTEXTURE9' as ImTextureID. Read the FAQ about ImTextureID!
|
||||
// [X] Renderer: Support for large meshes (64k+ vertices) with 16-bit indices.
|
||||
|
||||
// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this.
|
||||
// If you are new to dear imgui, read examples/README.txt and read the documentation at the top of imgui.cpp.
|
||||
// https://github.com/ocornut/imgui
|
||||
|
||||
// CHANGELOG
|
||||
// (minor and older changes stripped away, please see git history for details)
|
||||
// 2019-05-29: DirectX9: Added support for large mesh (64K+ vertices), enable ImGuiBackendFlags_RendererHasVtxOffset flag.
|
||||
// 2019-04-30: DirectX9: Added support for special ImDrawCallback_ResetRenderState callback to reset render state.
|
||||
// 2019-03-29: Misc: Fixed erroneous assert in ImGui_ImplDX9_InvalidateDeviceObjects().
|
||||
// 2019-01-16: Misc: Disabled fog before drawing UI's. Fixes issue #2288.
|
||||
// 2018-11-30: Misc: Setting up io.BackendRendererName so it can be displayed in the About Window.
|
||||
// 2018-06-08: Misc: Extracted imgui_impl_dx9.cpp/.h away from the old combined DX9+Win32 example.
|
||||
// 2018-06-08: DirectX9: Use draw_data->DisplayPos and draw_data->DisplaySize to setup projection matrix and clipping rectangle.
|
||||
// 2018-05-07: Render: Saving/restoring Transform because they don't seem to be included in the StateBlock. Setting shading mode to Gouraud.
|
||||
// 2018-02-16: Misc: Obsoleted the io.RenderDrawListsFn callback and exposed ImGui_ImplDX9_RenderDrawData() in the .h file so you can call it yourself.
|
||||
// 2018-02-06: Misc: Removed call to ImGui::Shutdown() which is not available from 1.60 WIP, user needs to call CreateContext/DestroyContext themselves.
|
||||
|
||||
#include "imgui.h"
|
||||
#include "imgui_impl_dx9.h"
|
||||
|
||||
// DirectX
|
||||
#include <d3d9.h>
|
||||
#define DIRECTINPUT_VERSION 0x0800
|
||||
#include <dinput.h>
|
||||
|
||||
// DirectX data
|
||||
static LPDIRECT3DDEVICE9 g_pd3dDevice = NULL;
|
||||
static LPDIRECT3DVERTEXBUFFER9 g_pVB = NULL;
|
||||
static LPDIRECT3DINDEXBUFFER9 g_pIB = NULL;
|
||||
static LPDIRECT3DTEXTURE9 g_FontTexture = NULL;
|
||||
static int g_VertexBufferSize = 5000, g_IndexBufferSize = 10000;
|
||||
|
||||
struct CUSTOMVERTEX
|
||||
{
|
||||
float pos[3];
|
||||
D3DCOLOR col;
|
||||
float uv[2];
|
||||
};
|
||||
#define D3DFVF_CUSTOMVERTEX (D3DFVF_XYZ|D3DFVF_DIFFUSE|D3DFVF_TEX1)
|
||||
|
||||
static void ImGui_ImplDX9_SetupRenderState(ImDrawData* draw_data)
|
||||
{
|
||||
// Setup viewport
|
||||
D3DVIEWPORT9 vp;
|
||||
vp.X = vp.Y = 0;
|
||||
vp.Width = (DWORD)draw_data->DisplaySize.x;
|
||||
vp.Height = (DWORD)draw_data->DisplaySize.y;
|
||||
vp.MinZ = 0.0f;
|
||||
vp.MaxZ = 1.0f;
|
||||
g_pd3dDevice->SetViewport(&vp);
|
||||
|
||||
// Setup render state: fixed-pipeline, alpha-blending, no face culling, no depth testing, shade mode (for gradient)
|
||||
g_pd3dDevice->SetPixelShader(NULL);
|
||||
g_pd3dDevice->SetVertexShader(NULL);
|
||||
g_pd3dDevice->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE);
|
||||
g_pd3dDevice->SetRenderState(D3DRS_LIGHTING, FALSE);
|
||||
g_pd3dDevice->SetRenderState(D3DRS_ZENABLE, FALSE);
|
||||
g_pd3dDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE);
|
||||
g_pd3dDevice->SetRenderState(D3DRS_ALPHATESTENABLE, FALSE);
|
||||
g_pd3dDevice->SetRenderState(D3DRS_BLENDOP, D3DBLENDOP_ADD);
|
||||
g_pd3dDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
|
||||
g_pd3dDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA);
|
||||
g_pd3dDevice->SetRenderState(D3DRS_SCISSORTESTENABLE, TRUE);
|
||||
g_pd3dDevice->SetRenderState(D3DRS_SHADEMODE, D3DSHADE_GOURAUD);
|
||||
g_pd3dDevice->SetRenderState(D3DRS_FOGENABLE, FALSE);
|
||||
g_pd3dDevice->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_MODULATE);
|
||||
g_pd3dDevice->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE);
|
||||
g_pd3dDevice->SetTextureStageState(0, D3DTSS_COLORARG2, D3DTA_DIFFUSE);
|
||||
g_pd3dDevice->SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_MODULATE);
|
||||
g_pd3dDevice->SetTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE);
|
||||
g_pd3dDevice->SetTextureStageState(0, D3DTSS_ALPHAARG2, D3DTA_DIFFUSE);
|
||||
g_pd3dDevice->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR);
|
||||
g_pd3dDevice->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR);
|
||||
|
||||
// Setup orthographic projection matrix
|
||||
// Our visible imgui space lies from draw_data->DisplayPos (top left) to draw_data->DisplayPos+data_data->DisplaySize (bottom right). DisplayPos is (0,0) for single viewport apps.
|
||||
// Being agnostic of whether <d3dx9.h> or <DirectXMath.h> can be used, we aren't relying on D3DXMatrixIdentity()/D3DXMatrixOrthoOffCenterLH() or DirectX::XMMatrixIdentity()/DirectX::XMMatrixOrthographicOffCenterLH()
|
||||
{
|
||||
float L = draw_data->DisplayPos.x + 0.5f;
|
||||
float R = draw_data->DisplayPos.x + draw_data->DisplaySize.x + 0.5f;
|
||||
float T = draw_data->DisplayPos.y + 0.5f;
|
||||
float B = draw_data->DisplayPos.y + draw_data->DisplaySize.y + 0.5f;
|
||||
D3DMATRIX mat_identity = { { { 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f } } };
|
||||
D3DMATRIX mat_projection =
|
||||
{ { {
|
||||
2.0f/(R-L), 0.0f, 0.0f, 0.0f,
|
||||
0.0f, 2.0f/(T-B), 0.0f, 0.0f,
|
||||
0.0f, 0.0f, 0.5f, 0.0f,
|
||||
(L+R)/(L-R), (T+B)/(B-T), 0.5f, 1.0f
|
||||
} } };
|
||||
g_pd3dDevice->SetTransform(D3DTS_WORLD, &mat_identity);
|
||||
g_pd3dDevice->SetTransform(D3DTS_VIEW, &mat_identity);
|
||||
g_pd3dDevice->SetTransform(D3DTS_PROJECTION, &mat_projection);
|
||||
}
|
||||
}
|
||||
|
||||
// Render function.
|
||||
// (this used to be set in io.RenderDrawListsFn and called by ImGui::Render(), but you can now call this directly from your main loop)
|
||||
void ImGui_ImplDX9_RenderDrawData(ImDrawData* draw_data)
|
||||
{
|
||||
// Avoid rendering when minimized
|
||||
if (draw_data->DisplaySize.x <= 0.0f || draw_data->DisplaySize.y <= 0.0f)
|
||||
return;
|
||||
|
||||
// Create and grow buffers if needed
|
||||
if (!g_pVB || g_VertexBufferSize < draw_data->TotalVtxCount)
|
||||
{
|
||||
if (g_pVB) { g_pVB->Release(); g_pVB = NULL; }
|
||||
g_VertexBufferSize = draw_data->TotalVtxCount + 5000;
|
||||
if (g_pd3dDevice->CreateVertexBuffer(g_VertexBufferSize * sizeof(CUSTOMVERTEX), D3DUSAGE_DYNAMIC | D3DUSAGE_WRITEONLY, D3DFVF_CUSTOMVERTEX, D3DPOOL_DEFAULT, &g_pVB, NULL) < 0)
|
||||
return;
|
||||
}
|
||||
if (!g_pIB || g_IndexBufferSize < draw_data->TotalIdxCount)
|
||||
{
|
||||
if (g_pIB) { g_pIB->Release(); g_pIB = NULL; }
|
||||
g_IndexBufferSize = draw_data->TotalIdxCount + 10000;
|
||||
if (g_pd3dDevice->CreateIndexBuffer(g_IndexBufferSize * sizeof(ImDrawIdx), D3DUSAGE_DYNAMIC | D3DUSAGE_WRITEONLY, sizeof(ImDrawIdx) == 2 ? D3DFMT_INDEX16 : D3DFMT_INDEX32, D3DPOOL_DEFAULT, &g_pIB, NULL) < 0)
|
||||
return;
|
||||
}
|
||||
|
||||
// Backup the DX9 state
|
||||
IDirect3DStateBlock9* d3d9_state_block = NULL;
|
||||
if (g_pd3dDevice->CreateStateBlock(D3DSBT_ALL, &d3d9_state_block) < 0)
|
||||
return;
|
||||
|
||||
// Backup the DX9 transform (DX9 documentation suggests that it is included in the StateBlock but it doesn't appear to)
|
||||
D3DMATRIX last_world, last_view, last_projection;
|
||||
g_pd3dDevice->GetTransform(D3DTS_WORLD, &last_world);
|
||||
g_pd3dDevice->GetTransform(D3DTS_VIEW, &last_view);
|
||||
g_pd3dDevice->GetTransform(D3DTS_PROJECTION, &last_projection);
|
||||
|
||||
// Copy and convert all vertices into a single contiguous buffer, convert colors to DX9 default format.
|
||||
// FIXME-OPT: This is a waste of resource, the ideal is to use imconfig.h and
|
||||
// 1) to avoid repacking colors: #define IMGUI_USE_BGRA_PACKED_COLOR
|
||||
// 2) to avoid repacking vertices: #define IMGUI_OVERRIDE_DRAWVERT_STRUCT_LAYOUT struct ImDrawVert { ImVec2 pos; float z; ImU32 col; ImVec2 uv; }
|
||||
CUSTOMVERTEX* vtx_dst;
|
||||
ImDrawIdx* idx_dst;
|
||||
if (g_pVB->Lock(0, (UINT)(draw_data->TotalVtxCount * sizeof(CUSTOMVERTEX)), (void**)&vtx_dst, D3DLOCK_DISCARD) < 0)
|
||||
return;
|
||||
if (g_pIB->Lock(0, (UINT)(draw_data->TotalIdxCount * sizeof(ImDrawIdx)), (void**)&idx_dst, D3DLOCK_DISCARD) < 0)
|
||||
return;
|
||||
for (int n = 0; n < draw_data->CmdListsCount; n++)
|
||||
{
|
||||
const ImDrawList* cmd_list = draw_data->CmdLists[n];
|
||||
const ImDrawVert* vtx_src = cmd_list->VtxBuffer.Data;
|
||||
for (int i = 0; i < cmd_list->VtxBuffer.Size; i++)
|
||||
{
|
||||
vtx_dst->pos[0] = vtx_src->pos.x;
|
||||
vtx_dst->pos[1] = vtx_src->pos.y;
|
||||
vtx_dst->pos[2] = 0.0f;
|
||||
vtx_dst->col = (vtx_src->col & 0xFF00FF00) | ((vtx_src->col & 0xFF0000) >> 16) | ((vtx_src->col & 0xFF) << 16); // RGBA --> ARGB for DirectX9
|
||||
vtx_dst->uv[0] = vtx_src->uv.x;
|
||||
vtx_dst->uv[1] = vtx_src->uv.y;
|
||||
vtx_dst++;
|
||||
vtx_src++;
|
||||
}
|
||||
memcpy(idx_dst, cmd_list->IdxBuffer.Data, cmd_list->IdxBuffer.Size * sizeof(ImDrawIdx));
|
||||
idx_dst += cmd_list->IdxBuffer.Size;
|
||||
}
|
||||
g_pVB->Unlock();
|
||||
g_pIB->Unlock();
|
||||
g_pd3dDevice->SetStreamSource(0, g_pVB, 0, sizeof(CUSTOMVERTEX));
|
||||
g_pd3dDevice->SetIndices(g_pIB);
|
||||
g_pd3dDevice->SetFVF(D3DFVF_CUSTOMVERTEX);
|
||||
|
||||
// Setup desired DX state
|
||||
ImGui_ImplDX9_SetupRenderState(draw_data);
|
||||
|
||||
// Render command lists
|
||||
// (Because we merged all buffers into a single one, we maintain our own offset into them)
|
||||
int global_vtx_offset = 0;
|
||||
int global_idx_offset = 0;
|
||||
ImVec2 clip_off = draw_data->DisplayPos;
|
||||
for (int n = 0; n < draw_data->CmdListsCount; n++)
|
||||
{
|
||||
const ImDrawList* cmd_list = draw_data->CmdLists[n];
|
||||
for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++)
|
||||
{
|
||||
const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i];
|
||||
if (pcmd->UserCallback != NULL)
|
||||
{
|
||||
// User callback, registered via ImDrawList::AddCallback()
|
||||
// (ImDrawCallback_ResetRenderState is a special callback value used by the user to request the renderer to reset render state.)
|
||||
if (pcmd->UserCallback == ImDrawCallback_ResetRenderState)
|
||||
ImGui_ImplDX9_SetupRenderState(draw_data);
|
||||
else
|
||||
pcmd->UserCallback(cmd_list, pcmd);
|
||||
}
|
||||
else
|
||||
{
|
||||
const RECT r = { (LONG)(pcmd->ClipRect.x - clip_off.x), (LONG)(pcmd->ClipRect.y - clip_off.y), (LONG)(pcmd->ClipRect.z - clip_off.x), (LONG)(pcmd->ClipRect.w - clip_off.y) };
|
||||
const LPDIRECT3DTEXTURE9 texture9 = (LPDIRECT3DTEXTURE9)pcmd->TextureId;
|
||||
g_pd3dDevice->SetTexture(0, texture9);
|
||||
g_pd3dDevice->SetScissorRect(&r);
|
||||
g_pd3dDevice->DrawIndexedPrimitive(D3DPT_TRIANGLELIST, pcmd->VtxOffset + global_vtx_offset, 0, (UINT)cmd_list->VtxBuffer.Size, pcmd->IdxOffset + global_idx_offset, pcmd->ElemCount/3);
|
||||
}
|
||||
}
|
||||
global_idx_offset += cmd_list->IdxBuffer.Size;
|
||||
global_vtx_offset += cmd_list->VtxBuffer.Size;
|
||||
}
|
||||
|
||||
// Restore the DX9 transform
|
||||
g_pd3dDevice->SetTransform(D3DTS_WORLD, &last_world);
|
||||
g_pd3dDevice->SetTransform(D3DTS_VIEW, &last_view);
|
||||
g_pd3dDevice->SetTransform(D3DTS_PROJECTION, &last_projection);
|
||||
|
||||
// Restore the DX9 state
|
||||
d3d9_state_block->Apply();
|
||||
d3d9_state_block->Release();
|
||||
}
|
||||
|
||||
bool ImGui_ImplDX9_Init(IDirect3DDevice9* device)
|
||||
{
|
||||
// Setup back-end capabilities flags
|
||||
ImGuiIO& io = ImGui::GetIO();
|
||||
io.BackendRendererName = "imgui_impl_dx9";
|
||||
io.BackendFlags |= ImGuiBackendFlags_RendererHasVtxOffset; // We can honor the ImDrawCmd::VtxOffset field, allowing for large meshes.
|
||||
|
||||
g_pd3dDevice = device;
|
||||
g_pd3dDevice->AddRef();
|
||||
return true;
|
||||
}
|
||||
|
||||
void ImGui_ImplDX9_Shutdown()
|
||||
{
|
||||
ImGui_ImplDX9_InvalidateDeviceObjects();
|
||||
if (g_pd3dDevice) { g_pd3dDevice->Release(); g_pd3dDevice = NULL; }
|
||||
}
|
||||
|
||||
static bool ImGui_ImplDX9_CreateFontsTexture()
|
||||
{
|
||||
// Build texture atlas
|
||||
ImGuiIO& io = ImGui::GetIO();
|
||||
unsigned char* pixels;
|
||||
int width, height, bytes_per_pixel;
|
||||
io.Fonts->GetTexDataAsRGBA32(&pixels, &width, &height, &bytes_per_pixel);
|
||||
|
||||
// Upload texture to graphics system
|
||||
g_FontTexture = NULL;
|
||||
if (g_pd3dDevice->CreateTexture(width, height, 1, D3DUSAGE_DYNAMIC, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &g_FontTexture, NULL) < 0)
|
||||
return false;
|
||||
D3DLOCKED_RECT tex_locked_rect;
|
||||
if (g_FontTexture->LockRect(0, &tex_locked_rect, NULL, 0) != D3D_OK)
|
||||
return false;
|
||||
for (int y = 0; y < height; y++)
|
||||
memcpy((unsigned char *)tex_locked_rect.pBits + tex_locked_rect.Pitch * y, pixels + (width * bytes_per_pixel) * y, (width * bytes_per_pixel));
|
||||
g_FontTexture->UnlockRect(0);
|
||||
|
||||
// Store our identifier
|
||||
io.Fonts->TexID = (ImTextureID)g_FontTexture;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ImGui_ImplDX9_CreateDeviceObjects()
|
||||
{
|
||||
if (!g_pd3dDevice)
|
||||
return false;
|
||||
if (!ImGui_ImplDX9_CreateFontsTexture())
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
void ImGui_ImplDX9_InvalidateDeviceObjects()
|
||||
{
|
||||
if (!g_pd3dDevice)
|
||||
return;
|
||||
if (g_pVB) { g_pVB->Release(); g_pVB = NULL; }
|
||||
if (g_pIB) { g_pIB->Release(); g_pIB = NULL; }
|
||||
if (g_FontTexture) { g_FontTexture->Release(); g_FontTexture = NULL; ImGui::GetIO().Fonts->TexID = NULL; } // We copied g_pFontTextureView to io.Fonts->TexID so let's clear that as well.
|
||||
}
|
||||
|
||||
void ImGui_ImplDX9_NewFrame()
|
||||
{
|
||||
if (!g_FontTexture)
|
||||
ImGui_ImplDX9_CreateDeviceObjects();
|
||||
}
|
24
CheatMenu/external/imgui/imgui_impl_dx9.h
vendored
Normal file
@ -0,0 +1,24 @@
|
||||
// dear imgui: Renderer for DirectX9
|
||||
// This needs to be used along with a Platform Binding (e.g. Win32)
|
||||
|
||||
// Implemented features:
|
||||
// [X] Renderer: User texture binding. Use 'LPDIRECT3DTEXTURE9' as ImTextureID. Read the FAQ about ImTextureID!
|
||||
// [X] Renderer: Support for large meshes (64k+ vertices) with 16-bit indices.
|
||||
|
||||
// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this.
|
||||
// If you are new to dear imgui, read examples/README.txt and read the documentation at the top of imgui.cpp.
|
||||
// https://github.com/ocornut/imgui
|
||||
|
||||
#pragma once
|
||||
#include "imgui.h" // IMGUI_IMPL_API
|
||||
|
||||
struct IDirect3DDevice9;
|
||||
|
||||
IMGUI_IMPL_API bool ImGui_ImplDX9_Init(IDirect3DDevice9* device);
|
||||
IMGUI_IMPL_API void ImGui_ImplDX9_Shutdown();
|
||||
IMGUI_IMPL_API void ImGui_ImplDX9_NewFrame();
|
||||
IMGUI_IMPL_API void ImGui_ImplDX9_RenderDrawData(ImDrawData* draw_data);
|
||||
|
||||
// Use if you want to reset your rendering device without losing Dear ImGui state.
|
||||
IMGUI_IMPL_API bool ImGui_ImplDX9_CreateDeviceObjects();
|
||||
IMGUI_IMPL_API void ImGui_ImplDX9_InvalidateDeviceObjects();
|
441
CheatMenu/external/imgui/imgui_impl_win32.cpp
vendored
Normal file
@ -0,0 +1,441 @@
|
||||
// dear imgui: Platform Binding for Windows (standard windows API for 32 and 64 bits applications)
|
||||
// This needs to be used along with a Renderer (e.g. DirectX11, OpenGL3, Vulkan..)
|
||||
|
||||
// Implemented features:
|
||||
// [X] Platform: Clipboard support (for Win32 this is actually part of core dear imgui)
|
||||
// [X] Platform: Mouse cursor shape and visibility. Disable with 'io.ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange'.
|
||||
// [X] Platform: Keyboard arrays indexed using VK_* Virtual Key Codes, e.g. ImGui::IsKeyPressed(VK_SPACE).
|
||||
// [X] Platform: Gamepad support. Enabled with 'io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad'.
|
||||
|
||||
#include "imgui.h"
|
||||
#include "imgui_impl_win32.h"
|
||||
#ifndef WIN32_LEAN_AND_MEAN
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#endif
|
||||
#include <windows.h>
|
||||
#include <tchar.h>
|
||||
|
||||
// Using XInput library for gamepad (with recent Windows SDK this may leads to executables which won't run on Windows 7)
|
||||
#ifndef IMGUI_IMPL_WIN32_DISABLE_GAMEPAD
|
||||
#include <XInput.h>
|
||||
#else
|
||||
#define IMGUI_IMPL_WIN32_DISABLE_LINKING_XINPUT
|
||||
#endif
|
||||
#if defined(_MSC_VER) && !defined(IMGUI_IMPL_WIN32_DISABLE_LINKING_XINPUT)
|
||||
#pragma comment(lib, "xinput")
|
||||
//#pragma comment(lib, "Xinput9_1_0")
|
||||
#endif
|
||||
|
||||
// CHANGELOG
|
||||
// (minor and older changes stripped away, please see git history for details)
|
||||
// 2020-03-03: Inputs: Calling AddInputCharacterUTF16() to support surrogate pairs leading to codepoint >= 0x10000 (for more complete CJK inputs)
|
||||
// 2020-02-17: Added ImGui_ImplWin32_EnableDpiAwareness(), ImGui_ImplWin32_GetDpiScaleForHwnd(), ImGui_ImplWin32_GetDpiScaleForMonitor() helper functions.
|
||||
// 2020-01-14: Inputs: Added support for #define IMGUI_IMPL_WIN32_DISABLE_GAMEPAD/IMGUI_IMPL_WIN32_DISABLE_LINKING_XINPUT.
|
||||
// 2019-12-05: Inputs: Added support for ImGuiMouseCursor_NotAllowed mouse cursor.
|
||||
// 2019-05-11: Inputs: Don't filter value from WM_CHAR before calling AddInputCharacter().
|
||||
// 2019-01-17: Misc: Using GetForegroundWindow()+IsChild() instead of GetActiveWindow() to be compatible with windows created in a different thread or parent.
|
||||
// 2019-01-17: Inputs: Added support for mouse buttons 4 and 5 via WM_XBUTTON* messages.
|
||||
// 2019-01-15: Inputs: Added support for XInput gamepads (if ImGuiConfigFlags_NavEnableGamepad is set by user application).
|
||||
// 2018-11-30: Misc: Setting up io.BackendPlatformName so it can be displayed in the About Window.
|
||||
// 2018-06-29: Inputs: Added support for the ImGuiMouseCursor_Hand cursor.
|
||||
// 2018-06-10: Inputs: Fixed handling of mouse wheel messages to support fine position messages (typically sent by track-pads).
|
||||
// 2018-06-08: Misc: Extracted imgui_impl_win32.cpp/.h away from the old combined DX9/DX10/DX11/DX12 examples.
|
||||
// 2018-03-20: Misc: Setup io.BackendFlags ImGuiBackendFlags_HasMouseCursors and ImGuiBackendFlags_HasSetMousePos flags + honor ImGuiConfigFlags_NoMouseCursorChange flag.
|
||||
// 2018-02-20: Inputs: Added support for mouse cursors (ImGui::GetMouseCursor() value and WM_SETCURSOR message handling).
|
||||
// 2018-02-06: Inputs: Added mapping for ImGuiKey_Space.
|
||||
// 2018-02-06: Inputs: Honoring the io.WantSetMousePos by repositioning the mouse (when using navigation and ImGuiConfigFlags_NavMoveMouse is set).
|
||||
// 2018-02-06: Misc: Removed call to ImGui::Shutdown() which is not available from 1.60 WIP, user needs to call CreateContext/DestroyContext themselves.
|
||||
// 2018-01-20: Inputs: Added Horizontal Mouse Wheel support.
|
||||
// 2018-01-08: Inputs: Added mapping for ImGuiKey_Insert.
|
||||
// 2018-01-05: Inputs: Added WM_LBUTTONDBLCLK double-click handlers for window classes with the CS_DBLCLKS flag.
|
||||
// 2017-10-23: Inputs: Added WM_SYSKEYDOWN / WM_SYSKEYUP handlers so e.g. the VK_MENU key can be read.
|
||||
// 2017-10-23: Inputs: Using Win32 ::SetCapture/::GetCapture() to retrieve mouse positions outside the client area when dragging.
|
||||
// 2016-11-12: Inputs: Only call Win32 ::SetCursor(NULL) when io.MouseDrawCursor is set.
|
||||
|
||||
// Win32 Data
|
||||
static HWND g_hWnd = NULL;
|
||||
static INT64 g_Time = 0;
|
||||
static INT64 g_TicksPerSecond = 0;
|
||||
static ImGuiMouseCursor g_LastMouseCursor = ImGuiMouseCursor_COUNT;
|
||||
static bool g_HasGamepad = false;
|
||||
static bool g_WantUpdateHasGamepad = true;
|
||||
|
||||
// Functions
|
||||
bool ImGui_ImplWin32_Init(void* hwnd)
|
||||
{
|
||||
if (!::QueryPerformanceFrequency((LARGE_INTEGER *)&g_TicksPerSecond))
|
||||
return false;
|
||||
if (!::QueryPerformanceCounter((LARGE_INTEGER *)&g_Time))
|
||||
return false;
|
||||
|
||||
// Setup back-end capabilities flags
|
||||
g_hWnd = (HWND)hwnd;
|
||||
ImGuiIO& io = ImGui::GetIO();
|
||||
io.BackendFlags |= ImGuiBackendFlags_HasMouseCursors; // We can honor GetMouseCursor() values (optional)
|
||||
io.BackendFlags |= ImGuiBackendFlags_HasSetMousePos; // We can honor io.WantSetMousePos requests (optional, rarely used)
|
||||
io.BackendPlatformName = "imgui_impl_win32";
|
||||
io.ImeWindowHandle = hwnd;
|
||||
|
||||
// Keyboard mapping. ImGui will use those indices to peek into the io.KeysDown[] array that we will update during the application lifetime.
|
||||
io.KeyMap[ImGuiKey_Tab] = VK_TAB;
|
||||
io.KeyMap[ImGuiKey_LeftArrow] = VK_LEFT;
|
||||
io.KeyMap[ImGuiKey_RightArrow] = VK_RIGHT;
|
||||
io.KeyMap[ImGuiKey_UpArrow] = VK_UP;
|
||||
io.KeyMap[ImGuiKey_DownArrow] = VK_DOWN;
|
||||
io.KeyMap[ImGuiKey_PageUp] = VK_PRIOR;
|
||||
io.KeyMap[ImGuiKey_PageDown] = VK_NEXT;
|
||||
io.KeyMap[ImGuiKey_Home] = VK_HOME;
|
||||
io.KeyMap[ImGuiKey_End] = VK_END;
|
||||
io.KeyMap[ImGuiKey_Insert] = VK_INSERT;
|
||||
io.KeyMap[ImGuiKey_Delete] = VK_DELETE;
|
||||
io.KeyMap[ImGuiKey_Backspace] = VK_BACK;
|
||||
io.KeyMap[ImGuiKey_Space] = VK_SPACE;
|
||||
io.KeyMap[ImGuiKey_Enter] = VK_RETURN;
|
||||
io.KeyMap[ImGuiKey_Escape] = VK_ESCAPE;
|
||||
io.KeyMap[ImGuiKey_KeyPadEnter] = VK_RETURN;
|
||||
io.KeyMap[ImGuiKey_A] = 'A';
|
||||
io.KeyMap[ImGuiKey_C] = 'C';
|
||||
io.KeyMap[ImGuiKey_V] = 'V';
|
||||
io.KeyMap[ImGuiKey_X] = 'X';
|
||||
io.KeyMap[ImGuiKey_Y] = 'Y';
|
||||
io.KeyMap[ImGuiKey_Z] = 'Z';
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void ImGui_ImplWin32_Shutdown()
|
||||
{
|
||||
g_hWnd = (HWND)0;
|
||||
}
|
||||
|
||||
static bool ImGui_ImplWin32_UpdateMouseCursor()
|
||||
{
|
||||
ImGuiIO& io = ImGui::GetIO();
|
||||
if (io.ConfigFlags & ImGuiConfigFlags_NoMouseCursorChange)
|
||||
return false;
|
||||
|
||||
ImGuiMouseCursor imgui_cursor = ImGui::GetMouseCursor();
|
||||
if (imgui_cursor == ImGuiMouseCursor_None || io.MouseDrawCursor)
|
||||
{
|
||||
// Hide OS mouse cursor if imgui is drawing it or if it wants no cursor
|
||||
::SetCursor(NULL);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Show OS mouse cursor
|
||||
LPTSTR win32_cursor = IDC_ARROW;
|
||||
switch (imgui_cursor)
|
||||
{
|
||||
case ImGuiMouseCursor_Arrow: win32_cursor = IDC_ARROW; break;
|
||||
case ImGuiMouseCursor_TextInput: win32_cursor = IDC_IBEAM; break;
|
||||
case ImGuiMouseCursor_ResizeAll: win32_cursor = IDC_SIZEALL; break;
|
||||
case ImGuiMouseCursor_ResizeEW: win32_cursor = IDC_SIZEWE; break;
|
||||
case ImGuiMouseCursor_ResizeNS: win32_cursor = IDC_SIZENS; break;
|
||||
case ImGuiMouseCursor_ResizeNESW: win32_cursor = IDC_SIZENESW; break;
|
||||
case ImGuiMouseCursor_ResizeNWSE: win32_cursor = IDC_SIZENWSE; break;
|
||||
case ImGuiMouseCursor_Hand: win32_cursor = IDC_HAND; break;
|
||||
case ImGuiMouseCursor_NotAllowed: win32_cursor = IDC_NO; break;
|
||||
}
|
||||
::SetCursor(::LoadCursor(NULL, win32_cursor));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
static void ImGui_ImplWin32_UpdateMousePos()
|
||||
{
|
||||
ImGuiIO& io = ImGui::GetIO();
|
||||
|
||||
// Set OS mouse position if requested (rarely used, only when ImGuiConfigFlags_NavEnableSetMousePos is enabled by user)
|
||||
if (io.WantSetMousePos)
|
||||
{
|
||||
POINT pos = { (int)io.MousePos.x, (int)io.MousePos.y };
|
||||
::ClientToScreen(g_hWnd, &pos);
|
||||
::SetCursorPos(pos.x, pos.y);
|
||||
}
|
||||
|
||||
// Set mouse position
|
||||
io.MousePos = ImVec2(-FLT_MAX, -FLT_MAX);
|
||||
POINT pos;
|
||||
if (HWND active_window = ::GetForegroundWindow())
|
||||
if (active_window == g_hWnd || ::IsChild(active_window, g_hWnd))
|
||||
if (::GetCursorPos(&pos) && ::ScreenToClient(g_hWnd, &pos))
|
||||
io.MousePos = ImVec2((float)pos.x, (float)pos.y);
|
||||
}
|
||||
|
||||
// Gamepad navigation mapping
|
||||
static void ImGui_ImplWin32_UpdateGamepads()
|
||||
{
|
||||
#ifndef IMGUI_IMPL_WIN32_DISABLE_GAMEPAD
|
||||
ImGuiIO& io = ImGui::GetIO();
|
||||
memset(io.NavInputs, 0, sizeof(io.NavInputs));
|
||||
if ((io.ConfigFlags & ImGuiConfigFlags_NavEnableGamepad) == 0)
|
||||
return;
|
||||
|
||||
// Calling XInputGetState() every frame on disconnected gamepads is unfortunately too slow.
|
||||
// Instead we refresh gamepad availability by calling XInputGetCapabilities() _only_ after receiving WM_DEVICECHANGE.
|
||||
if (g_WantUpdateHasGamepad)
|
||||
{
|
||||
XINPUT_CAPABILITIES caps;
|
||||
g_HasGamepad = (XInputGetCapabilities(0, XINPUT_FLAG_GAMEPAD, &caps) == ERROR_SUCCESS);
|
||||
g_WantUpdateHasGamepad = false;
|
||||
}
|
||||
|
||||
XINPUT_STATE xinput_state;
|
||||
io.BackendFlags &= ~ImGuiBackendFlags_HasGamepad;
|
||||
if (g_HasGamepad && XInputGetState(0, &xinput_state) == ERROR_SUCCESS)
|
||||
{
|
||||
const XINPUT_GAMEPAD& gamepad = xinput_state.Gamepad;
|
||||
io.BackendFlags |= ImGuiBackendFlags_HasGamepad;
|
||||
|
||||
#define MAP_BUTTON(NAV_NO, BUTTON_ENUM) { io.NavInputs[NAV_NO] = (gamepad.wButtons & BUTTON_ENUM) ? 1.0f : 0.0f; }
|
||||
#define MAP_ANALOG(NAV_NO, VALUE, V0, V1) { float vn = (float)(VALUE - V0) / (float)(V1 - V0); if (vn > 1.0f) vn = 1.0f; if (vn > 0.0f && io.NavInputs[NAV_NO] < vn) io.NavInputs[NAV_NO] = vn; }
|
||||
MAP_BUTTON(ImGuiNavInput_Activate, XINPUT_GAMEPAD_A); // Cross / A
|
||||
MAP_BUTTON(ImGuiNavInput_Cancel, XINPUT_GAMEPAD_B); // Circle / B
|
||||
MAP_BUTTON(ImGuiNavInput_Menu, XINPUT_GAMEPAD_X); // Square / X
|
||||
MAP_BUTTON(ImGuiNavInput_Input, XINPUT_GAMEPAD_Y); // Triangle / Y
|
||||
MAP_BUTTON(ImGuiNavInput_DpadLeft, XINPUT_GAMEPAD_DPAD_LEFT); // D-Pad Left
|
||||
MAP_BUTTON(ImGuiNavInput_DpadRight, XINPUT_GAMEPAD_DPAD_RIGHT); // D-Pad Right
|
||||
MAP_BUTTON(ImGuiNavInput_DpadUp, XINPUT_GAMEPAD_DPAD_UP); // D-Pad Up
|
||||
MAP_BUTTON(ImGuiNavInput_DpadDown, XINPUT_GAMEPAD_DPAD_DOWN); // D-Pad Down
|
||||
MAP_BUTTON(ImGuiNavInput_FocusPrev, XINPUT_GAMEPAD_LEFT_SHOULDER); // L1 / LB
|
||||
MAP_BUTTON(ImGuiNavInput_FocusNext, XINPUT_GAMEPAD_RIGHT_SHOULDER); // R1 / RB
|
||||
MAP_BUTTON(ImGuiNavInput_TweakSlow, XINPUT_GAMEPAD_LEFT_SHOULDER); // L1 / LB
|
||||
MAP_BUTTON(ImGuiNavInput_TweakFast, XINPUT_GAMEPAD_RIGHT_SHOULDER); // R1 / RB
|
||||
MAP_ANALOG(ImGuiNavInput_LStickLeft, gamepad.sThumbLX, -XINPUT_GAMEPAD_LEFT_THUMB_DEADZONE, -32768);
|
||||
MAP_ANALOG(ImGuiNavInput_LStickRight, gamepad.sThumbLX, +XINPUT_GAMEPAD_LEFT_THUMB_DEADZONE, +32767);
|
||||
MAP_ANALOG(ImGuiNavInput_LStickUp, gamepad.sThumbLY, +XINPUT_GAMEPAD_LEFT_THUMB_DEADZONE, +32767);
|
||||
MAP_ANALOG(ImGuiNavInput_LStickDown, gamepad.sThumbLY, -XINPUT_GAMEPAD_LEFT_THUMB_DEADZONE, -32767);
|
||||
#undef MAP_BUTTON
|
||||
#undef MAP_ANALOG
|
||||
}
|
||||
#endif // #ifndef IMGUI_IMPL_WIN32_DISABLE_GAMEPAD
|
||||
}
|
||||
|
||||
void ImGui_ImplWin32_NewFrame()
|
||||
{
|
||||
ImGuiIO& io = ImGui::GetIO();
|
||||
IM_ASSERT(io.Fonts->IsBuilt() && "Font atlas not built! It is generally built by the renderer back-end. Missing call to renderer _NewFrame() function? e.g. ImGui_ImplOpenGL3_NewFrame().");
|
||||
|
||||
// Setup display size (every frame to accommodate for window resizing)
|
||||
RECT rect;
|
||||
::GetClientRect(g_hWnd, &rect);
|
||||
io.DisplaySize = ImVec2((float)(rect.right - rect.left), (float)(rect.bottom - rect.top));
|
||||
|
||||
// Setup time step
|
||||
INT64 current_time;
|
||||
::QueryPerformanceCounter((LARGE_INTEGER *)¤t_time);
|
||||
io.DeltaTime = (float)(current_time - g_Time) / g_TicksPerSecond;
|
||||
g_Time = current_time;
|
||||
|
||||
// Read keyboard modifiers inputs
|
||||
io.KeyCtrl = (::GetKeyState(VK_CONTROL) & 0x8000) != 0;
|
||||
io.KeyShift = (::GetKeyState(VK_SHIFT) & 0x8000) != 0;
|
||||
io.KeyAlt = (::GetKeyState(VK_MENU) & 0x8000) != 0;
|
||||
io.KeySuper = false;
|
||||
// io.KeysDown[], io.MousePos, io.MouseDown[], io.MouseWheel: filled by the WndProc handler below.
|
||||
|
||||
// Update OS mouse position
|
||||
ImGui_ImplWin32_UpdateMousePos();
|
||||
|
||||
// Update OS mouse cursor with the cursor requested by imgui
|
||||
ImGuiMouseCursor mouse_cursor = io.MouseDrawCursor ? ImGuiMouseCursor_None : ImGui::GetMouseCursor();
|
||||
if (g_LastMouseCursor != mouse_cursor)
|
||||
{
|
||||
g_LastMouseCursor = mouse_cursor;
|
||||
ImGui_ImplWin32_UpdateMouseCursor();
|
||||
}
|
||||
|
||||
// Update game controllers (if enabled and available)
|
||||
ImGui_ImplWin32_UpdateGamepads();
|
||||
}
|
||||
|
||||
// Allow compilation with old Windows SDK. MinGW doesn't have default _WIN32_WINNT/WINVER versions.
|
||||
#ifndef WM_MOUSEHWHEEL
|
||||
#define WM_MOUSEHWHEEL 0x020E
|
||||
#endif
|
||||
#ifndef DBT_DEVNODES_CHANGED
|
||||
#define DBT_DEVNODES_CHANGED 0x0007
|
||||
#endif
|
||||
|
||||
// Win32 message handler (process Win32 mouse/keyboard inputs, etc.)
|
||||
// Call from your application's message handler.
|
||||
// When implementing your own back-end, you can read the io.WantCaptureMouse, io.WantCaptureKeyboard flags to tell if Dear ImGui wants to use your inputs.
|
||||
// - When io.WantCaptureMouse is true, do not dispatch mouse input data to your main application.
|
||||
// - When io.WantCaptureKeyboard is true, do not dispatch keyboard input data to your main application.
|
||||
// Generally you may always pass all inputs to Dear ImGui, and hide them from your application based on those two flags.
|
||||
// PS: In this Win32 handler, we use the capture API (GetCapture/SetCapture/ReleaseCapture) to be able to read mouse coordinates when dragging mouse outside of our window bounds.
|
||||
// PS: We treat DBLCLK messages as regular mouse down messages, so this code will work on windows classes that have the CS_DBLCLKS flag set. Our own example app code doesn't set this flag.
|
||||
#if 0
|
||||
// Copy this line into your .cpp file to forward declare the function.
|
||||
extern IMGUI_IMPL_API LRESULT ImGui_ImplWin32_WndProcHandler(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
|
||||
#endif
|
||||
IMGUI_IMPL_API LRESULT ImGui_ImplWin32_WndProcHandler(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
if (ImGui::GetCurrentContext() == NULL)
|
||||
return 0;
|
||||
|
||||
ImGuiIO& io = ImGui::GetIO();
|
||||
switch (msg)
|
||||
{
|
||||
case WM_LBUTTONDOWN: case WM_LBUTTONDBLCLK:
|
||||
case WM_RBUTTONDOWN: case WM_RBUTTONDBLCLK:
|
||||
case WM_MBUTTONDOWN: case WM_MBUTTONDBLCLK:
|
||||
case WM_XBUTTONDOWN: case WM_XBUTTONDBLCLK:
|
||||
{
|
||||
int button = 0;
|
||||
if (msg == WM_LBUTTONDOWN || msg == WM_LBUTTONDBLCLK) { button = 0; }
|
||||
if (msg == WM_RBUTTONDOWN || msg == WM_RBUTTONDBLCLK) { button = 1; }
|
||||
if (msg == WM_MBUTTONDOWN || msg == WM_MBUTTONDBLCLK) { button = 2; }
|
||||
if (msg == WM_XBUTTONDOWN || msg == WM_XBUTTONDBLCLK) { button = (GET_XBUTTON_WPARAM(wParam) == XBUTTON1) ? 3 : 4; }
|
||||
if (!ImGui::IsAnyMouseDown() && ::GetCapture() == NULL)
|
||||
::SetCapture(hwnd);
|
||||
io.MouseDown[button] = true;
|
||||
return 0;
|
||||
}
|
||||
case WM_LBUTTONUP:
|
||||
case WM_RBUTTONUP:
|
||||
case WM_MBUTTONUP:
|
||||
case WM_XBUTTONUP:
|
||||
{
|
||||
int button = 0;
|
||||
if (msg == WM_LBUTTONUP) { button = 0; }
|
||||
if (msg == WM_RBUTTONUP) { button = 1; }
|
||||
if (msg == WM_MBUTTONUP) { button = 2; }
|
||||
if (msg == WM_XBUTTONUP) { button = (GET_XBUTTON_WPARAM(wParam) == XBUTTON1) ? 3 : 4; }
|
||||
io.MouseDown[button] = false;
|
||||
if (!ImGui::IsAnyMouseDown() && ::GetCapture() == hwnd)
|
||||
::ReleaseCapture();
|
||||
return 0;
|
||||
}
|
||||
case WM_MOUSEWHEEL:
|
||||
io.MouseWheel += (float)GET_WHEEL_DELTA_WPARAM(wParam) / (float)WHEEL_DELTA;
|
||||
return 0;
|
||||
case WM_MOUSEHWHEEL:
|
||||
io.MouseWheelH += (float)GET_WHEEL_DELTA_WPARAM(wParam) / (float)WHEEL_DELTA;
|
||||
return 0;
|
||||
case WM_KEYDOWN:
|
||||
case WM_SYSKEYDOWN:
|
||||
if (wParam < 256)
|
||||
io.KeysDown[wParam] = 1;
|
||||
return 0;
|
||||
case WM_KEYUP:
|
||||
case WM_SYSKEYUP:
|
||||
if (wParam < 256)
|
||||
io.KeysDown[wParam] = 0;
|
||||
return 0;
|
||||
case WM_CHAR:
|
||||
// You can also use ToAscii()+GetKeyboardState() to retrieve characters.
|
||||
if (wParam > 0 && wParam < 0x10000)
|
||||
io.AddInputCharacterUTF16((unsigned short)wParam);
|
||||
return 0;
|
||||
case WM_SETCURSOR:
|
||||
if (LOWORD(lParam) == HTCLIENT && ImGui_ImplWin32_UpdateMouseCursor())
|
||||
return 1;
|
||||
return 0;
|
||||
case WM_DEVICECHANGE:
|
||||
if ((UINT)wParam == DBT_DEVNODES_CHANGED)
|
||||
g_WantUpdateHasGamepad = true;
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------
|
||||
// DPI-related helpers (optional)
|
||||
//--------------------------------------------------------------------------------------------------------
|
||||
// - Use to enable DPI awareness without having to create an application manifest.
|
||||
// - Your own app may already do this via a manifest or explicit calls. This is mostly useful for our examples/ apps.
|
||||
// - In theory we could call simple functions from Windows SDK such as SetProcessDPIAware(), SetProcessDpiAwareness(), etc.
|
||||
// but most of the functions provided by Microsoft require Windows 8.1/10+ SDK at compile time and Windows 8/10+ at runtime,
|
||||
// neither we want to require the user to have. So we dynamically select and load those functions to avoid dependencies.
|
||||
//---------------------------------------------------------------------------------------------------------
|
||||
// This is the scheme successfully used by GLFW (from which we borrowed some of the code) and other apps aiming to be highly portable.
|
||||
// ImGui_ImplWin32_EnableDpiAwareness() is just a helper called by main.cpp, we don't call it automatically.
|
||||
// If you are trying to implement your own back-end for your own engine, you may ignore that noise.
|
||||
//---------------------------------------------------------------------------------------------------------
|
||||
|
||||
// Implement some of the functions and types normally declared in recent Windows SDK.
|
||||
#if !defined(_versionhelpers_H_INCLUDED_) && !defined(_INC_VERSIONHELPERS)
|
||||
static BOOL IsWindowsVersionOrGreater(WORD major, WORD minor, WORD sp)
|
||||
{
|
||||
OSVERSIONINFOEXW osvi = { sizeof(osvi), major, minor, 0, 0, { 0 }, sp };
|
||||
DWORD mask = VER_MAJORVERSION | VER_MINORVERSION | VER_SERVICEPACKMAJOR;
|
||||
ULONGLONG cond = ::VerSetConditionMask(0, VER_MAJORVERSION, VER_GREATER_EQUAL);
|
||||
cond = ::VerSetConditionMask(cond, VER_MINORVERSION, VER_GREATER_EQUAL);
|
||||
cond = ::VerSetConditionMask(cond, VER_SERVICEPACKMAJOR, VER_GREATER_EQUAL);
|
||||
return ::VerifyVersionInfoW(&osvi, mask, cond);
|
||||
}
|
||||
#define IsWindows8Point1OrGreater() IsWindowsVersionOrGreater(HIBYTE(0x0602), LOBYTE(0x0602), 0) // _WIN32_WINNT_WINBLUE
|
||||
#endif
|
||||
|
||||
#ifndef DPI_ENUMS_DECLARED
|
||||
typedef enum { PROCESS_DPI_UNAWARE = 0, PROCESS_SYSTEM_DPI_AWARE = 1, PROCESS_PER_MONITOR_DPI_AWARE = 2 } PROCESS_DPI_AWARENESS;
|
||||
typedef enum { MDT_EFFECTIVE_DPI = 0, MDT_ANGULAR_DPI = 1, MDT_RAW_DPI = 2, MDT_DEFAULT = MDT_EFFECTIVE_DPI } MONITOR_DPI_TYPE;
|
||||
#endif
|
||||
#ifndef _DPI_AWARENESS_CONTEXTS_
|
||||
DECLARE_HANDLE(DPI_AWARENESS_CONTEXT);
|
||||
#define DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE (DPI_AWARENESS_CONTEXT)-3
|
||||
#endif
|
||||
#ifndef DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2
|
||||
#define DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2 (DPI_AWARENESS_CONTEXT)-4
|
||||
#endif
|
||||
typedef HRESULT(WINAPI* PFN_SetProcessDpiAwareness)(PROCESS_DPI_AWARENESS); // Shcore.lib + dll, Windows 8.1+
|
||||
typedef HRESULT(WINAPI* PFN_GetDpiForMonitor)(HMONITOR, MONITOR_DPI_TYPE, UINT*, UINT*); // Shcore.lib + dll, Windows 8.1+
|
||||
typedef DPI_AWARENESS_CONTEXT(WINAPI* PFN_SetThreadDpiAwarenessContext)(DPI_AWARENESS_CONTEXT); // User32.lib + dll, Windows 10 v1607+ (Creators Update)
|
||||
|
||||
// Helper function to enable DPI awareness without setting up a manifest
|
||||
void ImGui_ImplWin32_EnableDpiAwareness()
|
||||
{
|
||||
// if (IsWindows10OrGreater()) // This needs a manifest to succeed. Instead we try to grab the function pointer!
|
||||
{
|
||||
static HINSTANCE user32_dll = ::LoadLibraryA("user32.dll"); // Reference counted per-process
|
||||
if (PFN_SetThreadDpiAwarenessContext SetThreadDpiAwarenessContextFn = (PFN_SetThreadDpiAwarenessContext)::GetProcAddress(user32_dll, "SetThreadDpiAwarenessContext"))
|
||||
{
|
||||
SetThreadDpiAwarenessContextFn(DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2);
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (IsWindows8Point1OrGreater())
|
||||
{
|
||||
static HINSTANCE shcore_dll = ::LoadLibraryA("shcore.dll"); // Reference counted per-process
|
||||
if (PFN_SetProcessDpiAwareness SetProcessDpiAwarenessFn = (PFN_SetProcessDpiAwareness)::GetProcAddress(shcore_dll, "SetProcessDpiAwareness"))
|
||||
{
|
||||
SetProcessDpiAwarenessFn(PROCESS_PER_MONITOR_DPI_AWARE);
|
||||
return;
|
||||
}
|
||||
}
|
||||
SetProcessDPIAware();
|
||||
}
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma comment(lib, "gdi32") // Link with gdi32.lib for GetDeviceCaps()
|
||||
#endif
|
||||
|
||||
float ImGui_ImplWin32_GetDpiScaleForMonitor(void* monitor)
|
||||
{
|
||||
UINT xdpi = 96, ydpi = 96;
|
||||
if (IsWindows8Point1OrGreater())
|
||||
{
|
||||
static HINSTANCE shcore_dll = ::LoadLibraryA("shcore.dll"); // Reference counted per-process
|
||||
if (PFN_GetDpiForMonitor GetDpiForMonitorFn = (PFN_GetDpiForMonitor)::GetProcAddress(shcore_dll, "GetDpiForMonitor"))
|
||||
GetDpiForMonitorFn((HMONITOR)monitor, MDT_EFFECTIVE_DPI, &xdpi, &ydpi);
|
||||
}
|
||||
else
|
||||
{
|
||||
const HDC dc = ::GetDC(NULL);
|
||||
xdpi = ::GetDeviceCaps(dc, LOGPIXELSX);
|
||||
ydpi = ::GetDeviceCaps(dc, LOGPIXELSY);
|
||||
::ReleaseDC(NULL, dc);
|
||||
}
|
||||
IM_ASSERT(xdpi == ydpi); // Please contact me if you hit this assert!
|
||||
return xdpi / 96.0f;
|
||||
}
|
||||
|
||||
float ImGui_ImplWin32_GetDpiScaleForHwnd(void* hwnd)
|
||||
{
|
||||
HMONITOR monitor = ::MonitorFromWindow((HWND)hwnd, MONITOR_DEFAULTTONEAREST);
|
||||
return ImGui_ImplWin32_GetDpiScaleForMonitor(monitor);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------
|
37
CheatMenu/external/imgui/imgui_impl_win32.h
vendored
Normal file
@ -0,0 +1,37 @@
|
||||
// dear imgui: Platform Binding for Windows (standard windows API for 32 and 64 bits applications)
|
||||
// This needs to be used along with a Renderer (e.g. DirectX11, OpenGL3, Vulkan..)
|
||||
|
||||
// Implemented features:
|
||||
// [X] Platform: Clipboard support (for Win32 this is actually part of core dear imgui)
|
||||
// [X] Platform: Mouse cursor shape and visibility. Disable with 'io.ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange'.
|
||||
// [X] Platform: Keyboard arrays indexed using VK_* Virtual Key Codes, e.g. ImGui::IsKeyPressed(VK_SPACE).
|
||||
// [X] Platform: Gamepad support. Enabled with 'io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad'.
|
||||
|
||||
#pragma once
|
||||
#include "imgui.h" // IMGUI_IMPL_API
|
||||
|
||||
IMGUI_IMPL_API bool ImGui_ImplWin32_Init(void* hwnd);
|
||||
IMGUI_IMPL_API void ImGui_ImplWin32_Shutdown();
|
||||
IMGUI_IMPL_API void ImGui_ImplWin32_NewFrame();
|
||||
|
||||
// Configuration
|
||||
// - Disable gamepad support or linking with xinput.lib
|
||||
//#define IMGUI_IMPL_WIN32_DISABLE_GAMEPAD
|
||||
//#define IMGUI_IMPL_WIN32_DISABLE_LINKING_XINPUT
|
||||
|
||||
// Win32 message handler your application need to call.
|
||||
// - Intentionally commented out in a '#if 0' block to avoid dragging dependencies on <windows.h> from this helper.
|
||||
// - You should COPY the line below into your .cpp code to forward declare the function and then you can call it.
|
||||
#if 0
|
||||
extern IMGUI_IMPL_API LRESULT ImGui_ImplWin32_WndProcHandler(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
|
||||
#endif
|
||||
|
||||
// DPI-related helpers (optional)
|
||||
// - Use to enable DPI awareness without having to create an application manifest.
|
||||
// - Your own app may already do this via a manifest or explicit calls. This is mostly useful for our examples/ apps.
|
||||
// - In theory we could call simple functions from Windows SDK such as SetProcessDPIAware(), SetProcessDpiAwareness(), etc.
|
||||
// but most of the functions provided by Microsoft require Windows 8.1/10+ SDK at compile time and Windows 8/10+ at runtime,
|
||||
// neither we want to require the user to have. So we dynamically select and load those functions to avoid dependencies.
|
||||
IMGUI_IMPL_API void ImGui_ImplWin32_EnableDpiAwareness();
|
||||
IMGUI_IMPL_API float ImGui_ImplWin32_GetDpiScaleForHwnd(void* hwnd); // HWND hwnd
|
||||
IMGUI_IMPL_API float ImGui_ImplWin32_GetDpiScaleForMonitor(void* monitor); // HMONITOR monitor
|
2093
CheatMenu/external/imgui/imgui_internal.h
vendored
Normal file
8299
CheatMenu/external/imgui/imgui_widgets.cpp
vendored
Normal file
639
CheatMenu/external/imgui/imstb_rectpack.h
vendored
Normal file
@ -0,0 +1,639 @@
|
||||
// [DEAR IMGUI]
|
||||
// This is a slightly modified version of stb_rect_pack.h 1.00.
|
||||
// Those changes would need to be pushed into nothings/stb:
|
||||
// - Added STBRP__CDECL
|
||||
// Grep for [DEAR IMGUI] to find the changes.
|
||||
|
||||
// stb_rect_pack.h - v1.00 - public domain - rectangle packing
|
||||
// Sean Barrett 2014
|
||||
//
|
||||
// Useful for e.g. packing rectangular textures into an atlas.
|
||||
// Does not do rotation.
|
||||
//
|
||||
// Not necessarily the awesomest packing method, but better than
|
||||
// the totally naive one in stb_truetype (which is primarily what
|
||||
// this is meant to replace).
|
||||
//
|
||||
// Has only had a few tests run, may have issues.
|
||||
//
|
||||
// More docs to come.
|
||||
//
|
||||
// No memory allocations; uses qsort() and assert() from stdlib.
|
||||
// Can override those by defining STBRP_SORT and STBRP_ASSERT.
|
||||
//
|
||||
// This library currently uses the Skyline Bottom-Left algorithm.
|
||||
//
|
||||
// Please note: better rectangle packers are welcome! Please
|
||||
// implement them to the same API, but with a different init
|
||||
// function.
|
||||
//
|
||||
// Credits
|
||||
//
|
||||
// Library
|
||||
// Sean Barrett
|
||||
// Minor features
|
||||
// Martins Mozeiko
|
||||
// github:IntellectualKitty
|
||||
//
|
||||
// Bugfixes / warning fixes
|
||||
// Jeremy Jaussaud
|
||||
// Fabian Giesen
|
||||
//
|
||||
// Version history:
|
||||
//
|
||||
// 1.00 (2019-02-25) avoid small space waste; gracefully fail too-wide rectangles
|
||||
// 0.99 (2019-02-07) warning fixes
|
||||
// 0.11 (2017-03-03) return packing success/fail result
|
||||
// 0.10 (2016-10-25) remove cast-away-const to avoid warnings
|
||||
// 0.09 (2016-08-27) fix compiler warnings
|
||||
// 0.08 (2015-09-13) really fix bug with empty rects (w=0 or h=0)
|
||||
// 0.07 (2015-09-13) fix bug with empty rects (w=0 or h=0)
|
||||
// 0.06 (2015-04-15) added STBRP_SORT to allow replacing qsort
|
||||
// 0.05: added STBRP_ASSERT to allow replacing assert
|
||||
// 0.04: fixed minor bug in STBRP_LARGE_RECTS support
|
||||
// 0.01: initial release
|
||||
//
|
||||
// LICENSE
|
||||
//
|
||||
// See end of file for license information.
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// INCLUDE SECTION
|
||||
//
|
||||
|
||||
#ifndef STB_INCLUDE_STB_RECT_PACK_H
|
||||
#define STB_INCLUDE_STB_RECT_PACK_H
|
||||
|
||||
#define STB_RECT_PACK_VERSION 1
|
||||
|
||||
#ifdef STBRP_STATIC
|
||||
#define STBRP_DEF static
|
||||
#else
|
||||
#define STBRP_DEF extern
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct stbrp_context stbrp_context;
|
||||
typedef struct stbrp_node stbrp_node;
|
||||
typedef struct stbrp_rect stbrp_rect;
|
||||
|
||||
#ifdef STBRP_LARGE_RECTS
|
||||
typedef int stbrp_coord;
|
||||
#else
|
||||
typedef unsigned short stbrp_coord;
|
||||
#endif
|
||||
|
||||
STBRP_DEF int stbrp_pack_rects (stbrp_context *context, stbrp_rect *rects, int num_rects);
|
||||
// Assign packed locations to rectangles. The rectangles are of type
|
||||
// 'stbrp_rect' defined below, stored in the array 'rects', and there
|
||||
// are 'num_rects' many of them.
|
||||
//
|
||||
// Rectangles which are successfully packed have the 'was_packed' flag
|
||||
// set to a non-zero value and 'x' and 'y' store the minimum location
|
||||
// on each axis (i.e. bottom-left in cartesian coordinates, top-left
|
||||
// if you imagine y increasing downwards). Rectangles which do not fit
|
||||
// have the 'was_packed' flag set to 0.
|
||||
//
|
||||
// You should not try to access the 'rects' array from another thread
|
||||
// while this function is running, as the function temporarily reorders
|
||||
// the array while it executes.
|
||||
//
|
||||
// To pack into another rectangle, you need to call stbrp_init_target
|
||||
// again. To continue packing into the same rectangle, you can call
|
||||
// this function again. Calling this multiple times with multiple rect
|
||||
// arrays will probably produce worse packing results than calling it
|
||||
// a single time with the full rectangle array, but the option is
|
||||
// available.
|
||||
//
|
||||
// The function returns 1 if all of the rectangles were successfully
|
||||
// packed and 0 otherwise.
|
||||
|
||||
struct stbrp_rect
|
||||
{
|
||||
// reserved for your use:
|
||||
int id;
|
||||
|
||||
// input:
|
||||
stbrp_coord w, h;
|
||||
|
||||
// output:
|
||||
stbrp_coord x, y;
|
||||
int was_packed; // non-zero if valid packing
|
||||
|
||||
}; // 16 bytes, nominally
|
||||
|
||||
|
||||
STBRP_DEF void stbrp_init_target (stbrp_context *context, int width, int height, stbrp_node *veh_nodes, int num_nodes);
|
||||
// Initialize a rectangle packer to:
|
||||
// pack a rectangle that is 'width' by 'height' in dimensions
|
||||
// using temporary storage provided by the array 'nodes', which is 'num_nodes' long
|
||||
//
|
||||
// You must call this function every time you start packing into a new target.
|
||||
//
|
||||
// There is no "shutdown" function. The 'nodes' memory must stay valid for
|
||||
// the following stbrp_pack_rects() call (or calls), but can be freed after
|
||||
// the call (or calls) finish.
|
||||
//
|
||||
// Note: to guarantee best results, either:
|
||||
// 1. make sure 'num_nodes' >= 'width'
|
||||
// or 2. call stbrp_allow_out_of_mem() defined below with 'allow_out_of_mem = 1'
|
||||
//
|
||||
// If you don't do either of the above things, widths will be quantized to multiples
|
||||
// of small integers to guarantee the algorithm doesn't run out of temporary storage.
|
||||
//
|
||||
// If you do #2, then the non-quantized algorithm will be used, but the algorithm
|
||||
// may run out of temporary storage and be unable to pack some rectangles.
|
||||
|
||||
STBRP_DEF void stbrp_setup_allow_out_of_mem (stbrp_context *context, int allow_out_of_mem);
|
||||
// Optionally call this function after init but before doing any packing to
|
||||
// change the handling of the out-of-temp-memory scenario, described above.
|
||||
// If you call init again, this will be reset to the default (false).
|
||||
|
||||
|
||||
STBRP_DEF void stbrp_setup_heuristic (stbrp_context *context, int heuristic);
|
||||
// Optionally select which packing heuristic the library should use. Different
|
||||
// heuristics will produce better/worse results for different data sets.
|
||||
// If you call init again, this will be reset to the default.
|
||||
|
||||
enum
|
||||
{
|
||||
STBRP_HEURISTIC_Skyline_default=0,
|
||||
STBRP_HEURISTIC_Skyline_BL_sortHeight = STBRP_HEURISTIC_Skyline_default,
|
||||
STBRP_HEURISTIC_Skyline_BF_sortHeight
|
||||
};
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// the details of the following structures don't matter to you, but they must
|
||||
// be visible so you can handle the memory allocations for them
|
||||
|
||||
struct stbrp_node
|
||||
{
|
||||
stbrp_coord x,y;
|
||||
stbrp_node *next;
|
||||
};
|
||||
|
||||
struct stbrp_context
|
||||
{
|
||||
int width;
|
||||
int height;
|
||||
int align;
|
||||
int init_mode;
|
||||
int heuristic;
|
||||
int num_nodes;
|
||||
stbrp_node *active_head;
|
||||
stbrp_node *free_head;
|
||||
stbrp_node extra[2]; // we allocate two extra nodes so optimal user-node-count is 'width' not 'width+2'
|
||||
};
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// IMPLEMENTATION SECTION
|
||||
//
|
||||
|
||||
#ifdef STB_RECT_PACK_IMPLEMENTATION
|
||||
#ifndef STBRP_SORT
|
||||
#include <stdlib.h>
|
||||
#define STBRP_SORT qsort
|
||||
#endif
|
||||
|
||||
#ifndef STBRP_ASSERT
|
||||
#include <assert.h>
|
||||
#define STBRP_ASSERT assert
|
||||
#endif
|
||||
|
||||
// [DEAR IMGUI] Added STBRP__CDECL
|
||||
#ifdef _MSC_VER
|
||||
#define STBRP__NOTUSED(v) (void)(v)
|
||||
#define STBRP__CDECL __cdecl
|
||||
#else
|
||||
#define STBRP__NOTUSED(v) (void)sizeof(v)
|
||||
#define STBRP__CDECL
|
||||
#endif
|
||||
|
||||
enum
|
||||
{
|
||||
STBRP__INIT_skyline = 1
|
||||
};
|
||||
|
||||
STBRP_DEF void stbrp_setup_heuristic(stbrp_context *context, int heuristic)
|
||||
{
|
||||
switch (context->init_mode) {
|
||||
case STBRP__INIT_skyline:
|
||||
STBRP_ASSERT(heuristic == STBRP_HEURISTIC_Skyline_BL_sortHeight || heuristic == STBRP_HEURISTIC_Skyline_BF_sortHeight);
|
||||
context->heuristic = heuristic;
|
||||
break;
|
||||
default:
|
||||
STBRP_ASSERT(0);
|
||||
}
|
||||
}
|
||||
|
||||
STBRP_DEF void stbrp_setup_allow_out_of_mem(stbrp_context *context, int allow_out_of_mem)
|
||||
{
|
||||
if (allow_out_of_mem)
|
||||
// if it's ok to run out of memory, then don't bother aligning them;
|
||||
// this gives better packing, but may fail due to OOM (even though
|
||||
// the rectangles easily fit). @TODO a smarter approach would be to only
|
||||
// quantize once we've hit OOM, then we could get rid of this parameter.
|
||||
context->align = 1;
|
||||
else {
|
||||
// if it's not ok to run out of memory, then quantize the widths
|
||||
// so that num_nodes is always enough nodes.
|
||||
//
|
||||
// I.e. num_nodes * align >= width
|
||||
// align >= width / num_nodes
|
||||
// align = ceil(width/num_nodes)
|
||||
|
||||
context->align = (context->width + context->num_nodes-1) / context->num_nodes;
|
||||
}
|
||||
}
|
||||
|
||||
STBRP_DEF void stbrp_init_target(stbrp_context *context, int width, int height, stbrp_node *veh_nodes, int num_nodes)
|
||||
{
|
||||
int i;
|
||||
#ifndef STBRP_LARGE_RECTS
|
||||
STBRP_ASSERT(width <= 0xffff && height <= 0xffff);
|
||||
#endif
|
||||
|
||||
for (i=0; i < num_nodes-1; ++i)
|
||||
veh_nodes[i].next = &veh_nodes[i+1];
|
||||
veh_nodes[i].next = NULL;
|
||||
context->init_mode = STBRP__INIT_skyline;
|
||||
context->heuristic = STBRP_HEURISTIC_Skyline_default;
|
||||
context->free_head = &veh_nodes[0];
|
||||
context->active_head = &context->extra[0];
|
||||
context->width = width;
|
||||
context->height = height;
|
||||
context->num_nodes = num_nodes;
|
||||
stbrp_setup_allow_out_of_mem(context, 0);
|
||||
|
||||
// node 0 is the full width, node 1 is the sentinel (lets us not store width explicitly)
|
||||
context->extra[0].x = 0;
|
||||
context->extra[0].y = 0;
|
||||
context->extra[0].next = &context->extra[1];
|
||||
context->extra[1].x = (stbrp_coord) width;
|
||||
#ifdef STBRP_LARGE_RECTS
|
||||
context->extra[1].y = (1<<30);
|
||||
#else
|
||||
context->extra[1].y = 65535;
|
||||
#endif
|
||||
context->extra[1].next = NULL;
|
||||
}
|
||||
|
||||
// find minimum y position if it starts at x1
|
||||
static int stbrp__skyline_find_min_y(stbrp_context *c, stbrp_node *first, int x0, int width, int *pwaste)
|
||||
{
|
||||
stbrp_node *node = first;
|
||||
int x1 = x0 + width;
|
||||
int min_y, visited_width, waste_area;
|
||||
|
||||
STBRP__NOTUSED(c);
|
||||
|
||||
STBRP_ASSERT(first->x <= x0);
|
||||
|
||||
#if 0
|
||||
// skip in case we're past the node
|
||||
while (node->next->x <= x0)
|
||||
++node;
|
||||
#else
|
||||
STBRP_ASSERT(node->next->x > x0); // we ended up handling this in the caller for efficiency
|
||||
#endif
|
||||
|
||||
STBRP_ASSERT(node->x <= x0);
|
||||
|
||||
min_y = 0;
|
||||
waste_area = 0;
|
||||
visited_width = 0;
|
||||
while (node->x < x1) {
|
||||
if (node->y > min_y) {
|
||||
// raise min_y higher.
|
||||
// we've accounted for all waste up to min_y,
|
||||
// but we'll now add more waste for everything we've visted
|
||||
waste_area += visited_width * (node->y - min_y);
|
||||
min_y = node->y;
|
||||
// the first time through, visited_width might be reduced
|
||||
if (node->x < x0)
|
||||
visited_width += node->next->x - x0;
|
||||
else
|
||||
visited_width += node->next->x - node->x;
|
||||
} else {
|
||||
// add waste area
|
||||
int under_width = node->next->x - node->x;
|
||||
if (under_width + visited_width > width)
|
||||
under_width = width - visited_width;
|
||||
waste_area += under_width * (min_y - node->y);
|
||||
visited_width += under_width;
|
||||
}
|
||||
node = node->next;
|
||||
}
|
||||
|
||||
*pwaste = waste_area;
|
||||
return min_y;
|
||||
}
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int x,y;
|
||||
stbrp_node **prev_link;
|
||||
} stbrp__findresult;
|
||||
|
||||
static stbrp__findresult stbrp__skyline_find_best_pos(stbrp_context *c, int width, int height)
|
||||
{
|
||||
int best_waste = (1<<30), best_x, best_y = (1 << 30);
|
||||
stbrp__findresult fr;
|
||||
stbrp_node **prev, *node, *tail, **best = NULL;
|
||||
|
||||
// align to multiple of c->align
|
||||
width = (width + c->align - 1);
|
||||
width -= width % c->align;
|
||||
STBRP_ASSERT(width % c->align == 0);
|
||||
|
||||
// if it can't possibly fit, bail immediately
|
||||
if (width > c->width || height > c->height) {
|
||||
fr.prev_link = NULL;
|
||||
fr.x = fr.y = 0;
|
||||
return fr;
|
||||
}
|
||||
|
||||
node = c->active_head;
|
||||
prev = &c->active_head;
|
||||
while (node->x + width <= c->width) {
|
||||
int y,waste;
|
||||
y = stbrp__skyline_find_min_y(c, node, node->x, width, &waste);
|
||||
if (c->heuristic == STBRP_HEURISTIC_Skyline_BL_sortHeight) { // actually just want to test BL
|
||||
// bottom left
|
||||
if (y < best_y) {
|
||||
best_y = y;
|
||||
best = prev;
|
||||
}
|
||||
} else {
|
||||
// best-fit
|
||||
if (y + height <= c->height) {
|
||||
// can only use it if it first vertically
|
||||
if (y < best_y || (y == best_y && waste < best_waste)) {
|
||||
best_y = y;
|
||||
best_waste = waste;
|
||||
best = prev;
|
||||
}
|
||||
}
|
||||
}
|
||||
prev = &node->next;
|
||||
node = node->next;
|
||||
}
|
||||
|
||||
best_x = (best == NULL) ? 0 : (*best)->x;
|
||||
|
||||
// if doing best-fit (BF), we also have to try aligning right edge to each node position
|
||||
//
|
||||
// e.g, if fitting
|
||||
//
|
||||
// ____________________
|
||||
// |____________________|
|
||||
//
|
||||
// into
|
||||
//
|
||||
// | |
|
||||
// | ____________|
|
||||
// |____________|
|
||||
//
|
||||
// then right-aligned reduces waste, but bottom-left BL is always chooses left-aligned
|
||||
//
|
||||
// This makes BF take about 2x the time
|
||||
|
||||
if (c->heuristic == STBRP_HEURISTIC_Skyline_BF_sortHeight) {
|
||||
tail = c->active_head;
|
||||
node = c->active_head;
|
||||
prev = &c->active_head;
|
||||
// find first node that's admissible
|
||||
while (tail->x < width)
|
||||
tail = tail->next;
|
||||
while (tail) {
|
||||
int xpos = tail->x - width;
|
||||
int y,waste;
|
||||
STBRP_ASSERT(xpos >= 0);
|
||||
// find the left position that matches this
|
||||
while (node->next->x <= xpos) {
|
||||
prev = &node->next;
|
||||
node = node->next;
|
||||
}
|
||||
STBRP_ASSERT(node->next->x > xpos && node->x <= xpos);
|
||||
y = stbrp__skyline_find_min_y(c, node, xpos, width, &waste);
|
||||
if (y + height <= c->height) {
|
||||
if (y <= best_y) {
|
||||
if (y < best_y || waste < best_waste || (waste==best_waste && xpos < best_x)) {
|
||||
best_x = xpos;
|
||||
STBRP_ASSERT(y <= best_y);
|
||||
best_y = y;
|
||||
best_waste = waste;
|
||||
best = prev;
|
||||
}
|
||||
}
|
||||
}
|
||||
tail = tail->next;
|
||||
}
|
||||
}
|
||||
|
||||
fr.prev_link = best;
|
||||
fr.x = best_x;
|
||||
fr.y = best_y;
|
||||
return fr;
|
||||
}
|
||||
|
||||
static stbrp__findresult stbrp__skyline_pack_rectangle(stbrp_context *context, int width, int height)
|
||||
{
|
||||
// find best position according to heuristic
|
||||
stbrp__findresult res = stbrp__skyline_find_best_pos(context, width, height);
|
||||
stbrp_node *node, *cur;
|
||||
|
||||
// bail if:
|
||||
// 1. it failed
|
||||
// 2. the best node doesn't fit (we don't always check this)
|
||||
// 3. we're out of memory
|
||||
if (res.prev_link == NULL || res.y + height > context->height || context->free_head == NULL) {
|
||||
res.prev_link = NULL;
|
||||
return res;
|
||||
}
|
||||
|
||||
// on success, create new node
|
||||
node = context->free_head;
|
||||
node->x = (stbrp_coord) res.x;
|
||||
node->y = (stbrp_coord) (res.y + height);
|
||||
|
||||
context->free_head = node->next;
|
||||
|
||||
// insert the new node into the right starting point, and
|
||||
// let 'cur' point to the remaining nodes needing to be
|
||||
// stiched back in
|
||||
|
||||
cur = *res.prev_link;
|
||||
if (cur->x < res.x) {
|
||||
// preserve the existing one, so start testing with the next one
|
||||
stbrp_node *next = cur->next;
|
||||
cur->next = node;
|
||||
cur = next;
|
||||
} else {
|
||||
*res.prev_link = node;
|
||||
}
|
||||
|
||||
// from here, traverse cur and free the nodes, until we get to one
|
||||
// that shouldn't be freed
|
||||
while (cur->next && cur->next->x <= res.x + width) {
|
||||
stbrp_node *next = cur->next;
|
||||
// move the current node to the free list
|
||||
cur->next = context->free_head;
|
||||
context->free_head = cur;
|
||||
cur = next;
|
||||
}
|
||||
|
||||
// stitch the list back in
|
||||
node->next = cur;
|
||||
|
||||
if (cur->x < res.x + width)
|
||||
cur->x = (stbrp_coord) (res.x + width);
|
||||
|
||||
#ifdef _DEBUG
|
||||
cur = context->active_head;
|
||||
while (cur->x < context->width) {
|
||||
STBRP_ASSERT(cur->x < cur->next->x);
|
||||
cur = cur->next;
|
||||
}
|
||||
STBRP_ASSERT(cur->next == NULL);
|
||||
|
||||
{
|
||||
int count=0;
|
||||
cur = context->active_head;
|
||||
while (cur) {
|
||||
cur = cur->next;
|
||||
++count;
|
||||
}
|
||||
cur = context->free_head;
|
||||
while (cur) {
|
||||
cur = cur->next;
|
||||
++count;
|
||||
}
|
||||
STBRP_ASSERT(count == context->num_nodes+2);
|
||||
}
|
||||
#endif
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
// [DEAR IMGUI] Added STBRP__CDECL
|
||||
static int STBRP__CDECL rect_height_compare(const void *a, const void *b)
|
||||
{
|
||||
const stbrp_rect *p = (const stbrp_rect *) a;
|
||||
const stbrp_rect *q = (const stbrp_rect *) b;
|
||||
if (p->h > q->h)
|
||||
return -1;
|
||||
if (p->h < q->h)
|
||||
return 1;
|
||||
return (p->w > q->w) ? -1 : (p->w < q->w);
|
||||
}
|
||||
|
||||
// [DEAR IMGUI] Added STBRP__CDECL
|
||||
static int STBRP__CDECL rect_original_order(const void *a, const void *b)
|
||||
{
|
||||
const stbrp_rect *p = (const stbrp_rect *) a;
|
||||
const stbrp_rect *q = (const stbrp_rect *) b;
|
||||
return (p->was_packed < q->was_packed) ? -1 : (p->was_packed > q->was_packed);
|
||||
}
|
||||
|
||||
#ifdef STBRP_LARGE_RECTS
|
||||
#define STBRP__MAXVAL 0xffffffff
|
||||
#else
|
||||
#define STBRP__MAXVAL 0xffff
|
||||
#endif
|
||||
|
||||
STBRP_DEF int stbrp_pack_rects(stbrp_context *context, stbrp_rect *rects, int num_rects)
|
||||
{
|
||||
int i, all_rects_packed = 1;
|
||||
|
||||
// we use the 'was_packed' field internally to allow sorting/unsorting
|
||||
for (i=0; i < num_rects; ++i) {
|
||||
rects[i].was_packed = i;
|
||||
}
|
||||
|
||||
// sort according to heuristic
|
||||
STBRP_SORT(rects, num_rects, sizeof(rects[0]), rect_height_compare);
|
||||
|
||||
for (i=0; i < num_rects; ++i) {
|
||||
if (rects[i].w == 0 || rects[i].h == 0) {
|
||||
rects[i].x = rects[i].y = 0; // empty rect needs no space
|
||||
} else {
|
||||
stbrp__findresult fr = stbrp__skyline_pack_rectangle(context, rects[i].w, rects[i].h);
|
||||
if (fr.prev_link) {
|
||||
rects[i].x = (stbrp_coord) fr.x;
|
||||
rects[i].y = (stbrp_coord) fr.y;
|
||||
} else {
|
||||
rects[i].x = rects[i].y = STBRP__MAXVAL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// unsort
|
||||
STBRP_SORT(rects, num_rects, sizeof(rects[0]), rect_original_order);
|
||||
|
||||
// set was_packed flags and all_rects_packed status
|
||||
for (i=0; i < num_rects; ++i) {
|
||||
rects[i].was_packed = !(rects[i].x == STBRP__MAXVAL && rects[i].y == STBRP__MAXVAL);
|
||||
if (!rects[i].was_packed)
|
||||
all_rects_packed = 0;
|
||||
}
|
||||
|
||||
// return the all_rects_packed status
|
||||
return all_rects_packed;
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
------------------------------------------------------------------------------
|
||||
This software is available under 2 licenses -- choose whichever you prefer.
|
||||
------------------------------------------------------------------------------
|
||||
ALTERNATIVE A - MIT License
|
||||
Copyright (c) 2017 Sean Barrett
|
||||
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.
|
||||
------------------------------------------------------------------------------
|
||||
ALTERNATIVE B - Public Domain (www.unlicense.org)
|
||||
This is free and unencumbered software released into the public domain.
|
||||
Anyone is free to copy, modify, publish, use, compile, sell, or distribute this
|
||||
software, either in source code form or as a compiled binary, for any purpose,
|
||||
commercial or non-commercial, and by any means.
|
||||
In jurisdictions that recognize copyright laws, the author or authors of this
|
||||
software dedicate any and all copyright interest in the software to the public
|
||||
domain. We make this dedication for the benefit of the public at large and to
|
||||
the detriment of our heirs and successors. We intend this dedication to be an
|
||||
overt act of relinquishment in perpetuity of all present and future rights to
|
||||
this software under copyright law.
|
||||
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 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.
|
||||
------------------------------------------------------------------------------
|
||||
*/
|
1447
CheatMenu/external/imgui/imstb_textedit.h
vendored
Normal file
4903
CheatMenu/external/imgui/imstb_truetype.h
vendored
Normal file
7762
CheatMenu/external/imgui/stb_image.h
vendored
Normal file
25447
CheatMenu/external/json.hpp
vendored
Normal file
661
CheatMenu/external/kiero/kiero.cpp
vendored
Normal file
@ -0,0 +1,661 @@
|
||||
/* Slightly modified version of https://github.com/Rebzzel/kiero
|
||||
|
||||
MIT License
|
||||
|
||||
Copyright(c) 2014 - 2020 Rebzzel
|
||||
|
||||
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.
|
||||
*/
|
||||
|
||||
#include "kiero.h"
|
||||
#include <Windows.h>
|
||||
#include <assert.h>
|
||||
#include "Renderware.h"
|
||||
|
||||
#if KIERO_INCLUDE_D3D9
|
||||
# include <d3d9.h>
|
||||
#endif
|
||||
|
||||
#if KIERO_INCLUDE_D3D10
|
||||
# include <dxgi.h>
|
||||
# include <d3d10_1.h>
|
||||
# include <d3d10.h>
|
||||
#endif
|
||||
|
||||
#if KIERO_INCLUDE_D3D11
|
||||
# include <dxgi.h>
|
||||
# include <d3d11.h>
|
||||
#endif
|
||||
|
||||
#if KIERO_INCLUDE_D3D12
|
||||
# include <dxgi.h>
|
||||
# include <d3d12.h>
|
||||
#endif
|
||||
|
||||
#if KIERO_INCLUDE_OPENGL
|
||||
# include <gl/GL.h>
|
||||
#endif
|
||||
|
||||
#if KIERO_INCLUDE_VULKAN
|
||||
# include <vulkan/vulkan.h>
|
||||
#endif
|
||||
|
||||
#if KIERO_USE_MINHOOK
|
||||
#include "minhook/include/MinHook.h"
|
||||
#endif
|
||||
|
||||
#ifdef _UNICODE
|
||||
# define KIERO_TEXT(text) L##text
|
||||
#else
|
||||
# define KIERO_TEXT(text) text
|
||||
#endif
|
||||
|
||||
#define KIERO_ARRAY_SIZE(arr) ((size_t)(sizeof(arr)/sizeof(arr[0])))
|
||||
|
||||
static kiero::RenderType::Enum g_renderType = kiero::RenderType::None;
|
||||
static uint150_t* g_methodsTable = NULL;
|
||||
|
||||
kiero::Status::Enum kiero::init(RenderType::Enum _renderType)
|
||||
{
|
||||
if (g_renderType != RenderType::None)
|
||||
{
|
||||
return Status::AlreadyInitializedError;
|
||||
}
|
||||
|
||||
if (_renderType != RenderType::None)
|
||||
{
|
||||
if (_renderType >= RenderType::D3D9 && _renderType <= RenderType::D3D12)
|
||||
{
|
||||
if (_renderType == RenderType::D3D9)
|
||||
{
|
||||
#if KIERO_INCLUDE_D3D9
|
||||
|
||||
if (GetModuleHandle(KIERO_TEXT("d3d9.dll")) == NULL)
|
||||
{
|
||||
return Status::ModuleNotFoundError;
|
||||
}
|
||||
g_methodsTable = (uint150_t*)::calloc(119, sizeof(uint150_t));
|
||||
::memcpy(g_methodsTable, *(uint150_t**)GetD3DDevice(), 119 * sizeof(uint150_t));
|
||||
|
||||
#if KIERO_USE_MINHOOK
|
||||
MH_Initialize();
|
||||
#endif
|
||||
g_renderType = RenderType::D3D9;
|
||||
|
||||
return Status::Success;
|
||||
#endif
|
||||
}
|
||||
else if (_renderType == RenderType::D3D10)
|
||||
{
|
||||
#if KIERO_INCLUDE_D3D10
|
||||
HMODULE libDXGI;
|
||||
HMODULE libD3D10;
|
||||
if ((libDXGI = ::GetModuleHandle(KIERO_TEXT("dxgi.dll"))) == NULL || (libD3D10 = ::GetModuleHandle(KIERO_TEXT("d3d10.dll"))) == NULL)
|
||||
{
|
||||
::DestroyWindow(window);
|
||||
::UnregisterClass(windowClass.lpszClassName, windowClass.hInstance);
|
||||
return Status::ModuleNotFoundError;
|
||||
}
|
||||
|
||||
void* CreateDXGIFactory;
|
||||
if ((CreateDXGIFactory = ::GetProcAddress(libDXGI, "CreateDXGIFactory")) == NULL)
|
||||
{
|
||||
::DestroyWindow(window);
|
||||
::UnregisterClass(windowClass.lpszClassName, windowClass.hInstance);
|
||||
return Status::UnknownError;
|
||||
}
|
||||
|
||||
IDXGIFactory* factory;
|
||||
if (((long(__stdcall*)(const IID&, void**))(CreateDXGIFactory))(__uuidof(IDXGIFactory), (void**)&factory) < 0)
|
||||
{
|
||||
::DestroyWindow(window);
|
||||
::UnregisterClass(windowClass.lpszClassName, windowClass.hInstance);
|
||||
return Status::UnknownError;
|
||||
}
|
||||
|
||||
IDXGIAdapter* adapter;
|
||||
if (factory->EnumAdapters(0, &adapter) == DXGI_ERROR_NOT_FOUND)
|
||||
{
|
||||
::DestroyWindow(window);
|
||||
::UnregisterClass(windowClass.lpszClassName, windowClass.hInstance);
|
||||
return Status::UnknownError;
|
||||
}
|
||||
|
||||
void* D3D10CreateDeviceAndSwapChain;
|
||||
if ((D3D10CreateDeviceAndSwapChain = ::GetProcAddress(libD3D10, "D3D10CreateDeviceAndSwapChain")) == NULL)
|
||||
{
|
||||
::DestroyWindow(window);
|
||||
::UnregisterClass(windowClass.lpszClassName, windowClass.hInstance);
|
||||
return Status::UnknownError;
|
||||
}
|
||||
|
||||
DXGI_RATIONAL refreshRate;
|
||||
refreshRate.Numerator = 60;
|
||||
refreshRate.Denominator = 1;
|
||||
|
||||
DXGI_MODE_DESC bufferDesc;
|
||||
bufferDesc.Width = 100;
|
||||
bufferDesc.Height = 100;
|
||||
bufferDesc.RefreshRate = refreshRate;
|
||||
bufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
|
||||
bufferDesc.ScanlineOrdering = DXGI_MODE_SCANLINE_ORDER_UNSPECIFIED;
|
||||
bufferDesc.Scaling = DXGI_MODE_SCALING_UNSPECIFIED;
|
||||
|
||||
DXGI_SAMPLE_DESC sampleDesc;
|
||||
sampleDesc.Count = 1;
|
||||
sampleDesc.Quality = 0;
|
||||
|
||||
DXGI_SWAP_CHAIN_DESC swapChainDesc;
|
||||
swapChainDesc.BufferDesc = bufferDesc;
|
||||
swapChainDesc.SampleDesc = sampleDesc;
|
||||
swapChainDesc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
|
||||
swapChainDesc.BufferCount = 1;
|
||||
swapChainDesc.OutputWindow = window;
|
||||
swapChainDesc.Windowed = 1;
|
||||
swapChainDesc.SwapEffect = DXGI_SWAP_EFFECT_DISCARD;
|
||||
swapChainDesc.Flags = DXGI_SWAP_CHAIN_FLAG_ALLOW_MODE_SWITCH;
|
||||
|
||||
IDXGISwapChain* swapChain;
|
||||
ID3D10Device* device;
|
||||
|
||||
if (((long(__stdcall*)(
|
||||
IDXGIAdapter*,
|
||||
D3D10_DRIVER_TYPE,
|
||||
HMODULE,
|
||||
UINT,
|
||||
UINT,
|
||||
DXGI_SWAP_CHAIN_DESC*,
|
||||
IDXGISwapChain**,
|
||||
ID3D10Device**))(D3D10CreateDeviceAndSwapChain))(adapter, D3D10_DRIVER_TYPE_HARDWARE, NULL, 0, D3D10_SDK_VERSION, &swapChainDesc, &swapChain, &device) < 0)
|
||||
{
|
||||
::DestroyWindow(window);
|
||||
::UnregisterClass(windowClass.lpszClassName, windowClass.hInstance);
|
||||
return Status::UnknownError;
|
||||
}
|
||||
|
||||
g_methodsTable = (uint150_t*)::calloc(116, sizeof(uint150_t));
|
||||
::memcpy(g_methodsTable, *(uint150_t**)swapChain, 18 * sizeof(uint150_t));
|
||||
::memcpy(g_methodsTable + 18, *(uint150_t**)device, 98 * sizeof(uint150_t));
|
||||
|
||||
#if KIERO_USE_MINHOOK
|
||||
MH_Initialize();
|
||||
#endif
|
||||
|
||||
swapChain->Release();
|
||||
swapChain = NULL;
|
||||
|
||||
device->Release();
|
||||
device = NULL;
|
||||
|
||||
::DestroyWindow(window);
|
||||
::UnregisterClass(windowClass.lpszClassName, windowClass.hInstance);
|
||||
|
||||
g_renderType = RenderType::D3D10;
|
||||
|
||||
return Status::Success;
|
||||
#endif
|
||||
}
|
||||
else if (_renderType == RenderType::D3D11)
|
||||
{
|
||||
#if KIERO_INCLUDE_D3D11
|
||||
HMODULE libD3D11;
|
||||
if ((libD3D11 = ::GetModuleHandle(KIERO_TEXT("d3d11.dll"))) == NULL)
|
||||
{
|
||||
return Status::ModuleNotFoundError;
|
||||
}
|
||||
|
||||
void* D3D11CreateDeviceAndSwapChain;
|
||||
if ((D3D11CreateDeviceAndSwapChain = ::GetProcAddress(libD3D11, "D3D11CreateDeviceAndSwapChain")) == NULL)
|
||||
{
|
||||
return Status::UnknownError;
|
||||
}
|
||||
|
||||
D3D_FEATURE_LEVEL featureLevel;
|
||||
const D3D_FEATURE_LEVEL featureLevels[] = { D3D_FEATURE_LEVEL_10_1, D3D_FEATURE_LEVEL_11_0 };
|
||||
|
||||
DXGI_RATIONAL refreshRate;
|
||||
refreshRate.Numerator = 60;
|
||||
refreshRate.Denominator = 1;
|
||||
|
||||
DXGI_MODE_DESC bufferDesc;
|
||||
bufferDesc.Width = 100;
|
||||
bufferDesc.Height = 100;
|
||||
bufferDesc.RefreshRate = refreshRate;
|
||||
bufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
|
||||
bufferDesc.ScanlineOrdering = DXGI_MODE_SCANLINE_ORDER_UNSPECIFIED;
|
||||
bufferDesc.Scaling = DXGI_MODE_SCALING_UNSPECIFIED;
|
||||
|
||||
DXGI_SAMPLE_DESC sampleDesc;
|
||||
sampleDesc.Count = 1;
|
||||
sampleDesc.Quality = 0;
|
||||
|
||||
DXGI_SWAP_CHAIN_DESC swapChainDesc;
|
||||
swapChainDesc.BufferDesc = bufferDesc;
|
||||
swapChainDesc.SampleDesc = sampleDesc;
|
||||
swapChainDesc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
|
||||
swapChainDesc.BufferCount = 1;
|
||||
swapChainDesc.OutputWindow = RsGlobal.ps->window;
|
||||
swapChainDesc.Windowed = 1;
|
||||
swapChainDesc.SwapEffect = DXGI_SWAP_EFFECT_DISCARD;
|
||||
swapChainDesc.Flags = DXGI_SWAP_CHAIN_FLAG_ALLOW_MODE_SWITCH;
|
||||
|
||||
IDXGISwapChain* swapChain;
|
||||
ID3D11Device* device;
|
||||
ID3D11DeviceContext* context;
|
||||
|
||||
if (((long(__stdcall*)(
|
||||
IDXGIAdapter*,
|
||||
D3D_DRIVER_TYPE,
|
||||
HMODULE,
|
||||
UINT,
|
||||
const D3D_FEATURE_LEVEL*,
|
||||
UINT,
|
||||
UINT,
|
||||
const DXGI_SWAP_CHAIN_DESC*,
|
||||
IDXGISwapChain**,
|
||||
ID3D11Device**,
|
||||
D3D_FEATURE_LEVEL*,
|
||||
ID3D11DeviceContext**))(D3D11CreateDeviceAndSwapChain))(NULL, D3D_DRIVER_TYPE_HARDWARE, NULL, 0, featureLevels, 2, D3D11_SDK_VERSION, &swapChainDesc, &swapChain, &device, &featureLevel, &context) < 0)
|
||||
{
|
||||
return Status::UnknownError;
|
||||
}
|
||||
|
||||
g_methodsTable = (uint150_t*)::calloc(205, sizeof(uint150_t));
|
||||
::memcpy(g_methodsTable, *(uint150_t**)swapChain, 18 * sizeof(uint150_t));
|
||||
::memcpy(g_methodsTable + 18, *(uint150_t**)device, 43 * sizeof(uint150_t));
|
||||
::memcpy(g_methodsTable + 18 + 43, *(uint150_t**)context, 144 * sizeof(uint150_t));
|
||||
|
||||
#if KIERO_USE_MINHOOK
|
||||
MH_Initialize();
|
||||
#endif
|
||||
|
||||
swapChain->Release();
|
||||
swapChain = NULL;
|
||||
|
||||
device->Release();
|
||||
device = NULL;
|
||||
|
||||
context->Release();
|
||||
context = NULL;
|
||||
|
||||
g_renderType = RenderType::D3D11;
|
||||
|
||||
return Status::Success;
|
||||
#endif
|
||||
}
|
||||
else if (_renderType == RenderType::D3D12)
|
||||
{
|
||||
#if KIERO_INCLUDE_D3D12
|
||||
HMODULE libDXGI;
|
||||
HMODULE libD3D12;
|
||||
if ((libDXGI = ::GetModuleHandle(KIERO_TEXT("dxgi.dll"))) == NULL || (libD3D12 = ::GetModuleHandle(KIERO_TEXT("d3d12.dll"))) == NULL)
|
||||
{
|
||||
::DestroyWindow(window);
|
||||
::UnregisterClass(windowClass.lpszClassName, windowClass.hInstance);
|
||||
return Status::ModuleNotFoundError;
|
||||
}
|
||||
|
||||
void* CreateDXGIFactory;
|
||||
if ((CreateDXGIFactory = ::GetProcAddress(libDXGI, "CreateDXGIFactory")) == NULL)
|
||||
{
|
||||
::DestroyWindow(window);
|
||||
::UnregisterClass(windowClass.lpszClassName, windowClass.hInstance);
|
||||
return Status::UnknownError;
|
||||
}
|
||||
|
||||
IDXGIFactory* factory;
|
||||
if (((long(__stdcall*)(const IID&, void**))(CreateDXGIFactory))(__uuidof(IDXGIFactory), (void**)&factory) < 0)
|
||||
{
|
||||
::DestroyWindow(window);
|
||||
::UnregisterClass(windowClass.lpszClassName, windowClass.hInstance);
|
||||
return Status::UnknownError;
|
||||
}
|
||||
|
||||
IDXGIAdapter* adapter;
|
||||
if (factory->EnumAdapters(0, &adapter) == DXGI_ERROR_NOT_FOUND)
|
||||
{
|
||||
::DestroyWindow(window);
|
||||
::UnregisterClass(windowClass.lpszClassName, windowClass.hInstance);
|
||||
return Status::UnknownError;
|
||||
}
|
||||
|
||||
void* D3D12CreateDevice;
|
||||
if ((D3D12CreateDevice = ::GetProcAddress(libD3D12, "D3D12CreateDevice")) == NULL)
|
||||
{
|
||||
::DestroyWindow(window);
|
||||
::UnregisterClass(windowClass.lpszClassName, windowClass.hInstance);
|
||||
return Status::UnknownError;
|
||||
}
|
||||
|
||||
ID3D12Device* device;
|
||||
if (((long(__stdcall*)(IUnknown*, D3D_FEATURE_LEVEL, const IID&, void**))(D3D12CreateDevice))(adapter, D3D_FEATURE_LEVEL_11_0, __uuidof(ID3D12Device), (void**)&device) < 0)
|
||||
{
|
||||
::DestroyWindow(window);
|
||||
::UnregisterClass(windowClass.lpszClassName, windowClass.hInstance);
|
||||
return Status::UnknownError;
|
||||
}
|
||||
|
||||
D3D12_COMMAND_QUEUE_DESC queueDesc;
|
||||
queueDesc.Type = D3D12_COMMAND_LIST_TYPE_DIRECT;
|
||||
queueDesc.Priority = 0;
|
||||
queueDesc.Flags = D3D12_COMMAND_QUEUE_FLAG_NONE;
|
||||
queueDesc.NodeMask = 0;
|
||||
|
||||
ID3D12CommandQueue* commandQueue;
|
||||
if (device->CreateCommandQueue(&queueDesc, __uuidof(ID3D12CommandQueue), (void**)&commandQueue) < 0)
|
||||
{
|
||||
::DestroyWindow(window);
|
||||
::UnregisterClass(windowClass.lpszClassName, windowClass.hInstance);
|
||||
return Status::UnknownError;
|
||||
}
|
||||
|
||||
ID3D12CommandAllocator* commandAllocator;
|
||||
if (device->CreateCommandAllocator(D3D12_COMMAND_LIST_TYPE_DIRECT, __uuidof(ID3D12CommandAllocator), (void**)&commandAllocator) < 0)
|
||||
{
|
||||
::DestroyWindow(window);
|
||||
::UnregisterClass(windowClass.lpszClassName, windowClass.hInstance);
|
||||
return Status::UnknownError;
|
||||
}
|
||||
|
||||
ID3D12GraphicsCommandList* commandList;
|
||||
if (device->CreateCommandList(0, D3D12_COMMAND_LIST_TYPE_DIRECT, commandAllocator, NULL, __uuidof(ID3D12GraphicsCommandList), (void**)&commandList) < 0)
|
||||
{
|
||||
::DestroyWindow(window);
|
||||
::UnregisterClass(windowClass.lpszClassName, windowClass.hInstance);
|
||||
return Status::UnknownError;
|
||||
}
|
||||
|
||||
DXGI_RATIONAL refreshRate;
|
||||
refreshRate.Numerator = 60;
|
||||
refreshRate.Denominator = 1;
|
||||
|
||||
DXGI_MODE_DESC bufferDesc;
|
||||
bufferDesc.Width = 100;
|
||||
bufferDesc.Height = 100;
|
||||
bufferDesc.RefreshRate = refreshRate;
|
||||
bufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
|
||||
bufferDesc.ScanlineOrdering = DXGI_MODE_SCANLINE_ORDER_UNSPECIFIED;
|
||||
bufferDesc.Scaling = DXGI_MODE_SCALING_UNSPECIFIED;
|
||||
|
||||
DXGI_SAMPLE_DESC sampleDesc;
|
||||
sampleDesc.Count = 1;
|
||||
sampleDesc.Quality = 0;
|
||||
|
||||
DXGI_SWAP_CHAIN_DESC swapChainDesc = {};
|
||||
swapChainDesc.BufferDesc = bufferDesc;
|
||||
swapChainDesc.SampleDesc = sampleDesc;
|
||||
swapChainDesc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
|
||||
swapChainDesc.BufferCount = 2;
|
||||
swapChainDesc.OutputWindow = window;
|
||||
swapChainDesc.Windowed = 1;
|
||||
swapChainDesc.SwapEffect = DXGI_SWAP_EFFECT_FLIP_DISCARD;
|
||||
swapChainDesc.Flags = DXGI_SWAP_CHAIN_FLAG_ALLOW_MODE_SWITCH;
|
||||
|
||||
IDXGISwapChain* swapChain;
|
||||
if (factory->CreateSwapChain(commandQueue, &swapChainDesc, &swapChain) < 0)
|
||||
{
|
||||
::DestroyWindow(window);
|
||||
::UnregisterClass(windowClass.lpszClassName, windowClass.hInstance);
|
||||
return Status::UnknownError;
|
||||
}
|
||||
|
||||
g_methodsTable = (uint150_t*)::calloc(150, sizeof(uint150_t));
|
||||
::memcpy(g_methodsTable, *(uint150_t**)device, 44 * sizeof(uint150_t));
|
||||
::memcpy(g_methodsTable + 44, *(uint150_t**)commandQueue, 19 * sizeof(uint150_t));
|
||||
::memcpy(g_methodsTable + 44 + 19, *(uint150_t**)commandAllocator, 9 * sizeof(uint150_t));
|
||||
::memcpy(g_methodsTable + 44 + 19 + 9, *(uint150_t**)commandList, 60 * sizeof(uint150_t));
|
||||
::memcpy(g_methodsTable + 44 + 19 + 9 + 60, *(uint150_t**)swapChain, 18 * sizeof(uint150_t));
|
||||
|
||||
#if KIERO_USE_MINHOOK
|
||||
MH_Initialize();
|
||||
#endif
|
||||
|
||||
device->Release();
|
||||
device = NULL;
|
||||
|
||||
commandQueue->Release();
|
||||
commandQueue = NULL;
|
||||
|
||||
commandAllocator->Release();
|
||||
commandAllocator = NULL;
|
||||
|
||||
commandList->Release();
|
||||
commandList = NULL;
|
||||
|
||||
swapChain->Release();
|
||||
swapChain = NULL;
|
||||
|
||||
::DestroyWindow(window);
|
||||
::UnregisterClass(windowClass.lpszClassName, windowClass.hInstance);
|
||||
|
||||
g_renderType = RenderType::D3D12;
|
||||
|
||||
return Status::Success;
|
||||
#endif
|
||||
}
|
||||
|
||||
return Status::NotSupportedError;
|
||||
}
|
||||
else if (_renderType != RenderType::Auto)
|
||||
{
|
||||
if (_renderType == RenderType::OpenGL)
|
||||
{
|
||||
#if KIERO_INCLUDE_OPENGL
|
||||
HMODULE libOpenGL32;
|
||||
if ((libOpenGL32 = ::GetModuleHandle(KIERO_TEXT("opengl32.dll"))) == NULL)
|
||||
{
|
||||
return Status::ModuleNotFoundError;
|
||||
}
|
||||
|
||||
const char* const methodsNames[] = {
|
||||
"glAccum", "glAlphaFunc", "glAreTexturesResident", "glArrayElement", "glBegin", "glBindTexture", "glBitmap", "glBlendFunc", "glCallList", "glCallLists", "glClear", "glClearAccum",
|
||||
"glClearColor", "glClearDepth", "glClearIndex", "glClearStencil", "glClipPlane", "glColor3b", "glColor3bv", "glColor3d", "glColor3dv", "glColor3f", "glColor3fv", "glColor3i", "glColor3iv",
|
||||
"glColor3s", "glColor3sv", "glColor3ub", "glColor3ubv", "glColor3ui", "glColor3uiv", "glColor3us", "glColor3usv", "glColor4b", "glColor4bv", "glColor4d", "glColor4dv", "glColor4f",
|
||||
"glColor4fv", "glColor4i", "glColor4iv", "glColor4s", "glColor4sv", "glColor4ub", "glColor4ubv", "glColor4ui", "glColor4uiv", "glColor4us", "glColor4usv", "glColorMask", "glColorMaterial",
|
||||
"glColorPointer", "glCopyPixels", "glCopyTexImage1D", "glCopyTexImage2D", "glCopyTexSubImage1D", "glCopyTexSubImage2D", "glCullFaceglCullFace", "glDeleteLists", "glDeleteTextures",
|
||||
"glDepthFunc", "glDepthMask", "glDepthRange", "glDisable", "glDisableClientState", "glDrawArrays", "glDrawBuffer", "glDrawElements", "glDrawPixels", "glEdgeFlag", "glEdgeFlagPointer",
|
||||
"glEdgeFlagv", "glEnable", "glEnableClientState", "glEnd", "glEndList", "glEvalCoord1d", "glEvalCoord1dv", "glEvalCoord1f", "glEvalCoord1fv", "glEvalCoord2d", "glEvalCoord2dv",
|
||||
"glEvalCoord2f", "glEvalCoord2fv", "glEvalMesh1", "glEvalMesh2", "glEvalPoint1", "glEvalPoint2", "glFeedbackBuffer", "glFinish", "glFlush", "glFogf", "glFogfv", "glFogi", "glFogiv",
|
||||
"glFrontFace", "glFrustum", "glGenLists", "glGenTextures", "glGetBooleanv", "glGetClipPlane", "glGetDoublev", "glGetError", "glGetFloatv", "glGetIntegerv", "glGetLightfv", "glGetLightiv",
|
||||
"glGetMapdv", "glGetMapfv", "glGetMapiv", "glGetMaterialfv", "glGetMaterialiv", "glGetPixelMapfv", "glGetPixelMapuiv", "glGetPixelMapusv", "glGetPointerv", "glGetPolygonStipple",
|
||||
"glGetString", "glGetTexEnvfv", "glGetTexEnviv", "glGetTexGendv", "glGetTexGenfv", "glGetTexGeniv", "glGetTexImage", "glGetTexLevelParameterfv", "glGetTexLevelParameteriv",
|
||||
"glGetTexParameterfv", "glGetTexParameteriv", "glHint", "glIndexMask", "glIndexPointer", "glIndexd", "glIndexdv", "glIndexf", "glIndexfv", "glIndexi", "glIndexiv", "glIndexs", "glIndexsv",
|
||||
"glIndexub", "glIndexubv", "glInitNames", "glInterleavedArrays", "glIsEnabled", "glIsList", "glIsTexture", "glLightModelf", "glLightModelfv", "glLightModeli", "glLightModeliv", "glLightf",
|
||||
"glLightfv", "glLighti", "glLightiv", "glLineStipple", "glLineWidth", "glListBase", "glLoadIdentity", "glLoadMatrixd", "glLoadMatrixf", "glLoadName", "glLogicOp", "glMap1d", "glMap1f",
|
||||
"glMap2d", "glMap2f", "glMapGrid1d", "glMapGrid1f", "glMapGrid2d", "glMapGrid2f", "glMaterialf", "glMaterialfv", "glMateriali", "glMaterialiv", "glMatrixMode", "glMultMatrixd",
|
||||
"glMultMatrixf", "glNewList", "glNormal3b", "glNormal3bv", "glNormal3d", "glNormal3dv", "glNormal3f", "glNormal3fv", "glNormal3i", "glNormal3iv", "glNormal3s", "glNormal3sv",
|
||||
"glNormalPointer", "glOrtho", "glPassThrough", "glPixelMapfv", "glPixelMapuiv", "glPixelMapusv", "glPixelStoref", "glPixelStorei", "glPixelTransferf", "glPixelTransferi", "glPixelZoom",
|
||||
"glPointSize", "glPolygonMode", "glPolygonOffset", "glPolygonStipple", "glPopAttrib", "glPopClientAttrib", "glPopMatrix", "glPopName", "glPrioritizeTextures", "glPushAttrib",
|
||||
"glPushClientAttrib", "glPushMatrix", "glPushName", "glRasterPos2d", "glRasterPos2dv", "glRasterPos2f", "glRasterPos2fv", "glRasterPos2i", "glRasterPos2iv", "glRasterPos2s",
|
||||
"glRasterPos2sv", "glRasterPos3d", "glRasterPos3dv", "glRasterPos3f", "glRasterPos3fv", "glRasterPos3i", "glRasterPos3iv", "glRasterPos3s", "glRasterPos3sv", "glRasterPos4d",
|
||||
"glRasterPos4dv", "glRasterPos4f", "glRasterPos4fv", "glRasterPos4i", "glRasterPos4iv", "glRasterPos4s", "glRasterPos4sv", "glReadBuffer", "glReadPixels", "glRectd", "glRectdv", "glRectf",
|
||||
"glRectfv", "glRecti", "glRectiv", "glRects", "glRectsv", "glRenderMode", "glRotated", "glRotatef", "glScaled", "glScalef", "glScissor", "glSelectBuffer", "glShadeModel", "glStencilFunc",
|
||||
"glStencilMask", "glStencilOp", "glTexCoord1d", "glTexCoord1dv", "glTexCoord1f", "glTexCoord1fv", "glTexCoord1i", "glTexCoord1iv", "glTexCoord1s", "glTexCoord1sv", "glTexCoord2d",
|
||||
"glTexCoord2dv", "glTexCoord2f", "glTexCoord2fv", "glTexCoord2i", "glTexCoord2iv", "glTexCoord2s", "glTexCoord2sv", "glTexCoord3d", "glTexCoord3dv", "glTexCoord3f", "glTexCoord3fv",
|
||||
"glTexCoord3i", "glTexCoord3iv", "glTexCoord3s", "glTexCoord3sv", "glTexCoord4d", "glTexCoord4dv", "glTexCoord4f", "glTexCoord4fv", "glTexCoord4i", "glTexCoord4iv", "glTexCoord4s",
|
||||
"glTexCoord4sv", "glTexCoordPointer", "glTexEnvf", "glTexEnvfv", "glTexEnvi", "glTexEnviv", "glTexGend", "glTexGendv", "glTexGenf", "glTexGenfv", "glTexGeni", "glTexGeniv", "glTexImage1D",
|
||||
"glTexImage2D", "glTexParameterf", "glTexParameterfv", "glTexParameteri", "glTexParameteriv", "glTexSubImage1D", "glTexSubImage2D", "glTranslated", "glTranslatef", "glVertex2d",
|
||||
"glVertex2dv", "glVertex2f", "glVertex2fv", "glVertex2i", "glVertex2iv", "glVertex2s", "glVertex2sv", "glVertex3d", "glVertex3dv", "glVertex3f", "glVertex3fv", "glVertex3i", "glVertex3iv",
|
||||
"glVertex3s", "glVertex3sv", "glVertex4d", "glVertex4dv", "glVertex4f", "glVertex4fv", "glVertex4i", "glVertex4iv", "glVertex4s", "glVertex4sv", "glVertexPointer", "glViewport"
|
||||
};
|
||||
|
||||
size_t size = KIERO_ARRAY_SIZE(methodsNames);
|
||||
|
||||
g_methodsTable = (uint150_t*)::calloc(size, sizeof(uint150_t));
|
||||
|
||||
for (int i = 0; i < size; i++)
|
||||
{
|
||||
g_methodsTable[i] = (uint150_t)::GetProcAddress(libOpenGL32, methodsNames[i]);
|
||||
}
|
||||
|
||||
#if KIERO_USE_MINHOOK
|
||||
MH_Initialize();
|
||||
#endif
|
||||
|
||||
g_renderType = RenderType::OpenGL;
|
||||
|
||||
return Status::Success;
|
||||
#endif
|
||||
}
|
||||
else if (_renderType == RenderType::Vulkan)
|
||||
{
|
||||
#if KIERO_INCLUDE_VULKAN
|
||||
HMODULE libVulkan;
|
||||
if ((libVulkan = GetModuleHandle(KIERO_TEXT("vulkan-1.dll"))) == NULL)
|
||||
{
|
||||
return Status::ModuleNotFoundError;
|
||||
}
|
||||
|
||||
const char* const methodsNames[] = {
|
||||
"vkCreateInstance", "vkDestroyInstance", "vkEnumeratePhysicalDevices", "vkGetPhysicalDeviceFeatures", "vkGetPhysicalDeviceFormatProperties", "vkGetPhysicalDeviceImageFormatProperties",
|
||||
"vkGetPhysicalDeviceProperties", "vkGetPhysicalDeviceQueueFamilyProperties", "vkGetPhysicalDeviceMemoryProperties", "vkGetInstanceProcAddr", "vkGetDeviceProcAddr", "vkCreateDevice",
|
||||
"vkDestroyDevice", "vkEnumerateInstanceExtensionProperties", "vkEnumerateDeviceExtensionProperties", "vkEnumerateDeviceLayerProperties", "vkGetDeviceQueue", "vkQueueSubmit", "vkQueueWaitIdle",
|
||||
"vkDeviceWaitIdle", "vkAllocateMemory", "vkFreeMemory", "vkMapMemory", "vkUnmapMemory", "vkFlushMappedMemoryRanges", "vkInvalidateMappedMemoryRanges", "vkGetDeviceMemoryCommitment",
|
||||
"vkBindBufferMemory", "vkBindImageMemory", "vkGetBufferMemoryRequirements", "vkGetImageMemoryRequirements", "vkGetImageSparseMemoryRequirements", "vkGetPhysicalDeviceSparseImageFormatProperties",
|
||||
"vkQueueBindSparse", "vkCreateFence", "vkDestroyFence", "vkResetFences", "vkGetFenceStatus", "vkWaitForFences", "vkCreateSemaphore", "vkDestroySemaphore", "vkCreateEvent", "vkDestroyEvent",
|
||||
"vkGetEventStatus", "vkSetEvent", "vkResetEvent", "vkCreateQueryPool", "vkDestroyQueryPool", "vkGetQueryPoolResults", "vkCreateBuffer", "vkDestroyBuffer", "vkCreateBufferView", "vkDestroyBufferView",
|
||||
"vkCreateImage", "vkDestroyImage", "vkGetImageSubresourceLayout", "vkCreateImageView", "vkDestroyImageView", "vkCreateShaderModule", "vkDestroyShaderModule", "vkCreatePipelineCache",
|
||||
"vkDestroyPipelineCache", "vkGetPipelineCacheData", "vkMergePipelineCaches", "vkCreateGraphicsPipelines", "vkCreateComputePipelines", "vkDestroyPipeline", "vkCreatePipelineLayout",
|
||||
"vkDestroyPipelineLayout", "vkCreateSampler", "vkDestroySampler", "vkCreateDescriptorSetLayout", "vkDestroyDescriptorSetLayout", "vkCreateDescriptorPool", "vkDestroyDescriptorPool",
|
||||
"vkResetDescriptorPool", "vkAllocateDescriptorSets", "vkFreeDescriptorSets", "vkUpdateDescriptorSets", "vkCreateFramebuffer", "vkDestroyFramebuffer", "vkCreateRenderPass", "vkDestroyRenderPass",
|
||||
"vkGetRenderAreaGranularity", "vkCreateCommandPool", "vkDestroyCommandPool", "vkResetCommandPool", "vkAllocateCommandBuffers", "vkFreeCommandBuffers", "vkBeginCommandBuffer", "vkEndCommandBuffer",
|
||||
"vkResetCommandBuffer", "vkCmdBindPipeline", "vkCmdSetViewport", "vkCmdSetScissor", "vkCmdSetLineWidth", "vkCmdSetDepthBias", "vkCmdSetBlendConstants", "vkCmdSetDepthBounds",
|
||||
"vkCmdSetStencilCompareMask", "vkCmdSetStencilWriteMask", "vkCmdSetStencilReference", "vkCmdBindDescriptorSets", "vkCmdBindIndexBuffer", "vkCmdBindVertexBuffers", "vkCmdDraw", "vkCmdDrawIndexed",
|
||||
"vkCmdDrawIndirect", "vkCmdDrawIndexedIndirect", "vkCmdDispatch", "vkCmdDispatchIndirect", "vkCmdCopyBuffer", "vkCmdCopyImage", "vkCmdBlitImage", "vkCmdCopyBufferToImage", "vkCmdCopyImageToBuffer",
|
||||
"vkCmdUpdateBuffer", "vkCmdFillBuffer", "vkCmdClearColorImage", "vkCmdClearDepthStencilImage", "vkCmdClearAttachments", "vkCmdResolveImage", "vkCmdSetEvent", "vkCmdResetEvent", "vkCmdWaitEvents",
|
||||
"vkCmdPipelineBarrier", "vkCmdBeginQuery", "vkCmdEndQuery", "vkCmdResetQueryPool", "vkCmdWriteTimestamp", "vkCmdCopyQueryPoolResults", "vkCmdPushConstants", "vkCmdBeginRenderPass", "vkCmdNextSubpass",
|
||||
"vkCmdEndRenderPass", "vkCmdExecuteCommands"
|
||||
};
|
||||
|
||||
size_t size = KIERO_ARRAY_SIZE(methodsNames);
|
||||
|
||||
g_methodsTable = (uint150_t*)::calloc(size, sizeof(uint150_t));
|
||||
|
||||
for (int i = 0; i < size; i++)
|
||||
{
|
||||
g_methodsTable[i] = (uint150_t)::GetProcAddress(libVulkan, methodsNames[i]);
|
||||
}
|
||||
|
||||
#if KIERO_USE_MINHOOK
|
||||
MH_Initialize();
|
||||
#endif
|
||||
|
||||
g_renderType = RenderType::Vulkan;
|
||||
|
||||
return Status::Success;
|
||||
#endif
|
||||
}
|
||||
|
||||
return Status::NotSupportedError;
|
||||
}
|
||||
else
|
||||
{
|
||||
RenderType::Enum type = RenderType::None;
|
||||
|
||||
if (::GetModuleHandle(KIERO_TEXT("d3d9.dll")) != NULL)
|
||||
{
|
||||
type = RenderType::D3D9;
|
||||
}
|
||||
else if (::GetModuleHandle(KIERO_TEXT("d3d10.dll")) != NULL)
|
||||
{
|
||||
type = RenderType::D3D10;
|
||||
}
|
||||
else if (::GetModuleHandle(KIERO_TEXT("d3d11.dll")) != NULL)
|
||||
{
|
||||
type = RenderType::D3D11;
|
||||
}
|
||||
else if (::GetModuleHandle(KIERO_TEXT("d3d12.dll")) != NULL)
|
||||
{
|
||||
type = RenderType::D3D12;
|
||||
}
|
||||
else if (::GetModuleHandle(KIERO_TEXT("opengl32.dll")) != NULL)
|
||||
{
|
||||
type = RenderType::OpenGL;
|
||||
}
|
||||
else if (::GetModuleHandle(KIERO_TEXT("vulkan-1.dll")) != NULL)
|
||||
{
|
||||
type = RenderType::Vulkan;
|
||||
}
|
||||
else
|
||||
{
|
||||
return Status::NotSupportedError;
|
||||
}
|
||||
|
||||
return init(type);
|
||||
}
|
||||
}
|
||||
|
||||
return Status::Success;
|
||||
}
|
||||
|
||||
void kiero::shutdown()
|
||||
{
|
||||
if (g_renderType != RenderType::None)
|
||||
{
|
||||
#if KIERO_USE_MINHOOK
|
||||
MH_DisableHook(MH_ALL_HOOKS);
|
||||
#endif
|
||||
|
||||
::free(g_methodsTable);
|
||||
g_methodsTable = NULL;
|
||||
g_renderType = RenderType::None;
|
||||
}
|
||||
}
|
||||
|
||||
kiero::Status::Enum kiero::bind(uint16_t _index, void** _original, void* _function)
|
||||
{
|
||||
// TODO: Need own detour function
|
||||
|
||||
assert(_original != NULL && _function != NULL);
|
||||
|
||||
if (g_renderType != RenderType::None)
|
||||
{
|
||||
#if KIERO_USE_MINHOOK
|
||||
void* target = (void*)g_methodsTable[_index];
|
||||
if (MH_CreateHook(target, _function, _original) != MH_OK || MH_EnableHook(target) != MH_OK)
|
||||
{
|
||||
return Status::UnknownError;
|
||||
}
|
||||
#endif
|
||||
|
||||
return Status::Success;
|
||||
}
|
||||
|
||||
return Status::NotInitializedError;
|
||||
}
|
||||
|
||||
void kiero::unbind(uint16_t _index)
|
||||
{
|
||||
if (g_renderType != RenderType::None)
|
||||
{
|
||||
#if KIERO_USE_MINHOOK
|
||||
MH_DisableHook((void*)g_methodsTable[_index]);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
kiero::RenderType::Enum kiero::getRenderType()
|
||||
{
|
||||
return g_renderType;
|
||||
}
|
||||
|
||||
uint150_t* kiero::getMethodsTable()
|
||||
{
|
||||
return g_methodsTable;
|
||||
}
|
102
CheatMenu/external/kiero/kiero.h
vendored
Normal file
@ -0,0 +1,102 @@
|
||||
/* Slightly modified version of https://github.com/Rebzzel/kiero
|
||||
|
||||
MIT License
|
||||
|
||||
Copyright(c) 2014 - 2020 Rebzzel
|
||||
|
||||
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.
|
||||
*/
|
||||
#ifndef __KIERO_H__
|
||||
#define __KIERO_H__
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#define KIERO_VERSION "1.2.10"
|
||||
|
||||
#define KIERO_INCLUDE_D3D9 1 // 1 if you need D3D9 hook
|
||||
#define KIERO_INCLUDE_D3D10 0 // 1 if you need D3D10 hook
|
||||
#define KIERO_INCLUDE_D3D11 1 // 1 if you need D3D11 hook
|
||||
#define KIERO_INCLUDE_D3D12 0 // 1 if you need D3D12 hook
|
||||
#define KIERO_INCLUDE_OPENGL 0 // 1 if you need OpenGL hook
|
||||
#define KIERO_INCLUDE_VULKAN 0 // 1 if you need Vulkan hook
|
||||
#define KIERO_USE_MINHOOK 1 // 1 if you will use kiero::bind function
|
||||
|
||||
#define KIERO_ARCH_X64 0
|
||||
#define KIERO_ARCH_X86 0
|
||||
|
||||
#if defined(_M_X64)
|
||||
# undef KIERO_ARCH_X64
|
||||
# define KIERO_ARCH_X64 1
|
||||
#else
|
||||
# undef KIERO_ARCH_X86
|
||||
# define KIERO_ARCH_X86 1
|
||||
#endif
|
||||
|
||||
#if KIERO_ARCH_X64
|
||||
typedef uint64_t uint150_t;
|
||||
#else
|
||||
typedef uint32_t uint150_t;
|
||||
#endif
|
||||
|
||||
namespace kiero
|
||||
{
|
||||
struct Status
|
||||
{
|
||||
enum Enum
|
||||
{
|
||||
UnknownError = -1,
|
||||
NotSupportedError = -2,
|
||||
ModuleNotFoundError = -3,
|
||||
|
||||
AlreadyInitializedError = -4,
|
||||
NotInitializedError = -5,
|
||||
|
||||
Success = 0,
|
||||
};
|
||||
};
|
||||
|
||||
struct RenderType
|
||||
{
|
||||
enum Enum
|
||||
{
|
||||
None,
|
||||
|
||||
D3D9,
|
||||
D3D10,
|
||||
D3D11,
|
||||
D3D12,
|
||||
|
||||
OpenGL,
|
||||
Vulkan,
|
||||
|
||||
Auto
|
||||
};
|
||||
};
|
||||
|
||||
Status::Enum init(RenderType::Enum renderType);
|
||||
void shutdown();
|
||||
|
||||
Status::Enum bind(uint16_t index, void** original, void* function);
|
||||
void unbind(uint16_t index);
|
||||
|
||||
RenderType::Enum getRenderType();
|
||||
uint150_t* getMethodsTable();
|
||||
}
|
||||
|
||||
#endif // __KIERO_H__
|
186
CheatMenu/external/kiero/minhook/include/MinHook.h
vendored
Normal file
@ -0,0 +1,186 @@
|
||||
/*
|
||||
* MinHook - The Minimalistic API Hooking Library for x64/x86
|
||||
* Copyright (C) 2009-2017 Tsuda Kageyu.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
|
||||
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER
|
||||
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#if !(defined _M_IX86) && !(defined _M_X64) && !(defined __i386__) && !(defined __x86_64__)
|
||||
#error MinHook supports only x86 and x64 systems.
|
||||
#endif
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
// MinHook Error Codes.
|
||||
typedef enum MH_STATUS
|
||||
{
|
||||
// Unknown error. Should not be returned.
|
||||
MH_UNKNOWN = -1,
|
||||
|
||||
// Successful.
|
||||
MH_OK = 0,
|
||||
|
||||
// MinHook is already initialized.
|
||||
MH_ERROR_ALREADY_INITIALIZED,
|
||||
|
||||
// MinHook is not initialized yet, or already uninitialized.
|
||||
MH_ERROR_NOT_INITIALIZED,
|
||||
|
||||
// The hook for the specified target function is already created.
|
||||
MH_ERROR_ALREADY_CREATED,
|
||||
|
||||
// The hook for the specified target function is not created yet.
|
||||
MH_ERROR_NOT_CREATED,
|
||||
|
||||
// The hook for the specified target function is already enabled.
|
||||
MH_ERROR_ENABLED,
|
||||
|
||||
// The hook for the specified target function is not enabled yet, or already
|
||||
// disabled.
|
||||
MH_ERROR_DISABLED,
|
||||
|
||||
// The specified pointer is invalid. It points the address of non-allocated
|
||||
// and/or non-executable region.
|
||||
MH_ERROR_NOT_EXECUTABLE,
|
||||
|
||||
// The specified target function cannot be hooked.
|
||||
MH_ERROR_UNSUPPORTED_FUNCTION,
|
||||
|
||||
// Failed to allocate memory.
|
||||
MH_ERROR_MEMORY_ALLOC,
|
||||
|
||||
// Failed to change the memory protection.
|
||||
MH_ERROR_MEMORY_PROTECT,
|
||||
|
||||
// The specified module is not loaded.
|
||||
MH_ERROR_MODULE_NOT_FOUND,
|
||||
|
||||
// The specified function is not found.
|
||||
MH_ERROR_FUNCTION_NOT_FOUND
|
||||
}
|
||||
MH_STATUS;
|
||||
|
||||
// Can be passed as a parameter to MH_EnableHook, MH_DisableHook,
|
||||
// MH_QueueEnableHook or MH_QueueDisableHook.
|
||||
#define MH_ALL_HOOKS NULL
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// Initialize the MinHook library. You must call this function EXACTLY ONCE
|
||||
// at the beginning of your program.
|
||||
MH_STATUS WINAPI MH_Initialize(VOID);
|
||||
|
||||
// Uninitialize the MinHook library. You must call this function EXACTLY
|
||||
// ONCE at the end of your program.
|
||||
MH_STATUS WINAPI MH_Uninitialize(VOID);
|
||||
|
||||
// Creates a Hook for the specified target function, in disabled state.
|
||||
// Parameters:
|
||||
// pTarget [in] A pointer to the target function, which will be
|
||||
// overridden by the detour function.
|
||||
// pDetour [in] A pointer to the detour function, which will override
|
||||
// the target function.
|
||||
// ppOriginal [out] A pointer to the trampoline function, which will be
|
||||
// used to call the original target function.
|
||||
// This parameter can be NULL.
|
||||
MH_STATUS WINAPI MH_CreateHook(LPVOID pTarget, LPVOID pDetour, LPVOID *ppOriginal);
|
||||
|
||||
// Creates a Hook for the specified API function, in disabled state.
|
||||
// Parameters:
|
||||
// pszModule [in] A pointer to the loaded module name which contains the
|
||||
// target function.
|
||||
// pszTarget [in] A pointer to the target function name, which will be
|
||||
// overridden by the detour function.
|
||||
// pDetour [in] A pointer to the detour function, which will override
|
||||
// the target function.
|
||||
// ppOriginal [out] A pointer to the trampoline function, which will be
|
||||
// used to call the original target function.
|
||||
// This parameter can be NULL.
|
||||
MH_STATUS WINAPI MH_CreateHookApi(
|
||||
LPCWSTR pszModule, LPCSTR pszProcName, LPVOID pDetour, LPVOID *ppOriginal);
|
||||
|
||||
// Creates a Hook for the specified API function, in disabled state.
|
||||
// Parameters:
|
||||
// pszModule [in] A pointer to the loaded module name which contains the
|
||||
// target function.
|
||||
// pszTarget [in] A pointer to the target function name, which will be
|
||||
// overridden by the detour function.
|
||||
// pDetour [in] A pointer to the detour function, which will override
|
||||
// the target function.
|
||||
// ppOriginal [out] A pointer to the trampoline function, which will be
|
||||
// used to call the original target function.
|
||||
// This parameter can be NULL.
|
||||
// ppTarget [out] A pointer to the target function, which will be used
|
||||
// with other functions.
|
||||
// This parameter can be NULL.
|
||||
MH_STATUS WINAPI MH_CreateHookApiEx(
|
||||
LPCWSTR pszModule, LPCSTR pszProcName, LPVOID pDetour, LPVOID *ppOriginal, LPVOID *ppTarget);
|
||||
|
||||
// Removes an already created hook.
|
||||
// Parameters:
|
||||
// pTarget [in] A pointer to the target function.
|
||||
MH_STATUS WINAPI MH_RemoveHook(LPVOID pTarget);
|
||||
|
||||
// Enables an already created hook.
|
||||
// Parameters:
|
||||
// pTarget [in] A pointer to the target function.
|
||||
// If this parameter is MH_ALL_HOOKS, all created hooks are
|
||||
// enabled in one go.
|
||||
MH_STATUS WINAPI MH_EnableHook(LPVOID pTarget);
|
||||
|
||||
// Disables an already created hook.
|
||||
// Parameters:
|
||||
// pTarget [in] A pointer to the target function.
|
||||
// If this parameter is MH_ALL_HOOKS, all created hooks are
|
||||
// disabled in one go.
|
||||
MH_STATUS WINAPI MH_DisableHook(LPVOID pTarget);
|
||||
|
||||
// Queues to enable an already created hook.
|
||||
// Parameters:
|
||||
// pTarget [in] A pointer to the target function.
|
||||
// If this parameter is MH_ALL_HOOKS, all created hooks are
|
||||
// queued to be enabled.
|
||||
MH_STATUS WINAPI MH_QueueEnableHook(LPVOID pTarget);
|
||||
|
||||
// Queues to disable an already created hook.
|
||||
// Parameters:
|
||||
// pTarget [in] A pointer to the target function.
|
||||
// If this parameter is MH_ALL_HOOKS, all created hooks are
|
||||
// queued to be disabled.
|
||||
MH_STATUS WINAPI MH_QueueDisableHook(LPVOID pTarget);
|
||||
|
||||
// Applies all queued changes in one go.
|
||||
MH_STATUS WINAPI MH_ApplyQueued(VOID);
|
||||
|
||||
// Translates the MH_STATUS to its name as a string.
|
||||
const char * WINAPI MH_StatusToString(MH_STATUS status);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
74
CheatMenu/external/moon/pool_object_extender.h
vendored
Normal file
@ -0,0 +1,74 @@
|
||||
// This 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.
|
||||
|
||||
#pragma once
|
||||
#include <unordered_map>
|
||||
|
||||
template<typename ObjT, typename DataT>
|
||||
class ExtendedObjectDataPool
|
||||
{
|
||||
public:
|
||||
auto begin()
|
||||
{
|
||||
return _pool.begin();
|
||||
}
|
||||
|
||||
auto end()
|
||||
{
|
||||
return _pool.end();
|
||||
}
|
||||
|
||||
bool exists(const ObjT* obj) const
|
||||
{
|
||||
return _pool.find(obj) != _pool.end();
|
||||
}
|
||||
|
||||
DataT& get(const ObjT* obj)
|
||||
{
|
||||
auto& it = _pool.find(obj);
|
||||
if (it != _pool.end())
|
||||
return *it->second;
|
||||
return *(_pool[obj] = std::make_unique<DataT>(obj));
|
||||
}
|
||||
|
||||
void remove(const ObjT* obj)
|
||||
{
|
||||
_pool.erase(obj);
|
||||
}
|
||||
|
||||
private:
|
||||
std::unordered_map<const ObjT*, std::unique_ptr<DataT>> _pool;
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
class VehicleDataExtended : public ExtendedObjectDataPool<CVehicle, T>
|
||||
{
|
||||
public:
|
||||
VehicleDataExtended()
|
||||
{
|
||||
plugin::Events::vehicleDtorEvent.after += [this](CVehicle* veh) {
|
||||
this->remove(veh);
|
||||
};
|
||||
}
|
||||
};
|
58
CheatMenu/external/moon/texture_manager.cpp
vendored
Normal file
@ -0,0 +1,58 @@
|
||||
// This 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.
|
||||
#include "..\..\pch.h"
|
||||
#include "texture_manager.h"
|
||||
|
||||
RwTexture* createRwTextureFromRwImage(RwImage* image)
|
||||
{
|
||||
RwInt32 width, height, depth, flags;
|
||||
RwImageFindRasterFormat(image, 4, &width, &height, &depth, &flags);
|
||||
RwRaster* raster = RwRasterCreate(width, height, depth, flags);
|
||||
RwRasterSetFromImage(raster, image);
|
||||
RwImageDestroy(image);
|
||||
RwTexture* texture = RwTextureCreate(raster);
|
||||
return texture;
|
||||
}
|
||||
|
||||
void setRwTextureNameFromFilename(RwTexture* texture, const fs::path& path)
|
||||
{
|
||||
path.stem().string().copy(texture->name, sizeof(texture->name) - 1);
|
||||
}
|
||||
|
||||
RwTexture* texture_manager::loadTextureFromPngFile(fs::path path)
|
||||
{
|
||||
RwImage* image = RtPNGImageRead(path.string().c_str());
|
||||
if (!image)
|
||||
return nullptr;
|
||||
RwTexture* texture = createRwTextureFromRwImage(image);
|
||||
setRwTextureNameFromFilename(texture, path);
|
||||
return texture;
|
||||
}
|
||||
|
||||
void texture_manager::unloadTexture(RwTexture* texture)
|
||||
{
|
||||
if (!texture)
|
||||
return;
|
||||
RwTextureDestroy(texture);
|
||||
}
|
33
CheatMenu/external/moon/texture_manager.h
vendored
Normal file
@ -0,0 +1,33 @@
|
||||
// This 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.
|
||||
|
||||
#pragma once
|
||||
#include "plugin.h"
|
||||
#include "game_sa\RenderWare.h"
|
||||
|
||||
namespace texture_manager
|
||||
{
|
||||
RwTexture* loadTextureFromPngFile(fs::path path);
|
||||
void unloadTexture(RwTexture* texture9);
|
||||
}
|
145
CheatMenu/external/moon/vehicle_renderer.cpp
vendored
Normal file
@ -0,0 +1,145 @@
|
||||
// This 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.
|
||||
#include "plugin.h"
|
||||
#include "vehicle_renderer.h"
|
||||
|
||||
auto& VehicleRenderer::getVehicleData(CVehicle* veh)
|
||||
{
|
||||
if (!_vehicleData)
|
||||
_vehicleData = std::make_unique<VehicleDataExtended<VehicleData>>();
|
||||
return _vehicleData->get(veh);
|
||||
}
|
||||
|
||||
auto& VehicleRenderer::getVehicleMaterialProperties(CVehicle* veh)
|
||||
{
|
||||
return getVehicleData(veh)._materialProperties;
|
||||
}
|
||||
|
||||
void VehicleRenderer::setMaterialColor(CVehicle* veh, RpMaterial* material, RpGeometry* geometry, RwRGBA color, bool filter_mat)
|
||||
{
|
||||
auto& matProps = getVehicleMaterialProperties(veh)[material];
|
||||
|
||||
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))
|
||||
{
|
||||
matProps._recolor = true;
|
||||
matProps._color = color;
|
||||
matProps._geometry = geometry;
|
||||
}
|
||||
}
|
||||
|
||||
void VehicleRenderer::setMaterialTexture(CVehicle* veh, RpMaterial* material, std::shared_ptr<RwTexture> texture, bool filter_mat)
|
||||
{
|
||||
auto& matProps = getVehicleMaterialProperties(veh)[material];
|
||||
|
||||
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))
|
||||
{
|
||||
matProps._retexture = true;
|
||||
matProps._texture = texture;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void VehicleRenderer::resetMaterialColor(CVehicle* veh, RpMaterial* material)
|
||||
{
|
||||
if (isInitialized() && _vehicleData->exists(veh))
|
||||
{
|
||||
auto& matProps = getVehicleMaterialProperties(veh)[material];
|
||||
matProps._recolor = false;
|
||||
matProps._color = {0, 0, 0, 0};
|
||||
}
|
||||
}
|
||||
|
||||
void VehicleRenderer::resetMaterialTexture(CVehicle* veh, RpMaterial* material)
|
||||
{
|
||||
if (isInitialized() && _vehicleData->exists(veh))
|
||||
{
|
||||
auto& matProps = getVehicleMaterialProperties(veh)[material];
|
||||
matProps._retexture = false;
|
||||
matProps._texture.reset();
|
||||
}
|
||||
}
|
||||
|
||||
void VehicleRenderer::processRender(CVehicle* veh)
|
||||
{
|
||||
if (isInitialized() && _vehicleData->exists(veh))
|
||||
{
|
||||
// reset custom color if color id changed
|
||||
if (veh->m_nPrimaryColor != getVehicleData(veh).primary_color
|
||||
|| veh->m_nSecondaryColor != getVehicleData(veh).secondary_color)
|
||||
{
|
||||
for (auto& it : _vehicleData->get(veh)._materialProperties)
|
||||
resetMaterialColor(veh, it.first);
|
||||
|
||||
getVehicleData(veh).primary_color = veh->m_nPrimaryColor;
|
||||
getVehicleData(veh).secondary_color = veh->m_nSecondaryColor;
|
||||
}
|
||||
|
||||
for (auto& it : _vehicleData->get(veh)._materialProperties)
|
||||
{
|
||||
if (it.second._recolor)
|
||||
{
|
||||
it.second._originalColor = it.first->color;
|
||||
it.first->color = it.second._color;
|
||||
it.second._originalGeometryFlags = it.second._geometry->flags;
|
||||
it.second._geometry->flags |= rpGEOMETRYMODULATEMATERIALCOLOR;
|
||||
}
|
||||
if (it.second._retexture)
|
||||
{
|
||||
auto tex = it.second._texture.lock();
|
||||
if (tex)
|
||||
{
|
||||
it.second._originalTexture = it.first->texture;
|
||||
it.first->texture = tex.get();
|
||||
}
|
||||
else
|
||||
{
|
||||
it.second._retexture = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void VehicleRenderer::postRender(CVehicle* veh)
|
||||
{
|
||||
if (isInitialized() && _vehicleData->exists(veh))
|
||||
{
|
||||
for (auto& it : _vehicleData->get(veh)._materialProperties)
|
||||
{
|
||||
if (it.second._recolor)
|
||||
{
|
||||
it.first->color = it.second._originalColor;
|
||||
it.second._geometry->flags = it.second._originalGeometryFlags;
|
||||
}
|
||||
if (it.second._retexture)
|
||||
{
|
||||
it.first->texture = it.second._originalTexture;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
87
CheatMenu/external/moon/vehicle_renderer.h
vendored
Normal file
@ -0,0 +1,87 @@
|
||||
// This 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.
|
||||
|
||||
#pragma once
|
||||
#include "pool_object_extender.h"
|
||||
class VehicleRenderer
|
||||
{
|
||||
struct MaterialProperties
|
||||
{
|
||||
MaterialProperties() :
|
||||
_color{0, 0, 0, 0},
|
||||
_recolor(false),
|
||||
_retexture(false),
|
||||
_originalColor{0, 0, 0, 0},
|
||||
_originalTexture(nullptr),
|
||||
_originalGeometryFlags(0),
|
||||
_geometry(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
RwRGBA _color;
|
||||
std::weak_ptr<RwTexture> _texture;
|
||||
bool _recolor;
|
||||
bool _retexture;
|
||||
RpGeometry* _geometry;
|
||||
RwRGBA _originalColor;
|
||||
RwTexture* _originalTexture;
|
||||
RwInt32 _originalGeometryFlags;
|
||||
};
|
||||
|
||||
struct VehicleData
|
||||
{
|
||||
VehicleData(const CVehicle* veh)
|
||||
{
|
||||
primary_color = veh->m_nPrimaryColor;
|
||||
secondary_color = veh->m_nSecondaryColor;
|
||||
}
|
||||
|
||||
// carcols color id
|
||||
uchar primary_color;
|
||||
uchar secondary_color;
|
||||
|
||||
std::unordered_map<RpMaterial*, MaterialProperties> _materialProperties;
|
||||
};
|
||||
|
||||
public:
|
||||
void setMaterialColor(CVehicle* veh, RpMaterial* material, RpGeometry* geometry, RwRGBA color, bool filter_mat = false);
|
||||
void setMaterialTexture(CVehicle* veh, RpMaterial* material, std::shared_ptr<RwTexture> texture9, bool filter_mat = false);
|
||||
void resetMaterialColor(CVehicle* veh, RpMaterial* material);
|
||||
void resetMaterialTexture(CVehicle* veh, RpMaterial* material);
|
||||
void processRender(CVehicle* veh);
|
||||
void postRender(CVehicle* veh);
|
||||
bool isInitialized() const { return _vehicleData != nullptr; }
|
||||
|
||||
static VehicleRenderer* get()
|
||||
{
|
||||
static std::unique_ptr<VehicleRenderer> instance = std::make_unique<VehicleRenderer>();
|
||||
return instance.get();
|
||||
}
|
||||
|
||||
private:
|
||||
auto& getVehicleMaterialProperties(CVehicle* veh);
|
||||
auto& getVehicleData(CVehicle* veh);
|
||||
|
||||
std::unique_ptr<VehicleDataExtended<VehicleData>> _vehicleData;
|
||||
};
|
18
CheatMenu/pch.cpp
Normal file
@ -0,0 +1,18 @@
|
||||
#include "pch.h"
|
||||
|
||||
std::string Globals::header_id = "";
|
||||
int Globals::last_key_timer = 0;
|
||||
ImVec2 Globals::menu_size = ImVec2(screen::GetScreenWidth()/4, screen::GetScreenHeight()/1.2);
|
||||
std::string Globals::menu_title = std::string("Cheat Menu v") + std::string(MENU_VERSION);
|
||||
ImVec2 Globals::font_screen_size = ImVec2(-1, -1);
|
||||
bool Globals::show_menu = false;
|
||||
bool Globals::init_done = false;
|
||||
Renderer Globals::renderer = Render_Unknown;
|
||||
ID3D11Device *Globals::device11 = nullptr;
|
||||
|
||||
CJson config = CJson("config", true);
|
||||
std::ofstream flog = std::ofstream("CheatMenu.log");
|
||||
|
||||
std::random_device rd;
|
||||
std::mt19937 gen(rd());
|
||||
std::uniform_int_distribution<> cheat_id(0, 91);
|
108
CheatMenu/pch.h
Normal file
@ -0,0 +1,108 @@
|
||||
#pragma once
|
||||
#pragma warning(disable:4503 4244)
|
||||
|
||||
#define INPUT_BUFFER_SIZE 64
|
||||
#define SPAWN_PED_LIMIT 20
|
||||
#define MENU_VERSION "2.5-alpha"
|
||||
#define BUILD_NUMBER "20201112"
|
||||
#define STB_IMAGE_IMPLEMENTATION
|
||||
|
||||
#include <ctime>
|
||||
#include <d3d9.h>
|
||||
#include <d3d11.h>
|
||||
#include <d3d11Shader.h>
|
||||
#include <D3dx9tex.h>
|
||||
#include <D3DX11tex.h>
|
||||
#include <filesystem>
|
||||
#include <fstream>
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
#include <random>
|
||||
#include <sstream>
|
||||
#include <vector>
|
||||
#include <windows.h>
|
||||
|
||||
#include "plugin.h"
|
||||
#include "CCamera.h"
|
||||
#include "CCheat.h"
|
||||
#include "CClothes.h"
|
||||
#include "CClock.h"
|
||||
#include "CCivilianPed.h"
|
||||
#include "CCutsceneMgr.h"
|
||||
#include "CGangs.h"
|
||||
#include "CGangWars.h"
|
||||
#include "cHandlingDataMgr.h"
|
||||
#include "CHud.h"
|
||||
#include "CMenuManager.h"
|
||||
#include "CModelInfo.h"
|
||||
#include "CRadar.h"
|
||||
#include "RenderWare.h"
|
||||
#include "CStats.h"
|
||||
#include "CStreaming.h"
|
||||
#include "CTheScripts.h"
|
||||
#include "CTheZones.h"
|
||||
#include "CTimer.h"
|
||||
#include "CTimeCycle.h"
|
||||
#include "CWeather.h"
|
||||
#include "CWorld.h"
|
||||
#include "extensions/ScriptCommands.h"
|
||||
#include "extensions/Screen.h"
|
||||
#include "eVehicleClass.h"
|
||||
|
||||
#include "external/imgui/imgui.h"
|
||||
#include "external/imgui/imgui_impl_dx9.h"
|
||||
#include "external/imgui/imgui_impl_dx11.h"
|
||||
#include "external/imgui/imgui_impl_win32.h"
|
||||
|
||||
#include "Events.h"
|
||||
#include "Json.h"
|
||||
#include "VKeys.h"
|
||||
|
||||
// Globals
|
||||
typedef std::vector<std::pair<std::string, void(*)(void)>> unsortedMap;
|
||||
using namespace plugin;
|
||||
|
||||
enum Renderer
|
||||
{
|
||||
Render_DirectX9,
|
||||
Render_DirectX10,
|
||||
Render_DirectX11,
|
||||
Render_DirectX12,
|
||||
Render_OpenGL,
|
||||
Render_Unknown,
|
||||
Render_Vulkan,
|
||||
};
|
||||
|
||||
struct Globals
|
||||
{
|
||||
static std::string header_id;
|
||||
static int last_key_timer;
|
||||
static ImVec2 menu_size;
|
||||
static std::string menu_title;
|
||||
static ImVec2 font_screen_size;
|
||||
static bool show_menu;
|
||||
static bool init_done;
|
||||
static Renderer renderer;
|
||||
static ID3D11Device* device11;
|
||||
};
|
||||
|
||||
struct TextureStructure
|
||||
{
|
||||
std::string file_name;
|
||||
std::string category_name;
|
||||
PDIRECT3DTEXTURE9 texture9;
|
||||
ID3D11ShaderResourceView* texture11;
|
||||
};
|
||||
|
||||
extern CJson config;
|
||||
extern std::ofstream flog;
|
||||
|
||||
// Random cheats
|
||||
extern std::random_device rd;
|
||||
extern std::mt19937 gen;
|
||||
extern std::uniform_int_distribution<> cheat_id;
|
||||
|
||||
#include "Ui.h"
|
||||
#include "Util.h"
|
||||
|
||||
namespace fs = std::experimental::filesystem;
|
Before Width: | Height: | Size: 9.6 KiB After Width: | Height: | Size: 9.6 KiB |
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 11 KiB |
Before Width: | Height: | Size: 9.5 KiB After Width: | Height: | Size: 9.5 KiB |
Before Width: | Height: | Size: 7.8 KiB After Width: | Height: | Size: 7.8 KiB |
Before Width: | Height: | Size: 9.4 KiB After Width: | Height: | Size: 9.4 KiB |
Before Width: | Height: | Size: 8.4 KiB After Width: | Height: | Size: 8.4 KiB |
Before Width: | Height: | Size: 7.8 KiB After Width: | Height: | Size: 7.8 KiB |
Before Width: | Height: | Size: 8.7 KiB After Width: | Height: | Size: 8.7 KiB |
Before Width: | Height: | Size: 9.4 KiB After Width: | Height: | Size: 9.4 KiB |
Before Width: | Height: | Size: 5.2 KiB After Width: | Height: | Size: 5.2 KiB |
Before Width: | Height: | Size: 5.3 KiB After Width: | Height: | Size: 5.3 KiB |
Before Width: | Height: | Size: 4.8 KiB After Width: | Height: | Size: 4.8 KiB |
Before Width: | Height: | Size: 5.0 KiB After Width: | Height: | Size: 5.0 KiB |
Before Width: | Height: | Size: 4.1 KiB After Width: | Height: | Size: 4.1 KiB |
Before Width: | Height: | Size: 4.4 KiB After Width: | Height: | Size: 4.4 KiB |
Before Width: | Height: | Size: 4.3 KiB After Width: | Height: | Size: 4.3 KiB |
Before Width: | Height: | Size: 4.3 KiB After Width: | Height: | Size: 4.3 KiB |
Before Width: | Height: | Size: 4.3 KiB After Width: | Height: | Size: 4.3 KiB |
Before Width: | Height: | Size: 4.2 KiB After Width: | Height: | Size: 4.2 KiB |
Before Width: | Height: | Size: 4.4 KiB After Width: | Height: | Size: 4.4 KiB |
Before Width: | Height: | Size: 4.2 KiB After Width: | Height: | Size: 4.2 KiB |
Before Width: | Height: | Size: 4.2 KiB After Width: | Height: | Size: 4.2 KiB |
Before Width: | Height: | Size: 4.1 KiB After Width: | Height: | Size: 4.1 KiB |
Before Width: | Height: | Size: 4.2 KiB After Width: | Height: | Size: 4.2 KiB |
Before Width: | Height: | Size: 4.5 KiB After Width: | Height: | Size: 4.5 KiB |
Before Width: | Height: | Size: 4.0 KiB After Width: | Height: | Size: 4.0 KiB |
Before Width: | Height: | Size: 6.1 KiB After Width: | Height: | Size: 6.1 KiB |
Before Width: | Height: | Size: 6.2 KiB After Width: | Height: | Size: 6.2 KiB |
Before Width: | Height: | Size: 5.4 KiB After Width: | Height: | Size: 5.4 KiB |
Before Width: | Height: | Size: 6.1 KiB After Width: | Height: | Size: 6.1 KiB |
Before Width: | Height: | Size: 6.0 KiB After Width: | Height: | Size: 6.0 KiB |
Before Width: | Height: | Size: 6.1 KiB After Width: | Height: | Size: 6.1 KiB |
Before Width: | Height: | Size: 5.4 KiB After Width: | Height: | Size: 5.4 KiB |