diff --git a/.clang-format b/.clang-format deleted file mode 100644 index a882bff..0000000 --- a/.clang-format +++ /dev/null @@ -1,11 +0,0 @@ ---- -# We'll use defaults from the LLVM style, but with 4 columns indentation. -BasedOnStyle: Microsoft -IndentWidth: 4 ---- -Language: Cpp -# Force pointers to the type for C++. -DerivePointerAlignment: false -PointerAlignment: Right -AccessModifierOffset: -4 ---- diff --git a/src/animation.cpp b/src/animation.cpp index 5b82c2a..34ef63f 100644 --- a/src/animation.cpp +++ b/src/animation.cpp @@ -1,211 +1,210 @@ -#include "animation.h" - #include "pch.h" - +#include "animation.h" #ifdef GTASA #include "ui.h" #include "util.h" Animation::Animation() { - Events::processScriptsEvent += [this] { - if (m_Cutscene::m_bRunning) - { - if (Command()) - { - CPlayerPed *pPlayer = FindPlayerPed(); - if (!pPlayer) - { - return; - } + Events::processScriptsEvent += [this] + { + if (m_Cutscene::m_bRunning) + { + if (Command()) + { + CPlayerPed* pPlayer = FindPlayerPed(); + if (!pPlayer) + { + return; + } - pPlayer->m_nAreaCode = m_Cutscene::m_nInterior; - Command(pPlayer->m_nAreaCode); - m_Cutscene::m_nInterior = 0; - TheCamera.Fade(0, 1); - } - } - else - { - if (m_Cutscene::m_SceneName != "" && Command()) - { - Command(); - m_Cutscene::m_bRunning = true; - } - } - }; + pPlayer->m_nAreaCode = m_Cutscene::m_nInterior; + Command(pPlayer->m_nAreaCode); + m_Cutscene::m_nInterior = 0; + TheCamera.Fade(0, 1); + } + } + else + { + if (m_Cutscene::m_SceneName != "" && Command()) + { + Command(); + m_Cutscene::m_bRunning = true; + } + } + }; } -void Animation::PlayCutscene(std::string &rootKey, std::string &cutsceneId, std::string &interior) +void Animation::PlayCutscene(std::string& rootKey, std::string& cutsceneId, std::string& interior) { - if (Util::IsOnCutscene()) - { - SetHelpMessage("Another cutscene is running", false, false, false); - return; - } + if (Util::IsOnCutscene()) + { + SetHelpMessage("Another cutscene is running", false, false, false); + return; + } - CPlayerPed *pPlayer = FindPlayerPed(); - if (!pPlayer) - { - return; - } - - m_Cutscene::m_SceneName = cutsceneId; - Command(cutsceneId.c_str()); - m_Cutscene::m_nInterior = pPlayer->m_nAreaCode; - pPlayer->m_nAreaCode = std::stoi(interior); - Command(pPlayer->m_nAreaCode); + CPlayerPed* pPlayer = FindPlayerPed(); + if (!pPlayer) + { + return; + } + + m_Cutscene::m_SceneName = cutsceneId; + Command(cutsceneId.c_str()); + m_Cutscene::m_nInterior = pPlayer->m_nAreaCode; + pPlayer->m_nAreaCode = std::stoi(interior); + Command(pPlayer->m_nAreaCode); } void Animation::Draw() { - if (ImGui::BeginTabBar("Animation", ImGuiTabBarFlags_NoTooltip + ImGuiTabBarFlags_FittingPolicyScroll)) - { - ImGui::Spacing(); - CPlayerPed *pPlayer = FindPlayerPed(); - int hPlayer = CPools::GetPedRef(pPlayer); + if (ImGui::BeginTabBar("Animation", ImGuiTabBarFlags_NoTooltip + ImGuiTabBarFlags_FittingPolicyScroll)) + { + ImGui::Spacing(); + CPlayerPed* pPlayer = FindPlayerPed(); + int hPlayer = CPools::GetPedRef(pPlayer); - ImGui::Spacing(); + ImGui::Spacing(); - if (ImGui::BeginTabItem("Anims")) - { - ImGui::Spacing(); - if (ImGui::Button("Stop animation", Ui::GetSize())) - { - if (hPlayer) - { - Command(hPlayer); - } - } + if (ImGui::BeginTabItem("Anims")) + { + ImGui::Spacing(); + if (ImGui::Button("Stop animation", Ui::GetSize())) + { + if (hPlayer) + { + Command(hPlayer); + } + } - ImGui::Spacing(); + ImGui::Spacing(); - ImGui::Columns(2, nullptr, false); - ImGui::Checkbox("Loop", &m_Loop); - Ui::ShowTooltip("Keep playing the animation on repeat"); - ImGui::NextColumn(); - ImGui::Checkbox("Secondary", &m_bSecondary); - Ui::ShowTooltip("Player can move while playing the animation"); - ImGui::Columns(1); - ImGui::Spacing(); + ImGui::Columns(2, nullptr, false); + ImGui::Checkbox("Loop", &m_Loop); + Ui::ShowTooltip("Keep playing the animation on repeat"); + ImGui::NextColumn(); + ImGui::Checkbox("Secondary", &m_bSecondary); + Ui::ShowTooltip("Player can move while playing the animation"); + ImGui::Columns(1); + ImGui::Spacing(); - if (ImGui::BeginChild("Anims Child")) - { - ImGui::Spacing(); - Ui::DrawJSON(m_AnimData, PlayAnimation, RemoveAnimation); - ImGui::EndChild(); - } - ImGui::EndTabItem(); - } + if (ImGui::BeginChild("Anims Child")) + { + ImGui::Spacing(); + Ui::DrawJSON(m_AnimData, PlayAnimation, RemoveAnimation); + ImGui::EndChild(); + } + ImGui::EndTabItem(); + } - if (ImGui::BeginTabItem("Misc")) - { - ImGui::Spacing(); - if (Ui::ListBox("Fighting style", m_FightingStyleList, m_nFightingStyle)) - { - Command(hPlayer, m_nFightingStyle + 4, 6); - SetHelpMessage("Fighting anim set", false, false, false); - } - if (Ui::ListBoxStr("Walking style", m_WalkingStyleList, m_nWalkingStyle)) - { - if (m_nWalkingStyle == "default") - { - patch::Set(0x609A4E, 0x4D48689); - patch::Set(0x609A52, 0); - } - else - { - patch::Nop(0x609A4E, 6); - Command(m_nWalkingStyle.c_str()); - Command(); - Command(hPlayer, m_nWalkingStyle.c_str()); - Command(m_nWalkingStyle.c_str()); - } - SetHelpMessage("Walking anim set", false, false, false); - } - ImGui::EndTabItem(); - } + if (ImGui::BeginTabItem("Misc")) + { + ImGui::Spacing(); + if (Ui::ListBox("Fighting style", m_FightingStyleList, m_nFightingStyle)) + { + Command(hPlayer, m_nFightingStyle + 4, 6); + SetHelpMessage("Fighting anim set", false, false, false); + } + if (Ui::ListBoxStr("Walking style", m_WalkingStyleList, m_nWalkingStyle)) + { + if (m_nWalkingStyle == "default") + { + patch::Set(0x609A4E, 0x4D48689); + patch::Set(0x609A52, 0); + } + else + { + patch::Nop(0x609A4E, 6); + Command(m_nWalkingStyle.c_str()); + Command(); + Command(hPlayer, m_nWalkingStyle.c_str()); + Command(m_nWalkingStyle.c_str()); + } + SetHelpMessage("Walking anim set", false, false, false); + } + ImGui::EndTabItem(); + } - if (ImGui::BeginTabItem("Custom")) - { - ImGui::InputTextWithHint("IFP name", "ped", m_nIfpBuffer, INPUT_BUFFER_SIZE); - ImGui::InputTextWithHint("Anim name", "cower", m_nAnimBuffer, INPUT_BUFFER_SIZE); - ImGui::Spacing(); - if (ImGui::Button("Add animation", Ui::GetSize())) - { - m_AnimData.m_pJson->m_Data["Custom"][m_nAnimBuffer] = ("0, " + std::string(m_nIfpBuffer)); - m_AnimData.m_pJson->WriteToDisk(); - } - ImGui::EndTabItem(); - } - if (ImGui::BeginTabItem("Cutscene")) - { - ImGui::Spacing(); - if (ImGui::Button("Stop cutscene", Ui::GetSize())) - { - if (m_Cutscene::m_bRunning) - { - Command(); - m_Cutscene::m_bRunning = false; - m_Cutscene::m_SceneName = ""; - CPlayerPed *player = FindPlayerPed(); - player->m_nAreaCode = m_Cutscene::m_nInterior; - Command(player->m_nAreaCode); - m_Cutscene::m_nInterior = 0; - TheCamera.Fade(0, 1); - } - } - ImGui::Spacing(); + if (ImGui::BeginTabItem("Custom")) + { + ImGui::InputTextWithHint("IFP name", "ped", m_nIfpBuffer, INPUT_BUFFER_SIZE); + ImGui::InputTextWithHint("Anim name", "cower", m_nAnimBuffer, INPUT_BUFFER_SIZE); + ImGui::Spacing(); + if (ImGui::Button("Add animation", Ui::GetSize())) + { + m_AnimData.m_pJson->m_Data["Custom"][m_nAnimBuffer] = ("0, " + std::string(m_nIfpBuffer)); + m_AnimData.m_pJson->WriteToDisk(); + } + ImGui::EndTabItem(); + } + if (ImGui::BeginTabItem("Cutscene")) + { + ImGui::Spacing(); + if (ImGui::Button("Stop cutscene", Ui::GetSize())) + { + if (m_Cutscene::m_bRunning) + { + Command(); + m_Cutscene::m_bRunning = false; + m_Cutscene::m_SceneName = ""; + CPlayerPed* player = FindPlayerPed(); + player->m_nAreaCode = m_Cutscene::m_nInterior; + Command(player->m_nAreaCode); + m_Cutscene::m_nInterior = 0; + TheCamera.Fade(0, 1); + } + } + ImGui::Spacing(); - if (ImGui::BeginChild("Cutscene Child")) - { - ImGui::Spacing(); - Ui::DrawJSON(m_Cutscene::m_Data, PlayCutscene, nullptr); - ImGui::EndChild(); - } - ImGui::EndTabItem(); - } - ImGui::EndTabBar(); - } + if (ImGui::BeginChild("Cutscene Child")) + { + ImGui::Spacing(); + Ui::DrawJSON(m_Cutscene::m_Data, PlayCutscene, nullptr); + ImGui::EndChild(); + } + ImGui::EndTabItem(); + } + ImGui::EndTabBar(); + } } -void Animation::PlayAnimation(std::string &ifp, std::string &anim, std::string &ifpRepeat) +void Animation::PlayAnimation(std::string& ifp, std::string& anim, std::string& ifpRepeat) { - int hplayer = CPools::GetPedRef(FindPlayerPed()); + int hplayer = CPools::GetPedRef(FindPlayerPed()); - if (ifp != "PED") - { - Command(ifp.c_str()); - Command(); - } + if (ifp != "PED") + { + Command(ifp.c_str()); + Command(); + } - Command(hplayer); - if (m_bSecondary) - { - Command(hplayer, anim.c_str(), ifp.c_str(), 4.0, m_Loop, 0, 0, 0, -1); - } - else - { - Command(hplayer, anim.c_str(), ifp.c_str(), 4.0, m_Loop, 0, 0, 0, -1); - } + Command(hplayer); + if (m_bSecondary) + { + Command(hplayer, anim.c_str(), ifp.c_str(), 4.0, m_Loop, 0, 0, 0, -1); + } + else + { + Command(hplayer, anim.c_str(), ifp.c_str(), 4.0, m_Loop, 0, 0, 0, -1); + } - if (ifp != "PED") - { - Command(ifp.c_str()); - } + if (ifp != "PED") + { + Command(ifp.c_str()); + } } -void Animation::RemoveAnimation(std::string &ifp, std::string &anim, std::string &ifpRepeat) +void Animation::RemoveAnimation(std::string& ifp, std::string& anim, std::string& ifpRepeat) { - if (ifp == "Custom") - { - m_AnimData.m_pJson->m_Data["Custom"].erase(anim); - m_AnimData.m_pJson->WriteToDisk(); - SetHelpMessage("Animation removed", false, false, false); - } - else - { - SetHelpMessage("You can only remove custom anims", false, false, false); - } + if (ifp == "Custom") + { + m_AnimData.m_pJson->m_Data["Custom"].erase(anim); + m_AnimData.m_pJson->WriteToDisk(); + SetHelpMessage("Animation removed", false, false, false); + } + else + { + SetHelpMessage("You can only remove custom anims", false, false, false); + } } #endif \ No newline at end of file diff --git a/src/animation.h b/src/animation.h index 16380b4..77f40e1 100644 --- a/src/animation.h +++ b/src/animation.h @@ -5,44 +5,45 @@ class Animation { private: - // Animation player - static inline ResourceStore m_AnimData{"animation", eResourceType::TYPE_TEXT}; - static inline char m_nAnimBuffer[INPUT_BUFFER_SIZE]; - static inline char m_nIfpBuffer[INPUT_BUFFER_SIZE]; - static inline bool m_Loop; // loop animation - static inline bool m_bSecondary; // play animation as secondary - // Cutscene player - struct m_Cutscene - { - static inline ResourceStore m_Data{"cutscene", eResourceType::TYPE_TEXT}; - static inline std::string m_SceneName; - static inline int m_nInterior; // player interior backup - static inline bool m_bRunning; - }; + // Animation player + static inline ResourceStore m_AnimData{ "animation", eResourceType::TYPE_TEXT }; + static inline char m_nAnimBuffer[INPUT_BUFFER_SIZE]; + static inline char m_nIfpBuffer[INPUT_BUFFER_SIZE]; + static inline bool m_Loop; // loop animation + static inline bool m_bSecondary; // play animation as secondary - static inline int m_nFightingStyle; - static inline std::string m_nWalkingStyle = "default"; - static inline std::vector m_FightingStyleList = {"Default", "Boxing", "Kung fu", "Kick Boxing", - "Punch Kick"}; - static inline std::vector m_WalkingStyleList = { - "default", "man", "shuffle", "oldman", "gang1", "gang2", "oldfatman", "fatman", - "jogger", "drunkman", "blindman", "swat", "woman", "shopping", "busywoman", "sexywoman", - "pro", "oldwoman", "fatwoman", "jogwoman", "oldfatwoman", "skate"}; + // Cutscene player + struct m_Cutscene + { + static inline ResourceStore m_Data{ "cutscene", eResourceType::TYPE_TEXT }; + static inline std::string m_SceneName; + static inline int m_nInterior; // player interior backup + static inline bool m_bRunning; + }; + + static inline int m_nFightingStyle; + static inline std::string m_nWalkingStyle = "default"; + static inline std::vector m_FightingStyleList = + { "Default", "Boxing", "Kung fu", "Kick Boxing", "Punch Kick" }; + static inline std::vector m_WalkingStyleList = + { + "default", "man", "shuffle", "oldman", "gang1", "gang2", "oldfatman", + "fatman", "jogger", "drunkman", "blindman", "swat", "woman", "shopping", "busywoman", + "sexywoman", "pro", "oldwoman", "fatwoman", "jogwoman", "oldfatwoman", "skate" + }; protected: - Animation(); + Animation(); public: - static void Draw(); - static void PlayAnimation(std::string &rootKey, std::string &anim, std::string &ifp); - static void PlayCutscene(std::string &rootKey, std::string &cutsceneId, std::string &interior); - static void RemoveAnimation(std::string &rootKey, std::string &anim, std::string &ifp); + static void Draw(); + static void PlayAnimation(std::string& rootKey, std::string& anim, std::string& ifp); + static void PlayCutscene(std::string& rootKey, std::string& cutsceneId, std::string& interior); + static void RemoveAnimation(std::string& rootKey, std::string& anim, std::string& ifp); }; #else // Dummy Class for VC & III -class Animation -{ -}; +class Animation{}; #endif \ No newline at end of file diff --git a/src/cheatmenu.cpp b/src/cheatmenu.cpp index c76e793..8a834e2 100644 --- a/src/cheatmenu.cpp +++ b/src/cheatmenu.cpp @@ -1,184 +1,183 @@ +#include "pch.h" #include "cheatMenu.h" #include "menuinfo.h" -#include "pch.h" #include "ui.h" #include "updater.h" void CheatMenu::DrawWindow() { - ImGuiIO &io = ImGui::GetIO(); - static bool bRunning = true; + ImGuiIO& io = ImGui::GetIO(); + static bool bRunning = true; - if (BY_GAME(FrontEndMenuManager.m_bMenuActive, FrontendMenuManager.m_bMenuVisible, - FrontEndMenuManager.m_bMenuActive)) - { - if (bRunning) - { - gConfig.WriteToDisk(); - bRunning = false; - m_bShowMouse = false; - } - } - else - { - bRunning = true; - if (m_bShowMenu || BY_GAME(m_Commands::m_bShowMenu, true, true)) - { - if (m_bShowMenu) - { - static ImVec2 fScreenSize = ImVec2(-1, -1); - ImVec2 size(screen::GetScreenWidth(), screen::GetScreenHeight()); + if (BY_GAME(FrontEndMenuManager.m_bMenuActive, FrontendMenuManager.m_bMenuVisible, FrontEndMenuManager.m_bMenuActive)) + { + if (bRunning) + { + gConfig.WriteToDisk(); + bRunning = false; + m_bShowMouse = false; + } + } + else + { + bRunning = true; + if (m_bShowMenu || BY_GAME(m_Commands::m_bShowMenu, true, true)) + { + if (m_bShowMenu) + { + static ImVec2 fScreenSize = ImVec2(-1, -1); + ImVec2 size(screen::GetScreenWidth(), screen::GetScreenHeight()); + + if (fScreenSize.x != -1 && fScreenSize.y != -1) + { + m_fMenuSize.x += (size.x - fScreenSize.x) / 4.0f; + m_fMenuSize.y += (size.y - fScreenSize.y) / 1.2f; + } + ImGui::SetNextWindowSize(m_fMenuSize); - if (fScreenSize.x != -1 && fScreenSize.y != -1) - { - m_fMenuSize.x += (size.x - fScreenSize.x) / 4.0f; - m_fMenuSize.y += (size.y - fScreenSize.y) / 1.2f; - } - ImGui::SetNextWindowSize(m_fMenuSize); + if (ImGui::Begin(MENU_TITLE, &m_bShowMenu, ImGuiWindowFlags_NoCollapse)) + { + ImGui::PushStyleVar(ImGuiStyleVar_WindowMinSize, ImVec2(250, 350)); + ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, + ImVec2(ImGui::GetWindowWidth() / 85, ImGui::GetWindowHeight() / 200)); - if (ImGui::Begin(MENU_TITLE, &m_bShowMenu, ImGuiWindowFlags_NoCollapse)) - { - ImGui::PushStyleVar(ImGuiStyleVar_WindowMinSize, ImVec2(250, 350)); - ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, - ImVec2(ImGui::GetWindowWidth() / 85, ImGui::GetWindowHeight() / 200)); + if (Updater::m_State == UPDATER_UPDATE_FOUND) + Updater::ShowUpdateScreen(); + else + Ui::DrawHeaders(header); - if (Updater::m_State == UPDATER_UPDATE_FOUND) - Updater::ShowUpdateScreen(); - else - Ui::DrawHeaders(header); + m_fMenuSize = ImGui::GetWindowSize(); + gConfig.SetValue("window.sizeX", m_fMenuSize.x); + gConfig.SetValue("window.sizeY", m_fMenuSize.y); - m_fMenuSize = ImGui::GetWindowSize(); - gConfig.SetValue("window.sizeX", m_fMenuSize.x); - gConfig.SetValue("window.sizeY", m_fMenuSize.y); - - ImGui::PopStyleVar(2); - ImGui::End(); - } - } + ImGui::PopStyleVar(2); + ImGui::End(); + } + } #ifdef GTASA - else - { - DrawShortcutsWindow(); - } + else + { + DrawShortcutsWindow(); + } #endif - } - } - DrawOverlay(); + } + } + DrawOverlay(); } CheatMenu::CheatMenu() { - ApplyStyle(); - windowCallback = std::bind(&DrawWindow); + ApplyStyle(); + windowCallback = std::bind(&DrawWindow); - // Load menu settings - Ui::m_HeaderId = gConfig.GetValue("window.id", std::string("")); - m_fMenuSize.x = gConfig.GetValue("window.sizeX", screen::GetScreenWidth() / 4.0f); - m_fMenuSize.y = gConfig.GetValue("window.sizeY", screen::GetScreenHeight() / 1.2f); - srand(CTimer::m_snTimeInMilliseconds); + // Load menu settings + Ui::m_HeaderId = gConfig.GetValue("window.id", std::string("")); + m_fMenuSize.x = gConfig.GetValue("window.sizeX", screen::GetScreenWidth() / 4.0f); + m_fMenuSize.y = gConfig.GetValue("window.sizeY", screen::GetScreenHeight() / 1.2f); + srand(CTimer::m_snTimeInMilliseconds); - Events::processScriptsEvent += []() { - if (!BY_GAME(FrontEndMenuManager.m_bMenuActive, FrontendMenuManager.m_bMenuVisible, - FrontEndMenuManager.m_bMenuActive)) - { - if (menuOpen.Pressed()) - { - m_bShowMenu = !m_bShowMenu; - } + Events::processScriptsEvent += []() + { + if (!BY_GAME(FrontEndMenuManager.m_bMenuActive, FrontendMenuManager.m_bMenuVisible, FrontEndMenuManager.m_bMenuActive)) + { + if (menuOpen.Pressed()) + { + m_bShowMenu = !m_bShowMenu; + } - if (commandWindow.Pressed()) - { - if (m_Commands::m_bShowMenu) - { - ProcessCommands(); - strcpy(m_Commands::m_nInputBuffer, ""); - } - m_Commands::m_bShowMenu = !m_Commands::m_bShowMenu; - } + if (commandWindow.Pressed()) + { + if (m_Commands::m_bShowMenu) + { + ProcessCommands(); + strcpy(m_Commands::m_nInputBuffer, ""); + } + m_Commands::m_bShowMenu = !m_Commands::m_bShowMenu; + } - if (m_bShowMouse != m_bShowMenu) - { - if (m_bShowMouse) // Only write when the menu closes - { - gConfig.WriteToDisk(); - } + if (m_bShowMouse != m_bShowMenu) + { + if (m_bShowMouse) // Only write when the menu closes + { + gConfig.WriteToDisk(); + } - m_bShowMouse = m_bShowMenu; - } - } - }; + m_bShowMouse = m_bShowMenu; + } + } + }; } void CheatMenu::ApplyStyle() { - ImGuiStyle *style = &ImGui::GetStyle(); - ImVec4 *colors = style->Colors; + ImGuiStyle* style = &ImGui::GetStyle(); + ImVec4* colors = style->Colors; - style->WindowRounding = 1; - style->ScrollbarRounding = 1; - style->GrabRounding = 1; - style->WindowRounding = 1; - style->ChildRounding = 1; - style->ScrollbarRounding = 1; - style->GrabRounding = 1; - style->FrameRounding = 0; - style->TabRounding = 1.0; - style->AntiAliasedLines = true; - style->AntiAliasedFill = true; - style->Alpha = 1; + style->WindowRounding = 1; + style->ScrollbarRounding = 1; + style->GrabRounding = 1; + style->WindowRounding = 1; + style->ChildRounding = 1; + style->ScrollbarRounding = 1; + style->GrabRounding = 1; + style->FrameRounding = 0; + style->TabRounding = 1.0; + style->AntiAliasedLines = true; + style->AntiAliasedFill = true; + style->Alpha = 1; - style->FrameBorderSize = 0; - style->ChildBorderSize = 0; - style->TabBorderSize = 0; - style->WindowBorderSize = 0; - style->PopupBorderSize = 0; + 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.0f); - 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); + 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.0f); + 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); } diff --git a/src/cheatmenu.h b/src/cheatmenu.h index 94e0f60..97cf15d 100644 --- a/src/cheatmenu.h +++ b/src/cheatmenu.h @@ -9,9 +9,6 @@ */ #pragma once -#ifndef GTA3 -#include "visual.h" -#endif #include "animation.h" #include "game.h" #include "hook.h" @@ -20,24 +17,15 @@ #include "player.h" #include "teleport.h" #include "vehicle.h" +#include "visual.h" #include "weapon.h" -#ifndef GTA3 class CheatMenu : Hook, Animation, Game, Menu, Ped, Player, Teleport, Vehicle, Visual, Weapon -#else -class CheatMenu : Hook, Animation, Game, Menu, Ped, Player, Teleport, Vehicle, Weapon -#endif { private: static inline bool m_bShowMenu = false; static inline ImVec2 m_fMenuSize = ImVec2(screen::GetScreenWidth() / 4, screen::GetScreenHeight() / 1.2); -#ifdef GTA3 - static inline CallbackTable header{ - {"Teleport", &Teleport::Draw}, {"Player", &Player::Draw}, {"Ped", &Ped::Draw}, {"Dummy", nullptr}, - {"Vehicle", &Vehicle::Draw}, {"Weapon", &Weapon::Draw}, {"Game", &Game::Draw}, {"Menu", &Menu::Draw}, - }; -#else static inline CallbackTable header{ {"Teleport", &Teleport::Draw}, {"Player", &Player::Draw}, {"Ped", &Ped::Draw}, #ifdef GTASA @@ -46,8 +34,8 @@ private: {"Dummy", nullptr}, #endif {"Vehicle", &Vehicle::Draw}, {"Weapon", &Weapon::Draw}, {"Game", &Game::Draw}, - {"Visual", &Visual::Draw}, {"Menu", &Menu::Draw}}; -#endif + {"Visual", &Visual::Draw}, {"Menu", &Menu::Draw} + }; static void ApplyStyle(); static void DrawWindow(); diff --git a/src/dllmain.cpp b/src/dllmain.cpp index b4a8b47..d3f25af 100644 --- a/src/dllmain.cpp +++ b/src/dllmain.cpp @@ -1,100 +1,101 @@ -#include "cheatmenu.h" -#include "hook.h" -#include "menuinfo.h" #include "pch.h" +#include "hook.h" +#include "cheatmenu.h" #include "updater.h" +#include "menuinfo.h" -void MenuThread(void *param) +void MenuThread(void* param) { - /* - Had to put this in place since some people put the folder in root - directory and the asi in modloader. Why?? + /* + Had to put this in place since some people put the folder in root + directory and the asi in modloader. Why?? - TODO: Unlikely they'd even read the log so have to do something else - */ - if (!std::filesystem::is_directory(PLUGIN_PATH((char *)"CheatMenu"))) - { - gLog << "CheatMenu folder not found. You need to put both \"CheatMenu.asi\" & \"CheatMenu\" folder in the same " - "directory" - << std::endl; - return; - } + TODO: Unlikely they'd even read the log so have to do something else + */ + if (!std::filesystem::is_directory(PLUGIN_PATH((char*)"CheatMenu"))) + { + gLog << "CheatMenu folder not found. You need to put both \"CheatMenu.asi\" & \"CheatMenu\" folder in the same directory" << std::endl; + return; + } #ifdef GTASA - Hook::ApplyMouseFix(); + Hook::ApplyMouseFix(); #endif - static bool bGameInit = false; + static bool bGameInit = false; - // Wait till game init - Events::initRwEvent += [] { bGameInit = true; }; + // Wait till game init + Events::initRwEvent += [] + { + bGameInit = true; + }; - while (!bGameInit) - { - Sleep(1000); - } + while (!bGameInit) + { + Sleep(1000); + } #ifdef GTASA /* TODO: Find a better way Since you could still name it something else */ - if (GetModuleHandle("SAMP.dll") || GetModuleHandle("SAMP.asi")) - { - MessageBox(RsGlobal.ps->window, "SAMP detected. Exiting CheatMenu.", "CheatMenu", MB_ICONERROR); - return; - } - CFastman92limitAdjuster::Init(); + if (GetModuleHandle("SAMP.dll") || GetModuleHandle("SAMP.asi")) + { + MessageBox(RsGlobal.ps->window, "SAMP detected. Exiting CheatMenu.", "CheatMenu", MB_ICONERROR); + return; + } + CFastman92limitAdjuster::Init(); #endif - gLog << "Starting...\nVersion: " MENU_TITLE "\nAuthor: Grinch_\nDiscord: " DISCORD_INVITE - "\nMore Info: " GITHUB_LINK "\n" - << std::endl; - CheatMenu menu; + gLog << "Starting...\nVersion: " MENU_TITLE "\nAuthor: Grinch_\nDiscord: " DISCORD_INVITE "\nMore Info: " + GITHUB_LINK "\n" << std::endl; + CheatMenu menu; - // Checking for updates once a day - time_t now = time(0); - struct tm tstruct = *localtime(&now); - int lastCheckDate = gConfig.GetValue("config.last_update_checked", 0); - if (lastCheckDate != tstruct.tm_mday) - { - Updater::CheckForUpdate(); - gConfig.SetValue("config.last_update_checked", tstruct.tm_mday); - } + // Checking for updates once a day + time_t now = time(0); + struct tm tstruct = *localtime(&now); + int lastCheckDate = gConfig.GetValue("config.last_update_checked", 0); - while (true) - { - Sleep(5000); + if (lastCheckDate != tstruct.tm_mday) + { + Updater::CheckForUpdate(); + gConfig.SetValue("config.last_update_checked", tstruct.tm_mday); + } - if (Updater::m_State == UPDATER_CHECKING) - { - Updater::CheckForUpdate(); - } - } + while (true) + { + Sleep(5000); + + if (Updater::m_State == UPDATER_CHECKING) + { + Updater::CheckForUpdate(); + } + } } BOOL WINAPI DllMain(HINSTANCE hDllHandle, DWORD nReason, LPVOID Reserved) { - if (nReason == DLL_PROCESS_ATTACH) - { - uint gameVersion = GetGameVersion(); - - if (gameVersion == BY_GAME(GAME_10US_HOODLUM, GAME_10EN, GAME_10EN)) - { - CreateThread(nullptr, NULL, (LPTHREAD_START_ROUTINE)&MenuThread, nullptr, NULL, nullptr); - } - else - { + if (nReason == DLL_PROCESS_ATTACH) + { + uint gameVersion = GetGameVersion(); + + if (gameVersion == BY_GAME(GAME_10US_HOODLUM, GAME_10EN, GAME_10EN)) + { + CreateThread(nullptr, NULL, (LPTHREAD_START_ROUTINE)&MenuThread, nullptr, NULL, nullptr); + } + else + { #ifdef GTASA - MessageBox(HWND_DESKTOP, "Unknown game version. GTA SA v1.0 US is required.", "CheatMenu", MB_ICONERROR); + MessageBox(HWND_DESKTOP, "Unknown game version. GTA SA v1.0 US is required.", "CheatMenu", MB_ICONERROR); #elif GTAVC - MessageBox(HWND_DESKTOP, "Unknown game version. GTA VC v1.0 EN is required.", "CheatMenu", MB_ICONERROR); + MessageBox(HWND_DESKTOP, "Unknown game version. GTA VC v1.0 EN is required.", "CheatMenu", MB_ICONERROR); #else // GTA3 - MessageBox(HWND_DESKTOP, "Unknown game version. GTA III v1.0 EN is required.", "CheatMenu", MB_ICONERROR); + MessageBox(HWND_DESKTOP, "Unknown game version. GTA III v1.0 EN is required.", "CheatMenu", MB_ICONERROR); #endif - } - } + } + } - return TRUE; + return TRUE; } \ No newline at end of file diff --git a/src/filehandler.cpp b/src/filehandler.cpp index 5b576cf..4380f72 100644 --- a/src/filehandler.cpp +++ b/src/filehandler.cpp @@ -1,191 +1,192 @@ -#include "filehandler.h" #include "pch.h" +#include "filehandler.h" #include "visual.h" // TODO: Clean up this mess, use structures instead? -void FileHandler::GenerateHandlingFile(int pHandling, std::map &storeMap) +void FileHandler::GenerateHandlingFile(int pHandling, std::map& storeMap) { - FILE *fp = fopen("handling.txt", "w"); + FILE* fp = fopen("handling.txt", "w"); - std::string handlingId = storeMap[FindPlayerPed()->m_pVehicle->m_nModelIndex]; - float fMass = patch::Get(pHandling + 0x4); - float fTurnMass = patch::Get(pHandling + 0xC); - float fDragMult = patch::Get(pHandling + 0x10); - float CentreOfMassX = patch::Get(pHandling + 0x14); - float CentreOfMassY = patch::Get(pHandling + 0x18); - float CentreOfMassZ = patch::Get(pHandling + 0x1C); - int nPercentSubmerged = patch::Get(pHandling + 0x20); - float fTractionMultiplier = patch::Get(pHandling + 0x28); - float fTractionLoss = patch::Get(pHandling + 0xA4); - float TractionBias = patch::Get(pHandling + 0xA8); - float fEngineAcceleration = patch::Get(pHandling + 0x7C) * 12500; - float fEngineInertia = patch::Get(pHandling + 0x80); - int nDriveType = patch::Get(pHandling + 0x74); - int nEngineType = patch::Get(pHandling + 0x75); - float BrakeDeceleration = patch::Get(pHandling + 0x94) * 2500; - float BrakeBias = patch::Get(pHandling + 0x98); - int ABS = patch::Get(pHandling + 0x9C); - float SteeringLock = patch::Get(pHandling + 0xA0); - float SuspensionForceLevel = patch::Get(pHandling + 0xAC); - float SuspensionDampingLevel = patch::Get(pHandling + 0xB0); - float SuspensionHighSpdComDamp = patch::Get(pHandling + 0xB4); - float Suspension_upper_limit = patch::Get(pHandling + 0xB8); - float Suspension_lower_limit = patch::Get(pHandling + 0xBC); - float Suspension_bias = patch::Get(pHandling + 0xC0); - float Suspension_anti_dive_multiplier = patch::Get(pHandling + 0xC4); - float fCollisionDamageMultiplier = patch::Get(pHandling + 0xC8) * 0.338; - int nMonetaryValue = patch::Get(pHandling + 0xD8); - int MaxVelocity = patch::Get(pHandling + 0x84); - MaxVelocity = MaxVelocity * 206 + (MaxVelocity - 0.918668) * 1501; - int modelFlags = patch::Get(pHandling + 0xCC); - int handlingFlags = patch::Get(pHandling + 0xD0); - int front_lights = patch::Get(pHandling + 0xDC); - int rear_lights = patch::Get(pHandling + 0xDD); - int vehicle_anim_group = patch::Get(pHandling + 0xDE); - int nNumberOfGears = patch::Get(pHandling + 0x76); - float fSeatOffsetDistance = patch::Get(pHandling + 0xD4); + std::string handlingId = storeMap[FindPlayerPed()->m_pVehicle->m_nModelIndex]; + float fMass = patch::Get(pHandling + 0x4); + float fTurnMass = patch::Get(pHandling + 0xC); + float fDragMult = patch::Get(pHandling + 0x10); + float CentreOfMassX = patch::Get(pHandling + 0x14); + float CentreOfMassY = patch::Get(pHandling + 0x18); + float CentreOfMassZ = patch::Get(pHandling + 0x1C); + int nPercentSubmerged = patch::Get(pHandling + 0x20); + float fTractionMultiplier = patch::Get(pHandling + 0x28); + float fTractionLoss = patch::Get(pHandling + 0xA4); + float TractionBias = patch::Get(pHandling + 0xA8); + float fEngineAcceleration = patch::Get(pHandling + 0x7C) * 12500; + float fEngineInertia = patch::Get(pHandling + 0x80); + int nDriveType = patch::Get(pHandling + 0x74); + int nEngineType = patch::Get(pHandling + 0x75); + float BrakeDeceleration = patch::Get(pHandling + 0x94) * 2500; + float BrakeBias = patch::Get(pHandling + 0x98); + int ABS = patch::Get(pHandling + 0x9C); + float SteeringLock = patch::Get(pHandling + 0xA0); + float SuspensionForceLevel = patch::Get(pHandling + 0xAC); + float SuspensionDampingLevel = patch::Get(pHandling + 0xB0); + float SuspensionHighSpdComDamp = patch::Get(pHandling + 0xB4); + float Suspension_upper_limit = patch::Get(pHandling + 0xB8); + float Suspension_lower_limit = patch::Get(pHandling + 0xBC); + float Suspension_bias = patch::Get(pHandling + 0xC0); + float Suspension_anti_dive_multiplier = patch::Get(pHandling + 0xC4); + float fCollisionDamageMultiplier = patch::Get(pHandling + 0xC8) * 0.338; + int nMonetaryValue = patch::Get(pHandling + 0xD8); + int MaxVelocity = patch::Get(pHandling + 0x84); + MaxVelocity = MaxVelocity * 206 + (MaxVelocity - 0.918668) * 1501; + int modelFlags = patch::Get(pHandling + 0xCC); + int handlingFlags = patch::Get(pHandling + 0xD0); + int front_lights = patch::Get(pHandling + 0xDC); + int rear_lights = patch::Get(pHandling + 0xDD); + int vehicle_anim_group = patch::Get(pHandling + 0xDE); + int nNumberOfGears = patch::Get(pHandling + 0x76); + float fSeatOffsetDistance = patch::Get(pHandling + 0xD4); - // TODO: make this more readable - fprintf(fp, - "\n%s\t%.5g\t%.5g\t%.5g\t%.5g\t%.5g\t%.5g\t%d\t%.5g\t%.5g\t%.5g\t%d\t%d\t%.5g\t%.5g\t%c\t%c\t%.5g\t%.5g\t%" - "d\t%.5g\t%.5g\t%.5g\t%.5g\t%.5g\t%.5g\t%.5g\t%.5g\t%.5g\t%.5g\t%d\t%d\t%d\t%d\t%d\t%d", - handlingId.c_str(), fMass, fTurnMass, fDragMult, CentreOfMassX, CentreOfMassY, CentreOfMassZ, - nPercentSubmerged, fTractionMultiplier, fTractionLoss, TractionBias, nNumberOfGears, MaxVelocity, - fEngineAcceleration, fEngineInertia, nDriveType, nEngineType, BrakeDeceleration, BrakeBias, ABS, - SteeringLock, SuspensionForceLevel, SuspensionDampingLevel, SuspensionHighSpdComDamp, - Suspension_upper_limit, Suspension_lower_limit, Suspension_bias, Suspension_anti_dive_multiplier, - fSeatOffsetDistance, fCollisionDamageMultiplier, nMonetaryValue, modelFlags, handlingFlags, front_lights, - rear_lights, vehicle_anim_group); + // TODO: make this more readable + fprintf( + fp, + "\n%s\t%.5g\t%.5g\t%.5g\t%.5g\t%.5g\t%.5g\t%d\t%.5g\t%.5g\t%.5g\t%d\t%d\t%.5g\t%.5g\t%c\t%c\t%.5g\t%.5g\t%d\t%.5g\t%.5g\t%.5g\t%.5g\t%.5g\t%.5g\t%.5g\t%.5g\t%.5g\t%.5g\t%d\t%d\t%d\t%d\t%d\t%d", + handlingId.c_str(), fMass, fTurnMass, fDragMult, CentreOfMassX, CentreOfMassY, CentreOfMassZ, nPercentSubmerged, + fTractionMultiplier, fTractionLoss, TractionBias, nNumberOfGears, + MaxVelocity, fEngineAcceleration, fEngineInertia, nDriveType, nEngineType, BrakeDeceleration, BrakeBias, ABS, + SteeringLock, SuspensionForceLevel, SuspensionDampingLevel, + SuspensionHighSpdComDamp, Suspension_upper_limit, Suspension_lower_limit, Suspension_bias, + Suspension_anti_dive_multiplier, fSeatOffsetDistance, + fCollisionDamageMultiplier, nMonetaryValue, modelFlags, handlingFlags, front_lights, rear_lights, + vehicle_anim_group); - fclose(fp); + fclose(fp); } -void FileHandler::FetchColorData(std::vector> &storeVec) +void FileHandler::FetchColorData(std::vector>& storeVec) { - std::string m_FilePath = GAME_PATH((char *)"/data/carcols.dat"); + std::string m_FilePath = GAME_PATH((char*)"/data/carcols.dat"); - if (std::filesystem::exists(m_FilePath)) - { - std::ifstream file(m_FilePath); - std::string line; - bool bIsCar = false; - bool bIsCol = false; - int nLineCount = 0; + if (std::filesystem::exists(m_FilePath)) + { + std::ifstream file(m_FilePath); + std::string line; + bool bIsCar = false; + bool bIsCol = false; + int nLineCount = 0; - while (getline(file, line)) - { + while (getline(file, line)) + { // skip commented & emety lines - if (line[0] == '#' || line == "") + if (line[0] == '#' || line == "") { continue; } // section blocks - if (line[0] == 'c' && line[1] == 'a' && line[2] == 'r') - { - bIsCar = true; - continue; - } + if (line[0] == 'c' && line[1] == 'a' && line[2] == 'r') + { + bIsCar = true; + continue; + } - if (line[0] == 'c' && line[1] == 'o' && line[2] == 'l') - { - bIsCol = true; - continue; - } + if (line[0] == 'c' && line[1] == 'o' && line[2] == 'l') + { + bIsCol = true; + continue; + } - if (line[0] == 'e' && line[1] == 'n' && line[2] == 'd') - { - bIsCar = false; - bIsCol = false; - continue; - } + if (line[0] == 'e' && line[1] == 'n' && line[2] == 'd') + { + bIsCar = false; + bIsCol = false; + continue; + } - if (bIsCol) - { - try - { - std::string temp; - std::stringstream ss(line); + if (bIsCol) + { + try + { + std::string temp; + std::stringstream ss(line); // fix one instance where . is used instead of , - std::replace(temp.begin(), temp.end(), '.', ','); + std::replace(temp.begin(), temp.end(), '.', ','); // Format: red, green, blue - int r, g, b; - getline(ss, temp, ','); - r = std::stoi(temp); - getline(ss, temp, ','); - g = std::stoi(temp); - getline(ss, temp, ','); - b = std::stoi(temp); + int r,g,b; + getline(ss, temp, ','); + r = std::stoi(temp); + getline(ss, temp, ','); + g = std::stoi(temp); + getline(ss, temp, ','); + b = std::stoi(temp); - storeVec.push_back({r / 255.0f, g / 255.0f, b / 255.0f}); - ++nLineCount; - } - catch (...) - { - gLog << "Error parsing carcols.dat, " << line << std::endl; - } - } - } + storeVec.push_back({r / 255.0f, g / 255.0f, b / 255.0f}); + ++nLineCount; + } + catch (...) + { + gLog << "Error parsing carcols.dat, " << line << std::endl; + } + } + } - file.close(); - } - else - { - gLog << "Carcols.dat not found"; - } + file.close(); + } + else + { + gLog << "Carcols.dat not found"; + } } -void FileHandler::FetchHandlingID(std::map &storeMap) +void FileHandler::FetchHandlingID(std::map& storeMap) { - std::string m_FilePath = GAME_PATH((char *)"/data/vehicles.ide"); + std::string m_FilePath = GAME_PATH((char*)"/data/vehicles.ide"); - if (std::filesystem::exists(m_FilePath)) - { - std::ifstream file(m_FilePath); - std::string line; + if (std::filesystem::exists(m_FilePath)) + { + std::ifstream file(m_FilePath); + std::string line; - while (getline(file, line)) - { + while (getline(file, line)) + { /* Format: model, modelname, txdname, type, handlingId, ... Skip if first thing isn't model id */ - if (line[0] <= '0' || line[0] >= '9') - { - continue; - } + if (line[0] <= '0' || line[0] >= '9') + { + continue; + } // running inside try block to handle user errors, mostly commas - try - { - std::string temp; - std::stringstream ss(line); + try + { + std::string temp; + std::stringstream ss(line); - // get model - getline(ss, temp, ','); - int model = std::stoi(temp); + // get model + getline(ss, temp, ','); + int model = std::stoi(temp); - // get modelname, txd, type, handlingId - getline(ss, temp, ','); - getline(ss, temp, ','); - getline(ss, temp, ','); - getline(ss, temp, ','); + // get modelname, txd, type, handlingId + getline(ss, temp, ','); + getline(ss, temp, ','); + getline(ss, temp, ','); + getline(ss, temp, ','); - temp.erase(std::remove_if(temp.begin(), temp.end(), ::isspace), temp.end()); + temp.erase(std::remove_if(temp.begin(), temp.end(), ::isspace), temp.end()); - storeMap[model] = temp; - } - catch (...) - { - gLog << "Error parsing vehicles.ide, " << line << std::endl; - } - } + storeMap[model] = temp; + } + catch (...) + { + gLog << "Error parsing vehicles.ide, " << line << std::endl; + } + } - file.close(); - } - else + file.close(); + } + else { gLog << "Vehicle.ide not found"; } diff --git a/src/filehandler.h b/src/filehandler.h index 499dc53..55bed4b 100644 --- a/src/filehandler.h +++ b/src/filehandler.h @@ -1,23 +1,24 @@ #pragma once #include -#include #include +#include class FileHandler { public: FileHandler() = delete; - FileHandler(FileHandler &) = delete; + FileHandler(FileHandler&) = delete; /* Parses data/carcols.dat file and stores color data TODO: Implement something that also parses modloader data */ - static void FetchColorData(std::vector> &storeVec); + static void FetchColorData(std::vector>& storeVec); /* Parses data/vehicles.ide file and stores handingId in a map TODO: Implement something that also parses modloader data */ - static void FetchHandlingID(std::map &storeMap); - static void GenerateHandlingFile(int pHandling, std::map &storeMap); + static void FetchHandlingID(std::map& storeMap); + static void GenerateHandlingFile(int pHandling, std::map& storeMap); }; + diff --git a/src/game.cpp b/src/game.cpp index fc0ca34..049da05 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -1,9 +1,8 @@ -#include "game.h" -#include "menu.h" #include "pch.h" +#include "menu.h" +#include "game.h" #include "ui.h" #include "util.h" - #ifdef GTASA #include #include @@ -15,757 +14,770 @@ static bool bSaveGameFlag = false; // Thanks to aap void Game::RealTimeClock() { - time_t tmp = time(nullptr); - struct tm *now = localtime(&tmp); + time_t tmp = time(nullptr); + struct tm* now = localtime(&tmp); #ifdef GTASA - static int lastday; - if (now->tm_yday != lastday) - { - CStats::SetStatValue(0x86, CStats::GetStatValue(0x86) + 1.0f); - } + static int lastday; + if (now->tm_yday != lastday) + { + CStats::SetStatValue(0x86, CStats::GetStatValue(0x86) + 1.0f); + } - lastday = now->tm_yday; - CClock::ms_nGameClockMonth = now->tm_mon + 1; - CClock::ms_nGameClockDays = now->tm_mday; - CClock::CurrentDay = now->tm_wday + 1; + lastday = now->tm_yday; + CClock::ms_nGameClockMonth = now->tm_mon + 1; + CClock::ms_nGameClockDays = now->tm_mday; + CClock::CurrentDay = now->tm_wday + 1; #endif - CClock::ms_nGameClockHours = now->tm_hour; - CClock::ms_nGameClockMinutes = now->tm_min; - CClock::ms_nGameClockSeconds = now->tm_sec; + CClock::ms_nGameClockHours = now->tm_hour; + CClock::ms_nGameClockMinutes = now->tm_min; + CClock::ms_nGameClockSeconds = now->tm_sec; } Game::Game() { #ifdef GTASA - // Generate enabled cheats vector - for (auto element : m_RandomCheats::m_Json.m_Data.items()) - { - /* - [ - cheat_id = [ cheat_name, state (true/false) ] - ] - */ - m_RandomCheats::m_EnabledCheats[std::stoi(element.key())][0] = element.value().get(); - m_RandomCheats::m_EnabledCheats[std::stoi(element.key())][1] = "true"; - } + // Generate enabled cheats vector + for (auto element : m_RandomCheats::m_Json.m_Data.items()) + { + /* + [ + cheat_id = [ cheat_name, state (true/false) ] + ] + */ + m_RandomCheats::m_EnabledCheats[std::stoi(element.key())][0] = element.value().get(); + m_RandomCheats::m_EnabledCheats[std::stoi(element.key())][1] = "true"; + } - Events::drawMenuBackgroundEvent += []() { - if (bSaveGameFlag) - { - FrontEndMenuManager.m_nCurrentMenuPage = MENUPAGE_GAME_SAVE; - bSaveGameFlag = false; - } - }; + Events::drawMenuBackgroundEvent += []() + { + if (bSaveGameFlag) + { + FrontEndMenuManager.m_nCurrentMenuPage = MENUPAGE_GAME_SAVE; + bSaveGameFlag = false; + } + }; - Events::drawingEvent += []() { - if (m_RandomCheats::m_bEnabled && m_RandomCheats::m_bProgressBar) - { - // Next cheat timer bar - uint screenWidth = screen::GetScreenWidth(); - uint screenHeight = screen::GetScreenHeight(); - uint timer = CTimer::m_snTimeInMilliseconds; - uint totalTime = m_RandomCheats::m_nInterval; - float progress = (totalTime - (timer - m_RandomCheats::m_nTimer) / 1000.0f) / totalTime; + Events::drawingEvent += []() + { + if (m_RandomCheats::m_bEnabled && m_RandomCheats::m_bProgressBar) + { + // Next cheat timer bar + uint screenWidth = screen::GetScreenWidth(); + uint screenHeight = screen::GetScreenHeight(); + uint timer = CTimer::m_snTimeInMilliseconds; + uint totalTime = m_RandomCheats::m_nInterval; + float progress = (totalTime - (timer - m_RandomCheats::m_nTimer) / 1000.0f) / totalTime; - CRect sizeBox = CRect(0, 0, screenWidth, screenHeight / 50); - CRect sizeProgress = CRect(0, 0, screenWidth * progress, screenHeight / 50); - CRGBA colorBG = CRGBA(24, 99, 44, 255); - CRGBA colorProgress = CRGBA(33, 145, 63, 255); + CRect sizeBox = CRect(0,0, screenWidth, screenHeight/50); + CRect sizeProgress = CRect(0,0, screenWidth*progress, screenHeight/50); + CRGBA colorBG = CRGBA(24, 99, 44, 255); + CRGBA colorProgress = CRGBA(33, 145, 63, 255); - CSprite2d::DrawRect(sizeBox, colorBG); - CSprite2d::DrawRect(sizeProgress, colorProgress); - } - }; + CSprite2d::DrawRect(sizeBox, colorBG); + CSprite2d::DrawRect(sizeProgress, colorProgress); + } + }; #endif - Events::processScriptsEvent += [] { - uint timer = CTimer::m_snTimeInMilliseconds; - CPlayerPed *pPlayer = FindPlayerPed(); - int hplayer = CPools::GetPedRef(pPlayer); + Events::processScriptsEvent += [] + { + uint timer = CTimer::m_snTimeInMilliseconds; + CPlayerPed* pPlayer = FindPlayerPed(); + int hplayer = CPools::GetPedRef(pPlayer); #ifdef GTASA - if (m_bScreenShot) - { - if (quickSceenShot.Pressed()) - { - Command(); - SetHelpMessage("Screenshot taken", false, false, false); - } - } + if (m_bScreenShot) + { + if (quickSceenShot.Pressed()) + { + Command(); + SetHelpMessage("Screenshot taken", false, false, false); + } + } - if (m_HardMode::m_bEnabled) - { - if (pPlayer->m_fHealth > 50.0f) - pPlayer->m_fHealth = 50.0f; + if (m_HardMode::m_bEnabled) + { + if (pPlayer->m_fHealth > 50.0f) + pPlayer->m_fHealth = 50.0f; - pPlayer->m_fArmour = 0.0f; - CStats::SetStatValue(STAT_MAX_HEALTH, 350.0f); - CStats::SetStatValue(STAT_STAMINA, 0.0f); - } + pPlayer->m_fArmour = 0.0f; + CStats::SetStatValue(STAT_MAX_HEALTH, 350.0f); + CStats::SetStatValue(STAT_STAMINA, 0.0f); + } - static int m_nSolidWaterObj; - if (m_bSolidWater) - { - CVector pos = pPlayer->GetPosition(); + static int m_nSolidWaterObj; + if (m_bSolidWater) + { + CVector pos = pPlayer->GetPosition(); - float waterHeight = 0; - Command(pos.x, pos.y, false, &waterHeight); + float waterHeight = 0; + Command(pos.x, pos.y, false, &waterHeight); - if (!Command(hplayer) && waterHeight != -1000.0f && pos.z > (waterHeight)) - { - if (m_nSolidWaterObj == 0) - { - Command(3095, pos.x, pos.y, waterHeight, &m_nSolidWaterObj); - Command(m_nSolidWaterObj, false); - if (pos.z < (waterHeight + 1)) - { - pPlayer->SetPosn(pos.x, pos.y, waterHeight + 1); - } - } - else - { - Command(m_nSolidWaterObj, pos.x, pos.y, waterHeight); - } - } - } - else - { - if (m_nSolidWaterObj) - { - Command(m_nSolidWaterObj); - m_nSolidWaterObj = 0; - } - } + if (!Command(hplayer) && waterHeight != -1000.0f && pos.z > (waterHeight)) + { + if (m_nSolidWaterObj == 0) + { + Command(3095, pos.x, pos.y, waterHeight, &m_nSolidWaterObj); + Command(m_nSolidWaterObj, false); + if (pos.z < (waterHeight + 1)) + { + pPlayer->SetPosn(pos.x, pos.y, waterHeight + 1); + } + } + else + { + Command(m_nSolidWaterObj, pos.x, pos.y, waterHeight); + } + } + } + else + { + if (m_nSolidWaterObj) + { + Command(m_nSolidWaterObj); + m_nSolidWaterObj = 0; + } + } - if (freeCam.Pressed()) - { - if (m_Freecam::m_bEnabled) - { - m_Freecam::m_bEnabled = false; - ClearFreecamStuff(); - } - else - { - m_Freecam::m_bEnabled = true; - } - } + if (freeCam.Pressed()) + { + if (m_Freecam::m_bEnabled) + { + m_Freecam::m_bEnabled = false; + ClearFreecamStuff(); + } + else + { + m_Freecam::m_bEnabled = true; + } + } - if (m_Freecam::m_bEnabled) - { - FreeCam(); - } + if (m_Freecam::m_bEnabled) + { + FreeCam(); + } #endif - // improve this later - static uint syncTimer; - if (m_bSyncTime && timer - syncTimer > 50) - { - std::time_t t = std::time(nullptr); - std::tm *now = std::localtime(&t); + // improve this later + static uint syncTimer; + if (m_bSyncTime && timer - syncTimer > 50) + { + std::time_t t = std::time(nullptr); + std::tm* now = std::localtime(&t); - CClock::ms_nGameClockHours = now->tm_hour; - CClock::ms_nGameClockMinutes = now->tm_min; + CClock::ms_nGameClockHours = now->tm_hour; + CClock::ms_nGameClockMinutes = now->tm_min; - syncTimer = timer; - } + syncTimer = timer; + } #ifdef GTASA - if (m_RandomCheats::m_bEnabled) - { - if ((timer - m_RandomCheats::m_nTimer) > (static_cast(m_RandomCheats::m_nInterval) * 1000)) - { - int id = Random(0, 91); + if (m_RandomCheats::m_bEnabled) + { + if ((timer - m_RandomCheats::m_nTimer) > (static_cast(m_RandomCheats::m_nInterval) * 1000)) + { + int id = Random(0, 91); - for (int i = 0; i < 92; i++) - { - if (i == id) - { - if (m_RandomCheats::m_EnabledCheats[i][1] == "true") - { - Call<0x00438370>(id); // cheatEnableLegimate(int CheatID) - CMessages::AddMessage((char *)m_RandomCheats::m_EnabledCheats[i][0].c_str(), 2000, 0, - false); - m_RandomCheats::m_nTimer = timer; - } - break; - } - } - } - } + for (int i = 0; i < 92; i++) + { + if (i == id) + { + if (m_RandomCheats::m_EnabledCheats[i][1] == "true") + { + Call<0x00438370>(id); // cheatEnableLegimate(int CheatID) + CMessages::AddMessage((char*)m_RandomCheats::m_EnabledCheats[i][0].c_str(), 2000, 0, false); + m_RandomCheats::m_nTimer = timer; + } + break; + } + } + } + } #endif - }; + }; } -void SetPlayerMission(std::string &rootkey, std::string &name, std::string &id) +void SetPlayerMission(std::string& rootkey, std::string& name, std::string& id) { - CPlayerPed *player = FindPlayerPed(); - uint hplayer = CPools::GetPedRef(player); - int interior = 0; + CPlayerPed* player = FindPlayerPed(); + uint hplayer = CPools::GetPedRef(player); + int interior = 0; #ifndef GTA3 - Command<0x09E8>(hplayer, &interior); + Command<0x09E8>(hplayer, &interior); #endif - if (BY_GAME(Util::IsOnMission(), true, true) && interior == 0) - { - player->SetWantedLevel(0); - Command(std::stoi(id)); - } - else - { - SetHelpMessage("Can't start mission now", false, false, false); - } + if (BY_GAME(Util::IsOnMission(), true, true) && interior == 0) + { + player->SetWantedLevel(0); + Command(std::stoi(id)); + } + else + { + SetHelpMessage("Can't start mission now", false, false, false); + } } #ifdef GTASA void Game::FreeCam() { - int delta = (CTimer::m_snTimeInMillisecondsNonClipped - CTimer::m_snPreviousTimeInMillisecondsNonClipped); + int delta = (CTimer::m_snTimeInMillisecondsNonClipped - + CTimer::m_snPreviousTimeInMillisecondsNonClipped); + + int ratio = 1 / (1 + (delta * m_Freecam::m_nMul)); + int speed = m_Freecam::m_nMul + m_Freecam::m_nMul * ratio * delta; + + if (!m_Freecam::m_bInitDone) + { + CPlayerPed* player = FindPlayerPed(-1); + Command(0, true); - int ratio = 1 / (1 + (delta * m_Freecam::m_nMul)); - int speed = m_Freecam::m_nMul + m_Freecam::m_nMul * ratio * delta; + m_Freecam::m_bHudState = patch::Get(0xBA6769); // hud + m_Freecam::m_bRadarState = patch::Get(0xBA676C); // radar + patch::Set(0xBA6769, 0); // hud + patch::Set(0xBA676C, 2); // radar - if (!m_Freecam::m_bInitDone) - { - CPlayerPed *player = FindPlayerPed(-1); - Command(0, true); + CVector player_pos = player->GetPosition(); + CPad::GetPad(0)->DisablePlayerControls = true; - m_Freecam::m_bHudState = patch::Get(0xBA6769); // hud - m_Freecam::m_bRadarState = patch::Get(0xBA676C); // radar - patch::Set(0xBA6769, 0); // hud - patch::Set(0xBA676C, 2); // radar + Command(player_pos.x, player_pos.y, player_pos.z, &m_Freecam::m_nPed); + m_Freecam::m_pPed = CPools::GetPed(m_Freecam::m_nPed); + m_Freecam::m_pPed->m_bIsVisible = false; - CVector player_pos = player->GetPosition(); - CPad::GetPad(0)->DisablePlayerControls = true; + Command(m_Freecam::m_nPed, true); + Command(m_Freecam::m_nPed, false); + Command(m_Freecam::m_nPed, false); - Command(player_pos.x, player_pos.y, player_pos.z, &m_Freecam::m_nPed); - m_Freecam::m_pPed = CPools::GetPed(m_Freecam::m_nPed); - m_Freecam::m_pPed->m_bIsVisible = false; + m_Freecam::m_fTotalMouse.x = player->GetHeading() + 89.6f; + m_Freecam::m_fTotalMouse.y = 0; - Command(m_Freecam::m_nPed, true); - Command(m_Freecam::m_nPed, false); - Command(m_Freecam::m_nPed, false); + m_Freecam::m_bInitDone = true; + player_pos.z -= 20; + m_Freecam::m_pPed->SetPosn(player_pos); - m_Freecam::m_fTotalMouse.x = player->GetHeading() + 89.6f; - m_Freecam::m_fTotalMouse.y = 0; + TheCamera.LerpFOV(TheCamera.FindCamFOV(), m_Freecam::m_fFOV, 1000, true); + Command(true); + } - m_Freecam::m_bInitDone = true; - player_pos.z -= 20; - m_Freecam::m_pPed->SetPosn(player_pos); + CVector pos = m_Freecam::m_pPed->GetPosition(); - TheCamera.LerpFOV(TheCamera.FindCamFOV(), m_Freecam::m_fFOV, 1000, true); - Command(true); - } + Command(&m_Freecam::m_fMouse.x, &m_Freecam::m_fMouse.y); + m_Freecam::m_fTotalMouse.x = m_Freecam::m_fTotalMouse.x - m_Freecam::m_fMouse.x / 250; + m_Freecam::m_fTotalMouse.y = m_Freecam::m_fTotalMouse.y + m_Freecam::m_fMouse.y / 3; - CVector pos = m_Freecam::m_pPed->GetPosition(); + if (m_Freecam::m_fTotalMouse.x > 150) + { + m_Freecam::m_fTotalMouse.y = 150; + } - Command(&m_Freecam::m_fMouse.x, &m_Freecam::m_fMouse.y); - m_Freecam::m_fTotalMouse.x = m_Freecam::m_fTotalMouse.x - m_Freecam::m_fMouse.x / 250; - m_Freecam::m_fTotalMouse.y = m_Freecam::m_fTotalMouse.y + m_Freecam::m_fMouse.y / 3; + if (m_Freecam::m_fTotalMouse.y < -150) + { + m_Freecam::m_fTotalMouse.y = -150; + } - if (m_Freecam::m_fTotalMouse.x > 150) - { - m_Freecam::m_fTotalMouse.y = 150; - } + if (freeCamTeleportPlayer.Pressed()) + { + CPlayerPed* player = FindPlayerPed(-1); + CVector pos = m_Freecam::m_pPed->GetPosition(); + CEntity* player_entity = FindPlayerEntity(-1); + pos.z = CWorld::FindGroundZFor3DCoord(pos.x, pos.y, 1000, nullptr, &player_entity) + 0.5f; + Command(CPools::GetPedRef(player), pos.x, pos.y, pos.z); - if (m_Freecam::m_fTotalMouse.y < -150) - { - m_Freecam::m_fTotalMouse.y = -150; - } + // disble them again cause they get enabled + CHud::bScriptDontDisplayRadar = true; + CHud::m_Wants_To_Draw_Hud = false; + SetHelpMessage("Player telported", false, false, false); + } - if (freeCamTeleportPlayer.Pressed()) - { - CPlayerPed *player = FindPlayerPed(-1); - CVector pos = m_Freecam::m_pPed->GetPosition(); - CEntity *player_entity = FindPlayerEntity(-1); - pos.z = CWorld::FindGroundZFor3DCoord(pos.x, pos.y, 1000, nullptr, &player_entity) + 0.5f; - Command(CPools::GetPedRef(player), pos.x, pos.y, pos.z); + if (KeyPressed(VK_RCONTROL)) + { + speed /= 2; + } - // disble them again cause they get enabled - CHud::bScriptDontDisplayRadar = true; - CHud::m_Wants_To_Draw_Hud = false; - SetHelpMessage("Player telported", false, false, false); - } + if (KeyPressed(VK_RSHIFT)) + { + speed *= 2; + } - if (KeyPressed(VK_RCONTROL)) - { - speed /= 2; - } + if (KeyPressed(VK_KEY_I) || KeyPressed(VK_KEY_K)) + { + if (KeyPressed(VK_KEY_K)) + { + speed *= -1; + } - if (KeyPressed(VK_RSHIFT)) - { - speed *= 2; - } + float angle; + Command(m_Freecam::m_nPed, &angle); + pos.x += speed * cos(angle * 3.14159f / 180.0f); + pos.y += speed * sin(angle * 3.14159f / 180.0f); + pos.z += speed * 2 * sin(m_Freecam::m_fTotalMouse.y / 3 * 3.14159f / 180.0f); + } - if (KeyPressed(VK_KEY_I) || KeyPressed(VK_KEY_K)) - { - if (KeyPressed(VK_KEY_K)) - { - speed *= -1; - } + if (KeyPressed(VK_KEY_J) || KeyPressed(VK_KEY_L)) + { + if (KeyPressed(VK_KEY_J)) + { + speed *= -1; + } - float angle; - Command(m_Freecam::m_nPed, &angle); - pos.x += speed * cos(angle * 3.14159f / 180.0f); - pos.y += speed * sin(angle * 3.14159f / 180.0f); - pos.z += speed * 2 * sin(m_Freecam::m_fTotalMouse.y / 3 * 3.14159f / 180.0f); - } + float angle; + Command(m_Freecam::m_nPed, &angle); + angle -= 90; - if (KeyPressed(VK_KEY_J) || KeyPressed(VK_KEY_L)) - { - if (KeyPressed(VK_KEY_J)) - { - speed *= -1; - } + pos.x += speed * cos(angle * 3.14159f / 180.0f); + pos.y += speed * sin(angle * 3.14159f / 180.0f); + } - float angle; - Command(m_Freecam::m_nPed, &angle); - angle -= 90; + if (CPad::NewMouseControllerState.wheelUp) + { + if (m_Freecam::m_fFOV > 10.0f) + { + m_Freecam::m_fFOV -= 2.0f * speed; + } - pos.x += speed * cos(angle * 3.14159f / 180.0f); - pos.y += speed * sin(angle * 3.14159f / 180.0f); - } + TheCamera.LerpFOV(TheCamera.FindCamFOV(), m_Freecam::m_fFOV, 250, true); + Command(true); + } - if (CPad::NewMouseControllerState.wheelUp) - { - if (m_Freecam::m_fFOV > 10.0f) - { - m_Freecam::m_fFOV -= 2.0f * speed; - } + if (CPad::NewMouseControllerState.wheelDown) + { + if (m_Freecam::m_fFOV < 115.0f) + { + m_Freecam::m_fFOV += 2.0f * speed; + } - TheCamera.LerpFOV(TheCamera.FindCamFOV(), m_Freecam::m_fFOV, 250, true); - Command(true); - } + TheCamera.LerpFOV(TheCamera.FindCamFOV(), m_Freecam::m_fFOV, 250, true); + Command(true); + } - if (CPad::NewMouseControllerState.wheelDown) - { - if (m_Freecam::m_fFOV < 115.0f) - { - m_Freecam::m_fFOV += 2.0f * speed; - } - - TheCamera.LerpFOV(TheCamera.FindCamFOV(), m_Freecam::m_fFOV, 250, true); - Command(true); - } - - m_Freecam::m_pPed->SetHeading(m_Freecam::m_fTotalMouse.x); - Command(m_Freecam::m_nPed, 0.0, 0.0, 20.0, 90.0, 180, m_Freecam::m_fTotalMouse.y, - 0.0, 2); - m_Freecam::m_pPed->SetPosn(pos); - CIplStore::AddIplsNeededAtPosn(pos); + m_Freecam::m_pPed->SetHeading(m_Freecam::m_fTotalMouse.x); + Command(m_Freecam::m_nPed, 0.0, 0.0, 20.0, 90.0, 180, m_Freecam::m_fTotalMouse.y, 0.0, 2); + m_Freecam::m_pPed->SetPosn(pos); + CIplStore::AddIplsNeededAtPosn(pos); } void Game::ClearFreecamStuff() { - m_Freecam::m_bInitDone = false; - Command(0, false); - patch::Set(BY_GAME(0xBA6769, 0x86963A), m_Freecam::m_bHudState); // hud - patch::Set(0xBA676C, m_Freecam::m_bRadarState); // radar - CPad::GetPad(0)->DisablePlayerControls = false; + m_Freecam::m_bInitDone = false; + Command(0, false); + patch::Set(BY_GAME(0xBA6769, 0x86963A), m_Freecam::m_bHudState); // hud + patch::Set(0xBA676C, m_Freecam::m_bRadarState); // radar + CPad::GetPad(0)->DisablePlayerControls = false; - Command(m_Freecam::m_nPed); - m_Freecam::m_pPed = nullptr; - Command(false); - Command(); + Command(m_Freecam::m_nPed); + m_Freecam::m_pPed = nullptr; + Command(false); + Command(); } #endif void Game::Draw() { - ImGui::Spacing(); - CPlayerPed *pPlayer = FindPlayerPed(); - int hplayer = CPools::GetPedRef(pPlayer); + ImGui::Spacing(); + CPlayerPed* pPlayer = FindPlayerPed(); + int hplayer = CPools::GetPedRef(pPlayer); #ifdef GTASA - if (ImGui::Button("Save game (might cause game bugs)", Ui::GetSize())) - { - FrontEndMenuManager.m_bActivateMenuNextFrame = true; - bSaveGameFlag = true; - } - ImGui::Spacing(); + if (ImGui::Button("Save game (might cause game bugs)", Ui::GetSize())) + { + FrontEndMenuManager.m_bActivateMenuNextFrame = true; + bSaveGameFlag = true; + } + ImGui::Spacing(); #endif - if (ImGui::BeginTabBar("Game", ImGuiTabBarFlags_NoTooltip + ImGuiTabBarFlags_FittingPolicyScroll)) - { - if (ImGui::BeginTabItem("Checkboxes")) - { - ImGui::Spacing(); - ImGui::Columns(2, nullptr, false); - if (ImGui::Checkbox("Disable cheats", &m_bDisableCheats)) - { - if (m_bDisableCheats) - { + if (ImGui::BeginTabBar("Game", ImGuiTabBarFlags_NoTooltip + ImGuiTabBarFlags_FittingPolicyScroll)) + { + if (ImGui::BeginTabItem("Checkboxes")) + { + ImGui::Spacing(); + ImGui::Columns(2, nullptr, false); + if (ImGui::Checkbox("Disable cheats", &m_bDisableCheats)) + { + if (m_bDisableCheats) + { #ifdef GTASA - patch::Set(0x4384D0, 0xE9, false); - patch::SetInt(0x4384D1, 0xD0, false); - patch::Nop(0x4384D5, 4, false); -#elif GTAVC - patch::Nop(0x602BD8, 5); - patch::Nop(0x602BE7, 5); + patch::Set(0x4384D0, 0xE9, false); + patch::SetInt(0x4384D1, 0xD0, false); + patch::Nop(0x4384D5, 4, false); +#elif GTAVC + patch::Nop(0x602BD8, 5); + patch::Nop(0x602BE7, 5); #else // GTA3 - patch::Nop(0x5841B8, 5); - patch::Nop(0x5841C7, 5); + patch::Nop(0x5841B8, 5); + patch::Nop(0x5841C7, 5); #endif - } - else - { + } + else + { #ifdef GTASA - patch::Set(0x4384D0, 0x83, false); - patch::SetInt(0x4384D1, -0x7DF0F908, false); // correct? - patch::SetInt(0x4384D5, 0xCC, false); -#elif GTAVC - patch::SetRaw(0x602BD8, (char *)"\x88\xD8\x89\xF1\x50", 5); - patch::SetRaw(0x602BE7, (char *)"\xE8\x34\x91\xEA\xFF", 5); + patch::Set(0x4384D0, 0x83, false); + patch::SetInt(0x4384D1, -0x7DF0F908, false); // correct? + patch::SetInt(0x4384D5, 0xCC, false); +#elif GTAVC + patch::SetRaw(0x602BD8, (char*)"\x88\xD8\x89\xF1\x50", 5); + patch::SetRaw(0x602BE7, (char*)"\xE8\x34\x91\xEA\xFF", 5); #else // GTA3 - patch::SetRaw(0x5841B8, (char *)"\x88\xD8\x89\xF1\x50", 5); - patch::SetRaw(0x5841C7, (char *)"\xE8\x84\xE2\xF0\xFF", 5); + patch::SetRaw(0x5841B8, (char*)"\x88\xD8\x89\xF1\x50", 5); + patch::SetRaw(0x5841C7, (char*)"\xE8\x84\xE2\xF0\xFF", 5); #endif - } - } - if (ImGui::Checkbox("Disable F1 & F3 replay", &m_bDisableReplay)) - { - if (m_bDisableReplay) - { - patch::SetUChar(BY_GAME(0x460500, 0x624EC0, 0x593170), 0xC3); - } - else - { - patch::SetUChar(BY_GAME(0x460500, 0x624EC0, 0x593170), 0x80); - } - } + } + } + if (ImGui::Checkbox("Disable F1 & F3 replay", &m_bDisableReplay)) + { + if (m_bDisableReplay) + { + patch::SetUChar(BY_GAME(0x460500, 0x624EC0, 0x593170), 0xC3); + } + else + { + patch::SetUChar(BY_GAME(0x460500, 0x624EC0, 0x593170), 0x80); + } + } - Ui::CheckboxAddress("Faster clock", BY_GAME(0x96913B, 0xA10B87, 0x95CDBB)); + Ui::CheckboxAddress("Faster clock", BY_GAME(0x96913B, 0xA10B87, 0x95CDBB)); #ifdef GTASA - if (Ui::CheckboxWithHint("Forbidden area wl", &m_bForbiddenArea, "Wanted levels that appears outside \ + if (Ui::CheckboxWithHint("Forbidden area wl", &m_bForbiddenArea, "Wanted levels that appears outside \ of LS without completing missions")) - { - if (m_bForbiddenArea) - { - patch::Set(0x441770, 0x83, false); - } - else - { - patch::Set(0x441770, 0xC3, false); - } - } - Ui::CheckboxAddress("Free pay n spray", 0x96C009); + { + if (m_bForbiddenArea) + { + patch::Set(0x441770, 0x83, false); + } + else + { + patch::Set(0x441770, 0xC3, false); + } + } + Ui::CheckboxAddress("Free pay n spray", 0x96C009); #endif #ifdef GTAVC - ImGui::NextColumn(); + ImGui::NextColumn(); #endif #ifdef GTASA - Ui::CheckboxAddress("Freeze game", 0xA10B48); + Ui::CheckboxAddress("Freeze game", 0xA10B48); #endif - if (ImGui::Checkbox("Freeze game time", &m_bFreezeTime)) - { - if (m_bFreezeTime) - { - patch::SetRaw(BY_GAME(0x52CF10, 0x487010, 0x473460), (char *)"\xEB\xEF", 2); - } - else - { - patch::SetRaw(BY_GAME(0x52CF10, 0x487010, 0x473460), - (char *)BY_GAME("\x56\x8B", "\x6A\x01", "\x6A\x01"), 2); - } - } + if (ImGui::Checkbox("Freeze game time", &m_bFreezeTime)) + { + if (m_bFreezeTime) + { + patch::SetRaw(BY_GAME(0x52CF10, 0x487010, 0x473460), (char*)"\xEB\xEF", 2); + } + else + { + patch::SetRaw(BY_GAME(0x52CF10, 0x487010, 0x473460), (char*)BY_GAME("\x56\x8B", "\x6A\x01", "\x6A\x01"), 2); + } + } #ifdef GTASA - ImGui::NextColumn(); + ImGui::NextColumn(); #endif - if (ImGui::Checkbox("Freeze misson timer", &m_bMissionTimer)) - { - Command(m_bMissionTimer); - } + if (ImGui::Checkbox("Freeze misson timer", &m_bMissionTimer)) + { + Command(m_bMissionTimer); + } #ifdef GTASA - if (Ui::CheckboxWithHint("Hard mode", &m_HardMode::m_bEnabled, - "Makes the game more challanging to play. \n\ + if (Ui::CheckboxWithHint("Hard mode", &m_HardMode::m_bEnabled, "Makes the game more challanging to play. \n\ Lowers armour, health, stamina etc.")) - { - CPlayerPed *player = FindPlayerPed(); + { + CPlayerPed* player = FindPlayerPed(); - if (m_HardMode::m_bEnabled) - { - m_HardMode::m_fBacArmour = player->m_fArmour; - m_HardMode::m_fBacHealth = player->m_fHealth; - m_HardMode::m_fBacMaxHealth = CStats::GetStatValue(STAT_MAX_HEALTH); - m_HardMode::m_fBacStamina = CStats::GetStatValue(STAT_STAMINA); - player->m_fHealth = 50.0f; - } - else - { - player->m_fArmour = m_HardMode::m_fBacArmour; - CStats::SetStatValue(STAT_STAMINA, m_HardMode::m_fBacStamina); - CStats::SetStatValue(STAT_MAX_HEALTH, m_HardMode::m_fBacMaxHealth); - player->m_fHealth = m_HardMode::m_fBacHealth; - CWeaponInfo::LoadWeaponData(); - } - } - if (Ui::CheckboxWithHint("Keep stuff", &m_bKeepStuff, "Keep stuff after arrest/death")) - { - Command(m_bKeepStuff); - Command(m_bKeepStuff); - } - Ui::CheckboxWithHint("Screenshot shortcut", &m_bScreenShot, - (("Take screenshot using ") + quickSceenShot.GetNameString() + - "\nSaved inside 'GTA San Andreas User Files\\Gallery'") - .c_str()); - Ui::CheckboxWithHint("Solid water", &m_bSolidWater, - "Player can walk on water\nTurn this off if you want to swim."); + if (m_HardMode::m_bEnabled) + { + m_HardMode::m_fBacArmour = player->m_fArmour; + m_HardMode::m_fBacHealth = player->m_fHealth; + m_HardMode::m_fBacMaxHealth = CStats::GetStatValue(STAT_MAX_HEALTH); + m_HardMode::m_fBacStamina = CStats::GetStatValue(STAT_STAMINA); + player->m_fHealth = 50.0f; + } + else + { + player->m_fArmour = m_HardMode::m_fBacArmour; + CStats::SetStatValue(STAT_STAMINA, m_HardMode::m_fBacStamina); + CStats::SetStatValue(STAT_MAX_HEALTH, m_HardMode::m_fBacMaxHealth); + player->m_fHealth = m_HardMode::m_fBacHealth; + CWeaponInfo::LoadWeaponData(); + } + } + if (Ui::CheckboxWithHint("Keep stuff", &m_bKeepStuff, "Keep stuff after arrest/death")) + { + Command(m_bKeepStuff); + Command(m_bKeepStuff); + } + Ui::CheckboxWithHint("Screenshot shortcut", &m_bScreenShot, + (("Take screenshot using ") + quickSceenShot.GetNameString() + + "\nSaved inside 'GTA San Andreas User Files\\Gallery'").c_str()); + Ui::CheckboxWithHint("Solid water", &m_bSolidWater, + "Player can walk on water\nTurn this off if you want to swim."); #endif - if (ImGui::Checkbox("Sync system time", &m_bSyncTime)) - { - if (m_bSyncTime) - { - patch::RedirectCall(BY_GAME(0x53BFBD, 0x4A44F7, 0x48C8EB), &RealTimeClock); - } - else - { - patch::RedirectCall(BY_GAME(0x53BFBD, 0x4A44F7, 0x48C8EB), &CClock::Update); - } - } + if (ImGui::Checkbox("Sync system time", &m_bSyncTime)) + { + if (m_bSyncTime) + { + patch::RedirectCall(BY_GAME(0x53BFBD, 0x4A44F7, 0x48C8EB), &RealTimeClock); + } + else + { + patch::RedirectCall(BY_GAME(0x53BFBD, 0x4A44F7, 0x48C8EB), &CClock::Update); + } + } - ImGui::Columns(1); - ImGui::EndTabItem(); - } - if (ImGui::BeginTabItem("Menus")) - { + ImGui::Columns(1); + ImGui::EndTabItem(); + } + if (ImGui::BeginTabItem("Menus")) + { #ifdef GTASA - if (ImGui::CollapsingHeader("Current day")) - { - int day = CClock::CurrentDay - 1; - if (Ui::ListBox("Select day", m_DayNames, day)) - { - CClock::CurrentDay = day + 1; - } + if (ImGui::CollapsingHeader("Current day")) + { + int day = CClock::CurrentDay - 1; + if (Ui::ListBox("Select day", m_DayNames, day)) + { + CClock::CurrentDay = day + 1; + } - ImGui::Spacing(); - ImGui::Separator(); - } + ImGui::Spacing(); + ImGui::Separator(); + } #endif - Ui::EditAddress("Days passed", BY_GAME(0xB79038, 0x97F1F4, 0x8F2BB8), 0, 9999); - Ui::EditReference("FPS limit", BY_GAME(RsGlobal.frameLimit, RsGlobal.maxFPS, RsGlobal.maxFPS), 1, 30, 60); + Ui::EditAddress("Days passed", BY_GAME(0xB79038, 0x97F1F4, 0x8F2BB8), 0, 9999); + Ui::EditReference("FPS limit", BY_GAME(RsGlobal.frameLimit, RsGlobal.maxFPS, RsGlobal.maxFPS), 1, 30, 60); #ifdef GTASA - if (ImGui::CollapsingHeader("Free cam")) - { - if (Ui::CheckboxWithHint("Enable", &m_Freecam::m_bEnabled, "Forward: I\tBackward: K\ + if (ImGui::CollapsingHeader("Free cam")) + { + if (Ui::CheckboxWithHint("Enable", &m_Freecam::m_bEnabled, "Forward: I\tBackward: K\ \nLeft: J\t\t Right: L\n\nSlower: RCtrl\tFaster: RShift\n\nZoom: Mouse wheel")) - { - if (!m_Freecam::m_bEnabled) - { - ClearFreecamStuff(); - } - } - ImGui::Spacing(); + { + if (!m_Freecam::m_bEnabled) + { + ClearFreecamStuff(); + } + } + ImGui::Spacing(); - ImGui::SliderFloat("Field of view", &m_Freecam::m_fFOV, 5.0f, 120.0f); - ImGui::SliderInt("Movement Speed", &m_Freecam::m_nMul, 1, 10); - ImGui::Spacing(); - ImGui::TextWrapped("Press Enter to teleport player to camera location"); - ImGui::Spacing(); - ImGui::Separator(); - } + ImGui::SliderFloat("Field of view", &m_Freecam::m_fFOV, 5.0f, 120.0f); + ImGui::SliderInt("Movement Speed", &m_Freecam::m_nMul, 1, 10); + ImGui::Spacing(); + ImGui::TextWrapped("Press Enter to teleport player to camera location"); + ImGui::Spacing(); + ImGui::Separator(); + } #endif - Ui::EditReference("Game speed", CTimer::ms_fTimeScale, 1, 1, 10); - Ui::EditFloat("Gravity", BY_GAME(0x863984, 0x68F5F0, 0x5F68D4), -1.0f, 0.008f, 1.0f, 1.0f, 0.01f); + Ui::EditReference("Game speed", CTimer::ms_fTimeScale, 1, 1, 10); + Ui::EditFloat("Gravity", BY_GAME(0x863984, 0x68F5F0, 0x5F68D4), -1.0f, 0.008f, 1.0f, 1.0f, 0.01f); - if (ImGui::CollapsingHeader("Set time")) - { - int hour = CClock::ms_nGameClockHours; - int minute = CClock::ms_nGameClockMinutes; + 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("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; - } + if (ImGui::InputInt("Minute", &minute)) + { + if (minute < 0) minute = 59; + if (minute > 59) minute = 0; + CClock::ms_nGameClockMinutes = minute; + } - ImGui::Spacing(); - ImGui::Separator(); - } + ImGui::Spacing(); + ImGui::Separator(); + } #ifdef GTASA - static std::vector themes{ - {"Beach", 0x969159}, {"Country", 0x96917D}, {"Fun house", 0x969176}, {"Ninja", 0x96915C}}; - Ui::EditRadioButtonAddress("Themes", themes); + static std::vector themes{ + {"Beach", 0x969159}, {"Country", 0x96917D}, {"Fun house", 0x969176}, {"Ninja", 0x96915C} + }; + Ui::EditRadioButtonAddress("Themes", themes); #endif - if (ImGui::CollapsingHeader("Weather")) - { + if (ImGui::CollapsingHeader("Weather")) + { #ifdef GTASA - if (ImGui::Button("Foggy", Ui::GetSize(3))) - { - Call<0x438F80>(); - } + if (ImGui::Button("Foggy", Ui::GetSize(3))) + { + Call<0x438F80>(); + } - ImGui::SameLine(); - if (ImGui::Button("Overcast", Ui::GetSize(3))) - { - Call<0x438F60>(); - } + ImGui::SameLine(); + if (ImGui::Button("Overcast", Ui::GetSize(3))) + { + Call<0x438F60>(); + } - ImGui::SameLine(); - if (ImGui::Button("Rainy", Ui::GetSize(3))) - { - Call<0x438F70>(); - } + ImGui::SameLine(); + if (ImGui::Button("Rainy", Ui::GetSize(3))) + { + Call<0x438F70>(); + } - if (ImGui::Button("Sandstorm", Ui::GetSize(3))) - { - Call<0x439590>(); - } + if (ImGui::Button("Sandstorm", Ui::GetSize(3))) + { + Call<0x439590>(); + } - ImGui::SameLine(); - if (ImGui::Button("Thunderstorm", Ui::GetSize(3))) - { - Call<0x439570>(); - } + ImGui::SameLine(); + if (ImGui::Button("Thunderstorm", Ui::GetSize(3))) + { + Call<0x439570>(); + } - ImGui::SameLine(); - if (ImGui::Button("Very sunny", Ui::GetSize(3))) - { - Call<0x438F50>(); - } + ImGui::SameLine(); + if (ImGui::Button("Very sunny", Ui::GetSize(3))) + { + Call<0x438F50>(); + } #else // GTA3 & GTAVC - if (ImGui::Button("Sunny", Ui::GetSize(3))) + if (ImGui::Button("Sunny", Ui::GetSize(3))) + { + CWeather::ForceWeatherNow(0); + } + ImGui::SameLine(); + if (ImGui::Button("Cloudy", Ui::GetSize(3))) + { + CWeather::ForceWeatherNow(1); + } + ImGui::SameLine(); + if (ImGui::Button("Rainy", Ui::GetSize(3))) + { + CWeather::ForceWeatherNow(2); + } + + if (ImGui::Button("Foggy", Ui::GetSize(3))) + { + CWeather::ForceWeatherNow(3); + } +#ifdef GTAVC + ImGui::SameLine(); + if (ImGui::Button("Extra sunny", Ui::GetSize(3))) { - CWeather::ForceWeatherNow(0); + CWeather::ForceWeatherNow(4); } ImGui::SameLine(); - if (ImGui::Button("Cloudy", Ui::GetSize(3))) + if (ImGui::Button("Hurricane", Ui::GetSize(3))) { - CWeather::ForceWeatherNow(1); - } - ImGui::SameLine(); - if (ImGui::Button("Rainy", Ui::GetSize(3))) - { - CWeather::ForceWeatherNow(2); + CWeather::ForceWeatherNow(5); } - if (ImGui::Button("Foggy", Ui::GetSize(3))) + if (ImGui::Button("Extra colors", Ui::GetSize(3))) { - CWeather::ForceWeatherNow(3); + CWeather::ForceWeatherNow(6); } #endif - ImGui::Spacing(); - ImGui::Separator(); - } - ImGui::EndTabItem(); - } - if (ImGui::BeginTabItem("Missions")) - { - ImGui::Spacing(); +#endif + ImGui::Spacing(); + ImGui::Separator(); + } + ImGui::EndTabItem(); + } + if (ImGui::BeginTabItem("Missions")) + { + ImGui::Spacing(); - static bool bMissionLoaderWarningShown; - if (!bMissionLoaderWarningShown) - { - ImGui::TextWrapped("Mission loader may cause,\n\ + static bool bMissionLoaderWarningShown; + if (!bMissionLoaderWarningShown) + { + ImGui::TextWrapped("Mission loader may cause,\n\ 1. Game crashes\n\ 2. Break save games\n\ 3. Break game progression\n\ 4. Random bugs & glitches\n\n\ It's recommanded not to save after using the mission loader. Use it at your own risk!"); - ImGui::Spacing(); - if (ImGui::Button("Show mission loader", ImVec2(Ui::GetSize()))) - { - bMissionLoaderWarningShown = true; - } - } - else - { - if (ImGui::Button("Fail current mission", ImVec2(Ui::GetSize()))) - { - if (!Util::IsOnCutscene()) - { - Command(); - } - } + ImGui::Spacing(); + if (ImGui::Button("Show mission loader", ImVec2(Ui::GetSize()))) + { + bMissionLoaderWarningShown = true; + } + } + else + { + if (ImGui::Button("Fail current mission", ImVec2(Ui::GetSize()))) + { + if (!Util::IsOnCutscene()) + { + Command(); + } + } - ImGui::Spacing(); + ImGui::Spacing(); - Ui::DrawJSON(m_MissionData, SetPlayerMission, nullptr); - } - ImGui::EndTabItem(); - } + Ui::DrawJSON(m_MissionData, SetPlayerMission, nullptr); + } + ImGui::EndTabItem(); + } #ifdef GTASA - if (ImGui::BeginTabItem("Stats")) - { - // similar to Ui::DrawJSON() - ImGui::Spacing(); + if (ImGui::BeginTabItem("Stats")) + { + // similar to Ui::DrawJSON() + ImGui::Spacing(); - ImGui::PushItemWidth(ImGui::GetContentRegionAvailWidth() / 2 - 5); - Ui::ListBoxStr("##Categories", m_StatData.m_Categories, m_StatData.m_Selected); - ImGui::SameLine(); - Ui::FilterWithHint("##Filter", m_StatData.m_Filter, "Search"); - ImGui::PopItemWidth(); + ImGui::PushItemWidth(ImGui::GetContentRegionAvailWidth() / 2 - 5); + Ui::ListBoxStr("##Categories", m_StatData.m_Categories, m_StatData.m_Selected); + ImGui::SameLine(); + Ui::FilterWithHint("##Filter", m_StatData.m_Filter, "Search"); + ImGui::PopItemWidth(); - ImGui::Spacing(); + ImGui::Spacing(); - ImGui::BeginChild("STATCHILD"); - for (auto root : m_StatData.m_pJson->m_Data.items()) - { - if (root.key() == m_StatData.m_Selected || m_StatData.m_Selected == "All") - { - for (auto _data : root.value().items()) - { - std::string name = _data.value().get(); - if (m_StatData.m_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::Columns(2, NULL, false); - ImGui::Checkbox("Enable", &m_RandomCheats::m_bEnabled); - ImGui::NextColumn(); - ImGui::Checkbox("Progress bar", &m_RandomCheats::m_bProgressBar); - ImGui::Columns(1); - ImGui::Spacing(); + ImGui::BeginChild("STATCHILD"); + for (auto root : m_StatData.m_pJson->m_Data.items()) + { + if (root.key() == m_StatData.m_Selected || m_StatData.m_Selected == "All") + { + for (auto _data : root.value().items()) + { + std::string name = _data.value().get(); + if (m_StatData.m_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::Columns(2, NULL, false); + ImGui::Checkbox("Enable", &m_RandomCheats::m_bEnabled); + ImGui::NextColumn(); + ImGui::Checkbox("Progress bar", &m_RandomCheats::m_bProgressBar); + ImGui::Columns(1); + ImGui::Spacing(); - ImGui::PushItemWidth(ImGui::GetWindowContentRegionWidth() / 2); + ImGui::PushItemWidth(ImGui::GetWindowContentRegionWidth() / 2); - ImGui::SliderInt("Activate cheat timer", &m_RandomCheats::m_nInterval, 5, 60); - Ui::ShowTooltip("Time for the next cheat activation."); + ImGui::SliderInt("Activate cheat timer", &m_RandomCheats::m_nInterval, 5, 60); + Ui::ShowTooltip("Time for the next cheat activation."); - ImGui::PopItemWidth(); + ImGui::PopItemWidth(); - ImGui::TextWrapped("Select cheats"); - ImGui::Separator(); - if (ImGui::BeginChild("Cheats list")) - { - for (std::string *element : m_RandomCheats::m_EnabledCheats) - { - bool selected = (element[1] == "true") ? true : false; + ImGui::TextWrapped("Select cheats"); + ImGui::Separator(); + if (ImGui::BeginChild("Cheats list")) + { + for (std::string* element : m_RandomCheats::m_EnabledCheats) + { + bool selected = (element[1] == "true") ? true : false; - if (ImGui::MenuItem(element[0].c_str(), nullptr, selected)) - { - element[1] = selected ? "false" : "true"; - } - } - ImGui::EndChild(); - } - ImGui::EndTabItem(); - } + if (ImGui::MenuItem(element[0].c_str(), nullptr, selected)) + { + element[1] = selected ? "false" : "true"; + } + } + ImGui::EndChild(); + } + ImGui::EndTabItem(); + } #endif - ImGui::EndTabBar(); - } + ImGui::EndTabBar(); + } } diff --git a/src/game.h b/src/game.h index e164ddd..7b5b710 100644 --- a/src/game.h +++ b/src/game.h @@ -3,63 +3,65 @@ class Game { public: - static inline ResourceStore m_MissionData{"mission", eResourceType::TYPE_TEXT}; + static inline ResourceStore m_MissionData{ "mission", eResourceType::TYPE_TEXT }; - static inline bool m_bDisableCheats; - static inline bool m_bDisableReplay; - static inline bool m_bMissionTimer; - static inline bool m_bFreezeTime; - static inline bool m_bSyncTime; + static inline bool m_bDisableCheats; + static inline bool m_bDisableReplay; + static inline bool m_bMissionTimer; + static inline bool m_bFreezeTime; + static inline bool m_bSyncTime; #ifdef GTASA - static inline bool m_bForbiddenArea = true; // wanted level when going outside playable aea - static inline bool m_bSolidWater; // walk on water hack - static inline bool m_bScreenShot; - static inline bool m_bKeepStuff; - static inline ResourceStore m_StatData{"stat", eResourceType::TYPE_TEXT}; - - static inline std::vector m_DayNames = {"Sunday", "Monday", "Tuesday", "Wednesday", - "Thursday", "Friday", "Saturday"}; - - struct m_RandomCheats - { - static inline bool m_bEnabled; - static inline bool m_bProgressBar = true; - static inline std::string m_EnabledCheats[92][2]; - static inline int m_nInterval = 10; - static inline CJson m_Json = CJson("cheat name"); - static inline uint m_nTimer; - }; - struct m_Freecam - { - static inline bool m_bEnabled; - static inline int m_nMul = 1; - static inline float m_fFOV = 60.0f; - static inline bool m_bInitDone; - static inline CPed *m_pPed; - static inline int m_nPed = -1; - static inline CVector m_fMouse; - static inline CVector m_fTotalMouse; - static inline BYTE m_bHudState; - static inline BYTE m_bRadarState; - }; - struct m_HardMode - { - static inline bool m_bEnabled; - static inline float m_fBacHealth = 0.0f; - static inline float m_fBacMaxHealth = 0.0f; - static inline float m_fBacArmour = 0.0f; - static inline float m_fBacStamina = 0.0f; - }; + static inline bool m_bForbiddenArea = true; // wanted level when going outside playable aea + static inline bool m_bSolidWater; // walk on water hack + static inline bool m_bScreenShot; + static inline bool m_bKeepStuff; + static inline ResourceStore m_StatData{ "stat", eResourceType::TYPE_TEXT }; + + static inline std::vector m_DayNames = + { + "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" + }; + struct m_RandomCheats + { + static inline bool m_bEnabled; + static inline bool m_bProgressBar = true; + static inline std::string m_EnabledCheats[92][2]; + static inline int m_nInterval = 10; + static inline CJson m_Json = CJson("cheat name"); + static inline uint m_nTimer; + }; + struct m_Freecam + { + static inline bool m_bEnabled; + static inline int m_nMul = 1; + static inline float m_fFOV = 60.0f; + static inline bool m_bInitDone; + static inline CPed* m_pPed; + static inline int m_nPed = -1; + static inline CVector m_fMouse; + static inline CVector m_fTotalMouse; + static inline BYTE m_bHudState; + static inline BYTE m_bRadarState; + }; + struct m_HardMode + { + static inline bool m_bEnabled; + static inline float m_fBacHealth = 0.0f; + static inline float m_fBacMaxHealth = 0.0f; + static inline float m_fBacArmour = 0.0f; + static inline float m_fBacStamina = 0.0f; + }; + #endif - Game(); - static void Draw(); - static void RealTimeClock(); + Game(); + static void Draw(); + static void RealTimeClock(); #ifdef GTASA - // TODO: Update freecam with aap's code - static void FreeCam(); - static void ClearFreecamStuff(); + // TODO: Update freecam with aap's code + static void FreeCam(); + static void ClearFreecamStuff(); #endif }; diff --git a/src/hook.cpp b/src/hook.cpp index be31f6f..9092bae 100644 --- a/src/hook.cpp +++ b/src/hook.cpp @@ -1,350 +1,350 @@ +#include "pch.h" #include "hook.h" -#include "../depend/imgui/imgui_impl_dx11.h" -#include "../depend/imgui/imgui_impl_dx9.h" -#include "../depend/imgui/imgui_impl_win32.h" #include "../depend/kiero/kiero.h" #include "../depend/kiero/minhook/MinHook.h" -#include "pch.h" +#include "../depend/imgui/imgui_impl_dx9.h" +#include "../depend/imgui/imgui_impl_dx11.h" +#include "../depend/imgui/imgui_impl_win32.h" #include #define DIMOUSE ((LPDIRECTINPUTDEVICE8)(RsGlobal.ps->diMouse)) LRESULT Hook::WndProc(const HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { - ImGui_ImplWin32_WndProcHandler(hWnd, uMsg, wParam, lParam); + ImGui_ImplWin32_WndProcHandler(hWnd, uMsg, wParam, lParam); - if (ImGui::GetIO().WantTextInput) - { + if (ImGui::GetIO().WantTextInput) + { #ifdef GTASA - Call<0x53F1E0>(); // CPad::ClearKeyboardHistory + Call<0x53F1E0>(); // CPad::ClearKeyboardHistory #endif - return 1; - } + return 1; + } - return CallWindowProc(oWndProc, hWnd, uMsg, wParam, lParam); + return CallWindowProc(oWndProc, hWnd, uMsg, wParam, lParam); } -HRESULT Hook::Reset(IDirect3DDevice9 *pDevice, D3DPRESENT_PARAMETERS *pPresentationParameters) +HRESULT Hook::Reset(IDirect3DDevice9* pDevice, D3DPRESENT_PARAMETERS* pPresentationParameters) { - ImGui_ImplDX9_InvalidateDeviceObjects(); + ImGui_ImplDX9_InvalidateDeviceObjects(); - return oReset(pDevice, pPresentationParameters); + return oReset(pDevice, pPresentationParameters); } -void Hook::RenderFrame(void *ptr) +void Hook::RenderFrame(void* ptr) { - if (!ImGui::GetCurrentContext()) - { - return; - } + if (!ImGui::GetCurrentContext()) + { + return; + } - ImGuiIO &io = ImGui::GetIO(); - static bool bInit = false; + ImGuiIO& io = ImGui::GetIO(); + static bool bInit = false; - if (bInit) - { - ShowMouse(m_bShowMouse); + if (bInit) + { + ShowMouse(m_bShowMouse); - // handle window scaling here - static ImVec2 fScreenSize = ImVec2(-1, -1); - ImVec2 size(screen::GetScreenWidth(), screen::GetScreenHeight()); - if (fScreenSize.x != size.x && fScreenSize.y != size.y) - { - int fontSize = static_cast(size.y / 54.85f); // manually tested + // handle window scaling here + static ImVec2 fScreenSize = ImVec2(-1, -1); + ImVec2 size(screen::GetScreenWidth(), screen::GetScreenHeight()); + if (fScreenSize.x != size.x && fScreenSize.y != size.y) + { + int fontSize = static_cast(size.y / 54.85f); // manually tested - io.FontDefault = io.Fonts->AddFontFromFileTTF("C:/Windows/Fonts/trebucbd.ttf", fontSize); - io.Fonts->Build(); + io.FontDefault = io.Fonts->AddFontFromFileTTF("C:/Windows/Fonts/trebucbd.ttf", fontSize); + io.Fonts->Build(); - if (gRenderer == Render_DirectX9) - { - ImGui_ImplDX9_InvalidateDeviceObjects(); - } - else - { - ImGui_ImplDX11_InvalidateDeviceObjects(); - } + if (gRenderer == Render_DirectX9) + { + ImGui_ImplDX9_InvalidateDeviceObjects(); + } + else + { + ImGui_ImplDX11_InvalidateDeviceObjects(); + } - ImGuiStyle *style = &ImGui::GetStyle(); - float scaleX = size.x / 1366.0f; - float scaleY = size.y / 768.0f; + ImGuiStyle* style = &ImGui::GetStyle(); + float scaleX = size.x / 1366.0f; + float scaleY = size.y / 768.0f; - style->FramePadding = ImVec2(5 * scaleX, 3 * scaleY); - style->ItemSpacing = ImVec2(8 * scaleX, 4 * scaleY); - style->ScrollbarSize = 12 * scaleX; - style->IndentSpacing = 20 * scaleX; - style->ItemInnerSpacing = ImVec2(4 * scaleX, 4 * scaleY); + style->FramePadding = ImVec2(5 * scaleX, 3 * scaleY); + style->ItemSpacing = ImVec2(8 * scaleX, 4 * scaleY); + style->ScrollbarSize = 12 * scaleX; + style->IndentSpacing = 20 * scaleX; + style->ItemInnerSpacing = ImVec2(4 * scaleX, 4 * scaleY); - fScreenSize = size; - } + fScreenSize = size; + } - ImGui_ImplWin32_NewFrame(); - if (gRenderer == Render_DirectX9) - { - ImGui_ImplDX9_NewFrame(); - } - else - { - ImGui_ImplDX11_NewFrame(); - } + ImGui_ImplWin32_NewFrame(); + if (gRenderer == Render_DirectX9) + { + ImGui_ImplDX9_NewFrame(); + } + else + { + ImGui_ImplDX11_NewFrame(); + } - ImGui::NewFrame(); + ImGui::NewFrame(); - if (windowCallback != nullptr) - { - windowCallback(); - } + if (windowCallback != nullptr) + { + windowCallback(); + } - ImGui::EndFrame(); - ImGui::Render(); + ImGui::EndFrame(); + ImGui::Render(); - if (gRenderer == Render_DirectX9) - { - ImGui_ImplDX9_RenderDrawData(ImGui::GetDrawData()); - } - else - { - ImGui_ImplDX11_RenderDrawData(ImGui::GetDrawData()); - } - } - else - { - bInit = true; - ImGuiStyle &style = ImGui::GetStyle(); - ImGui_ImplWin32_Init(RsGlobal.ps->window); + if (gRenderer == Render_DirectX9) + { + ImGui_ImplDX9_RenderDrawData(ImGui::GetDrawData()); + } + else + { + ImGui_ImplDX11_RenderDrawData(ImGui::GetDrawData()); + } + } + else + { + bInit = true; + ImGuiStyle& style = ImGui::GetStyle(); + ImGui_ImplWin32_Init(RsGlobal.ps->window); #ifdef GTASA - // shift trigger fix - patch::Nop(0x00531155, 5); + // shift trigger fix + patch::Nop(0x00531155, 5); #endif - if (gRenderer == Render_DirectX9) - { - ImGui_ImplDX9_Init(reinterpret_cast(ptr)); - } - else - { - // for dx11 device ptr is swapchain - reinterpret_cast(ptr)->GetDevice(__uuidof(ID3D11Device), &ptr); - ID3D11DeviceContext *context; - reinterpret_cast(ptr)->GetImmediateContext(&context); + if (gRenderer == Render_DirectX9) + { + ImGui_ImplDX9_Init(reinterpret_cast(ptr)); + } + else + { + // for dx11 device ptr is swapchain + reinterpret_cast(ptr)->GetDevice(__uuidof(ID3D11Device), &ptr); + ID3D11DeviceContext* context; + reinterpret_cast(ptr)->GetImmediateContext(&context); - ImGui_ImplDX11_Init(reinterpret_cast(ptr), context); - } + ImGui_ImplDX11_Init(reinterpret_cast(ptr), context); + } - ImGui_ImplWin32_EnableDpiAwareness(); + ImGui_ImplWin32_EnableDpiAwareness(); - io.IniFilename = nullptr; - io.LogFilename = nullptr; - io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; + io.IniFilename = nullptr; + io.LogFilename = nullptr; + io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; - style.WindowTitleAlign = ImVec2(0.5, 0.5); - oWndProc = (WNDPROC)SetWindowLongPtr(RsGlobal.ps->window, GWL_WNDPROC, (LRESULT)WndProc); - } + style.WindowTitleAlign = ImVec2(0.5, 0.5); + oWndProc = (WNDPROC)SetWindowLongPtr(RsGlobal.ps->window, GWL_WNDPROC, (LRESULT)WndProc); + } } -HRESULT Hook::Dx9Handler(IDirect3DDevice9 *pDevice) +HRESULT Hook::Dx9Handler(IDirect3DDevice9* pDevice) { - RenderFrame(pDevice); - return oEndScene(pDevice); + RenderFrame(pDevice); + return oEndScene(pDevice); } -HRESULT Hook::Dx11Handler(IDXGISwapChain *pSwapChain, UINT SyncInterval, UINT Flags) +HRESULT Hook::Dx11Handler(IDXGISwapChain* pSwapChain, UINT SyncInterval, UINT Flags) { - RenderFrame(pSwapChain); - return oPresent11(pSwapChain, SyncInterval, Flags); + RenderFrame(pSwapChain); + return oPresent11(pSwapChain, SyncInterval, Flags); } void Hook::ShowMouse(bool state) { - // Disable player controls for controllers - bool bMouseDisabled = false; - bool isController; + // Disable player controls for controllers + bool bMouseDisabled = false; + bool isController; #ifdef GTA3 - isController = !patch::Get(0x5F03D8); + isController = !patch::Get(0x5F03D8); #elif GTAVC - isController = patch::Get(0x86968B); + isController = patch::Get(0x86968B); #else // GTASA - isController = patch::Get(0xBA6818); + isController = patch::Get(0xBA6818); #endif - if (isController && (m_bShowMouse || bMouseDisabled)) - { + + if (isController && (m_bShowMouse || bMouseDisabled)) + { #ifdef GTASA - CPlayerPed *player = FindPlayerPed(); - CPad *pad = player ? player->GetPadFromPlayer() : NULL; + CPlayerPed *player = FindPlayerPed(); + CPad *pad = player ? player->GetPadFromPlayer() : NULL; #else - CPad *pad = CPad::GetPad(0); + CPad *pad = CPad::GetPad(0); #endif - if (pad) - { - if (m_bShowMouse) - { - bMouseDisabled = true; + if (pad) + { + if (m_bShowMouse) + { + bMouseDisabled = true; #ifdef GTA3 - pad->m_bDisablePlayerControls = true; -#else // GTAVC & GTASA - pad->DisablePlayerControls = true; + pad->m_bDisablePlayerControls = true; +#else //GTAVC & GTASA + pad->DisablePlayerControls = true; #endif - } - else - { - bMouseDisabled = false; + } + else + { + bMouseDisabled = false; #ifdef GTA3 - pad->m_bDisablePlayerControls = false; -#else // GTAVC & GTASA - pad->DisablePlayerControls = false; + pad->m_bDisablePlayerControls = false; +#else //GTAVC & GTASA + pad->DisablePlayerControls = false; #endif - } - } - } + } + } + } - if (m_bMouseVisibility != m_bShowMouse) - { - ImGui::GetIO().MouseDrawCursor = state; + if (m_bMouseVisibility != m_bShowMouse) + { + ImGui::GetIO().MouseDrawCursor = state; #ifdef GTASA - Hook::ApplyMouseFix(); // Reapply the patches + Hook::ApplyMouseFix(); // Reapply the patches #else - if (m_bShowMouse) - { - - patch::SetUChar(BY_GAME(0, 0x6020A0, 0x580D20), 0xC3); // psSetMousePos - patch::Nop(BY_GAME(0, 0x4AB6CA, 0x49272F), 5); // don't call CPad::UpdateMouse() - } - else - { - - patch::SetUChar(BY_GAME(0, 0x6020A0, 0x580D20), 0x53); + if (m_bShowMouse) + { + + patch::SetUChar(BY_GAME(0, 0x6020A0, 0x580D20), 0xC3); // psSetMousePos + patch::Nop(BY_GAME(0, 0x4AB6CA, 0x49272F), 5); // don't call CPad::UpdateMouse() + } + else + { + + patch::SetUChar(BY_GAME(0, 0x6020A0, 0x580D20), 0x53); #ifdef GTAVC - patch::SetRaw(0x4AB6CA, (char *)"\xE8\x51\x21\x00\x00", 5); + patch::SetRaw(0x4AB6CA, (char*)"\xE8\x51\x21\x00\x00", 5); #else // GTA3 - patch::SetRaw(0x49272F, (char *)"\xE8\x6C\xF5\xFF\xFF", 5); + patch::SetRaw(0x49272F, (char*)"\xE8\x6C\xF5\xFF\xFF", 5); #endif - } + } #endif - CPad::NewMouseControllerState.X = 0; - CPad::NewMouseControllerState.Y = 0; + CPad::NewMouseControllerState.X = 0; + CPad::NewMouseControllerState.Y = 0; #ifdef GTA3 - CPad::GetPad(0)->ClearMouseHistory(); + CPad::GetPad(0)->ClearMouseHistory(); #else // GTAVC & GTASA - CPad::ClearMouseHistory(); + CPad::ClearMouseHistory(); #endif - CPad::UpdatePads(); - m_bMouseVisibility = m_bShowMouse; - } + CPad::UpdatePads(); + m_bMouseVisibility = m_bShowMouse; + } } Hook::Hook() { - ImGui::CreateContext(); + ImGui::CreateContext(); - // Nvidia Overlay crash fix - if (init(kiero::RenderType::D3D9) == kiero::Status::Success) - { - gRenderer = Render_DirectX9; - kiero::bind(16, (void **)&oReset, Reset); - kiero::bind(42, (void **)&oEndScene, Dx9Handler); - } - else - { - // gtaRenderHook - if (init(kiero::RenderType::D3D11) == kiero::Status::Success) - { - gRenderer = Render_DirectX11; - kiero::bind(8, (void **)&oPresent11, Dx11Handler); - } - } + // Nvidia Overlay crash fix + if (init(kiero::RenderType::D3D9) == kiero::Status::Success) + { + gRenderer = Render_DirectX9; + kiero::bind(16, (void**)&oReset, Reset); + kiero::bind(42, (void**)&oEndScene, Dx9Handler); + } + else + { + // gtaRenderHook + if (init(kiero::RenderType::D3D11) == kiero::Status::Success) + { + gRenderer = Render_DirectX11; + kiero::bind(8, (void**)&oPresent11, Dx11Handler); + } + } } Hook::~Hook() { - SetWindowLongPtr(RsGlobal.ps->window, GWL_WNDPROC, (LRESULT)oWndProc); - ImGui_ImplDX9_Shutdown(); - ImGui_ImplWin32_Shutdown(); - ImGui::DestroyContext(); - kiero::shutdown(); + SetWindowLongPtr(RsGlobal.ps->window, GWL_WNDPROC, (LRESULT)oWndProc); + ImGui_ImplDX9_Shutdown(); + ImGui_ImplWin32_Shutdown(); + ImGui::DestroyContext(); + kiero::shutdown(); } #ifdef GTASA struct Mouse { - unsigned int x, y; - unsigned int wheelDelta; - unsigned char buttons[8]; + unsigned int x, y; + unsigned int wheelDelta; + unsigned char buttons[8]; }; struct MouseInfo { - int x, y, wheelDelta; + int x, y, wheelDelta; } mouseInfo; static BOOL __stdcall _SetCursorPos(int X, int Y) { - if (Hook::m_bShowMouse || GetActiveWindow() != RsGlobal.ps->window) - { - return 1; - } + if (Hook::m_bShowMouse || GetActiveWindow() != RsGlobal.ps->window) + { + return 1; + } - mouseInfo.x = X; - mouseInfo.y = Y; + mouseInfo.x = X; + mouseInfo.y = Y; - return SetCursorPos(X, Y); + return SetCursorPos(X, Y); } -static LRESULT __stdcall _DispatchMessage(MSG *lpMsg) +static LRESULT __stdcall _DispatchMessage(MSG* lpMsg) { - if (lpMsg->message == WM_MOUSEWHEEL && !Hook::m_bShowMouse) - { - mouseInfo.wheelDelta += GET_WHEEL_DELTA_WPARAM(lpMsg->wParam); - } + if (lpMsg->message == WM_MOUSEWHEEL && !Hook::m_bShowMouse) + { + mouseInfo.wheelDelta += GET_WHEEL_DELTA_WPARAM(lpMsg->wParam); + } - return DispatchMessageA(lpMsg); + return DispatchMessageA(lpMsg); } -static int _cdecl _GetMouseState(Mouse *pMouse) +static int _cdecl _GetMouseState(Mouse* pMouse) { - if (Hook::m_bShowMouse || !RsGlobal.ps->diMouse) - { - DIMOUSE->Unacquire(); - return -1; - } + if (Hook::m_bShowMouse || !RsGlobal.ps->diMouse) + { + DIMOUSE->Unacquire(); + return -1; + } + + if (DIMOUSE->GetDeviceState(sizeof(Mouse), pMouse) < 0) + { + if (DIMOUSE->Acquire() == DIERR_NOTINITIALIZED) + { + while (DIMOUSE->Acquire() == DIERR_NOTINITIALIZED); + } + } - if (DIMOUSE->GetDeviceState(sizeof(Mouse), pMouse) < 0) - { - if (DIMOUSE->Acquire() == DIERR_NOTINITIALIZED) - { - while (DIMOUSE->Acquire() == DIERR_NOTINITIALIZED) - ; - } - } - - pMouse->wheelDelta = mouseInfo.wheelDelta; - mouseInfo.wheelDelta = 0; - pMouse->buttons[0] = (GetAsyncKeyState(1) >> 8); - pMouse->buttons[1] = (GetAsyncKeyState(2) >> 8); - pMouse->buttons[2] = (GetAsyncKeyState(4) >> 8); - pMouse->buttons[3] = (GetAsyncKeyState(5) >> 8); - pMouse->buttons[4] = (GetAsyncKeyState(6) >> 8); - - return 0; + pMouse->wheelDelta = mouseInfo.wheelDelta; + mouseInfo.wheelDelta = 0; + pMouse->buttons[0] = (GetAsyncKeyState(1) >> 8); + pMouse->buttons[1] = (GetAsyncKeyState(2) >> 8); + pMouse->buttons[2] = (GetAsyncKeyState(4) >> 8); + pMouse->buttons[3] = (GetAsyncKeyState(5) >> 8); + pMouse->buttons[4] = (GetAsyncKeyState(6) >> 8); + + return 0; } void Hook::ApplyMouseFix() { - patch::ReplaceFunctionCall(0x53F417, _GetMouseState); - patch::Nop(0x57C59B, 1); - patch::ReplaceFunctionCall(0x57C59C, _SetCursorPos); - patch::Nop(0x81E5D4, 1); - patch::ReplaceFunctionCall(0x81E5D5, _SetCursorPos); - patch::Nop(0x74542D, 1); - patch::ReplaceFunctionCall(0x74542E, _SetCursorPos); - patch::Nop(0x748A7C, 1); - patch::ReplaceFunctionCall(0x748A7D, _DispatchMessage); - patch::SetChar(0x746A08, 32); // diMouseOffset - patch::SetChar(0x746A58, 32); // diDeviceoffset + patch::ReplaceFunctionCall(0x53F417, _GetMouseState); + patch::Nop(0x57C59B, 1); + patch::ReplaceFunctionCall(0x57C59C, _SetCursorPos); + patch::Nop(0x81E5D4, 1); + patch::ReplaceFunctionCall(0x81E5D5, _SetCursorPos); + patch::Nop(0x74542D, 1); + patch::ReplaceFunctionCall(0x74542E, _SetCursorPos); + patch::Nop(0x748A7C, 1); + patch::ReplaceFunctionCall(0x748A7D, _DispatchMessage); + patch::SetChar(0x746A08, 32); // diMouseOffset + patch::SetChar(0x746A58, 32); // diDeviceoffset } #endif \ No newline at end of file diff --git a/src/hook.h b/src/hook.h index 7bb9abd..128e0b8 100644 --- a/src/hook.h +++ b/src/hook.h @@ -1,36 +1,36 @@ #pragma once #include "pch.h" -using f_EndScene = HRESULT(CALLBACK *)(IDirect3DDevice9 *); -using f_Present11 = HRESULT(CALLBACK *)(IDXGISwapChain *, UINT, UINT); -using f_Reset = HRESULT(CALLBACK *)(IDirect3DDevice9 *, D3DPRESENT_PARAMETERS *); +using f_EndScene = HRESULT(CALLBACK*)(IDirect3DDevice9*); +using f_Present11 = HRESULT(CALLBACK*)(IDXGISwapChain*, UINT, UINT); +using f_Reset = HRESULT(CALLBACK*)(IDirect3DDevice9*, D3DPRESENT_PARAMETERS*); extern IMGUI_IMPL_API LRESULT ImGui_ImplWin32_WndProcHandler(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam); class Hook { private: - static inline WNDPROC oWndProc; - static inline f_Present11 oPresent11; - static inline f_EndScene oEndScene; - static inline f_Reset oReset; - static inline bool m_bMouseVisibility; + static inline WNDPROC oWndProc; + static inline f_Present11 oPresent11; + static inline f_EndScene oEndScene; + static inline f_Reset oReset; + static inline bool m_bMouseVisibility; - static void CALLBACK RenderFrame(void *ptr); - static HRESULT CALLBACK Dx9Handler(IDirect3DDevice9 *pDevice); - static HRESULT CALLBACK Dx11Handler(IDXGISwapChain *pSwapChain, UINT SyncInterval, UINT Flags); - static HRESULT CALLBACK Reset(IDirect3DDevice9 *pDevice, D3DPRESENT_PARAMETERS *pPresentationParameters); - static LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam); - static void ShowMouse(bool state); + static void CALLBACK RenderFrame(void* ptr); + static HRESULT CALLBACK Dx9Handler(IDirect3DDevice9* pDevice); + static HRESULT CALLBACK Dx11Handler(IDXGISwapChain* pSwapChain, UINT SyncInterval, UINT Flags); + static HRESULT CALLBACK Reset(IDirect3DDevice9* pDevice, D3DPRESENT_PARAMETERS* pPresentationParameters); + static LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam); + static void ShowMouse(bool state); public: - static inline bool m_bShowMouse = false; - static inline std::function windowCallback = nullptr; + static inline bool m_bShowMouse = false; + static inline std::function windowCallback = nullptr; #ifdef GTASA - static void ApplyMouseFix(); + static void ApplyMouseFix(); #endif - Hook(); - ~Hook(); + Hook(); + ~Hook(); }; diff --git a/src/hotkeys.cpp b/src/hotkeys.cpp index c914dab..14c9c71 100644 --- a/src/hotkeys.cpp +++ b/src/hotkeys.cpp @@ -1,5 +1,5 @@ -#include "hotkeys.h" #include "pch.h" +#include "hotkeys.h" Hotkey aimSkinChanger; Hotkey freeCam; @@ -15,124 +15,124 @@ Hotkey vehEngine; Hotkey vehInstantStart; Hotkey vehInstantStop; -bool Hotkey::DrawUI(const char *label) +bool Hotkey::DrawUI(const char* label) { - bool active = m_CurrentHotkey == label; - bool state = false; + bool active = m_CurrentHotkey == label; + bool state = false; - if (active) - { - ImGui::PushStyleColor(ImGuiCol_Button, ImGui::GetStyle().Colors[ImGuiCol_ButtonActive]); - ImGui::PushStyleColor(ImGuiCol_ButtonHovered, ImGui::GetStyle().Colors[ImGuiCol_ButtonActive]); + if (active) + { + ImGui::PushStyleColor(ImGuiCol_Button, ImGui::GetStyle().Colors[ImGuiCol_ButtonActive]); + ImGui::PushStyleColor(ImGuiCol_ButtonHovered, ImGui::GetStyle().Colors[ImGuiCol_ButtonActive]); - for (int key = 3; key != 135; ++key) - { - if (KeyPressed(key)) - { - m_key1 = key; - break; - } - } + for (int key = 3; key != 135; ++key) + { + if (KeyPressed(key)) + { + m_key1 = key; + break; + } + } - for (int key = 135; key != 3; --key) - { - if (KeyPressed(key)) - { - m_key2 = key; - break; - } - } - } + for (int key = 135; key != 3; --key) + { + if (KeyPressed(key)) + { + m_key2 = key; + break; + } + } + } - std::string text; + std::string text; - if (m_key1 != VK_NONE) - { - text = key_names[m_key1 - 1]; - } - else - { - text = "None"; - } + if (m_key1 != VK_NONE) + { + text = key_names[m_key1 - 1]; + } + else + { + text = "None"; + } - if (m_key1 != m_key2) - { - text += (" + " + key_names[m_key2 - 1]); - } + if (m_key1 != m_key2) + { + text += (" + " + key_names[m_key2 - 1]); + } - if (ImGui::Button((text + std::string("##") + std::string(label)).c_str(), - ImVec2(ImGui::GetWindowContentRegionWidth() / 3.5, ImGui::GetFrameHeight()))) - { - if (!active) - { - m_CurrentHotkey = label; - } - } + if (ImGui::Button((text + std::string("##") + std::string(label)).c_str(), + ImVec2(ImGui::GetWindowContentRegionWidth() / 3.5, ImGui::GetFrameHeight()))) + { + if (!active) + { + m_CurrentHotkey = label; + } + } - if (active && ImGui::IsMouseClicked(ImGuiMouseButton_Left)) - { - m_CurrentHotkey = ""; - state = true; - } + if (active && ImGui::IsMouseClicked(ImGuiMouseButton_Left)) + { + m_CurrentHotkey = ""; + state = true; + } - if (ImGui::IsMouseClicked(ImGuiMouseButton_Right)) - { - if (ImGui::IsItemHovered()) - { - m_key1 = VK_NONE; - m_key2 = VK_NONE; - } - else - { - m_CurrentHotkey = ""; - } + if (ImGui::IsMouseClicked(ImGuiMouseButton_Right)) + { + if (ImGui::IsItemHovered()) + { + m_key1 = VK_NONE; + m_key2 = VK_NONE; + } + else + { + m_CurrentHotkey = ""; + } - state = true; - } + state = true; + } - ImGui::SameLine(); - ImGui::Text(label); + ImGui::SameLine(); + ImGui::Text(label); - if (active) - { - ImGui::PopStyleColor(2); - } + if (active) + { + ImGui::PopStyleColor(2); + } - return state; + return state; } bool Hotkey::Pressed() { - if (KeyPressed(m_key1) && KeyPressed(m_key2)) - m_bPressed = true; - else - { - if (m_bPressed) - { - m_bPressed = false; - return m_CurrentHotkey == ""; - } - } - return false; + if (KeyPressed(m_key1) && KeyPressed(m_key2)) + m_bPressed = true; + else + { + if (m_bPressed) + { + m_bPressed = false; + return m_CurrentHotkey == ""; + } + } + return false; } std::string Hotkey::GetNameString() { - std::string text; + std::string text; - if (m_key1 != VK_NONE) - { - text = key_names[m_key1 - 1]; - } - else - { - text = "None"; - } + if (m_key1 != VK_NONE) + { + text = key_names[m_key1 - 1]; + } + else + { + text = "None"; + } - if (m_key1 != m_key2) - { - text += (" + " + key_names[m_key2 - 1]); - } + if (m_key1 != m_key2) + { + text += (" + " + key_names[m_key2 - 1]); + } - return text; + return text; } \ No newline at end of file diff --git a/src/hotkeys.h b/src/hotkeys.h index 8b290b5..1797765 100644 --- a/src/hotkeys.h +++ b/src/hotkeys.h @@ -10,13 +10,13 @@ private: public: int m_key1; int m_key2; - - Hotkey(int key1 = -1, int key2 = -1) : m_key1(key1), m_key2(key2) - { - } + + Hotkey(int key1 = -1, int key2 = -1) + : m_key1(key1), m_key2(key2) + {} // Draws ui to change the hotkeys from frontend - bool DrawUI(const char *label); + bool DrawUI(const char* label); bool Pressed(); std::string GetNameString(); }; diff --git a/src/json.cpp b/src/json.cpp index af3351f..6a6e5f9 100644 --- a/src/json.cpp +++ b/src/json.cpp @@ -1,47 +1,47 @@ -#include "json.h" #include "pch.h" +#include "json.h" -CJson::CJson(const char *name) +CJson::CJson(const char* name) { - if (name == "" || !std::filesystem::is_directory(PLUGIN_PATH((char *)"CheatMenu"))) - { - return; - } + if (name == "" || !std::filesystem::is_directory(PLUGIN_PATH((char*)"CheatMenu"))) + { + return; + } - m_FilePath = PLUGIN_PATH((char *)"/CheatMenu/json/") + std::string(name) + ".json"; + m_FilePath = PLUGIN_PATH((char*)"/CheatMenu/json/") + std::string(name) + ".json"; - if (std::filesystem::exists(m_FilePath)) - { - try - { - std::ifstream file(m_FilePath); - file >> m_Data; - file.close(); - } - catch (...) - { - gLog << "Error trying to read " << m_FilePath << std::endl; - m_Data = "{}"_json; - } - } - else - { - m_Data = "{}"_json; + if (std::filesystem::exists(m_FilePath)) + { + try + { + std::ifstream file(m_FilePath); + file >> m_Data; + file.close(); + } + catch (...) + { + gLog << "Error trying to read " << m_FilePath << std::endl; + m_Data = "{}"_json; + } + } + else + { + m_Data = "{}"_json; - if (m_FilePath.find("config")) - { - gLog << "Creating config.json file" << std::endl; - } - else - { - gLog << "Failed to locate file " << m_FilePath << std::endl; - } - } + if (m_FilePath.find("config")) + { + gLog << "Creating config.json file" << std::endl; + } + else + { + gLog << "Failed to locate file " << m_FilePath << std::endl; + } + } } void CJson::WriteToDisk() { - std::ofstream file(m_FilePath); - file << m_Data.dump(4, ' ', false, nlohmann::json::error_handler_t::replace) << std::endl; - file.close(); + std::ofstream file(m_FilePath); + file << m_Data.dump(4, ' ', false, nlohmann::json::error_handler_t::replace) << std::endl; + file.close(); } diff --git a/src/json.h b/src/json.h index 94b5a03..579f10a 100644 --- a/src/json.h +++ b/src/json.h @@ -2,117 +2,122 @@ #include "../depend/json.hpp" /* - Wrapper class for nlohmann::json - Contains helper methods + Wrapper class for nlohmann::json + Contains helper methods */ class CJson { private: - std::string m_FilePath; + std::string m_FilePath; public: - nlohmann::json m_Data; + nlohmann::json m_Data; - /* - Returns a value from json structure hierarchy using '.' - Example: "Menu.Window.X" - */ - // specialize since typeid(std::string) doesn't work + /* + Returns a value from json structure hierarchy using '.' + Example: "Menu.Window.X" + */ + // specialize since typeid(std::string) doesn't work - template T GetValue(std::string &&key, T &&defaultVal) - { - try - { - std::stringstream ss(key); - std::string line; + template + T GetValue(std::string&& key, T&& defaultVal) + { + try + { + std::stringstream ss(key); + std::string line; - nlohmann::json *json = &m_Data; + nlohmann::json* json = &m_Data; - while (getline(ss, line, '.')) - { - json = &((*json)[line]); - } + while (getline(ss, line, '.')) + { + json = &((*json)[line]); + } - // json library bugs with bool, using int instead - if (typeid(T) == typeid(bool)) - { - return ((json->get() == 1) ? true : false); - } - return json->get(); - } - catch (...) - { - return defaultVal; - } - } + // json library bugs with bool, using int instead + if (typeid(T) == typeid(bool)) + { + return ((json->get() == 1) ? true : false); + } + return json->get(); + } + catch (...) + { + return defaultVal; + } + } - template <> std::string GetValue(std::string &&key, std::string &&defaultVal) - { - try - { - std::stringstream ss(key); - std::string line; + template <> + std::string GetValue(std::string&& key, std::string&& defaultVal) + { + try + { + std::stringstream ss(key); + std::string line; - nlohmann::json *json = &m_Data; + nlohmann::json* json = &m_Data; - while (getline(ss, line, '.')) - { - json = &((*json)[line]); - } + while (getline(ss, line, '.')) + { + json = &((*json)[line]); + } - return json->get(); - } - catch (...) - { - return defaultVal; - } - } + return json->get(); + } + catch (...) + { + return defaultVal; + } + } - /* - Allows to save values in json hierarchy using '.' - Example: "Menu.Window.X" - */ - template void SetValue(std::string &&key, T &val) - { - std::stringstream ss(key); - std::string line; + /* + Allows to save values in json hierarchy using '.' + Example: "Menu.Window.X" + */ + template + void SetValue(std::string&& key, T& val) + { + std::stringstream ss(key); + std::string line; - nlohmann::json *json = &m_Data; + nlohmann::json* json = &m_Data; - while (getline(ss, line, '.')) - { - json = &((*json)[line]); - } + 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; - } - } + } - template <> void SetValue(std::string &&key, std::string &val) - { - std::stringstream ss(key); - std::string line; + // json library bugs with bool, using int instead + if (typeid(T) == typeid(bool)) + { + *json = (val ? 1 : 0); + } + else + { + *json = val; + } + } - nlohmann::json *json = &m_Data; + template <> + void SetValue(std::string&& key, std::string& val) + { + std::stringstream ss(key); + std::string line; - while (getline(ss, line, '.')) - { - json = &((*json)[line]); - } + nlohmann::json* json = &m_Data; - *json = val; - } + while (getline(ss, line, '.')) + { + json = &((*json)[line]); + } - /* - Saves json data to disk - */ - void WriteToDisk(); - CJson(const char *text = ""); + *json = val; + } + + /* + Saves json data to disk + */ + void WriteToDisk(); + CJson(const char* text = ""); }; diff --git a/src/menu.cpp b/src/menu.cpp index 62bf1ef..bbcc481 100644 --- a/src/menu.cpp +++ b/src/menu.cpp @@ -1,567 +1,563 @@ -#include "menu.h" -#include "menuinfo.h" #include "pch.h" +#include "menuinfo.h" +#include "menu.h" #include "ui.h" -#include "updater.h" #include "util.h" +#include "updater.h" #ifdef GTASA #include "teleport.h" -#include "vehicle.h" #include "weapon.h" - +#include "vehicle.h" #endif Menu::Menu() { - // TODO: use structs - // Load config data - m_Overlay::bCoord = gConfig.GetValue("overlay.coord", false); - m_Overlay::bCpuUsage = gConfig.GetValue("overlay.cpu_usage", false); - m_Overlay::bFPS = gConfig.GetValue("overlay.fps", false); - m_Overlay::bLocName = gConfig.GetValue("overlay.loc_name", false); - m_Overlay::bTransparent = gConfig.GetValue("overlay.transparent", false); - m_Overlay::bMemUsage = gConfig.GetValue("overlay.mem_usage", false); - m_Overlay::bVehHealth = gConfig.GetValue("overlay.veh_health", false); - m_Overlay::bVehSpeed = gConfig.GetValue("overlay.veh_speed", false); - m_Overlay::mSelectedPos = (DISPLAY_POS)gConfig.GetValue("overlay.selected_pos", (int)DISPLAY_POS::BOTTOM_RIGHT); - m_Overlay::fPosX = gConfig.GetValue("overlay.pox", 0); - m_Overlay::fPosY = gConfig.GetValue("overlay.posy", 0); + // TODO: use structs + // Load config data + m_Overlay::bCoord = gConfig.GetValue("overlay.coord", false); + m_Overlay::bCpuUsage = gConfig.GetValue("overlay.cpu_usage", false); + m_Overlay::bFPS = gConfig.GetValue("overlay.fps", false); + m_Overlay::bLocName = gConfig.GetValue("overlay.loc_name", false); + m_Overlay::bTransparent = gConfig.GetValue("overlay.transparent", false); + m_Overlay::bMemUsage = gConfig.GetValue("overlay.mem_usage", false); + m_Overlay::bVehHealth = gConfig.GetValue("overlay.veh_health", false); + m_Overlay::bVehSpeed = gConfig.GetValue("overlay.veh_speed", false); + m_Overlay::mSelectedPos = (DISPLAY_POS)gConfig.GetValue("overlay.selected_pos", (int)DISPLAY_POS::BOTTOM_RIGHT); + m_Overlay::fPosX = gConfig.GetValue("overlay.pox", 0); + m_Overlay::fPosY = gConfig.GetValue("overlay.posy", 0); - // Hotkeys - aimSkinChanger.m_key1 = gConfig.GetValue("hotkey.aim_skin_changer.key1", VK_RETURN); - aimSkinChanger.m_key2 = gConfig.GetValue("hotkey.aim_skin_changer.key2", VK_RETURN); + // Hotkeys + aimSkinChanger.m_key1 = gConfig.GetValue("hotkey.aim_skin_changer.key1", VK_RETURN); + aimSkinChanger.m_key2 = gConfig.GetValue("hotkey.aim_skin_changer.key2", VK_RETURN); - freeCam.m_key1 = gConfig.GetValue("hotkey.freecam.key1", VK_F6); - freeCam.m_key2 = gConfig.GetValue("hotkey.freecam.key2", VK_F6); + freeCam.m_key1 = gConfig.GetValue("hotkey.freecam.key1", VK_F6); + freeCam.m_key2 = gConfig.GetValue("hotkey.freecam.key2", VK_F6); - quickSceenShot.m_key1 = gConfig.GetValue("hotkey.quick_screenshot.key1", VK_F5); - quickSceenShot.m_key2 = gConfig.GetValue("hotkey.quick_screenshot.key2", VK_F5); + quickSceenShot.m_key1 = gConfig.GetValue("hotkey.quick_screenshot.key1", VK_F5); + quickSceenShot.m_key2 = gConfig.GetValue("hotkey.quick_screenshot.key2", VK_F5); - quickTeleport.m_key1 = gConfig.GetValue("hotkey.quick_tp.key1", VK_KEY_X); - quickTeleport.m_key2 = gConfig.GetValue("hotkey.quick_tp.key2", VK_KEY_Y); + quickTeleport.m_key1 = gConfig.GetValue("hotkey.quick_tp.key1", VK_KEY_X); + quickTeleport.m_key2 = gConfig.GetValue("hotkey.quick_tp.key2", VK_KEY_Y); - menuOpen.m_key1 = gConfig.GetValue("hotkey.menu_open.key1", VK_LCONTROL); - menuOpen.m_key2 = gConfig.GetValue("hotkey.menu_open.key2", VK_KEY_M); + menuOpen.m_key1 = gConfig.GetValue("hotkey.menu_open.key1", VK_LCONTROL); + menuOpen.m_key2 = gConfig.GetValue("hotkey.menu_open.key2", VK_KEY_M); - commandWindow.m_key1 = gConfig.GetValue("hotkey.command_window.key1", VK_LMENU); - commandWindow.m_key2 = gConfig.GetValue("hotkey.command_window.key2", VK_KEY_C); + commandWindow.m_key1 = gConfig.GetValue("hotkey.command_window.key1", VK_LMENU); + commandWindow.m_key2 = gConfig.GetValue("hotkey.command_window.key2", VK_KEY_C); - flipVeh.m_key1 = gConfig.GetValue("hotkey.flip_veh.key1", VK_NONE); - flipVeh.m_key2 = gConfig.GetValue("hotkey.flip_veh.key2", VK_NONE); + flipVeh.m_key1 = gConfig.GetValue("hotkey.flip_veh.key1", VK_NONE); + flipVeh.m_key2 = gConfig.GetValue("hotkey.flip_veh.key2", VK_NONE); - fixVeh.m_key1 = gConfig.GetValue("hotkey.fix_veh.key1", VK_NONE); - fixVeh.m_key2 = gConfig.GetValue("hotkey.fix_veh.key2", VK_NONE); + fixVeh.m_key1 = gConfig.GetValue("hotkey.fix_veh.key1", VK_NONE); + fixVeh.m_key2 = gConfig.GetValue("hotkey.fix_veh.key2", VK_NONE); - godMode.m_key1 = gConfig.GetValue("hotkey.god_mode.key1", VK_NONE); - godMode.m_key2 = gConfig.GetValue("hotkey.god_mode.key2", VK_NONE); + godMode.m_key1 = gConfig.GetValue("hotkey.god_mode.key1", VK_NONE); + godMode.m_key2 = gConfig.GetValue("hotkey.god_mode.key2", VK_NONE); - vehEngine.m_key1 = gConfig.GetValue("hotkey.veh_engine.key1", VK_NONE); - vehEngine.m_key2 = gConfig.GetValue("hotkey.veh_engine.key2", VK_NONE); + vehEngine.m_key1 = gConfig.GetValue("hotkey.veh_engine.key1", VK_NONE); + vehEngine.m_key2 = gConfig.GetValue("hotkey.veh_engine.key2", VK_NONE); - vehInstantStart.m_key1 = gConfig.GetValue("hotkey.veh_instant_start.key1", VK_NONE); - vehInstantStart.m_key2 = gConfig.GetValue("hotkey.veh_instant_start.key2", VK_NONE); + vehInstantStart.m_key1 = gConfig.GetValue("hotkey.veh_instant_start.key1", VK_NONE); + vehInstantStart.m_key2 = gConfig.GetValue("hotkey.veh_instant_start.key2", VK_NONE); - vehInstantStop.m_key1 = gConfig.GetValue("hotkey.veh_instant_stop.key1", VK_NONE); - vehInstantStop.m_key2 = gConfig.GetValue("hotkey.veh_instant_stop.key2", VK_NONE); + vehInstantStop.m_key1 = gConfig.GetValue("hotkey.veh_instant_stop.key1", VK_NONE); + vehInstantStop.m_key2 = gConfig.GetValue("hotkey.veh_instant_stop.key2", VK_NONE); - Util::GetCPUUsageInit(); - MEMORYSTATUSEX memInfo; - memInfo.dwLength = sizeof(MEMORYSTATUSEX); - GlobalMemoryStatusEx(&memInfo); + Util::GetCPUUsageInit(); + MEMORYSTATUSEX memInfo; + memInfo.dwLength = sizeof(MEMORYSTATUSEX); + GlobalMemoryStatusEx(&memInfo); - m_Overlay::mTotalRam = static_cast(memInfo.ullTotalPhys * 1e-6); // Bytes -> MegaBytes + m_Overlay::mTotalRam = static_cast(memInfo.ullTotalPhys * 1e-6); // Bytes -> MegaBytes } void Menu::DrawOverlay() { - CPlayerPed *pPlayer = FindPlayerPed(); - if (pPlayer) - { - bool m_bShowMenu = m_Overlay::bCoord || m_Overlay::bFPS || m_Overlay::bLocName || m_Overlay::bCpuUsage || - m_Overlay::bMemUsage || - ((m_Overlay::bVehHealth || m_Overlay::bVehSpeed) && pPlayer && pPlayer->m_pVehicle && - pPlayer->m_pVehicle->m_pDriver == pPlayer); + CPlayerPed* pPlayer = FindPlayerPed(); + if (pPlayer) + { + bool m_bShowMenu = m_Overlay::bCoord || m_Overlay::bFPS || m_Overlay::bLocName || m_Overlay::bCpuUsage || m_Overlay::bMemUsage || + ((m_Overlay::bVehHealth || m_Overlay::bVehSpeed) && pPlayer && pPlayer->m_pVehicle && pPlayer->m_pVehicle->m_pDriver == pPlayer); - const float offset = 10.0f; - ImGuiIO &io = ImGui::GetIO(); - ImGuiWindowFlags window_flags = ImGuiWindowFlags_NoDecoration | ImGuiWindowFlags_AlwaysAutoResize | - ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_NoFocusOnAppearing | - ImGuiWindowFlags_NoNav; + const float offset = 10.0f; + ImGuiIO& io = ImGui::GetIO(); + ImGuiWindowFlags window_flags = ImGuiWindowFlags_NoDecoration | ImGuiWindowFlags_AlwaysAutoResize | + ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_NoFocusOnAppearing | ImGuiWindowFlags_NoNav; - if (m_Overlay::mSelectedPos == DISPLAY_POS::CUSTOM) - { - if (m_Overlay::fPosX != NULL && m_Overlay::fPosY != NULL) - { - gConfig.SetValue("overlay.posx", m_Overlay::fPosX); - gConfig.SetValue("overlay.posy", m_Overlay::fPosY); - ImGui::SetNextWindowPos(ImVec2(m_Overlay::fPosX, m_Overlay::fPosY), ImGuiCond_Once); - } - } - else - { - window_flags |= ImGuiWindowFlags_NoMove; - ImVec2 pos, pivot; + if (m_Overlay::mSelectedPos == DISPLAY_POS::CUSTOM) + { + if (m_Overlay::fPosX != NULL && m_Overlay::fPosY != NULL) + { + gConfig.SetValue("overlay.posx", m_Overlay::fPosX); + gConfig.SetValue("overlay.posy", m_Overlay::fPosY); + ImGui::SetNextWindowPos(ImVec2(m_Overlay::fPosX, m_Overlay::fPosY), ImGuiCond_Once); + } + } + else + { + window_flags |= ImGuiWindowFlags_NoMove; + ImVec2 pos, pivot; - if (m_Overlay::mSelectedPos == DISPLAY_POS::TOP_LEFT) - { - pos = ImVec2(offset, offset); - pivot = ImVec2(0.0f, 0.0f); - } + if (m_Overlay::mSelectedPos == DISPLAY_POS::TOP_LEFT) + { + pos = ImVec2(offset, offset); + pivot = ImVec2(0.0f, 0.0f); + } - if (m_Overlay::mSelectedPos == DISPLAY_POS::TOP_RIGHT) - { - pos = ImVec2(io.DisplaySize.x - offset, offset); - pivot = ImVec2(1.0f, 0.0f); - } + if (m_Overlay::mSelectedPos == DISPLAY_POS::TOP_RIGHT) + { + pos = ImVec2(io.DisplaySize.x - offset, offset); + pivot = ImVec2(1.0f, 0.0f); + } - if (m_Overlay::mSelectedPos == DISPLAY_POS::BOTTOM_LEFT) - { - pos = ImVec2(offset, io.DisplaySize.y - offset); - pivot = ImVec2(0.0f, 1.0f); - } + if (m_Overlay::mSelectedPos == DISPLAY_POS::BOTTOM_LEFT) + { + pos = ImVec2(offset, io.DisplaySize.y - offset); + pivot = ImVec2(0.0f, 1.0f); + } - if (m_Overlay::mSelectedPos == DISPLAY_POS::BOTTOM_RIGHT) - { - pos = ImVec2(io.DisplaySize.x - offset, io.DisplaySize.y - offset); - pivot = ImVec2(1.0f, 1.0f); - } + if (m_Overlay::mSelectedPos == DISPLAY_POS::BOTTOM_RIGHT) + { + pos = ImVec2(io.DisplaySize.x - offset, io.DisplaySize.y - offset); + pivot = ImVec2(1.0f, 1.0f); + } - ImGui::SetNextWindowPos(pos, ImGuiCond_Always, pivot); - } + ImGui::SetNextWindowPos(pos, ImGuiCond_Always, pivot); + } - ImGui::SetNextWindowBgAlpha(m_Overlay::bTransparent ? 0.0f : 0.5f); + ImGui::SetNextWindowBgAlpha(m_Overlay::bTransparent ? 0.0f : 0.5f); - if (m_bShowMenu && ImGui::Begin("Overlay", nullptr, window_flags)) - { - CVector pos{0, 0, 0}; - pos = pPlayer->GetPosition(); + if (m_bShowMenu && ImGui::Begin("Overlay", nullptr, window_flags)) + { + CVector pos{0,0,0}; + pos = pPlayer->GetPosition(); - size_t game_ms = CTimer::m_snTimeInMilliseconds; + size_t game_ms = CTimer::m_snTimeInMilliseconds; - if (game_ms - m_Overlay::mLastInterval > m_Overlay::mInterval) - { - m_Overlay::fCpuUsage = static_cast(Util::GetCurrentCPUUsage()); + if (game_ms - m_Overlay::mLastInterval > m_Overlay::mInterval) + { + m_Overlay::fCpuUsage = static_cast(Util::GetCurrentCPUUsage()); - MEMORYSTATUSEX memInfo; - memInfo.dwLength = sizeof(MEMORYSTATUSEX); - GlobalMemoryStatusEx(&memInfo); - int mUsedRam = static_cast((memInfo.ullTotalPhys - memInfo.ullAvailPhys) * 1e-6); - m_Overlay::fMemUsage = - 100.0f * (static_cast(mUsedRam) / static_cast(m_Overlay::mTotalRam)); + MEMORYSTATUSEX memInfo; + memInfo.dwLength = sizeof(MEMORYSTATUSEX); + GlobalMemoryStatusEx(&memInfo); + int mUsedRam = static_cast((memInfo.ullTotalPhys - memInfo.ullAvailPhys) * 1e-6); + m_Overlay::fMemUsage = 100.0f * (static_cast(mUsedRam) / static_cast(m_Overlay::mTotalRam)); + + m_Overlay::mFPS = static_cast(BY_GAME(CTimer::game_FPS, io.Framerate, io.Framerate)); + m_Overlay::mLastInterval = game_ms; + } - m_Overlay::mFPS = static_cast(BY_GAME(CTimer::game_FPS, io.Framerate, io.Framerate)); - m_Overlay::mLastInterval = game_ms; - } + if (m_Overlay::bCoord) + { + ImGui::Text("Coord: %.2f, %.2f, %.2f", pos.x, pos.y, pos.z); + } - if (m_Overlay::bCoord) - { - ImGui::Text("Coord: %.2f, %.2f, %.2f", pos.x, pos.y, pos.z); - } + if (m_Overlay::bCpuUsage) + { + ImGui::Text("CPU usage: %.2f%%", m_Overlay::fCpuUsage); + } - if (m_Overlay::bCpuUsage) - { - ImGui::Text("CPU usage: %.2f%%", m_Overlay::fCpuUsage); - } + if (m_Overlay::bFPS) + { + ImGui::Text("Frames: %d", m_Overlay::mFPS); + } - if (m_Overlay::bFPS) - { - ImGui::Text("Frames: %d", m_Overlay::mFPS); - } + if (m_Overlay::bLocName) + { + ImGui::Text("Location: %s", Util::GetLocationName(&pos).c_str()); + } - if (m_Overlay::bLocName) - { - ImGui::Text("Location: %s", Util::GetLocationName(&pos).c_str()); - } + if (m_Overlay::bMemUsage) + { + ImGui::Text("RAM usage: %.2f%%", m_Overlay::fMemUsage); + } - if (m_Overlay::bMemUsage) - { - ImGui::Text("RAM usage: %.2f%%", m_Overlay::fMemUsage); - } + if (pPlayer->m_pVehicle && pPlayer->m_pVehicle->m_pDriver == pPlayer) + { + if (m_Overlay::bVehHealth) + { + ImGui::Text("Veh Health: %.f", pPlayer->m_pVehicle->m_fHealth); + } - if (pPlayer->m_pVehicle && pPlayer->m_pVehicle->m_pDriver == pPlayer) - { - if (m_Overlay::bVehHealth) - { - ImGui::Text("Veh Health: %.f", pPlayer->m_pVehicle->m_fHealth); - } + if (m_Overlay::bVehSpeed) + { + int speed = pPlayer->m_pVehicle->m_vecMoveSpeed.Magnitude() * 50.0f; // 02E3 - GET_CAR_SPEED + ImGui::Text("Veh Speed: %d", speed); + } + } - if (m_Overlay::bVehSpeed) - { - int speed = pPlayer->m_pVehicle->m_vecMoveSpeed.Magnitude() * 50.0f; // 02E3 - GET_CAR_SPEED - ImGui::Text("Veh Speed: %d", speed); - } - } + ImVec2 windowPos = ImGui::GetWindowPos(); + m_Overlay::fPosX = windowPos.x; + m_Overlay::fPosY = windowPos.y; - ImVec2 windowPos = ImGui::GetWindowPos(); - m_Overlay::fPosX = windowPos.x; - m_Overlay::fPosY = windowPos.y; - - ImGui::End(); - } - } + ImGui::End(); + } + } } void Menu::DrawShortcutsWindow() { - int resX = static_cast(screen::GetScreenWidth()); - int resY = static_cast(screen::GetScreenHeight()); + int resX = static_cast(screen::GetScreenWidth()); + int resY = static_cast(screen::GetScreenHeight()); - ImGui::SetNextWindowPos(ImVec2(0, resY - 40), ImGuiCond_Always); - ImGui::SetNextWindowSize(ImVec2(resX, 40)); + ImGui::SetNextWindowPos(ImVec2(0, resY - 40), ImGuiCond_Always); + ImGui::SetNextWindowSize(ImVec2(resX, 40)); - ImGuiWindowFlags flags = ImGuiWindowFlags_NoDecoration + ImGuiWindowFlags_AlwaysAutoResize + - ImGuiWindowFlags_NoSavedSettings + ImGuiWindowFlags_NoMove; + ImGuiWindowFlags flags = ImGuiWindowFlags_NoDecoration + ImGuiWindowFlags_AlwaysAutoResize + + ImGuiWindowFlags_NoSavedSettings + + ImGuiWindowFlags_NoMove; - if (ImGui::Begin("Shortcuts window", nullptr, flags)) - { - ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(ImGui::GetStyle().FramePadding.x, resY / 130)); - ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(3, 3)); + if (ImGui::Begin("Shortcuts window", nullptr, 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::SetNextItemWidth(resX); + ImGui::SetKeyboardFocusHere(-1); - if (ImGui::InputTextWithHint("##TEXTFIELD", "Enter command", m_Commands::m_nInputBuffer, INPUT_BUFFER_SIZE, - ImGuiInputTextFlags_EnterReturnsTrue)) - { - ProcessCommands(); - m_Commands::m_bShowMenu = false; - strcpy(m_Commands::m_nInputBuffer, ""); - } + if (ImGui::InputTextWithHint("##TEXTFIELD", "Enter command", m_Commands::m_nInputBuffer, INPUT_BUFFER_SIZE, + ImGuiInputTextFlags_EnterReturnsTrue)) + { + ProcessCommands(); + m_Commands::m_bShowMenu = false; + strcpy(m_Commands::m_nInputBuffer, ""); + } - ImGui::PopStyleVar(2); - ImGui::End(); - } + ImGui::PopStyleVar(2); + ImGui::End(); + } } void Menu::ProcessCommands() { - std::stringstream ss(m_Commands::m_nInputBuffer); + std::stringstream ss(m_Commands::m_nInputBuffer); - std::string command; - ss >> command; + std::string command; + ss >> command; - if (command == "hp") - { - try - { - std::string temp; - ss >> temp; - FindPlayerPed()->m_fHealth = std::stof(temp); - } - catch (...) - { - SetHelpMessage("Invalid value", false, false, false); - } - } + if (command == "hp") + { + try + { + std::string temp; + ss >> temp; + FindPlayerPed()->m_fHealth = std::stof(temp); + } + catch (...) + { + SetHelpMessage("Invalid value", false, false, false); + } + } - if (command == "time") - { - try - { - std::string temp; - ss >> temp; - CClock::ms_nGameClockHours = std::stoi(temp); + if (command == "time") + { + try + { + std::string temp; + ss >> temp; + CClock::ms_nGameClockHours = std::stoi(temp); - ss >> temp; - CClock::ms_nGameClockMinutes = std::stoi(temp); - } - catch (...) - { - SetHelpMessage("Invalid value", false, false, false); - } - } + ss >> temp; + CClock::ms_nGameClockMinutes = std::stoi(temp); + } + catch (...) + { + SetHelpMessage("Invalid value", false, false, false); + } + } -#ifdef GTASA - if (command == "tp") - { - try - { - CVector pos; - std::string temp; + #ifdef GTASA + if (command == "tp") + { + try + { + CVector pos; + std::string temp; - ss >> temp; - pos.x = std::stof(temp); + ss >> temp; + pos.x = std::stof(temp); - ss >> temp; - pos.y = std::stof(temp); + ss >> temp; + pos.y = std::stof(temp); - ss >> temp; - pos.z = std::stof(temp); + ss >> temp; + pos.z = std::stof(temp); - Teleport::TeleportPlayer(false, pos, 0); - } - catch (...) - { - SetHelpMessage("Invalid location", false, false, false); - } - } + Teleport::TeleportPlayer(false, pos, 0); + } + catch (...) + { + SetHelpMessage("Invalid location", false, false, false); + } + } - if (command == "wep") - { - std::string wep_name; - ss >> wep_name; + if (command == "wep") + { + std::string wep_name; + ss >> wep_name; - if (wep_name == "jetpack") - { - std::string weapon = "-1"; - Weapon::GiveWeaponToPlayer(weapon); - SetHelpMessage("Weapon given", false, false, false); - } - else - { - eWeaponType weapon = CWeaponInfo::FindWeaponType((char *)wep_name.c_str()); - std::string weapon_name = std::to_string(weapon); - CWeaponInfo *pweaponinfo = CWeaponInfo::GetWeaponInfo(weapon, 1); + if (wep_name == "jetpack") + { + std::string weapon = "-1"; + Weapon::GiveWeaponToPlayer(weapon); + SetHelpMessage("Weapon given", false, false, false); + } + else + { + eWeaponType weapon = CWeaponInfo::FindWeaponType((char*)wep_name.c_str()); + std::string weapon_name = std::to_string(weapon); + CWeaponInfo* pweaponinfo = CWeaponInfo::GetWeaponInfo(weapon, 1); - if (wep_name != "" && pweaponinfo->m_nModelId1 != -1) - { - Weapon::GiveWeaponToPlayer(weapon_name); - SetHelpMessage("Weapon given", false, false, false); - } - else - SetHelpMessage("Invalid command", false, false, false); - } + if (wep_name != "" && pweaponinfo->m_nModelId1 != -1) + { + Weapon::GiveWeaponToPlayer(weapon_name); + SetHelpMessage("Weapon given", false, false, false); + } + else + SetHelpMessage("Invalid command", false, false, false); + } - return; - } - if (command == "veh") - { - std::string veh_name; - ss >> veh_name; + return; + } + if (command == "veh") + { + std::string veh_name; + ss >> veh_name; - int model = Vehicle::GetModelFromName(veh_name.c_str()); - if (model != 0) - { - std::string smodel = std::to_string(model); - Vehicle::SpawnVehicle(smodel); - SetHelpMessage("Vehicle spawned", false, false, false); - } - else - SetHelpMessage("Invalid command", false, false, false); - } -#endif + int model = Vehicle::GetModelFromName(veh_name.c_str()); + if (model != 0) + { + std::string smodel = std::to_string(model); + Vehicle::SpawnVehicle(smodel); + SetHelpMessage("Vehicle spawned", false, false, false); + } + else + SetHelpMessage("Invalid command", false, false, false); + } + #endif } void Menu::Draw() { - if (ImGui::BeginTabBar("Menu", ImGuiTabBarFlags_NoTooltip + ImGuiTabBarFlags_FittingPolicyScroll)) - { - if (ImGui::BeginTabItem("Overlay")) - { - ImGui::Spacing(); - ImGui::Spacing(); - ImGui::SameLine(); - if (Ui::ListBox("Overlay", m_Overlay::posNames, (int &)m_Overlay::mSelectedPos)) - gConfig.SetValue("overlay.selected_pos", m_Overlay::mSelectedPos); + if (ImGui::BeginTabBar("Menu", ImGuiTabBarFlags_NoTooltip + ImGuiTabBarFlags_FittingPolicyScroll)) + { + if (ImGui::BeginTabItem("Overlay")) + { + ImGui::Spacing(); + ImGui::Spacing(); + ImGui::SameLine(); + if (Ui::ListBox("Overlay", m_Overlay::posNames, (int&)m_Overlay::mSelectedPos)) + gConfig.SetValue("overlay.selected_pos", m_Overlay::mSelectedPos); - ImGui::Spacing(); + ImGui::Spacing(); - ImGui::Columns(2, nullptr, false); - if (ImGui::Checkbox("No background", &m_Overlay::bTransparent)) - gConfig.SetValue("overlay.transparent", m_Overlay::bTransparent); + ImGui::Columns(2, nullptr, false); + if (ImGui::Checkbox("No background", &m_Overlay::bTransparent)) + gConfig.SetValue("overlay.transparent", m_Overlay::bTransparent); - if (ImGui::Checkbox("Show coordinates", &m_Overlay::bCoord)) - gConfig.SetValue("overlay.coord", m_Overlay::bCoord); + if (ImGui::Checkbox("Show coordinates", &m_Overlay::bCoord)) + gConfig.SetValue("overlay.coord", m_Overlay::bCoord); - if (ImGui::Checkbox("Show CPU usage", &m_Overlay::bCpuUsage)) - gConfig.SetValue("overlay.cpu_usage", m_Overlay::bCpuUsage); + if (ImGui::Checkbox("Show CPU usage", &m_Overlay::bCpuUsage)) + gConfig.SetValue("overlay.cpu_usage", m_Overlay::bCpuUsage); - if (ImGui::Checkbox("Show FPS", &m_Overlay::bFPS)) - gConfig.SetValue("overlay.fps", m_Overlay::bFPS); + if (ImGui::Checkbox("Show FPS", &m_Overlay::bFPS)) + gConfig.SetValue("overlay.fps", m_Overlay::bFPS); - ImGui::NextColumn(); + ImGui::NextColumn(); - if (ImGui::Checkbox("Show location", &m_Overlay::bLocName)) - gConfig.SetValue("overlay.loc_name", m_Overlay::bLocName); + if (ImGui::Checkbox("Show location", &m_Overlay::bLocName)) + gConfig.SetValue("overlay.loc_name", m_Overlay::bLocName); - if (ImGui::Checkbox("Show RAM usage", &m_Overlay::bMemUsage)) - gConfig.SetValue("overlay.mem_usage", m_Overlay::bMemUsage); + if (ImGui::Checkbox("Show RAM usage", &m_Overlay::bMemUsage)) + gConfig.SetValue("overlay.mem_usage", m_Overlay::bMemUsage); - if (ImGui::Checkbox("Show veh health", &m_Overlay::bVehHealth)) - gConfig.SetValue("overlay.veh_health", m_Overlay::bVehHealth); + if (ImGui::Checkbox("Show veh health", &m_Overlay::bVehHealth)) + gConfig.SetValue("overlay.veh_health", m_Overlay::bVehHealth); - if (ImGui::Checkbox("Show veh speed", &m_Overlay::bVehSpeed)) - gConfig.SetValue("overlay.veh_speed", m_Overlay::bVehSpeed); + if (ImGui::Checkbox("Show veh speed", &m_Overlay::bVehSpeed)) + gConfig.SetValue("overlay.veh_speed", m_Overlay::bVehSpeed); - ImGui::Columns(1); + ImGui::Columns(1); - ImGui::EndTabItem(); - } - if (ImGui::BeginTabItem("Hotkeys")) - { - ImGui::Spacing(); - ImGui::Text("Usage"); - Ui::ShowTooltip("Left-click selects hotkey.\nLeft clicking outside deselects." - "\nRight click disables hotkey."); - ImGui::Spacing(); - ImGui::BeginChild("Hotkeys"); - if (menuOpen.DrawUI("Open/ close cheat menu")) - { - gConfig.SetValue("hotkey.menu_open.key1", menuOpen.m_key1); - gConfig.SetValue("hotkey.menu_open.key2", menuOpen.m_key2); - } - if (commandWindow.DrawUI("Open/ close command window")) - { - gConfig.SetValue("hotkey.command_window.key1", commandWindow.m_key1); - gConfig.SetValue("hotkey.command_window.key2", commandWindow.m_key2); - } + ImGui::EndTabItem(); + } + if (ImGui::BeginTabItem("Hotkeys")) + { + ImGui::Spacing(); + ImGui::Text("Usage"); + Ui::ShowTooltip("Left-click selects hotkey.\nLeft clicking outside deselects." + "\nRight click disables hotkey."); + ImGui::Spacing(); + ImGui::BeginChild("Hotkeys"); + if (menuOpen.DrawUI("Open/ close cheat menu")) + { + gConfig.SetValue("hotkey.menu_open.key1", menuOpen.m_key1); + gConfig.SetValue("hotkey.menu_open.key2", menuOpen.m_key2); + } + if (commandWindow.DrawUI("Open/ close command window")) + { + gConfig.SetValue("hotkey.command_window.key1", commandWindow.m_key1); + gConfig.SetValue("hotkey.command_window.key2", commandWindow.m_key2); + } - ImGui::Dummy(ImVec2(0, 10)); + ImGui::Dummy(ImVec2(0, 10)); - if (aimSkinChanger.DrawUI("Activate aim skin changer")) - { - gConfig.SetValue("hotkey.aim_skin_changer.key1", aimSkinChanger.m_key1); - gConfig.SetValue("hotkey.aim_skin_changer.key2", aimSkinChanger.m_key2); - } - if (freeCam.DrawUI("Freecam")) - { - gConfig.SetValue("hotkey.freecam.key1", freeCam.m_key1); - gConfig.SetValue("hotkey.freecam.key2", freeCam.m_key2); - } - if (quickSceenShot.DrawUI("Take quick screenshot")) - { - gConfig.SetValue("hotkey.quick_screenshot.key1", quickSceenShot.m_key1); - gConfig.SetValue("hotkey.quick_screenshot.key2", quickSceenShot.m_key2); - } - if (quickTeleport.DrawUI("Toggle quick teleport")) - { - gConfig.SetValue("hotkey.quick_tp.key1", quickTeleport.m_key1); - gConfig.SetValue("hotkey.quick_tp.key2", quickTeleport.m_key2); - } + if (aimSkinChanger.DrawUI("Activate aim skin changer")) + { + gConfig.SetValue("hotkey.aim_skin_changer.key1", aimSkinChanger.m_key1); + gConfig.SetValue("hotkey.aim_skin_changer.key2", aimSkinChanger.m_key2); + } + if (freeCam.DrawUI("Freecam")) + { + gConfig.SetValue("hotkey.freecam.key1", freeCam.m_key1); + gConfig.SetValue("hotkey.freecam.key2", freeCam.m_key2); + } + if (quickSceenShot.DrawUI("Take quick screenshot")) + { + gConfig.SetValue("hotkey.quick_screenshot.key1", quickSceenShot.m_key1); + gConfig.SetValue("hotkey.quick_screenshot.key2", quickSceenShot.m_key2); + } + if (quickTeleport.DrawUI("Toggle quick teleport")) + { + gConfig.SetValue("hotkey.quick_tp.key1", quickTeleport.m_key1); + gConfig.SetValue("hotkey.quick_tp.key2", quickTeleport.m_key2); + } - ImGui::Dummy(ImVec2(0, 10)); + ImGui::Dummy(ImVec2(0, 10)); - if (fixVeh.DrawUI("Fix current vehicle")) - { - gConfig.SetValue("hotkey.fix_veh.key1", fixVeh.m_key1); - gConfig.SetValue("hotkey.fix_veh.key2", fixVeh.m_key2); - } + if (fixVeh.DrawUI("Fix current vehicle")) + { + gConfig.SetValue("hotkey.fix_veh.key1", fixVeh.m_key1); + gConfig.SetValue("hotkey.fix_veh.key2", fixVeh.m_key2); + } - if (flipVeh.DrawUI("Flip current vehicle")) - { - gConfig.SetValue("hotkey.flip_veh.key1", flipVeh.m_key1); - gConfig.SetValue("hotkey.flip_veh.key2", flipVeh.m_key2); - } + if (flipVeh.DrawUI("Flip current vehicle")) + { + gConfig.SetValue("hotkey.flip_veh.key1", flipVeh.m_key1); + gConfig.SetValue("hotkey.flip_veh.key2", flipVeh.m_key2); + } - if (godMode.DrawUI("Toggle god mode")) - { - gConfig.SetValue("hotkey.god_mode.key1", godMode.m_key1); - gConfig.SetValue("hotkey.god_mode.key2", godMode.m_key2); - } + if (godMode.DrawUI("Toggle god mode")) + { + gConfig.SetValue("hotkey.god_mode.key1", godMode.m_key1); + gConfig.SetValue("hotkey.god_mode.key2", godMode.m_key2); + } - if (vehEngine.DrawUI("Toggle veh engine")) - { - gConfig.SetValue("hotkey.veh_engine.key1", vehEngine.m_key1); - gConfig.SetValue("hotkey.veh_engine.key2", vehEngine.m_key2); - } + if (vehEngine.DrawUI("Toggle veh engine")) + { + gConfig.SetValue("hotkey.veh_engine.key1", vehEngine.m_key1); + gConfig.SetValue("hotkey.veh_engine.key2", vehEngine.m_key2); + } - if (vehInstantStart.DrawUI("Vehicle instant start")) - { - gConfig.SetValue("hotkey.veh_instant_start.key1", vehInstantStart.m_key1); - gConfig.SetValue("hotkey.veh_instant_start.key2", vehInstantStart.m_key2); - } + if (vehInstantStart.DrawUI("Vehicle instant start")) + { + gConfig.SetValue("hotkey.veh_instant_start.key1", vehInstantStart.m_key1); + gConfig.SetValue("hotkey.veh_instant_start.key2", vehInstantStart.m_key2); + } - if (vehInstantStop.DrawUI("Vehicle instant stop")) - { - gConfig.SetValue("hotkey.veh_instant_stop.key1", vehInstantStop.m_key1); - gConfig.SetValue("hotkey.veh_instant_stop.key2", vehInstantStop.m_key2); - } + if (vehInstantStop.DrawUI("Vehicle instant stop")) + { + gConfig.SetValue("hotkey.veh_instant_stop.key1", vehInstantStop.m_key1); + gConfig.SetValue("hotkey.veh_instant_stop.key2", vehInstantStop.m_key2); + } - ImGui::Dummy(ImVec2(0, 10)); + ImGui::Dummy(ImVec2(0, 10)); - ImGui::EndChild(); - ImGui::EndTabItem(); - } - if (ImGui::BeginTabItem("Commands")) - { - if (ImGui::BeginChild("CommandsChild")) - { - ImGui::TextWrapped("Open or close command window using %s", commandWindow.GetNameString().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("Commands")) + { + if (ImGui::BeginChild("CommandsChild")) + { + ImGui::TextWrapped("Open or close command window using %s", commandWindow.GetNameString().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(); + ImGui::EndChild(); + } + ImGui::EndTabItem(); + } + if (ImGui::BeginTabItem("About")) + { + ImGui::Spacing(); - if (ImGui::Button("Check update", ImVec2(Ui::GetSize(3)))) - { - if (Updater::m_State == UPDATER_IDLE) - { - Updater::m_State = UPDATER_CHECKING; - } - } + if (ImGui::Button("Check update", ImVec2(Ui::GetSize(3)))) + { + if (Updater::m_State == UPDATER_IDLE) + { + Updater::m_State = UPDATER_CHECKING; + } + } - ImGui::SameLine(); + ImGui::SameLine(); - if (ImGui::Button("Discord server", ImVec2(Ui::GetSize(3)))) - ShellExecute(nullptr, "open", DISCORD_INVITE, nullptr, nullptr, SW_SHOWNORMAL); + if (ImGui::Button("Discord server", ImVec2(Ui::GetSize(3)))) + ShellExecute(nullptr, "open", DISCORD_INVITE, nullptr, nullptr, SW_SHOWNORMAL); - ImGui::SameLine(); + ImGui::SameLine(); - if (ImGui::Button("GitHub repo", ImVec2(Ui::GetSize(3)))) - ShellExecute(nullptr, "open", GITHUB_LINK, nullptr, nullptr, SW_SHOWNORMAL); + if (ImGui::Button("GitHub repo", ImVec2(Ui::GetSize(3)))) + ShellExecute(nullptr, "open", GITHUB_LINK, nullptr, nullptr, SW_SHOWNORMAL); - ImGui::Spacing(); + ImGui::Spacing(); - if (ImGui::BeginChild("AboutChild")) - { - ImGui::Columns(2, nullptr, false); - ImGui::Text("Author: Grinch_"); + if (ImGui::BeginChild("AboutChild")) + { + ImGui::Columns(2, nullptr, false); + ImGui::Text("Author: Grinch_"); - ImGui::Text("Version: %s", MENU_VERSION); + ImGui::Text("Version: %s",MENU_VERSION); - ImGui::NextColumn(); - ImGui::Text("ImGui: %s", ImGui::GetVersion()); - ImGui::Text("Build: %s", BUILD_NUMBER); + ImGui::NextColumn(); + ImGui::Text("ImGui: %s", ImGui::GetVersion()); + ImGui::Text("Build: %s", BUILD_NUMBER); - ImGui::Columns(1); + ImGui::Columns(1); - ImGui::Dummy(ImVec2(0, 10)); - ImGui::TextWrapped("If you find bugs or have suggestions, let me know on discord."); - ImGui::Dummy(ImVec2(0, 10)); - ImGui::TextWrapped("Thanks to Junior-Djjr"); - ImGui::Dummy(ImVec2(0, 30)); - Ui::CenterdText("Copyright Grinch_ 2019-2022. All rights reserved"); + ImGui::Dummy(ImVec2(0, 10)); + ImGui::TextWrapped("If you find bugs or have suggestions, let me know on discord."); + ImGui::Dummy(ImVec2(0, 10)); + ImGui::TextWrapped("Thanks to Junior-Djjr"); + ImGui::Dummy(ImVec2(0, 30)); + Ui::CenterdText("Copyright Grinch_ 2019-2022. All rights reserved"); - ImGui::EndChild(); - } + ImGui::EndChild(); + } - ImGui::EndTabItem(); - } - ImGui::EndTabBar(); - } + ImGui::EndTabItem(); + } + ImGui::EndTabBar(); + } } diff --git a/src/menu.h b/src/menu.h index 9a9e5d2..7cc3383 100644 --- a/src/menu.h +++ b/src/menu.h @@ -3,48 +3,50 @@ class Menu { private: - enum DISPLAY_POS - { - CUSTOM, - TOP_LEFT, - TOP_RIGHT, - BOTTOM_LEFT, - BOTTOM_RIGHT - }; - struct m_Overlay - { - static inline bool bCoord = false; - static inline bool bFPS = false; - static inline int mFPS = 0; - static inline bool bLocName = false; - static inline bool bTransparent = false; - static inline bool bVehHealth = false; - static inline bool bVehSpeed = false; - static inline bool bCpuUsage = false; - static inline float fCpuUsage = 0.0f; - static inline bool bMemUsage = false; - static inline float fMemUsage = 0.0f; - static inline std::vector posNames = {"Custom", "Top left", "Top right", "Bottom left", - "Bottom right"}; - static inline DISPLAY_POS mSelectedPos = DISPLAY_POS::BOTTOM_RIGHT; - static inline float fPosX = 0.0f; - static inline float fPosY = 0.0f; - static inline size_t mInterval = 1000; - static inline size_t mLastInterval = 0; - static inline int mTotalRam = 0; - }; + enum DISPLAY_POS + { + CUSTOM, + TOP_LEFT, + TOP_RIGHT, + BOTTOM_LEFT, + BOTTOM_RIGHT + }; + + struct m_Overlay + { + static inline bool bCoord = false; + static inline bool bFPS = false; + static inline int mFPS = 0; + static inline bool bLocName = false; + static inline bool bTransparent = false; + static inline bool bVehHealth = false; + static inline bool bVehSpeed = false; + static inline bool bCpuUsage = false; + static inline float fCpuUsage = 0.0f; + static inline bool bMemUsage = false; + static inline float fMemUsage = 0.0f; + static inline std::vector posNames = { + "Custom", "Top left", "Top right", "Bottom left", "Bottom right" + }; + static inline DISPLAY_POS mSelectedPos = DISPLAY_POS::BOTTOM_RIGHT; + static inline float fPosX = 0.0f; + static inline float fPosY = 0.0f; + static inline size_t mInterval = 1000; + static inline size_t mLastInterval = 0; + static inline int mTotalRam = 0; + }; public: - struct m_Commands - { - static inline bool m_bShowMenu = false; - static inline char m_nInputBuffer[INPUT_BUFFER_SIZE] = ""; - }; + struct m_Commands + { + static inline bool m_bShowMenu = false; + static inline char m_nInputBuffer[INPUT_BUFFER_SIZE] = ""; + }; - Menu(); - static void Draw(); - static void DrawOverlay(); - static void DrawShortcutsWindow(); - static void ProcessCommands(); + Menu(); + static void Draw(); + static void DrawOverlay(); + static void DrawShortcutsWindow(); + static void ProcessCommands(); }; diff --git a/src/menuinfo.h b/src/menuinfo.h index 22ccafd..37b6686 100644 --- a/src/menuinfo.h +++ b/src/menuinfo.h @@ -1,6 +1,6 @@ #pragma once #define MENU_NAME "Cheat Menu" #define MENU_VERSION_NUMBER "3.0" -#define MENU_VERSION MENU_VERSION_NUMBER "-beta" +#define MENU_VERSION MENU_VERSION_NUMBER"-beta" #define BUILD_NUMBER "20211020" #define MENU_TITLE MENU_NAME " v" MENU_VERSION "(" BUILD_NUMBER ")" diff --git a/src/neon.cpp b/src/neon.cpp index aa3a509..a4ee16b 100644 --- a/src/neon.cpp +++ b/src/neon.cpp @@ -1,184 +1,254 @@ -#include "neon.h" #include "pch.h" +#include "neon.h" #include "util.h" // Neon sprite -const unsigned char neon_mask[1689] = { - 0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, 0x00, 0x00, 0x00, 0x0d, 0x49, 0x48, 0x44, 0x52, 0x00, 0x00, 0x00, - 0x40, 0x00, 0x00, 0x00, 0x80, 0x08, 0x06, 0x00, 0x00, 0x00, 0xbb, 0x81, 0x6f, 0x6a, 0x00, 0x00, 0x00, 0x09, 0x70, - 0x48, 0x59, 0x73, 0x00, 0x00, 0x0b, 0x13, 0x00, 0x00, 0x0b, 0x13, 0x01, 0x00, 0x9a, 0x9c, 0x18, 0x00, 0x00, 0x00, - 0x20, 0x63, 0x48, 0x52, 0x4d, 0x00, 0x00, 0x7a, 0x25, 0x00, 0x00, 0x80, 0x83, 0x00, 0x00, 0xf9, 0xff, 0x00, 0x00, - 0x80, 0xe9, 0x00, 0x00, 0x75, 0x30, 0x00, 0x00, 0xea, 0x60, 0x00, 0x00, 0x3a, 0x98, 0x00, 0x00, 0x17, 0x6f, 0x92, - 0x5f, 0xc5, 0x46, 0x00, 0x00, 0x06, 0x1f, 0x49, 0x44, 0x41, 0x54, 0x78, 0xda, 0xec, 0x5d, 0xdb, 0x8e, 0xe4, 0x2a, - 0x0c, 0x64, 0xa3, 0xf3, 0x10, 0x45, 0x49, 0x2b, 0xe2, 0xff, 0xbf, 0x11, 0x45, 0x09, 0x42, 0x79, 0x9b, 0xf3, 0x34, - 0xda, 0xde, 0x08, 0x70, 0xd9, 0x18, 0x42, 0x66, 0x1a, 0x69, 0xb4, 0xdb, 0x37, 0x3a, 0x55, 0x2e, 0x97, 0x0d, 0xdd, - 0x6a, 0xfe, 0x7c, 0x7d, 0x7d, 0x99, 0x86, 0x63, 0x01, 0x9f, 0x77, 0xb4, 0xba, 0xa0, 0x3f, 0x95, 0x09, 0x58, 0x14, - 0xe6, 0x38, 0x9e, 0x46, 0x00, 0x02, 0xda, 0x26, 0xee, 0x77, 0xad, 0xc9, 0xd0, 0x24, 0x60, 0x11, 0x82, 0x36, 0x02, - 0x32, 0x8e, 0xde, 0x08, 0x58, 0x98, 0xa0, 0x2d, 0x03, 0xb0, 0xab, 0x49, 0x82, 0x06, 0x01, 0x4b, 0x21, 0x70, 0x14, - 0x74, 0x15, 0x22, 0x4a, 0x09, 0x40, 0xc1, 0x53, 0xf7, 0xa1, 0xd1, 0x77, 0xbd, 0x10, 0x80, 0x4a, 0xde, 0x0a, 0x14, - 0xe0, 0x84, 0x6a, 0x38, 0x5a, 0x11, 0xa0, 0x01, 0x7e, 0x8d, 0xbc, 0x7e, 0x63, 0x12, 0xa1, 0x42, 0x82, 0x16, 0x01, - 0x96, 0x41, 0xc4, 0x9a, 0x99, 0xbb, 0x39, 0x09, 0x5c, 0x02, 0x16, 0x66, 0xe4, 0x53, 0x51, 0x7f, 0x45, 0xe6, 0xd9, - 0x41, 0x22, 0x9c, 0xa6, 0x31, 0x72, 0x08, 0xa8, 0x01, 0x7e, 0x36, 0xc6, 0x78, 0x90, 0x08, 0x0e, 0x09, 0x4d, 0x08, - 0x48, 0x81, 0x4f, 0x49, 0xfe, 0x0a, 0x3c, 0x36, 0x7c, 0x6b, 0x12, 0x50, 0x02, 0x16, 0x41, 0xe4, 0x63, 0x51, 0x9f, - 0x13, 0x24, 0x78, 0x06, 0x11, 0xaa, 0x24, 0x0c, 0xca, 0x2d, 0xae, 0x04, 0xfc, 0xf7, 0xed, 0xd8, 0xe3, 0xaf, 0x88, - 0x92, 0x2c, 0x68, 0xbe, 0xd0, 0x18, 0x04, 0xaf, 0xb1, 0x05, 0xe0, 0xdf, 0x81, 0x4e, 0x97, 0xbf, 0xeb, 0xe3, 0x73, - 0xc6, 0x30, 0x45, 0x60, 0xb5, 0x08, 0x40, 0xc0, 0xbf, 0x12, 0xe0, 0xcd, 0x05, 0xf0, 0xf4, 0x36, 0xc7, 0x14, 0x51, - 0xc0, 0x95, 0x84, 0x95, 0x59, 0x82, 0x97, 0x52, 0x02, 0x16, 0x01, 0xf3, 0xaf, 0x4b, 0x34, 0xaf, 0x51, 0xbf, 0x02, - 0x9e, 0x12, 0xff, 0xa7, 0x48, 0xb0, 0x77, 0x2a, 0x80, 0x92, 0x7e, 0xcc, 0xe5, 0x63, 0x20, 0x4d, 0x42, 0x01, 0x14, - 0x09, 0xb9, 0xca, 0xc3, 0x52, 0xc1, 0x50, 0x18, 0x7d, 0x4b, 0x94, 0xba, 0x58, 0xbe, 0x5f, 0x41, 0x4f, 0x89, 0xdb, - 0x29, 0x12, 0x90, 0x54, 0x68, 0xe2, 0x01, 0xa9, 0x31, 0x67, 0x22, 0x9b, 0x03, 0x9e, 0x52, 0xcb, 0x75, 0x4e, 0x24, - 0x15, 0xac, 0x36, 0x01, 0x36, 0x23, 0xbb, 0xf7, 0xe8, 0xc7, 0x0c, 0xcf, 0x10, 0x60, 0x29, 0x52, 0x26, 0xa2, 0x3c, - 0x16, 0xed, 0x56, 0x0d, 0xc2, 0xda, 0x9f, 0x32, 0x3e, 0x29, 0x78, 0x8e, 0xb2, 0xe6, 0x4c, 0x6f, 0xc0, 0xee, 0x0b, - 0xb8, 0x29, 0x60, 0x41, 0xe3, 0x2b, 0x01, 0x3f, 0x31, 0x53, 0xa1, 0x48, 0x05, 0x03, 0x53, 0xfe, 0x68, 0xf4, 0x0d, - 0xe0, 0x03, 0xc6, 0x18, 0x33, 0x0a, 0x48, 0xa0, 0x54, 0x50, 0x6c, 0x82, 0x4b, 0x85, 0xe8, 0xe7, 0xc0, 0x8f, 0x09, - 0x22, 0x26, 0x66, 0xea, 0x89, 0xda, 0xe3, 0xd2, 0x2a, 0x50, 0x12, 0x7d, 0x54, 0x0d, 0x57, 0x52, 0x67, 0xe2, 0xfd, - 0x6e, 0x2f, 0x83, 0x14, 0xe8, 0x31, 0x03, 0x76, 0x14, 0x92, 0xb7, 0x12, 0x4b, 0x72, 0x31, 0x01, 0x16, 0x94, 0xff, - 0x4c, 0xd4, 0x73, 0x24, 0xca, 0x1c, 0x52, 0xa5, 0x66, 0xb8, 0x68, 0x2a, 0xe0, 0x55, 0x49, 0x3d, 0x94, 0x0a, 0x28, - 0x33, 0x64, 0x99, 0xf8, 0x50, 0x58, 0xff, 0x73, 0xdd, 0x9b, 0x66, 0xf4, 0x29, 0xf0, 0xc8, 0xce, 0x14, 0x3b, 0x05, - 0x90, 0x09, 0x38, 0x46, 0x74, 0x2a, 0x7a, 0xca, 0xa4, 0xa5, 0x46, 0x4e, 0x1f, 0x60, 0x13, 0x52, 0x9b, 0x19, 0xe6, - 0x27, 0x4d, 0x83, 0x6a, 0x63, 0xa8, 0x94, 0xff, 0x1a, 0xf2, 0x47, 0x5f, 0xc3, 0xf5, 0x81, 0x25, 0x45, 0x00, 0x37, - 0xff, 0x6b, 0x44, 0x9e, 0xe3, 0x31, 0x2a, 0x3e, 0xc0, 0x55, 0xc0, 0x5a, 0xe0, 0x01, 0xb5, 0x87, 0xa8, 0x1c, 0x0e, - 0xcc, 0xfa, 0x2f, 0x6d, 0x7e, 0x6a, 0x37, 0x5b, 0x73, 0x4b, 0x0f, 0x78, 0x11, 0xf2, 0xd7, 0x24, 0x62, 0x14, 0x80, - 0x5f, 0x6b, 0x11, 0xb0, 0x0a, 0xa2, 0x3f, 0x56, 0x8c, 0x3a, 0x55, 0x0e, 0x21, 0x15, 0x0f, 0x40, 0xfd, 0xb7, 0x8c, - 0x1e, 0x60, 0x32, 0x0f, 0x1b, 0x43, 0xa6, 0x02, 0x58, 0x81, 0xfc, 0x6b, 0x44, 0x7f, 0x04, 0xab, 0xc1, 0x2c, 0x49, - 0x83, 0x5a, 0xab, 0xc1, 0xb1, 0x93, 0xf9, 0x48, 0x35, 0x7f, 0x13, 0x70, 0x30, 0xf3, 0x5f, 0xb2, 0x01, 0xd2, 0xaa, - 0x1a, 0xb0, 0x3e, 0x4a, 0x1b, 0x88, 0x26, 0xc8, 0x66, 0xea, 0xac, 0xd4, 0xf8, 0x90, 0xcf, 0x07, 0xa8, 0x79, 0xd5, - 0x48, 0xff, 0x8f, 0xb9, 0x10, 0x2a, 0xdd, 0xf5, 0xa9, 0x65, 0x98, 0xdf, 0x73, 0xf9, 0x8b, 0x6a, 0x37, 0x29, 0x01, - 0x5c, 0xf9, 0x6b, 0x01, 0xbd, 0x3e, 0x37, 0x44, 0x54, 0x70, 0xbe, 0x3d, 0x37, 0x64, 0x7a, 0x95, 0x5d, 0x62, 0x82, - 0xb6, 0x30, 0x7a, 0x31, 0xf9, 0x87, 0x4a, 0xb9, 0x1f, 0x12, 0xd7, 0x32, 0x97, 0x6c, 0x88, 0xe4, 0xf2, 0x7f, 0x06, - 0xca, 0x91, 0xb6, 0xd4, 0xa7, 0x0c, 0xc9, 0x31, 0x1f, 0x61, 0x77, 0x85, 0xdc, 0x32, 0x38, 0xdf, 0x98, 0xe7, 0xa5, - 0xf3, 0x5b, 0x0d, 0x02, 0x24, 0x0d, 0x4b, 0x0d, 0x90, 0xd4, 0x7b, 0xcd, 0xc0, 0xea, 0x70, 0x41, 0x5a, 0xe1, 0x95, - 0xb8, 0xa0, 0x1e, 0x5b, 0xdf, 0x99, 0xc0, 0x64, 0xb9, 0x0a, 0x78, 0x01, 0x51, 0x19, 0xcd, 0x43, 0xc7, 0x60, 0xb0, - 0x9d, 0xa0, 0xbb, 0x73, 0x1f, 0x35, 0xc3, 0x89, 0xb9, 0x8a, 0x25, 0x37, 0x44, 0x7a, 0x5a, 0xed, 0x55, 0xa9, 0x36, - 0x43, 0x06, 0xf4, 0x4a, 0xa8, 0x60, 0xea, 0x90, 0x24, 0xae, 0x11, 0x8a, 0xaa, 0x40, 0x4f, 0xf9, 0x3f, 0x82, 0xcd, - 0x50, 0x76, 0x35, 0x78, 0x30, 0x0d, 0xb0, 0xf7, 0x31, 0x49, 0x53, 0x40, 0xcb, 0x00, 0xbb, 0x01, 0xa7, 0xd9, 0x08, - 0x3d, 0x25, 0xff, 0xd9, 0xef, 0xcf, 0x59, 0x0c, 0x21, 0x1d, 0x59, 0xaf, 0x2a, 0x58, 0x35, 0x4c, 0x30, 0x74, 0x92, - 0x06, 0xaa, 0xd7, 0x31, 0x34, 0xca, 0xbf, 0x3b, 0x15, 0xf0, 0xd2, 0x2e, 0x83, 0x3f, 0x6a, 0xfc, 0x74, 0x02, 0xe6, - 0xdf, 0x4e, 0xc0, 0xaf, 0x57, 0x80, 0xff, 0x28, 0x40, 0x91, 0x80, 0xa7, 0x96, 0xc1, 0xfd, 0xb7, 0x97, 0x41, 0x96, - 0x02, 0x1c, 0x93, 0xf9, 0xf3, 0x01, 0x0a, 0x30, 0x26, 0xf3, 0x01, 0x09, 0xaa, 0x00, 0x0f, 0x5e, 0x44, 0x78, 0x58, - 0x7a, 0x40, 0x04, 0x78, 0xd3, 0xcf, 0x28, 0x21, 0xd8, 0xa5, 0x08, 0x58, 0xa4, 0x06, 0xd2, 0xe9, 0x08, 0xda, 0x0a, - 0xa0, 0xde, 0xe0, 0xbc, 0x11, 0xec, 0x99, 0xb8, 0x26, 0x8f, 0xaa, 0x60, 0xc8, 0x3c, 0xb8, 0x3d, 0xd4, 0x07, 0xde, - 0xaf, 0x77, 0x97, 0x2a, 0xc0, 0x75, 0x08, 0x2e, 0xd4, 0xf0, 0x07, 0x6a, 0x4f, 0x50, 0x6a, 0x84, 0xa1, 0x01, 0xf8, - 0x98, 0xfc, 0x03, 0xa7, 0x04, 0xa2, 0x1e, 0xb0, 0x77, 0xee, 0x03, 0xea, 0xad, 0xb0, 0x23, 0xd8, 0x0b, 0x1d, 0xe6, - 0x3b, 0xa5, 0xd6, 0xe4, 0x0f, 0x2d, 0x68, 0x2e, 0x86, 0xce, 0x4a, 0x69, 0x10, 0x04, 0xef, 0x85, 0x18, 0xe0, 0x21, - 0x21, 0xe0, 0x6e, 0x2f, 0x28, 0x99, 0xdf, 0x71, 0x3d, 0xc0, 0x5d, 0x7c, 0x20, 0x55, 0x06, 0x43, 0x45, 0x12, 0x50, - 0xf3, 0xfb, 0xbe, 0xed, 0x39, 0x06, 0xc8, 0x5d, 0x0c, 0x21, 0xa0, 0xce, 0x86, 0xab, 0xc8, 0x09, 0x6c, 0x82, 0xb2, - 0x98, 0x90, 0x6f, 0x89, 0x6d, 0xe6, 0xdf, 0x7d, 0x75, 0x6f, 0xfe, 0xee, 0xb5, 0x05, 0x00, 0x60, 0x60, 0x10, 0x12, - 0x18, 0x3e, 0x13, 0x34, 0x5a, 0x78, 0x6e, 0x23, 0xe4, 0x15, 0x65, 0x1e, 0xde, 0xfe, 0x34, 0xbc, 0x80, 0x2d, 0xff, - 0x77, 0x02, 0x0e, 0xd0, 0x07, 0xa4, 0x69, 0x10, 0x03, 0x4e, 0xdd, 0x87, 0x44, 0xbf, 0x98, 0x3c, 0xea, 0xab, 0xb2, - 0xc8, 0xba, 0x40, 0xed, 0x62, 0x14, 0x8c, 0x32, 0x55, 0xfe, 0x9c, 0xe6, 0x6a, 0x50, 0xd2, 0x13, 0xdc, 0x35, 0x1f, - 0xf9, 0xeb, 0x73, 0xb9, 0x14, 0x70, 0x09, 0x73, 0xf1, 0x60, 0xee, 0x9f, 0x95, 0xc0, 0x87, 0x44, 0xe4, 0x3d, 0x37, - 0xff, 0x91, 0x56, 0x98, 0x6b, 0x88, 0x3d, 0xb6, 0xc6, 0x6a, 0x1b, 0x22, 0x9b, 0x52, 0x5f, 0xa0, 0xd9, 0xf9, 0x85, - 0x4c, 0xf9, 0x73, 0x89, 0x7f, 0x8b, 0x3d, 0x80, 0x4a, 0x83, 0xd0, 0x20, 0xf7, 0x43, 0x46, 0x89, 0x9b, 0x86, 0x02, - 0x20, 0xf6, 0x6e, 0x96, 0x7f, 0x28, 0x58, 0xa3, 0x88, 0x15, 0xb0, 0x15, 0x2e, 0x8e, 0x6a, 0x0e, 0xce, 0x06, 0xee, - 0x11, 0x23, 0x80, 0xfb, 0x8b, 0xac, 0xad, 0xab, 0x41, 0x60, 0x44, 0x1e, 0x56, 0xee, 0x50, 0x89, 0x6d, 0x8d, 0x1d, - 0xa3, 0x53, 0x10, 0x88, 0x0d, 0xe8, 0x07, 0x0e, 0x2e, 0x01, 0x57, 0x36, 0xb7, 0x06, 0x4a, 0x68, 0xb6, 0xc5, 0x86, - 0xee, 0x07, 0x68, 0x6c, 0x90, 0x8c, 0x0a, 0xf2, 0x47, 0xca, 0x5f, 0x11, 0x01, 0x87, 0x62, 0x8e, 0xd6, 0xd8, 0x38, - 0x55, 0xcd, 0xff, 0xd2, 0xb5, 0x40, 0xad, 0x8f, 0xcd, 0x4e, 0x46, 0xf4, 0xb9, 0xf9, 0xcf, 0x26, 0xc0, 0x01, 0x3e, - 0xf0, 0xde, 0x87, 0x53, 0x52, 0x3d, 0x2b, 0x44, 0x5f, 0x54, 0xfe, 0x6a, 0xaf, 0x06, 0x29, 0x33, 0x3c, 0x85, 0xd1, - 0xa7, 0xfa, 0x13, 0x96, 0xfc, 0x35, 0x08, 0xd8, 0x81, 0x9c, 0x0c, 0x42, 0xe9, 0xa7, 0xfc, 0xc5, 0x6b, 0x36, 0x61, - 0x03, 0x22, 0x13, 0x30, 0x0d, 0xb8, 0x1b, 0x24, 0x27, 0xa1, 0x88, 0x20, 0xf4, 0x21, 0x87, 0xe6, 0x3f, 0xb7, 0x0f, - 0xa8, 0xa1, 0x02, 0x64, 0xb1, 0x43, 0x75, 0x80, 0x1b, 0x57, 0xf6, 0x25, 0x29, 0x50, 0xa2, 0x82, 0x20, 0xf0, 0x8f, - 0xeb, 0x3c, 0x52, 0xf3, 0x4b, 0x2a, 0x7b, 0xe0, 0x3c, 0x99, 0xa9, 0x82, 0x12, 0x12, 0x72, 0x4d, 0x97, 0x07, 0xcd, - 0x4f, 0xb5, 0x0f, 0x70, 0x80, 0x0a, 0xf6, 0xc8, 0x45, 0x72, 0x48, 0x08, 0x0c, 0xe9, 0xab, 0x44, 0xbf, 0x56, 0x19, - 0x44, 0xbe, 0x49, 0x12, 0x08, 0x52, 0x10, 0xe9, 0xe7, 0x72, 0x5f, 0xa5, 0x0c, 0x1e, 0xc0, 0xa4, 0x31, 0x15, 0xa4, - 0x1a, 0x24, 0xe4, 0xf3, 0x80, 0x90, 0x01, 0x4f, 0x75, 0x7d, 0x4d, 0x4c, 0x30, 0x97, 0x12, 0x1b, 0x51, 0x0d, 0x42, - 0x02, 0x74, 0xce, 0xfc, 0x3c, 0x21, 0x7d, 0x24, 0xf7, 0x8f, 0x12, 0x02, 0x0e, 0x01, 0xcb, 0xfb, 0x45, 0x01, 0xa9, - 0x56, 0x39, 0x24, 0xa2, 0x4e, 0x81, 0x2f, 0x2a, 0x7b, 0x9a, 0x1e, 0xe0, 0x88, 0x54, 0xd8, 0x13, 0x40, 0x02, 0x60, - 0x8e, 0x14, 0x78, 0xb4, 0xf1, 0x39, 0x6a, 0x10, 0xe0, 0x18, 0xa9, 0x10, 0x23, 0x21, 0xe6, 0x0b, 0x21, 0xf2, 0xb8, - 0x07, 0xbb, 0xbd, 0xea, 0x0a, 0x38, 0x0a, 0xfd, 0x60, 0x8f, 0xf8, 0x42, 0xec, 0x50, 0x15, 0x4f, 0x94, 0xbb, 0x0d, - 0x0c, 0x00, 0x6b, 0x7c, 0x8e, 0xd9, 0xf9, 0x1c, 0xb4, 0xf4, 0x39, 0x6a, 0xeb, 0x73, 0xd8, 0x9a, 0x06, 0x01, 0x08, - 0xf0, 0x1f, 0x73, 0xdc, 0x9e, 0x16, 0x09, 0xe8, 0xfe, 0x43, 0x77, 0x07, 0x2e, 0x72, 0x3d, 0x01, 0xb9, 0xef, 0x71, - 0x47, 0x6e, 0x4a, 0x48, 0x40, 0x15, 0xc0, 0x5d, 0xe1, 0xdd, 0x4e, 0x00, 0x27, 0x25, 0x72, 0xf7, 0x3f, 0xf6, 0xd8, - 0x5d, 0x8a, 0x04, 0x6e, 0xf4, 0x91, 0xce, 0xae, 0xbb, 0x83, 0x97, 0x39, 0x44, 0xe4, 0xc8, 0x78, 0xf4, 0xd1, 0xdb, - 0x52, 0x32, 0x4c, 0x6b, 0xd0, 0x2d, 0x09, 0x90, 0x12, 0x72, 0xb4, 0xba, 0xa0, 0xff, 0x07, 0x00, 0x48, 0x04, 0x71, - 0x83, 0x9e, 0xcc, 0x51, 0xce, 0x00, 0x00, 0x00, 0x00, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82}; +const unsigned char neon_mask[1689] = +{ + 0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, 0x00, 0x00, 0x00, + 0x0d, 0x49, 0x48, 0x44, 0x52, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, + 0x00, 0x80, 0x08, 0x06, 0x00, 0x00, 0x00, 0xbb, 0x81, 0x6f, 0x6a, + 0x00, 0x00, 0x00, 0x09, 0x70, 0x48, 0x59, 0x73, 0x00, 0x00, 0x0b, + 0x13, 0x00, 0x00, 0x0b, 0x13, 0x01, 0x00, 0x9a, 0x9c, 0x18, 0x00, + 0x00, 0x00, 0x20, 0x63, 0x48, 0x52, 0x4d, 0x00, 0x00, 0x7a, 0x25, + 0x00, 0x00, 0x80, 0x83, 0x00, 0x00, 0xf9, 0xff, 0x00, 0x00, 0x80, + 0xe9, 0x00, 0x00, 0x75, 0x30, 0x00, 0x00, 0xea, 0x60, 0x00, 0x00, + 0x3a, 0x98, 0x00, 0x00, 0x17, 0x6f, 0x92, 0x5f, 0xc5, 0x46, 0x00, + 0x00, 0x06, 0x1f, 0x49, 0x44, 0x41, 0x54, 0x78, 0xda, 0xec, 0x5d, + 0xdb, 0x8e, 0xe4, 0x2a, 0x0c, 0x64, 0xa3, 0xf3, 0x10, 0x45, 0x49, + 0x2b, 0xe2, 0xff, 0xbf, 0x11, 0x45, 0x09, 0x42, 0x79, 0x9b, 0xf3, + 0x34, 0xda, 0xde, 0x08, 0x70, 0xd9, 0x18, 0x42, 0x66, 0x1a, 0x69, + 0xb4, 0xdb, 0x37, 0x3a, 0x55, 0x2e, 0x97, 0x0d, 0xdd, 0x6a, 0xfe, + 0x7c, 0x7d, 0x7d, 0x99, 0x86, 0x63, 0x01, 0x9f, 0x77, 0xb4, 0xba, + 0xa0, 0x3f, 0x95, 0x09, 0x58, 0x14, 0xe6, 0x38, 0x9e, 0x46, 0x00, + 0x02, 0xda, 0x26, 0xee, 0x77, 0xad, 0xc9, 0xd0, 0x24, 0x60, 0x11, + 0x82, 0x36, 0x02, 0x32, 0x8e, 0xde, 0x08, 0x58, 0x98, 0xa0, 0x2d, + 0x03, 0xb0, 0xab, 0x49, 0x82, 0x06, 0x01, 0x4b, 0x21, 0x70, 0x14, + 0x74, 0x15, 0x22, 0x4a, 0x09, 0x40, 0xc1, 0x53, 0xf7, 0xa1, 0xd1, + 0x77, 0xbd, 0x10, 0x80, 0x4a, 0xde, 0x0a, 0x14, 0xe0, 0x84, 0x6a, + 0x38, 0x5a, 0x11, 0xa0, 0x01, 0x7e, 0x8d, 0xbc, 0x7e, 0x63, 0x12, + 0xa1, 0x42, 0x82, 0x16, 0x01, 0x96, 0x41, 0xc4, 0x9a, 0x99, 0xbb, + 0x39, 0x09, 0x5c, 0x02, 0x16, 0x66, 0xe4, 0x53, 0x51, 0x7f, 0x45, + 0xe6, 0xd9, 0x41, 0x22, 0x9c, 0xa6, 0x31, 0x72, 0x08, 0xa8, 0x01, + 0x7e, 0x36, 0xc6, 0x78, 0x90, 0x08, 0x0e, 0x09, 0x4d, 0x08, 0x48, + 0x81, 0x4f, 0x49, 0xfe, 0x0a, 0x3c, 0x36, 0x7c, 0x6b, 0x12, 0x50, + 0x02, 0x16, 0x41, 0xe4, 0x63, 0x51, 0x9f, 0x13, 0x24, 0x78, 0x06, + 0x11, 0xaa, 0x24, 0x0c, 0xca, 0x2d, 0xae, 0x04, 0xfc, 0xf7, 0xed, + 0xd8, 0xe3, 0xaf, 0x88, 0x92, 0x2c, 0x68, 0xbe, 0xd0, 0x18, 0x04, + 0xaf, 0xb1, 0x05, 0xe0, 0xdf, 0x81, 0x4e, 0x97, 0xbf, 0xeb, 0xe3, + 0x73, 0xc6, 0x30, 0x45, 0x60, 0xb5, 0x08, 0x40, 0xc0, 0xbf, 0x12, + 0xe0, 0xcd, 0x05, 0xf0, 0xf4, 0x36, 0xc7, 0x14, 0x51, 0xc0, 0x95, + 0x84, 0x95, 0x59, 0x82, 0x97, 0x52, 0x02, 0x16, 0x01, 0xf3, 0xaf, + 0x4b, 0x34, 0xaf, 0x51, 0xbf, 0x02, 0x9e, 0x12, 0xff, 0xa7, 0x48, + 0xb0, 0x77, 0x2a, 0x80, 0x92, 0x7e, 0xcc, 0xe5, 0x63, 0x20, 0x4d, + 0x42, 0x01, 0x14, 0x09, 0xb9, 0xca, 0xc3, 0x52, 0xc1, 0x50, 0x18, + 0x7d, 0x4b, 0x94, 0xba, 0x58, 0xbe, 0x5f, 0x41, 0x4f, 0x89, 0xdb, + 0x29, 0x12, 0x90, 0x54, 0x68, 0xe2, 0x01, 0xa9, 0x31, 0x67, 0x22, + 0x9b, 0x03, 0x9e, 0x52, 0xcb, 0x75, 0x4e, 0x24, 0x15, 0xac, 0x36, + 0x01, 0x36, 0x23, 0xbb, 0xf7, 0xe8, 0xc7, 0x0c, 0xcf, 0x10, 0x60, + 0x29, 0x52, 0x26, 0xa2, 0x3c, 0x16, 0xed, 0x56, 0x0d, 0xc2, 0xda, + 0x9f, 0x32, 0x3e, 0x29, 0x78, 0x8e, 0xb2, 0xe6, 0x4c, 0x6f, 0xc0, + 0xee, 0x0b, 0xb8, 0x29, 0x60, 0x41, 0xe3, 0x2b, 0x01, 0x3f, 0x31, + 0x53, 0xa1, 0x48, 0x05, 0x03, 0x53, 0xfe, 0x68, 0xf4, 0x0d, 0xe0, + 0x03, 0xc6, 0x18, 0x33, 0x0a, 0x48, 0xa0, 0x54, 0x50, 0x6c, 0x82, + 0x4b, 0x85, 0xe8, 0xe7, 0xc0, 0x8f, 0x09, 0x22, 0x26, 0x66, 0xea, + 0x89, 0xda, 0xe3, 0xd2, 0x2a, 0x50, 0x12, 0x7d, 0x54, 0x0d, 0x57, + 0x52, 0x67, 0xe2, 0xfd, 0x6e, 0x2f, 0x83, 0x14, 0xe8, 0x31, 0x03, + 0x76, 0x14, 0x92, 0xb7, 0x12, 0x4b, 0x72, 0x31, 0x01, 0x16, 0x94, + 0xff, 0x4c, 0xd4, 0x73, 0x24, 0xca, 0x1c, 0x52, 0xa5, 0x66, 0xb8, + 0x68, 0x2a, 0xe0, 0x55, 0x49, 0x3d, 0x94, 0x0a, 0x28, 0x33, 0x64, + 0x99, 0xf8, 0x50, 0x58, 0xff, 0x73, 0xdd, 0x9b, 0x66, 0xf4, 0x29, + 0xf0, 0xc8, 0xce, 0x14, 0x3b, 0x05, 0x90, 0x09, 0x38, 0x46, 0x74, + 0x2a, 0x7a, 0xca, 0xa4, 0xa5, 0x46, 0x4e, 0x1f, 0x60, 0x13, 0x52, + 0x9b, 0x19, 0xe6, 0x27, 0x4d, 0x83, 0x6a, 0x63, 0xa8, 0x94, 0xff, + 0x1a, 0xf2, 0x47, 0x5f, 0xc3, 0xf5, 0x81, 0x25, 0x45, 0x00, 0x37, + 0xff, 0x6b, 0x44, 0x9e, 0xe3, 0x31, 0x2a, 0x3e, 0xc0, 0x55, 0xc0, + 0x5a, 0xe0, 0x01, 0xb5, 0x87, 0xa8, 0x1c, 0x0e, 0xcc, 0xfa, 0x2f, + 0x6d, 0x7e, 0x6a, 0x37, 0x5b, 0x73, 0x4b, 0x0f, 0x78, 0x11, 0xf2, + 0xd7, 0x24, 0x62, 0x14, 0x80, 0x5f, 0x6b, 0x11, 0xb0, 0x0a, 0xa2, + 0x3f, 0x56, 0x8c, 0x3a, 0x55, 0x0e, 0x21, 0x15, 0x0f, 0x40, 0xfd, + 0xb7, 0x8c, 0x1e, 0x60, 0x32, 0x0f, 0x1b, 0x43, 0xa6, 0x02, 0x58, + 0x81, 0xfc, 0x6b, 0x44, 0x7f, 0x04, 0xab, 0xc1, 0x2c, 0x49, 0x83, + 0x5a, 0xab, 0xc1, 0xb1, 0x93, 0xf9, 0x48, 0x35, 0x7f, 0x13, 0x70, + 0x30, 0xf3, 0x5f, 0xb2, 0x01, 0xd2, 0xaa, 0x1a, 0xb0, 0x3e, 0x4a, + 0x1b, 0x88, 0x26, 0xc8, 0x66, 0xea, 0xac, 0xd4, 0xf8, 0x90, 0xcf, + 0x07, 0xa8, 0x79, 0xd5, 0x48, 0xff, 0x8f, 0xb9, 0x10, 0x2a, 0xdd, + 0xf5, 0xa9, 0x65, 0x98, 0xdf, 0x73, 0xf9, 0x8b, 0x6a, 0x37, 0x29, + 0x01, 0x5c, 0xf9, 0x6b, 0x01, 0xbd, 0x3e, 0x37, 0x44, 0x54, 0x70, + 0xbe, 0x3d, 0x37, 0x64, 0x7a, 0x95, 0x5d, 0x62, 0x82, 0xb6, 0x30, + 0x7a, 0x31, 0xf9, 0x87, 0x4a, 0xb9, 0x1f, 0x12, 0xd7, 0x32, 0x97, + 0x6c, 0x88, 0xe4, 0xf2, 0x7f, 0x06, 0xca, 0x91, 0xb6, 0xd4, 0xa7, + 0x0c, 0xc9, 0x31, 0x1f, 0x61, 0x77, 0x85, 0xdc, 0x32, 0x38, 0xdf, + 0x98, 0xe7, 0xa5, 0xf3, 0x5b, 0x0d, 0x02, 0x24, 0x0d, 0x4b, 0x0d, + 0x90, 0xd4, 0x7b, 0xcd, 0xc0, 0xea, 0x70, 0x41, 0x5a, 0xe1, 0x95, + 0xb8, 0xa0, 0x1e, 0x5b, 0xdf, 0x99, 0xc0, 0x64, 0xb9, 0x0a, 0x78, + 0x01, 0x51, 0x19, 0xcd, 0x43, 0xc7, 0x60, 0xb0, 0x9d, 0xa0, 0xbb, + 0x73, 0x1f, 0x35, 0xc3, 0x89, 0xb9, 0x8a, 0x25, 0x37, 0x44, 0x7a, + 0x5a, 0xed, 0x55, 0xa9, 0x36, 0x43, 0x06, 0xf4, 0x4a, 0xa8, 0x60, + 0xea, 0x90, 0x24, 0xae, 0x11, 0x8a, 0xaa, 0x40, 0x4f, 0xf9, 0x3f, + 0x82, 0xcd, 0x50, 0x76, 0x35, 0x78, 0x30, 0x0d, 0xb0, 0xf7, 0x31, + 0x49, 0x53, 0x40, 0xcb, 0x00, 0xbb, 0x01, 0xa7, 0xd9, 0x08, 0x3d, + 0x25, 0xff, 0xd9, 0xef, 0xcf, 0x59, 0x0c, 0x21, 0x1d, 0x59, 0xaf, + 0x2a, 0x58, 0x35, 0x4c, 0x30, 0x74, 0x92, 0x06, 0xaa, 0xd7, 0x31, + 0x34, 0xca, 0xbf, 0x3b, 0x15, 0xf0, 0xd2, 0x2e, 0x83, 0x3f, 0x6a, + 0xfc, 0x74, 0x02, 0xe6, 0xdf, 0x4e, 0xc0, 0xaf, 0x57, 0x80, 0xff, + 0x28, 0x40, 0x91, 0x80, 0xa7, 0x96, 0xc1, 0xfd, 0xb7, 0x97, 0x41, + 0x96, 0x02, 0x1c, 0x93, 0xf9, 0xf3, 0x01, 0x0a, 0x30, 0x26, 0xf3, + 0x01, 0x09, 0xaa, 0x00, 0x0f, 0x5e, 0x44, 0x78, 0x58, 0x7a, 0x40, + 0x04, 0x78, 0xd3, 0xcf, 0x28, 0x21, 0xd8, 0xa5, 0x08, 0x58, 0xa4, + 0x06, 0xd2, 0xe9, 0x08, 0xda, 0x0a, 0xa0, 0xde, 0xe0, 0xbc, 0x11, + 0xec, 0x99, 0xb8, 0x26, 0x8f, 0xaa, 0x60, 0xc8, 0x3c, 0xb8, 0x3d, + 0xd4, 0x07, 0xde, 0xaf, 0x77, 0x97, 0x2a, 0xc0, 0x75, 0x08, 0x2e, + 0xd4, 0xf0, 0x07, 0x6a, 0x4f, 0x50, 0x6a, 0x84, 0xa1, 0x01, 0xf8, + 0x98, 0xfc, 0x03, 0xa7, 0x04, 0xa2, 0x1e, 0xb0, 0x77, 0xee, 0x03, + 0xea, 0xad, 0xb0, 0x23, 0xd8, 0x0b, 0x1d, 0xe6, 0x3b, 0xa5, 0xd6, + 0xe4, 0x0f, 0x2d, 0x68, 0x2e, 0x86, 0xce, 0x4a, 0x69, 0x10, 0x04, + 0xef, 0x85, 0x18, 0xe0, 0x21, 0x21, 0xe0, 0x6e, 0x2f, 0x28, 0x99, + 0xdf, 0x71, 0x3d, 0xc0, 0x5d, 0x7c, 0x20, 0x55, 0x06, 0x43, 0x45, + 0x12, 0x50, 0xf3, 0xfb, 0xbe, 0xed, 0x39, 0x06, 0xc8, 0x5d, 0x0c, + 0x21, 0xa0, 0xce, 0x86, 0xab, 0xc8, 0x09, 0x6c, 0x82, 0xb2, 0x98, + 0x90, 0x6f, 0x89, 0x6d, 0xe6, 0xdf, 0x7d, 0x75, 0x6f, 0xfe, 0xee, + 0xb5, 0x05, 0x00, 0x60, 0x60, 0x10, 0x12, 0x18, 0x3e, 0x13, 0x34, + 0x5a, 0x78, 0x6e, 0x23, 0xe4, 0x15, 0x65, 0x1e, 0xde, 0xfe, 0x34, + 0xbc, 0x80, 0x2d, 0xff, 0x77, 0x02, 0x0e, 0xd0, 0x07, 0xa4, 0x69, + 0x10, 0x03, 0x4e, 0xdd, 0x87, 0x44, 0xbf, 0x98, 0x3c, 0xea, 0xab, + 0xb2, 0xc8, 0xba, 0x40, 0xed, 0x62, 0x14, 0x8c, 0x32, 0x55, 0xfe, + 0x9c, 0xe6, 0x6a, 0x50, 0xd2, 0x13, 0xdc, 0x35, 0x1f, 0xf9, 0xeb, + 0x73, 0xb9, 0x14, 0x70, 0x09, 0x73, 0xf1, 0x60, 0xee, 0x9f, 0x95, + 0xc0, 0x87, 0x44, 0xe4, 0x3d, 0x37, 0xff, 0x91, 0x56, 0x98, 0x6b, + 0x88, 0x3d, 0xb6, 0xc6, 0x6a, 0x1b, 0x22, 0x9b, 0x52, 0x5f, 0xa0, + 0xd9, 0xf9, 0x85, 0x4c, 0xf9, 0x73, 0x89, 0x7f, 0x8b, 0x3d, 0x80, + 0x4a, 0x83, 0xd0, 0x20, 0xf7, 0x43, 0x46, 0x89, 0x9b, 0x86, 0x02, + 0x20, 0xf6, 0x6e, 0x96, 0x7f, 0x28, 0x58, 0xa3, 0x88, 0x15, 0xb0, + 0x15, 0x2e, 0x8e, 0x6a, 0x0e, 0xce, 0x06, 0xee, 0x11, 0x23, 0x80, + 0xfb, 0x8b, 0xac, 0xad, 0xab, 0x41, 0x60, 0x44, 0x1e, 0x56, 0xee, + 0x50, 0x89, 0x6d, 0x8d, 0x1d, 0xa3, 0x53, 0x10, 0x88, 0x0d, 0xe8, + 0x07, 0x0e, 0x2e, 0x01, 0x57, 0x36, 0xb7, 0x06, 0x4a, 0x68, 0xb6, + 0xc5, 0x86, 0xee, 0x07, 0x68, 0x6c, 0x90, 0x8c, 0x0a, 0xf2, 0x47, + 0xca, 0x5f, 0x11, 0x01, 0x87, 0x62, 0x8e, 0xd6, 0xd8, 0x38, 0x55, + 0xcd, 0xff, 0xd2, 0xb5, 0x40, 0xad, 0x8f, 0xcd, 0x4e, 0x46, 0xf4, + 0xb9, 0xf9, 0xcf, 0x26, 0xc0, 0x01, 0x3e, 0xf0, 0xde, 0x87, 0x53, + 0x52, 0x3d, 0x2b, 0x44, 0x5f, 0x54, 0xfe, 0x6a, 0xaf, 0x06, 0x29, + 0x33, 0x3c, 0x85, 0xd1, 0xa7, 0xfa, 0x13, 0x96, 0xfc, 0x35, 0x08, + 0xd8, 0x81, 0x9c, 0x0c, 0x42, 0xe9, 0xa7, 0xfc, 0xc5, 0x6b, 0x36, + 0x61, 0x03, 0x22, 0x13, 0x30, 0x0d, 0xb8, 0x1b, 0x24, 0x27, 0xa1, + 0x88, 0x20, 0xf4, 0x21, 0x87, 0xe6, 0x3f, 0xb7, 0x0f, 0xa8, 0xa1, + 0x02, 0x64, 0xb1, 0x43, 0x75, 0x80, 0x1b, 0x57, 0xf6, 0x25, 0x29, + 0x50, 0xa2, 0x82, 0x20, 0xf0, 0x8f, 0xeb, 0x3c, 0x52, 0xf3, 0x4b, + 0x2a, 0x7b, 0xe0, 0x3c, 0x99, 0xa9, 0x82, 0x12, 0x12, 0x72, 0x4d, + 0x97, 0x07, 0xcd, 0x4f, 0xb5, 0x0f, 0x70, 0x80, 0x0a, 0xf6, 0xc8, + 0x45, 0x72, 0x48, 0x08, 0x0c, 0xe9, 0xab, 0x44, 0xbf, 0x56, 0x19, + 0x44, 0xbe, 0x49, 0x12, 0x08, 0x52, 0x10, 0xe9, 0xe7, 0x72, 0x5f, + 0xa5, 0x0c, 0x1e, 0xc0, 0xa4, 0x31, 0x15, 0xa4, 0x1a, 0x24, 0xe4, + 0xf3, 0x80, 0x90, 0x01, 0x4f, 0x75, 0x7d, 0x4d, 0x4c, 0x30, 0x97, + 0x12, 0x1b, 0x51, 0x0d, 0x42, 0x02, 0x74, 0xce, 0xfc, 0x3c, 0x21, + 0x7d, 0x24, 0xf7, 0x8f, 0x12, 0x02, 0x0e, 0x01, 0xcb, 0xfb, 0x45, + 0x01, 0xa9, 0x56, 0x39, 0x24, 0xa2, 0x4e, 0x81, 0x2f, 0x2a, 0x7b, + 0x9a, 0x1e, 0xe0, 0x88, 0x54, 0xd8, 0x13, 0x40, 0x02, 0x60, 0x8e, + 0x14, 0x78, 0xb4, 0xf1, 0x39, 0x6a, 0x10, 0xe0, 0x18, 0xa9, 0x10, + 0x23, 0x21, 0xe6, 0x0b, 0x21, 0xf2, 0xb8, 0x07, 0xbb, 0xbd, 0xea, + 0x0a, 0x38, 0x0a, 0xfd, 0x60, 0x8f, 0xf8, 0x42, 0xec, 0x50, 0x15, + 0x4f, 0x94, 0xbb, 0x0d, 0x0c, 0x00, 0x6b, 0x7c, 0x8e, 0xd9, 0xf9, + 0x1c, 0xb4, 0xf4, 0x39, 0x6a, 0xeb, 0x73, 0xd8, 0x9a, 0x06, 0x01, + 0x08, 0xf0, 0x1f, 0x73, 0xdc, 0x9e, 0x16, 0x09, 0xe8, 0xfe, 0x43, + 0x77, 0x07, 0x2e, 0x72, 0x3d, 0x01, 0xb9, 0xef, 0x71, 0x47, 0x6e, + 0x4a, 0x48, 0x40, 0x15, 0xc0, 0x5d, 0xe1, 0xdd, 0x4e, 0x00, 0x27, + 0x25, 0x72, 0xf7, 0x3f, 0xf6, 0xd8, 0x5d, 0x8a, 0x04, 0x6e, 0xf4, + 0x91, 0xce, 0xae, 0xbb, 0x83, 0x97, 0x39, 0x44, 0xe4, 0xc8, 0x78, + 0xf4, 0xd1, 0xdb, 0x52, 0x32, 0x4c, 0x6b, 0xd0, 0x2d, 0x09, 0x90, + 0x12, 0x72, 0xb4, 0xba, 0xa0, 0xff, 0x07, 0x00, 0x48, 0x04, 0x71, + 0x83, 0x9e, 0xcc, 0x51, 0xce, 0x00, 0x00, 0x00, 0x00, 0x49, 0x45, + 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82 +}; Neon::Neon() { - Events::processScriptsEvent += [this] { - if (!m_pNeonTexture) - { - m_pNeonTexture = Util::LoadTextureFromMemory((char *)neon_mask, sizeof(neon_mask)); - } - }; + Events::processScriptsEvent += [this] + { + if (!m_pNeonTexture) + { + m_pNeonTexture = Util::LoadTextureFromMemory((char*)neon_mask, sizeof(neon_mask)); + } + }; - Events::vehicleRenderEvent += [](CVehicle *pVeh) { - NeonData *data = &m_VehNeon.Get(pVeh); - if (data->m_bNeonInstalled && !pVeh->IsUpsideDown()) - { - CVector Pos = CModelInfo::GetModelInfo(pVeh->m_nModelIndex)->m_pColModel->m_boundBox.m_vecMin; - CVector center = pVeh->TransformFromObjectSpace(CVector(0.0f, 0.0f, 0.0f)); - CVector up = pVeh->TransformFromObjectSpace(CVector(0.0f, -Pos.y - data->m_fVal, 0.0f)) - center; - CVector right = pVeh->TransformFromObjectSpace(CVector(Pos.x + data->m_fVal, 0.0f, 0.0f)) - center; - CShadows::StoreShadowToBeRendered(5, m_pNeonTexture, ¢er, up.x, up.y, right.x, right.y, 180, - data->m_Color.r, data->m_Color.g, data->m_Color.b, 2.0f, false, 1.0f, 0, - true); + Events::vehicleRenderEvent += [](CVehicle* pVeh) + { + NeonData* data = &m_VehNeon.Get(pVeh); + if (data->m_bNeonInstalled && !pVeh->IsUpsideDown()) + { + CVector Pos = CModelInfo::GetModelInfo(pVeh->m_nModelIndex)->m_pColModel->m_boundBox.m_vecMin; + CVector center = pVeh->TransformFromObjectSpace(CVector(0.0f, 0.0f, 0.0f)); + CVector up = pVeh->TransformFromObjectSpace(CVector(0.0f, -Pos.y - data->m_fVal, 0.0f)) - center; + CVector right = pVeh->TransformFromObjectSpace(CVector(Pos.x + data->m_fVal, 0.0f, 0.0f)) - center; + CShadows::StoreShadowToBeRendered(5, m_pNeonTexture, ¢er, up.x, up.y, right.x, right.y, 180, data->m_Color.r, + data->m_Color.g, data->m_Color.b, 2.0f, false, 1.0f, 0, true); - if (data->m_bPulsing) - { - size_t delta = CTimer::m_snTimeInMilliseconds - CTimer::m_snPreviousTimeInMilliseconds; + if (data->m_bPulsing) + { + size_t delta = CTimer::m_snTimeInMilliseconds - CTimer::m_snPreviousTimeInMilliseconds; - if (data->m_fVal < 0.0f) - { - data->m_bIncrement = true; - } + if (data->m_fVal < 0.0f) + { + data->m_bIncrement = true; + } - if (data->m_fVal > 0.3f) - { - data->m_bIncrement = false; - } + if (data->m_fVal > 0.3f) + { + data->m_bIncrement = false; + } - if (data->m_bIncrement) - { - data->m_fVal += 0.0003f * delta; - } - else - { - data->m_fVal -= 0.0003f * delta; - } - } - } - }; + if (data->m_bIncrement) + { + data->m_fVal += 0.0003f * delta; + } + else + { + data->m_fVal -= 0.0003f * delta; + } + } + } + }; } Neon::~Neon() { - if (m_pNeonTexture) - { - RwTextureDestroy(m_pNeonTexture); - m_pNeonTexture = nullptr; - } + if (m_pNeonTexture) + { + RwTextureDestroy(m_pNeonTexture); + m_pNeonTexture = nullptr; + } } -bool Neon::IsNeonInstalled(CVehicle *pVeh) +bool Neon::IsNeonInstalled(CVehicle* pVeh) { - return m_VehNeon.Get(pVeh).m_bNeonInstalled; + return m_VehNeon.Get(pVeh).m_bNeonInstalled; } -bool Neon::IsPulsingEnabled(CVehicle *pVeh) +bool Neon::IsPulsingEnabled(CVehicle* pVeh) { - return m_VehNeon.Get(pVeh).m_bPulsing; + return m_VehNeon.Get(pVeh).m_bPulsing; } -void Neon::SetPulsing(CVehicle *pVeh, bool state) +void Neon::SetPulsing(CVehicle* pVeh, bool state) { - m_VehNeon.Get(pVeh).m_bPulsing = state; + m_VehNeon.Get(pVeh).m_bPulsing = state; } -void Neon::InstallNeon(CVehicle *pVeh, int red, int green, int blue) +void Neon::InstallNeon(CVehicle* pVeh, int red, int green, int blue) { - CRGBA &color = m_VehNeon.Get(pVeh).m_Color; + CRGBA& color = m_VehNeon.Get(pVeh).m_Color; - color.r = red; - color.g = green; - color.b = blue; - color.a = 255; + color.r = red; + color.g = green; + color.b = blue; + color.a = 255; - m_VehNeon.Get(pVeh).m_bNeonInstalled = true; + m_VehNeon.Get(pVeh).m_bNeonInstalled = true; } -void Neon::RemoveNeon(CVehicle *pVeh) +void Neon::RemoveNeon(CVehicle* pVeh) { - m_VehNeon.Get(pVeh).m_bNeonInstalled = false; + m_VehNeon.Get(pVeh).m_bNeonInstalled = false; } + + diff --git a/src/neon.h b/src/neon.h index 10f8b45..a6a59b1 100644 --- a/src/neon.h +++ b/src/neon.h @@ -4,32 +4,32 @@ class Neon { private: - class NeonData - { - public: - CRGBA m_Color; - bool m_bNeonInstalled; - float m_fVal; - bool m_bIncrement; - bool m_bPulsing; + class NeonData + { + public: + CRGBA m_Color; + bool m_bNeonInstalled; + float m_fVal; + bool m_bIncrement; + bool m_bPulsing; - NeonData(CVehicle *pVeh) - { - m_bNeonInstalled = false; - m_fVal = 0.0; - m_bIncrement = true; - } - }; + NeonData(CVehicle* pVeh) + { + m_bNeonInstalled = false; + m_fVal = 0.0; + m_bIncrement = true; + } + }; - static inline RwTexture *m_pNeonTexture = nullptr; // pointer to the neon mask texture - static inline VehicleExtendedData m_VehNeon; + static inline RwTexture* m_pNeonTexture = nullptr; // pointer to the neon mask texture + static inline VehicleExtendedData m_VehNeon; public: - Neon(); - ~Neon(); - static void InstallNeon(CVehicle *veh, int red, int green, int blue); - static bool IsNeonInstalled(CVehicle *veh); - static bool IsPulsingEnabled(CVehicle *veh); - static void SetPulsing(CVehicle *veh, bool state); - static void RemoveNeon(CVehicle *veh); + Neon(); + ~Neon(); + static void InstallNeon(CVehicle* veh, int red, int green, int blue); + static bool IsNeonInstalled(CVehicle* veh); + static bool IsPulsingEnabled(CVehicle* veh); + static void SetPulsing(CVehicle* veh, bool state); + static void RemoveNeon(CVehicle* veh); }; diff --git a/src/paint.cpp b/src/paint.cpp index 8fdf735..6df54e9 100644 --- a/src/paint.cpp +++ b/src/paint.cpp @@ -22,277 +22,279 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // SOFTWARE. +#include "pch.h" #include "paint.h" #include "NodeName.h" -#include "pch.h" #include "util.h" Paint::Paint() { - Events::vehicleRenderEvent.before += [](CVehicle *pVeh) { - VehData &data = m_VehData.Get(pVeh); + Events::vehicleRenderEvent.before += [](CVehicle* pVeh) + { + VehData& data = m_VehData.Get(pVeh); - // reset custom color if color id changed - if (pVeh->m_nPrimaryColor != data.primary_color || pVeh->m_nSecondaryColor != data.secondary_color) - { - for (auto &it : data.materialProperties) - data.resetMaterialColor(it.first); + // reset custom color if color id changed + if (pVeh->m_nPrimaryColor != data.primary_color + || pVeh->m_nSecondaryColor != data.secondary_color) + { + for (auto& it : data.materialProperties) + data.resetMaterialColor(it.first); - data.primary_color = pVeh->m_nPrimaryColor; - data.secondary_color = pVeh->m_nSecondaryColor; - } + data.primary_color = pVeh->m_nPrimaryColor; + data.secondary_color = pVeh->m_nSecondaryColor; + } - for (auto &it : data.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; - if (tex) - { - it.second._originalTexture = it.first->texture; - it.first->texture = tex; - } - else - { - it.second._retexture = false; - } - } - } - }; - - ThiscallEvent, PRIORITY_BEFORE, ArgPickN, void(CVehicle *)> - vehicleResetAfterRender; - vehicleResetAfterRender += [](CVehicle *pVeh) { - for (auto &it : m_VehData.Get(pVeh).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; - } - } - }; + for (auto& it : data.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; + if (tex) + { + it.second._originalTexture = it.first->texture; + it.first->texture = tex; + } + else + { + it.second._retexture = false; + } + } + } + }; + + ThiscallEvent, PRIORITY_BEFORE, ArgPickN, void(CVehicle*)> vehicleResetAfterRender; + vehicleResetAfterRender += [](CVehicle* pVeh) + { + for (auto& it : m_VehData.Get(pVeh).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; + } + } + }; } -void Paint::VehData::setMaterialColor(RpMaterial *material, RpGeometry *geometry, RwRGBA color, bool filter_mat) +void Paint::VehData::setMaterialColor(RpMaterial* material, RpGeometry* geometry, RwRGBA color, bool filter_mat) { - auto &matProps = materialProperties[material]; + auto& matProps = materialProperties[material]; - 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; - } + 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 Paint::VehData::setMaterialTexture(RpMaterial *material, RwTexture *texture, bool filter_mat) +void Paint::VehData::setMaterialTexture(RpMaterial* material, RwTexture* texture, bool filter_mat) { - auto &matProps = materialProperties[material]; + auto& matProps = materialProperties[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; - } + 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 Paint::VehData::resetMaterialColor(RpMaterial *material) +void Paint::VehData::resetMaterialColor(RpMaterial* material) { - auto &matProps = materialProperties[material]; - matProps._recolor = false; - matProps._color = {0, 0, 0, 0}; + auto& matProps = materialProperties[material]; + matProps._recolor = false; + matProps._color = {0, 0, 0, 0}; } -void Paint::VehData::resetMaterialTexture(RpMaterial *material) +void Paint::VehData::resetMaterialTexture(RpMaterial* material) { - auto &matProps = materialProperties[material]; - matProps._retexture = false; - matProps._texture = nullptr; + auto& matProps = materialProperties[material]; + matProps._retexture = false; + matProps._texture = nullptr; } -void Paint::NodeWrapperRecursive(RwFrame *frame, CVehicle *pVeh, std::function func) +void Paint::NodeWrapperRecursive(RwFrame* frame, CVehicle* pVeh, std::function func) { - if (frame) - { - func(frame); + if (frame) + { + func(frame); - if (RwFrame *newFrame = frame->child) - NodeWrapperRecursive(newFrame, pVeh, func); - if (RwFrame *newFrame = frame->next) - NodeWrapperRecursive(newFrame, pVeh, func); - } - return; + if (RwFrame* newFrame = frame->child) + NodeWrapperRecursive(newFrame, pVeh, func); + if (RwFrame* newFrame = frame->next) + NodeWrapperRecursive(newFrame, pVeh, func); + } + return; } -void Paint::UpdateNodeListRecursive(CVehicle *pVeh) +void Paint::UpdateNodeListRecursive(CVehicle* pVeh) { - RwFrame *frame = (RwFrame *)pVeh->m_pRwClump->object.parent; + RwFrame* frame = (RwFrame*)pVeh->m_pRwClump->object.parent; - NodeWrapperRecursive(frame, pVeh, [](RwFrame *frame) { - const std::string name = GetFrameNodeName(frame); + 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); - }); + 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) +void Paint::SetNodeColor(CVehicle* pVeh, std::string node_name, CRGBA color, bool filter_mat) { - RwFrame *frame = (RwFrame *)pVeh->m_pRwClump->object.parent; + RwFrame* frame = (RwFrame*)pVeh->m_pRwClump->object.parent; - NodeWrapperRecursive(frame, pVeh, [&](RwFrame *frame) { - const std::string name = GetFrameNodeName(frame); + NodeWrapperRecursive(frame, pVeh, [&](RwFrame* frame) + { + const std::string name = GetFrameNodeName(frame); - struct ST - { - CRGBA _color; - bool _filter; - } st; + struct ST + { + CRGBA _color; + bool _filter; + } st; - st._color = color; - st._filter = filter_mat; + 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(object); + if (node_name == "Default" || node_name == name) + { + RwFrameForAllObjects(frame, [](RwObject* object, void* data) -> RwObject* + { + if (object->type == rpATOMIC) + { + RpAtomic* atomic = reinterpret_cast(object); - ST *st = reinterpret_cast(data); - CRGBA *color = &st->_color; - bool filter_mat = st->_filter; + ST* st = reinterpret_cast(data); + CRGBA* color = &st->_color; + bool filter_mat = st->_filter; - VehData &data = m_VehData.Get(FindPlayerPed()->m_pVehicle); + VehData& data = m_VehData.Get(FindPlayerPed()->m_pVehicle); - for (int i = 0; i < atomic->geometry->matList.numMaterials; ++i) - data.setMaterialColor(atomic->geometry->matList.materials[i], atomic->geometry, - {color->r, color->g, color->b, 255}, filter_mat); - } - return object; - }, - &st); - } - }); + for (int i = 0; i < atomic->geometry->matList.numMaterials; ++i) + data.setMaterialColor(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) +void Paint::SetNodeTexture(CVehicle* pVeh, std::string node_name, std::string texturename, bool filter_mat) { - RwFrame *frame = (RwFrame *)pVeh->m_pRwClump->object.parent; - RwTexture *texture = nullptr; + RwFrame* frame = (RwFrame*)pVeh->m_pRwClump->object.parent; + RwTexture* texture = nullptr; - for (auto const &tex : m_TextureData.m_ImagesList) - { - if (tex.get()->m_FileName == texturename) - { - texture = tex.get()->m_pRwTexture; - break; - } - } + for (auto const& tex : m_TextureData.m_ImagesList) + { + if (tex.get()->m_FileName == texturename) + { + texture = tex.get()->m_pRwTexture; + break; + } + } - NodeWrapperRecursive(frame, pVeh, [&](RwFrame *frame) { - const std::string name = GetFrameNodeName(frame); + NodeWrapperRecursive(frame, pVeh, [&](RwFrame* frame) + { + const std::string name = GetFrameNodeName(frame); - struct ST - { - RwTexture *_tex; - bool _filter; - } st; + struct ST + { + RwTexture* _tex; + bool _filter; + } st; - st._tex = texture; - st._filter = filter_mat; + st._tex = texture; + 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(object); + if (node_name == "Default" || node_name == name) + { + RwFrameForAllObjects(frame, [](RwObject* object, void* data) -> RwObject* + { + if (object->type == rpATOMIC) + { + RpAtomic* atomic = reinterpret_cast(object); - ST *st = reinterpret_cast(data); - VehData &data = m_VehData.Get(FindPlayerPed()->m_pVehicle); + ST* st = reinterpret_cast(data); + VehData& data = m_VehData.Get(FindPlayerPed()->m_pVehicle); - for (int i = 0; i < atomic->geometry->matList.numMaterials; ++i) - { - data.setMaterialTexture(atomic->geometry->matList.materials[i], st->_tex, st->_filter); - } - } - return object; - }, - &st); - } - }); + for (int i = 0; i < atomic->geometry->matList.numMaterials; ++i) + { + data.setMaterialTexture(atomic->geometry->matList.materials[i], st->_tex, + st->_filter); + } + } + return object; + }, &st); + } + }); } -void Paint::ResetNodeColor(CVehicle *pVeh, std::string node_name) +void Paint::ResetNodeColor(CVehicle* pVeh, std::string node_name) { - RwFrame *frame = (RwFrame *)pVeh->m_pRwClump->object.parent; + RwFrame* frame = (RwFrame*)pVeh->m_pRwClump->object.parent; - NodeWrapperRecursive(frame, pVeh, [&](RwFrame *frame) { - const std::string name = GetFrameNodeName(frame); + 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(object); - VehData &data = m_VehData.Get(FindPlayerPed()->m_pVehicle); + if (node_name == "Default" || node_name == name) + { + RwFrameForAllObjects(frame, [](RwObject* object, void* data) -> RwObject* + { + if (object->type == rpATOMIC) + { + RpAtomic* atomic = reinterpret_cast(object); + VehData& data = m_VehData.Get(FindPlayerPed()->m_pVehicle); - for (int i = 0; i < atomic->geometry->matList.numMaterials; ++i) - data.resetMaterialColor(atomic->geometry->matList.materials[i]); - } - return object; - }, - nullptr); - } - }); + for (int i = 0; i < atomic->geometry->matList.numMaterials; ++i) + data.resetMaterialColor(atomic->geometry->matList.materials[i]); + } + return object; + }, nullptr); + } + }); } -void Paint::ResetNodeTexture(CVehicle *pVeh, std::string node_name) +void Paint::ResetNodeTexture(CVehicle* pVeh, std::string node_name) { - RwFrame *frame = (RwFrame *)pVeh->m_pRwClump->object.parent; + RwFrame* frame = (RwFrame*)pVeh->m_pRwClump->object.parent; - NodeWrapperRecursive(frame, pVeh, [&](RwFrame *frame) { - const std::string name = GetFrameNodeName(frame); + 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(object); + if (node_name == "Default" || node_name == name) + { + RwFrameForAllObjects(frame, [](RwObject* object, void* data) -> RwObject* + { + if (object->type == rpATOMIC) + { + RpAtomic* atomic = reinterpret_cast(object); - VehData &data = m_VehData.Get(FindPlayerPed()->m_pVehicle); + VehData& data = m_VehData.Get(FindPlayerPed()->m_pVehicle); - for (int i = 0; i < atomic->geometry->matList.numMaterials; ++i) - data.resetMaterialTexture(atomic->geometry->matList.materials[i]); - } - return object; - }, - nullptr); - } - }); + for (int i = 0; i < atomic->geometry->matList.numMaterials; ++i) + data.resetMaterialTexture(atomic->geometry->matList.materials[i]); + } + return object; + }, nullptr); + } + }); } diff --git a/src/paint.h b/src/paint.h index 21f406e..fe4552d 100644 --- a/src/paint.h +++ b/src/paint.h @@ -27,59 +27,64 @@ class Paint { private: - // store vehicle specific data - struct VehData - { - struct MaterialProperties - { - MaterialProperties() - : _color{0, 0, 0, 0}, _recolor(false), _retexture(false), - _geometry(nullptr), _originalColor{0, 0, 0, 0}, _originalTexture(nullptr), _originalGeometryFlags(0) - { - } + // store vehicle specific data + struct VehData + { + struct MaterialProperties + { + MaterialProperties() : + _color{0, 0, 0, 0}, + _recolor(false), + _retexture(false), + _geometry(nullptr), + _originalColor{0, 0, 0, 0}, + _originalTexture(nullptr), + _originalGeometryFlags(0) + { + } - RwRGBA _color; - RwTexture *_texture; - bool _recolor; - bool _retexture; - RpGeometry *_geometry; - RwRGBA _originalColor; - RwTexture *_originalTexture; - RwInt32 _originalGeometryFlags; - }; + RwRGBA _color; + RwTexture* _texture; + bool _recolor; + bool _retexture; + RpGeometry* _geometry; + RwRGBA _originalColor; + RwTexture* _originalTexture; + RwInt32 _originalGeometryFlags; + }; - // carcols color id - uchar primary_color = 0; - uchar secondary_color = 0; - std::unordered_map materialProperties; + // carcols color id + uchar primary_color = 0; + uchar secondary_color = 0; + std::unordered_map materialProperties; - VehData(CVehicle *veh) - { - primary_color = veh->m_nPrimaryColor; - secondary_color = veh->m_nSecondaryColor; - } + VehData(CVehicle* veh) + { + primary_color = veh->m_nPrimaryColor; + secondary_color = veh->m_nSecondaryColor; + } - void setMaterialColor(RpMaterial *material, RpGeometry *geometry, RwRGBA color, bool filter_mat = false); - void setMaterialTexture(RpMaterial *material, RwTexture *texture, bool filter_mat = false); - void resetMaterialColor(RpMaterial *material); - void resetMaterialTexture(RpMaterial *material); - }; - static inline VehicleExtendedData m_VehData; + void setMaterialColor(RpMaterial* material, RpGeometry* geometry, RwRGBA color, bool filter_mat = false); + void setMaterialTexture(RpMaterial* material, RwTexture* texture, bool filter_mat = false); + void resetMaterialColor(RpMaterial* material); + void resetMaterialTexture(RpMaterial* material); + }; + static inline VehicleExtendedData m_VehData; protected: - static inline ResourceStore m_TextureData{"textures", eResourceType::TYPE_IMAGE, ImVec2(100, 80)}; + static inline ResourceStore m_TextureData { "textures", eResourceType::TYPE_IMAGE, ImVec2(100, 80) }; - struct veh_nodes - { - static inline std::vector names_vec{"Default"}; - static inline std::string selected = "Default"; - }; + struct veh_nodes + { + static inline std::vector names_vec{"Default"}; + static inline std::string selected = "Default"; + }; - Paint(); - static void UpdateNodeListRecursive(CVehicle *pVeh); - static void NodeWrapperRecursive(RwFrame *frame, CVehicle *pVeh, std::function 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); + Paint(); + static void UpdateNodeListRecursive(CVehicle* pVeh); + static void NodeWrapperRecursive(RwFrame* frame, CVehicle* pVeh, std::function 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); }; diff --git a/src/pch.h b/src/pch.h index 30fe823..0ce49ea 100644 --- a/src/pch.h +++ b/src/pch.h @@ -1,5 +1,5 @@ #pragma once -#pragma warning(disable : 4503 4244 4005) +#pragma warning(disable:4503 4244 4005) #define INPUT_BUFFER_SIZE 64 #define SPAWN_PED_LIMIT 20 @@ -14,74 +14,72 @@ #define BY_GAME(sa, vc, iii) iii #endif +#include #include #include -#include #include #include #include -#include #include +#include #include #include #include +#include #include -#include #include +#include #include #include #include #include +#include #include #include #include -#include #include +#include #include #include #include -#include -#include -#include #include -#include +#include +#include #ifndef GTA3 #include +#include #include #include -#include - #endif #ifdef GTASA #include #include #include -#include #include #include #include - +#include #endif #include "../depend/fla/IDaccess.h" #include "../depend/imgui/imgui.h" -#include "hotkeys.h" #include "json.h" -#include "resourcestore.h" +#include "hotkeys.h" #include "vKeys.h" +#include "resourcestore.h" -using CallbackTable = std::vector>; +using CallbackTable = std::vector>; using namespace plugin; enum eRenderer { - Render_DirectX9, - Render_DirectX11, - Render_Unknown + Render_DirectX9, + Render_DirectX11, + Render_Unknown }; static eRenderer gRenderer = Render_Unknown; @@ -94,13 +92,13 @@ extern CJson gConfig; static void SetHelpMessage(const char *message, bool b1, bool b2, bool b3) { #if GTASA - CHud::SetHelpMessage(message, b1, b2, b3); + CHud::SetHelpMessage(message, b1, b2, b3); #elif GTAVC - CHud::SetHelpMessage(message, b1, b2); + CHud::SetHelpMessage(message, b1, b2); #else // GTA3 - const size_t cSize = strlen(message) + 1; - wchar_t *wc = new wchar_t[cSize]; - mbstowcs(wc, message, cSize); - CHud::SetHelpMessage((wchar_t *)wc, b1); + const size_t cSize = strlen(message)+1; + wchar_t* wc = new wchar_t[cSize]; + mbstowcs (wc, message, cSize); + CHud::SetHelpMessage((wchar_t*)wc, b1); #endif } \ No newline at end of file diff --git a/src/ped.cpp b/src/ped.cpp index 5cb6aea..4cf20a8 100644 --- a/src/ped.cpp +++ b/src/ped.cpp @@ -1,5 +1,5 @@ -#include "ped.h" #include "pch.h" +#include "ped.h" #include "ui.h" #include "util.h" #include "weapon.h" @@ -12,395 +12,395 @@ Ped::Ped() { #ifdef GTASA - if (GetModuleHandle("ExGangWars.asi")) - { - m_bExGangWarsInstalled = true; - } + if (GetModuleHandle("ExGangWars.asi")) + { + m_bExGangWarsInstalled = true; + } - /* - Taken from gta chaos mod by Lordmau5 - https://github.com/gta-chaos-mod/Trilogy-ASI-Script + /* + Taken from gta chaos mod by Lordmau5 + https://github.com/gta-chaos-mod/Trilogy-ASI-Script - TODO: Implement in VC too - */ - Events::pedRenderEvent += [](CPed *ped) { - if (m_bBigHead || m_bThinBody) - { - auto animHier = GetAnimHierarchyFromSkinClump(ped->m_pRwClump); - auto matrices = RpHAnimHierarchyGetMatrixArray(animHier); + TODO: Implement in VC too + */ + Events::pedRenderEvent += [](CPed *ped) + { - RwV3d scale = {0.7f, 0.7f, 0.7f}; - if (m_bThinBody) - { - for (int i = 1; i <= 52; i++) - { - RwMatrixScale(&matrices[RpHAnimIDGetIndex(animHier, i)], &scale, rwCOMBINEPRECONCAT); - } - } - scale = {3.0f, 3.0f, 3.0f}; - if (m_bBigHead) - { - for (int i = BONE_NECK; i <= BONE_HEAD; i++) - { - RwMatrixScale(&matrices[RpHAnimIDGetIndex(animHier, i)], &scale, rwCOMBINEPRECONCAT); - } - } - } - }; + if (m_bBigHead || m_bThinBody) + { + auto animHier = GetAnimHierarchyFromSkinClump (ped->m_pRwClump); + auto matrices = RpHAnimHierarchyGetMatrixArray (animHier); + + RwV3d scale = {0.7f, 0.7f, 0.7f}; + if (m_bThinBody) + { + for (int i = 1; i <= 52; i++) + { + RwMatrixScale (&matrices[RpHAnimIDGetIndex (animHier, i)], &scale, rwCOMBINEPRECONCAT); + } + } + scale = {3.0f, 3.0f, 3.0f}; + if (m_bBigHead) + { + for (int i = BONE_NECK; i <= BONE_HEAD; i++) + { + RwMatrixScale (&matrices[RpHAnimIDGetIndex (animHier, i)], &scale, rwCOMBINEPRECONCAT); + } + } + } + }; #endif } Ped::~Ped() { - for (CPed *ped : m_SpawnPed::m_List) - { - CWorld::Remove(ped); - ped->Remove(); - } + for (CPed* ped : m_SpawnPed::m_List) + { + CWorld::Remove(ped); + ped->Remove(); + } } #ifdef GTASA -void Ped::SpawnPed(std::string &model) +void Ped::SpawnPed(std::string& model) #else // GTA3 & GTAVC -void Ped::SpawnPed(std::string &cat, std::string &name, std::string &model) +void Ped::SpawnPed(std::string& cat, std::string& name, std::string& model) #endif { - if (m_SpawnPed::m_List.size() == SPAWN_PED_LIMIT) - { - SetHelpMessage("Max limit reached", false, false, false); - return; - } + if (m_SpawnPed::m_List.size() == SPAWN_PED_LIMIT) + { + SetHelpMessage("Max limit reached", false, false, false); + return; + } - if (BY_GAME(m_PedData.m_pJson->m_Data.contains(model), true, true)) - { - CPlayerPed *player = FindPlayerPed(); - CVector pos = player->GetPosition(); - pos.y += 1; + if (BY_GAME(m_PedData.m_pJson->m_Data.contains(model), true, true)) + { + CPlayerPed* player = FindPlayerPed(); + CVector pos = player->GetPosition(); + pos.y += 1; - CPed *ped; - int hplayer; - static size_t currentSlot = 1; + CPed* ped; + int hplayer; + static size_t currentSlot = 1; #ifdef GTASA - if (m_SpecialPedJson.m_Data.contains(model)) - { - std::string name; - if (m_SpecialPedJson.m_Data.contains(model)) - name = m_SpecialPedJson.m_Data[model].get().c_str(); - else - name = model; + if (m_SpecialPedJson.m_Data.contains(model)) + { + std::string name; + if (m_SpecialPedJson.m_Data.contains(model)) + name = m_SpecialPedJson.m_Data[model].get().c_str(); + else + name = model; - CStreaming::RequestSpecialChar(currentSlot, name.c_str(), PRIORITY_REQUEST); - CStreaming::LoadAllRequestedModels(true); + CStreaming::RequestSpecialChar(currentSlot, name.c_str(), PRIORITY_REQUEST); + CStreaming::LoadAllRequestedModels(true); - Command(m_SpawnPed::m_nSelectedPedType + 4, 290 + currentSlot, pos.x, pos.y, - pos.z + 1, &hplayer); - CStreaming::SetSpecialCharIsDeletable(290 + currentSlot); + Command(m_SpawnPed::m_nSelectedPedType + 4, 290 + currentSlot, pos.x, pos.y, pos.z + 1, &hplayer); + CStreaming::SetSpecialCharIsDeletable(290 + currentSlot); - // SA has 10 slots - ++currentSlot; - if (currentSlot > 10) - { - currentSlot = 1; - } - } + // SA has 10 slots + ++currentSlot; + if (currentSlot > 10) + { + currentSlot = 1; + } + } #else // GTA3 & GTAVC - if (cat == "Special") // Special model - { + if (cat == "Special") // Special model + { #ifdef GTA3 - SetHelpMessage("Spawning special peds isn't implemented yet.", false, false, false); - return; + SetHelpMessage("Spawning special peds isn't implemented yet.", false, false, false); + return; #else // GTAVC - Command(currentSlot, model.c_str()); - Command(); + Command(currentSlot, model.c_str()); + Command(); + + Command(m_SpawnPed::m_nSelectedPedType + 4, 108+currentSlot, pos.x, pos.y, pos.z + 1, &hplayer); + Command(currentSlot); - Command(m_SpawnPed::m_nSelectedPedType + 4, 108 + currentSlot, pos.x, pos.y, - pos.z + 1, &hplayer); - Command(currentSlot); - - ++currentSlot; - if (currentSlot > 21) - { - currentSlot = 1; - } + ++currentSlot; + if (currentSlot > 21) + { + currentSlot = 1; + } #endif - } + } #endif - else - { - int iModel = std::stoi(model); - CStreaming::RequestModel(iModel, eStreamingFlags::PRIORITY_REQUEST); - CStreaming::LoadAllRequestedModels(false); + else + { + int iModel = std::stoi(model); + CStreaming::RequestModel(iModel, eStreamingFlags::PRIORITY_REQUEST); + CStreaming::LoadAllRequestedModels(false); - Command(m_SpawnPed::m_nSelectedPedType + 4, iModel, pos.x, pos.y, pos.z + 1, - &hplayer); - CStreaming::SetModelIsDeletable(iModel); - } + Command(m_SpawnPed::m_nSelectedPedType + 4, iModel, pos.x, pos.y, pos.z + 1, &hplayer); + CStreaming::SetModelIsDeletable(iModel); + } - ped = CPools::GetPed(hplayer); + ped = CPools::GetPed(hplayer); - if (m_SpawnPed::m_bPedMove) - { - m_SpawnPed::m_List.push_back(ped); - } - else - { - Command(hplayer); - } - ped->m_nPedFlags.bPedIsBleeding = m_SpawnPed::m_bPedBleed; + if (m_SpawnPed::m_bPedMove) + { + m_SpawnPed::m_List.push_back(ped); + } + else + { + Command(hplayer); + } + ped->m_nPedFlags.bPedIsBleeding = m_SpawnPed::m_bPedBleed; #ifdef GTA3 - ped->m_nWepAccuracy = m_SpawnPed::m_nAccuracy; + ped->m_nWepAccuracy = m_SpawnPed::m_nAccuracy; #else - ped->m_nWeaponAccuracy = m_SpawnPed::m_nAccuracy; + ped->m_nWeaponAccuracy = m_SpawnPed::m_nAccuracy; #endif - ped->m_fHealth = m_SpawnPed::m_nPedHealth; + ped->m_fHealth = m_SpawnPed::m_nPedHealth; #ifdef GTASA - if (m_SpawnPed::m_nWeaponId != 0) - { - int model = 0; - Command(m_SpawnPed::m_nWeaponId, &model); - CStreaming::RequestModel(model, PRIORITY_REQUEST); - CStreaming::LoadAllRequestedModels(false); - Command(hplayer, m_SpawnPed::m_nWeaponId, 999); - } + if (m_SpawnPed::m_nWeaponId != 0) + { + int model = 0; + Command(m_SpawnPed::m_nWeaponId, &model); + CStreaming::RequestModel(model, PRIORITY_REQUEST); + CStreaming::LoadAllRequestedModels(false); + Command(hplayer, m_SpawnPed::m_nWeaponId, 999); + } #endif - } + } } void Ped::Draw() { - if (ImGui::BeginTabBar("Ped", ImGuiTabBarFlags_NoTooltip + ImGuiTabBarFlags_FittingPolicyScroll)) - { - if (ImGui::BeginTabItem("Checkboxes")) - { - ImGui::Spacing(); - ImGui::BeginChild("CheckboxesChild"); - ImGui::Columns(2, 0, false); + if (ImGui::BeginTabBar("Ped", ImGuiTabBarFlags_NoTooltip + ImGuiTabBarFlags_FittingPolicyScroll)) + { + if (ImGui::BeginTabItem("Checkboxes")) + { + ImGui::Spacing(); + ImGui::BeginChild("CheckboxesChild"); + ImGui::Columns(2, 0, false); #ifdef GTASA - Ui::CheckboxWithHint("Big head effect", &m_bBigHead); - 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); + Ui::CheckboxWithHint("Big head effect", &m_bBigHead); + 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(); + ImGui::NextColumn(); - Ui::CheckboxAddress("Peds mayhem", 0x96913E); - Ui::CheckboxAddress("Peds attack with rockets", 0x969158); - Ui::CheckboxAddress("Peds riot", 0x969175); - Ui::CheckboxAddress("Slut magnet", 0x96915D); - Ui::CheckboxWithHint("Thin body effect", &m_bThinBody); + Ui::CheckboxAddress("Peds mayhem", 0x96913E); + Ui::CheckboxAddress("Peds attack with rockets", 0x969158); + Ui::CheckboxAddress("Peds riot", 0x969175); + Ui::CheckboxAddress("Slut magnet", 0x96915D); + Ui::CheckboxWithHint("Thin body effect", &m_bThinBody); #elif GTAVC - Ui::CheckboxAddress("No prostitutes", 0xA10B99); - Ui::CheckboxAddress("Slut magnet", 0xA10B5F); - ImGui::NextColumn(); - Ui::CheckboxAddress("Weapons for all", 0xA10AB3); + Ui::CheckboxAddress("No prostitutes", 0xA10B99); + Ui::CheckboxAddress("Slut magnet", 0xA10B5F); + ImGui::NextColumn(); + Ui::CheckboxAddress("Weapons for all", 0xA10AB3); #else // GTA3 - // Bad idea lol - static bool pedsMayhem; - if (Ui::CheckboxWithHint("Peds mayhem", &pedsMayhem)) - { - Call<0x4911C0>(); - } - static bool everyoneAttacksPlayer; - if (Ui::CheckboxWithHint("Everyone attacks players", &everyoneAttacksPlayer)) - { - Call<0x491270>(); - } - ImGui::NextColumn(); - Ui::CheckboxAddress("Nasty limbs", 0x95CD44); - Ui::CheckboxAddress("Weapons for all", 0x95CCF6); + // Bad idea lol + static bool pedsMayhem; + if (Ui::CheckboxWithHint("Peds mayhem", &pedsMayhem)) + { + Call<0x4911C0>(); + } + static bool everyoneAttacksPlayer; + if (Ui::CheckboxWithHint("Everyone attacks players", &everyoneAttacksPlayer)) + { + Call<0x491270>(); + } + ImGui::NextColumn(); + Ui::CheckboxAddress("Nasty limbs", 0x95CD44); + Ui::CheckboxAddress("Weapons for all", 0x95CCF6); #endif - ImGui::Columns(1); - ImGui::EndChild(); + ImGui::Columns(1); + ImGui::EndChild(); - ImGui::EndTabItem(); - } - if (ImGui::BeginTabItem("Menus")) - { - ImGui::Spacing(); - ImGui::BeginChild("MenusChild"); + ImGui::EndTabItem(); + } + if (ImGui::BeginTabItem("Menus")) + { + ImGui::Spacing(); + ImGui::BeginChild("MenusChild"); #ifdef GTASA - 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); - } + 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::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 szone = CZone(); - CZone *pZone = &szone; + ImGui::PushItemWidth(ImGui::GetWindowContentRegionWidth() / 2); + for (int i = 0; i != 10; ++i) + { + CVector pos = FindPlayerPed()->GetPosition(); + CZone szone = CZone(); + CZone* pZone = &szone; - CZoneInfo *zoneInfo = CTheZones::GetZoneInfo(&pos, &pZone); - int density = zoneInfo->m_nGangDensity[i]; + CZoneInfo* zoneInfo = CTheZones::GetZoneInfo(&pos, &pZone); + int density = zoneInfo->m_nGangDensity[i]; - if (ImGui::SliderInt(m_GangNames[i].c_str(), &density, 0, 127)) - { - zoneInfo->m_nGangDensity[i] = static_cast(density); - Command(); - CGangWars::bGangWarsActive = true; - } - } - ImGui::PopItemWidth(); - ImGui::Spacing(); + if (ImGui::SliderInt(m_GangNames[i].c_str(), &density, 0, 127)) + { + zoneInfo->m_nGangDensity[i] = static_cast(density); + Command(); + CGangWars::bGangWarsActive = true; + } + } + ImGui::PopItemWidth(); + ImGui::Spacing(); - if (!m_bExGangWarsInstalled) - { - 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); - } - } + if (!m_bExGangWarsInstalled) + { + 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(); - } + ImGui::Spacing(); + ImGui::Separator(); + } #endif - Ui::EditReference("Pedestrian density multiplier", CPopulation::PedDensityMultiplier, 0, 1, 10); + Ui::EditReference("Pedestrian density multiplier", CPopulation::PedDensityMultiplier, 0, 1, 10); #ifdef GTASA - if (ImGui::CollapsingHeader("Recruit anyone")) - { - static std::vector selectWeapon{ - {"9mm", 0x96917C}, {"AK47", 0x96917D}, {"Rockets", 0x96917E}}; - Ui::RadioButtonAddress("Select weapon", selectWeapon); - ImGui::Spacing(); - ImGui::Separator(); - } + if (ImGui::CollapsingHeader("Recruit anyone")) + { + static std::vector selectWeapon{ + {"9mm", 0x96917C}, {"AK47", 0x96917D}, {"Rockets", 0x96917E} + }; + Ui::RadioButtonAddress("Select weapon", selectWeapon); + ImGui::Spacing(); + ImGui::Separator(); + } #endif - if (ImGui::CollapsingHeader("Remove peds in radius")) - { - ImGui::InputInt("Radius", &m_nPedRemoveRadius); - ImGui::Spacing(); - if (ImGui::Button("Remove peds", Ui::GetSize(1))) - { - CPlayerPed *player = FindPlayerPed(); - for (CPed *ped : CPools::ms_pPedPool) - { - if (DistanceBetweenPoints(ped->GetPosition(), player->GetPosition()) < m_nPedRemoveRadius && - ped->m_pVehicle == nullptr && ped != player) - { - Command(CPools::GetPedRef(ped)); - } - } - } - 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 : m_SpawnPed::m_List) - { - CWorld::Remove(ped); - ped->Remove(); - } - m_SpawnPed::m_List.clear(); - } - ImGui::Spacing(); - if (ImGui::BeginTabBar("SpawnPedBar")) - { - ImGui::Spacing(); + if (ImGui::CollapsingHeader("Remove peds in radius")) + { + ImGui::InputInt("Radius", &m_nPedRemoveRadius); + ImGui::Spacing(); + if (ImGui::Button("Remove peds", Ui::GetSize(1))) + { + CPlayerPed* player = FindPlayerPed(); + for (CPed* ped : CPools::ms_pPedPool) + { + if (DistanceBetweenPoints(ped->GetPosition(), player->GetPosition()) < m_nPedRemoveRadius + && ped->m_pVehicle == nullptr && ped != player) + { + Command(CPools::GetPedRef(ped)); + } + } + } + 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 : m_SpawnPed::m_List) + { + CWorld::Remove(ped); + ped->Remove(); + } + m_SpawnPed::m_List.clear(); + } + ImGui::Spacing(); + if (ImGui::BeginTabBar("SpawnPedBar")) + { + ImGui::Spacing(); - if (ImGui::BeginTabItem("Spawner")) - { - ImGui::Spacing(); + if (ImGui::BeginTabItem("Spawner")) + { + ImGui::Spacing(); #ifdef GTASA - Ui::DrawImages(m_PedData, SpawnPed, nullptr, - [](std::string str) { return m_PedData.m_pJson->m_Data[str].get(); }); + Ui::DrawImages(m_PedData, SpawnPed, nullptr, + [](std::string str) { return m_PedData.m_pJson->m_Data[str].get(); }); #else // GTA3 & GTAVC - Ui::DrawJSON(m_PedData, SpawnPed, nullptr); + Ui::DrawJSON(m_PedData, SpawnPed, nullptr); #endif - ImGui::EndTabItem(); - } - if (ImGui::BeginTabItem("Config")) - { - ImGui::Spacing(); - ImGui::BeginChild("PedCOnfig"); - ImGui::Columns(2, 0, false); - Ui::CheckboxWithHint("Don't move", &m_SpawnPed::m_bPedMove); - ImGui::NextColumn(); - Ui::CheckboxWithHint("Ped bleed", &m_SpawnPed::m_bPedBleed); - ImGui::Columns(1); + ImGui::EndTabItem(); + } + if (ImGui::BeginTabItem("Config")) + { + ImGui::Spacing(); + ImGui::BeginChild("PedCOnfig"); + ImGui::Columns(2, 0, false); + Ui::CheckboxWithHint("Don't move", &m_SpawnPed::m_bPedMove); + ImGui::NextColumn(); + Ui::CheckboxWithHint("Ped bleed", &m_SpawnPed::m_bPedBleed); + ImGui::Columns(1); - ImGui::Spacing(); - ImGui::SliderInt("Accuracy", &m_SpawnPed::m_nAccuracy, 0.0, 100.0); - if (ImGui::InputInt("Health", &m_SpawnPed::m_nPedHealth)) - { - if (m_SpawnPed::m_nPedHealth > 1000) - { - m_SpawnPed::m_nPedHealth = 1000; - } + ImGui::Spacing(); + ImGui::SliderInt("Accuracy", &m_SpawnPed::m_nAccuracy, 0.0, 100.0); + if (ImGui::InputInt("Health", &m_SpawnPed::m_nPedHealth)) + { + if (m_SpawnPed::m_nPedHealth > 1000) + { + m_SpawnPed::m_nPedHealth = 1000; + } - if (m_SpawnPed::m_nPedHealth < 0) - { - m_SpawnPed::m_nPedHealth = 0; - } - } - Ui::ListBox("Ped type", m_SpawnPed::m_PedTypeList, m_SpawnPed::m_nSelectedPedType); + if (m_SpawnPed::m_nPedHealth < 0) + { + m_SpawnPed::m_nPedHealth = 0; + } + } + Ui::ListBox("Ped type", m_SpawnPed::m_PedTypeList, m_SpawnPed::m_nSelectedPedType); - ImGui::Spacing(); - ImGui::Text("Selected weapon: %s", m_SpawnPed::m_nWeaponName.c_str()); - ImGui::Spacing(); + ImGui::Spacing(); + ImGui::Text("Selected weapon: %s", m_SpawnPed::m_nWeaponName.c_str()); + ImGui::Spacing(); #ifdef GTASA - Ui::DrawImages( - Weapon::m_WeaponData, [](std::string str) { m_SpawnPed::m_nWeaponId = std::stoi(str); }, - nullptr, - [](std::string str) { - m_SpawnPed::m_nWeaponName = Weapon::m_WeaponData.m_pJson->m_Data[str].get(); - return m_SpawnPed::m_nWeaponName; - }, - [](std::string str) { - return str != "-1"; /*Jetpack*/ - }); + Ui::DrawImages(Weapon::m_WeaponData, + [](std::string str) { m_SpawnPed::m_nWeaponId = std::stoi(str); }, + nullptr, + [](std::string str) + { + m_SpawnPed::m_nWeaponName = Weapon::m_WeaponData.m_pJson->m_Data[str].get(); + return m_SpawnPed::m_nWeaponName; + }, + [](std::string str) { return str != "-1"; /*Jetpack*/ } + ); #else // GTA3 & GTAVC - Ui::DrawJSON( - Weapon::m_WeaponData, - [](std::string &root, std::string &key, std::string &id) { - m_SpawnPed::m_nWeaponId = std::stoi(id); - m_SpawnPed::m_nWeaponName = key; - }, - nullptr); + Ui::DrawJSON(Weapon::m_WeaponData, + [](std::string& root, std::string& key, std::string& id) + { + m_SpawnPed::m_nWeaponId = std::stoi(id); + m_SpawnPed::m_nWeaponName = key; + }, + nullptr); #endif - ImGui::Spacing(); - ImGui::EndChild(); - ImGui::EndTabItem(); - } - ImGui::EndTabBar(); - } - ImGui::EndTabItem(); - } - ImGui::EndTabBar(); - } + ImGui::Spacing(); + ImGui::EndChild(); + ImGui::EndTabItem(); + } + ImGui::EndTabBar(); + } + ImGui::EndTabItem(); + } + ImGui::EndTabBar(); + } } diff --git a/src/ped.h b/src/ped.h index ab97b42..ac731f7 100644 --- a/src/ped.h +++ b/src/ped.h @@ -9,75 +9,63 @@ class Ped { private: #ifdef GTASA - static inline bool m_bBigHead; - static inline bool m_bThinBody; - static inline CJson m_SpecialPedJson = CJson("ped special"); - static inline ResourceStore m_PedData{"ped", eResourceType::TYPE_BOTH, ImVec2(65, 110)}; + static inline bool m_bBigHead; + static inline bool m_bThinBody; + static inline CJson m_SpecialPedJson = CJson("ped special"); + static inline ResourceStore m_PedData{"ped", eResourceType::TYPE_BOTH, ImVec2(65, 110)}; - static inline std::vector m_GangNames = { - "Ballas", "Grove street families", "Los santos vagos", "San fierro rifa", "Da nang boys", - "Mafia", "Mountain cloud triad", "Varrio los aztecas", "Gang9", "Gang10"}; + static inline std::vector m_GangNames = + { + "Ballas", "Grove street families", "Los santos vagos", "San fierro rifa", + "Da nang boys", "Mafia", "Mountain cloud triad", "Varrio los aztecas", "Gang9", "Gang10" + }; #else // GTA3 & GTAVC - static inline ResourceStore m_PedData{"ped", eResourceType::TYPE_TEXT}; + static inline ResourceStore m_PedData{"ped", eResourceType::TYPE_TEXT}; #endif - static inline bool m_bImagesLoaded; - static inline bool m_bExGangWarsInstalled; - static inline int m_nPedRemoveRadius = 5; - struct m_SpawnPed - { - static inline std::vector m_List; - static inline int m_nAccuracy = 50; - static inline int m_nPedHealth = 100; - static inline bool m_bPedMove; - static inline bool m_bPedBleed; - static inline int m_nSelectedPedType; - static inline int m_nWeaponId; - static inline std::string m_nWeaponName = "None"; - static inline std::vector m_PedTypeList = { + static inline bool m_bImagesLoaded; + static inline bool m_bExGangWarsInstalled; + static inline int m_nPedRemoveRadius = 5; + struct m_SpawnPed + { + static inline std::vector m_List; + static inline int m_nAccuracy = 50; + static inline int m_nPedHealth = 100; + static inline bool m_bPedMove; + static inline bool m_bPedBleed; + static inline int m_nSelectedPedType; + static inline int m_nWeaponId; + static inline std::string m_nWeaponName = "None"; + static inline std::vector m_PedTypeList = + { #ifdef GTASA - "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" + "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" #elif GTAVC - "Civ Male", "Civ Female", "Cop (crash)", "Cubans", "Haitians", "Streetwannabe's", "Diaz' Gang", - "Security Guards", "Biker Gang", "Vercetti Gang", "Golfers", "Gang 9", "Emergency", "Fireman", - "Criminal", "Unused", "Prostitute", "Special" + "Civ Male", "Civ Female", "Cop (crash)", "Cubans", "Haitians", "Streetwannabe's", "Diaz' Gang", + "Security Guards", "Biker Gang", "Vercetti Gang", "Golfers", "Gang 9", "Emergency", + "Fireman", "Criminal", "Unused", "Prostitute", "Special" #else // GTA3 - "Civ Male", "Civ Female", "Cop", "Leones", "Triads", "Diablos", "Yakuza", - "Yardies", "Colombians", "Hoods", "unused", "unused", "Emergency", "Fireman", - "Criminal", "unused", "Prostitute", "Special" + "Civ Male", "Civ Female", "Cop", "Leones", "Triads", "Diablos", "Yakuza", "Yardies", "Colombians", + "Hoods", "unused", "unused", "Emergency", "Fireman", "Criminal", "unused", "Prostitute", "Special" #endif - }; - }; + }; + }; - friend class Player; + friend class Player; #ifdef GTASA - friend class Weapon; + friend class Weapon; #endif public: - Ped(); - ~Ped(); - static void Draw(); + Ped(); + ~Ped(); + static void Draw(); #ifdef GTASA - static void SpawnPed(std::string &model); - static void BigHeadEffect(CPed *ped); + static void SpawnPed(std::string& model); + static void BigHeadEffect(CPed *ped); #else // GTA3 & GTAVC - static void SpawnPed(std::string &cat, std::string &name, std::string &model); + static void SpawnPed(std::string& cat, std::string& name, std::string& model); #endif }; diff --git a/src/player.cpp b/src/player.cpp index 047f33c..0d8632f 100644 --- a/src/player.cpp +++ b/src/player.cpp @@ -1,828 +1,829 @@ +#include "pch.h" #include "player.h" #include "menu.h" -#include "pch.h" #include "ui.h" #include "util.h" - #ifdef GTASA #include "ped.h" // hardcoded cloth category names -const char *cloth_category[18] = {"Shirts", - "Heads", - "Trousers", - "Shoes", - "Tattoos left lower arm", - "Tattoos left upper arm", - "Tattoos right upper arm", - "Tattoos right lower arm", - "Tattoos back", - "Tattoos left chest", - "Tattoos right chest", - "Tattoos stomach", - "Tattoos lower back", - "Necklaces", - "Watches", - "Glasses", - "Hats", - "Extras"}; +const char* cloth_category[18] = +{ + "Shirts", + "Heads", + "Trousers", + "Shoes", + "Tattoos left lower arm", + "Tattoos left upper arm", + "Tattoos right upper arm", + "Tattoos right lower arm", + "Tattoos back", + "Tattoos left chest", + "Tattoos right chest", + "Tattoos stomach", + "Tattoos lower back", + "Necklaces", + "Watches", + "Glasses", + "Hats", + "Extras" +}; static inline void PlayerModelBrokenFix() { - CPlayerPed *pPlayer = FindPlayerPed(); + CPlayerPed* pPlayer = FindPlayerPed(); - if (pPlayer->m_nModelIndex == 0) - Call<0x5A81E0>(0, pPlayer->m_pPlayerData->m_pPedClothesDesc, 0xBC1C78, false); + if (pPlayer->m_nModelIndex == 0) + Call<0x5A81E0>(0, pPlayer->m_pPlayerData->m_pPedClothesDesc, 0xBC1C78, false); } + /* - Taken from gta chaos mod by Lordmau5 - https://github.com/gta-chaos-mod/Trilogy-ASI-Script + Taken from gta chaos mod by Lordmau5 + https://github.com/gta-chaos-mod/Trilogy-ASI-Script */ void Player::TopDownCameraView() { - CPlayerPed *player = FindPlayerPed(); - CVector pos = player->GetPosition(); - float curOffset = m_TopDownCamera::m_fOffset; + CPlayerPed *player = FindPlayerPed (); + CVector pos = player->GetPosition (); + float curOffset = m_TopDownCamera::m_fOffset; - // drunk effect causes issues - Command(0, 0); + // drunk effect causes issues + Command (0, 0); - CVehicle *vehicle = FindPlayerVehicle(-1, false); + CVehicle *vehicle = FindPlayerVehicle(-1, false); + + // TODO: implement smooth transition + if (vehicle) + { + float speed = vehicle->m_vecMoveSpeed.Magnitude(); + if (speed > 1.2f) + { + speed = 1.2f; + } + if (speed * 40.0f > 40.0f) + { + speed = 40.0f; + } - // TODO: implement smooth transition - if (vehicle) - { - float speed = vehicle->m_vecMoveSpeed.Magnitude(); - if (speed > 1.2f) - { - speed = 1.2f; - } - if (speed * 40.0f > 40.0f) - { - speed = 40.0f; - } + if (speed < 0.0f) + { + speed = 0.0f; + } + curOffset += speed; + } - if (speed < 0.0f) - { - speed = 0.0f; - } - curOffset += speed; - } + CVector playerOffset = CVector (pos.x, pos.y, pos.z + 2.0f); + CVector cameraPos + = CVector (playerOffset.x, playerOffset.y, playerOffset.z + curOffset); - CVector playerOffset = CVector(pos.x, pos.y, pos.z + 2.0f); - CVector cameraPos = CVector(playerOffset.x, playerOffset.y, playerOffset.z + curOffset); + CColPoint outColPoint; + CEntity * outEntity; - CColPoint outColPoint; - CEntity *outEntity; + // TODO: Which variable? X, Y or Z for the look direction? - // TODO: Which variable? X, Y or Z for the look direction? + if (CWorld::ProcessLineOfSight (playerOffset, cameraPos, outColPoint, + outEntity, true, true, true, true, true, + true, true, true)) + { + Command ( + outColPoint.m_vecPoint.x, outColPoint.m_vecPoint.y, + outColPoint.m_vecPoint.z, 0.0f, 0.0f, 0.0f); + } + else + { + Command ( + cameraPos.x, cameraPos.y, cameraPos.z, 0.0f, 0.0f, 0.0f); + } - if (CWorld::ProcessLineOfSight(playerOffset, cameraPos, outColPoint, outEntity, true, true, true, true, true, true, - true, true)) - { - Command(outColPoint.m_vecPoint.x, outColPoint.m_vecPoint.y, - outColPoint.m_vecPoint.z, 0.0f, 0.0f, 0.0f); - } - else - { - Command(cameraPos.x, cameraPos.y, cameraPos.z, 0.0f, 0.0f, - 0.0f); - } + Command (pos.x, pos.y, + pos.z, 2); - Command(pos.x, pos.y, pos.z, 2); - - TheCamera.m_fGenerationDistMultiplier = 10.0f; - TheCamera.m_fLODDistMultiplier = 10.0f; + TheCamera.m_fGenerationDistMultiplier = 10.0f; + TheCamera.m_fLODDistMultiplier = 10.0f; } #endif Player::Player() { #ifdef GTASA - // Fix player model being broken after rebuild - patch::RedirectCall(0x5A834D, &PlayerModelBrokenFix); - m_bAimSkinChanger = gConfig.GetValue("aim_skin_changer", false); +// Fix player model being broken after rebuild + patch::RedirectCall(0x5A834D, &PlayerModelBrokenFix); + m_bAimSkinChanger = gConfig.GetValue("aim_skin_changer", false); #endif - // Custom skins setup - if (GetModuleHandle("modloader.asi")) - { + // Custom skins setup + if (GetModuleHandle("modloader.asi")) + { #ifdef GTASA - if (std::filesystem::is_directory(m_CustomSkins::m_Path)) - { - for (auto &p : std::filesystem::recursive_directory_iterator(m_CustomSkins::m_Path)) - { - if (p.path().extension() == ".dff") - { - std::string file_name = p.path().stem().string(); + if (std::filesystem::is_directory(m_CustomSkins::m_Path)) + { + for (auto& p : std::filesystem::recursive_directory_iterator(m_CustomSkins::m_Path)) + { + if (p.path().extension() == ".dff") + { + std::string file_name = p.path().stem().string(); - if (file_name.size() < 9) - m_CustomSkins::m_List.push_back(file_name); - else - gLog << "Custom Skin longer than 8 characters " << file_name << std::endl; - } - } - } - else - { - std::filesystem::create_directory(m_CustomSkins::m_Path); - } + if (file_name.size() < 9) + m_CustomSkins::m_List.push_back(file_name); + else + gLog << "Custom Skin longer than 8 characters " << file_name << std::endl; + } + } + } + else + { + std::filesystem::create_directory(m_CustomSkins::m_Path); + } #endif - m_bModloaderInstalled = true; - } + m_bModloaderInstalled = true; + } - Events::processScriptsEvent += [] { - uint timer = CTimer::m_snTimeInMilliseconds; - CPlayerPed *player = FindPlayerPed(); - int hplayer = CPools::GetPedRef(player); + Events::processScriptsEvent += [] + { + uint timer = CTimer::m_snTimeInMilliseconds; + CPlayerPed* player = FindPlayerPed(); + int hplayer = CPools::GetPedRef(player); - if (m_KeepPosition::m_bEnabled) - { - if (Command(hplayer)) - { - m_KeepPosition::m_fPos = player->GetPosition(); - } - else - { - CVector cur_pos = player->GetPosition(); + if (m_KeepPosition::m_bEnabled) + { + if (Command(hplayer)) + { + m_KeepPosition::m_fPos = player->GetPosition(); + } + else + { + CVector cur_pos = player->GetPosition(); - if (m_KeepPosition::m_fPos.x != 0 && m_KeepPosition::m_fPos.x != cur_pos.x && - m_KeepPosition::m_fPos.y != 0 && m_KeepPosition::m_fPos.y != cur_pos.y) - { - BY_GAME(player->Teleport(m_KeepPosition::m_fPos, false), player->Teleport(m_KeepPosition::m_fPos)); - m_KeepPosition::m_fPos = CVector(0, 0, 0); - } - } - } + if (m_KeepPosition::m_fPos.x != 0 && m_KeepPosition::m_fPos.x != cur_pos.x + && m_KeepPosition::m_fPos.y != 0 && m_KeepPosition::m_fPos.y != cur_pos.y) + { + BY_GAME(player->Teleport(m_KeepPosition::m_fPos, false) + , player->Teleport(m_KeepPosition::m_fPos), player->Teleport(m_KeepPosition::m_fPos)); + m_KeepPosition::m_fPos = CVector(0, 0, 0); + } + } + } - if (m_bGodMode) - { + if (m_bGodMode) + { #ifdef GTASA - patch::Set(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; + patch::Set(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; #elif GTAVC - player->m_nFlags.bBulletProof = 1; - player->m_nFlags.bCollisionProof = 1; - player->m_nFlags.bExplosionProof = 1; - player->m_nFlags.bFireProof = 1; - player->m_nFlags.bMeleeProof = 1; + player->m_nFlags.bBulletProof = 1; + player->m_nFlags.bCollisionProof = 1; + player->m_nFlags.bExplosionProof = 1; + player->m_nFlags.bFireProof = 1; + player->m_nFlags.bMeleeProof = 1; #else // GTA3 - player->m_nEntityFlags.bBulletProof = m_bGodMode; - player->m_nEntityFlags.bCollisionProof = m_bGodMode; - player->m_nEntityFlags.bExplosionProof = m_bGodMode; - player->m_nEntityFlags.bFireProof = m_bGodMode; - player->m_nEntityFlags.bMeleeProof = m_bGodMode; + player->m_nEntityFlags.bBulletProof = m_bGodMode; + player->m_nEntityFlags.bCollisionProof = m_bGodMode; + player->m_nEntityFlags.bExplosionProof = m_bGodMode; + player->m_nEntityFlags.bFireProof = m_bGodMode; + player->m_nEntityFlags.bMeleeProof = m_bGodMode; #endif - } + } #ifdef GTASA - if (m_bDrunkEffect && !m_TopDownCamera::m_bEnabled) - { - Command(0, 100); - } + if (m_bDrunkEffect && !m_TopDownCamera::m_bEnabled) + { + Command (0, 100); + } - if (m_TopDownCamera::m_bEnabled) - { - TopDownCameraView(); - } + if (m_TopDownCamera::m_bEnabled) + { + TopDownCameraView(); + } - if (m_bAimSkinChanger && aimSkinChanger.Pressed()) - { - CPed *targetPed = player->m_pPlayerTargettedPed; - if (targetPed) - { - player->SetModelIndex(targetPed->m_nModelIndex); - Util::ClearCharTasksVehCheck(player); - } - } + if (m_bAimSkinChanger && aimSkinChanger.Pressed()) + { + CPed* targetPed = player->m_pPlayerTargettedPed; + if (targetPed) + { + player->SetModelIndex(targetPed->m_nModelIndex); + Util::ClearCharTasksVehCheck(player); + } + } #endif - if (godMode.Pressed()) - { - if (m_bGodMode) - { - SetHelpMessage("God mode disabled", false, false, false); + if (godMode.Pressed()) + { + if (m_bGodMode) + { + SetHelpMessage("God mode disabled", false, false, false); #ifdef GTASA - patch::Set(0x96916D, m_bGodMode, false); - player->m_nPhysicalFlags.bBulletProof = 0; - player->m_nPhysicalFlags.bCollisionProof = 0; - player->m_nPhysicalFlags.bExplosionProof = 0; - player->m_nPhysicalFlags.bFireProof = 0; - player->m_nPhysicalFlags.bMeeleProof = 0; + patch::Set(0x96916D, m_bGodMode, false); + player->m_nPhysicalFlags.bBulletProof = 0; + player->m_nPhysicalFlags.bCollisionProof = 0; + player->m_nPhysicalFlags.bExplosionProof = 0; + player->m_nPhysicalFlags.bFireProof = 0; + player->m_nPhysicalFlags.bMeeleProof = 0; #elif GTAVC - player->m_nFlags.bBulletProof = 0; - player->m_nFlags.bCollisionProof = 0; - player->m_nFlags.bExplosionProof = 0; - player->m_nFlags.bFireProof = 0; - player->m_nFlags.bMeleeProof = 0; + player->m_nFlags.bBulletProof = 0; + player->m_nFlags.bCollisionProof = 0; + player->m_nFlags.bExplosionProof = 0; + player->m_nFlags.bFireProof = 0; + player->m_nFlags.bMeleeProof = 0; #else // GTA3 - player->m_nEntityFlags.bBulletProof = m_bGodMode; - player->m_nEntityFlags.bCollisionProof = m_bGodMode; - player->m_nEntityFlags.bExplosionProof = m_bGodMode; - player->m_nEntityFlags.bFireProof = m_bGodMode; - player->m_nEntityFlags.bMeleeProof = m_bGodMode; + player->m_nEntityFlags.bBulletProof = m_bGodMode; + player->m_nEntityFlags.bCollisionProof = m_bGodMode; + player->m_nEntityFlags.bExplosionProof = m_bGodMode; + player->m_nEntityFlags.bFireProof = m_bGodMode; + player->m_nEntityFlags.bMeleeProof = m_bGodMode; #endif - m_bGodMode = false; - } - else - { - SetHelpMessage("God mode enabled", false, false, false); - m_bGodMode = true; - } - } - }; + m_bGodMode = false; + } + else + { + SetHelpMessage("God mode enabled", false, false, false); + m_bGodMode = true; + } + } + }; } #ifdef GTASA -void Player::ChangePlayerCloth(std::string &name) +void Player::ChangePlayerCloth(std::string& name) { - std::stringstream ss(name); - std::string temp; + std::stringstream ss(name); + std::string temp; - getline(ss, temp, '$'); - int body_part = std::stoi(temp); + getline(ss, temp, '$'); + int body_part = std::stoi(temp); - getline(ss, temp, '$'); - std::string model = temp.c_str(); + getline(ss, temp, '$'); + std::string model = temp.c_str(); - getline(ss, temp, '$'); - std::string texName = temp.c_str(); + getline(ss, temp, '$'); + std::string texName = temp.c_str(); - CPlayerPed *player = FindPlayerPed(); + CPlayerPed* player = FindPlayerPed(); - if (texName == "cutoffchinosblue") - { - player->m_pPlayerData->m_pPedClothesDesc->SetTextureAndModel(-697413025, 744365350, body_part); - } - else - { - if (texName == "sneakerbincblue") - { - player->m_pPlayerData->m_pPedClothesDesc->SetTextureAndModel(-915574819, 2099005073, body_part); - } - else - { - if (texName == "12myfac") - { - player->m_pPlayerData->m_pPedClothesDesc->SetTextureAndModel(-1750049245, 1393983095, body_part); - } - else - { - player->m_pPlayerData->m_pPedClothesDesc->SetTextureAndModel(texName.c_str(), model.c_str(), body_part); - } - } - } - CClothes::RebuildPlayer(player, false); + if (texName == "cutoffchinosblue") + { + player->m_pPlayerData->m_pPedClothesDesc->SetTextureAndModel(-697413025, 744365350, body_part); + } + else + { + if (texName == "sneakerbincblue") + { + player->m_pPlayerData->m_pPedClothesDesc->SetTextureAndModel(-915574819, 2099005073, body_part); + } + else + { + if (texName == "12myfac") + { + player->m_pPlayerData->m_pPedClothesDesc->SetTextureAndModel(-1750049245, 1393983095, body_part); + } + else + { + player->m_pPlayerData->m_pPedClothesDesc->SetTextureAndModel(texName.c_str(), model.c_str(), body_part); + } + } + } + CClothes::RebuildPlayer(player, false); } #endif #ifdef GTASA -void Player::ChangePlayerModel(std::string &model) +void Player::ChangePlayerModel(std::string& model) { - bool custom_skin = - std::find(m_CustomSkins::m_List.begin(), m_CustomSkins::m_List.end(), model) != m_CustomSkins::m_List.end(); + bool custom_skin = std::find(m_CustomSkins::m_List.begin(), m_CustomSkins::m_List.end(), model) != + m_CustomSkins::m_List.end(); - if (Ped::m_PedData.m_pJson->m_Data.contains(model) || custom_skin) - { - CPlayerPed *player = FindPlayerPed(); - if (Ped::m_SpecialPedJson.m_Data.contains(model) || custom_skin) - { - std::string name; - if (Ped::m_SpecialPedJson.m_Data.contains(model)) - name = Ped::m_SpecialPedJson.m_Data[model].get().c_str(); - else - name = model; + if (Ped::m_PedData.m_pJson->m_Data.contains(model) || custom_skin) + { + CPlayerPed* player = FindPlayerPed(); + if (Ped::m_SpecialPedJson.m_Data.contains(model) || custom_skin) + { + std::string name; + if (Ped::m_SpecialPedJson.m_Data.contains(model)) + name = Ped::m_SpecialPedJson.m_Data[model].get().c_str(); + else + name = model; - CStreaming::RequestSpecialChar(1, name.c_str(), PRIORITY_REQUEST); - CStreaming::LoadAllRequestedModels(true); + CStreaming::RequestSpecialChar(1, name.c_str(), PRIORITY_REQUEST); + CStreaming::LoadAllRequestedModels(true); - player->SetModelIndex(291); + player->SetModelIndex(291); + + CStreaming::SetSpecialCharIsDeletable(291); + } + else + { + int imodel = std::stoi(model); - CStreaming::SetSpecialCharIsDeletable(291); - } - else - { - int imodel = std::stoi(model); - - CStreaming::RequestModel(imodel, eStreamingFlags::PRIORITY_REQUEST); - CStreaming::LoadAllRequestedModels(false); - player->SetModelIndex(imodel); - CStreaming::SetModelIsDeletable(imodel); - } - Util::ClearCharTasksVehCheck(player); - } + CStreaming::RequestModel(imodel, eStreamingFlags::PRIORITY_REQUEST); + CStreaming::LoadAllRequestedModels(false); + player->SetModelIndex(imodel); + CStreaming::SetModelIsDeletable(imodel); + } + Util::ClearCharTasksVehCheck(player); + } } #else // GTA3 & GTAVC -void Player::ChangePlayerModel(std::string &cat, std::string &key, std::string &val) +void Player::ChangePlayerModel(std::string& cat, std::string& key, std::string& val) { - CPlayerPed *player = FindPlayerPed(); + CPlayerPed* player = FindPlayerPed(); #ifdef GTAVC - player->Undress(id.c_str()); - CStreaming::LoadAllRequestedModels(false); - player->Dress(); + player->Undress(id.c_str()); + CStreaming::LoadAllRequestedModels(false); + player->Dress(); #else // GTA3 - if (cat == "Special") - { - // CStreaming::RequestSpecialChar(109, val.c_str(), PRIORITY_REQUEST); - // CStreaming::LoadAllRequestedModels(true); - // player->SetModelIndex(109); - // CStreaming::SetMissionDoesntRequireSpecialChar(109); - SetHelpMessage("Spawning special peds isn't implemented yet.", false, false, false); - } - else - { - int imodel = std::stoi(val); - CStreaming::RequestModel(imodel, eStreamingFlags::PRIORITY_REQUEST); - CStreaming::LoadAllRequestedModels(true); - player->SetModelIndex(imodel); - CStreaming::SetModelIsDeletable(imodel); - } + if (cat == "Special") + { + // CStreaming::RequestSpecialChar(109, val.c_str(), PRIORITY_REQUEST); + // CStreaming::LoadAllRequestedModels(true); + // player->SetModelIndex(109); + // CStreaming::SetMissionDoesntRequireSpecialChar(109); + SetHelpMessage("Spawning special peds isn't implemented yet.", false, false, false); + } + else + { + int imodel = std::stoi(val); + CStreaming::RequestModel(imodel, eStreamingFlags::PRIORITY_REQUEST); + CStreaming::LoadAllRequestedModels(true); + player->SetModelIndex(imodel); + CStreaming::SetModelIsDeletable(imodel); + } #endif } #endif void Player::Draw() { - CPlayerPed *pPlayer = FindPlayerPed(); - int hplayer = CPools::GetPedRef(pPlayer); + CPlayerPed* pPlayer = FindPlayerPed(); + int hplayer = CPools::GetPedRef(pPlayer); #ifdef GTASA - CPad *pad = pPlayer->GetPadFromPlayer(); + CPad* pad = pPlayer->GetPadFromPlayer(); #endif - CPlayerInfo *pInfo = &CWorld::Players[CWorld::PlayerInFocus]; + CPlayerInfo *pInfo = &CWorld::Players[CWorld::PlayerInFocus]; - if (ImGui::Button("Copy coordinates", ImVec2(Ui::GetSize(2)))) - { - CVector pos = pPlayer->GetPosition(); - std::string text = std::to_string(pos.x) + ", " + std::to_string(pos.y) + ", " + std::to_string(pos.z); + if (ImGui::Button("Copy coordinates", ImVec2(Ui::GetSize(2)))) + { + CVector pos = pPlayer->GetPosition(); + std::string text = std::to_string(pos.x) + ", " + std::to_string(pos.y) + ", " + std::to_string(pos.z); - ImGui::SetClipboardText(text.c_str()); - SetHelpMessage("Coordinates copied", false, false, false); - } - ImGui::SameLine(); - if (ImGui::Button("Suicide", ImVec2(Ui::GetSize(2)))) - { - pPlayer->m_fHealth = 0.0; - } + ImGui::SetClipboardText(text.c_str()); + SetHelpMessage("Coordinates copied", false, false, false); + } + ImGui::SameLine(); + if (ImGui::Button("Suicide", ImVec2(Ui::GetSize(2)))) + { + pPlayer->m_fHealth = 0.0; + } - ImGui::Spacing(); + ImGui::Spacing(); - if (ImGui::BeginTabBar("Player", ImGuiTabBarFlags_NoTooltip + ImGuiTabBarFlags_FittingPolicyScroll)) - { - if (ImGui::BeginTabItem("Checkboxes")) - { - ImGui::Spacing(); + if (ImGui::BeginTabBar("Player", ImGuiTabBarFlags_NoTooltip + ImGuiTabBarFlags_FittingPolicyScroll)) + { + if (ImGui::BeginTabItem("Checkboxes")) + { + ImGui::Spacing(); - ImGui::BeginChild("CheckboxesChild"); + ImGui::BeginChild("CheckboxesChild"); - ImGui::Columns(2, 0, false); + ImGui::Columns(2, 0, false); #ifdef GTASA - Ui::CheckboxAddress("Bounty on yourself", 0x96913F); + Ui::CheckboxAddress("Bounty on yourself", 0x96913F); - ImGui::BeginDisabled(m_TopDownCamera::m_bEnabled); - if (Ui::CheckboxWithHint("Drunk effect", &m_bDrunkEffect)) - { - if (!m_bDrunkEffect) - { - Command(0, 0); - } - } - if (Ui::CheckboxWithHint("Fast Sprint", &m_bFastSprint, "Best to enable God Mode & Infinite sprint too")) - { - if (m_bFastSprint) - { - patch::Set(0x8D2458, 0.1f); - } - else - { - patch::Set(0x8D2458, 5.0f); - } - } - ImGui::EndDisabled(); + ImGui::BeginDisabled(m_TopDownCamera::m_bEnabled); + if (Ui::CheckboxWithHint("Drunk effect", &m_bDrunkEffect)) + { + if (!m_bDrunkEffect) + { + Command (0, 0); + } + } + if (Ui::CheckboxWithHint("Fast Sprint", &m_bFastSprint, "Best to enable God Mode & Infinite sprint too")) + { + if(m_bFastSprint) + { + patch::Set(0x8D2458, 0.1f); + } + else + { + patch::Set(0x8D2458, 5.0f); + } + } + ImGui::EndDisabled(); #endif - Ui::CheckboxAddress("Free healthcare", - BY_GAME((int)&pInfo->m_bFreeHealthCare, (int)&pInfo->m_bFreeHealthCare, - (int)&pInfo->m_bGetOutOfHospitalFree)); + Ui::CheckboxAddress("Free healthcare", BY_GAME((int)&pInfo->m_bFreeHealthCare, + (int)&pInfo->m_bFreeHealthCare, (int)&pInfo->m_bGetOutOfHospitalFree)); - if (Ui::CheckboxWithHint("God mode", &m_bGodMode)) - { + if (Ui::CheckboxWithHint("God mode", &m_bGodMode)) + { #ifdef GTASA - patch::Set(0x96916D, m_bGodMode, false); - pPlayer->m_nPhysicalFlags.bBulletProof = m_bGodMode; - pPlayer->m_nPhysicalFlags.bCollisionProof = m_bGodMode; - pPlayer->m_nPhysicalFlags.bExplosionProof = m_bGodMode; - pPlayer->m_nPhysicalFlags.bFireProof = m_bGodMode; - pPlayer->m_nPhysicalFlags.bMeeleProof = m_bGodMode; + patch::Set(0x96916D, m_bGodMode, false); + pPlayer->m_nPhysicalFlags.bBulletProof = m_bGodMode; + pPlayer->m_nPhysicalFlags.bCollisionProof = m_bGodMode; + pPlayer->m_nPhysicalFlags.bExplosionProof = m_bGodMode; + pPlayer->m_nPhysicalFlags.bFireProof = m_bGodMode; + pPlayer->m_nPhysicalFlags.bMeeleProof = m_bGodMode; #elif GTAVC - pPlayer->m_nFlags.bBulletProof = m_bGodMode; - pPlayer->m_nFlags.bCollisionProof = m_bGodMode; - pPlayer->m_nFlags.bExplosionProof = m_bGodMode; - pPlayer->m_nFlags.bFireProof = m_bGodMode; - pPlayer->m_nFlags.bMeleeProof = m_bGodMode; + pPlayer->m_nFlags.bBulletProof = m_bGodMode; + pPlayer->m_nFlags.bCollisionProof = m_bGodMode; + pPlayer->m_nFlags.bExplosionProof = m_bGodMode; + pPlayer->m_nFlags.bFireProof = m_bGodMode; + pPlayer->m_nFlags.bMeleeProof = m_bGodMode; #else // GTA3 - pPlayer->m_nEntityFlags.bBulletProof = m_bGodMode; - pPlayer->m_nEntityFlags.bCollisionProof = m_bGodMode; - pPlayer->m_nEntityFlags.bExplosionProof = m_bGodMode; - pPlayer->m_nEntityFlags.bFireProof = m_bGodMode; - pPlayer->m_nEntityFlags.bMeleeProof = m_bGodMode; + pPlayer->m_nEntityFlags.bBulletProof = m_bGodMode; + pPlayer->m_nEntityFlags.bCollisionProof = m_bGodMode; + pPlayer->m_nEntityFlags.bExplosionProof = m_bGodMode; + pPlayer->m_nEntityFlags.bFireProof = m_bGodMode; + pPlayer->m_nEntityFlags.bMeleeProof = m_bGodMode; #endif - } + } #ifdef GTASA - Ui::CheckboxAddress("Higher cycle jumps", 0x969161); - Ui::CheckboxAddress("Infinite oxygen", 0x96916E); - if (Ui::CheckboxBitFlag("Invisible player", pPlayer->m_nPedFlags.bDontRender)) - { - pPlayer->m_nPedFlags.bDontRender = (pPlayer->m_nPedFlags.bDontRender == 1) ? 0 : 1; - } - Ui::CheckboxAddress("Infinite sprint", 0xB7CEE4); + Ui::CheckboxAddress("Higher cycle jumps", 0x969161); + Ui::CheckboxAddress("Infinite oxygen", 0x96916E); + if (Ui::CheckboxBitFlag("Invisible player", pPlayer->m_nPedFlags.bDontRender)) + { + pPlayer->m_nPedFlags.bDontRender = (pPlayer->m_nPedFlags.bDontRender == 1) ? 0 : 1; + } + Ui::CheckboxAddress("Infinite sprint", 0xB7CEE4); #else // GTA3 & GTAVC - Ui::CheckboxAddress("Infinite sprint", - BY_GAME(NULL, (int)&pInfo->m_bNeverGetsTired, (int)&pInfo->m_bInfiniteSprint)); + Ui::CheckboxAddress("Infinite sprint", BY_GAME(NULL, (int)&pInfo->m_bNeverGetsTired, (int)&pInfo->m_bInfiniteSprint)); #endif - ImGui::NextColumn(); + ImGui::NextColumn(); #ifdef GTASA - if (Ui::CheckboxBitFlag("Lock control", pad->bPlayerSafe)) - { - pad->bPlayerSafe = (pad->bPlayerSafe == 1) ? 0 : 1; - } - Ui::CheckboxAddressEx("Max sex appeal", 0x969180, 1, 0); - Ui::CheckboxAddress("Mega jump", 0x96916C); - Ui::CheckboxAddress("Mega punch", 0x969173); - Ui::CheckboxAddress("Never get hungry", 0x969174); + if (Ui::CheckboxBitFlag("Lock control", pad->bPlayerSafe)) + { + pad->bPlayerSafe = (pad->bPlayerSafe == 1) ? 0 : 1; + } + Ui::CheckboxAddressEx("Max sex appeal", 0x969180, 1, 0); + Ui::CheckboxAddress("Mega jump", 0x96916C); + Ui::CheckboxAddress("Mega punch", 0x969173); + Ui::CheckboxAddress("Never get hungry", 0x969174); - bool never_wanted = patch::Get(0x969171, false); - if (Ui::CheckboxWithHint("Never wanted", &never_wanted)) - { - CCheat::NotWantedCheat(); - } + bool never_wanted = patch::Get(0x969171, false); + if (Ui::CheckboxWithHint("Never wanted", &never_wanted)) + { + CCheat::NotWantedCheat(); + } #else // GTA3 & GTAVC - static bool neverWanted = false; - if (Ui::CheckboxWithHint("Never wanted", &neverWanted)) - { - if (neverWanted) - { + static bool neverWanted = false; + if (Ui::CheckboxWithHint("Never wanted", &neverWanted)) + { + if (neverWanted) + { #ifdef GTA3 - pPlayer->m_pWanted->SetWantedLevel(0); + pPlayer->m_pWanted->SetWantedLevel(0); #else - pPlayer->m_pWanted->CheatWantedLevel(0); + pPlayer->m_pWanted->CheatWantedLevel(0); #endif - pPlayer->m_pWanted->Update(); - patch::SetRaw(BY_GAME(NULL, 0x4D2110, 0x4AD900), (char *)"\xC3\x90\x90\x90\x90\x90", - 6); // CWanted::UpdateWantedLevel() - patch::Nop(BY_GAME(NULL, 0x5373D0, 0x4EFE73), 5); // CWanted::Update(); - } - else - { - pPlayer->m_pWanted->ClearQdCrimes(); + pPlayer->m_pWanted->Update(); + patch::SetRaw(BY_GAME(NULL, 0x4D2110, 0x4AD900), (char*)"\xC3\x90\x90\x90\x90\x90", 6); // CWanted::UpdateWantedLevel() + patch::Nop(BY_GAME(NULL, 0x5373D0, 0x4EFE73), 5); // CWanted::Update(); + } + else + { + pPlayer->m_pWanted->ClearQdCrimes(); #ifdef GTA3 - pPlayer->m_pWanted->SetWantedLevel(0); - patch::SetRaw(0x4AD900, (char *)"\xA1\x18\x77\x5F\x00", 6); - patch::SetRaw(0x4EFE73, (char *)"\xE8\x38\xD9\xFB\xFF", 5); + pPlayer->m_pWanted->SetWantedLevel(0); + patch::SetRaw(0x4AD900, (char*)"\xA1\x18\x77\x5F\x00", 6); + patch::SetRaw(0x4EFE73, (char*)"\xE8\x38\xD9\xFB\xFF", 5); #else - pPlayer->m_pWanted->CheatWantedLevel(0); - patch::SetRaw(0x4D2110, (char *)"\x8B\x15\xDC\x10\x69\x00", 6); - patch::SetRaw(0x5373D0, (char *)"\xE8\x8B\xAE\xF9\xFF", 5); + pPlayer->m_pWanted->CheatWantedLevel(0); + patch::SetRaw(0x4D2110, (char*)"\x8B\x15\xDC\x10\x69\x00", 6); + patch::SetRaw(0x5373D0, (char*)"\xE8\x8B\xAE\xF9\xFF", 5); #endif - } - } + } + } #endif - Ui::CheckboxAddress("No arrest fee", (int)&pInfo->m_bGetOutOfJailFree); - Ui::CheckboxWithHint("Respawn die location", &m_KeepPosition::m_bEnabled, - "Respawn to the location you died from"); + Ui::CheckboxAddress("No arrest fee", (int)&pInfo->m_bGetOutOfJailFree); + Ui::CheckboxWithHint("Respawn die location", &m_KeepPosition::m_bEnabled, "Respawn to the location you died from"); - ImGui::Columns(1); + ImGui::Columns(1); - ImGui::NewLine(); - ImGui::TextWrapped("Player flags,"); + ImGui::NewLine(); + ImGui::TextWrapped("Player flags,"); - ImGui::Columns(2, 0, false); + ImGui::Columns(2, 0, false); - bool state = BY_GAME(pPlayer->m_nPhysicalFlags.bBulletProof, pPlayer->m_nFlags.bBulletProof, - pPlayer->m_nEntityFlags.bBulletProof); - if (Ui::CheckboxWithHint("Bullet proof", &state, nullptr, m_bGodMode)) - { - BY_GAME(pPlayer->m_nPhysicalFlags.bBulletProof, pPlayer->m_nFlags.bBulletProof, - pPlayer->m_nEntityFlags.bBulletProof) = state; - } + bool state = BY_GAME(pPlayer->m_nPhysicalFlags.bBulletProof, pPlayer->m_nFlags.bBulletProof, + pPlayer->m_nEntityFlags.bBulletProof); + if (Ui::CheckboxWithHint("Bullet proof", &state, nullptr, m_bGodMode)) + { + BY_GAME(pPlayer->m_nPhysicalFlags.bBulletProof, pPlayer->m_nFlags.bBulletProof, + pPlayer->m_nEntityFlags.bBulletProof) = state; + } - state = BY_GAME(pPlayer->m_nPhysicalFlags.bCollisionProof, pPlayer->m_nFlags.bCollisionProof, - pPlayer->m_nEntityFlags.bCollisionProof); - if (Ui::CheckboxWithHint("Collision proof", &state, nullptr, m_bGodMode)) - { - BY_GAME(pPlayer->m_nPhysicalFlags.bCollisionProof, pPlayer->m_nFlags.bCollisionProof, - pPlayer->m_nEntityFlags.bCollisionProof) = state; - } + state = BY_GAME(pPlayer->m_nPhysicalFlags.bCollisionProof, pPlayer->m_nFlags.bCollisionProof, + pPlayer->m_nEntityFlags.bCollisionProof); + if (Ui::CheckboxWithHint("Collision proof", &state, nullptr, m_bGodMode)) + { + BY_GAME(pPlayer->m_nPhysicalFlags.bCollisionProof, pPlayer->m_nFlags.bCollisionProof, + pPlayer->m_nEntityFlags.bCollisionProof) = state; + } - state = BY_GAME(pPlayer->m_nPhysicalFlags.bExplosionProof, pPlayer->m_nFlags.bExplosionProof, - pPlayer->m_nEntityFlags.bExplosionProof); - if (Ui::CheckboxWithHint("Explosion proof", &state, nullptr, m_bGodMode)) - { - BY_GAME(pPlayer->m_nPhysicalFlags.bExplosionProof, pPlayer->m_nFlags.bExplosionProof, - pPlayer->m_nEntityFlags.bExplosionProof) = state; - } + state = BY_GAME(pPlayer->m_nPhysicalFlags.bExplosionProof, pPlayer->m_nFlags.bExplosionProof, + pPlayer->m_nEntityFlags.bExplosionProof); + if (Ui::CheckboxWithHint("Explosion proof", &state, nullptr, m_bGodMode)) + { + BY_GAME(pPlayer->m_nPhysicalFlags.bExplosionProof, pPlayer->m_nFlags.bExplosionProof, + pPlayer->m_nEntityFlags.bExplosionProof) = state; + } - ImGui::NextColumn(); + ImGui::NextColumn(); - state = BY_GAME(pPlayer->m_nPhysicalFlags.bFireProof, pPlayer->m_nFlags.bFireProof, - pPlayer->m_nEntityFlags.bFireProof); - if (Ui::CheckboxWithHint("Fire proof", &state, nullptr, m_bGodMode)) - { - BY_GAME(pPlayer->m_nPhysicalFlags.bFireProof, pPlayer->m_nFlags.bFireProof, - pPlayer->m_nEntityFlags.bFireProof) = state; - } + state = BY_GAME(pPlayer->m_nPhysicalFlags.bFireProof, pPlayer->m_nFlags.bFireProof, + pPlayer->m_nEntityFlags.bFireProof); + if (Ui::CheckboxWithHint("Fire proof", &state, nullptr, m_bGodMode)) + { + BY_GAME(pPlayer->m_nPhysicalFlags.bFireProof, pPlayer->m_nFlags.bFireProof, + pPlayer->m_nEntityFlags.bFireProof) = state; + } - state = BY_GAME(pPlayer->m_nPhysicalFlags.bMeeleProof, pPlayer->m_nFlags.bMeleeProof, - pPlayer->m_nEntityFlags.bMeleeProof); - if (Ui::CheckboxWithHint("Meele proof", &state, nullptr, m_bGodMode)) - { - BY_GAME(pPlayer->m_nPhysicalFlags.bMeeleProof, pPlayer->m_nFlags.bMeleeProof, - pPlayer->m_nEntityFlags.bMeleeProof) = state; - } + state = BY_GAME(pPlayer->m_nPhysicalFlags.bMeeleProof, pPlayer->m_nFlags.bMeleeProof, + pPlayer->m_nEntityFlags.bMeleeProof); + if (Ui::CheckboxWithHint("Meele proof", &state, nullptr, m_bGodMode)) + { + BY_GAME(pPlayer->m_nPhysicalFlags.bMeeleProof, pPlayer->m_nFlags.bMeleeProof, + pPlayer->m_nEntityFlags.bMeleeProof) = state; + } - ImGui::EndChild(); - ImGui::EndTabItem(); - } + ImGui::EndChild(); + ImGui::EndTabItem(); + } - if (ImGui::BeginTabItem("Menus")) - { - ImGui::BeginChild("PlayerMenus"); + if (ImGui::BeginTabItem("Menus")) + { + ImGui::BeginChild("PlayerMenus"); - Ui::EditReference("Armour", pPlayer->m_fArmour, 0, 100, 150); + Ui::EditReference("Armour", pPlayer->m_fArmour, 0, 100, 150); #ifdef GTASA - if (ImGui::CollapsingHeader("Body")) - { - if (pPlayer->m_nModelIndex == 0) - { - ImGui::Columns(3, 0, false); - if (ImGui::RadioButton("Fat", &m_nUiBodyState, 2)) - CCheat::FatCheat(); + if (ImGui::CollapsingHeader("Body")) + { + if (pPlayer->m_nModelIndex == 0) + { + ImGui::Columns(3, 0, false); + if (ImGui::RadioButton("Fat", &m_nUiBodyState, 2)) + CCheat::FatCheat(); - ImGui::NextColumn(); + ImGui::NextColumn(); - if (ImGui::RadioButton("Muscle", &m_nUiBodyState, 1)) - CCheat::MuscleCheat(); + if (ImGui::RadioButton("Muscle", &m_nUiBodyState, 1)) + CCheat::MuscleCheat(); - ImGui::NextColumn(); + ImGui::NextColumn(); - if (ImGui::RadioButton("Skinny", &m_nUiBodyState, 0)) - CCheat::SkinnyCheat(); + if (ImGui::RadioButton("Skinny", &m_nUiBodyState, 0)) + CCheat::SkinnyCheat(); - ImGui::Columns(1); - } - else - { - ImGui::TextWrapped("You need to be in CJ skin."); - ImGui::Spacing(); + 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)))) - { - pPlayer->SetModelIndex(0); - Util::ClearCharTasksVehCheck(pPlayer); - } - } - ImGui::Spacing(); - ImGui::Separator(); - } + if (ImGui::Button("Change to CJ skin", ImVec2(Ui::GetSize(1)))) + { + pPlayer->SetModelIndex(0); + Util::ClearCharTasksVehCheck(pPlayer); + } + } + ImGui::Spacing(); + ImGui::Separator(); + } - Ui::EditStat("Energy", STAT_ENERGY); - Ui::EditStat("Fat", STAT_FAT); + Ui::EditStat("Energy", STAT_ENERGY); + Ui::EditStat("Fat", STAT_FAT); #endif - Ui::EditReference("Health", pPlayer->m_fHealth, 0, 100, - BY_GAME(static_cast(pPlayer->m_fMaxHealth), 100, 100)); + Ui::EditReference("Health", pPlayer->m_fHealth, 0, 100, BY_GAME(static_cast(pPlayer->m_fMaxHealth), 100, 100)); #ifdef GTASA - Ui::EditStat("Lung capacity", STAT_LUNG_CAPACITY); - Ui::EditStat("Max health", STAT_MAX_HEALTH, 0, 569, 1450); - Ui::EditAddress("Money", 0xB7CE50, -99999999, 0, 99999999); + Ui::EditStat("Lung capacity", STAT_LUNG_CAPACITY); + Ui::EditStat("Max health", STAT_MAX_HEALTH, 0, 569, 1450); + Ui::EditAddress("Money", 0xB7CE50, -99999999, 0, 99999999); #else // GTA3 & GTAVC - int money = pInfo->m_nMoney; - Ui::EditAddress("Money", (int)&money, -9999999, 0, 99999999); - pInfo->m_nMoney = money; - pInfo->m_nDisplayMoney = money; + int money = pInfo->m_nMoney; + Ui::EditAddress("Money", (int)&money, -9999999, 0, 99999999); + pInfo->m_nMoney = money; + pInfo->m_nDisplayMoney = money; #endif + #ifdef GTASA - Ui::EditStat("Muscle", STAT_MUSCLE); - Ui::EditStat("Respect", STAT_RESPECT); - Ui::EditStat("Stamina", STAT_STAMINA); - if (ImGui::CollapsingHeader("Top down camera")) - { - if (ImGui::Checkbox("Enabled", &m_TopDownCamera::m_bEnabled)) - { - Command(); - } - ImGui::Spacing(); - ImGui::SliderFloat("Camera zoom", &m_TopDownCamera::m_fOffset, 20.0f, 60.0f); - ImGui::Spacing(); - ImGui::Separator(); - } + Ui::EditStat("Muscle", STAT_MUSCLE); + Ui::EditStat("Respect", STAT_RESPECT); + Ui::EditStat("Stamina", STAT_STAMINA); + if (ImGui::CollapsingHeader("Top down camera")) + { + if (ImGui::Checkbox("Enabled", &m_TopDownCamera::m_bEnabled)) + { + Command(); + } + ImGui::Spacing(); + ImGui::SliderFloat("Camera zoom", &m_TopDownCamera::m_fOffset, 20.0f, 60.0f); + ImGui::Spacing(); + ImGui::Separator(); + } #endif - if (ImGui::CollapsingHeader("Wanted level")) - { + if (ImGui::CollapsingHeader("Wanted level")) + { #ifdef GTASA - int val = pPlayer->m_pPlayerData->m_pWanted->m_nWantedLevel; - int max_wl = pPlayer->m_pPlayerData->m_pWanted->MaximumWantedLevel; - max_wl = max_wl < 6 ? 6 : max_wl; + int val = pPlayer->m_pPlayerData->m_pWanted->m_nWantedLevel; + int max_wl = pPlayer->m_pPlayerData->m_pWanted->MaximumWantedLevel; + max_wl = max_wl < 6 ? 6 : max_wl; #else // GTA3 & GTAVC - int val = pPlayer->m_pWanted->m_nWantedLevel; - int max_wl = 6; + int val = pPlayer->m_pWanted->m_nWantedLevel; + int max_wl = 6; #endif - ImGui::Columns(3, 0, false); - ImGui::Text("Min: 0"); - ImGui::NextColumn(); - ImGui::Text("Def: 0"); - ImGui::NextColumn(); - ImGui::Text("Max: %d", max_wl); - ImGui::Columns(1); + ImGui::Columns(3, 0, false); + ImGui::Text("Min: 0"); + ImGui::NextColumn(); + ImGui::Text("Def: 0"); + ImGui::NextColumn(); + ImGui::Text("Max: %d", max_wl); + ImGui::Columns(1); - ImGui::Spacing(); + ImGui::Spacing(); - if (ImGui::InputInt("Set value##Wanted level", &val)) - { + if (ImGui::InputInt("Set value##Wanted level", &val)) + { #ifdef GTASA - pPlayer->CheatWantedLevel(val); + pPlayer->CheatWantedLevel(val); #elif GTAVC - pPlayer->m_pWanted->CheatWantedLevel(val); + pPlayer->m_pWanted->CheatWantedLevel(val); #else // GTA3 - pPlayer->m_pWanted->SetWantedLevel(val); + pPlayer->m_pWanted->SetWantedLevel(val); #endif - } + } - ImGui::Spacing(); - if (ImGui::Button("Minimum##Wanted level", Ui::GetSize(3))) - { + ImGui::Spacing(); + if (ImGui::Button("Minimum##Wanted level", Ui::GetSize(3))) + { #ifdef GTASA - pPlayer->CheatWantedLevel(0); + pPlayer->CheatWantedLevel(0); #elif GTAVC - pPlayer->m_pWanted->CheatWantedLevel(0); + pPlayer->m_pWanted->CheatWantedLevel(0); #else // GTA3 - pPlayer->m_pWanted->SetWantedLevel(0); + pPlayer->m_pWanted->SetWantedLevel(0); #endif - } + } - ImGui::SameLine(); + ImGui::SameLine(); - if (ImGui::Button("Default##Wanted level", Ui::GetSize(3))) - { + if (ImGui::Button("Default##Wanted level", Ui::GetSize(3))) + { #ifdef GTASA - pPlayer->CheatWantedLevel(0); + pPlayer->CheatWantedLevel(0); #elif GTAVC - pPlayer->m_pWanted->CheatWantedLevel(0); + pPlayer->m_pWanted->CheatWantedLevel(0); #else // GTA3 - pPlayer->m_pWanted->SetWantedLevel(0); + pPlayer->m_pWanted->SetWantedLevel(0); #endif - } + } - ImGui::SameLine(); + ImGui::SameLine(); - if (ImGui::Button("Maximum##Wanted level", Ui::GetSize(3))) - { + if (ImGui::Button("Maximum##Wanted level", Ui::GetSize(3))) + { #ifdef GTASA - pPlayer->CheatWantedLevel(max_wl); + pPlayer->CheatWantedLevel(max_wl); #elif GTAVC - pPlayer->m_pWanted->CheatWantedLevel(max_wl); + pPlayer->m_pWanted->CheatWantedLevel(max_wl); #else // GTA3 - pPlayer->m_pWanted->SetWantedLevel(max_wl); + pPlayer->m_pWanted->SetWantedLevel(max_wl); #endif - } + } - ImGui::Spacing(); - ImGui::Separator(); - } - ImGui::EndChild(); - ImGui::EndTabItem(); - } + ImGui::Spacing(); + ImGui::Separator(); + } + ImGui::EndChild(); + ImGui::EndTabItem(); + } #ifdef GTASA - if (ImGui::BeginTabItem("Appearance")) - { - ImGui::Spacing(); + if (ImGui::BeginTabItem("Appearance")) + { + ImGui::Spacing(); - if (Ui::CheckboxWithHint("Aim skin changer", &m_bAimSkinChanger, - (("Changes to the ped, player is targeting with a weapon.\nTo use aim a ped with " - "a weapon and press ") + - aimSkinChanger.Pressed()))) - gConfig.SetValue("aim_skin_changer", m_bAimSkinChanger); - if (ImGui::BeginTabBar("AppearanceTabBar")) - { - if (ImGui::BeginTabItem("Clothes")) - { - static int bClothOption = 0; - ImGui::RadioButton("Add", &bClothOption, 0); - ImGui::SameLine(); - ImGui::RadioButton("Remove", &bClothOption, 1); - ImGui::Spacing(); + if (Ui::CheckboxWithHint("Aim skin changer", &m_bAimSkinChanger, + (("Changes to the ped, player is targeting with a weapon.\nTo use aim a ped with a weapon and press ") + + aimSkinChanger.Pressed()))) + gConfig.SetValue("aim_skin_changer", m_bAimSkinChanger); + if (ImGui::BeginTabBar("AppearanceTabBar")) + { + if (ImGui::BeginTabItem("Clothes")) + { + static int bClothOption = 0; + ImGui::RadioButton("Add", &bClothOption, 0); + ImGui::SameLine(); + ImGui::RadioButton("Remove", &bClothOption, 1); + ImGui::Spacing(); - if (pPlayer->m_nModelIndex == 0) - { - if (bClothOption == 0) - { - Ui::DrawImages( - m_ClothData, ChangePlayerCloth, nullptr, - [](std::string str) { - std::stringstream ss(str); - std::string temp; + if (pPlayer->m_nModelIndex == 0) + { + if (bClothOption == 0) + { + Ui::DrawImages(m_ClothData, ChangePlayerCloth, nullptr, + [](std::string str) + { + std::stringstream ss(str); + std::string temp; - getline(ss, temp, '$'); - getline(ss, temp, '$'); + getline(ss, temp, '$'); + getline(ss, temp, '$'); - return temp; - }, - nullptr, cloth_category, sizeof(cloth_category) / sizeof(const char *)); - } - else - { - size_t count = 0; + return temp; + }, nullptr, cloth_category, sizeof(cloth_category) / sizeof(const char*)); + } + else + { + size_t count = 0; - if (ImGui::Button("Remove all", ImVec2(Ui::GetSize(2)))) - { - CPlayerPed *player = FindPlayerPed(); - for (uint i = 0; i < 18; i++) - { - player->m_pPlayerData->m_pPedClothesDesc->SetTextureAndModel(0u, 0u, i); - } - CClothes::RebuildPlayer(player, false); - } - ImGui::SameLine(); - for (const char *clothName : cloth_category) - { - if (ImGui::Button(clothName, ImVec2(Ui::GetSize(2)))) - { - CPlayerPed *player = FindPlayerPed(); - player->m_pPlayerData->m_pPedClothesDesc->SetTextureAndModel(0u, 0u, count); - CClothes::RebuildPlayer(player, false); - } + if (ImGui::Button("Remove all", ImVec2(Ui::GetSize(2)))) + { + CPlayerPed* player = FindPlayerPed(); + for (uint i = 0; i < 18; i++) + { + player->m_pPlayerData->m_pPedClothesDesc->SetTextureAndModel(0u, 0u, i); + } + CClothes::RebuildPlayer(player, false); + } + ImGui::SameLine(); + for (const char* clothName : cloth_category) + { + if (ImGui::Button(clothName, ImVec2(Ui::GetSize(2)))) + { + CPlayerPed* player = FindPlayerPed(); + player->m_pPlayerData->m_pPedClothesDesc->SetTextureAndModel(0u, 0u, count); + CClothes::RebuildPlayer(player, false); + } - if (count % 2 != 0) - { - ImGui::SameLine(); - } - ++count; - } + if (count % 2 != 0) + { + ImGui::SameLine(); + } + ++count; + } - ImGui::Spacing(); - ImGui::TextWrapped( - "If CJ is wearing a full suit, click 'Extras/ Remove all' to remove it."); - } - } - else - { - ImGui::TextWrapped("You need to be in CJ skin."); - ImGui::Spacing(); + ImGui::Spacing(); + ImGui::TextWrapped("If CJ is wearing a full suit, click 'Extras/ Remove all' to remove it."); + } + } + else + { + ImGui::TextWrapped("You need to be in CJ skin."); + ImGui::Spacing(); - if (ImGui::Button("Change to CJ skin", ImVec2(Ui::GetSize(1)))) - { - pPlayer->SetModelIndex(0); - Util::ClearCharTasksVehCheck(pPlayer); - } - } - ImGui::EndTabItem(); - } - if (ImGui::BeginTabItem("Ped skins")) - { - Ui::DrawImages(Ped::m_PedData, ChangePlayerModel, nullptr, [](std::string str) { - return Ped::m_PedData.m_pJson->m_Data[str].get(); - }); - ImGui::EndTabItem(); - } - if (ImGui::BeginTabItem("Custom skins")) - { - ImGui::Spacing(); + if (ImGui::Button("Change to CJ skin", ImVec2(Ui::GetSize(1)))) + { + pPlayer->SetModelIndex(0); + Util::ClearCharTasksVehCheck(pPlayer); + } + } + ImGui::EndTabItem(); + } + if (ImGui::BeginTabItem("Ped skins")) + { + Ui::DrawImages(Ped::m_PedData, ChangePlayerModel, nullptr, + [](std::string str) { return Ped::m_PedData.m_pJson->m_Data[str].get(); }); + ImGui::EndTabItem(); + } + if (ImGui::BeginTabItem("Custom skins")) + { + ImGui::Spacing(); - if (m_bModloaderInstalled) - { - Ui::FilterWithHint( - "Search", m_ClothData.m_Filter, - std::string("Total skins: " + std::to_string(m_CustomSkins::m_List.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(); - for (std::string name : m_CustomSkins::m_List) - { - if (m_CustomSkins::m_Filter.PassFilter(name.c_str())) - { - if (ImGui::MenuItem(name.c_str())) - { - ChangePlayerModel(name); - } - } - } - } - else - { - ImGui::TextWrapped( - "Custom skin allows to change player skins without replacing any existing game ped skins.\n\ + if (m_bModloaderInstalled) + { + Ui::FilterWithHint("Search", m_ClothData.m_Filter, + std::string("Total skins: " + std::to_string(m_CustomSkins::m_List.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(); + for (std::string name : m_CustomSkins::m_List) + { + if (m_CustomSkins::m_Filter.PassFilter(name.c_str())) + { + if (ImGui::MenuItem(name.c_str())) + { + ChangePlayerModel(name); + } + } + } + } + else + { + ImGui::TextWrapped( + "Custom skin allows to change player skins without replacing any existing game ped skins.\n\ Steps to enable 'Custom Skins',\n\n\ 1. Download & install modloader\n\ 2. Create a folder inside 'modloader' folder with the name 'Custom Skins'\n\ @@ -832,31 +833,31 @@ Limitations:\n\ 1. Your .dff & .txd file names must not exceed 8 characters.\n\ 2. Do not rename them while the game is running\n\ \nDoing so will crash your game."); - 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::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(); + } #else // GTA3 & GTA - if (ImGui::BeginTabItem("Skins")) - { - ImGui::Spacing(); + if (ImGui::BeginTabItem("Skins")) + { + ImGui::Spacing(); #ifdef GTA3 - ImGui::TextWrapped("Player must be frozen to change skins."); - CPad::GetPad(0)->m_bDisablePlayerControls = true; + ImGui::TextWrapped("Player must be frozen to change skins."); + CPad::GetPad(0)->m_bDisablePlayerControls = true; #else - ImGui::TextWrapped("Only contains the skins that works."); + ImGui::TextWrapped("Only contains the skins that works."); #endif - Ui::DrawJSON(skinData, ChangePlayerModel, nullptr); - ImGui::EndTabItem(); - } + Ui::DrawJSON(skinData, ChangePlayerModel, nullptr); + ImGui::EndTabItem(); + } #endif - ImGui::EndTabBar(); - } + ImGui::EndTabBar(); + } } diff --git a/src/player.h b/src/player.h index 74425d4..e68b36c 100644 --- a/src/player.h +++ b/src/player.h @@ -4,46 +4,45 @@ class Player { private: - static inline bool m_bGodMode; - static inline bool m_bModloaderInstalled; - struct m_KeepPosition - { - static inline bool m_bEnabled = false; - static inline CVector m_fPos; - }; + static inline bool m_bGodMode; + static inline bool m_bModloaderInstalled; + struct m_KeepPosition + { + static inline bool m_bEnabled = false; + static inline CVector m_fPos; + }; #ifdef GTASA - static inline bool m_bAimSkinChanger; - static inline bool m_bDrunkEffect; - static inline bool m_bFastSprint; - static inline int m_nUiBodyState; - static inline ResourceStore m_ClothData{"clothes", eResourceType::TYPE_IMAGE, ImVec2(70, 100)}; - struct m_CustomSkins - { - static inline std::string m_Path = paths::GetGameDirPathA() + std::string("\\modloader\\Custom Skins\\"); - ; - static inline ImGuiTextFilter m_Filter; - static inline std::vector m_List; - }; + static inline bool m_bAimSkinChanger; + static inline bool m_bDrunkEffect; + static inline bool m_bFastSprint; + static inline int m_nUiBodyState; + static inline ResourceStore m_ClothData { "clothes" , eResourceType::TYPE_IMAGE, ImVec2(70, 100)}; + struct m_CustomSkins + { + static inline std::string m_Path = paths::GetGameDirPathA() + std::string("\\modloader\\Custom Skins\\");; + static inline ImGuiTextFilter m_Filter; + static inline std::vector m_List; + }; - struct m_TopDownCamera - { - static inline bool m_bEnabled = false; - static inline float m_fOffset = 40.0f; - }; + struct m_TopDownCamera + { + static inline bool m_bEnabled = false; + static inline float m_fOffset = 40.0f; + }; #else // GTA3 & GTAVC - static inline ResourceStore skinData{BY_GAME(NULL, "skin", "ped"), eResourceType::TYPE_TEXT}; + static inline ResourceStore skinData{ BY_GAME(NULL, "skin", "ped"), eResourceType::TYPE_TEXT }; #endif public: - Player(); - static void Draw(); + Player(); + static void Draw(); #ifdef GTASA - static void ChangePlayerModel(std::string &model); - static void ChangePlayerCloth(std::string &model); - static void TopDownCameraView(); + static void ChangePlayerModel(std::string& model); + static void ChangePlayerCloth(std::string& model); + static void TopDownCameraView(); #else // GTA3 & GTAVC - static void ChangePlayerModel(std::string &cat, std::string &name, std::string &id); + static void ChangePlayerModel(std::string& cat, std::string& name, std::string& id); #endif }; diff --git a/src/resourcestore.cpp b/src/resourcestore.cpp index 70f1782..2fea024 100644 --- a/src/resourcestore.cpp +++ b/src/resourcestore.cpp @@ -1,10 +1,12 @@ +#include "pch.h" #include "CFileLoader.h" #include "extensions/Paths.h" -#include "pch.h" -ResourceStore::ResourceStore(const char *text, eResourceType type, ImVec2 imageSize) : m_ImageSize(imageSize) +ResourceStore::ResourceStore(const char* text, eResourceType type, ImVec2 imageSize) +: m_ImageSize(imageSize) { - if (type == eResourceType::TYPE_TEXT || type == eResourceType::TYPE_BOTH) + if (type == eResourceType::TYPE_TEXT + || type == eResourceType::TYPE_BOTH) { m_pJson = std::make_unique(text); @@ -17,14 +19,16 @@ ResourceStore::ResourceStore(const char *text, eResourceType type, ImVec2 imageS } } } - - if (type == eResourceType::TYPE_IMAGE || type == eResourceType::TYPE_BOTH) + + if (type == eResourceType::TYPE_IMAGE + || type == eResourceType::TYPE_BOTH) { - /* + /* Textures need to be loaded from main thread Loading it directly here doesn't work */ - Events::processScriptsEvent += [text, this]() { + Events::processScriptsEvent += [text, this]() + { if (!m_bTexturesLoaded) { LoadTextureResource(text); @@ -34,30 +38,30 @@ ResourceStore::ResourceStore(const char *text, eResourceType type, ImVec2 imageS } } -static void *GetTextureFromRaster(RwTexture *pTexture) +static void* GetTextureFromRaster(RwTexture* pTexture) { - RwRasterEx *raster = (RwRasterEx *)(&pTexture->raster->parent); + RwRasterEx* raster = (RwRasterEx*)(&pTexture->raster->parent); - return (&raster->m_pRenderResource->texture); + return (&raster->m_pRenderResource->texture); } -void ResourceStore::LoadTextureResource(std::string &&name) +void ResourceStore::LoadTextureResource(std::string&& name) { - std::string fullPath = PLUGIN_PATH((char *)"CheatMenu\\") + name + ".txd"; - RwTexDictionary *pRwTexDictionary = CFileLoader::LoadTexDictionary(fullPath.c_str()); + std::string fullPath = PLUGIN_PATH((char*)"CheatMenu\\") + name + ".txd"; + RwTexDictionary* pRwTexDictionary = CFileLoader::LoadTexDictionary(fullPath.c_str()); - if (pRwTexDictionary) - { - RwLinkList *pRLL = (RwLinkList *)pRwTexDictionary->texturesInDict.link.next; + if (pRwTexDictionary) + { + RwLinkList *pRLL = (RwLinkList*)pRwTexDictionary->texturesInDict.link.next; RwTexDictionary *pEndDic; do { - pEndDic = (RwTexDictionary *)pRLL->link.next; - RwTexture *pTex = (RwTexture *)&pRLL[-1]; + pEndDic = (RwTexDictionary*)pRLL->link.next; + RwTexture *pTex = (RwTexture*)&pRLL[-1]; m_ImagesList.push_back(std::make_unique()); m_ImagesList.back().get()->m_pRwTexture = pTex; - + // Fetch IDirec9Texture9* from RwTexture* m_ImagesList.back().get()->m_pTexture = GetTextureFromRaster(pTex); @@ -84,7 +88,8 @@ void ResourceStore::LoadTextureResource(std::string &&name) { m_Categories.push_back(m_ImagesList.back().get()->m_CategoryName); } - pRLL = (RwLinkList *)pEndDic; - } while (pEndDic != (RwTexDictionary *)&pRwTexDictionary->texturesInDict); - } + pRLL = (RwLinkList*)pEndDic; + } + while ( pEndDic != (RwTexDictionary*)&pRwTexDictionary->texturesInDict ); + } } \ No newline at end of file diff --git a/src/resourcestore.h b/src/resourcestore.h index 8a099fd..df4975c 100644 --- a/src/resourcestore.h +++ b/src/resourcestore.h @@ -1,61 +1,62 @@ +#include +#include +#include "json.h" #include "../depend/imgui/imgui.h" #include "d3d9.h" -#include "json.h" -#include -#include struct RwD3D9Raster { - union { - IDirect3DTexture9 *texture; - IDirect3DSurface9 *surface; - }; - unsigned char *palette; - unsigned char alpha; - unsigned char cubeTextureFlags; /* 0x01 IS_CUBEMAP_TEX */ - unsigned char textureFlags; /* 0x10 IS_COMPRESSED */ - unsigned char lockedLevel; - IDirect3DSurface9 *lockedSurface; - D3DLOCKED_RECT lockedRect; - D3DFORMAT format; - IDirect3DSwapChain9 *swapChain; - HWND *hwnd; + union + { + IDirect3DTexture9* texture; + IDirect3DSurface9* surface; + }; + unsigned char* palette; + unsigned char alpha; + unsigned char cubeTextureFlags; /* 0x01 IS_CUBEMAP_TEX */ + unsigned char textureFlags; /* 0x10 IS_COMPRESSED */ + unsigned char lockedLevel; + IDirect3DSurface9* lockedSurface; + D3DLOCKED_RECT lockedRect; + D3DFORMAT format; + IDirect3DSwapChain9* swapChain; + HWND* hwnd; }; struct RwRasterEx : public RwRaster { - RwD3D9Raster *m_pRenderResource; + RwD3D9Raster *m_pRenderResource; }; struct TextureResource { - std::string m_FileName; - std::string m_CategoryName; - RwTexture *m_pRwTexture = nullptr; - void *m_pTexture = nullptr; + std::string m_FileName; + std::string m_CategoryName; + RwTexture *m_pRwTexture = nullptr; + void *m_pTexture = nullptr; }; enum eResourceType { - TYPE_IMAGE, - TYPE_TEXT, - TYPE_BOTH, + TYPE_IMAGE, + TYPE_TEXT, + TYPE_BOTH, }; using TextureResourceList = std::vector>; class ResourceStore { private: - void LoadTextureResource(std::string &&path); + void LoadTextureResource(std::string&& path); public: - ImGuiTextFilter m_Filter = ""; - std::vector m_Categories = {"All"}; - std::string m_Selected = "All"; - std::unique_ptr m_pJson; - TextureResourceList m_ImagesList; - ImVec2 m_ImageSize; - bool m_bTexturesLoaded = false; - - ResourceStore(const char *text, eResourceType type = TYPE_IMAGE, ImVec2 imageSize = ImVec2(64, 64)); + ImGuiTextFilter m_Filter = ""; + std::vector m_Categories = {"All"}; + std::string m_Selected = "All"; + std::unique_ptr m_pJson; + TextureResourceList m_ImagesList; + ImVec2 m_ImageSize; + bool m_bTexturesLoaded = false; + + ResourceStore(const char* text, eResourceType type = TYPE_IMAGE, ImVec2 imageSize = ImVec2(64, 64)); }; \ No newline at end of file diff --git a/src/teleport.cpp b/src/teleport.cpp index c385786..96c065a 100644 --- a/src/teleport.cpp +++ b/src/teleport.cpp @@ -1,297 +1,293 @@ +#include "pch.h" #include "teleport.h" #include "menu.h" -#include "pch.h" #include "ui.h" #include "util.h" #ifdef GTASA // FlA -tRadarTrace *CRadar::ms_RadarTrace = reinterpret_cast(patch::GetPointer(0x5838B0 + 2)); +tRadarTrace* CRadar::ms_RadarTrace = reinterpret_cast(patch::GetPointer(0x5838B0 + 2)); void Teleport::FetchRadarSpriteData() { - uint cur_timer = CTimer::m_snTimeInMilliseconds; - static uint timer = cur_timer; + uint cur_timer = CTimer::m_snTimeInMilliseconds; + static uint timer = cur_timer; - // Update the radar list each 5 seconds - if (cur_timer - timer < 5000) - { - return; - } + // Update the radar list each 5 seconds + if (cur_timer - timer < 5000) + { + return; + } - m_tpData.m_pJson->m_Data.erase("Radar"); + m_tpData.m_pJson->m_Data.erase("Radar"); - // 175 is the max number of sprites, FLA can increase this limit, might need to update this - for (int i = 0; i != 175; ++i) - { - CVector pos = CRadar::ms_RadarTrace[i].m_vPosition; - uchar sprite = CRadar::ms_RadarTrace[i].m_nBlipSprite; - auto sprite_name = m_SpriteJson.m_Data[std::to_string(sprite)].get(); - std::string key_name = sprite_name + ", " + Util::GetLocationName(&pos); + // 175 is the max number of sprites, FLA can increase this limit, might need to update this + for (int i = 0; i != 175; ++i) + { + CVector pos = CRadar::ms_RadarTrace[i].m_vPosition; + uchar sprite = CRadar::ms_RadarTrace[i].m_nBlipSprite; + auto sprite_name = m_SpriteJson.m_Data[std::to_string(sprite)].get(); + std::string key_name = sprite_name + ", " + Util::GetLocationName(&pos); - m_tpData.m_pJson->m_Data["Radar"][key_name] = - "0, " + std::to_string(pos.x) + ", " + std::to_string(pos.y) + ", " + std::to_string(pos.z); + m_tpData.m_pJson->m_Data["Radar"][key_name] = "0, " + std::to_string(pos.x) + ", " + std::to_string(pos.y) + ", " + + std::to_string(pos.z); - /* - "Radar" : { - "key_name" : "0, x, y, z", - } - */ - } + /* + "Radar" : { + "key_name" : "0, x, y, z", + } + */ + } } #endif Teleport::Teleport() { - m_bQuickTeleport = gConfig.GetValue("quick_teleport", false); + m_bQuickTeleport = gConfig.GetValue("quick_teleport", false); - Events::processScriptsEvent += [] { - if ((m_Teleport::m_bEnabled == true) && ((CTimer::m_snTimeInMilliseconds - m_Teleport::m_nTimer) > 500)) - { - CPlayerPed *player = FindPlayerPed(); + Events::processScriptsEvent += [] + { + if ((m_Teleport::m_bEnabled == true) && ((CTimer::m_snTimeInMilliseconds - m_Teleport::m_nTimer) > 500)) + { + CPlayerPed* player = FindPlayerPed(); #ifdef GTASA - CEntity *player_entity = FindPlayerEntity(-1); - m_Teleport::m_fPos.z = - CWorld::FindGroundZFor3DCoord(m_Teleport::m_fPos.x, m_Teleport::m_fPos.y, m_Teleport::m_fPos.z + 100.0f, - nullptr, &player_entity) + - 1.0f; + CEntity* player_entity = FindPlayerEntity(-1); + m_Teleport::m_fPos.z = CWorld::FindGroundZFor3DCoord(m_Teleport::m_fPos.x, m_Teleport::m_fPos.y, + m_Teleport::m_fPos.z + 100.0f, nullptr, &player_entity) + 1.0f; #else // GTA3 & GTAVC - m_Teleport::m_fPos.z = CWorld::FindGroundZFor3DCoord(m_Teleport::m_fPos.x, m_Teleport::m_fPos.y, - m_Teleport::m_fPos.z + 100.0f, nullptr) + - 1.0f; -#endif - CVehicle *pVeh = player->m_pVehicle; + m_Teleport::m_fPos.z = CWorld::FindGroundZFor3DCoord(m_Teleport::m_fPos.x, m_Teleport::m_fPos.y, + m_Teleport::m_fPos.z + 100.0f, nullptr) + 1.0f; +#endif + CVehicle* pVeh = player->m_pVehicle; - if (pVeh && BY_GAME(player->m_nPedFlags.bInVehicle, player->m_pVehicle, player->m_pVehicle)) - { - BY_GAME(pVeh->Teleport(m_Teleport::m_fPos, false), pVeh->Teleport(m_Teleport::m_fPos)); - } - else - { - BY_GAME(player->Teleport(m_Teleport::m_fPos, false), player->Teleport(m_Teleport::m_fPos)); - } + if (pVeh && BY_GAME(player->m_nPedFlags.bInVehicle, player->m_pVehicle, player->m_pVehicle)) + { + BY_GAME(pVeh->Teleport(m_Teleport::m_fPos, false, false), pVeh->Teleport(m_Teleport::m_fPos)); + } + else + { + BY_GAME(player->Teleport(m_Teleport::m_fPos, false, false), player->Teleport(m_Teleport::m_fPos)); + } - m_Teleport::m_bEnabled = false; - Command(CPools::GetPedRef(player), false); - Command(); - TheCamera.Fade(0, 1); - } + m_Teleport::m_bEnabled = false; + Command(CPools::GetPedRef(player), false); + Command(); + TheCamera.Fade(0, 1); + } - if (m_bQuickTeleport) - { - if (quickTeleport.Pressed() && ((CTimer::m_snTimeInMilliseconds - m_nQuickTeleportTimer) > 500)) - { - m_nQuickTeleportTimer = CTimer::m_snTimeInMilliseconds; - TeleportPlayer(true); - } - } - }; + if (m_bQuickTeleport) + { + if (quickTeleport.Pressed() + && ((CTimer::m_snTimeInMilliseconds - m_nQuickTeleportTimer) > 500)) + { + m_nQuickTeleportTimer = CTimer::m_snTimeInMilliseconds; + TeleportPlayer(true); + } + } + }; } void Teleport::TeleportPlayer(bool get_marker, CVector pos, int interior_id) { - CPlayerPed *pPlayer = FindPlayerPed(); - CVehicle *pVeh = pPlayer->m_pVehicle; - + CPlayerPed* pPlayer = FindPlayerPed(); + CVehicle* pVeh = pPlayer->m_pVehicle; + #ifdef GTASA - if (get_marker) - { - tRadarTrace targetBlip = CRadar::ms_RadarTrace[LOWORD(FrontEndMenuManager.m_nTargetBlipIndex)]; + if (get_marker) + { + tRadarTrace targetBlip = CRadar::ms_RadarTrace[LOWORD(FrontEndMenuManager.m_nTargetBlipIndex)]; - if (targetBlip.m_nBlipSprite != RADAR_SPRITE_WAYPOINT) - { - SetHelpMessage("Target blip not found. You need to place it on the map first.", false, false, false); - return; - } - CEntity *pPlayerEntity = FindPlayerEntity(-1); - pos = targetBlip.m_vPosition; - pos.z = CWorld::FindGroundZFor3DCoord(pos.x, pos.y, 1000, nullptr, &pPlayerEntity) + 50.f; + if (targetBlip.m_nBlipSprite != RADAR_SPRITE_WAYPOINT) + { + SetHelpMessage("Target blip not found. You need to place it on the map first.", false, false, false); + return; + } + CEntity* pPlayerEntity = FindPlayerEntity(-1); + pos = targetBlip.m_vPosition; + pos.z = CWorld::FindGroundZFor3DCoord(pos.x, pos.y, 1000, nullptr, &pPlayerEntity) + 50.f; - m_Teleport::m_fPos = pos; - m_Teleport::m_nTimer = CTimer::m_snTimeInMilliseconds; - m_Teleport::m_bEnabled = true; - TheCamera.Fade(0, 0); - Command(CPools::GetPedRef(pPlayer), true); - } + m_Teleport::m_fPos = pos; + m_Teleport::m_nTimer = CTimer::m_snTimeInMilliseconds; + m_Teleport::m_bEnabled = true; + TheCamera.Fade(0, 0); + Command(CPools::GetPedRef(pPlayer), true); + } #endif #ifdef GTA3 - CStreaming::LoadScene(pos); + CStreaming::LoadScene(pos); #else - CStreaming::LoadScene(&pos); - CStreaming::LoadSceneCollision(&pos); + CStreaming::LoadScene(&pos); + CStreaming::LoadSceneCollision(&pos); #endif - CStreaming::LoadAllRequestedModels(false); + CStreaming::LoadAllRequestedModels(false); #ifdef GTASA - if (pVeh && pPlayer->m_nPedFlags.bInVehicle) - { - pVeh->Teleport(pos, false); + if (pVeh && pPlayer->m_nPedFlags.bInVehicle) + { + pVeh->Teleport(pos, false); + + if (pVeh->m_nVehicleClass == VEHICLE_BIKE) + reinterpret_cast(pVeh)->PlaceOnRoadProperly(); + else if (pVeh->m_nVehicleClass != VEHICLE_BOAT) + reinterpret_cast(pVeh)->PlaceOnRoadProperly(); - if (pVeh->m_nVehicleClass == VEHICLE_BIKE) - reinterpret_cast(pVeh)->PlaceOnRoadProperly(); - else if (pVeh->m_nVehicleClass != VEHICLE_BOAT) - reinterpret_cast(pVeh)->PlaceOnRoadProperly(); - - BY_GAME(pVeh->m_nAreaCode, pVeh->m_nInterior) = interior_id; - } - else - { - pPlayer->Teleport(pos, false); - } + BY_GAME(pVeh->m_nAreaCode, pVeh->m_nInterior) = interior_id; + } + else + { + pPlayer->Teleport(pos, false); + } #else // GTA3 & GTAVC - if (pVeh && pPlayer->m_pVehicle) - { + if (pVeh && pPlayer->m_pVehicle) + { #ifndef GTA3 - BY_GAME(pPlayer->m_nAreaCode, pPlayer->m_nInterior, NULL) = interior_id; + BY_GAME(pPlayer->m_nAreaCode, pPlayer->m_nInterior, NULL) = interior_id; #endif - pVeh->Teleport(pos); - } - else - { - pPlayer->Teleport(pos); - } + pVeh->Teleport(pos); + } + else + { + pPlayer->Teleport(pos); + } #endif #ifndef GTA3 - BY_GAME(pPlayer->m_nAreaCode, pPlayer->m_nInterior, NULL) = interior_id; + BY_GAME(pPlayer->m_nAreaCode, pPlayer->m_nInterior, NULL) = interior_id; #endif - Command(interior_id); + Command(interior_id); } -void Teleport::TeleportToLocation(std::string &rootkey, std::string &bLocName, std::string &loc) +void Teleport::TeleportToLocation(std::string& rootkey, std::string& bLocName, std::string& loc) { - try - { - int dimension = 0; - CVector pos; - sscanf(loc.c_str(), "%d,%f,%f,%f", &dimension, &pos.x, &pos.y, &pos.z); - TeleportPlayer(false, pos, dimension); - } - catch (...) - { - SetHelpMessage("Invalid location", false, false, false); - } + try + { + int dimension = 0; + CVector pos; + sscanf(loc.c_str(), "%d,%f,%f,%f", &dimension, &pos.x, &pos.y, &pos.z); + TeleportPlayer(false, pos, dimension); + } + catch (...) + { + SetHelpMessage("Invalid location", false, false, false); + } } -void Teleport::RemoveTeleportEntry(std::string &category, std::string &key, std::string &val) +void Teleport::RemoveTeleportEntry(std::string& category, std::string& key, std::string& val) { - if (category == "Custom") - { - m_tpData.m_pJson->m_Data["Custom"].erase(key); - SetHelpMessage("Location removed", false, false, false); - m_tpData.m_pJson->WriteToDisk(); - } - else - { - SetHelpMessage("You can only remove custom location", false, false, false); - } + if (category == "Custom") + { + m_tpData.m_pJson->m_Data["Custom"].erase(key); + SetHelpMessage("Location removed", false, false, false); + m_tpData.m_pJson->WriteToDisk(); + } + else + { + SetHelpMessage("You can only remove custom location", false, false, false); + } } void Teleport::Draw() { - if (ImGui::BeginTabBar("Teleport", ImGuiTabBarFlags_NoTooltip + ImGuiTabBarFlags_FittingPolicyScroll)) - { - ImGui::Spacing(); - if (ImGui::BeginTabItem("Teleport")) - { - ImGui::Spacing(); - if (ImGui::BeginChild("Teleport Child")) - { - ImGui::Columns(2, nullptr, false); - ImGui::Checkbox("Insert coordinates", &m_bInsertCoord); - ImGui::NextColumn(); + if (ImGui::BeginTabBar("Teleport", ImGuiTabBarFlags_NoTooltip + ImGuiTabBarFlags_FittingPolicyScroll)) + { + ImGui::Spacing(); + if (ImGui::BeginTabItem("Teleport")) + { + ImGui::Spacing(); + if (ImGui::BeginChild("Teleport Child")) + { + ImGui::Columns(2, nullptr, false); + ImGui::Checkbox("Insert coordinates", &m_bInsertCoord); + ImGui::NextColumn(); #ifdef GTASA - if (Ui::CheckboxWithHint( - "Quick teleport", &m_bQuickTeleport, - std::string(std::string("Teleport to the location of your radar\ntarget blip using ") + - quickTeleport.GetNameString()) - .c_str())) - { - gConfig.SetValue("quick_teleport", m_bQuickTeleport); - } -#endif - ImGui::Columns(1); - ImGui::Spacing(); + if (Ui::CheckboxWithHint("Quick teleport", &m_bQuickTeleport, + std::string(std::string("Teleport to the location of your radar\ntarget blip using ") + + quickTeleport.GetNameString()).c_str())) + { + gConfig.SetValue("quick_teleport", m_bQuickTeleport); + } +#endif + ImGui::Columns(1); + ImGui::Spacing(); - if (m_bInsertCoord) - { - CVector pos = FindPlayerPed()->GetPosition(); + if (m_bInsertCoord) + { + CVector pos = FindPlayerPed()->GetPosition(); - strcpy(m_nInputBuffer, - (std::to_string(static_cast(pos.x)) + ", " + std::to_string(static_cast(pos.y)) + - ", " + std::to_string(static_cast(pos.z))) - .c_str()); - } + strcpy(m_nInputBuffer, + (std::to_string(static_cast(pos.x)) + ", " + std::to_string(static_cast(pos.y)) + + ", " + std::to_string(static_cast(pos.z))).c_str()); + } - ImGui::InputTextWithHint("Coordinates", "x, y, z", m_nInputBuffer, IM_ARRAYSIZE(m_nInputBuffer)); + ImGui::InputTextWithHint("Coordinates", "x, y, z", m_nInputBuffer, IM_ARRAYSIZE(m_nInputBuffer)); - ImGui::Spacing(); + ImGui::Spacing(); - if (ImGui::Button("Teleport to coord", Ui::GetSize(2))) - { - CVector pos{0, 0, 10}; + if (ImGui::Button("Teleport to coord", Ui::GetSize(2))) + { + CVector pos{0, 0, 10}; - try - { - sscanf(m_nInputBuffer, "%f,%f,%f", &pos.x, &pos.y, &pos.z); - pos.z += 1.0f; - TeleportPlayer(false, pos); - } - catch (...) - { - SetHelpMessage("Invalid coordinate", false, false, false); - } - } - ImGui::SameLine(); + try + { + sscanf(m_nInputBuffer,"%f,%f,%f", &pos.x, &pos.y, &pos.z); + pos.z += 1.0f; + TeleportPlayer(false, pos); + } + catch (...) + { + SetHelpMessage("Invalid coordinate", false, false, false); + } + } + ImGui::SameLine(); #ifdef GTASA - if (ImGui::Button("Teleport to marker", Ui::GetSize(2))) - { - TeleportPlayer(true); - } + if (ImGui::Button("Teleport to marker", Ui::GetSize(2))) + { + TeleportPlayer(true); + } #else - if (ImGui::Button("Teleport to map center", Ui::GetSize(2))) - { - TeleportPlayer(false, CVector(0, 0, 23)); - } + if (ImGui::Button("Teleport to map center", Ui::GetSize(2))) + { + TeleportPlayer(false, CVector(0, 0, 23)); + } #endif - ImGui::EndChild(); - } - ImGui::EndTabItem(); - } + ImGui::EndChild(); + } + ImGui::EndTabItem(); + } - if (ImGui::BeginTabItem("Search")) - { + if (ImGui::BeginTabItem("Search")) + { #ifdef GTASA - FetchRadarSpriteData(); + FetchRadarSpriteData(); #endif - ImGui::Spacing(); - Ui::DrawJSON(m_tpData, TeleportToLocation, RemoveTeleportEntry); - ImGui::EndTabItem(); - } + ImGui::Spacing(); + Ui::DrawJSON(m_tpData, TeleportToLocation,RemoveTeleportEntry); + ImGui::EndTabItem(); + } - if (ImGui::BeginTabItem("Custom")) - { - ImGui::Spacing(); - ImGui::InputTextWithHint("Location", "Groove Street", m_nLocationBuffer, IM_ARRAYSIZE(m_nInputBuffer)); - ImGui::InputTextWithHint("Coordinates", "x, y, z", m_nInputBuffer, IM_ARRAYSIZE(m_nInputBuffer)); - ImGui::Spacing(); - if (ImGui::Button("Add location", Ui::GetSize())) - { - m_tpData.m_pJson->m_Data["Custom"][m_nLocationBuffer] = ("0, " + std::string(m_nInputBuffer)); + if (ImGui::BeginTabItem("Custom")) + { + ImGui::Spacing(); + ImGui::InputTextWithHint("Location", "Groove Street", m_nLocationBuffer, IM_ARRAYSIZE(m_nInputBuffer)); + ImGui::InputTextWithHint("Coordinates", "x, y, z", m_nInputBuffer, IM_ARRAYSIZE(m_nInputBuffer)); + ImGui::Spacing(); + if (ImGui::Button("Add location", Ui::GetSize())) + { + m_tpData.m_pJson->m_Data["Custom"][m_nLocationBuffer] = ("0, " + std::string(m_nInputBuffer)); #ifdef GTASA - // Clear the Radar coordinates - m_tpData.m_pJson->m_Data.erase("Radar"); - m_tpData.m_pJson->m_Data["Radar"] = {}; + // Clear the Radar coordinates + m_tpData.m_pJson->m_Data.erase("Radar"); + m_tpData.m_pJson->m_Data["Radar"] = {}; #endif - m_tpData.m_pJson->WriteToDisk(); - } - ImGui::EndTabItem(); - } - ImGui::EndTabBar(); - } + m_tpData.m_pJson->WriteToDisk(); + } + ImGui::EndTabItem(); + } + ImGui::EndTabBar(); + } } diff --git a/src/teleport.h b/src/teleport.h index eea8965..07533b9 100644 --- a/src/teleport.h +++ b/src/teleport.h @@ -1,42 +1,42 @@ #pragma once -#include "pch.h" #include +#include "pch.h" class Teleport { private: - static inline bool m_bInsertCoord; - static inline bool m_bQuickTeleport; - static inline char m_nInputBuffer[INPUT_BUFFER_SIZE]; - static inline ResourceStore m_tpData{"teleport", eResourceType::TYPE_TEXT}; - static inline char m_nLocationBuffer[INPUT_BUFFER_SIZE]; - static inline uint m_nQuickTeleportTimer; + static inline bool m_bInsertCoord; + static inline bool m_bQuickTeleport; + static inline char m_nInputBuffer[INPUT_BUFFER_SIZE]; + static inline ResourceStore m_tpData{ "teleport", eResourceType::TYPE_TEXT }; + static inline char m_nLocationBuffer[INPUT_BUFFER_SIZE]; + static inline uint m_nQuickTeleportTimer; #ifdef GTASA - static inline CJson m_SpriteJson = CJson("radar sprite"); + static inline CJson m_SpriteJson = CJson("radar sprite"); #endif - struct m_Teleport - { - static inline bool m_bEnabled; - static inline CVector m_fPos = {-1, -1, -1}; - static inline uint m_nTimer; - }; + struct m_Teleport + { + static inline bool m_bEnabled; + static inline CVector m_fPos = { -1, -1, -1 }; + static inline uint m_nTimer; + }; + #ifdef GTASA - /* - Generates radar sprite coordinates on the fly. - Shouldn't get saved in 'teleport.json', needs to be cleared at game shutdown. - */ - static void FetchRadarSpriteData(); +/* + Generates radar sprite coordinates on the fly. + Shouldn't get saved in 'teleport.json', needs to be cleared at game shutdown. +*/ + static void FetchRadarSpriteData(); #endif protected: - Teleport(); - + Teleport(); public: - static void Draw(); - static void TeleportPlayer(bool get_marker = false, CVector pos = CVector(0, 0, 0), int interior_id = 0); - static void TeleportToLocation(std::string &rootkey, std::string &bLocName, std::string &loc); - static void RemoveTeleportEntry(std::string &rootkey, std::string &key, std::string &val); + static void Draw(); + static void TeleportPlayer(bool get_marker = false, CVector pos = CVector(0, 0, 0), int interior_id = 0); + static void TeleportToLocation(std::string& rootkey, std::string& bLocName, std::string& loc); + static void RemoveTeleportEntry(std::string& rootkey, std::string& key, std::string& val); }; diff --git a/src/timecycle.h b/src/timecycle.h index 6239c88..047682a 100644 --- a/src/timecycle.h +++ b/src/timecycle.h @@ -1,49 +1,49 @@ #pragma once -uchar *m_nAmbientRed = (uchar *)BY_GAME(0x560C61, 0x9388C8); -uchar *m_nAmbientGreen = (uchar *)BY_GAME(0x55F4D6, 0x78D508); -uchar *m_nAmbientBlue = (uchar *)BY_GAME(0x55F4E8, 0x813D48); - -uchar *m_nAmbientRed_Obj = (uchar *)BY_GAME(0x55F4FA, 0x7D53B0); -uchar *m_nAmbientGreen_Obj = (uchar *)BY_GAME(0x55F50C, 0x7D9370); -uchar *m_nAmbientBlue_Obj = (uchar *)BY_GAME(0x55F51E, 0x94C038); - -uchar *m_nSkyTopRed = (uchar *)BY_GAME(0x55F531, 0x94BE98); -uchar *m_nSkyTopGreen = (uchar *)BY_GAME(0x55F53D, 0x933A58); -uchar *m_nSkyTopBlue = (uchar *)BY_GAME(0x55F549, 0x94A170); - -uchar *m_nSkyBottomRed = (uchar *)BY_GAME(0x55F555, 0x7E44A0); -uchar *m_nSkyBottomGreen = (uchar *)BY_GAME(0x55F561, 0x7E9CD0); -uchar *m_nSkyBottomBlue = (uchar *)BY_GAME(0x55F56D, 0x92D420); - -uchar *m_nSunCoreRed = (uchar *)BY_GAME(0x55F59D, 0x944098); -uchar *m_nSunCoreGreen = (uchar *)BY_GAME(0x55F5A9, 0x7D94C0); -uchar *m_nSunCoreBlue = (uchar *)BY_GAME(0x55F5B5, 0x8614F8); - -uchar *m_nSunCoronaRed = (uchar *)BY_GAME(0x55F579, 0x78CCD8); -uchar *m_nSunCoronaGreen = (uchar *)BY_GAME(0x55F585, 0x7DBC08); -uchar *m_nSunCoronaBlue = (uchar *)BY_GAME(0x55F591, 0x7D1818); - -uchar *m_nLowCloudsRed = (uchar *)BY_GAME(0x55F653, 0x8100C0); -uchar *m_nLowCloudsGreen = (uchar *)BY_GAME(0x55F65F, 0x94AEA0); -uchar *m_nLowCloudsBlue = (uchar *)BY_GAME(0x55F66B, 0x94BDF0); - -uchar *m_fLightsOnGroundBrightness = (uchar *)BY_GAME(0x55F640, 0x92D378); -uchar *m_nPoleShadowStrength = (uchar *)BY_GAME(0x55F60F, 0x812090); -uchar *m_nLightShadowStrength = (uchar *)BY_GAME(0x55F603, 0x811828); -uchar *m_nShadowStrength = (uchar *)BY_GAME(0x55F5F7, 0x92D260); -uchar *m_fSpriteBrightness = (uchar *)BY_GAME(0x55F5E4, 0x7D5308); -uchar *m_fSpriteSize = (uchar *)BY_GAME(0x55F5D2, 0x94B848); -uchar *m_fSunSize = (uchar *)BY_GAME(0x55F5C0, 0x818720); -short *m_fFogStart = (short *)BY_GAME(0x55F62E, 0x94D638); -short *m_fFarClip = (short *)BY_GAME(0x55F61B, 0x94D4E8); - -uchar *m_fWaterRed = (uchar *)BY_GAME(0x55F69C, 0x7E5560); -uchar *m_fWaterGreen = (uchar *)BY_GAME(0x55F6B0, 0x7DE148); -uchar *m_fWaterBlue = (uchar *)BY_GAME(0x55F6C3, 0x862248); -uchar *m_fWaterAlpha = (uchar *)BY_GAME(0x55F6D6, 0x7DDAE0); - #ifdef GTASA +uchar *m_nAmbientRed = (uchar *)0x560C61; +uchar *m_nAmbientGreen = (uchar *)0x55F4D6; +uchar *m_nAmbientBlue = (uchar *)0x55F4E8; + +uchar *m_nAmbientRed_Obj = (uchar *)0x55F4FA; +uchar *m_nAmbientGreen_Obj = (uchar *)0x55F50C; +uchar *m_nAmbientBlue_Obj = (uchar *)0x55F51E; + +uchar *m_nSkyTopRed = (uchar *)0x55F531; +uchar *m_nSkyTopGreen = (uchar *)0x55F53D; +uchar *m_nSkyTopBlue = (uchar *)0x55F549; + +uchar *m_nSkyBottomRed = (uchar *)0x55F555; +uchar *m_nSkyBottomGreen = (uchar *)0x55F561; +uchar *m_nSkyBottomBlue = (uchar *)0x55F56D; + +uchar *m_nSunCoreRed = (uchar *)0x55F59D; +uchar *m_nSunCoreGreen = (uchar *)0x55F5A9; +uchar *m_nSunCoreBlue = (uchar *)0x55F5B5; + +uchar *m_nSunCoronaRed = (uchar *)0x55F579; +uchar *m_nSunCoronaGreen = (uchar *)0x55F585; +uchar *m_nSunCoronaBlue = (uchar *)0x55F591; + +uchar *m_nLowCloudsRed = (uchar *)0x55F653; +uchar *m_nLowCloudsGreen = (uchar *)0x55F65F; +uchar *m_nLowCloudsBlue = (uchar *)0x55F66B; + +uchar *m_fLightsOnGroundBrightness = (uchar *)0x55F640; +uchar *m_nPoleShadowStrength = (uchar *)0x55F60F; +uchar *m_nLightShadowStrength = (uchar *)0x55F603; +uchar *m_nShadowStrength = (uchar *)0x55F5F7; +uchar *m_fSpriteBrightness = (uchar *)0x55F5E4; +uchar *m_fSpriteSize = (uchar *)0x55F5D2; +uchar *m_fSunSize = (uchar *)0x55F5C0; +short *m_fFogStart = (short *)0x55F62E; +short *m_fFarClip = (short *)0x55F61B; + +uchar *m_fWaterRed = (uchar *)0x55F69C; +uchar *m_fWaterGreen = (uchar *)0x55F6B0; +uchar *m_fWaterBlue = (uchar *)0x55F6C3; +uchar *m_fWaterAlpha = (uchar *)0x55F6D6; + uchar *m_fPostFx2Alpha = (uchar *)0x55F77D; uchar *m_fPostFx2Blue = (uchar *)0x55F767; uchar *m_fPostFx2Green = (uchar *)0x55F751; @@ -63,6 +63,49 @@ uchar *m_nHighLightMinIntensity = (uchar *)0x55F7A9; uchar *m_fCloudAlpha = (uchar *)0x55F793; #elif GTAVC +uchar *m_nAmbientRed = (uchar *)0x9388C8; +uchar *m_nAmbientGreen = (uchar *)0x78D508; +uchar *m_nAmbientBlue = (uchar *)0x813D48; + +uchar *m_nAmbientRed_Obj = (uchar *)0x7D53B0; +uchar *m_nAmbientGreen_Obj = (uchar *)0x7D9370; +uchar *m_nAmbientBlue_Obj = (uchar *)0x94C038; + +uchar *m_nSkyTopRed = (uchar *)0x94BE98; +uchar *m_nSkyTopGreen = (uchar *)0x933A58; +uchar *m_nSkyTopBlue = (uchar *)0x94A170; + +uchar *m_nSkyBottomRed = (uchar *)0x7E44A0; +uchar *m_nSkyBottomGreen = (uchar *)0x7E9CD0; +uchar *m_nSkyBottomBlue = (uchar *)0x92D420; + +uchar *m_nSunCoreRed = (uchar *)0x944098; +uchar *m_nSunCoreGreen = (uchar *)0x7D94C0; +uchar *m_nSunCoreBlue = (uchar *)0x8614F8; + +uchar *m_nSunCoronaRed = (uchar *)0x78CCD8; +uchar *m_nSunCoronaGreen = (uchar *)0x7DBC08; +uchar *m_nSunCoronaBlue = (uchar *)0x7D1818; + +uchar *m_nLowCloudsRed = (uchar *)0x8100C0; +uchar *m_nLowCloudsGreen = (uchar *)0x94AEA0; +uchar *m_nLowCloudsBlue = (uchar *)0x94BDF0; + +uchar *m_fLightsOnGroundBrightness = (uchar *)0x92D378; +uchar *m_nPoleShadowStrength = (uchar *)0x812090; +uchar *m_nLightShadowStrength = (uchar *)0x811828; +uchar *m_nShadowStrength = (uchar *)0x92D260; +uchar *m_fSpriteBrightness = (uchar *)0x7D5308; +uchar *m_fSpriteSize = (uchar *)0x94B848; +uchar *m_fSunSize = (uchar *)0x818720; +short *m_fFogStart = (short *)0x94D638; +short *m_fFarClip = (short *)0x94D4E8; + +uchar *m_fWaterRed = (uchar *)0x7E5560; +uchar *m_fWaterGreen = (uchar *)0x7DE148; +uchar *m_fWaterBlue = (uchar *)0x862248; +uchar *m_fWaterAlpha = (uchar *)0x7DDAE0; + uchar *m_nAmbientBlRed = (uchar *)0x78D5B0; uchar *m_nAmbientBlGreen = (uchar *)0x861430; uchar *m_nAmbientBlBlue = (uchar *)0x811740; @@ -86,4 +129,57 @@ uchar *m_nBottomCloudsBlue = (uchar *)0x7D9630; uchar *m_nBlurRed = (uchar *)0x94B790; uchar *m_nBlurGreen = (uchar *)0x8621A0; uchar *m_nBlurBlue = (uchar *)0x945728; + +#else // GTA3 + +uchar *m_nAmbientRed = (uchar *)0x86AF78; +uchar *m_nAmbientGreen = (uchar *)0x665308; +uchar *m_nAmbientBlue = (uchar *)0x72CF88; + +uchar *m_nDirRed = (uchar *)0x6FAB78; +uchar *m_nDirGreen = (uchar *)0x6F4528; +uchar *m_nDirBlue = (uchar *)0x83CE58; + +uchar *m_nSkyTopRed = (uchar *)0x87FB90; +uchar *m_nSkyTopGreen = (uchar *)0x8460A8; +uchar *m_nSkyTopBlue = (uchar *)0x87B158; + +uchar *m_nSkyBottomRed = (uchar *)0x6FA960; +uchar *m_nSkyBottomGreen = (uchar *)0x70D6A8; +uchar *m_nSkyBottomBlue = (uchar *)0x83D288; + +uchar *m_nSunCoreRed = (uchar *)0x878360; +uchar *m_nSunCoreGreen = (uchar *)0x6EE088; +uchar *m_nSunCoreBlue = (uchar *)0x773A68; + +uchar *m_nSunCoronaRed = (uchar *)0x664B60; +uchar *m_nSunCoronaGreen = (uchar *)0x6F01E0; +uchar *m_nSunCoronaBlue = (uchar *)0x6E6340; + +uchar *m_nShadowStrength = (uchar *)0x83CFD8; +uchar *m_nLightShadowStrength = (uchar *)0x72B0F8; +uchar *m_nTreeShadowStrength = (uchar *)0x733450; +uchar *m_fSunSize = (uchar *)0x733510; +uchar *m_fSpriteSize = (uchar *)0x87F820; +uchar *m_fSpriteBrightness = (uchar *)0x6E96F0; +short *m_fFarClip = (short *)0x8804E0; +short *m_fFogStart = (short *)0x8806C8; +uchar *m_fLightsOnGroundBrightness = (uchar *)0x83D108; + +uchar *m_nLowCloudsRed = (uchar *)0x726770; +uchar *m_nLowCloudsGreen = (uchar *)0x87BF08; +uchar *m_nLowCloudsBlue = (uchar *)0x87FA10; + +uchar *m_nTopCloudsRed = (uchar *)0x70F2B0; +uchar *m_nTopCloudsGreen = (uchar *)0x72D288; +uchar *m_nTopCloudsBlue = (uchar *)0x86B108; + +uchar *m_nBottomCloudsRed = (uchar *)0x6E8DA8; +uchar *m_nBottomCloudsGreen = (uchar *)0x715AA8; +uchar *m_nBottomCloudsBlue = (uchar *)0x6EE2D0; + +uchar *m_fWaterRed = (uchar *)0x87C7E0; +uchar *m_fWaterGreen = (uchar *)0x774C10; +uchar *m_fWaterBlue = (uchar *)0x8784E0; +uchar *m_fWaterAlpha = (uchar *)0x733690; #endif diff --git a/src/ui.cpp b/src/ui.cpp index 478cc5a..ac9f372 100644 --- a/src/ui.cpp +++ b/src/ui.cpp @@ -1,864 +1,867 @@ -#include "ui.h" #include "pch.h" #include "util.h" +#include "ui.h" -bool Ui::ListBox(const char *label, std::vector &all_items, int &selected) +bool Ui::ListBox(const char* label, std::vector& 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 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 &all_items, std::string &selected) +bool Ui::ListBoxStr(const char* label, std::vector& all_items, std::string& selected) { - bool rtn = false; - if (ImGui::BeginCombo(label, selected.c_str())) - { - for (std::string current_item : all_items) - { - if (ImGui::MenuItem(current_item.c_str())) - { - selected = current_item; - rtn = true; - } - } - ImGui::EndCombo(); - } + bool rtn = false; + if (ImGui::BeginCombo(label, selected.c_str())) + { + for (std::string current_item : all_items) + { + if (ImGui::MenuItem(current_item.c_str())) + { + selected = current_item; + rtn = true; + } + } + ImGui::EndCombo(); + } - return rtn; + return rtn; } -bool Ui::ListBoxCustomNames(const char *label, std::vector &all_items, std::string &selected, - const char *customNames[], size_t length) +bool Ui::ListBoxCustomNames(const char* label, std::vector& all_items, std::string& selected, const char* customNames[], size_t length) { - bool rtn = false; - std::string display_selected = (selected == "All") ? selected : customNames[std::stoi(selected)]; + bool rtn = false; + std::string display_selected = (selected == "All") ? selected : customNames[std::stoi(selected)]; - if (ImGui::BeginCombo(label, display_selected.c_str())) - { - if (ImGui::MenuItem("All")) - { - selected = "All"; - rtn = true; - } + if (ImGui::BeginCombo(label, display_selected.c_str())) + { + if (ImGui::MenuItem("All")) + { + selected = "All"; + rtn = true; + } - for (size_t i = 0; i < length; ++i) - { - if (ImGui::MenuItem(customNames[i])) - { - selected = std::to_string(i); - rtn = true; - break; - } - } - ImGui::EndCombo(); - } - return rtn; + for (size_t i = 0; i < length; ++i) + { + if (ImGui::MenuItem(customNames[i])) + { + selected = std::to_string(i); + rtn = true; + break; + } + } + ImGui::EndCombo(); + } + return rtn; } ImVec2 Ui::GetSize(short count, bool spacing) { - if (count == 1) - spacing = false; + if (count == 1) + spacing = false; - float factor = ImGui::GetStyle().ItemSpacing.x / 2.0f; - float x; + float factor = ImGui::GetStyle().ItemSpacing.x / 2.0f; + float x; - if (count == 3) - factor = ImGui::GetStyle().ItemSpacing.x / 1.403f; + if (count == 3) + factor = ImGui::GetStyle().ItemSpacing.x / 1.403f; - if (spacing) - x = ImGui::GetWindowContentRegionWidth() / count - factor; - else - x = ImGui::GetWindowContentRegionWidth() / count; + if (spacing) + x = ImGui::GetWindowContentRegionWidth() / count - factor; + else + x = ImGui::GetWindowContentRegionWidth() / count; - return ImVec2(x, ImGui::GetFrameHeight() * 1.3f); + return ImVec2(x, ImGui::GetFrameHeight() * 1.3f); } -void Ui::CenterdText(const std::string &text) +void Ui::CenterdText(const std::string& text) { - float font_size = ImGui::GetFontSize() * text.size() / 2; - ImGui::NewLine(); - ImGui::SameLine(ImGui::GetWindowSize().x / 2 - font_size + (font_size / 1.8)); - ImGui::Text(text.c_str()); + float font_size = ImGui::GetFontSize() * text.size() / 2; + ImGui::NewLine(); + ImGui::SameLine(ImGui::GetWindowSize().x / 2 - font_size + (font_size / 1.8)); + ImGui::Text(text.c_str()); } -void Ui::DrawHeaders(CallbackTable &data) +void Ui::DrawHeaders(CallbackTable& data) { - ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(0, 0)); + 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(); + 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 == m_HeaderId) - { - colors[ImGuiCol_Button] = colors[ImGuiCol_ButtonActive]; - func = it->second; - } + if (btn_text == m_HeaderId) + { + colors[ImGuiCol_Button] = colors[ImGuiCol_ButtonActive]; + func = it->second; + } - if (ImGui::Button(btn_text, GetSize(3, false))) - { - m_HeaderId = btn_text; - gConfig.SetValue("window.id", m_HeaderId); - func = it->second; - } - colors[ImGuiCol_Button] = btn_col; + if (ImGui::Button(btn_text, GetSize(3, false))) + { + m_HeaderId = btn_text; + gConfig.SetValue("window.id", m_HeaderId); + func = it->second; + } - if (i % 3 != 0) - ImGui::SameLine(); - i++; - } - ImGui::PopStyleVar(); - ImGui::Dummy(ImVec2(0, 10)); + colors[ImGuiCol_Button] = btn_col; - if (m_HeaderId == "") - { - // Show Welcome page - ImGui::NewLine(); + if (i % 3 != 0) + ImGui::SameLine(); + i++; + } + ImGui::PopStyleVar(); + ImGui::Dummy(ImVec2(0, 10)); - CenterdText("Welcome to Cheat Menu"); - CenterdText("Author: Grinch_"); + if (m_HeaderId == "") + { + // Show Welcome page + ImGui::NewLine(); - ImGui::NewLine(); - ImGui::TextWrapped("Please ensure you have the latest version from GitHub."); - ImGui::NewLine(); - if (ImGui::Button("Discord server", ImVec2(GetSize(2)))) - ShellExecute(nullptr, "open", DISCORD_INVITE, nullptr, nullptr, SW_SHOWNORMAL); + CenterdText("Welcome to Cheat Menu"); + CenterdText("Author: Grinch_"); - ImGui::SameLine(); + ImGui::NewLine(); + ImGui::TextWrapped("Please ensure you have the latest version from GitHub."); + ImGui::NewLine(); + if (ImGui::Button("Discord server", ImVec2(GetSize(2)))) + ShellExecute(nullptr, "open", DISCORD_INVITE, nullptr, nullptr, SW_SHOWNORMAL); - if (ImGui::Button("GitHub repo", ImVec2(GetSize(2)))) - ShellExecute(nullptr, "open", GITHUB_LINK, nullptr, nullptr, SW_SHOWNORMAL); + ImGui::SameLine(); - ImGui::NewLine(); - ImGui::TextWrapped("If you find bugs or have suggestions, you can let me know on discord :)"); - ImGui::Dummy(ImVec2(0, 30)); - CenterdText("Copyright Grinch_ 2019-2022. All rights reserved."); - } - else - { - if (func != nullptr && ImGui::BeginChild("TABSBAR")) - { - static_cast(func)(); - ImGui::EndChild(); - } - } + if (ImGui::Button("GitHub repo", ImVec2(GetSize(2)))) + ShellExecute(nullptr, "open", GITHUB_LINK, nullptr, nullptr, SW_SHOWNORMAL); + + ImGui::NewLine(); + ImGui::TextWrapped("If you find bugs or have suggestions, you can let me know on discord :)"); + ImGui::Dummy(ImVec2(0, 30)); + CenterdText("Copyright Grinch_ 2019-2022. All rights reserved."); + } + else + { + if (func != nullptr && ImGui::BeginChild("TABSBAR")) + { + static_cast(func)(); + ImGui::EndChild(); + } + } } -void Ui::ShowTooltip(const char *text) +void Ui::ShowTooltip(const char* text) { - ImGui::SameLine(); - ImGui::TextDisabled("?"); + ImGui::SameLine(); + ImGui::TextDisabled("?"); - if (ImGui::IsItemHovered()) - { - ImGui::BeginTooltip(); - ImGui::Text(text); - ImGui::EndTooltip(); - } + if (ImGui::IsItemHovered()) + { + ImGui::BeginTooltip(); + ImGui::Text(text); + ImGui::EndTooltip(); + } } -bool Ui::CheckboxWithHint(const char *label, bool *v, const char *hint, bool is_disabled) +bool Ui::CheckboxWithHint(const char* label, bool* v, const char* hint, bool is_disabled) { - // set things up - bool pressed = false; - const ImGuiStyle &style = ImGui::GetStyle(); - const ImVec2 textSize = ImGui::CalcTextSize(label, nullptr, true); - float square_sz = ImGui::GetFrameHeight(); - ImDrawList *drawlist = ImGui::GetWindowDrawList(); - ImU32 color = ImGui::GetColorU32(ImGuiCol_FrameBg); - std::string slabel = "##InvCheckboxBtn" + std::string(label); + // set things up + bool pressed = false; + const ImGuiStyle& style = ImGui::GetStyle(); + const ImVec2 textSize = ImGui::CalcTextSize(label, nullptr, true); + float square_sz = ImGui::GetFrameHeight(); + ImDrawList* drawlist = ImGui::GetWindowDrawList(); + ImU32 color = ImGui::GetColorU32(ImGuiCol_FrameBg); + std::string slabel = "##InvCheckboxBtn" + std::string(label); - ImGui::BeginDisabled(is_disabled); + ImGui::BeginDisabled(is_disabled); + + // process the button states + if (ImGui::InvisibleButton(slabel.c_str(), ImVec2(square_sz, square_sz)) && !is_disabled) + { + pressed = true; + *v = !*v; + } - // process the button states - if (ImGui::InvisibleButton(slabel.c_str(), ImVec2(square_sz, square_sz)) && !is_disabled) - { - pressed = true; - *v = !*v; - } + if (ImGui::IsItemHovered() && !is_disabled) + color = ImGui::GetColorU32(ImGuiCol_FrameBgHovered); - if (ImGui::IsItemHovered() && !is_disabled) - color = ImGui::GetColorU32(ImGuiCol_FrameBgHovered); + // draw the button + ImVec2 min = ImGui::GetItemRectMin(); + ImVec2 max = ImGui::GetItemRectMax(); + drawlist->AddRectFilled(min, max, color); - // draw the button - ImVec2 min = ImGui::GetItemRectMin(); - ImVec2 max = ImGui::GetItemRectMax(); - drawlist->AddRectFilled(min, max, color); + int pad = static_cast(square_sz / 6.0); + pad = (pad < 1) ? 1 : pad; - int pad = static_cast(square_sz / 6.0); - pad = (pad < 1) ? 1 : pad; + if (*v) + { + // draw the checkmark + float sz = (square_sz - pad * 2.0); + float thickness = sz / 5.0; + thickness = (thickness < 1.0) ? 1.0 : thickness; + sz = sz - thickness * 0.5; - if (*v) - { - // draw the checkmark - float sz = (square_sz - pad * 2.0); - float thickness = sz / 5.0; - thickness = (thickness < 1.0) ? 1.0 : thickness; - sz = sz - thickness * 0.5; + auto pos = ImVec2(min.x + pad, min.y + pad); + pos.x = pos.x + thickness * 0.25; + pos.y = pos.y + thickness * 0.25; - auto pos = ImVec2(min.x + pad, min.y + pad); - pos.x = pos.x + thickness * 0.25; - pos.y = pos.y + thickness * 0.25; + float third = sz / 3.0; + float bx = pos.x + third; + float by = pos.y + sz - third * 0.5; - float third = sz / 3.0; - float bx = pos.x + third; - float by = pos.y + sz - third * 0.5; + drawlist->PathLineTo(ImVec2(bx - third, by - third)); + drawlist->PathLineTo(ImVec2(bx, by)); + drawlist->PathLineTo(ImVec2(bx + third * 2.0, by - third * 2.0)); + drawlist->PathStroke(ImGui::GetColorU32(ImGuiCol_CheckMark), false, thickness); + } - drawlist->PathLineTo(ImVec2(bx - third, by - third)); - drawlist->PathLineTo(ImVec2(bx, by)); - drawlist->PathLineTo(ImVec2(bx + third * 2.0, by - third * 2.0)); - drawlist->PathStroke(ImGui::GetColorU32(ImGuiCol_CheckMark), false, thickness); - } + // draw label + ImGui::SameLine(0, style.ItemInnerSpacing.x); + if (ImGui::InvisibleButton(label, ImVec2(ImGui::CalcTextSize(label, nullptr, true).x, square_sz)) && !is_disabled) + { + pressed = true; + *v = !*v; + } + min = ImGui::GetItemRectMin(); + drawlist->AddText(ImVec2(min.x, min.y + style.ItemInnerSpacing.y), ImGui::GetColorU32(ImGuiCol_Text), label); - // draw label - ImGui::SameLine(0, style.ItemInnerSpacing.x); - if (ImGui::InvisibleButton(label, ImVec2(ImGui::CalcTextSize(label, nullptr, true).x, square_sz)) && !is_disabled) - { - pressed = true; - *v = !*v; - } - min = ImGui::GetItemRectMin(); - drawlist->AddText(ImVec2(min.x, min.y + style.ItemInnerSpacing.y), ImGui::GetColorU32(ImGuiCol_Text), label); + // draw hint + if (hint != nullptr) + { + ImGui::SameLine(0, style.ItemInnerSpacing.x); + ImGui::InvisibleButton("?", ImGui::CalcTextSize("?", nullptr, true)); + min = ImGui::GetItemRectMin(); + drawlist->AddText(ImVec2(min.x, min.y + style.ItemInnerSpacing.y), ImGui::GetColorU32(ImGuiCol_TextDisabled), + "?"); - // draw hint - if (hint != nullptr) - { - ImGui::SameLine(0, style.ItemInnerSpacing.x); - ImGui::InvisibleButton("?", ImGui::CalcTextSize("?", nullptr, true)); - min = ImGui::GetItemRectMin(); - drawlist->AddText(ImVec2(min.x, min.y + style.ItemInnerSpacing.y), ImGui::GetColorU32(ImGuiCol_TextDisabled), - "?"); + if (ImGui::IsItemHovered() && !is_disabled) + { + ImGui::BeginTooltip(); + ImGui::Text(hint); + ImGui::Spacing(); + ImGui::EndTooltip(); + } + } - if (ImGui::IsItemHovered() && !is_disabled) - { - ImGui::BeginTooltip(); - ImGui::Text(hint); - ImGui::Spacing(); - ImGui::EndTooltip(); - } - } + ImGui::EndDisabled(); - ImGui::EndDisabled(); - - return pressed; + return pressed; } -bool Ui::CheckboxAddress(const char *label, const int addr, const char *hint) +bool Ui::CheckboxAddress(const char* label, const int addr, const char* hint) { - bool rtn = false; - bool state = patch::Get(addr, false); + bool rtn = false; + bool state = patch::Get(addr, false); - if (CheckboxWithHint(label, &state, hint) && addr != NULL) - { - patch::Set(addr, state, false); - rtn = true; - } + if (CheckboxWithHint(label, &state, hint) && addr != NULL) + { + patch::Set(addr, state, false); + rtn = true; + } - return rtn; + return rtn; } -bool Ui::CheckboxAddressEx(const char *label, const int addr, int enabled_val, int disabled_val, const char *hint) +bool Ui::CheckboxAddressEx(const char* label, const int addr, int enabled_val, int disabled_val, const char* hint) { - bool rtn = false; + bool rtn = false; - bool state = false; - int val = 0; - patch::GetRaw(addr, &val, 1, false); + bool state = false; + int val = 0; + patch::GetRaw(addr, &val, 1, false); - if (val == enabled_val) - state = true; + 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; - } + 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; + return rtn; } -bool Ui::CheckboxAddressVar(const char *label, bool val, int addr, const char *hint) +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(addr, state, false); - rtn = true; - } + bool rtn = false; + bool state = val; + if (CheckboxWithHint(label, &state, hint)) + { + patch::Set(addr, state, false); + rtn = true; + } - return rtn; + return rtn; } -bool Ui::CheckboxAddressVarEx(const char *label, bool val, int addr, int enabled_val, int disabled_val, - const char *hint) +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); + 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; - } + rtn = true; + } - return rtn; + return rtn; } -bool Ui::CheckboxBitFlag(const char *label, uint flag, const char *hint) +bool Ui::CheckboxBitFlag(const char* label, uint flag, const char* hint) { - bool rtn = false; - bool state = (flag == 1) ? true : false; - if (CheckboxWithHint(label, &state, hint)) - { - flag = state ? 1 : 0; - rtn = true; - } + bool rtn = false; + bool state = (flag == 1) ? true : false; + if (CheckboxWithHint(label, &state, hint)) + { + flag = state ? 1 : 0; + rtn = true; + } - return rtn; + return rtn; } -void Ui::DrawJSON(ResourceStore &data, std::function func_left_click, - std::function func_right_click) +void Ui::DrawJSON(ResourceStore& data, + std::function func_left_click, + std::function func_right_click) { - ImGui::PushItemWidth(ImGui::GetContentRegionAvailWidth() / 2 - 5); - ListBoxStr("##Categories", data.m_Categories, data.m_Selected); - ImGui::SameLine(); + ImGui::PushItemWidth(ImGui::GetContentRegionAvailWidth() / 2 - 5); + ListBoxStr("##Categories", data.m_Categories, data.m_Selected); + ImGui::SameLine(); - data.m_Filter.Draw("##Filter"); - if (strlen(data.m_Filter.InputBuf) == 0) - { - ImDrawList *drawlist = ImGui::GetWindowDrawList(); + data.m_Filter.Draw("##Filter"); + if (strlen(data.m_Filter.InputBuf) == 0) + { + ImDrawList* drawlist = ImGui::GetWindowDrawList(); - ImVec2 min = ImGui::GetItemRectMin(); - min.x += ImGui::GetStyle().FramePadding.x; - min.y += ImGui::GetStyle().FramePadding.y; + ImVec2 min = ImGui::GetItemRectMin(); + min.x += ImGui::GetStyle().FramePadding.x; + min.y += ImGui::GetStyle().FramePadding.y; - drawlist->AddText(min, ImGui::GetColorU32(ImGuiCol_TextDisabled), "Search"); - } + drawlist->AddText(min, ImGui::GetColorU32(ImGuiCol_TextDisabled), "Search"); + } - ImGui::PopItemWidth(); + ImGui::PopItemWidth(); - ImGui::Spacing(); + ImGui::Spacing(); - if (ImGui::IsMouseClicked(1)) - { - jsonPopup.function = nullptr; - } + if (ImGui::IsMouseClicked(1)) + { + jsonPopup.function = nullptr; + } - ImGui::BeginChild(1); - for (auto root : data.m_pJson->m_Data.items()) - { - if (root.key() == data.m_Selected || data.m_Selected == "All") - { - for (auto _data : root.value().items()) - { - std::string name = _data.key(); - if (data.m_Filter.PassFilter(name.c_str())) - { - if (ImGui::MenuItem(name.c_str()) && func_left_click != nullptr) - { - std::string root_key = root.key(); - std::string data_key = _data.key(); - std::string data_val = _data.value(); - func_left_click(root_key, data_key, data_val); - } + ImGui::BeginChild(1); + for (auto root : data.m_pJson->m_Data.items()) + { + if (root.key() == data.m_Selected || data.m_Selected == "All") + { + for (auto _data : root.value().items()) + { + std::string name = _data.key(); + if (data.m_Filter.PassFilter(name.c_str())) + { + if (ImGui::MenuItem(name.c_str()) && func_left_click != nullptr) + { + std::string root_key = root.key(); + std::string data_key = _data.key(); + std::string data_val = _data.value(); - if (ImGui::IsItemClicked(1) && func_right_click != nullptr) - { - jsonPopup.function = func_right_click; - jsonPopup.rootKey = root.key(); - jsonPopup.key = name; - jsonPopup.value = _data.value(); - } - } - } - } - } + func_left_click(root_key, data_key, data_val); + } - if (jsonPopup.function != nullptr) - { - if (ImGui::BeginPopupContextWindow()) - { - ImGui::Text(jsonPopup.key.c_str()); - ImGui::Separator(); - if (ImGui::MenuItem("Remove")) - jsonPopup.function(jsonPopup.rootKey, jsonPopup.key, jsonPopup.value); + if (ImGui::IsItemClicked(1) && func_right_click != nullptr) + { + jsonPopup.function = func_right_click; + jsonPopup.rootKey = root.key(); + jsonPopup.key = name; + jsonPopup.value = _data.value(); + } + } + } + } + } - if (ImGui::MenuItem("Close")) - jsonPopup.function = nullptr; + if (jsonPopup.function != nullptr) + { + if (ImGui::BeginPopupContextWindow()) + { + ImGui::Text(jsonPopup.key.c_str()); + ImGui::Separator(); + if (ImGui::MenuItem("Remove")) + jsonPopup.function(jsonPopup.rootKey, jsonPopup.key, jsonPopup.value); - ImGui::EndPopup(); - } - } - ImGui::EndChild(); + + if (ImGui::MenuItem("Close")) + jsonPopup.function = nullptr; + + ImGui::EndPopup(); + } + } + ImGui::EndChild(); } #ifdef GTASA -void Ui::EditStat(const char *label, const int stat_id, const int min, const int def, const int max) +void Ui::EditStat(const char* label, const int stat_id, const int min, const int def, const int max) { - if (ImGui::CollapsingHeader(label)) - { - int val = static_cast(CStats::GetStatValue(stat_id)); + if (ImGui::CollapsingHeader(label)) + { + int val = static_cast(CStats::GetStatValue(stat_id)); - ImGui::Columns(3, nullptr, false); - ImGui::Text("Min: %d", min); - ImGui::NextColumn(); - ImGui::Text("Def: %d", def); - ImGui::NextColumn(); - ImGui::Text("Max: %d", max); - ImGui::Columns(1); + ImGui::Columns(3, nullptr, false); + ImGui::Text("Min: %d", min); + ImGui::NextColumn(); + ImGui::Text("Def: %d", def); + ImGui::NextColumn(); + ImGui::Text("Max: %d", max); + ImGui::Columns(1); - ImGui::Spacing(); + ImGui::Spacing(); - if (ImGui::InputInt(("Set value##" + std::string(label)).c_str(), &val)) - CStats::SetStatValue(stat_id, static_cast(val)); + if (ImGui::InputInt(("Set value##" + std::string(label)).c_str(), &val)) + CStats::SetStatValue(stat_id, static_cast(val)); - ImGui::Spacing(); + ImGui::Spacing(); - if (ImGui::Button(("Minimum##" + std::string(label)).c_str(), GetSize(3))) - CStats::SetStatValue(stat_id, static_cast(min)); + if (ImGui::Button(("Minimum##" + std::string(label)).c_str(), GetSize(3))) + CStats::SetStatValue(stat_id, static_cast(min)); - ImGui::SameLine(); + ImGui::SameLine(); - if (ImGui::Button(("Default##" + std::string(label)).c_str(), GetSize(3))) - CStats::SetStatValue(stat_id, static_cast(def)); + if (ImGui::Button(("Default##" + std::string(label)).c_str(), GetSize(3))) + CStats::SetStatValue(stat_id, static_cast(def)); - ImGui::SameLine(); + ImGui::SameLine(); - if (ImGui::Button(("Maximum##" + std::string(label)).c_str(), GetSize(3))) - CStats::SetStatValue(stat_id, static_cast(max)); + if (ImGui::Button(("Maximum##" + std::string(label)).c_str(), GetSize(3))) + CStats::SetStatValue(stat_id, static_cast(max)); - ImGui::Spacing(); - ImGui::Separator(); - } + ImGui::Spacing(); + ImGui::Separator(); + } } #endif -void Ui::FilterWithHint(const char *label, ImGuiTextFilter &filter, const char *hint) +void Ui::FilterWithHint(const char* label, ImGuiTextFilter& filter, const char* hint) { - filter.Draw(label); + filter.Draw(label); - if (strlen(filter.InputBuf) == 0) - { - ImDrawList *drawlist = ImGui::GetWindowDrawList(); + 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; + ImVec2 min = ImGui::GetItemRectMin(); + min.x += ImGui::GetStyle().FramePadding.x; + min.y += ImGui::GetStyle().FramePadding.y; - drawlist->AddText(min, ImGui::GetColorU32(ImGuiCol_TextDisabled), hint); - } + drawlist->AddText(min, ImGui::GetColorU32(ImGuiCol_TextDisabled), hint); + } } -void Ui::DrawImages(ResourceStore &store, std::function onLeftClick, - std::function onRightClick, std::function getName, - std::function verifyFunc, const char **customNames, size_t length) +void Ui::DrawImages(ResourceStore &store, std::function onLeftClick, std::function onRightClick, + std::function getName, std::function verifyFunc, + const char** customNames, size_t length) { - /* - Trying to scale images based on resolutions - Native 1366x768 - */ - ImVec2 m_ImageSize = store.m_ImageSize; - m_ImageSize.x *= screen::GetScreenWidth() / 1366.0f; - m_ImageSize.y *= screen::GetScreenHeight() / 768.0f; + /* + Trying to scale images based on resolutions + Native 1366x768 + */ + ImVec2 m_ImageSize = store.m_ImageSize; + m_ImageSize.x *= screen::GetScreenWidth() / 1366.0f; + m_ImageSize.y *= screen::GetScreenHeight() / 768.0f; - int imageCount = 1; - int imagesInRow = static_cast(ImGui::GetWindowContentRegionWidth() / m_ImageSize.x); - m_ImageSize.x = - ImGui::GetWindowContentRegionWidth() / imagesInRow - static_cast(ImGuiStyleVar_ItemSpacing) * 0.65f; + int imageCount = 1; + int imagesInRow = static_cast(ImGui::GetWindowContentRegionWidth() / m_ImageSize.x); + m_ImageSize.x = ImGui::GetWindowContentRegionWidth() / imagesInRow - static_cast(ImGuiStyleVar_ItemSpacing) * 0.65f; - ImGui::Spacing(); + ImGui::Spacing(); - // Hide the popup if right clicked again - if (ImGui::IsMouseClicked(1)) - { - imgPopup.function = nullptr; - } + // Hide the popup if right clicked again + if (ImGui::IsMouseClicked(1)) + { + imgPopup.function = nullptr; + } - ImGui::PushItemWidth(ImGui::GetContentRegionAvailWidth() / 2 - 5); - if (customNames) - { - ListBoxCustomNames("##Categories", store.m_Categories, store.m_Selected, customNames, length); - } - else - { - ListBoxStr("##Categories", store.m_Categories, store.m_Selected); - } + ImGui::PushItemWidth(ImGui::GetContentRegionAvailWidth() / 2 - 5); + if (customNames) + { + ListBoxCustomNames("##Categories", store.m_Categories, store.m_Selected, customNames, length); + } + else + { + ListBoxStr("##Categories", store.m_Categories, store.m_Selected); + } - ImGui::SameLine(); - FilterWithHint("##Filter", store.m_Filter, "Search"); + ImGui::SameLine(); + FilterWithHint("##Filter", store.m_Filter, "Search"); - ImGui::Spacing(); + ImGui::Spacing(); - ImGui::BeginChild("DrawImages"); - for (uint i = 0; i < store.m_ImagesList.size(); ++i) - { - std::string text = store.m_ImagesList[i]->m_FileName; - std::string modelName = getName(text); + ImGui::BeginChild("DrawImages"); + for (uint i = 0; i < store.m_ImagesList.size(); ++i) + { + std::string text = store.m_ImagesList[i]->m_FileName; + std::string modelName = getName(text); - if (store.m_Filter.PassFilter(modelName.c_str()) && - (store.m_ImagesList[i]->m_CategoryName == store.m_Selected || store.m_Selected == "All") && - (verifyFunc == nullptr || verifyFunc(text))) - { - /* - Couldn't figure out how to laod images for Dx11 - Using texts for now - */ - if (gRenderer == Render_DirectX11) - { - if (ImGui::MenuItem(modelName.c_str())) - { - onLeftClick(text); - } - } - else - { - if (ImGui::ImageButton(store.m_ImagesList[i]->m_pTexture, m_ImageSize, ImVec2(0, 0), ImVec2(1, 1), 1, - ImVec4(1, 1, 1, 1), ImVec4(1, 1, 1, 1))) - { - onLeftClick(text); - } - } + if (store.m_Filter.PassFilter(modelName.c_str()) + && (store.m_ImagesList[i]->m_CategoryName == store.m_Selected || store.m_Selected == "All") + && (verifyFunc == nullptr || verifyFunc(text)) + ) + { + /* + Couldn't figure out how to laod images for Dx11 + Using texts for now + */ + if (gRenderer == Render_DirectX11) + { + if (ImGui::MenuItem(modelName.c_str())) + { + onLeftClick(text); + } + } + else + { + if (ImGui::ImageButton(store.m_ImagesList[i]->m_pTexture, m_ImageSize, ImVec2(0, 0), ImVec2(1, 1), 1, ImVec4(1, 1, 1, 1), ImVec4(1, 1, 1, 1))) + { + onLeftClick(text); + } + } - // Right click popup - if (ImGui::IsItemClicked(1) && onRightClick != nullptr) - { - imgPopup.function = onRightClick; - imgPopup.value = modelName; - } + // Right click popup + if (ImGui::IsItemClicked(1) && onRightClick != nullptr) + { + imgPopup.function = onRightClick; + imgPopup.value = modelName; + } - if (gRenderer != Render_DirectX11) - { - if (ImGui::IsItemHovered()) - { - ImDrawList *drawlist = ImGui::GetWindowDrawList(); + if (gRenderer != Render_DirectX11) + { + if (ImGui::IsItemHovered()) + { + ImDrawList* drawlist = ImGui::GetWindowDrawList(); - // Drawing selected overlay - ImVec2 btnMin = ImGui::GetItemRectMin(); - ImVec2 btnMax = ImGui::GetItemRectMax(); - drawlist->AddRectFilled(btnMin, btnMax, ImGui::GetColorU32(ImGuiCol_ModalWindowDimBg)); + // Drawing selected overlay + ImVec2 btnMin = ImGui::GetItemRectMin(); + ImVec2 btnMax = ImGui::GetItemRectMax(); + drawlist->AddRectFilled(btnMin, btnMax, ImGui::GetColorU32(ImGuiCol_ModalWindowDimBg)); - // Calculating and drawing text over the image - ImVec2 textSize = ImGui::CalcTextSize(modelName.c_str()); - if (textSize.x < m_ImageSize.x) - { - float offsetX = (ImGui::GetItemRectSize().x - textSize.x) / 2; - drawlist->AddText(ImVec2(btnMin.x + offsetX, btnMin.y + 10), ImGui::GetColorU32(ImGuiCol_Text), - modelName.c_str()); - } - else - { - std::string buff = ""; - std::stringstream ss(modelName); - short count = 1; + // Calculating and drawing text over the image + ImVec2 textSize = ImGui::CalcTextSize(modelName.c_str()); + if (textSize.x < m_ImageSize.x) + { + float offsetX = (ImGui::GetItemRectSize().x - textSize.x) / 2; + drawlist->AddText(ImVec2(btnMin.x + offsetX, btnMin.y + 10), ImGui::GetColorU32(ImGuiCol_Text), + modelName.c_str()); + } + else + { + std::string buff = ""; + std::stringstream ss(modelName); + short count = 1; - while (ss >> buff) - { - textSize = ImGui::CalcTextSize(buff.c_str()); - float offsetX = (ImGui::GetItemRectSize().x - textSize.x) / 2; - drawlist->AddText(ImVec2(btnMin.x + offsetX, btnMin.y + 10 * count), - ImGui::GetColorU32(ImGuiCol_Text), buff.c_str()); - ++count; - } - } - } + while (ss >> buff) + { + textSize = ImGui::CalcTextSize(buff.c_str()); + float offsetX = (ImGui::GetItemRectSize().x - textSize.x) / 2; + drawlist->AddText(ImVec2(btnMin.x + offsetX, btnMin.y + 10 * count), + ImGui::GetColorU32(ImGuiCol_Text), buff.c_str()); + ++count; + } + } + } - if (imageCount % imagesInRow != 0) - { - ImGui::SameLine(0.0, ImGui::GetStyle().ItemInnerSpacing.x); - } - } - imageCount++; - } - } + if (imageCount % imagesInRow != 0) + { + ImGui::SameLine(0.0, ImGui::GetStyle().ItemInnerSpacing.x); + } + } + imageCount++; + } + } - // Draw popup code - if (imgPopup.function != nullptr) - { - if (ImGui::BeginPopupContextWindow()) - { - ImGui::Text(imgPopup.value.c_str()); - ImGui::Separator(); - if (ImGui::MenuItem("Remove")) - { - imgPopup.function(imgPopup.value); - } + // Draw popup code + if (imgPopup.function != nullptr) + { + if (ImGui::BeginPopupContextWindow()) + { + ImGui::Text(imgPopup.value.c_str()); + ImGui::Separator(); + if (ImGui::MenuItem("Remove")) + { + imgPopup.function(imgPopup.value); + } - if (ImGui::MenuItem("Close")) - { - imgPopup.function = nullptr; - } + if (ImGui::MenuItem("Close")) + { + imgPopup.function = nullptr; + } - ImGui::EndPopup(); - } - } - ImGui::EndChild(); + ImGui::EndPopup(); + } + } + ImGui::EndChild(); } -void Ui::RadioButtonAddress(const char *label, std::vector &named_mem) +void Ui::RadioButtonAddress(const char* label, std::vector& named_mem) { - size_t btn_in_column = named_mem.size() / 2 - 1; + size_t btn_in_column = named_mem.size() / 2 - 1; - ImGui::Text(label); - ImGui::Columns(2, nullptr, false); + ImGui::Text(label); + ImGui::Columns(2, nullptr, false); - bool state = true; + bool state = true; - for (size_t i = 0; i < named_mem.size(); i++) - { - if (patch::Get(named_mem[i].addr, false)) - state = false; - } + for (size_t i = 0; i < named_mem.size(); i++) + { + if (patch::Get(named_mem[i].addr, false)) + state = false; + } - if (ImGui::RadioButton((std::string("None##") + label).c_str(), state)) - { - for (size_t i = 0; i < named_mem.size(); i++) - patch::Set(named_mem[i].addr, false); - } + if (ImGui::RadioButton((std::string("None##") + label).c_str(), state)) + { + for (size_t i = 0; i < named_mem.size(); i++) + patch::Set(named_mem[i].addr, false); + } - for (size_t i = 0; i < named_mem.size(); i++) - { - state = patch::Get(named_mem[i].addr, false); + for (size_t i = 0; i < named_mem.size(); i++) + { + state = patch::Get(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(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(named_mem[i].addr, false); - patch::Set(named_mem[i].addr, true); - } + patch::Set(named_mem[i].addr, true); + } - if (i == btn_in_column) - ImGui::NextColumn(); - } - ImGui::Columns(1); + if (i == btn_in_column) + ImGui::NextColumn(); + } + ImGui::Columns(1); } -void Ui::RadioButtonAddressEx(const char *label, int addr, std::vector &named_val) +void Ui::RadioButtonAddressEx(const char* label, int addr, std::vector& named_val) { - size_t btn_in_column = named_val.size() / 2; + size_t btn_in_column = named_val.size() / 2; - ImGui::Text(label); - ImGui::Columns(2, nullptr, false); + ImGui::Text(label); + ImGui::Columns(2, nullptr, false); - int mem_val = 0; - patch::GetRaw(addr, &mem_val, 1, 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); + 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); + if (i == btn_in_column) + ImGui::NextColumn(); + } + ImGui::Columns(1); } -void Ui::EditRadioButtonAddress(const char *label, std::vector &named_mem) +void Ui::EditRadioButtonAddress(const char* label, std::vector& named_mem) { - if (ImGui::CollapsingHeader(label)) - { - RadioButtonAddress(label, named_mem); - ImGui::Spacing(); - ImGui::Separator(); - } + if (ImGui::CollapsingHeader(label)) + { + RadioButtonAddress(label, named_mem); + ImGui::Spacing(); + ImGui::Separator(); + } } -void Ui::EditRadioButtonAddressEx(const char *label, int addr, std::vector &named_val) +void Ui::EditRadioButtonAddressEx(const char* label, int addr, std::vector& named_val) { - if (ImGui::CollapsingHeader(label)) - { - RadioButtonAddressEx(label, addr, named_val); - ImGui::Spacing(); - ImGui::Separator(); - } + 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) +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(base_addr, false); - cur_color[1] = patch::Get(base_addr + 1, false); - cur_color[2] = patch::Get(base_addr + 2, false); - cur_color[3] = patch::Get(base_addr + 3, false); + if (ImGui::CollapsingHeader(label)) + { + float cur_color[4]; + cur_color[0] = patch::Get(base_addr, false); + cur_color[1] = patch::Get(base_addr + 1, false); + cur_color[2] = patch::Get(base_addr + 2, false); + cur_color[3] = patch::Get(base_addr + 3, false); - // 0-255 -> 0-1 - cur_color[0] /= 255; - cur_color[1] /= 255; - cur_color[2] /= 255; - cur_color[3] /= 255; + // 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; + 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(base_addr, cur_color[0], false); - patch::Set(base_addr + 1, cur_color[1], false); - patch::Set(base_addr + 2, cur_color[2], false); - patch::Set(base_addr + 3, cur_color[3], false); - } - ImGui::Spacing(); + patch::Set(base_addr, cur_color[0], false); + patch::Set(base_addr + 1, cur_color[1], false); + patch::Set(base_addr + 2, cur_color[2], false); + patch::Set(base_addr + 3, cur_color[3], false); + } + ImGui::Spacing(); - if (ImGui::Button("Reset to default", GetSize())) - { - patch::Set(base_addr, default_color.x, false); - patch::Set(base_addr + 1, default_color.y, false); - patch::Set(base_addr + 2, default_color.z, false); - patch::Set(base_addr + 3, default_color.w, false); - } + if (ImGui::Button("Reset to default", GetSize())) + { + patch::Set(base_addr, default_color.x, false); + patch::Set(base_addr + 1, default_color.y, false); + patch::Set(base_addr + 2, default_color.z, false); + patch::Set(base_addr + 3, default_color.w, false); + } - ImGui::Spacing(); - ImGui::Separator(); - } + ImGui::Spacing(); + ImGui::Separator(); + } } -void Ui::EditBits(const char *label, const int address, const std::vector &names) +void Ui::EditBits(const char* label, const int address, const std::vector& names) { - auto mem_val = (int *)address; + auto mem_val = (int*)address; - if (ImGui::CollapsingHeader(label)) - { - ImGui::Columns(2, nullptr, false); + if (ImGui::CollapsingHeader(label)) + { + ImGui::Columns(2, nullptr, false); - for (int i = 0; i < 32; ++i) - { - int mask = 1 << i; - bool state = *mem_val & mask; + for (int i = 0; i < 32; ++i) + { + int mask = 1 << i; + bool state = *mem_val & mask; - if (ImGui::Checkbox(names[i].c_str(), &state)) - *mem_val ^= mask; + if (ImGui::Checkbox(names[i].c_str(), &state)) + *mem_val ^= mask; - if (i + 1 == 32 / 2) - ImGui::NextColumn(); - } - ImGui::Columns(1); + if (i + 1 == 32 / 2) + ImGui::NextColumn(); + } + ImGui::Columns(1); - ImGui::Spacing(); - ImGui::Separator(); - } + 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, const float change) +void Ui::EditFloat(const char* label, const int address, const float min, const float def, const float max, + const float mul, const float change) { - if (ImGui::CollapsingHeader(label)) - { - float val = patch::Get(address, false) * mul; + if (ImGui::CollapsingHeader(label)) + { + float val = patch::Get(address, false) * mul; - int items = 3; + int items = 3; - if (min == def) - items = 2; + if (min == def) + items = 2; - ImGui::Columns(items, nullptr, false); + ImGui::Columns(items, nullptr, false); - ImGui::Text("Min: %f", min); + ImGui::Text("Min: %f", min); - if (items == 3) - { - ImGui::NextColumn(); - ImGui::Text("Def: %f", def); - } + if (items == 3) + { + ImGui::NextColumn(); + ImGui::Text("Def: %f", def); + } - ImGui::NextColumn(); - ImGui::Text("Max: %f", max); - ImGui::Columns(1); + ImGui::NextColumn(); + ImGui::Text("Max: %f", max); + ImGui::Columns(1); - ImGui::Spacing(); + ImGui::Spacing(); - int size = ImGui::GetFrameHeight(); + int size = ImGui::GetFrameHeight(); - if (ImGui::InputFloat(("##" + std::string(label)).c_str(), &val)) - patch::SetFloat(address, val / mul, false); + if (ImGui::InputFloat(("##" + std::string(label)).c_str(), &val)) + patch::SetFloat(address, val / mul, false); - ImGui::SameLine(0.0, 4.0); - if (ImGui::Button("-", ImVec2(size, size)) && (val - change) > min) - { - val -= change; - patch::SetFloat(address, val / mul, false); - } - ImGui::SameLine(0.0, 4.0); - if (ImGui::Button("+", ImVec2(size, size)) && (val + change) < max) - { - val += change; - patch::SetFloat(address, val / mul, false); - } - ImGui::SameLine(0.0, 4.0); - ImGui::Text("Set"); + ImGui::SameLine(0.0, 4.0); + if (ImGui::Button("-", ImVec2(size, size)) && (val - change) > min) + { + val -= change; + patch::SetFloat(address, val / mul, false); + } + ImGui::SameLine(0.0, 4.0); + if (ImGui::Button("+", ImVec2(size, size)) && (val + change) < max) + { + val += change; + patch::SetFloat(address, val / mul, false); + } + ImGui::SameLine(0.0, 4.0); + ImGui::Text("Set"); - ImGui::Spacing(); - if (ImGui::Button(("Minimum##" + std::string(label)).c_str(), GetSize(items))) - patch::Set(address, min / mul, false); + ImGui::Spacing(); - if (items == 3) - { - ImGui::SameLine(); + if (ImGui::Button(("Minimum##" + std::string(label)).c_str(), GetSize(items))) + patch::Set(address, min / mul, false); - if (ImGui::Button(("Default##" + std::string(label)).c_str(), GetSize(items))) - patch::Set(address, def / mul, false); - } + if (items == 3) + { + ImGui::SameLine(); - ImGui::SameLine(); + if (ImGui::Button(("Default##" + std::string(label)).c_str(), GetSize(items))) + patch::Set(address, def / mul, false); + } - if (ImGui::Button(("Maximum##" + std::string(label)).c_str(), GetSize(items))) - patch::Set(address, max / mul, false); + ImGui::SameLine(); - ImGui::Spacing(); - ImGui::Separator(); - } + if (ImGui::Button(("Maximum##" + std::string(label)).c_str(), GetSize(items))) + patch::Set(address, max / mul, false); + + ImGui::Spacing(); + ImGui::Separator(); + } } -bool Ui::ColorButton(int color_id, std::vector &color, ImVec2 size) +bool Ui::ColorButton(int color_id, std::vector& color, ImVec2 size) { - bool rtn = false; - std::string label = "Color " + std::to_string(color_id); + 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::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)); - } + if (ImGui::IsItemHovered()) + { + ImDrawList* drawlist = ImGui::GetWindowDrawList(); + drawlist->AddRectFilled(ImGui::GetItemRectMin(), ImGui::GetItemRectMax(), + ImGui::GetColorU32(ImGuiCol_ModalWindowDimBg)); + } - return rtn; + return rtn; } diff --git a/src/ui.h b/src/ui.h index 6a600c3..aa6b9b7 100644 --- a/src/ui.h +++ b/src/ui.h @@ -4,183 +4,183 @@ class Ui { public: - struct NamedMemory - { - std::string name; - int addr; - }; + struct NamedMemory + { + std::string name; + int addr; + }; - struct NamedValue - { - std::string name; - int value; - }; + struct NamedValue + { + std::string name; + int value; + }; - struct JsonPopUpData - { - std::function function; - std::string key; - std::string rootKey; - std::string value; - }; + struct JsonPopUpData + { + std::function function; + std::string key; + std::string rootKey; + std::string value; + }; - struct ImgPopUpData - { - std::function function; - std::string value; - }; - static inline std::string m_HeaderId; - static inline JsonPopUpData jsonPopup; - static inline ImgPopUpData imgPopup; + struct ImgPopUpData + { + std::function function; + std::string value; + }; + static inline std::string m_HeaderId; + static inline JsonPopUpData jsonPopup; + static inline ImgPopUpData imgPopup; - Ui() = delete; - Ui(Ui &) = delete; - static void CenterdText(const std::string &text); - static bool ColorButton(int color_id, std::vector &color, ImVec2 size); - static bool CheckboxAddress(const char *label, int addr = NULL, const char *hint = nullptr); - static bool CheckboxAddressEx(const char *label, 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, bool is_disabled = false); - static void DrawHeaders(CallbackTable &data); + Ui() = delete; + Ui(Ui&) = delete; - static void DrawJSON(ResourceStore &data, - std::function func_left_click, - std::function func_right_click); - static void DrawImages(ResourceStore &store, std::function on_left_click, - std::function on_right_click, - std::function get_name_func, - std::function verify_func = nullptr, - const char **custom_names = nullptr, size_t length = 0); + static void CenterdText(const std::string& text); + static bool ColorButton(int color_id, std::vector& color, ImVec2 size); + static bool CheckboxAddress(const char* label, int addr = NULL, const char* hint = nullptr); + static bool CheckboxAddressEx(const char* label, 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, bool is_disabled = false); + static void DrawHeaders(CallbackTable& data); - template - static void EditAddress(const char *label, int address, int min = 0, int def = 0, int max = 100); - static void EditBits(const char *label, int address, const std::vector &names); - static void EditFloat(const char *label, int address, float min, float def, float max, float mul = 1, - float change = 1.0f); - template - static void EditReference(const char *label, T &address, int min = 0, int def = 0, int max = 100); - static void EditRadioButtonAddress(const char *label, std::vector &named_mem); - static void EditRadioButtonAddressEx(const char *label, int addr, std::vector &named_val); + static void DrawJSON(ResourceStore& data, + std::function func_left_click, + std::function func_right_click); + static void DrawImages(ResourceStore &store, std::function on_left_click, + std::function on_right_click, + std::function get_name_func, + std::function verify_func = nullptr, + const char** custom_names = nullptr, size_t length = 0); + + template + static void EditAddress(const char* label, int address, int min = 0, int def = 0, int max = 100); + static void EditBits(const char* label, int address, const std::vector& names); + static void EditFloat(const char* label, int address, float min, float def, float max, float mul = 1, float change = 1.0f); + template + static void EditReference(const char* label, T& address, int min = 0, int def = 0, int max = 100); + static void EditRadioButtonAddress(const char* label, std::vector& named_mem); + static void EditRadioButtonAddressEx(const char* label, int addr, std::vector& named_val); #ifdef GTASA - static void EditStat(const char *label, int stat_id, int min = 0, int def = 0, int max = 1000); + static void EditStat(const char* label, int stat_id, int min = 0, int def = 0, int max = 1000); #endif - static void FilterWithHint(const char *label, ImGuiTextFilter &filter, const char *hint); + static void FilterWithHint(const char* label, ImGuiTextFilter& filter, const char* hint); - static ImVec2 GetSize(short count = 1, bool spacing = true); + static ImVec2 GetSize(short count = 1, bool spacing = true); - static bool ListBox(const char *label, std::vector &all_items, int &selected); - static bool ListBoxStr(const char *label, std::vector &all_items, std::string &selected); - static bool ListBoxCustomNames(const char *label, std::vector &all_items, std::string &selected, - const char *custom_names[] = nullptr, size_t length = 0); + static bool ListBox(const char* label, std::vector& all_items, int& selected); + static bool ListBoxStr(const char* label, std::vector& all_items, std::string& selected); + static bool ListBoxCustomNames(const char* label, std::vector& all_items, std::string& selected, const char* custom_names[] = nullptr, size_t length = 0); - static void RadioButtonAddress(const char *label, std::vector &named_mem); - static void RadioButtonAddressEx(const char *label, int addr, std::vector &named_val); + static void RadioButtonAddress(const char* label, std::vector& named_mem); + static void RadioButtonAddressEx(const char* label, int addr, std::vector& named_val); - static void ColorPickerAddress(const char *label, int base_addr, ImVec4 &&default_color); - static void ShowTooltip(const char *text); + static void ColorPickerAddress(const char* label, int base_addr, ImVec4&& default_color); + static void ShowTooltip(const char* text); }; template -void Ui::EditAddress(const char *label, const int address, const int min, const int def, const int max) +void Ui::EditAddress(const char* label, const int address, const int min, const int def, const int max) { - if (ImGui::CollapsingHeader(label)) - { - int val = patch::Get(address, false); + if (ImGui::CollapsingHeader(label)) + { + int val = patch::Get(address, false); - int items = 3; + int items = 3; - if (min == def) - items = 2; + if (min == def) + items = 2; - ImGui::Columns(items, nullptr, false); - ImGui::Text(("Min: " + std::to_string(min)).c_str()); + ImGui::Columns(items, nullptr, false); + ImGui::Text(("Min: " + std::to_string(min)).c_str()); - if (items == 3) - { - ImGui::NextColumn(); - ImGui::Text(("Def: " + std::to_string(def)).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::NextColumn(); + ImGui::Text(("Max: " + std::to_string(max)).c_str()); + ImGui::Columns(1); - ImGui::Spacing(); + ImGui::Spacing(); - if (ImGui::InputInt(("Set value##" + std::string(label)).c_str(), &val)) - patch::Set(address, val, false); + if (ImGui::InputInt(("Set value##" + std::string(label)).c_str(), &val)) + patch::Set(address, val, false); - ImGui::Spacing(); + ImGui::Spacing(); - if (val < min) - val = min; + if (val < min) + val = min; - if (val > max) - val = max; + if (val > max) + val = max; - if (ImGui::Button(("Minimum##" + std::string(label)).c_str(), GetSize(items))) - patch::Set(address, min, false); + if (ImGui::Button(("Minimum##" + std::string(label)).c_str(), GetSize(items))) + patch::Set(address, min, false); - if (items == 3) - { - ImGui::SameLine(); + if (items == 3) + { + ImGui::SameLine(); - if (ImGui::Button(("Default##" + std::string(label)).c_str(), GetSize(3))) - patch::Set(address, def, false); - } + if (ImGui::Button(("Default##" + std::string(label)).c_str(), GetSize(3))) + patch::Set(address, def, false); + } - ImGui::SameLine(); + ImGui::SameLine(); - if (ImGui::Button(("Maximum##" + std::string(label)).c_str(), GetSize(items))) - patch::Set(address, max, false); + if (ImGui::Button(("Maximum##" + std::string(label)).c_str(), GetSize(items))) + patch::Set(address, max, false); - ImGui::Spacing(); - ImGui::Separator(); - } + ImGui::Spacing(); + ImGui::Separator(); + } } -template void Ui::EditReference(const char *label, T &address, const int min, const int def, const int max) +template +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(address); + if (ImGui::CollapsingHeader(label)) + { + int val = static_cast(address); - ImGui::Columns(3, nullptr, 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::Columns(3, nullptr, 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(); + ImGui::Spacing(); - if (ImGui::InputInt(("Set value##" + std::string(label)).c_str(), &val)) - address = static_cast(val); + if (ImGui::InputInt(("Set value##" + std::string(label)).c_str(), &val)) + address = static_cast(val); - ImGui::Spacing(); + ImGui::Spacing(); - if (ImGui::Button(("Minimum##" + std::string(label)).c_str(), GetSize(3))) - address = static_cast(min); + if (ImGui::Button(("Minimum##" + std::string(label)).c_str(), GetSize(3))) + address = static_cast(min); - ImGui::SameLine(); + ImGui::SameLine(); - if (ImGui::Button(("Default##" + std::string(label)).c_str(), GetSize(3))) - address = static_cast(def); + if (ImGui::Button(("Default##" + std::string(label)).c_str(), GetSize(3))) + address = static_cast(def); - ImGui::SameLine(); + ImGui::SameLine(); - if (ImGui::Button(("Maximum##" + std::string(label)).c_str(), GetSize(3))) - address = static_cast(max); + if (ImGui::Button(("Maximum##" + std::string(label)).c_str(), GetSize(3))) + address = static_cast(max); - ImGui::Spacing(); - ImGui::Separator(); - } + ImGui::Spacing(); + ImGui::Separator(); + } } diff --git a/src/updater.cpp b/src/updater.cpp index 1da0dd2..1a7ed1f 100644 --- a/src/updater.cpp +++ b/src/updater.cpp @@ -1,78 +1,76 @@ -#include "updater.h" -#include "menuinfo.h" #include "pch.h" +#include "updater.h" #include "ui.h" +#include "menuinfo.h" #include "util.h" void Updater::CheckForUpdate() { - const char *link = "https://api.github.com/repos/user-grinch/Cheat-Menu/tags"; - char *path = PLUGIN_PATH((char *)"CheatMenu/json/versioninfo.json"); - HRESULT res = URLDownloadToFile(NULL, link, path, 0, NULL); + const char* link = "https://api.github.com/repos/user-grinch/Cheat-Menu/tags"; + char* path = PLUGIN_PATH((char*)"CheatMenu/json/versioninfo.json"); + HRESULT res = URLDownloadToFile(NULL, link, path, 0, NULL); - if (res == E_OUTOFMEMORY || res == INET_E_DOWNLOAD_FAILURE) - { - SetHelpMessage("Failed to check for updates", false, false, false); - return; - } + if (res == E_OUTOFMEMORY || res == INET_E_DOWNLOAD_FAILURE) + { + SetHelpMessage("Failed to check for updates", false, false, false); + return; + } + + CJson verinfo = CJson("versioninfo"); - CJson verinfo = CJson("versioninfo"); + // fetch the version number + if (verinfo.m_Data.empty()) + { + m_LatestVersion = MENU_VERSION_NUMBER; + } + else + { + m_LatestVersion = verinfo.m_Data.items().begin().value()["name"].get(); + } - // fetch the version number - if (verinfo.m_Data.empty()) - { - m_LatestVersion = MENU_VERSION_NUMBER; - } - else - { - m_LatestVersion = verinfo.m_Data.items().begin().value()["name"].get(); - } - - if (m_LatestVersion > MENU_VERSION_NUMBER) - { - SetHelpMessage("Update found", false, false, false); - m_State = UPDATER_UPDATE_FOUND; - } - else - { - SetHelpMessage("No update found.", false, false, false); - Updater::m_State = UPDATER_IDLE; - } + if (m_LatestVersion > MENU_VERSION_NUMBER) + { + SetHelpMessage("Update found", false, false, false); + m_State = UPDATER_UPDATE_FOUND; + } + else + { + SetHelpMessage("No update found.", false, false, false); + Updater::m_State = UPDATER_IDLE; + } } void Updater::ShowUpdateScreen() { - ImGui::Dummy(ImVec2(0, 20)); - Ui::CenterdText("A new version of the mod is available."); - Ui::CenterdText(std::string("Current version: ") + MENU_VERSION); - Ui::CenterdText("Latest version: " + Updater::m_LatestVersion); - ImGui::Dummy(ImVec2(0, 10)); - ImGui::TextWrapped("In order to keep using the menu, you need to update to the latest version." - " This is to ensure everything is using the most up-to-date version."); - ImGui::Dummy(ImVec2(0, 10)); - ImGui::TextWrapped("To know what changes are made or to download, click on the \"Download page\" button." - " Follow the instructions there. If you're still having issues, let me know on discord."); + ImGui::Dummy(ImVec2(0, 20)); + Ui::CenterdText("A new version of the mod is available."); + Ui::CenterdText(std::string("Current version: ") + MENU_VERSION); + Ui::CenterdText("Latest version: " + Updater::m_LatestVersion); + ImGui::Dummy(ImVec2(0, 10)); + ImGui::TextWrapped("In order to keep using the menu, you need to update to the latest version." + " This is to ensure everything is using the most up-to-date version."); + ImGui::Dummy(ImVec2(0, 10)); + ImGui::TextWrapped("To know what changes are made or to download, click on the \"Download page\" button." + " Follow the instructions there. If you're still having issues, let me know on discord."); - ImGui::Dummy(ImVec2(0, 5)); - if (ImGui::Button("Discord server", ImVec2(Ui::GetSize(3)))) - { - ShellExecute(NULL, "open", DISCORD_INVITE, NULL, NULL, SW_SHOWNORMAL); - } + ImGui::Dummy(ImVec2(0, 5)); + if (ImGui::Button("Discord server", ImVec2(Ui::GetSize(3)))) + { + ShellExecute(NULL, "open", DISCORD_INVITE, NULL, NULL, SW_SHOWNORMAL); + } - ImGui::SameLine(); + ImGui::SameLine(); - if (ImGui::Button("Download page", Ui::GetSize(3))) - { - ShellExecute( - NULL, "open", - std::string("https://github.com/user-grinch/Cheat-Menu/releases/tag/" + Updater::m_LatestVersion).c_str(), - NULL, NULL, SW_SHOWNORMAL); - } + if (ImGui::Button("Download page", Ui::GetSize(3))) + { + ShellExecute(NULL, "open", std::string("https://github.com/user-grinch/Cheat-Menu/releases/tag/" + + Updater::m_LatestVersion).c_str(), NULL, NULL, SW_SHOWNORMAL); + } - ImGui::SameLine(); + ImGui::SameLine(); - if (ImGui::Button("Hide page", Ui::GetSize(3))) - { - Updater::m_State = UPDATER_IDLE; - } + if (ImGui::Button("Hide page", Ui::GetSize(3))) + { + Updater::m_State = UPDATER_IDLE; + } } diff --git a/src/updater.h b/src/updater.h index a37b5b0..19466d1 100644 --- a/src/updater.h +++ b/src/updater.h @@ -3,17 +3,17 @@ enum UPDATER_STATE { - UPDATER_IDLE, - UPDATER_CHECKING, - UPDATER_UPDATE_FOUND + UPDATER_IDLE, + UPDATER_CHECKING, + UPDATER_UPDATE_FOUND }; class Updater { public: - static inline UPDATER_STATE m_State = UPDATER_IDLE; - static inline std::string m_LatestVersion; + static inline UPDATER_STATE m_State = UPDATER_IDLE; + static inline std::string m_LatestVersion; - static void CheckForUpdate(); - static void ShowUpdateScreen(); + static void CheckForUpdate(); + static void ShowUpdateScreen(); }; diff --git a/src/util.cpp b/src/util.cpp index 8c7203b..c917744 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -1,220 +1,220 @@ -#include "util.h" #include "pch.h" +#include "util.h" #include "psapi.h" -std::string Util::GetLocationName(CVector *pos) +std::string Util::GetLocationName(CVector* pos) { - CPlayerPed *pPlayer = FindPlayerPed(); + CPlayerPed *pPlayer = FindPlayerPed(); #ifdef GTASA - int hplayer = CPools::GetPedRef(pPlayer); + int hplayer = CPools::GetPedRef(pPlayer); - int interior = 0; - Command(&interior); + int interior = 0; + Command(&interior); - std::string town = "San Andreas"; - int city; - Command(&hplayer, &city); + std::string town = "San Andreas"; + int city; + Command(&hplayer, &city); - switch (city) - { - case 0: - town = "CS"; - break; - case 1: - town = "LS"; - break; - case 2: - town = "SF"; - break; - case 3: - town = "LV"; - break; - } + 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; - return std::string("Interior ") + std::to_string(interior) + ", " + town; + if (interior == 0) + return CTheZones::FindSmallestZoneForPosition(*pos, true)->GetTranslatedName() + std::string(", ") + town; + return std::string("Interior ") + std::to_string(interior) + ", " + town; #elif GTAVC - if (pPlayer) - { - return std::to_string(pPlayer->m_nInterior) + ", Vice City"; - } - else - { - return "Vice City"; - } + if (pPlayer) + { + return std::to_string(pPlayer->m_nInterior) + ", Vice City" ; + } + else + { + return "Vice City"; + } #else - return "Liberty City"; + return "Liberty City"; #endif } #ifdef GTASA // Thanks DKPac22 -RwTexture *Util::LoadTextureFromMemory(char *data, unsigned int size) +RwTexture* Util::LoadTextureFromMemory(char* data, unsigned int size) { - patch::SetChar(0x7CF9CA, rwSTREAMMEMORY); - RwMemory memoryImage; - RwInt32 width, height, depth, flags; - memoryImage.start = (RwUInt8 *)data; - memoryImage.length = size; - RwImage *image = RtPNGImageRead((char *)&memoryImage); - RwImageFindRasterFormat(image, 4, &width, &height, &depth, &flags); - RwRaster *raster = RwRasterCreate(width, height, depth, flags); - RwRasterSetFromImage(raster, image); - RwImageDestroy(image); - patch::SetChar(0x7CF9CA, rwSTREAMFILENAME); + patch::SetChar(0x7CF9CA, rwSTREAMMEMORY); + RwMemory memoryImage; + RwInt32 width, height, depth, flags; + memoryImage.start = (RwUInt8*)data; + memoryImage.length = size; + RwImage* image = RtPNGImageRead((char*)&memoryImage); + RwImageFindRasterFormat(image, 4, &width, &height, &depth, &flags); + RwRaster* raster = RwRasterCreate(width, height, depth, flags); + RwRasterSetFromImage(raster, image); + RwImageDestroy(image); + patch::SetChar(0x7CF9CA, rwSTREAMFILENAME); - return RwTextureCreate(raster); + return RwTextureCreate(raster); } -void Util::ClearCharTasksVehCheck(CPed *ped) +void Util::ClearCharTasksVehCheck(CPed* ped) { - uint hped = CPools::GetPedRef(ped); - uint hveh = NULL; - bool veh_engine = true; - float speed; + uint hped = CPools::GetPedRef(ped); + uint hveh = NULL; + bool veh_engine = true; + float speed; - if (ped->m_nPedFlags.bInVehicle) - { - hveh = CPools::GetVehicleRef(ped->m_pVehicle); - veh_engine = ped->m_pVehicle->m_nVehicleFlags.bEngineOn; - speed = ped->m_pVehicle->m_vecMoveSpeed.Magnitude() * 50.0f; - } + if (ped->m_nPedFlags.bInVehicle) + { + hveh = CPools::GetVehicleRef(ped->m_pVehicle); + veh_engine = ped->m_pVehicle->m_nVehicleFlags.bEngineOn; + speed = ped->m_pVehicle->m_vecMoveSpeed.Magnitude() * 50.0f; + } - Command(hped); + Command(hped); - if (hveh) - { - Command(hped, hveh); - ped->m_pVehicle->m_nVehicleFlags.bEngineOn = veh_engine; - Command(hveh, speed); - } + if (hveh) + { + Command(hped, hveh); + ped->m_pVehicle->m_nVehicleFlags.bEngineOn = veh_engine; + Command(hveh, speed); + } } bool Util::IsOnMission() { - return FindPlayerPed()->CanPlayerStartMission() && - !*(patch::Get(0x5D5380, false) + CTheScripts::OnAMissionFlag); + return FindPlayerPed()->CanPlayerStartMission() && !*(patch::Get(0x5D5380, false) + + CTheScripts::OnAMissionFlag); } int Util::GetLargestGangInZone() { - int gang_id = 0, max_density = 0; + int gang_id = 0, max_density = 0; - for (int i = 0; i != 10; ++i) - { - CVector pos = FindPlayerPed()->GetPosition(); + for (int i = 0; i != 10; ++i) + { + CVector pos = FindPlayerPed()->GetPosition(); - CZoneInfo *zone_info = CTheZones::GetZoneInfo(&pos, nullptr); - int density = zone_info->m_nGangDensity[i]; + CZoneInfo* zone_info = CTheZones::GetZoneInfo(&pos, nullptr); + int density = zone_info->m_nGangDensity[i]; - if (density > max_density) - { - max_density = density; - gang_id = i; - } - } + if (density > max_density) + { + max_density = density; + gang_id = i; + } + } - return gang_id; + return gang_id; } -#endif +#endif // implemention of opcode 0AB5 (STORE_CLOSEST_ENTITIES) // https://github.com/cleolibrary/CLEO4/blob/916d400f4a731ba1dd0ff16e52bdb056f42b7038/source/CCustomOpcodeSystem.cpp#L1671 -CVehicle *Util::GetClosestVehicle() +CVehicle* Util::GetClosestVehicle() { - CPlayerPed *player = FindPlayerPed(); +CPlayerPed* player = FindPlayerPed(); #ifdef GTASA - CPedIntelligence *pedintel; - if (player && (pedintel = player->m_pIntelligence)) - { - CVehicle *veh = nullptr; - for (int i = 0; i < 16; i++) - { - veh = static_cast(pedintel->m_vehicleScanner.m_apEntities[i]); - if (veh && !veh->m_nVehicleFlags.bFadeOut) - break; - veh = nullptr; - } + CPedIntelligence* pedintel; + if (player && (pedintel = player->m_pIntelligence)) + { + CVehicle* veh = nullptr; + for (int i = 0; i < 16; i++) + { + veh = static_cast(pedintel->m_vehicleScanner.m_apEntities[i]); + if (veh && !veh->m_nVehicleFlags.bFadeOut) + break; + veh = nullptr; + } - return veh; - } - return nullptr; + return veh; + } + return nullptr; #else // GTAVC & GTA3 + + CVehicle *pClosestVeh = nullptr; + float distance = 999.0f; - CVehicle *pClosestVeh = nullptr; - float distance = 999.0f; + CVector playerPos = player->GetPosition(); - CVector playerPos = player->GetPosition(); + for (CVehicle *pVeh : CPools::ms_pVehiclePool) + { + CVector pos = pVeh->GetPosition(); + float dist = DistanceBetweenPoints(playerPos, pos); - for (CVehicle *pVeh : CPools::ms_pVehiclePool) - { - CVector pos = pVeh->GetPosition(); - float dist = DistanceBetweenPoints(playerPos, pos); - - if (dist < distance) - { - pClosestVeh = pVeh; - distance = dist; - } - } - return pClosestVeh; + if (dist < distance) + { + pClosestVeh = pVeh; + distance = dist; + } + } + return pClosestVeh; #endif } -CPed *Util::GetClosestPed() +CPed* Util::GetClosestPed() { - CPlayerPed *player = FindPlayerPed(); +CPlayerPed* player = FindPlayerPed(); #ifdef GTASA - CPedIntelligence *pedintel; - if (player && (pedintel = player->m_pIntelligence)) - { - CPed *ped = nullptr; + CPedIntelligence* pedintel; + if (player && (pedintel = player->m_pIntelligence)) + { + CPed* ped = nullptr; - for (int i = 0; i < 16; i++) - { - ped = static_cast(pedintel->m_pedScanner.m_apEntities[i]); - if (ped && ped != player && (ped->m_nCreatedBy & 0xFF) == 1 && !ped->m_nPedFlags.bFadeOut) - break; - ped = nullptr; - } + for (int i = 0; i < 16; i++) + { + ped = static_cast(pedintel->m_pedScanner.m_apEntities[i]); + if (ped && ped != player && (ped->m_nCreatedBy & 0xFF) == 1 && !ped->m_nPedFlags.bFadeOut) + break; + ped = nullptr; + } - return ped; - } - return nullptr; + return ped; + } + return nullptr; #else // GTA3 & GTAVC - return player->m_apNearPeds[0]; + return player->m_apNearPeds[0]; #endif } bool Util::IsOnCutscene() { - return BY_GAME(CCutsceneMgr::ms_running, *(bool *)0xA10AB2, *(bool *)0x95CCF5); + return BY_GAME(CCutsceneMgr::ms_running, *(bool*)0xA10AB2, *(bool*)0x95CCF5); } -void Util::RainbowValues(int &r, int &g, int &b, float speed) +void Util::RainbowValues(int& r, int& g, int& b, float speed) { - int timer = CTimer::m_snTimeInMilliseconds / 150; - r = sin(timer * speed) * 127 + 128; - g = sin(timer * speed + 2) * 127 + 128; - b = sin(timer * speed + 4) * 127 + 128; + 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; } void Util::GetCPUUsageInit() { - PdhOpenQuery(nullptr, NULL, &cpuQuery); - PdhAddEnglishCounter(cpuQuery, "\\Processor(_Total)\\% Processor Time", NULL, &cpuTotal); - PdhCollectQueryData(cpuQuery); + PdhOpenQuery(nullptr, NULL, &cpuQuery); + PdhAddEnglishCounter(cpuQuery, "\\Processor(_Total)\\% Processor Time", NULL, &cpuTotal); + PdhCollectQueryData(cpuQuery); } double Util::GetCurrentCPUUsage() { - PDH_FMT_COUNTERVALUE counterVal; + PDH_FMT_COUNTERVALUE counterVal; - PdhCollectQueryData(cpuQuery); - PdhGetFormattedCounterValue(cpuTotal, PDH_FMT_DOUBLE, nullptr, &counterVal); - return counterVal.doubleValue; + PdhCollectQueryData(cpuQuery); + PdhGetFormattedCounterValue(cpuTotal, PDH_FMT_DOUBLE, nullptr, &counterVal); + return counterVal.doubleValue; } diff --git a/src/util.h b/src/util.h index 177ebc2..302765c 100644 --- a/src/util.h +++ b/src/util.h @@ -1,6 +1,6 @@ #pragma once -#include "pdh.h" #include "tchar.h" +#include "pdh.h" static PDH_HQUERY cpuQuery; static PDH_HCOUNTER cpuTotal; @@ -11,18 +11,19 @@ static HANDLE self; class Util { public: + #ifdef GTASA - static void ClearCharTasksVehCheck(CPed *ped); - static int GetLargestGangInZone(); - static RwTexture *LoadTextureFromMemory(char *data, unsigned int size); + static void ClearCharTasksVehCheck(CPed* ped); + static int GetLargestGangInZone(); + static RwTexture* LoadTextureFromMemory(char* data, unsigned int size); #endif - static CPed *GetClosestPed(); - static CVehicle *GetClosestVehicle(); - static std::string GetLocationName(CVector *pos); - static bool IsOnMission(); - static bool IsOnCutscene(); - static void RainbowValues(int &r, int &g, int &b, float speed); - static void GetCPUUsageInit(); - static double GetCurrentCPUUsage(); + static CPed* GetClosestPed(); + static CVehicle* GetClosestVehicle(); + static std::string GetLocationName(CVector* pos); + static bool IsOnMission(); + static bool IsOnCutscene(); + static void RainbowValues(int& r, int& g, int& b, float speed); + static void GetCPUUsageInit(); + static double GetCurrentCPUUsage(); }; diff --git a/src/vehicle.cpp b/src/vehicle.cpp index ac7cebe..e6206c5 100644 --- a/src/vehicle.cpp +++ b/src/vehicle.cpp @@ -1,1328 +1,1327 @@ -#include "vehicle.h" -#include "filehandler.h" -#include "menu.h" #include "pch.h" +#include "vehicle.h" +#include "menu.h" #include "ui.h" #include "util.h" -#include +#include "filehandler.h" #include +#include void Vehicle::FixVehicle(CVehicle *pVeh) { #ifdef GTASA - pVeh->Fix(); + pVeh->Fix(); #else // GTA3 & GTAVC - switch (pVeh->m_nVehicleClass) - { - case VEHICLE_AUTOMOBILE: { - reinterpret_cast(pVeh)->Fix(); - break; - } + switch (pVeh->m_nVehicleClass) + { + case VEHICLE_AUTOMOBILE: + { + reinterpret_cast(pVeh)->Fix(); + break; + } #ifdef GTAVC - case VEHICLE_BIKE: { - reinterpret_cast(pVeh)->Fix(); - break; - } + case VEHICLE_BIKE: + { + reinterpret_cast(pVeh)->Fix(); + break; + } #endif - } -#endif - pVeh->m_fHealth = 1000.0f; + } +#endif + pVeh->m_fHealth = 1000.0f; } Vehicle::Vehicle() { #ifdef GTASA - FileHandler::FetchHandlingID(m_VehicleIDE); + FileHandler::FetchHandlingID(m_VehicleIDE); #endif - FileHandler::FetchColorData(m_CarcolsColorData); + FileHandler::FetchColorData(m_CarcolsColorData); - Events::processScriptsEvent += [this] { - uint timer = CTimer::m_snTimeInMilliseconds; - CPlayerPed *pPlayer = FindPlayerPed(); - CVehicle *pVeh = BY_GAME(FindPlayerVehicle(-1, false), FindPlayerVehicle(), FindPlayerVehicle()); + Events::processScriptsEvent += [this] + { + uint timer = CTimer::m_snTimeInMilliseconds; + CPlayerPed* pPlayer = FindPlayerPed(); + CVehicle* pVeh = BY_GAME(FindPlayerVehicle(-1, false), FindPlayerVehicle(), FindPlayerVehicle()); - if (pPlayer && pVeh) - { - int hveh = CPools::GetVehicleRef(pVeh); + if (pPlayer && pVeh) + { + int hveh = CPools::GetVehicleRef(pVeh); #ifdef GTASA - if (flipVeh.Pressed()) - { - int roll = 0; - Command(hveh, &roll); - roll += 180; - Command(hveh, roll); - Command(hveh, roll); // z rot fix - } + if (flipVeh.Pressed()) + { + int roll = 0; + Command(hveh, &roll); + roll += 180; + Command(hveh, roll); + Command(hveh, roll); // z rot fix + } #endif - if (fixVeh.Pressed()) - { - FixVehicle(pVeh); - SetHelpMessage("Vehicle fixed", false, false, false); - } + if (fixVeh.Pressed()) + { + FixVehicle(pVeh); + SetHelpMessage("Vehicle fixed", false, false, false); + } - if (vehEngine.Pressed()) - { - bool state = - BY_GAME(!pVeh->m_nVehicleFlags.bEngineBroken, true, true) || pVeh->m_nVehicleFlags.bEngineOn; + if (vehEngine.Pressed()) + { + bool state = BY_GAME(!pVeh->m_nVehicleFlags.bEngineBroken, true, true) || pVeh->m_nVehicleFlags.bEngineOn; - if (state) - { - SetHelpMessage("Vehicle engine off", false, false, false); - } - else - { - SetHelpMessage("Vehicle engine on", false, false, false); - } + if (state) + { + SetHelpMessage("Vehicle engine off", false, false, false); + } + else + { + SetHelpMessage("Vehicle engine on", false, false, false); + } #ifdef GTASA - pVeh->m_nVehicleFlags.bEngineBroken = state; + pVeh->m_nVehicleFlags.bEngineBroken = state; #endif - pVeh->m_nVehicleFlags.bEngineOn = !state; - } + pVeh->m_nVehicleFlags.bEngineOn = !state; + } - if (vehInstantStart.Pressed()) - Command(hveh, 40.0f); + if (vehInstantStart.Pressed()) + Command(hveh, 40.0f); - if (vehInstantStop.Pressed()) - Command(hveh, 0); + if (vehInstantStop.Pressed()) + Command(hveh, 0); - if (m_bNoDamage) - { + if (m_bNoDamage) + { #ifdef GTASA - pVeh->m_nPhysicalFlags.bBulletProof = true; - pVeh->m_nPhysicalFlags.bExplosionProof = true; - pVeh->m_nPhysicalFlags.bFireProof = true; - pVeh->m_nPhysicalFlags.bCollisionProof = true; - pVeh->m_nPhysicalFlags.bMeeleProof = true; - pVeh->m_nVehicleFlags.bCanBeDamaged = true; + pVeh->m_nPhysicalFlags.bBulletProof = true; + pVeh->m_nPhysicalFlags.bExplosionProof = true; + pVeh->m_nPhysicalFlags.bFireProof = true; + pVeh->m_nPhysicalFlags.bCollisionProof = true; + pVeh->m_nPhysicalFlags.bMeeleProof = true; + pVeh->m_nVehicleFlags.bCanBeDamaged = true; #elif GTAVC - pVeh->m_nFlags.bBulletProof = true; - pVeh->m_nFlags.bExplosionProof = true; - pVeh->m_nFlags.bFireProof = true; - pVeh->m_nFlags.bCollisionProof = true; - pVeh->m_nFlags.bMeleeProof = true; + pVeh->m_nFlags.bBulletProof = true; + pVeh->m_nFlags.bExplosionProof = true; + pVeh->m_nFlags.bFireProof = true; + pVeh->m_nFlags.bCollisionProof = true; + pVeh->m_nFlags.bMeleeProof = true; #else - pVeh->m_nEntityFlags.bBulletProof = true; - pVeh->m_nEntityFlags.bExplosionProof = true; - pVeh->m_nEntityFlags.bFireProof = true; - pVeh->m_nEntityFlags.bCollisionProof = true; - pVeh->m_nEntityFlags.bMeleeProof = true; + pVeh->m_nEntityFlags.bBulletProof = true; + pVeh->m_nEntityFlags.bExplosionProof = true; + pVeh->m_nEntityFlags.bFireProof = true; + pVeh->m_nEntityFlags.bCollisionProof = true; + pVeh->m_nEntityFlags.bMeleeProof = true; #endif - } + } - Command(hveh, m_bVehHeavy); - Command(hveh, m_bVehWatertight); + Command(hveh, m_bVehHeavy); + Command(hveh, m_bVehWatertight); - if (m_bLockSpeed) - { - Command(hveh, m_fLockSpeed); - } + if (m_bLockSpeed) + { + Command(hveh, m_fLockSpeed); + } #ifdef GTASA - pPlayer->m_nPedFlags.CantBeKnockedOffBike = m_bDontFallBike ? 1 : 2; + pPlayer->m_nPedFlags.CantBeKnockedOffBike = m_bDontFallBike ? 1 : 2; - if (m_UnlimitedNitro::m_bEnabled && - BY_GAME(pVeh->m_nVehicleSubClass, pVeh->m_nVehicleClass) == VEHICLE_AUTOMOBILE) - { - patch::Set(0x969165, 0, true); // All cars have nitro - patch::Set(0x96918B, 0, true); // All taxis have nitro + if (m_UnlimitedNitro::m_bEnabled + && BY_GAME(pVeh->m_nVehicleSubClass, pVeh->m_nVehicleClass) == VEHICLE_AUTOMOBILE) + { + patch::Set(0x969165, 0, true); // All cars have nitro + patch::Set(0x96918B, 0, true); // All taxis have nitro - if (KeyPressed(VK_LBUTTON)) - { - if (!m_UnlimitedNitro::m_bCompAdded) - { - AddComponent("1010", false); - m_UnlimitedNitro::m_bCompAdded = true; - } - } - else - { - if (m_UnlimitedNitro::m_bCompAdded) - { - RemoveComponent("1010", false); - m_UnlimitedNitro::m_bCompAdded = false; - } - } - } + if (KeyPressed(VK_LBUTTON)) + { + if (!m_UnlimitedNitro::m_bCompAdded) + { + AddComponent("1010", false); + m_UnlimitedNitro::m_bCompAdded = true; + } + } + else + { + if (m_UnlimitedNitro::m_bCompAdded) + { + RemoveComponent("1010", false); + m_UnlimitedNitro::m_bCompAdded = false; + } + } + } - if (m_Neon::m_bRainbowEffect && timer - m_Neon::m_nRainbowTimer > 50) - { - int red, green, blue; + if (m_Neon::m_bRainbowEffect && timer - m_Neon::m_nRainbowTimer > 50) + { + int red, green, blue; - Util::RainbowValues(red, green, blue, 0.25); - InstallNeon(pVeh, red, green, blue); - m_Neon::m_nRainbowTimer = timer; - } + Util::RainbowValues(red, green, blue, 0.25); + InstallNeon(pVeh, red, green, blue); + m_Neon::m_nRainbowTimer = timer; + } #endif - } + } #ifdef GTASA - // Traffic neons - if (m_Neon::m_bApplyOnTraffic && timer - m_Neon::m_bTrafficTimer > 1000) - { - for (CVehicle *veh : CPools::ms_pVehiclePool) - { - int chance = 0; + // Traffic neons + if (m_Neon::m_bApplyOnTraffic && timer - m_Neon::m_bTrafficTimer > 1000) + { + for (CVehicle* veh : CPools::ms_pVehiclePool) + { + int chance = 0; - if (veh->m_nVehicleClass == CLASS_NORMAL) // Normal - { - chance = Random(1, 20); - } + if (veh->m_nVehicleClass == CLASS_NORMAL) // Normal + { + chance = Random(1, 20); + } - if (veh->m_nVehicleClass == CLASS_RICHFAMILY) // Rich family - { - chance = Random(1, 4); - } + if (veh->m_nVehicleClass == CLASS_RICHFAMILY) // Rich family + { + chance = Random(1, 4); + } - if (veh->m_nVehicleClass == CLASS_EXECUTIVE) // Executive - { - chance = Random(1, 3); - } + if (veh->m_nVehicleClass == CLASS_EXECUTIVE) // Executive + { + chance = Random(1, 3); + } - if (chance == 1 && !IsNeonInstalled(veh) && veh->m_pDriver != pPlayer) - { - InstallNeon(veh, Random(0, 255), Random(0, 255), Random(0, 255)); - } - } - m_Neon::m_bTrafficTimer = timer; - } + if (chance == 1 && !IsNeonInstalled(veh) && veh->m_pDriver != pPlayer) + { + InstallNeon(veh, Random(0, 255), Random(0, 255), Random(0, 255)); + } + } + m_Neon::m_bTrafficTimer = timer; + } - if (m_bBikeFly && pVeh && pVeh->IsDriver(pPlayer)) - { - if (pVeh->m_nVehicleSubClass == VEHICLE_BIKE || pVeh->m_nVehicleSubClass == VEHICLE_BMX) - { - if (sqrt(pVeh->m_vecMoveSpeed.x * pVeh->m_vecMoveSpeed.x + - pVeh->m_vecMoveSpeed.y * pVeh->m_vecMoveSpeed.y + - pVeh->m_vecMoveSpeed.z * pVeh->m_vecMoveSpeed.z) > 0.0 && - CTimer::ms_fTimeStep > 0.0) - { - pVeh->FlyingControl(3, -9999.9902f, -9999.9902f, -9999.9902f, -9999.9902f); - } - } - } + if (m_bBikeFly && pVeh && pVeh->IsDriver(pPlayer)) + { + if (pVeh->m_nVehicleSubClass == VEHICLE_BIKE || pVeh->m_nVehicleSubClass == VEHICLE_BMX) + { + if (sqrt(pVeh->m_vecMoveSpeed.x * pVeh->m_vecMoveSpeed.x + + pVeh->m_vecMoveSpeed.y * pVeh->m_vecMoveSpeed.y + + pVeh->m_vecMoveSpeed.z * pVeh->m_vecMoveSpeed.z + ) > 0.0 + && CTimer::ms_fTimeStep > 0.0) + { + pVeh->FlyingControl(3, -9999.9902f, -9999.9902f, -9999.9902f, -9999.9902f); + } + } + } #endif - }; + }; } #ifdef GTASA -void Vehicle::AddComponent(const std::string &component, const bool display_message) +void Vehicle::AddComponent(const std::string& component, const bool display_message) { - try - { - CPlayerPed *player = FindPlayerPed(); - int icomp = std::stoi(component); - int hveh = CPools::GetVehicleRef(player->m_pVehicle); + try + { + CPlayerPed* player = FindPlayerPed(); + int icomp = std::stoi(component); + int hveh = CPools::GetVehicleRef(player->m_pVehicle); - CStreaming::RequestModel(icomp, eStreamingFlags::PRIORITY_REQUEST); - CStreaming::LoadAllRequestedModels(true); - player->m_pVehicle->AddVehicleUpgrade(icomp); - CStreaming::SetModelIsDeletable(icomp); + CStreaming::RequestModel(icomp, eStreamingFlags::PRIORITY_REQUEST); + CStreaming::LoadAllRequestedModels(true); + player->m_pVehicle->AddVehicleUpgrade(icomp); + CStreaming::SetModelIsDeletable(icomp); - if (display_message) - SetHelpMessage("Component added", false, false, false); - } - catch (...) - { - gLog << "Failed to component to vehicle " << component << std::endl; - } + if (display_message) + SetHelpMessage("Component added", false, false, false); + } + catch (...) + { + gLog << "Failed to component to vehicle " << component << std::endl; + } } -void Vehicle::RemoveComponent(const std::string &component, const bool display_message) + +void Vehicle::RemoveComponent(const std::string& component, const bool display_message) { - try - { - CPlayerPed *player = FindPlayerPed(); - int icomp = std::stoi(component); - int hveh = CPools::GetVehicleRef(player->m_pVehicle); + try + { + CPlayerPed* player = FindPlayerPed(); + int icomp = std::stoi(component); + int hveh = CPools::GetVehicleRef(player->m_pVehicle); - player->m_pVehicle->RemoveVehicleUpgrade(icomp); + player->m_pVehicle->RemoveVehicleUpgrade(icomp); - if (display_message) - { - SetHelpMessage("Component removed", false, false, false); - } - } - catch (...) - { - gLog << "Failed to remove component from vehicle " << component << std::endl; - } + if (display_message) + { + SetHelpMessage("Component removed", false, false, false); + } + } + catch (...) + { + gLog << "Failed to remove component from vehicle " << component << std::endl; + } } // hardcoded for now int Vehicle::GetRandomTrainIdForModel(int model) { - static int train_ids[] = { - 8, 9, // model 449 - 0, 3, 6, 10, 12, 13, // model 537 - 1, 5, 15 // model 538 - }; - int _start = 0, _end = 0; + static int train_ids[] = { + 8, 9, // model 449 + 0, 3, 6, 10, 12, 13, // model 537 + 1, 5, 15 // model 538 + }; + int _start = 0, _end = 0; - switch (model) - { - case 449: - _start = 0; - _end = 1; - break; - case 537: - _start = 2; - _end = 7; - break; - case 538: - _start = 8; - _end = 10; - break; - default: - SetHelpMessage("Invalid train model", false, false, false); - return -1; - } - int id = Random(_start, _end); - return train_ids[id]; + switch (model) + { + case 449: + _start = 0; + _end = 1; + break; + case 537: + _start = 2; + _end = 7; + break; + case 538: + _start = 8; + _end = 10; + break; + default: + SetHelpMessage("Invalid train model", false, false, false); + return -1; + } + int id = Random(_start, _end); + return train_ids[id]; } #elif GTAVC void WarpPlayerIntoVehicle(CVehicle *pVeh, int seatId) { - CPlayerPed *pPlayer = FindPlayerPed(); - pPlayer->m_bInVehicle = true; - pPlayer->m_pVehicle = pVeh; - pPlayer->RegisterReference((CEntity **)&pPlayer->m_pVehicle); - pPlayer->m_pObjectiveVehicle = pVeh; - pPlayer->RegisterReference((CEntity **)&pPlayer->m_pObjectiveVehicle); - pPlayer->m_dwAction = ePedAction::Driving; - pPlayer->m_dwObjective = OBJECTIVE_NO_OBJ; - patch::Set(0x7838CD, 1); // player got in car flag - Call<0x41D370>(pVeh); // CCarCtrl::RegisterVehicleOfInterest + CPlayerPed *pPlayer = FindPlayerPed(); + pPlayer->m_bInVehicle = true; + pPlayer->m_pVehicle = pVeh; + pPlayer->RegisterReference((CEntity**)&pPlayer->m_pVehicle); + pPlayer->m_pObjectiveVehicle = pVeh; + pPlayer->RegisterReference((CEntity**)&pPlayer->m_pObjectiveVehicle); + pPlayer->m_dwAction = ePedAction::Driving; + pPlayer->m_dwObjective = OBJECTIVE_NO_OBJ; + patch::Set(0x7838CD, 1); // player got in car flag + Call<0x41D370>(pVeh); // CCarCtrl::RegisterVehicleOfInterest - if (pVeh->m_passengers[seatId]) - { - pVeh->m_passengers[seatId]->Remove(); - } - pVeh->m_passengers[seatId] = pPlayer; - pVeh->RegisterReference((CEntity **)&pVeh->m_passengers[seatId]); + if (pVeh->m_passengers[seatId]) + { + pVeh->m_passengers[seatId]->Remove(); + } + pVeh->m_passengers[seatId] = pPlayer; + pVeh->RegisterReference((CEntity**)&pVeh->m_passengers[seatId]); - // Set player position - CWorld::Remove(pPlayer); - pPlayer->m_placement.pos.x = pVeh->m_placement.pos.x; - pPlayer->m_placement.pos.y = pVeh->m_placement.pos.y; - pPlayer->m_placement.pos.z = pVeh->m_placement.pos.z; - CWorld::Add(pPlayer); + // Set player position + CWorld::Remove(pPlayer); + pPlayer->m_placement.pos.x = pVeh->m_placement.pos.x; + pPlayer->m_placement.pos.y = pVeh->m_placement.pos.y; + pPlayer->m_placement.pos.z = pVeh->m_placement.pos.z; + CWorld::Add(pPlayer); - pPlayer->m_nFlags.bUseCollision = false; - pPlayer->m_nPedFlags.bIsStanding = false; - pPlayer->m_nPedFlags.b03 = 0; - RpAnimBlendClumpSetBlendDeltas(pPlayer->m_pRwClump, 16, -1000); - pPlayer->AddInCarAnims(pVeh, false); - CallMethod<0x4FF6A0>(pPlayer); // char __thiscall RemoveWeaponWhenEnteringVehicle(CPed*) + pPlayer->m_nFlags.bUseCollision = false; + pPlayer->m_nPedFlags.bIsStanding = false; + pPlayer->m_nPedFlags.b03 = 0; + RpAnimBlendClumpSetBlendDeltas(pPlayer->m_pRwClump, 16, -1000); + pPlayer->AddInCarAnims(pVeh, false); + CallMethod<0x4FF6A0>(pPlayer); // char __thiscall RemoveWeaponWhenEnteringVehicle(CPed*) } -#endif +#endif #ifdef GTASA -void Vehicle::SpawnVehicle(std::string &smodel) +void Vehicle::SpawnVehicle(std::string& smodel) #else // GTA3 & GTAVC -void Vehicle::SpawnVehicle(std::string &rootkey, std::string &vehName, std::string &smodel) +void Vehicle::SpawnVehicle(std::string& rootkey, std::string& vehName, std::string& smodel) #endif { - CPlayerPed *player = FindPlayerPed(); - int hplayer = CPools::GetPedRef(player); + CPlayerPed* player = FindPlayerPed(); + int hplayer = CPools::GetPedRef(player); - int imodel = std::stoi(smodel); - CVehicle *veh = nullptr; + int imodel = std::stoi(smodel); + CVehicle* veh = nullptr; - int interior = BY_GAME(player->m_nAreaCode, player->m_nInterior, 0); + int interior = BY_GAME(player->m_nAreaCode, player->m_nInterior, 0); - CVector pos = player->GetPosition(); - int speed = 0; + CVector pos = player->GetPosition(); + int speed = 0; - bool bInVehicle = Command(hplayer); - if (bInVehicle && m_Spawner::m_bSpawnInside) - { - CVehicle *pveh = player->m_pVehicle; - int hveh = CPools::GetVehicleRef(pveh); - pos = pveh->GetPosition(); + bool bInVehicle = Command(hplayer); + if (bInVehicle && m_Spawner::m_bSpawnInside) + { + CVehicle* pveh = player->m_pVehicle; + int hveh = CPools::GetVehicleRef(pveh); + pos = pveh->GetPosition(); - Command(hveh, &speed); + Command(hveh, &speed); - Command(hplayer, pos.x, pos.y, pos.z); + Command(hplayer, pos.x, pos.y, pos.z); #ifdef GTASA - if (pveh->m_nVehicleClass == VEHICLE_TRAIN) - { - Command(hveh); - } - else - { - Command(hveh); - } + if (pveh->m_nVehicleClass == VEHICLE_TRAIN) + { + Command(hveh); + } + else + { + Command(hveh); + } #else // GTA3 & GTAVC - Command(hveh); + Command(hveh); #endif - } + } - if (interior == 0) - { - if (m_Spawner::m_bSpawnInAir && (CModelInfo::IsHeliModel(imodel) || CModelInfo::IsPlaneModel(imodel))) - { - pos.z = 400; - } - else - { - pos.z -= 5; - } - } + if (interior == 0) + { + if (m_Spawner::m_bSpawnInAir && (CModelInfo::IsHeliModel(imodel) || CModelInfo::IsPlaneModel(imodel))) + { + pos.z = 400; + } + else + { + pos.z -= 5; + } + } #ifdef GTASA - if (CModelInfo::IsTrainModel(imodel)) - { - int train_id = GetRandomTrainIdForModel(imodel); + if (CModelInfo::IsTrainModel(imodel)) + { + int train_id = GetRandomTrainIdForModel(imodel); - if (train_id == -1) // Unknown train id - return; + if (train_id == -1) // Unknown train id + return; - int hveh = 0; + int hveh = 0; - // Loading all train related models - CStreaming::RequestModel(590, PRIORITY_REQUEST); - CStreaming::RequestModel(538, PRIORITY_REQUEST); - CStreaming::RequestModel(570, PRIORITY_REQUEST); - CStreaming::RequestModel(569, PRIORITY_REQUEST); - CStreaming::RequestModel(537, PRIORITY_REQUEST); - CStreaming::RequestModel(449, PRIORITY_REQUEST); + // Loading all train related models + CStreaming::RequestModel(590, PRIORITY_REQUEST); + CStreaming::RequestModel(538, PRIORITY_REQUEST); + CStreaming::RequestModel(570, PRIORITY_REQUEST); + CStreaming::RequestModel(569, PRIORITY_REQUEST); + CStreaming::RequestModel(537, PRIORITY_REQUEST); + CStreaming::RequestModel(449, PRIORITY_REQUEST); - CStreaming::LoadAllRequestedModels(false); + CStreaming::LoadAllRequestedModels(false); - CTrain *train = nullptr; - CTrain *carraige = nullptr; - int track = Random(0, 1); - int node = CTrain::FindClosestTrackNode(pos, &track); - CTrain::CreateMissionTrain(pos, (Random(0, 1)) == 1 ? true : false, train_id, &train, &carraige, node, track, - false); + CTrain* train = nullptr; + CTrain* carraige = nullptr; + int track = Random(0, 1); + int node = CTrain::FindClosestTrackNode(pos, &track); + CTrain::CreateMissionTrain(pos, (Random(0, 1)) == 1 ? true : false, train_id, &train, &carraige, node, + track, false); - veh = (CVehicle *)train; - hveh = CPools::GetVehicleRef(veh); - if (veh->m_pDriver) - Command(CPools::GetPedRef(veh->m_pDriver)); + veh = (CVehicle*)train; + hveh = CPools::GetVehicleRef(veh); + if (veh->m_pDriver) + Command(CPools::GetPedRef(veh->m_pDriver)); - if (m_Spawner::m_bSpawnInside) - { - Command(hplayer, hveh); - Command(hveh, speed); - } - Command(hveh); - Command(hveh); - CStreaming::SetModelIsDeletable(590); - CStreaming::SetModelIsDeletable(538); - CStreaming::SetModelIsDeletable(570); - CStreaming::SetModelIsDeletable(569); - CStreaming::SetModelIsDeletable(537); - CStreaming::SetModelIsDeletable(449); - } - else - { + if (m_Spawner::m_bSpawnInside) + { + Command(hplayer, hveh); + Command(hveh, speed); + } + Command(hveh); + Command(hveh); + CStreaming::SetModelIsDeletable(590); + CStreaming::SetModelIsDeletable(538); + CStreaming::SetModelIsDeletable(570); + CStreaming::SetModelIsDeletable(569); + CStreaming::SetModelIsDeletable(537); + CStreaming::SetModelIsDeletable(449); + } + else + { #endif - CStreaming::RequestModel(imodel, PRIORITY_REQUEST); - CStreaming::LoadAllRequestedModels(false); + CStreaming::RequestModel(imodel, PRIORITY_REQUEST); + CStreaming::LoadAllRequestedModels(false); #ifdef GTASA - if (m_Spawner::m_nLicenseText[0] != '\0') - { - Command(imodel, m_Spawner::m_nLicenseText); - } + if (m_Spawner::m_nLicenseText[0] != '\0') + { + Command(imodel, m_Spawner::m_nLicenseText); + } #endif - int hveh = 0; - if (m_Spawner::m_bSpawnInside) - { - Command(imodel, pos.x, pos.y, pos.z + 4.0f, &hveh); - veh = CPools::GetVehicle(hveh); + int hveh = 0; + if (m_Spawner::m_bSpawnInside) + { + Command(imodel, pos.x, pos.y, pos.z + 4.0f, &hveh); + veh = CPools::GetVehicle(hveh); #ifdef GTASA - veh->SetHeading(player->GetHeading()); + veh->SetHeading(player->GetHeading()); #elif GTAVC - float x, y, z; - player->m_placement.GetOrientation(x, y, z); - veh->m_placement.SetOrientation(x, y, z); -#else // GTA3 - float x, y, z; - player->GetOrientation(x, y, z); - veh->SetOrientation(x, y, z); + float x,y,z; + player->m_placement.GetOrientation(x, y, z); + veh->m_placement.SetOrientation(x, y, z); +#else // GTA3 + float x,y,z; + player->GetOrientation(x, y, z); + veh->SetOrientation(x, y, z); #endif - Command(hplayer, hveh); - Command(hveh, speed); - } - else - { + Command(hplayer, hveh); + Command(hveh, speed); + } + else + { #ifdef GTASA - player->TransformFromObjectSpace(pos, CVector(0, 10, 0)); + player->TransformFromObjectSpace(pos, CVector(0, 10, 0)); #else // GTA3 & GTAVC - player->TransformFromObjectSpace(pos); -#endif - Command(imodel, pos.x, pos.y, pos.z + 3.0f, &hveh); - veh = CPools::GetVehicle(hveh); + player->TransformFromObjectSpace(pos); +#endif + Command(imodel, pos.x, pos.y, pos.z + 3.0f, &hveh); + veh = CPools::GetVehicle(hveh); #ifdef GTASA - veh->SetHeading(player->GetHeading() + 55.0f); + veh->SetHeading(player->GetHeading() + 55.0f); #elif GTAVC - float x, y, z; - player->m_placement.GetOrientation(x, y, z); - veh->m_placement.SetOrientation(x, y, z); -#else // GTA3 - float x, y, z; - player->GetOrientation(x, y, z); - veh->SetOrientation(x, y, z); + float x,y,z; + player->m_placement.GetOrientation(x, y, z); + veh->m_placement.SetOrientation(x, y, z); +#else // GTA3 + float x,y,z; + player->GetOrientation(x, y, z); + veh->SetOrientation(x, y, z); #endif - } - BY_GAME(veh->m_nDoorLock, veh->m_nLockStatus, veh->m_nDoorLock) = CARLOCK_UNLOCKED; + } + BY_GAME(veh->m_nDoorLock, veh->m_nLockStatus, veh->m_nDoorLock) = CARLOCK_UNLOCKED; #ifndef GTA3 - BY_GAME(veh->m_nAreaCode, veh->m_nInterior) = interior; + BY_GAME(veh->m_nAreaCode, veh->m_nInterior) = interior; #endif - Command(CPools::GetVehicleRef(veh)); - CStreaming::SetModelIsDeletable(imodel); + Command(CPools::GetVehicleRef(veh)); + CStreaming::SetModelIsDeletable(imodel); #ifdef GTASA - } - veh->m_nVehicleFlags.bHasBeenOwnedByPlayer = true; + } + veh->m_nVehicleFlags.bHasBeenOwnedByPlayer = true; #else // GTA3 & GTAVC - Command(); + Command(); #endif } std::string Vehicle::GetNameFromModel(int model) { #ifdef GTA3 - return std::to_string(model); + return std::to_string(model); #else - return (const char *)CModelInfo::GetModelInfo(model) + 0x32; + return (const char*)CModelInfo::GetModelInfo(model) + 0x32; #endif } -int Vehicle::GetModelFromName(const char *name) +int Vehicle::GetModelFromName(const char* name) { - int model = 0; - CBaseModelInfo *pModelInfo = CModelInfo::GetModelInfo((char *)name, &model); + int model = 0; + CBaseModelInfo* pModelInfo = CModelInfo::GetModelInfo((char*)name, &model); - if (model > 0 && model < 1000000 && GetNameFromModel(model) != "") - { - return model; - } - else - { - return 0; - } + if (model > 0 && model < 1000000 && GetNameFromModel(model) != "") + { + return model; + } + else + { + return 0; + } } void Vehicle::Draw() { - ImGui::Spacing(); - CPlayerPed *pPlayer = FindPlayerPed(); - int hplayer = CPools::GetPedRef(pPlayer); - CVehicle *pVeh = pPlayer->m_pVehicle; + ImGui::Spacing(); + CPlayerPed* pPlayer = FindPlayerPed(); + int hplayer = CPools::GetPedRef(pPlayer); + CVehicle *pVeh = pPlayer->m_pVehicle; - if (ImGui::Button("Blow up cars", ImVec2(Ui::GetSize(BY_GAME(3, 2, 2))))) - { - for (CVehicle *pVeh : CPools::ms_pVehiclePool) - { - BY_GAME(pVeh->BlowUpCar(pPlayer, false), pVeh->BlowUpCar(pPlayer), pVeh->BlowUpCar(pPlayer)); - } - } + if (ImGui::Button("Blow up cars", ImVec2(Ui::GetSize(BY_GAME(3,2,2))))) + { + for (CVehicle *pVeh : CPools::ms_pVehiclePool) + { + BY_GAME(pVeh->BlowUpCar(pPlayer, false), pVeh->BlowUpCar(pPlayer), pVeh->BlowUpCar(pPlayer)); + } + } - ImGui::SameLine(); + ImGui::SameLine(); - if (ImGui::Button("Fix vehicle", ImVec2(Ui::GetSize(BY_GAME(3, 2, 2))))) - { - if (pPlayer && pVeh) - { - FixVehicle(pVeh); - } - } + if (ImGui::Button("Fix vehicle", ImVec2(Ui::GetSize(BY_GAME(3,2,2))))) + { + if (pPlayer && pVeh) + { + FixVehicle(pVeh); + } + } #ifdef GTASA - ImGui::SameLine(); + ImGui::SameLine(); - if (ImGui::Button("Flip vehicle", ImVec2(Ui::GetSize(3)))) - { - if (pPlayer->m_nPedFlags.bInVehicle) - { - int hveh = CPools::GetVehicleRef(pPlayer->m_pVehicle); - float roll; + if (ImGui::Button("Flip vehicle", ImVec2(Ui::GetSize(3)))) + { + if (pPlayer->m_nPedFlags.bInVehicle) + { + int hveh = CPools::GetVehicleRef(pPlayer->m_pVehicle); + float roll; - Command(hveh, &roll); - roll += 180; - Command(hveh, roll); - Command(hveh, roll); // z rot fix - } - } + Command(hveh, &roll); + roll += 180; + Command(hveh, roll); + Command(hveh, roll); // z rot fix + } + } #endif - ImGui::Spacing(); + ImGui::Spacing(); - if (ImGui::BeginTabBar("Vehicle", ImGuiTabBarFlags_NoTooltip + ImGuiTabBarFlags_FittingPolicyScroll)) - { - CVehicle *pVeh = pPlayer->m_pVehicle; - bool is_driver = pVeh && (pPlayer->m_pVehicle->m_pDriver == pPlayer); + if (ImGui::BeginTabBar("Vehicle", ImGuiTabBarFlags_NoTooltip + ImGuiTabBarFlags_FittingPolicyScroll)) + { + CVehicle* pVeh = pPlayer->m_pVehicle; + bool is_driver = pVeh && (pPlayer->m_pVehicle->m_pDriver == pPlayer); - ImGui::Spacing(); + ImGui::Spacing(); - if (ImGui::BeginTabItem("Checkboxes")) - { - ImGui::Spacing(); - ImGui::BeginChild("CheckboxesChild"); - ImGui::Columns(2, 0, false); + if (ImGui::BeginTabItem("Checkboxes")) + { + ImGui::Spacing(); + ImGui::BeginChild("CheckboxesChild"); + ImGui::Columns(2, 0, false); #ifdef GTASA - Ui::CheckboxAddress("Aim while driving", 0x969179); - Ui::CheckboxAddress("All cars have nitro", 0x969165); + Ui::CheckboxAddress("Aim while driving", 0x969179); + Ui::CheckboxAddress("All cars have nitro", 0x969165); #endif #ifdef GTA3 - Ui::CheckboxAddress("Cars fly", 0x95CD75); + Ui::CheckboxAddress("Cars fly", 0x95CD75); #else - Ui::CheckboxAddress("Aggressive drivers", BY_GAME(0x96914F, 0xA10B47, NULL)); - Ui::CheckboxAddress("All taxis have nitro", BY_GAME(0x96918B, 0xA10B3A, NULL)); - Ui::CheckboxWithHint("Bikes fly", &m_bBikeFly); - Ui::CheckboxAddress("Boats fly", BY_GAME(0x969153, 0xA10B11, NULL)); - Ui::CheckboxAddress("Cars fly", BY_GAME(0x969160, 0xA10B28, NULL)); - Ui::CheckboxWithHint("Cars heavy", &m_bVehHeavy); + Ui::CheckboxAddress("Aggressive drivers", BY_GAME(0x96914F,0xA10B47, NULL)); + Ui::CheckboxAddress("All taxis have nitro", BY_GAME(0x96918B,0xA10B3A, NULL)); + Ui::CheckboxWithHint("Bikes fly", &m_bBikeFly); + Ui::CheckboxAddress("Boats fly", BY_GAME(0x969153, 0xA10B11, NULL)); + Ui::CheckboxAddress("Cars fly", BY_GAME(0x969160, 0xA10B28, NULL)); + Ui::CheckboxWithHint("Cars heavy", &m_bVehHeavy); #endif - if (Ui::CheckboxWithHint( - "Damage proof", &m_bNoDamage, - "Every vehicle entered will be damage proof\nBullet, Collision, Explosion, Fire, Meele etc")) - { - if (pVeh && !m_bNoDamage) - { + if (Ui::CheckboxWithHint("Damage proof", &m_bNoDamage, + "Every vehicle entered will be damage proof\nBullet, Collision, Explosion, Fire, Meele etc")) + { + if (pVeh && !m_bNoDamage) + { #ifdef GTASA - pVeh->m_nPhysicalFlags.bBulletProof = false; - pVeh->m_nPhysicalFlags.bExplosionProof = false; - pVeh->m_nPhysicalFlags.bFireProof = false; - pVeh->m_nPhysicalFlags.bCollisionProof = false; - pVeh->m_nPhysicalFlags.bMeeleProof = false; - pVeh->m_nVehicleFlags.bCanBeDamaged = false; + pVeh->m_nPhysicalFlags.bBulletProof = false; + pVeh->m_nPhysicalFlags.bExplosionProof = false; + pVeh->m_nPhysicalFlags.bFireProof = false; + pVeh->m_nPhysicalFlags.bCollisionProof = false; + pVeh->m_nPhysicalFlags.bMeeleProof = false; + pVeh->m_nVehicleFlags.bCanBeDamaged = false; #elif GTAVC - pVeh->m_nFlags.bBulletProof = false; - pVeh->m_nFlags.bExplosionProof = false; - pVeh->m_nFlags.bFireProof = false; - pVeh->m_nFlags.bCollisionProof = false; - pVeh->m_nFlags.bMeleeProof = false; + pVeh->m_nFlags.bBulletProof = false; + pVeh->m_nFlags.bExplosionProof = false; + pVeh->m_nFlags.bFireProof = false; + pVeh->m_nFlags.bCollisionProof = false; + pVeh->m_nFlags.bMeleeProof = false; #else // GTA3 - pVeh->m_nEntityFlags.bBulletProof = false; - pVeh->m_nEntityFlags.bExplosionProof = false; - pVeh->m_nEntityFlags.bFireProof = false; - pVeh->m_nEntityFlags.bCollisionProof = false; - pVeh->m_nEntityFlags.bMeleeProof = false; + pVeh->m_nEntityFlags.bBulletProof = false; + pVeh->m_nEntityFlags.bExplosionProof = false; + pVeh->m_nEntityFlags.bFireProof = false; + pVeh->m_nEntityFlags.bCollisionProof = false; + pVeh->m_nEntityFlags.bMeleeProof = false; #endif - } - } + } + } #ifdef GTASA - Ui::CheckboxAddress("Decreased traffic", 0x96917A); - // if (Ui::CheckboxWithHint("Disable collisions", &m_bDisableColDetection)) - // { - // if (m_bDisableColDetection) - // { - // patch::SetUChar(0x56717B, 0x7D); - // patch::SetUChar(0x56725D, 0x7D); - // } - // // update flags for exising vehicles - // for (auto veh : CPools::ms_pVehiclePool) - // { - // if (veh == FindPlayerVehicle(-1, false)) - // { - // continue; - // } - // if (m_bDisableColDetection) - // { - // CCollisionData* pColData = veh->GetColModel()->m_pColData; - // // pColData->m_nNumSpheres = 0; - // pColData->m_nNumBoxes = 0; - // pColData->m_nNumTriangles = 0; - // } - // } - // } + Ui::CheckboxAddress("Decreased traffic", 0x96917A); + // if (Ui::CheckboxWithHint("Disable collisions", &m_bDisableColDetection)) + // { + // if (m_bDisableColDetection) + // { + // patch::SetUChar(0x56717B, 0x7D); + // patch::SetUChar(0x56725D, 0x7D); + // } + // // update flags for exising vehicles + // for (auto veh : CPools::ms_pVehiclePool) + // { + // if (veh == FindPlayerVehicle(-1, false)) + // { + // continue; + // } + // if (m_bDisableColDetection) + // { + // CCollisionData* pColData = veh->GetColModel()->m_pColData; + // // pColData->m_nNumSpheres = 0; + // pColData->m_nNumBoxes = 0; + // pColData->m_nNumTriangles = 0; + // } + // } + // } #endif - ImGui::NextColumn(); + ImGui::NextColumn(); #ifdef GTASA - Ui::CheckboxWithHint("Don't fall off bike", &m_bDontFallBike); + Ui::CheckboxWithHint("Don't fall off bike", &m_bDontFallBike); #endif #ifndef GTA3 - Ui::CheckboxAddress("Drive on water", BY_GAME(0x969152, 0xA10B81)); + Ui::CheckboxAddress("Drive on water", BY_GAME(0x969152,0xA10B81)); #endif #ifdef GTASA - Ui::CheckboxAddressEx("Lock train camera", 0x52A52F, 171, 6); - Ui::CheckboxAddress("Float away when hit", 0x969166); + Ui::CheckboxAddressEx("Lock train camera", 0x52A52F, 171, 6); + Ui::CheckboxAddress("Float away when hit", 0x969166); #endif #ifndef GTA3 - Ui::CheckboxAddress("Green traffic lights", BY_GAME(0x96914E, 0xA10ADC)); + Ui::CheckboxAddress("Green traffic lights", BY_GAME(0x96914E,0xA10ADC)); #endif #ifdef GTASA - Ui::CheckboxAddress("Perfect handling", 0x96914C); - Ui::CheckboxAddress("Tank mode", 0x969164); + Ui::CheckboxAddress("Perfect handling", 0x96914C); + Ui::CheckboxAddress("Tank mode", 0x969164); - Ui::CheckboxWithHint("Unlimited nitro", &m_UnlimitedNitro::m_bEnabled, - "Nitro will activate when left clicked\n\ + Ui::CheckboxWithHint("Unlimited nitro", &m_UnlimitedNitro::m_bEnabled, "Nitro will activate when left clicked\n\ \nEnabling this would disable\nAll cars have nitro\nAll taxis have nitro"); #elif GTA3 - Ui::CheckboxAddress("Perfect handling", 0x95CD66); - static bool bTankMode = false; - if (Ui::CheckboxWithHint("Tank mode", &bTankMode)) - { - Call<0x490EE0>(); - } + Ui::CheckboxAddress("Perfect handling", 0x95CD66); + static bool bTankMode = false; + if (Ui::CheckboxWithHint("Tank mode", &bTankMode)) + { + Call<0x490EE0>(); + } #endif - Ui::CheckboxWithHint("Watertight car", &m_bVehWatertight); - Ui::CheckboxAddress("Wheels only", BY_GAME(0x96914B, 0xA10B70, 0x95CD78)); - ImGui::Columns(1); + Ui::CheckboxWithHint("Watertight car", &m_bVehWatertight); + Ui::CheckboxAddress("Wheels only", BY_GAME(0x96914B, 0xA10B70, 0x95CD78)); + ImGui::Columns(1); - if (is_driver) - { - ImGui::NewLine(); - ImGui::TextWrapped("For current vehicle,"); + if (is_driver) + { + ImGui::NewLine(); + ImGui::TextWrapped("For current vehicle,"); - ImGui::Columns(2, 0, false); + ImGui::Columns(2, 0, false); - bool state = false; + bool state = false; #ifdef GTASA - state = pVeh->m_nVehicleFlags.bAlwaysSkidMarks; - if (Ui::CheckboxWithHint("Always skid marks", &state, nullptr)) - pVeh->m_nVehicleFlags.bAlwaysSkidMarks = state; + state = pVeh->m_nVehicleFlags.bAlwaysSkidMarks; + if (Ui::CheckboxWithHint("Always skid marks", &state, nullptr)) + pVeh->m_nVehicleFlags.bAlwaysSkidMarks = state; #endif - state = BY_GAME(pVeh->m_nPhysicalFlags.bBulletProof, pVeh->m_nFlags.bBulletProof, - pVeh->m_nEntityFlags.bBulletProof); - if (Ui::CheckboxWithHint("Bullet proof", &state, nullptr, m_bNoDamage)) - { - BY_GAME(pVeh->m_nPhysicalFlags.bBulletProof, pVeh->m_nFlags.bBulletProof, - pVeh->m_nEntityFlags.bBulletProof) = state; - } + state = BY_GAME(pVeh->m_nPhysicalFlags.bBulletProof, pVeh->m_nFlags.bBulletProof, pVeh->m_nEntityFlags.bBulletProof); + if (Ui::CheckboxWithHint("Bullet proof", &state, nullptr, m_bNoDamage)) + { + BY_GAME(pVeh->m_nPhysicalFlags.bBulletProof, pVeh->m_nFlags.bBulletProof, pVeh->m_nEntityFlags.bBulletProof) = state; + } - state = BY_GAME(pVeh->m_nPhysicalFlags.bCollisionProof, pVeh->m_nFlags.bCollisionProof, - pVeh->m_nEntityFlags.bCollisionProof); - if (Ui::CheckboxWithHint("Collision proof", &state, nullptr, m_bNoDamage)) - { - BY_GAME(pVeh->m_nPhysicalFlags.bCollisionProof, pVeh->m_nFlags.bCollisionProof, - pVeh->m_nEntityFlags.bCollisionProof) = state; - } + state = BY_GAME(pVeh->m_nPhysicalFlags.bCollisionProof, pVeh->m_nFlags.bCollisionProof, pVeh->m_nEntityFlags.bCollisionProof); + if (Ui::CheckboxWithHint("Collision proof", &state, nullptr, m_bNoDamage)) + { + BY_GAME(pVeh->m_nPhysicalFlags.bCollisionProof, pVeh->m_nFlags.bCollisionProof, pVeh->m_nEntityFlags.bCollisionProof) = state; + } #ifdef GTASA - state = pVeh->m_nVehicleFlags.bDisableParticles; - if (Ui::CheckboxWithHint("Disable particles", &state, nullptr)) - { - pVeh->m_nVehicleFlags.bDisableParticles = state; - } + state = pVeh->m_nVehicleFlags.bDisableParticles; + if (Ui::CheckboxWithHint("Disable particles", &state, nullptr)) + { + pVeh->m_nVehicleFlags.bDisableParticles = state; + } - state = pVeh->m_nVehicleFlags.bVehicleCanBeTargetted; - if (Ui::CheckboxWithHint("Driver targetable", &state, "Driver can be targeted")) - { - pVeh->m_nVehicleFlags.bVehicleCanBeTargetted = state; - } + state = pVeh->m_nVehicleFlags.bVehicleCanBeTargetted; + if (Ui::CheckboxWithHint("Driver targetable", &state, "Driver can be targeted")) + { + pVeh->m_nVehicleFlags.bVehicleCanBeTargetted = state; + } #endif - state = BY_GAME(!pVeh->m_nVehicleFlags.bEngineBroken, true, true) || pVeh->m_nVehicleFlags.bEngineOn; - if (Ui::CheckboxWithHint("Engine on", &state, nullptr, !is_driver)) - { + state = BY_GAME(!pVeh->m_nVehicleFlags.bEngineBroken, true, true) || pVeh->m_nVehicleFlags.bEngineOn; + if (Ui::CheckboxWithHint("Engine on", &state, nullptr, !is_driver)) + { #ifdef GTASA - pVeh->m_nVehicleFlags.bEngineBroken = !state; + pVeh->m_nVehicleFlags.bEngineBroken = !state; #endif - pVeh->m_nVehicleFlags.bEngineOn = state; - } + pVeh->m_nVehicleFlags.bEngineOn = state; + } + + state = BY_GAME(pVeh->m_nPhysicalFlags.bExplosionProof, pVeh->m_nFlags.bExplosionProof, pVeh->m_nEntityFlags.bExplosionProof); + if (Ui::CheckboxWithHint("Explosion proof", &state, nullptr, m_bNoDamage)) + { + BY_GAME(pVeh->m_nPhysicalFlags.bExplosionProof, pVeh->m_nFlags.bExplosionProof, pVeh->m_nEntityFlags.bExplosionProof) = state; + } - state = BY_GAME(pVeh->m_nPhysicalFlags.bExplosionProof, pVeh->m_nFlags.bExplosionProof, - pVeh->m_nEntityFlags.bExplosionProof); - if (Ui::CheckboxWithHint("Explosion proof", &state, nullptr, m_bNoDamage)) - { - BY_GAME(pVeh->m_nPhysicalFlags.bExplosionProof, pVeh->m_nFlags.bExplosionProof, - pVeh->m_nEntityFlags.bExplosionProof) = state; - } + state = BY_GAME(pVeh->m_nPhysicalFlags.bFireProof, pVeh->m_nFlags.bFireProof, pVeh->m_nEntityFlags.bFireProof); + if (Ui::CheckboxWithHint("Fire proof", &state, nullptr, m_bNoDamage)) + { + BY_GAME(pVeh->m_nPhysicalFlags.bFireProof, pVeh->m_nFlags.bFireProof, pVeh->m_nEntityFlags.bFireProof) = state; + } - state = BY_GAME(pVeh->m_nPhysicalFlags.bFireProof, pVeh->m_nFlags.bFireProof, - pVeh->m_nEntityFlags.bFireProof); - if (Ui::CheckboxWithHint("Fire proof", &state, nullptr, m_bNoDamage)) - { - BY_GAME(pVeh->m_nPhysicalFlags.bFireProof, pVeh->m_nFlags.bFireProof, - pVeh->m_nEntityFlags.bFireProof) = state; - } - - ImGui::NextColumn(); + ImGui::NextColumn(); #ifdef GTASA - state = pVeh->m_nVehicleFlags.bVehicleCanBeTargettedByHS; - if (Ui::CheckboxWithHint("HS targetable", &state, "Heat Seaker missile can target this")) - { - pVeh->m_nVehicleFlags.bVehicleCanBeTargettedByHS = state; - } + state = pVeh->m_nVehicleFlags.bVehicleCanBeTargettedByHS; + if (Ui::CheckboxWithHint("HS targetable", &state, "Heat Seaker missile can target this")) + { + pVeh->m_nVehicleFlags.bVehicleCanBeTargettedByHS = state; + } #endif - state = !BY_GAME(pVeh->m_bIsVisible, pVeh->m_nFlags.bIsVisible, pVeh->m_nEntityFlags.bIsVisible); - if (Ui::CheckboxWithHint("Invisible car", &state, nullptr, !is_driver)) - { - BY_GAME(pVeh->m_bIsVisible, pVeh->m_nFlags.bIsVisible, pVeh->m_nEntityFlags.bIsVisible) = !state; - } + state = !BY_GAME(pVeh->m_bIsVisible, pVeh->m_nFlags.bIsVisible, pVeh->m_nEntityFlags.bIsVisible); + if (Ui::CheckboxWithHint("Invisible car", &state, nullptr, !is_driver)) + { + BY_GAME(pVeh->m_bIsVisible, pVeh->m_nFlags.bIsVisible, pVeh->m_nEntityFlags.bIsVisible) = !state; + } - state = BY_GAME(!pVeh->ms_forceVehicleLightsOff, pVeh->m_nVehicleFlags.bLightsOn, - pVeh->m_nVehicleFlags.bLightsOn); - if (Ui::CheckboxWithHint("Lights on", &state, nullptr, !is_driver)) - { - BY_GAME(pVeh->ms_forceVehicleLightsOff, pVeh->m_nVehicleFlags.bLightsOn, - pVeh->m_nVehicleFlags.bLightsOn) = state; - } + state = BY_GAME(!pVeh->ms_forceVehicleLightsOff, pVeh->m_nVehicleFlags.bLightsOn, pVeh->m_nVehicleFlags.bLightsOn); + if (Ui::CheckboxWithHint("Lights on", &state, nullptr, !is_driver)) + { + BY_GAME(pVeh->ms_forceVehicleLightsOff, pVeh->m_nVehicleFlags.bLightsOn, pVeh->m_nVehicleFlags.bLightsOn) = state; + } - state = - BY_GAME(pVeh->m_nDoorLock, pVeh->m_nLockStatus, pVeh->m_nDoorLock) == CARLOCK_LOCKED_PLAYER_INSIDE; - if (Ui::CheckboxWithHint("Lock doors", &state, nullptr, !is_driver)) - { - if (state) - { - BY_GAME(pVeh->m_nDoorLock, pVeh->m_nLockStatus, pVeh->m_nDoorLock) = - CARLOCK_LOCKED_PLAYER_INSIDE; - } - else - { - BY_GAME(pVeh->m_nDoorLock, pVeh->m_nLockStatus, pVeh->m_nDoorLock) = CARLOCK_UNLOCKED; - } - } + state = BY_GAME(pVeh->m_nDoorLock, pVeh->m_nLockStatus, pVeh->m_nDoorLock) == CARLOCK_LOCKED_PLAYER_INSIDE; + if (Ui::CheckboxWithHint("Lock doors", &state, nullptr, !is_driver)) + { + if (state) + { + BY_GAME(pVeh->m_nDoorLock, pVeh->m_nLockStatus, pVeh->m_nDoorLock) = CARLOCK_LOCKED_PLAYER_INSIDE; + } + else + { + BY_GAME(pVeh->m_nDoorLock, pVeh->m_nLockStatus, pVeh->m_nDoorLock) = CARLOCK_UNLOCKED; + } + } - state = BY_GAME(pVeh->m_nPhysicalFlags.bMeeleProof, pVeh->m_nFlags.bMeleeProof, - pVeh->m_nEntityFlags.bMeleeProof); - if (Ui::CheckboxWithHint("Melee proof", &state, nullptr, m_bNoDamage)) - { - BY_GAME(pVeh->m_nPhysicalFlags.bMeeleProof, pVeh->m_nFlags.bMeleeProof, - pVeh->m_nEntityFlags.bMeleeProof) = state; - } + state = BY_GAME(pVeh->m_nPhysicalFlags.bMeeleProof, pVeh->m_nFlags.bMeleeProof, pVeh->m_nEntityFlags.bMeleeProof); + if (Ui::CheckboxWithHint("Melee proof", &state, nullptr, m_bNoDamage)) + { + BY_GAME(pVeh->m_nPhysicalFlags.bMeeleProof, pVeh->m_nFlags.bMeleeProof, pVeh->m_nEntityFlags.bMeleeProof) = state; + } #ifdef GTASA - state = pVeh->m_nVehicleFlags.bPetrolTankIsWeakPoint; - if (Ui::CheckboxWithHint("Petrol tank blow", &state, "Vehicle will blow up if petrol tank is shot")) - { - pVeh->m_nVehicleFlags.bPetrolTankIsWeakPoint = state; - } + state = pVeh->m_nVehicleFlags.bPetrolTankIsWeakPoint; + if (Ui::CheckboxWithHint("Petrol tank blow", &state, "Vehicle will blow up if petrol tank is shot")) + { + pVeh->m_nVehicleFlags.bPetrolTankIsWeakPoint = state; + } - state = pVeh->m_nVehicleFlags.bSirenOrAlarm; - if (Ui::CheckboxWithHint("Siren", &state)) - { - pVeh->m_nVehicleFlags.bSirenOrAlarm = state; - } + state = pVeh->m_nVehicleFlags.bSirenOrAlarm; + if (Ui::CheckboxWithHint("Siren", &state)) + { + pVeh->m_nVehicleFlags.bSirenOrAlarm = state; + } - state = pVeh->m_nVehicleFlags.bTakeLessDamage; - if (Ui::CheckboxWithHint("Take less dmg", &state, nullptr)) - pVeh->m_nVehicleFlags.bTakeLessDamage = state; + state = pVeh->m_nVehicleFlags.bTakeLessDamage; + if (Ui::CheckboxWithHint("Take less dmg", &state, nullptr)) + pVeh->m_nVehicleFlags.bTakeLessDamage = state; #endif - ImGui::Columns(1); - } - - ImGui::EndChild(); - ImGui::EndTabItem(); - } - if (ImGui::BeginTabItem("Menus")) - { - ImGui::Spacing(); - ImGui::BeginChild("MenusChild"); + ImGui::Columns(1); + } + ImGui::EndChild(); + ImGui::EndTabItem(); + } + if (ImGui::BeginTabItem("Menus")) + { + ImGui::Spacing(); + ImGui::BeginChild("MenusChild"); + #ifdef GTASA - Ui::EditAddress("Density multiplier", 0x8A5B20, 0, 1, 10); + Ui::EditAddress("Density multiplier", 0x8A5B20, 0, 1, 10); #endif - if (ImGui::CollapsingHeader("Enter nearest vehicle as")) - { - int hplayer = CPools::GetPedRef(pPlayer); - CVehicle *pClosestVeh = Util::GetClosestVehicle(); + if (ImGui::CollapsingHeader("Enter nearest vehicle as")) + { + int hplayer = CPools::GetPedRef(pPlayer); + CVehicle* pClosestVeh = Util::GetClosestVehicle(); - if (pClosestVeh) - { + if (pClosestVeh) + { #ifdef GTA3 - int seats = pClosestVeh->m_nNumMaxPassengers; + int seats = pClosestVeh->m_nNumMaxPassengers; #else - int seats = pClosestVeh->m_nMaxPassengers; + int seats = pClosestVeh->m_nMaxPassengers; #endif - ImGui::Spacing(); - ImGui::Columns(2, 0, false); + ImGui::Spacing(); + ImGui::Columns(2, 0, false); - ImGui::Text(GetNameFromModel(pClosestVeh->m_nModelIndex).c_str()); - ImGui::NextColumn(); - ImGui::Text("Total seats: %d", (seats + 1)); - ImGui::Columns(1); + ImGui::Text(GetNameFromModel(pClosestVeh->m_nModelIndex).c_str()); + ImGui::NextColumn(); + ImGui::Text("Total seats: %d", (seats + 1)); + ImGui::Columns(1); - ImGui::Spacing(); - if (ImGui::Button("Driver", ImVec2(Ui::GetSize(2)))) - { - Command(hplayer, pClosestVeh); - } + ImGui::Spacing(); + if (ImGui::Button("Driver", ImVec2(Ui::GetSize(2)))) + { + Command(hplayer, pClosestVeh); + } #ifndef GTA3 - for (int i = 0; i < seats; ++i) - { - if (i % 2 != 1) - { - ImGui::SameLine(); - } + for (int i = 0; i < seats; ++i) + { + if (i % 2 != 1) + { + ImGui::SameLine(); + } - if (ImGui::Button((std::string("Passenger ") + std::to_string(i + 1)).c_str(), - ImVec2(Ui::GetSize(2)))) - { + if (ImGui::Button((std::string("Passenger ") + std::to_string(i + 1)).c_str(), + ImVec2(Ui::GetSize(2)))) + { #ifdef GTASA - Command(hplayer, pClosestVeh, i); + Command(hplayer, pClosestVeh, i); #elif GTAVC - WarpPlayerIntoVehicle(pClosestVeh, i); + WarpPlayerIntoVehicle(pClosestVeh, i); #endif - } - } + } + } #endif - } - else - { - ImGui::Text("No nearby vehicles"); - } - - ImGui::Spacing(); - ImGui::Separator(); - } - if (ImGui::CollapsingHeader("Remove vehicles in radius")) - { - ImGui::InputInt("Radius", &m_nVehRemoveRadius); - ImGui::Spacing(); - if (ImGui::Button("Remove vehicles", Ui::GetSize(1))) - { - CPlayerPed *player = FindPlayerPed(); - for (CVehicle *pVeh : CPools::ms_pVehiclePool) - { - if (DistanceBetweenPoints(pVeh->GetPosition(), player->GetPosition()) < m_nVehRemoveRadius && - player->m_pVehicle != pVeh) - { - Command(CPools::GetVehicleRef(pVeh)); - } - } - } - ImGui::Spacing(); - ImGui::Separator(); - } + } + else + { + ImGui::Text("No nearby vehicles"); + } + ImGui::Spacing(); + ImGui::Separator(); + } + if (ImGui::CollapsingHeader("Remove vehicles in radius")) + { + ImGui::InputInt("Radius", &m_nVehRemoveRadius); + ImGui::Spacing(); + if (ImGui::Button("Remove vehicles", Ui::GetSize(1))) + { + CPlayerPed* player = FindPlayerPed(); + for (CVehicle* pVeh : CPools::ms_pVehiclePool) + { + if (DistanceBetweenPoints(pVeh->GetPosition(), player->GetPosition()) < m_nVehRemoveRadius + && player->m_pVehicle != pVeh) + { + Command(CPools::GetVehicleRef(pVeh)); + } + } + } + ImGui::Spacing(); + ImGui::Separator(); + } + #ifndef GTA3 - if (ImGui::CollapsingHeader("Traffic options")) - { + if (ImGui::CollapsingHeader("Traffic options")) + { - static std::vector color{{"Black", BY_GAME(0x969151, 0xA10B82)}, - {"Pink", BY_GAME(0x969150, 0xA10B26)}}; - Ui::RadioButtonAddress("Color", color); - ImGui::Spacing(); + static std::vector color + { + {"Black", BY_GAME(0x969151, 0xA10B82)}, + {"Pink", BY_GAME(0x969150, 0xA10B26)} + }; + Ui::RadioButtonAddress("Color", color); + ImGui::Spacing(); #ifdef GTASA - static std::vector type{ - {"Cheap", 0x96915E}, {"Country", 0x96917B}, {"Fast", 0x96915F}}; - Ui::RadioButtonAddress("Type", type); + static std::vector type{ + {"Cheap", 0x96915E}, {"Country", 0x96917B}, {"Fast", 0x96915F} + }; + Ui::RadioButtonAddress("Type", type); #endif - ImGui::Spacing(); - ImGui::Separator(); - } + ImGui::Spacing(); + ImGui::Separator(); + } #endif - if (pPlayer && pPlayer->m_pVehicle) - { - CVehicle *pVeh = pPlayer->m_pVehicle; - int hVeh = CPools::GetVehicleRef(pVeh); + if (pPlayer && pPlayer->m_pVehicle) + { + CVehicle* pVeh = pPlayer->m_pVehicle; + int hVeh = CPools::GetVehicleRef(pVeh); #ifdef GTASA - Ui::EditFloat("Dirt level", (int)pVeh + 0x4B0, 0, 7.5, 15); - if (pVeh->m_nVehicleClass == VEHICLE_AUTOMOBILE && ImGui::CollapsingHeader("Doors")) - { - ImGui::Columns(2, 0, false); - ImGui::RadioButton("Damage", &m_nDoorMenuButton, 0); - ImGui::RadioButton("Fix", &m_nDoorMenuButton, 1); - ImGui::NextColumn(); - ImGui::RadioButton("Open", &m_nDoorMenuButton, 2); - ImGui::RadioButton("Pop", &m_nDoorMenuButton, 3); - ImGui::Columns(1); - ImGui::Spacing(); + Ui::EditFloat("Dirt level", (int)pVeh + 0x4B0, 0, 7.5, 15); + if (pVeh->m_nVehicleClass == VEHICLE_AUTOMOBILE && ImGui::CollapsingHeader("Doors")) + { + ImGui::Columns(2, 0, false); + ImGui::RadioButton("Damage", &m_nDoorMenuButton, 0); + ImGui::RadioButton("Fix", &m_nDoorMenuButton, 1); + ImGui::NextColumn(); + ImGui::RadioButton("Open", &m_nDoorMenuButton, 2); + ImGui::RadioButton("Pop", &m_nDoorMenuButton, 3); + ImGui::Columns(1); + ImGui::Spacing(); - int seats = pVeh->m_nMaxPassengers + 1; // passenger + driver - int doors = seats == 4 ? 6 : 4; - int hveh = CPools::GetVehicleRef(pVeh); + int seats = pVeh->m_nMaxPassengers + 1; // passenger + driver + int doors = seats == 4 ? 6 : 4; + int hveh = CPools::GetVehicleRef(pVeh); - if (ImGui::Button("All", ImVec2(Ui::GetSize()))) - { - for (int i = 0; i < doors; ++i) - { - switch (m_nDoorMenuButton) - { - case 0: - Command(hveh, i); - break; - case 1: - Command(hveh, i); - break; - case 2: - Command(hveh, i); - break; - case 3: - Command(hveh, i); - break; - default: - break; - } - } - } + if (ImGui::Button("All", ImVec2(Ui::GetSize()))) + { + for (int i = 0; i < doors; ++i) + { + switch (m_nDoorMenuButton) + { + case 0: + Command(hveh, i); + break; + case 1: + Command(hveh, i); + break; + case 2: + Command(hveh, i); + break; + case 3: + Command(hveh, i); + break; + default: + break; + } + } + } - for (int i = 0; i != doors; ++i) - { - if (ImGui::Button(m_DoorNames[i].c_str(), ImVec2(Ui::GetSize(2)))) - { - switch (m_nDoorMenuButton) - { - case 0: - Command(hveh, i); - break; - case 1: - Command(hveh, i); - break; - case 2: - Command(hveh, i); - break; - case 3: - Command(hveh, i); - break; - default: - break; - } - } + for (int i = 0; i != doors; ++i) + { + if (ImGui::Button(m_DoorNames[i].c_str(), ImVec2(Ui::GetSize(2)))) + { + switch (m_nDoorMenuButton) + { + case 0: + Command(hveh, i); + break; + case 1: + Command(hveh, i); + break; + case 2: + Command(hveh, i); + break; + case 3: + Command(hveh, i); + break; + default: + break; + } + } - if (i % 2 != 1) - { - ImGui::SameLine(); - } - } + if (i % 2 != 1) + { + ImGui::SameLine(); + } + } - ImGui::Spacing(); - ImGui::Separator(); - } + ImGui::Spacing(); + ImGui::Separator(); + } #endif - if (ImGui::CollapsingHeader("Set speed")) - { - Ui::CheckboxWithHint("Lock speed", &m_bLockSpeed); - ImGui::Spacing(); - ImGui::InputFloat("Set", &m_fLockSpeed); - ImGui::Spacing(); + if (ImGui::CollapsingHeader("Set speed")) + { + Ui::CheckboxWithHint("Lock speed", &m_bLockSpeed); + ImGui::Spacing(); + ImGui::InputFloat("Set", &m_fLockSpeed); + ImGui::Spacing(); - m_fLockSpeed = m_fLockSpeed > 100 ? 100 : m_fLockSpeed; - m_fLockSpeed = m_fLockSpeed < 0 ? 0 : m_fLockSpeed; + m_fLockSpeed = m_fLockSpeed > 100 ? 100 : m_fLockSpeed; + m_fLockSpeed = m_fLockSpeed < 0 ? 0 : m_fLockSpeed; - if (ImGui::Button("Set speed##brn", ImVec2(Ui::GetSize(2)))) - { - Command(hVeh, m_fLockSpeed); - } + if (ImGui::Button("Set speed##brn", ImVec2(Ui::GetSize(2)))) + { + Command(hVeh, m_fLockSpeed); + } - ImGui::SameLine(); + ImGui::SameLine(); - if (ImGui::Button("Instant stop##brn", ImVec2(Ui::GetSize(2)))) - { - Command(hVeh, 0); - } - } - } - ImGui::EndChild(); - ImGui::EndTabItem(); - } - if (ImGui::BeginTabItem("Spawn")) - { - ImGui::Spacing(); - ImGui::Columns(2, 0, false); - Ui::CheckboxWithHint("Spawn inside", &m_Spawner::m_bSpawnInside, "Spawn inside vehicle as driver"); - ImGui::NextColumn(); - Ui::CheckboxWithHint("Spawn aircraft in air", &m_Spawner::m_bSpawnInAir); - ImGui::Columns(1); + if (ImGui::Button("Instant stop##brn", ImVec2(Ui::GetSize(2)))) + { + Command(hVeh, 0); + } + } + } + ImGui::EndChild(); + ImGui::EndTabItem(); + } + if (ImGui::BeginTabItem("Spawn")) + { + ImGui::Spacing(); + ImGui::Columns(2, 0, false); + Ui::CheckboxWithHint("Spawn inside", &m_Spawner::m_bSpawnInside, "Spawn inside vehicle as driver"); + ImGui::NextColumn(); + Ui::CheckboxWithHint("Spawn aircraft in air", &m_Spawner::m_bSpawnInAir); + ImGui::Columns(1); - ImGui::Spacing(); + + ImGui::Spacing(); #ifdef GTASA - ImGui::SetNextItemWidth(ImGui::GetWindowContentRegionWidth() - 2.5); - ImGui::InputTextWithHint("##LicenseText", "License plate text", m_Spawner::m_nLicenseText, 9); + ImGui::SetNextItemWidth(ImGui::GetWindowContentRegionWidth() - 2.5); + ImGui::InputTextWithHint("##LicenseText", "License plate text", m_Spawner::m_nLicenseText, 9); - Ui::DrawImages(m_Spawner::m_VehData, SpawnVehicle, nullptr, - [](std::string str) { return GetNameFromModel(std::stoi(str)); }); + Ui::DrawImages(m_Spawner::m_VehData, SpawnVehicle, nullptr, + [](std::string str) + { + return GetNameFromModel(std::stoi(str)); + }); #else // GTA3 & GTAVC - Ui::DrawJSON(m_Spawner::m_VehData, SpawnVehicle, nullptr); + Ui::DrawJSON(m_Spawner::m_VehData, SpawnVehicle, nullptr); #endif - ImGui::EndTabItem(); - } + ImGui::EndTabItem(); + } - if (pPlayer->m_pVehicle && Command(hplayer)) - { - CVehicle *veh = FindPlayerPed()->m_pVehicle; - int hveh = CPools::GetVehicleRef(veh); - if (ImGui::BeginTabItem("Color")) - { + if (pPlayer->m_pVehicle && Command(hplayer)) + { + CVehicle* veh = FindPlayerPed()->m_pVehicle; + int hveh = CPools::GetVehicleRef(veh); + if (ImGui::BeginTabItem("Color")) + { #ifdef GTASA - Paint::UpdateNodeListRecursive(veh); + Paint::UpdateNodeListRecursive(veh); - ImGui::Spacing(); - if (ImGui::Button("Reset color", ImVec2(Ui::GetSize()))) - { - Paint::ResetNodeColor(veh, Paint::veh_nodes::selected); - SetHelpMessage("Color reset", false, false, false); - } - ImGui::Spacing(); + ImGui::Spacing(); + if (ImGui::Button("Reset color", ImVec2(Ui::GetSize()))) + { + Paint::ResetNodeColor(veh, Paint::veh_nodes::selected); + SetHelpMessage("Color reset", false, false, false); + } + ImGui::Spacing(); - Ui::ListBoxStr("Component", Paint::veh_nodes::names_vec, Paint::veh_nodes::selected); + Ui::ListBoxStr("Component", Paint::veh_nodes::names_vec, Paint::veh_nodes::selected); - if (ImGui::ColorEdit3("Color picker", m_Color::m_fColorPicker)) - { - uchar r = m_Color::m_fColorPicker[0] * 255; - uchar g = m_Color::m_fColorPicker[1] * 255; - uchar b = m_Color::m_fColorPicker[2] * 255; - Paint::SetNodeColor(veh, Paint::veh_nodes::selected, {r, g, b, 255}, m_Color::m_bMatFilter); - } + if (ImGui::ColorEdit3("Color picker", m_Color::m_fColorPicker)) + { + uchar r = m_Color::m_fColorPicker[0] * 255; + uchar g = m_Color::m_fColorPicker[1] * 255; + uchar b = m_Color::m_fColorPicker[2] * 255; + Paint::SetNodeColor(veh, Paint::veh_nodes::selected, { r, g, b, 255 }, m_Color::m_bMatFilter); + } #endif - ImGui::Spacing(); - ImGui::Columns(2, NULL, false); + ImGui::Spacing(); + ImGui::Columns(2, NULL, false); #ifdef GTASA - ImGui::Checkbox("Material filter", &m_Color::m_bMatFilter); - ImGui::RadioButton("Primary", &m_Color::m_nRadioButton, 1); - ImGui::RadioButton("Secondary", &m_Color::m_nRadioButton, 2); - ImGui::NextColumn(); - ImGui::NewLine(); - ImGui::RadioButton("Tertiary", &m_Color::m_nRadioButton, 3); - ImGui::RadioButton("Quaternary", &m_Color::m_nRadioButton, 4); + ImGui::Checkbox("Material filter", &m_Color::m_bMatFilter); + ImGui::RadioButton("Primary", &m_Color::m_nRadioButton, 1); + ImGui::RadioButton("Secondary", &m_Color::m_nRadioButton, 2); + ImGui::NextColumn(); + ImGui::NewLine(); + ImGui::RadioButton("Tertiary", &m_Color::m_nRadioButton, 3); + ImGui::RadioButton("Quaternary", &m_Color::m_nRadioButton, 4); #else // GTA3 & GTAVC - ImGui::RadioButton("Primary", &m_Color::m_nRadioButton, 1); - ImGui::NextColumn(); - ImGui::RadioButton("Secondary", &m_Color::m_nRadioButton, 2); -#endif - ImGui::Spacing(); - ImGui::Columns(1); - ImGui::Text("Select color preset:"); - ImGui::Spacing(); + ImGui::RadioButton("Primary", &m_Color::m_nRadioButton, 1); + ImGui::NextColumn(); + ImGui::RadioButton("Secondary", &m_Color::m_nRadioButton, 2); +#endif + ImGui::Spacing(); + ImGui::Columns(1); + ImGui::Text("Select color preset:"); + ImGui::Spacing(); - int count = (int)m_CarcolsColorData.size(); + int count = (int)m_CarcolsColorData.size(); - ImVec2 size = Ui::GetSize(); - int btnsInRow = ImGui::GetWindowContentRegionWidth() / (size.y * 2); - int btnSize = (ImGui::GetWindowContentRegionWidth() - - int(ImGuiStyleVar_ItemSpacing) * (btnsInRow - 0.6 * btnsInRow)) / - btnsInRow; + ImVec2 size = Ui::GetSize(); + int btnsInRow = ImGui::GetWindowContentRegionWidth() / (size.y * 2); + int btnSize = (ImGui::GetWindowContentRegionWidth() - int(ImGuiStyleVar_ItemSpacing) * (btnsInRow - + 0.6 * btnsInRow)) / btnsInRow; - ImGui::BeginChild("Colorss"); + ImGui::BeginChild("Colorss"); - for (int colorId = 0; colorId < count; ++colorId) - { - if (Ui::ColorButton(colorId, m_CarcolsColorData[colorId], ImVec2(btnSize, btnSize))) - { - *(uint8_replacement *)(int(veh) + BY_GAME(0x433, 0x19F, 0x19B) + m_Color::m_nRadioButton) = - colorId; - } + for (int colorId = 0; colorId < count; ++colorId) + { + if (Ui::ColorButton(colorId, m_CarcolsColorData[colorId], ImVec2(btnSize, btnSize))) + { + *(uint8_replacement*)(int(veh) + BY_GAME(0x433, 0x19F, 0x19B) + m_Color::m_nRadioButton) = colorId; + } - if ((colorId + 1) % btnsInRow != 0) - { - ImGui::SameLine(0.0, 4.0); - } - } + if ((colorId + 1) % btnsInRow != 0) + { + ImGui::SameLine(0.0, 4.0); + } + } - ImGui::EndChild(); - ImGui::EndTabItem(); - } + ImGui::EndChild(); + ImGui::EndTabItem(); + } #ifdef GTASA - if (gRenderer != Render_DirectX11) - { - if (ImGui::BeginTabItem("Neons")) - { - ImGui::Spacing(); - if (ImGui::Button("Remove neon", ImVec2(Ui::GetSize()))) - { - RemoveNeon(veh); - SetHelpMessage("Neon removed", false, false, false); - } + if (gRenderer != Render_DirectX11) + { + if (ImGui::BeginTabItem("Neons")) + { + ImGui::Spacing(); + if (ImGui::Button("Remove neon", ImVec2(Ui::GetSize()))) + { + RemoveNeon(veh); + SetHelpMessage("Neon removed", false, false, false); + } - ImGui::Spacing(); - ImGui::Columns(2, NULL, false); + ImGui::Spacing(); + ImGui::Columns(2, NULL, false); - bool pulsing = IsPulsingEnabled(veh); - if (Ui::CheckboxWithHint("Pulsing neons", &pulsing)) - SetPulsing(veh, pulsing); + bool pulsing = IsPulsingEnabled(veh); + if (Ui::CheckboxWithHint("Pulsing neons", &pulsing)) + SetPulsing(veh, pulsing); - Ui::CheckboxWithHint("Rainbow neons", &m_Neon::m_bRainbowEffect, "Rainbow effect to neon lights"); - ImGui::NextColumn(); - Ui::CheckboxWithHint("Traffic neons", &m_Neon::m_bApplyOnTraffic, - "Adds neon lights to traffic vehicles.\n\ + Ui::CheckboxWithHint("Rainbow neons", &m_Neon::m_bRainbowEffect, "Rainbow effect to neon lights"); + ImGui::NextColumn(); + Ui::CheckboxWithHint("Traffic neons", &m_Neon::m_bApplyOnTraffic, "Adds neon lights to traffic vehicles.\n\ Only some vehicles will have them."); - ImGui::Columns(1); + ImGui::Columns(1); - ImGui::Spacing(); + ImGui::Spacing(); - if (ImGui::ColorEdit3("Color picker", m_Neon::m_fColorPicker)) - InstallNeon(veh, m_Neon::m_fColorPicker[0] * 255, m_Neon::m_fColorPicker[1] * 255, - m_Neon::m_fColorPicker[2] * 255); + if (ImGui::ColorEdit3("Color picker", m_Neon::m_fColorPicker)) + InstallNeon(veh, m_Neon::m_fColorPicker[0] * 255, m_Neon::m_fColorPicker[1] * 255, + m_Neon::m_fColorPicker[2] * 255); - ImGui::Spacing(); - ImGui::Text("Select neon preset:"); + ImGui::Spacing(); + ImGui::Text("Select neon preset:"); - int count = (int)m_CarcolsColorData.size(); - ImVec2 size = Ui::GetSize(); - int btnsInRow = ImGui::GetWindowContentRegionWidth() / (size.y * 2); - int btnSize = (ImGui::GetWindowContentRegionWidth() - - int(ImGuiStyleVar_ItemSpacing) * (btnsInRow - 0.6 * btnsInRow)) / - btnsInRow; + int count = (int)m_CarcolsColorData.size(); + ImVec2 size = Ui::GetSize(); + int btnsInRow = ImGui::GetWindowContentRegionWidth() / (size.y * 2); + int btnSize = (ImGui::GetWindowContentRegionWidth() - int(ImGuiStyleVar_ItemSpacing) * (btnsInRow - + 0.6 * btnsInRow)) / btnsInRow; - ImGui::BeginChild("Neonss"); + ImGui::BeginChild("Neonss"); - for (int color_id = 0; color_id < count; ++color_id) - { - if (Ui::ColorButton(color_id, m_CarcolsColorData[color_id], ImVec2(btnSize, btnSize))) - { - std::vector &color = m_CarcolsColorData[color_id]; - InstallNeon(veh, color[0] * 255, color[1] * 255, color[2] * 255); - } + for (int color_id = 0; color_id < count; ++color_id) + { + if (Ui::ColorButton(color_id, m_CarcolsColorData[color_id], ImVec2(btnSize, btnSize))) + { + std::vector& color = m_CarcolsColorData[color_id]; + InstallNeon(veh, color[0] * 255, color[1] * 255, color[2] * 255); + } - if ((color_id + 1) % btnsInRow != 0) - ImGui::SameLine(0.0, 4.0); - } + if ((color_id + 1) % btnsInRow != 0) + ImGui::SameLine(0.0, 4.0); + } - ImGui::EndChild(); - ImGui::EndTabItem(); - } - if (ImGui::BeginTabItem("Textures")) - { - Paint::UpdateNodeListRecursive(veh); + ImGui::EndChild(); + ImGui::EndTabItem(); + } + if (ImGui::BeginTabItem("Textures")) + { + Paint::UpdateNodeListRecursive(veh); - ImGui::Spacing(); - if (ImGui::Button("Reset texture", ImVec2(Ui::GetSize()))) - { - Paint::ResetNodeTexture(veh, Paint::veh_nodes::selected); - SetHelpMessage("Texture reset", false, false, false); - } - ImGui::Spacing(); + ImGui::Spacing(); + if (ImGui::Button("Reset texture", ImVec2(Ui::GetSize()))) + { + Paint::ResetNodeTexture(veh, Paint::veh_nodes::selected); + SetHelpMessage("Texture reset", false, false, false); + } + ImGui::Spacing(); - Ui::ListBoxStr("Component", Paint::veh_nodes::names_vec, Paint::veh_nodes::selected); - ImGui::Spacing(); + Ui::ListBoxStr("Component", Paint::veh_nodes::names_vec, Paint::veh_nodes::selected); + ImGui::Spacing(); - int maxpjob, curpjob; - Command(hveh, &maxpjob); + int maxpjob, curpjob; + Command(hveh, &maxpjob); - if (maxpjob > 0) - { - Command(hveh, &curpjob); + if (maxpjob > 0) + { + Command(hveh, &curpjob); - if (ImGui::InputInt("Paintjob", &curpjob)) - { - if (curpjob > maxpjob) - curpjob = -1; - if (curpjob < -1) - curpjob = maxpjob - 1; + if (ImGui::InputInt("Paintjob", &curpjob)) + { + if (curpjob > maxpjob) + curpjob = -1; + if (curpjob < -1) + curpjob = maxpjob - 1; - Command(hveh, curpjob); - } + Command(hveh, curpjob); + } - ImGui::Spacing(); - } + ImGui::Spacing(); + } - ImGui::Spacing(); - ImGui::SameLine(); - ImGui::Checkbox("Material filter", &m_Color::m_bMatFilter); - ImGui::Spacing(); - Ui::DrawImages( - m_TextureData, - [](std::string &str) { - Paint::SetNodeTexture(FindPlayerPed()->m_pVehicle, Paint::veh_nodes::selected, str, - m_Color::m_bMatFilter); - }, - nullptr, [](std::string &str) { return str; }); + ImGui::Spacing(); + ImGui::SameLine(); + ImGui::Checkbox("Material filter", &m_Color::m_bMatFilter); + ImGui::Spacing(); + Ui::DrawImages(m_TextureData, + [](std::string& str) + { + Paint::SetNodeTexture(FindPlayerPed()->m_pVehicle, Paint::veh_nodes::selected, str, + m_Color::m_bMatFilter); + }, + nullptr, + [](std::string& str) + { + return str; + }); - ImGui::EndTabItem(); - } - } - if (ImGui::BeginTabItem("Tune")) - { - ImGui::Spacing(); - Ui::DrawImages( - m_TuneData, [](std::string &str) { AddComponent(str); }, - [](std::string &str) { RemoveComponent(str); }, [](std::string &str) { return str; }, - [pPlayer](std::string &str) { - return ((bool (*)(int, CVehicle *))0x49B010)(std::stoi(str), pPlayer->m_pVehicle); - }); + ImGui::EndTabItem(); + } + } + if (ImGui::BeginTabItem("Tune")) + { + ImGui::Spacing(); + Ui::DrawImages(m_TuneData, + [](std::string& str) { AddComponent(str); }, + [](std::string& str) { RemoveComponent(str); }, + [](std::string& str) { return str; }, + [pPlayer](std::string& str) + { + return ((bool(*)(int, CVehicle*))0x49B010)(std::stoi(str), pPlayer->m_pVehicle); + } + ); - ImGui::EndTabItem(); - } - if (ImGui::BeginTabItem("Handling")) - { - ImGui::Spacing(); + ImGui::EndTabItem(); + } + if (ImGui::BeginTabItem("Handling")) + { + ImGui::Spacing(); - CBaseModelInfo *info = CModelInfo::GetModelInfo(pPlayer->m_pVehicle->m_nModelIndex); - int pHandling = patch::Get((int)info + 0x4A, false); - pHandling *= 0xE0; - pHandling += 0xC2B9DC; + CBaseModelInfo* info = CModelInfo::GetModelInfo(pPlayer->m_pVehicle->m_nModelIndex); + int pHandling = patch::Get((int)info + 0x4A, false); + pHandling *= 0xE0; + pHandling += 0xC2B9DC; - if (ImGui::Button("Reset handling", ImVec2(Ui::GetSize(3)))) - { - gHandlingDataMgr.LoadHandlingData(); - SetHelpMessage("Handling reset", false, false, false); - } + if (ImGui::Button("Reset handling", ImVec2(Ui::GetSize(3)))) + { + gHandlingDataMgr.LoadHandlingData(); + SetHelpMessage("Handling reset", false, false, false); + } - ImGui::SameLine(); + ImGui::SameLine(); - if (ImGui::Button("Save to file", ImVec2(Ui::GetSize(3)))) - { - FileHandler::GenerateHandlingFile(pHandling, m_VehicleIDE); - SetHelpMessage("Handling saved", false, false, false); - } + if (ImGui::Button("Save to file", ImVec2(Ui::GetSize(3)))) + { + FileHandler::GenerateHandlingFile(pHandling, m_VehicleIDE); + SetHelpMessage("Handling saved", false, false, false); + } - ImGui::SameLine(); + ImGui::SameLine(); - if (ImGui::Button("Read more", ImVec2(Ui::GetSize(3)))) - ShellExecute(NULL, "open", "https://projectcerbera.com/gta/sa/tutorials/handling", NULL, NULL, - SW_SHOWNORMAL); + if (ImGui::Button("Read more", ImVec2(Ui::GetSize(3)))) + ShellExecute(NULL, "open", "https://projectcerbera.com/gta/sa/tutorials/handling", NULL, NULL, + SW_SHOWNORMAL); - ImGui::Spacing(); + ImGui::Spacing(); - ImGui::BeginChild("HandlingChild"); + ImGui::BeginChild("HandlingChild"); - static std::vector abs{{"On", 1}, {"Off", 0}}; - Ui::EditRadioButtonAddressEx("Abs", pHandling + 0x9C, abs); + static std::vector abs{ {"On", 1}, {"Off", 0} }; + Ui::EditRadioButtonAddressEx("Abs", pHandling + 0x9C, abs); - Ui::EditFloat("Anti dive multiplier", pHandling + 0xC4, 0.0f, 0.0f, 1.0f); - Ui::EditFloat("Brake bias", pHandling + 0x98, 0.0f, 0.0f, 1.0f); - Ui::EditFloat("Brake deceleration", pHandling + 0x94, 0.0f, 0.0f, 20.0f, 2500.0f); - Ui::EditFloat("Centre of mass X", pHandling + 0x14, -10.0f, -10.0f, 10.0f); - Ui::EditFloat("Centre of mass Y", pHandling + 0x18, -10.0f, -10.0f, 10.0f); - Ui::EditFloat("Centre of mass Z", pHandling + 0x1C, -10.0f, -10.0f, 10.0f); - Ui::EditFloat("Collision damage multiplier", pHandling + 0xC8, 0.0f, 0.0f, 1.0f, 0.3381f); - Ui::EditFloat("Damping level", pHandling + 0xB0, -10.0f, -10.0f, 10.0f); // test later - Ui::EditFloat("Drag mult", pHandling + 0x10, 0.0f, 0.0f, 30.0f); + Ui::EditFloat("Anti dive multiplier", pHandling + 0xC4, 0.0f, 0.0f, 1.0f); + Ui::EditFloat("Brake bias", pHandling + 0x98, 0.0f, 0.0f, 1.0f); + Ui::EditFloat("Brake deceleration", pHandling + 0x94, 0.0f, 0.0f, 20.0f, 2500.0f); + Ui::EditFloat("Centre of mass X", pHandling + 0x14, -10.0f, -10.0f, 10.0f); + Ui::EditFloat("Centre of mass Y", pHandling + 0x18, -10.0f, -10.0f, 10.0f); + Ui::EditFloat("Centre of mass Z", pHandling + 0x1C, -10.0f, -10.0f, 10.0f); + Ui::EditFloat("Collision damage multiplier", pHandling + 0xC8, 0.0f, 0.0f, 1.0f, 0.3381f); + Ui::EditFloat("Damping level", pHandling + 0xB0, -10.0f, -10.0f, 10.0f); // test later + Ui::EditFloat("Drag mult", pHandling + 0x10, 0.0f, 0.0f, 30.0f); - static std::vector drive_type{ - {"Front wheel drive", 70}, {"Rear wheel drive", 82}, {"Four wheel drive", 52}}; - Ui::EditRadioButtonAddressEx("Drive type", pHandling + 0x74, drive_type); + static std::vector drive_type{ + {"Front wheel drive", 70}, {"Rear wheel drive", 82}, {"Four wheel drive", 52} + }; + Ui::EditRadioButtonAddressEx("Drive type", pHandling + 0x74, drive_type); - Ui::EditFloat("Engine acceleration", pHandling + 0x7C, 0.0f, 0.0f, 49.0f, 12500.0f); - Ui::EditFloat("Engine inertia", pHandling + 0x80, 0.1f, 0.1f, 400.0f); + Ui::EditFloat("Engine acceleration", pHandling + 0x7C, 0.0f, 0.0f, 49.0f, 12500.0f); + Ui::EditFloat("Engine inertia", pHandling + 0x80, 0.1f, 0.1f, 400.0f); - static std::vector engine_type{{"Petrol", 80}, {"Diseal", 68}, {"Electric", 69}}; - Ui::EditRadioButtonAddressEx("Engine type", pHandling + 0x75, engine_type); + static std::vector engine_type{ {"Petrol", 80}, {"Diseal", 68}, {"Electric", 69} }; + Ui::EditRadioButtonAddressEx("Engine type", pHandling + 0x75, engine_type); - std::vector front_lights{{"Long", 0}, {"Small", 1}, {"Big", 2}, {"Tall", 3}}; - Ui::EditRadioButtonAddressEx("Front lights", pHandling + 0xDC, front_lights); + std::vector front_lights{ {"Long", 0}, {"Small", 1}, {"Big", 2}, {"Tall", 3} }; + Ui::EditRadioButtonAddressEx("Front lights", pHandling + 0xDC, front_lights); - Ui::EditFloat("Force level", pHandling + 0xAC, -10.0f, -10.0f, 10.0f); // test later + Ui::EditFloat("Force level", pHandling + 0xAC, -10.0f, -10.0f, 10.0f); // test later - Ui::EditBits("Handling flags", pHandling + 0xD0, m_HandlingFlagNames); + Ui::EditBits("Handling flags", pHandling + 0xD0, m_HandlingFlagNames); - Ui::EditFloat("High speed damping", pHandling + 0xB4, -10.0f, -10.0f, 10.0f); // test later - Ui::EditFloat("Lower limit", pHandling + 0xBC, -10.0f, -10.0f, 10.0f); // test later - Ui::EditFloat("Mass", pHandling + 0x4, 1.0f, 1.0f, 50000.0f); + Ui::EditFloat("High speed damping", pHandling + 0xB4, -10.0f, -10.0f, 10.0f); // test later + Ui::EditFloat("Lower limit", pHandling + 0xBC, -10.0f, -10.0f, 10.0f); // test later + Ui::EditFloat("Mass", pHandling + 0x4, 1.0f, 1.0f, 50000.0f); - /// fcommon.UpdateAddress({ name = 'Max velocity',address = phandling + 0x84 ,size = 4,min = 0,max = - /// 2,is_float = true,cvalue = 0.01 , save = false }) + ///fcommon.UpdateAddress({ name = 'Max velocity',address = phandling + 0x84 ,size = 4,min = 0,max = 2,is_float = true,cvalue = 0.01 , save = false }) - Ui::EditBits("Model flags", pHandling + 0xCC, m_ModelFlagNames); + Ui::EditBits("Model flags", pHandling + 0xCC, m_ModelFlagNames); - Ui::EditAddress("Monetary value", pHandling + 0xD8, 1, 1, 100000); - Ui::EditAddress("Number of gears", pHandling + 0x76, 1, 1, 10); - Ui::EditAddress("Percent submerged", pHandling + 0x20, 10, 10, 120); + Ui::EditAddress("Monetary value", pHandling + 0xD8, 1, 1, 100000); + Ui::EditAddress("Number of gears", pHandling + 0x76, 1, 1, 10); + Ui::EditAddress("Percent submerged", pHandling + 0x20, 10, 10, 120); - static std::vector rear_lights{{"Long", 0}, {"Small", 1}, {"Big", 2}, {"Tall", 3}}; - Ui::EditRadioButtonAddressEx("Rear lights", pHandling + 0xDD, rear_lights); + static std::vector rear_lights{ {"Long", 0}, {"Small", 1}, {"Big", 2}, {"Tall", 3} }; + Ui::EditRadioButtonAddressEx("Rear lights", pHandling + 0xDD, rear_lights); - Ui::EditFloat("Seat offset distance", pHandling + 0xD4, 0.0f, 0.0f, 1.0f); - Ui::EditFloat("Steering lock", pHandling + 0xA0, 10.0f, 10.0f, 50.0f); - Ui::EditFloat("Suspension bias", pHandling + 0xC0, 0.0f, 0.0f, 1.0f); - Ui::EditFloat("Traction bias", pHandling + 0xA8, 0.0f, 0.0f, 1.0f); - Ui::EditFloat("Traction loss", pHandling + 0xA4, 0.0f, 0.0f, 1.0f); - Ui::EditFloat("Traction multiplier", pHandling + 0x28, 0.5f, 0.5f, 2.0f); - Ui::EditFloat("Turn mass", pHandling + 0xC, 20.0f, 20.0f, 1000.0f); // test later - Ui::EditFloat("Upper limit", pHandling + 0xB8, -1.0f, -1.0f, 1.0f); - Ui::EditAddress("Vehicle anim group", pHandling + 0xDE, 0, 0, 20); + Ui::EditFloat("Seat offset distance", pHandling + 0xD4, 0.0f, 0.0f, 1.0f); + Ui::EditFloat("Steering lock", pHandling + 0xA0, 10.0f, 10.0f, 50.0f); + Ui::EditFloat("Suspension bias", pHandling + 0xC0, 0.0f, 0.0f, 1.0f); + Ui::EditFloat("Traction bias", pHandling + 0xA8, 0.0f, 0.0f, 1.0f); + Ui::EditFloat("Traction loss", pHandling + 0xA4, 0.0f, 0.0f, 1.0f); + Ui::EditFloat("Traction multiplier", pHandling + 0x28, 0.5f, 0.5f, 2.0f); + Ui::EditFloat("Turn mass", pHandling + 0xC, 20.0f, 20.0f, 1000.0f); // test later + Ui::EditFloat("Upper limit", pHandling + 0xB8, -1.0f, -1.0f, 1.0f); + Ui::EditAddress("Vehicle anim group", pHandling + 0xDE, 0, 0, 20); - ImGui::EndChild(); + ImGui::EndChild(); - ImGui::EndTabItem(); - } + ImGui::EndTabItem(); + } #endif - } - ImGui::EndTabBar(); - } + } + ImGui::EndTabBar(); + } } \ No newline at end of file diff --git a/src/vehicle.h b/src/vehicle.h index 5410f29..11993bf 100644 --- a/src/vehicle.h +++ b/src/vehicle.h @@ -12,119 +12,98 @@ class Vehicle #endif { private: - static inline bool m_bBikeFly; - static inline bool m_bDontFallBike; - static inline bool m_bVehHeavy; - static inline bool m_bVehWatertight; - static inline bool m_bNoDamage; - static inline int m_nDoorMenuButton; - static inline std::string m_DoorNames[6] = { - "Hood", "Boot", "Front left door", "Front right door", "Rear left door", "Rear right door"}; - static inline int m_nVehRemoveRadius; - static inline bool m_bLockSpeed; - static inline float m_fLockSpeed; - static inline std::vector> m_CarcolsColorData; - struct m_Color - { - static inline bool m_bMatFilter = true; - static inline int m_nRadioButton = 1; - static inline float m_fColorPicker[3]{0, 0, 0}; - }; - + static inline bool m_bBikeFly; + static inline bool m_bDontFallBike; + static inline bool m_bVehHeavy; + static inline bool m_bVehWatertight; + static inline bool m_bNoDamage; + static inline int m_nDoorMenuButton; + static inline std::string m_DoorNames[6] = + { "Hood", "Boot", "Front left door", "Front right door", "Rear left door", "Rear right door" }; + static inline int m_nVehRemoveRadius; + static inline bool m_bLockSpeed; + static inline float m_fLockSpeed; + static inline std::vector> m_CarcolsColorData; + struct m_Color + { + static inline bool m_bMatFilter = true; + static inline int m_nRadioButton = 1; + static inline float m_fColorPicker[3]{ 0, 0, 0 }; + }; + #ifdef GTASA - static inline bool m_bDisableColDetection; - static inline std::map m_VehicleIDE; - struct m_Neon - { - static inline float m_fColorPicker[3]{0, 0, 0}; - static inline bool m_bRainbowEffect; - static inline uint m_nRainbowTimer; - static inline bool m_bApplyOnTraffic; - static inline uint m_bTrafficTimer; - }; - static inline ResourceStore m_TuneData{"components", eResourceType::TYPE_IMAGE, ImVec2(100, 80)}; -#endif + static inline bool m_bDisableColDetection; + static inline std::map m_VehicleIDE; + struct m_Neon + { + static inline float m_fColorPicker[3]{ 0, 0, 0 }; + static inline bool m_bRainbowEffect; + static inline uint m_nRainbowTimer; + static inline bool m_bApplyOnTraffic; + static inline uint m_bTrafficTimer; + }; + static inline ResourceStore m_TuneData { "components", eResourceType::TYPE_IMAGE, ImVec2(100, 80) }; +#endif - struct m_Spawner - { + struct m_Spawner + { #ifdef GTASA - static inline ResourceStore m_VehData{"vehicles", eResourceType::TYPE_IMAGE, ImVec2(100, 75)}; + static inline ResourceStore m_VehData { "vehicles", eResourceType::TYPE_IMAGE, ImVec2(100, 75)}; #else // GTA3 & GTAVC - static inline ResourceStore m_VehData{"vehicle", eResourceType::TYPE_TEXT}; + static inline ResourceStore m_VehData{"vehicle", eResourceType::TYPE_TEXT}; #endif - static inline bool m_bSpawnInside = true; - static inline bool m_bSpawnInAir = true; - static inline char m_nLicenseText[9]; - }; - struct m_UnlimitedNitro - { - static inline bool m_bEnabled; - static inline bool m_bCompAdded; - }; + static inline bool m_bSpawnInside = true; + static inline bool m_bSpawnInAir = true; + static inline char m_nLicenseText[9]; + }; + struct m_UnlimitedNitro + { + static inline bool m_bEnabled; + static inline bool m_bCompAdded; + }; -#ifdef GTASA - static inline std::vector(m_HandlingFlagNames) = // 32 flags - {"1G_BOOST", "2G_BOOST", "NPC_ANTI_ROLL", "NPC_NEUTRAL_HANDL", - "NO_HANDBRAKE", "STEER_REARWHEELS", "HB_REARWHEEL_STEER", "ALT_STEER_OPT", - "WHEEL_F_NARROW2", "WHEEL_F_NARROW", "WHEEL_F_WIDE", "WHEEL_F_WIDE2", - "WHEEL_R_NARROW2", "WHEEL_R_NARROW", "WHEEL_R_WIDE", "WHEEL_R_WIDE2", - "HYDRAULIC_GEOM", "HYDRAULIC_INST", "HYDRAULIC_NONE", "NOS_INST", - "OFFROAD_ABILITY", "OFFROAD_ABILITY2", "HALOGEN_LIGHTS", "PROC_REARWHEEL_1ST", - "USE_MAXSP_LIMIT", "LOW_RIDER", "STREET_RACER", "SWINGING_CHASSIS", - "Unused 1", "Unused 2", "Unused 3", "Unused 4"}; +#ifdef GTASA + static inline std::vector(m_HandlingFlagNames) = // 32 flags + { + "1G_BOOST", "2G_BOOST", "NPC_ANTI_ROLL", "NPC_NEUTRAL_HANDL", "NO_HANDBRAKE", "STEER_REARWHEELS", + "HB_REARWHEEL_STEER", "ALT_STEER_OPT", + "WHEEL_F_NARROW2", "WHEEL_F_NARROW", "WHEEL_F_WIDE", "WHEEL_F_WIDE2", "WHEEL_R_NARROW2", "WHEEL_R_NARROW", + "WHEEL_R_WIDE", "WHEEL_R_WIDE2", + "HYDRAULIC_GEOM", "HYDRAULIC_INST", "HYDRAULIC_NONE", "NOS_INST", "OFFROAD_ABILITY", "OFFROAD_ABILITY2", + "HALOGEN_LIGHTS", "PROC_REARWHEEL_1ST", + "USE_MAXSP_LIMIT", "LOW_RIDER", "STREET_RACER", "SWINGING_CHASSIS", "Unused 1", "Unused 2", "Unused 3", + "Unused 4" + }; - static inline std::vector(m_ModelFlagNames) = // 32 flags - {"IS_VAN", - "IS_BUS", - "IS_LOW", - "IS_BIG", - "REVERSE_BONNET", - "HANGING_BOOT", - "TAILGATE_BOOT", - "NOSWING_BOOT", - "NO_DOORS", - "TANDEM_SEATS", - "SIT_IN_BOAT", - "CONVERTIBLE", - "NO_EXHAUST", - "DOUBLE_EXHAUST", - "NO1FPS_LOOK_BEHIND", - "FORCE_DOOR_CHECK", - "AXLE_F_NOTILT", - "AXLE_F_SOLID", - "AXLE_F_MCPHERSON", - "AXLE_F_REVERSE", - "AXLE_R_NOTILT", - "AXLE_R_SOLID", - "AXLE_R_MCPHERSON", - "AXLE_R_REVERSE", - "IS_BIKE", - "IS_HELI", - "IS_PLANE", - "IS_BOAT", - "BOUNCE_PANELS", - "DOUBLE_RWHEELS", - "FORCE_GROUND_CLEARANCE", - "IS_HATCHBAC1K"}; + static inline std::vector(m_ModelFlagNames) = // 32 flags + { + "IS_VAN", "IS_BUS", "IS_LOW", "IS_BIG", "REVERSE_BONNET", "HANGING_BOOT", "TAILGATE_BOOT", "NOSWING_BOOT", + "NO_DOORS", "TANDEM_SEATS", + "SIT_IN_BOAT", "CONVERTIBLE", "NO_EXHAUST", "DOUBLE_EXHAUST", "NO1FPS_LOOK_BEHIND", "FORCE_DOOR_CHECK", + "AXLE_F_NOTILT", "AXLE_F_SOLID", "AXLE_F_MCPHERSON", + "AXLE_F_REVERSE", "AXLE_R_NOTILT", "AXLE_R_SOLID", "AXLE_R_MCPHERSON", "AXLE_R_REVERSE", "IS_BIKE", "IS_HELI", + "IS_PLANE", "IS_BOAT", "BOUNCE_PANELS", + "DOUBLE_RWHEELS", "FORCE_GROUND_CLEARANCE", "IS_HATCHBAC1K" + }; #endif private: - static void FixVehicle(CVehicle *pVeh); + static void FixVehicle(CVehicle *pVeh); #ifdef GTASA - static void AddComponent(const std::string &component, bool display_message = true); - static void RemoveComponent(const std::string &component, bool display_message = true); - static int GetRandomTrainIdForModel(int model); - static void GenerateHandlingDataFile(int phandling); + static void AddComponent(const std::string& component, bool display_message = true); + static void RemoveComponent(const std::string& component, bool display_message = true); + static int GetRandomTrainIdForModel(int model); + static void GenerateHandlingDataFile(int phandling); #endif public: #ifdef GTASA - static void SpawnVehicle(std::string &name); + static void SpawnVehicle(std::string& name); #else // GTA3 & GTAVC - static void SpawnVehicle(std::string &rootkey, std::string &vehName, std::string &model); + static void SpawnVehicle(std::string& rootkey, std::string& vehName, std::string& model); #endif - static std::string GetNameFromModel(int model); - static int GetModelFromName(const char *name); - static void Draw(); - Vehicle(); + static std::string GetNameFromModel(int model); + static int GetModelFromName(const char* name); + static void Draw(); + Vehicle(); }; diff --git a/src/visual.cpp b/src/visual.cpp index cc5c3b4..796cc51 100644 --- a/src/visual.cpp +++ b/src/visual.cpp @@ -1,198 +1,187 @@ -#include "visual.h" -#include "game.h" #include "pch.h" -#include "timecycle.h" +#include "visual.h" #include "ui.h" #include "util.h" +#include "game.h" +#include "timecycle.h" #ifdef GTASA #include "CHudColours.h" #endif +#ifdef GTASA +#define TOTAL_WEATHERS 23 +#elif GTAVC +#define TOTAL_WEATHERS 7 +#else // GTA3 +#define TOTAL_WEATHERS 4 +#endif + Visual::Visual() { #ifdef GTASA - if (GetModuleHandle("timecycle24.asi")) - { - m_nTimecycHour = 24; - } + if (GetModuleHandle("timecycle24.asi")) + { + m_nTimecycHour = 24; + } #endif - Events::processScriptsEvent += [] { - // TODO: Needs improvement - static short m_nBacWeatherType; - if (m_bLockWeather) - { - CWeather::OldWeatherType = m_nBacWeatherType; - CWeather::NewWeatherType = m_nBacWeatherType; - } - else - { - m_nBacWeatherType = CWeather::OldWeatherType; - } - }; + Events::processScriptsEvent += [] + { + // TODO: Needs improvement + static short m_nBacWeatherType; + if (m_bLockWeather) + { + CWeather::OldWeatherType = m_nBacWeatherType; + CWeather::NewWeatherType = m_nBacWeatherType; + } + else + { + m_nBacWeatherType = CWeather::OldWeatherType; + } + }; } -template int GetTCVal(T *addr, int index) +template +int GetTCVal(T* addr, int index) { #ifdef GTASA - T *arr = static_cast(patch::GetPointer(int(addr))); -#elif GTAVC - T *arr = static_cast(addr); + T* arr = static_cast(patch::GetPointer(int(addr))); +#else // GTA3 & GTAVC + T* arr = static_cast(addr); #endif - return static_cast(arr[index]); + return static_cast(arr[index]); } void Visual::GenerateTimecycFile() { #ifdef GTASA - std::ofstream file; - std::string buffer; - if (m_nTimecycHour == 24) - { - file = std::ofstream("timecyc_24h.dat"); - } - else - { - file = std::ofstream("timecyc.dat"); - } + std::ofstream file; + std::string buffer; + if (m_nTimecycHour == 24) + { + file = std::ofstream("timecyc_24h.dat"); + } + else + { + file = std::ofstream("timecyc.dat"); + } - for (uint i = 0; i < m_WeatherNames.size(); ++i) - { - buffer += "\n// " + m_WeatherNames[i] + "\n"; - buffer += "// Amb Amb Obj Dir Sky top Sky " - "bot SunCore SunCorona SunSz SprSz SprBght Shdw " - "LightShd PoleShd FarClp FogSt LightOnGround LowCloudsRGB BottomCloudRGB " - "WaterRGBA ARGB1 ARGB2 CloudAlpha IntensityLimit " - " WaterFogAlpha DirMult"; + for (uint i = 0; i < m_WeatherNames.size(); ++i) + { + buffer += "\n// " + m_WeatherNames[i] + "\n"; + buffer += "// Amb Amb Obj Dir Sky top Sky bot SunCore SunCorona SunSz SprSz SprBght Shdw LightShd PoleShd FarClp FogSt LightOnGround LowCloudsRGB BottomCloudRGB WaterRGBA ARGB1 ARGB2 CloudAlpha IntensityLimit WaterFogAlpha DirMult"; - file << buffer << std::endl; - for (int j = 0; j < m_nTimecycHour; ++j) - { - if (m_nTimecycHour == 24) - { - if (j < 12) - { - buffer = std::format("// {} AM\n", j); - } - else - { - buffer = std::format("// {} PM\n", j); - } - } - else - { - if (j == 0) - buffer = "// Midnight\n"; - if (j == 1) - buffer = "// 5 AM\n"; - if (j == 2) - buffer = "// 6 AM\n"; - if (j == 3) - buffer = "// 7 AM\n"; - if (j == 4) - buffer = "// Midday\n"; - if (j == 5) - buffer = "// 7 PM\n"; - if (j == 6) - buffer = "// 8 PM\n"; - if (j == 7) - buffer = "// 10 PM\n"; - } + file << buffer << std::endl; + for (int j = 0; j < m_nTimecycHour; ++j) + { + if (m_nTimecycHour == 24) + { + if (j < 12) + { + buffer = std::format("// {} AM\n", j); + } + else + { + buffer = std::format("// {} PM\n", j); + } + } + else + { + if (j == 0) buffer = "// Midnight\n"; + if (j == 1) buffer = "// 5 AM\n"; + if (j == 2) buffer = "// 6 AM\n"; + if (j == 3) buffer = "// 7 AM\n"; + if (j == 4) buffer = "// Midday\n"; + if (j == 5) buffer = "// 7 PM\n"; + if (j == 6) buffer = "// 8 PM\n"; + if (j == 7) buffer = "// 10 PM\n"; + } - int val = 23 * j + i; + int val = 23 * j + i; - buffer += std::format( - "{} {} {}\t{} {} {}\t255 255 255\t{} {} {}\t{} {} {}\t{} {} {}\t{} {} {}\t{} {} {}\t{} {} {}\t{} {} " - "{}\t{} {} {}\t{} {} {}\t{} {} {} {}\t{} {} {} {}\t{} {} {} {}\t{} {} {} {}", - GetTCVal(m_nAmbientRed, val), GetTCVal(m_nAmbientGreen, val), GetTCVal(m_nAmbientBlue, val), - GetTCVal(m_nAmbientRed_Obj, val), GetTCVal(m_nAmbientGreen_Obj, val), GetTCVal(m_nAmbientBlue_Obj, val), - GetTCVal(m_nSkyTopRed, val), GetTCVal(m_nSkyTopGreen, val), GetTCVal(m_nSkyTopBlue, val), - GetTCVal(m_nSkyBottomRed, val), GetTCVal(m_nSkyBottomGreen, val), GetTCVal(m_nSkyBottomBlue, val), - GetTCVal(m_nSunCoreRed, val), GetTCVal(m_nSunCoreGreen, val), GetTCVal(m_nSunCoreBlue, val), - GetTCVal(m_nSunCoronaRed, val), GetTCVal(m_nSunCoronaGreen, val), GetTCVal(m_nSunCoronaBlue, val), - GetTCVal(m_fSunSize, val) / 10.0f, GetTCVal(m_fSpriteSize, val) / 10.0f, - GetTCVal(m_fSpriteBrightness, val) / 10.0f, GetTCVal(m_nShadowStrength, val), - GetTCVal(m_nLightShadowStrength, val), GetTCVal(m_nPoleShadowStrength, val), GetTCVal(m_fFarClip, val), - GetTCVal(m_fFogStart, val), GetTCVal(m_fLightsOnGroundBrightness, val) / 10.0f, - GetTCVal(m_nLowCloudsRed, val), GetTCVal(m_nLowCloudsGreen, val), GetTCVal(m_nLowCloudsBlue, val), - GetTCVal(m_nSkyBottomRed, val), GetTCVal(m_nSkyBottomGreen, val), GetTCVal(m_nSkyBottomBlue, val), - GetTCVal(m_fWaterRed, val), GetTCVal(m_fWaterGreen, val), GetTCVal(m_fWaterBlue, val), - GetTCVal(m_fWaterAlpha, val), GetTCVal(m_fPostFx1Red, val), GetTCVal(m_fPostFx1Green, val), - GetTCVal(m_fPostFx1Blue, val), GetTCVal(m_fPostFx1Alpha, val), GetTCVal(m_fPostFx2Red, val), - GetTCVal(m_fPostFx2Green, val), GetTCVal(m_fPostFx2Blue, val), GetTCVal(m_fPostFx2Alpha, val), - GetTCVal(m_fCloudAlpha, val), GetTCVal(m_nHighLightMinIntensity, val), GetTCVal(m_nWaterFogAlpha, val), - GetTCVal(m_nDirectionalMult, val) / 100.0); - file << buffer << std::endl; - } - } + buffer += std::format("{} {} {}\t{} {} {}\t255 255 255\t{} {} {}\t{} {} {}\t{} {} {}\t{} {} {}\t{} {} {}\t{} {} {}\t{} {} {}\t{} {} {}\t{} {} {}\t{} {} {} {}\t{} {} {} {}\t{} {} {} {}\t{} {} {} {}", + GetTCVal(m_nAmbientRed, val), GetTCVal(m_nAmbientGreen, val), GetTCVal(m_nAmbientBlue, val), + GetTCVal(m_nAmbientRed_Obj, val), GetTCVal(m_nAmbientGreen_Obj, val), GetTCVal(m_nAmbientBlue_Obj, val), + GetTCVal(m_nSkyTopRed, val), GetTCVal(m_nSkyTopGreen, val), GetTCVal(m_nSkyTopBlue, val), + GetTCVal(m_nSkyBottomRed, val), GetTCVal(m_nSkyBottomGreen, val), GetTCVal(m_nSkyBottomBlue, val), + GetTCVal(m_nSunCoreRed, val), GetTCVal(m_nSunCoreGreen, val), GetTCVal(m_nSunCoreBlue, val), + GetTCVal(m_nSunCoronaRed, val), GetTCVal(m_nSunCoronaGreen, val), GetTCVal(m_nSunCoronaBlue, val), + GetTCVal(m_fSunSize, val) / 10.0f, GetTCVal(m_fSpriteSize, val) / 10.0f, GetTCVal(m_fSpriteBrightness, val) / 10.0f, + GetTCVal(m_nShadowStrength, val), GetTCVal(m_nLightShadowStrength, val), GetTCVal(m_nPoleShadowStrength, val), + GetTCVal(m_fFarClip, val), GetTCVal(m_fFogStart, val), GetTCVal(m_fLightsOnGroundBrightness, val)/ 10.0f, + GetTCVal(m_nLowCloudsRed, val), GetTCVal(m_nLowCloudsGreen, val), GetTCVal(m_nLowCloudsBlue, val), + GetTCVal(m_nSkyBottomRed, val), GetTCVal(m_nSkyBottomGreen, val), GetTCVal(m_nSkyBottomBlue, val), + GetTCVal(m_fWaterRed, val), GetTCVal(m_fWaterGreen, val), GetTCVal(m_fWaterBlue, val), GetTCVal(m_fWaterAlpha, val), + GetTCVal(m_fPostFx1Red, val), GetTCVal(m_fPostFx1Green, val), GetTCVal(m_fPostFx1Blue, val), GetTCVal(m_fPostFx1Alpha, val), + GetTCVal(m_fPostFx2Red, val), GetTCVal(m_fPostFx2Green, val), GetTCVal(m_fPostFx2Blue, val), GetTCVal(m_fPostFx2Alpha, val), + GetTCVal(m_fCloudAlpha, val), GetTCVal(m_nHighLightMinIntensity, val), GetTCVal(m_nWaterFogAlpha, val), GetTCVal(m_nDirectionalMult, val) / 100.0 + ); + file << buffer << std::endl; + } + } #elif GTAVC - std::ofstream file = std::ofstream("timecyc.dat"); + std::ofstream file = std::ofstream("timecyc.dat"); - for (uint i = 0; i < 4; ++i) - { - std::string buffer; - switch (i) - { - case 0: - buffer = "\n// SUNNY\n"; - break; - case 1: - buffer = "\n// CLOUDY\n"; - break; - case 2: - buffer = "\n// RAINY\n"; - break; - case 3: - buffer = "\n// FOGGY\n"; - } + for (uint i = 0; i < 4; ++i) + { + std::string buffer; + switch(i) + { + case 0: + buffer = "\n// SUNNY\n"; + break; + case 1: + buffer = "\n// CLOUDY\n"; + break; + case 2: + buffer = "\n// RAINY\n"; + break; + case 3: + buffer = "\n// FOGGY\n"; + } - buffer += "// Amb Amb_Obj Amb_bl Amb_Obj_bl Dir Sky top Sky bot SunCore " - " SunCorona SunSz SprSz SprBght Shdw LightShd PoleShd FarClp FogSt LightOnGround " - "LowCloudsRGB TopCloudRGB BottomCloudRGB BlurRGB WaterRGBA"; + buffer += "// Amb Amb_Obj Amb_bl Amb_Obj_bl Dir Sky top Sky bot SunCore SunCorona SunSz SprSz SprBght Shdw LightShd PoleShd FarClp FogSt LightOnGround LowCloudsRGB TopCloudRGB BottomCloudRGB BlurRGB WaterRGBA"; - file << buffer << std::endl; + file << buffer << std::endl; - for (size_t j = 0; j < 24; ++j) - { - buffer = "// " + std::to_string(j) + " "; - if (j < 12) - { - buffer += "AM\n"; - } - else - { - buffer += "PM\n"; - } + for (size_t j = 0; j < 24; ++j) + { + buffer = "// " + std::to_string(j) + " "; + if (j < 12) + { + buffer += "AM\n"; + } + else + { + buffer += "PM\n"; + } - size_t val = 7 * i + j; + size_t val = 7 * i + j; - buffer += std::format( - "{} {} {}\t{} {} {}\t{} {} {}\t{} {} {}\t{} {} {}\t{} {} {}\t{} {} {}\t{} {} {}\t{} {} " - "{}\t{}\t{}\t{}\t{}\t{}\t{}\t{}\t{}\t{}\t{} {} {}\t{} {} {}\t{} {} {}\t{} {} {}\t{} {} {} {}", - GetTCVal(m_nAmbientRed, val), GetTCVal(m_nAmbientGreen, val), GetTCVal(m_nAmbientBlue, val), - GetTCVal(m_nAmbientRed_Obj, val), GetTCVal(m_nAmbientGreen_Obj, val), GetTCVal(m_nAmbientBlue_Obj, val), - GetTCVal(m_nAmbientBlRed, val), GetTCVal(m_nAmbientBlGreen, val), GetTCVal(m_nAmbientBlBlue, val), - GetTCVal(m_nAmbientBlRed_Obj, val), GetTCVal(m_nAmbientBlGreen_Obj, val), - GetTCVal(m_nAmbientBlBlue_Obj, val), GetTCVal(m_nDirRed, val), GetTCVal(m_nDirGreen, val), - GetTCVal(m_nDirBlue, val), GetTCVal(m_nSkyTopRed, val), GetTCVal(m_nSkyTopGreen, val), - GetTCVal(m_nSkyTopBlue, val), GetTCVal(m_nSkyBottomRed, val), GetTCVal(m_nSkyBottomGreen, val), - GetTCVal(m_nSkyBottomBlue, val), GetTCVal(m_nSunCoreRed, val), GetTCVal(m_nSunCoreGreen, val), - GetTCVal(m_nSunCoreBlue, val), GetTCVal(m_nSunCoronaRed, val), GetTCVal(m_nSunCoronaGreen, val), - GetTCVal(m_nSunCoronaBlue, val), GetTCVal(m_fSunSize, val) / 10.0f, - GetTCVal(m_fSpriteSize, val) / 10.0f, GetTCVal(m_fSpriteBrightness, val) / 10.0f, - GetTCVal(m_nShadowStrength, val), GetTCVal(m_nLightShadowStrength, val), - GetTCVal(m_nPoleShadowStrength, val), GetTCVal(m_fFarClip, val), GetTCVal(m_fFogStart, val), - GetTCVal(m_fLightsOnGroundBrightness, val) / 10.0f, GetTCVal(m_nLowCloudsRed, val), - GetTCVal(m_nLowCloudsGreen, val), GetTCVal(m_nLowCloudsBlue, val), GetTCVal(m_nTopCloudsRed, val), - GetTCVal(m_nTopCloudsGreen, val), GetTCVal(m_nTopCloudsBlue, val), GetTCVal(m_nBottomCloudsRed, val), - GetTCVal(m_nBottomCloudsGreen, val), GetTCVal(m_nBottomCloudsBlue, val), GetTCVal(m_nBlurRed, val), - GetTCVal(m_nBlurGreen, val), GetTCVal(m_nBlurBlue, val), GetTCVal(m_fWaterRed, val), - GetTCVal(m_fWaterGreen, val), GetTCVal(m_fWaterBlue, val), GetTCVal(m_fWaterAlpha, val)); - file << buffer << std::endl; - } - } -#endif + buffer += std::format("{} {} {}\t{} {} {}\t{} {} {}\t{} {} {}\t{} {} {}\t{} {} {}\t{} {} {}\t{} {} {}\t{} {} {}\t{}\t{}\t{}\t{}\t{}\t{}\t{}\t{}\t{}\t{} {} {}\t{} {} {}\t{} {} {}\t{} {} {}\t{} {} {} {}", + GetTCVal(m_nAmbientRed, val), GetTCVal(m_nAmbientGreen, val), GetTCVal(m_nAmbientBlue, val), + GetTCVal(m_nAmbientRed_Obj, val), GetTCVal(m_nAmbientGreen_Obj, val), GetTCVal(m_nAmbientBlue_Obj, val), + GetTCVal(m_nAmbientBlRed, val), GetTCVal(m_nAmbientBlGreen, val), GetTCVal(m_nAmbientBlBlue, val), + GetTCVal(m_nAmbientBlRed_Obj, val), GetTCVal(m_nAmbientBlGreen_Obj, val), GetTCVal(m_nAmbientBlBlue_Obj, val), + GetTCVal(m_nDirRed, val), GetTCVal(m_nDirGreen, val), GetTCVal(m_nDirBlue, val), + GetTCVal(m_nSkyTopRed, val), GetTCVal(m_nSkyTopGreen, val), GetTCVal(m_nSkyTopBlue, val), + GetTCVal(m_nSkyBottomRed, val), GetTCVal(m_nSkyBottomGreen, val), GetTCVal(m_nSkyBottomBlue, val), + GetTCVal(m_nSunCoreRed, val), GetTCVal(m_nSunCoreGreen, val), GetTCVal(m_nSunCoreBlue, val), + GetTCVal(m_nSunCoronaRed, val), GetTCVal(m_nSunCoronaGreen, val), GetTCVal(m_nSunCoronaBlue, val), + GetTCVal(m_fSunSize, val) / 10.0f, GetTCVal(m_fSpriteSize, val) / 10.0f, GetTCVal(m_fSpriteBrightness, val) / 10.0f, + GetTCVal(m_nShadowStrength, val), GetTCVal(m_nLightShadowStrength, val), GetTCVal(m_nPoleShadowStrength, val), + GetTCVal(m_fFarClip, val), GetTCVal(m_fFogStart, val), GetTCVal(m_fLightsOnGroundBrightness, val)/ 10.0f, + GetTCVal(m_nLowCloudsRed, val), GetTCVal(m_nLowCloudsGreen, val), GetTCVal(m_nLowCloudsBlue, val), + GetTCVal(m_nTopCloudsRed, val), GetTCVal(m_nTopCloudsGreen, val), GetTCVal(m_nTopCloudsBlue, val), + GetTCVal(m_nBottomCloudsRed, val), GetTCVal(m_nBottomCloudsGreen, val), GetTCVal(m_nBottomCloudsBlue, val), + GetTCVal(m_nBlurRed, val), GetTCVal(m_nBlurGreen, val), GetTCVal(m_nBlurBlue, val), + GetTCVal(m_fWaterRed, val), GetTCVal(m_fWaterGreen, val), GetTCVal(m_fWaterBlue, val), GetTCVal(m_fWaterAlpha, val) + ); + file << buffer << std::endl; + } + } +#endif } int Visual::CalcArrayIndex() @@ -200,408 +189,429 @@ int Visual::CalcArrayIndex() int hour = CClock::ms_nGameClockHours; #ifdef GTASA - int result = 0; - if (m_nTimecycHour == 24) { - result = hour; + hour = hour; } else { if (hour < 5) - result = 0; + hour = 0; if (hour == 5) - result = 1; + hour = 1; if (hour == 6) - result = 2; + hour = 2; if (7 <= hour && hour < 12) - result = 3; + hour = 3; if (12 <= hour && hour < 19) - result = 4; + hour = 4; if (hour == 19) - result = 5; + hour = 5; if (hour == 20 || hour == 21) - result = 6; + hour = 6; if (hour == 22 || hour == 23) - result = 7; + hour = 7; } - - return 23 * result + CWeather::OldWeatherType; -#elif GTAVC - return 7 * hour + CWeather::OldWeatherType; #endif + + return TOTAL_WEATHERS * hour + CWeather::OldWeatherType; } -bool Visual::TimeCycColorEdit3(const char *label, uchar *r, uchar *g, uchar *b, ImGuiColorEditFlags flags) +bool Visual::TimeCycColorEdit3(const char* label, uchar* r, uchar* g, uchar* b, ImGuiColorEditFlags flags) { - bool rtn = false; - int val = CalcArrayIndex(); + bool rtn = false; + int val = CalcArrayIndex(); #ifdef GTASA - auto red = static_cast(patch::GetPointer(int(r))); - auto green = static_cast(patch::GetPointer(int(g))); - auto blue = static_cast(patch::GetPointer(int(b))); -#elif GTAVC - auto red = static_cast(r); - auto green = static_cast(g); - auto blue = static_cast(b); + auto red = static_cast(patch::GetPointer(int(r))); + auto green = static_cast(patch::GetPointer(int(g))); + auto blue = static_cast(patch::GetPointer(int(b))); +#else // GTA3 & GTAVC + auto red = static_cast(r); + auto green = static_cast(g); + auto blue = static_cast(b); #endif - float col[3]{red[val] / 255.0f, green[val] / 255.0f, blue[val] / 255.0f}; + float col[3]{ red[val] / 255.0f, green[val] / 255.0f, blue[val] / 255.0f }; - if (ImGui::ColorEdit3(label, col, flags)) - { - red[val] = col[0] * 255; - green[val] = col[1] * 255; - blue[val] = col[2] * 255; - rtn = true; - } + if (ImGui::ColorEdit3(label, col, flags)) + { + red[val] = col[0] * 255; + green[val] = col[1] * 255; + blue[val] = col[2] * 255; + rtn = true; + } - return rtn; + return rtn; } -bool Visual::TimeCycColorEdit4(const char *label, uchar *r, uchar *g, uchar *b, uchar *a, ImGuiColorEditFlags flags) +bool Visual::TimeCycColorEdit4(const char* label, uchar* r, uchar* g, uchar* b, uchar* a, ImGuiColorEditFlags flags) { - bool rtn = false; - int val = CalcArrayIndex(); + bool rtn = false; + int val = CalcArrayIndex(); #ifdef GTASA - auto red = static_cast(patch::GetPointer(int(r))); - auto green = static_cast(patch::GetPointer(int(g))); - auto blue = static_cast(patch::GetPointer(int(b))); - auto alpha = static_cast(patch::GetPointer(int(a))); -#elif GTAVC - auto red = static_cast(r); - auto green = static_cast(g); - auto blue = static_cast(b); - auto alpha = static_cast(a); + auto red = static_cast(patch::GetPointer(int(r))); + auto green = static_cast(patch::GetPointer(int(g))); + auto blue = static_cast(patch::GetPointer(int(b))); + auto alpha = static_cast(patch::GetPointer(int(a))); +#else // GTA3 & GTAVC + auto red = static_cast(r); + auto green = static_cast(g); + auto blue = static_cast(b); + auto alpha = static_cast(a); #endif - float col[4]{red[val] / 255.0f, green[val] / 255.0f, blue[val] / 255.0f, alpha[val] / 255.0f}; + float col[4]{ red[val] / 255.0f, green[val] / 255.0f, blue[val] / 255.0f, alpha[val] / 255.0f }; - if (ImGui::ColorEdit4(label, col, flags)) - { - red[val] = col[0] * 255; - green[val] = col[1] * 255; - blue[val] = col[2] * 255; - alpha[val] = col[3] * 255; - rtn = true; - } + if (ImGui::ColorEdit4(label, col, flags)) + { + red[val] = col[0] * 255; + green[val] = col[1] * 255; + blue[val] = col[2] * 255; + alpha[val] = col[3] * 255; + rtn = true; + } - return rtn; + return rtn; } void Visual::Draw() { - if (ImGui::BeginTabBar("Visual", ImGuiTabBarFlags_NoTooltip + ImGuiTabBarFlags_FittingPolicyScroll)) - { - if (ImGui::BeginTabItem("Checkboxes")) - { - ImGui::Spacing(); - ImGui::Columns(2, nullptr, false); + if (ImGui::BeginTabBar("Visual", ImGuiTabBarFlags_NoTooltip + ImGuiTabBarFlags_FittingPolicyScroll)) + { + if (ImGui::BeginTabItem("Checkboxes")) + { + ImGui::Spacing(); + ImGui::Columns(2, nullptr, false); #ifdef GTASA - Ui::CheckboxAddress("Armour border", 0x589123); - Ui::CheckboxAddress("Armour percentage", 0x589125); - Ui::CheckboxAddress("Breath border", 0x589207); - Ui::CheckboxAddress("Breath percentage", 0x589209); - if (Ui::CheckboxWithHint("Disable hydrant splash", &m_bDisableHydrant)) + Ui::CheckboxAddress("Armour border", 0x589123); + Ui::CheckboxAddress("Armour percentage", 0x589125); + Ui::CheckboxAddress("Breath border", 0x589207); + Ui::CheckboxAddress("Breath percentage", 0x589209); + if (Ui::CheckboxWithHint("Disable hydrant splash", &m_bDisableHydrant)) + { + if (m_bDisableHydrant) + { + // don't call Fx_c::TriggerWaterHydrant + plugin::patch::Nop(0x4A0D70, 5); + } + else + { + plugin::patch::SetRaw(0x4A0D70, (char*)"\xE9\x94\x3F\xF6\xFF", 5); + } + } + Ui::CheckboxAddress("Gray radar", 0xA444A4); + Ui::CheckboxAddress("Health border", 0x589353); + Ui::CheckboxAddress("Health percentage", 0x589355); + if (Ui::CheckboxWithHint("Hide area names", &CHud::bScriptDontDisplayAreaName)) + { + Command(!CHud::bScriptDontDisplayAreaName); + } + + ImGui::NextColumn(); + + if (Ui::CheckboxWithHint("Hide veh names", &CHud::bScriptDontDisplayVehicleName)) + { + Command(!CHud::bScriptDontDisplayVehicleName); + } + + Ui::CheckboxAddressEx("Hide wanted level", 0x58DD1B, 0x90, 1); + + if (Ui::CheckboxWithHint("Invisible water", &m_bInvisibleWater)) + { + if (!m_bNoWater) + { + if (m_bInvisibleWater) + { + // don't call CWaterLevel::RenderWater() + plugin::patch::Nop(0x53E004, 5); + plugin::patch::Nop(0x53E142, 5); + } + else + { + // restore call CWaterLevel::RenderWater() + plugin::patch::SetRaw(0x53E004, (char*)"\xE8\x47\x16\x1B\x00", 5); + plugin::patch::SetRaw(0x53E142, (char*)"\xE8\x09\x15\x1B\x00", 5); + } + } + } + Ui::CheckboxWithHint("Lock weather", &m_bLockWeather); + if (Ui::CheckboxWithHint("No water", &m_bNoWater)) + { + if (m_bNoWater) + { + // don't call CWaterLevel::RenderWater() + plugin::patch::Nop(0x53E004, 5); + plugin::patch::Nop(0x53E142, 5); + + // rtn CWaterLevel::GetWaterLevelNoWaves + plugin::patch::SetRaw(0x6E8580, (char*)"\x32\xC0\xC3", 3); + } + else + { + // restore call CWaterLevel::RenderWater() + plugin::patch::SetRaw(0x53E004, (char*)"\xE8\x47\x16\x1B\x00", 5); + plugin::patch::SetRaw(0x53E142, (char*)"\xE8\x09\x15\x1B\x00", 5); + + // restore CWaterLevel::GetWaterLevelNoWaves + plugin::patch::SetRaw(0x6E8580, (char*)"\x51\xD9\x44", 3); + } + } + + bool radar_state = (patch::Get(0xBA676C) != 2); + if (Ui::CheckboxWithHint("Show radar", &radar_state)) + { + patch::Set(0xBA676C, radar_state == true ? 0 : 2); + } + + Ui::CheckboxAddress("Show hud", 0xBA6769); + Ui::CheckboxAddressEx("Unfog map", 0xBA372C, 0x50, 0x0); +#elif GTAVC + Ui::CheckboxAddress("Hide radar", 0xA10AB6); + Ui::CheckboxWithHint("Lock weather", &m_bLockWeather); + Ui::CheckboxAddress("Show hud", 0x86963A); + + ImGui::NextColumn(); + + Ui::CheckboxAddress("Green scanlines", 0xA10B69); + Ui::CheckboxAddress("White scanlines", 0xA10B68); +#else // GTA3 + Ui::CheckboxWithHint("Lock weather", &m_bLockWeather); + static bool showHud, showRadar; + if (Ui::CheckboxWithHint("Show hud", &showHud)) { - if (m_bDisableHydrant) + if (showHud) { - // don't call Fx_c::TriggerWaterHydrant - plugin::patch::Nop(0x4A0D70, 5); + patch::Nop(0x48E420, 5); // CHud::Draw } else { - plugin::patch::SetRaw(0x4A0D70, (char *)"\xE9\x94\x3F\xF6\xFF", 5); + patch::SetRaw(0x48E420, (char*)"\xE8\x7B\x6E\x07\x00", 5); } } - Ui::CheckboxAddress("Gray radar", 0xA444A4); - Ui::CheckboxAddress("Health border", 0x589353); - Ui::CheckboxAddress("Health percentage", 0x589355); - if (Ui::CheckboxWithHint("Hide area names", &CHud::bScriptDontDisplayAreaName)) + if (Ui::CheckboxWithHint("Show radar", &showRadar)) { - Command(!CHud::bScriptDontDisplayAreaName); - } - - ImGui::NextColumn(); - - if (Ui::CheckboxWithHint("Hide veh names", &CHud::bScriptDontDisplayVehicleName)) - { - Command(!CHud::bScriptDontDisplayVehicleName); - } - - Ui::CheckboxAddressEx("Hide wanted level", 0x58DD1B, 0x90, 1); - - if (Ui::CheckboxWithHint("Invisible water", &m_bInvisibleWater)) - { - if (!m_bNoWater) + if (showHud) { - if (m_bInvisibleWater) - { - // don't call CWaterLevel::RenderWater() - plugin::patch::Nop(0x53E004, 5); - plugin::patch::Nop(0x53E142, 5); - } - else - { - // restore call CWaterLevel::RenderWater() - plugin::patch::SetRaw(0x53E004, (char *)"\xE8\x47\x16\x1B\x00", 5); - plugin::patch::SetRaw(0x53E142, (char *)"\xE8\x09\x15\x1B\x00", 5); - } - } - } - Ui::CheckboxWithHint("Lock weather", &m_bLockWeather); - if (Ui::CheckboxWithHint("No water", &m_bNoWater)) - { - if (m_bNoWater) - { - // don't call CWaterLevel::RenderWater() - plugin::patch::Nop(0x53E004, 5); - plugin::patch::Nop(0x53E142, 5); - - // rtn CWaterLevel::GetWaterLevelNoWaves - plugin::patch::SetRaw(0x6E8580, (char *)"\x32\xC0\xC3", 3); + patch::Nop(0x50838D, 5); // CRadar::Draw } else { - // restore call CWaterLevel::RenderWater() - plugin::patch::SetRaw(0x53E004, (char *)"\xE8\x47\x16\x1B\x00", 5); - plugin::patch::SetRaw(0x53E142, (char *)"\xE8\x09\x15\x1B\x00", 5); - - // restore CWaterLevel::GetWaterLevelNoWaves - plugin::patch::SetRaw(0x6E8580, (char *)"\x51\xD9\x44", 3); + patch::SetRaw(0x50838D, (char*)"\xE8\x6E\xBE\xF9\xFF", 5); } } - - bool radar_state = (patch::Get(0xBA676C) != 2); - if (Ui::CheckboxWithHint("Show radar", &radar_state)) - { - patch::Set(0xBA676C, radar_state == true ? 0 : 2); - } - - Ui::CheckboxAddress("Show hud", 0xBA6769); - Ui::CheckboxAddressEx("Unfog map", 0xBA372C, 0x50, 0x0); -#elif GTAVC - Ui::CheckboxAddress("Hide radar", 0xA10AB6); - Ui::CheckboxWithHint("Lock weather", &m_bLockWeather); - Ui::CheckboxAddress("Show hud", 0x86963A); - - ImGui::NextColumn(); - - Ui::CheckboxAddress("Green scanlines", 0xA10B69); - Ui::CheckboxAddress("White scanlines", 0xA10B68); #endif - ImGui::Columns(1); - ImGui::EndTabItem(); - } - if (ImGui::BeginTabItem("Menus")) - { + ImGui::Columns(1); + ImGui::EndTabItem(); + } + if (ImGui::BeginTabItem("Menus")) + { #ifdef GTASA - static bool init_patches = false; - static float clock_posX = *(float *)*(int *)0x58EC16; - static float clock_posY = *(float *)*(int *)0x58EC04; - static float radar_posX = *(float *)*(int *)0x5834D4; - static float radar_posY = *(float *)*(int *)0x583500; - static float radar_width = *(float *)*(int *)0x5834C2; - static float radar_height = *(float *)*(int *)0x5834F6; - static CHudColour armour_bar = HudColour.m_aColours[4]; - static CHudColour clock_bar = HudColour.m_aColours[4]; - static CHudColour health_bar = HudColour.m_aColours[0]; - static CHudColour breath_bar = HudColour.m_aColours[3]; - static CHudColour wanted_bar = HudColour.m_aColours[6]; - static float money_posX = *(float *)*(int *)0x58F5FC; - static float breath_posX = *(float *)*(int *)0x58F11F; - static float breath_posY = *(float *)*(int *)0x58F100; - static float weapon_icon_posX = *(float *)*(int *)0x58F927; - static float weapon_icon_posY = *(float *)*(int *)0x58F913; - static float weapon_ammo_posX = *(float *)*(int *)0x58FA02; - static float weapon_ammo_posY = *(float *)*(int *)0x58F9E6; - static float wanted_posX = *(float *)*(int *)0x58DD0F; + static bool init_patches = false; + static float clock_posX = *(float*)*(int*)0x58EC16; + static float clock_posY = *(float*)*(int*)0x58EC04; + static float radar_posX = *(float*)*(int*)0x5834D4; + static float radar_posY = *(float*)*(int*)0x583500; + static float radar_width = *(float*)*(int*)0x5834C2; + static float radar_height = *(float*)*(int*)0x5834F6; + static CHudColour armour_bar = HudColour.m_aColours[4]; + static CHudColour clock_bar = HudColour.m_aColours[4]; + static CHudColour health_bar = HudColour.m_aColours[0]; + static CHudColour breath_bar = HudColour.m_aColours[3]; + static CHudColour wanted_bar = HudColour.m_aColours[6]; + static float money_posX = *(float*)*(int*)0x58F5FC; + static float breath_posX = *(float*)*(int*)0x58F11F; + static float breath_posY = *(float*)*(int*)0x58F100; + static float weapon_icon_posX = *(float*)*(int*)0x58F927; + static float weapon_icon_posY = *(float*)*(int*)0x58F913; + static float weapon_ammo_posX = *(float*)*(int*)0x58FA02; + static float weapon_ammo_posY = *(float*)*(int*)0x58F9E6; + static float wanted_posX = *(float*)*(int*)0x58DD0F; - if (!init_patches) - { - patch::SetPointer(0x58EC16, &clock_posX); - patch::SetPointer(0x58EC04, &clock_posY); - patch::SetPointer(0x5834D4, &radar_posX); - patch::SetPointer(0x583500, &radar_posY); - patch::SetPointer(0x5834F6, &radar_height); - patch::SetPointer(0x5834C2, &radar_width); + if (!init_patches) + { + patch::SetPointer(0x58EC16, &clock_posX); + patch::SetPointer(0x58EC04, &clock_posY); + patch::SetPointer(0x5834D4, &radar_posX); + patch::SetPointer(0x583500, &radar_posY); + patch::SetPointer(0x5834F6, &radar_height); + patch::SetPointer(0x5834C2, &radar_width); - patch::SetPointer(0x58A79B, &radar_posX); - patch::SetPointer(0x58A7C7, &radar_posY); - patch::SetPointer(0x58A801, &radar_height); - patch::SetPointer(0x58A7E9, &radar_width); - patch::SetPointer(0x58A836, &radar_posX); - patch::SetPointer(0x58A868, &radar_posY); - patch::SetPointer(0x58A8AB, &radar_height); - patch::SetPointer(0x58A840, &radar_width); - patch::SetPointer(0x58A8E9, &radar_posX); - patch::SetPointer(0x58A913, &radar_posY); - patch::SetPointer(0x58A921, &radar_height); - patch::SetPointer(0x58A943, &radar_width); - patch::SetPointer(0x58A98A, &radar_posX); - patch::SetPointer(0x58A9C7, &radar_posY); - patch::SetPointer(0x58A9D5, &radar_height); - patch::SetPointer(0x58A99D, &radar_width); + patch::SetPointer(0x58A79B, &radar_posX); + patch::SetPointer(0x58A7C7, &radar_posY); + patch::SetPointer(0x58A801, &radar_height); + patch::SetPointer(0x58A7E9, &radar_width); + patch::SetPointer(0x58A836, &radar_posX); + patch::SetPointer(0x58A868, &radar_posY); + patch::SetPointer(0x58A8AB, &radar_height); + patch::SetPointer(0x58A840, &radar_width); + patch::SetPointer(0x58A8E9, &radar_posX); + patch::SetPointer(0x58A913, &radar_posY); + patch::SetPointer(0x58A921, &radar_height); + patch::SetPointer(0x58A943, &radar_width); + patch::SetPointer(0x58A98A, &radar_posX); + patch::SetPointer(0x58A9C7, &radar_posY); + patch::SetPointer(0x58A9D5, &radar_height); + patch::SetPointer(0x58A99D, &radar_width); - patch::SetPointer(0x5890FC, &armour_bar); - patch::SetChar(0x5890F5, 0); - patch::SetPointer(0x589331, &health_bar); - patch::SetPointer(0x5891EB, &breath_bar); - patch::SetChar(0x5891E4, 0); - patch::SetPointer(0x58EBD1, &clock_bar); - patch::SetChar(0x58EBCA, 0); + patch::SetPointer(0x5890FC, &armour_bar); + patch::SetChar(0x5890F5, 0); + patch::SetPointer(0x589331, &health_bar); + patch::SetPointer(0x5891EB, &breath_bar); + patch::SetChar(0x5891E4, 0); + patch::SetPointer(0x58EBD1, &clock_bar); + patch::SetChar(0x58EBCA, 0); - patch::SetPointer(0x58F5FC, &money_posX); - patch::SetPointer(0x58F11F, &breath_posX); - patch::SetPointer(0x58F100, &breath_posY); - patch::SetPointer(0x58DD0F, &wanted_posX); - patch::SetPointer(0x58F927, &weapon_icon_posX); - patch::SetPointer(0x58F913, &weapon_icon_posY); - patch::SetPointer(0x58FA02, &weapon_ammo_posX); - patch::SetPointer(0x58F9E6, &weapon_ammo_posY); + patch::SetPointer(0x58F5FC, &money_posX); + patch::SetPointer(0x58F11F, &breath_posX); + patch::SetPointer(0x58F100, &breath_posY); + patch::SetPointer(0x58DD0F, &wanted_posX); + patch::SetPointer(0x58F927, &weapon_icon_posX); + patch::SetPointer(0x58F913, &weapon_icon_posY); + patch::SetPointer(0x58FA02, &weapon_ammo_posX); + patch::SetPointer(0x58F9E6, &weapon_ammo_posY); - init_patches = true; - } + init_patches = true; + } #endif - if (ImGui::BeginChild("VisualsChild")) - { + if (ImGui::BeginChild("VisualsChild")) + { #ifdef GTASA - ImGui::TextWrapped("These options won't work if you got any mods that drastically changes the game " - "hud. i.e. Mobile Hud, GTA 5 Hud etc."); - ImGui::Spacing(); - Ui::ColorPickerAddress("Armourbar color", *(int *)0x5890FC, ImVec4(225, 225, 225, 255)); - Ui::EditAddress("Armourbar posX", 0x866B78, -999, 94, 999); - Ui::EditAddress("Armourbar posY", 0x862D38, -999, 48, 999); - Ui::ColorPickerAddress("Breathbar color", *(int *)0x5891EB, ImVec4(172, 203, 241, 255)); - Ui::EditAddress("Breathbar posX", *(int *)0x58F11F, -999, 94, 999); - Ui::EditAddress("Breathbar posY", *(int *)0x58F100, -999, 62, 999); - Ui::ColorPickerAddress("Clock color", *(int *)0x58EBD1, ImVec4(180, 25, 29, 255)); - Ui::EditAddress("Clock posX", *(int *)0x58EC16, -999, 32, 999); - Ui::EditAddress("Clock posY", *(int *)0x58EC04, -999, 22, 999); - Ui::ColorPickerAddress("Healthbar color", *(int *)0x589331, ImVec4(180, 25, 29, 255)); - Ui::EditAddress("Healthbar posX", 0x86535C, -999, 141, 999); - Ui::EditAddress("Healthbar posY", 0x866CA8, -999, 77, 999); - Ui::ColorPickerAddress("Draw menu title border color", 0xBAB240, ImVec4(0, 0, 0, 255)); - Ui::ColorPickerAddress("Money color", 0xBAB230, ImVec4(54, 104, 44, 255)); - Ui::EditAddress("Money posX", *(int *)0x58F5FC, -999, 32, 999); - Ui::EditAddress("Money posY", 0x866C88, -999, 89, 999); - static std::vector font_outline{ - {"No outline", 0}, {"Thin outline", 1}, {"Default outline", 2}}; - Ui::EditRadioButtonAddressEx("Money font outline", 0x58F58D, font_outline); - static std::vector style{{"Style 1", 1}, {"Style 2", 2}, {"Default style", 3}}; - Ui::EditRadioButtonAddressEx("Money font style", 0x58F57F, style); - Ui::EditAddress("Radar Height", *(int *)0x5834F6, 0, 76, 999); - Ui::EditAddress("Radar Width", *(int *)0x5834C2, 0, 94, 999); - Ui::EditAddress("Radar posX", *(int *)0x5834D4, -999, 40, 999); - Ui::EditAddress("Radar posY", *(int *)0x583500, -999, 104, 999); - Ui::EditAddress("Radar zoom", 0xA444A3, 0, 0, 170); - Ui::ColorPickerAddress("Radio station color", 0xBAB24C, ImVec4(150, 150, 150, 255)); - static std::vector star_border{{"No border", 0}, {"Default", 1}, {"Bold border", 2}}; - Ui::EditRadioButtonAddressEx("Wanted star border", 0x58DD41, star_border); - Ui::EditAddress("Wanted posX", *(int *)0x58DD0F, -999, 29, 999); - Ui::EditAddress("Wanted posY", *(int *)0x58DDFC, -999, 114, 999); - Ui::EditAddress("Weapon ammo posX", *(int *)0x58FA02, -999, 32, 999); - Ui::EditAddress("Weapon ammo posY", *(int *)0x58F9E6, -999, 43, 999); - Ui::EditAddress("Weapon icon posX", *(int *)0x58F927, -999, 32, 999); - Ui::EditAddress("Weapon icon posY", *(int *)0x58F913, -999, 20, 999); + ImGui::TextWrapped( + "These options won't work if you got any mods that drastically changes the game hud. i.e. Mobile Hud, GTA 5 Hud etc."); + ImGui::Spacing(); + Ui::ColorPickerAddress("Armourbar color", *(int*)0x5890FC, ImVec4(225, 225, 225, 255)); + Ui::EditAddress("Armourbar posX", 0x866B78, -999, 94, 999); + Ui::EditAddress("Armourbar posY", 0x862D38, -999, 48, 999); + Ui::ColorPickerAddress("Breathbar color", *(int*)0x5891EB, ImVec4(172, 203, 241, 255)); + Ui::EditAddress("Breathbar posX", *(int*)0x58F11F, -999, 94, 999); + Ui::EditAddress("Breathbar posY", *(int*)0x58F100, -999, 62, 999); + Ui::ColorPickerAddress("Clock color", *(int*)0x58EBD1, ImVec4(180, 25, 29, 255)); + Ui::EditAddress("Clock posX", *(int*)0x58EC16, -999, 32, 999); + Ui::EditAddress("Clock posY", *(int*)0x58EC04, -999, 22, 999); + Ui::ColorPickerAddress("Healthbar color", *(int*)0x589331, ImVec4(180, 25, 29, 255)); + Ui::EditAddress("Healthbar posX", 0x86535C, -999, 141, 999); + Ui::EditAddress("Healthbar posY", 0x866CA8, -999, 77, 999); + Ui::ColorPickerAddress("Draw menu title border color", 0xBAB240, ImVec4(0, 0, 0, 255)); + Ui::ColorPickerAddress("Money color", 0xBAB230, ImVec4(54, 104, 44, 255)); + Ui::EditAddress("Money posX", *(int*)0x58F5FC, -999, 32, 999); + Ui::EditAddress("Money posY", 0x866C88, -999, 89, 999); + static std::vector font_outline{ + {"No outline", 0}, {"Thin outline", 1}, {"Default outline", 2} + }; + Ui::EditRadioButtonAddressEx("Money font outline", 0x58F58D, font_outline); + static std::vector style{ {"Style 1", 1}, {"Style 2", 2}, {"Default style", 3} }; + Ui::EditRadioButtonAddressEx("Money font style", 0x58F57F, style); + Ui::EditAddress("Radar Height", *(int*)0x5834F6, 0, 76, 999); + Ui::EditAddress("Radar Width", *(int*)0x5834C2, 0, 94, 999); + Ui::EditAddress("Radar posX", *(int*)0x5834D4, -999, 40, 999); + Ui::EditAddress("Radar posY", *(int*)0x583500, -999, 104, 999); + Ui::EditAddress("Radar zoom", 0xA444A3, 0, 0, 170); + Ui::ColorPickerAddress("Radio station color", 0xBAB24C, ImVec4(150, 150, 150, 255)); + static std::vector star_border{ {"No border", 0}, {"Default", 1}, {"Bold border", 2} }; + Ui::EditRadioButtonAddressEx("Wanted star border", 0x58DD41, star_border); + Ui::EditAddress("Wanted posX", *(int*)0x58DD0F, -999, 29, 999); + Ui::EditAddress("Wanted posY", *(int*)0x58DDFC, -999, 114, 999); + Ui::EditAddress("Weapon ammo posX", *(int*)0x58FA02, -999, 32, 999); + Ui::EditAddress("Weapon ammo posY", *(int*)0x58F9E6, -999, 43, 999); + Ui::EditAddress("Weapon icon posX", *(int*)0x58F927, -999, 32, 999); + Ui::EditAddress("Weapon icon posY", *(int*)0x58F913, -999, 20, 999); #elif GTAVC - Ui::EditAddress("Radar posX", 0x68FD2C, -999, 40, 999); - Ui::EditAddress("Radar posY", 0x68FD34, -999, 104, 999); - Ui::EditAddress("Radar width", 0x68FD28, -999, 20, 999); + Ui::EditAddress("Radar posX", 0x68FD2C, -999, 40, 999); + Ui::EditAddress("Radar posY", 0x68FD34, -999, 104, 999); + Ui::EditAddress("Radar width", 0x68FD28, -999, 20, 999); #endif - ImGui::EndChild(); - } + ImGui::EndChild(); + } - ImGui::EndTabItem(); - } + ImGui::EndTabItem(); + } #ifdef GTASA - if (m_nTimecycHour == 8 ? ImGui::BeginTabItem("Timecyc") : ImGui::BeginTabItem("Timecyc 24h")) -#elif GTAVC - if (ImGui::BeginTabItem("Timecyc")) + if (m_nTimecycHour == 8 ? ImGui::BeginTabItem("Timecyc") : ImGui::BeginTabItem("Timecyc 24h")) +#else // GTA3 & GTAVC + if (ImGui::BeginTabItem("Timecyc")) #endif - { - ImGui::Spacing(); - if (ImGui::Button("Generate timecyc file", Ui::GetSize(2))) - { - GenerateTimecycFile(); - SetHelpMessage("File generated", false, false, false); - } - ImGui::SameLine(); - if (ImGui::Button("Reset timecyc", Ui::GetSize(2))) - { - CTimeCycle::Initialise(); - SetHelpMessage("Timecyc reset", false, false, false); - } - ImGui::Spacing(); + { + ImGui::Spacing(); + if (ImGui::Button("Generate timecyc file", Ui::GetSize(2))) + { + GenerateTimecycFile(); + SetHelpMessage("File generated", false, false, false); + } + ImGui::SameLine(); + if (ImGui::Button("Reset timecyc", Ui::GetSize(2))) + { + CTimeCycle::Initialise(); + SetHelpMessage("Timecyc reset", false, false, false); + } + ImGui::Spacing(); - int weather = CWeather::OldWeatherType; - if (Ui::ListBox("Current weather", m_WeatherNames, weather)) - { - CWeather::OldWeatherType = weather; - } + int weather = CWeather::OldWeatherType; + if (Ui::ListBox("Current weather", m_WeatherNames, weather)) + { + CWeather::OldWeatherType = weather; + } - weather = CWeather::NewWeatherType; - if (Ui::ListBox("Next weather", m_WeatherNames, weather)) - { - CWeather::NewWeatherType = weather; - } + weather = CWeather::NewWeatherType; + if (Ui::ListBox("Next weather", m_WeatherNames, weather)) + { + CWeather::NewWeatherType = weather; + } - ImGui::Spacing(); - int hour = CClock::ms_nGameClockHours; - int minute = CClock::ms_nGameClockMinutes; + ImGui::Spacing(); + int hour = CClock::ms_nGameClockHours; + int minute = CClock::ms_nGameClockMinutes; - ImGui::BeginDisabled(Game::m_bSyncTime); + ImGui::BeginDisabled(Game::m_bSyncTime); - if (ImGui::InputInt("Hour", &hour) & !Game::m_bSyncTime) - { - if (hour < 0) - hour = 23; - if (hour > 23) - hour = 0; - CClock::ms_nGameClockHours = hour; - } + if (ImGui::InputInt("Hour", &hour) & !Game::m_bSyncTime) + { + if (hour < 0) hour = 23; + if (hour > 23) hour = 0; + CClock::ms_nGameClockHours = hour; + } - if (ImGui::InputInt("Minute", &minute) & !Game::m_bSyncTime) - { - if (minute < 0) - minute = 59; - if (minute > 59) - minute = 0; - CClock::ms_nGameClockMinutes = minute; - } + if (ImGui::InputInt("Minute", &minute) & !Game::m_bSyncTime) + { + if (minute < 0) minute = 59; + if (minute > 59) minute = 0; + CClock::ms_nGameClockMinutes = minute; + } - if (Game::m_bSyncTime) - { - ImGui::EndDisabled(); - Ui::ShowTooltip("Sync system time is enabled.\n(Game/Sync system time)"); - } + if (Game::m_bSyncTime) + { + ImGui::EndDisabled(); + Ui::ShowTooltip("Sync system time is enabled.\n(Game/Sync system time)"); + } - if (ImGui::Checkbox("Freeze game time", &Game::m_bFreezeTime)) - { + if (ImGui::Checkbox("Freeze game time", &Game::m_bFreezeTime)) + { if (Game::m_bFreezeTime) { - patch::SetRaw(BY_GAME(0x52CF10, 0x487010), (char *)"\xEB\xEF", 2); + patch::SetRaw(BY_GAME(0x52CF10, 0x487010, 0x473460), (char *)"\xEB\xEF", 2); } else { - patch::SetRaw(BY_GAME(0x52CF10, 0x487010), (char *)BY_GAME("\x56\x8B", "\x6A\x01"), 2); + patch::SetRaw(BY_GAME(0x52CF10, 0x487010, 0x473460), + (char *)BY_GAME("\x56\x8B", "\x6A\x01", "\x6A\x01"), 2); } - } - ImGui::Spacing(); - if (ImGui::BeginTabBar("Timecyc subtab", ImGuiTabBarFlags_NoTooltip + ImGuiTabBarFlags_FittingPolicyScroll)) - { - if (ImGui::BeginTabItem("Colors")) - { + } + ImGui::Spacing(); + if (ImGui::BeginTabBar("Timecyc subtab", ImGuiTabBarFlags_NoTooltip + ImGuiTabBarFlags_FittingPolicyScroll)) + { + if (ImGui::BeginTabItem("Colors")) + { ImGui::BeginChild("TimecycColors"); ImGui::Spacing(); TimeCycColorEdit3("Ambient", m_nAmbientRed, m_nAmbientGreen, m_nAmbientBlue); +#ifndef GTA3 TimeCycColorEdit3("Ambient obj", m_nAmbientRed_Obj, m_nAmbientGreen_Obj, m_nAmbientBlue_Obj); +#endif #ifdef GTASA TimeCycColorEdit3("Fluffy clouds", m_nFluffyCloudsBottomRed, m_nFluffyCloudsBottomGreen, @@ -611,11 +621,14 @@ void Visual::Draw() TimeCycColorEdit3("Ambient obj bl", m_nAmbientBlRed_Obj, m_nAmbientBlGreen_Obj, m_nAmbientBlBlue_Obj); TimeCycColorEdit3("Blur", m_nBlurRed, m_nBlurGreen, m_nBlurBlue); +#endif + +#ifndef GTASA TimeCycColorEdit3("Clouds bottom", m_nBottomCloudsRed, m_nBottomCloudsGreen, m_nBottomCloudsBlue); + TimeCycColorEdit3("Clouds low", m_nLowCloudsRed, m_nLowCloudsGreen, m_nLowCloudsBlue); TimeCycColorEdit3("Clouds top", m_nTopCloudsRed, m_nTopCloudsGreen, m_nTopCloudsBlue); TimeCycColorEdit3("Directional light", m_nDirRed, m_nDirGreen, m_nDirBlue); #endif - TimeCycColorEdit3("Low clouds", m_nLowCloudsRed, m_nLowCloudsGreen, m_nLowCloudsBlue); #ifdef GTASA TimeCycColorEdit4("Postfx 1", m_fPostFx1Red, m_fPostFx1Green, m_fPostFx1Blue, m_fPostFx1Alpha); @@ -631,11 +644,11 @@ void Visual::Draw() ImGui::EndChild(); ImGui::EndTabItem(); - } - if (ImGui::BeginTabItem("Misc")) - { - ImGui::BeginChild("TimecycMisc"); - ImGui::PushItemWidth(ImGui::GetWindowContentRegionWidth() / 2); + } + if (ImGui::BeginTabItem("Misc")) + { + ImGui::BeginChild("TimecycMisc"); + ImGui::PushItemWidth(ImGui::GetWindowContentRegionWidth() / 2); #ifdef GTASA TimecycSlider("Cloud alpha", m_fCloudAlpha, 0, 255); @@ -648,24 +661,32 @@ void Visual::Draw() #endif TimecycSlider("Light on ground brightness", m_fLightsOnGroundBrightness, 0, 255); TimecycSlider("Light shadow strength", m_nLightShadowStrength, 0, 255); + +#ifndef GTA3 TimecycSlider("Pole shadow strength", m_nPoleShadowStrength, 0, 255); +#endif TimecycSlider("Shadow strength", m_nShadowStrength, 0, 255); TimecycSlider("Sprite brightness", m_fSpriteBrightness, 0, 127); TimecycSlider("Sprite size", m_fSpriteSize, 0, 127); TimecycSlider("Sun size", m_fSunSize, 0, 127); + +#ifdef GTA3 + TimecycSlider("Tree shadow strength", m_nTreeShadowStrength, 0, 255); +#endif + #ifdef GTASA TimecycSlider("Water fog alpha", m_nWaterFogAlpha, 0, 255); #endif - ImGui::PopItemWidth(); + ImGui::PopItemWidth(); - ImGui::Spacing(); - ImGui::EndChild(); - ImGui::EndTabItem(); - } - ImGui::EndTabBar(); - } - ImGui::EndTabItem(); - } - ImGui::EndTabBar(); - } + ImGui::Spacing(); + ImGui::EndChild(); + ImGui::EndTabItem(); + } + ImGui::EndTabBar(); + } + ImGui::EndTabItem(); + } + ImGui::EndTabBar(); + } } diff --git a/src/visual.h b/src/visual.h index 819b06e..bc7435a 100644 --- a/src/visual.h +++ b/src/visual.h @@ -4,52 +4,48 @@ class Visual { private: - static inline bool m_bLockWeather; + static inline bool m_bLockWeather; #ifdef GTASA - static inline bool m_bInvisibleWater; - static inline bool m_bNoWater; - static inline bool m_bDisableHydrant; + static inline bool m_bInvisibleWater; + static inline bool m_bNoWater; + static inline bool m_bDisableHydrant; #endif - // Timecyc stuff - static inline int m_nTimecycHour = 8; - static inline std::vector m_WeatherNames{"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"}; - - static void GenerateTimecycFile(); - static int CalcArrayIndex(); - 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 static void TimecycSlider(const char *label, T *data, int min, int max); + // Timecyc stuff + static inline int m_nTimecycHour = 8; + static inline std::vector m_WeatherNames + { + "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" + }; + static void GenerateTimecycFile(); + static int CalcArrayIndex(); + 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 + static void TimecycSlider(const char* label, T* data, int min, int max); public: - Visual(); - static void Draw(); + Visual(); + static void Draw(); }; -template void Visual::TimecycSlider(const char *label, T *ptr, int min, int max) +template +void Visual::TimecycSlider(const char* label, T* ptr, int min, int max) { - int val = CalcArrayIndex(); + int val = CalcArrayIndex(); #ifdef GTASA - // Compatable with 24h TimeCyc - T *arr = static_cast(patch::GetPointer(int(ptr))); + // Compatable with 24h TimeCyc + T* arr = static_cast(patch::GetPointer(int(ptr))); #else // GTA3 & GTAVC - T *arr = static_cast(ptr); + T* arr = static_cast(ptr); #endif - int a = arr[val]; + int a = arr[val]; - if (ImGui::SliderInt(label, &a, min, max)) - arr[val] = static_cast(a); + if (ImGui::SliderInt(label, &a, min, max)) + arr[val] = static_cast(a); } diff --git a/src/vkeys.h b/src/vkeys.h index 1cbf381..aa43882 100644 --- a/src/vkeys.h +++ b/src/vkeys.h @@ -1,206 +1,210 @@ #pragma once -#define VK_NONE -1 -#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 +#define VK_NONE -1 +#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"}; + +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" +}; diff --git a/src/weapon.cpp b/src/weapon.cpp index e9e59fe..15ea924 100644 --- a/src/weapon.cpp +++ b/src/weapon.cpp @@ -1,413 +1,404 @@ -#include "weapon.h" -#include "CWeaponInfo.h" #include "pch.h" -#include "ped.h" +#include "weapon.h" #include "ui.h" #include "util.h" +#include "ped.h" +#include "CWeaponInfo.h" Weapon::Weapon() { - Events::processScriptsEvent += [] { - CPlayerPed *player = FindPlayerPed(); + Events::processScriptsEvent += [] + { + CPlayerPed* player = FindPlayerPed(); #ifdef GTASA - if (m_bAutoAim) - { - if (CPad::NewMouseControllerState.X == 0 && CPad::NewMouseControllerState.Y == 0) - { - if (KeyPressed(2)) - { - CCamera::m_bUseMouse3rdPerson = false; - } - } - else - { - CCamera::m_bUseMouse3rdPerson = true; - } - } + if (m_bAutoAim) + { + if (CPad::NewMouseControllerState.X == 0 && CPad::NewMouseControllerState.Y == 0) + { + if (KeyPressed(2)) + { + CCamera::m_bUseMouse3rdPerson = false; + } + } + else + { + CCamera::m_bUseMouse3rdPerson = true; + } + } #endif - uchar slot = BY_GAME(player->m_nActiveWeaponSlot, player->m_nActiveWeaponSlot, player->m_nCurrentWeapon); - if (m_nCurrentWeaponSlot != slot) - { + + uchar slot = BY_GAME(player->m_nActiveWeaponSlot, player->m_nActiveWeaponSlot, player->m_nCurrentWeapon); + if (m_nCurrentWeaponSlot != slot) + { #ifdef GTA3 - eWeaponType weaponType = player->m_aWeapons[slot].m_eWeaponType; + eWeaponType weaponType = player->m_aWeapons[slot].m_eWeaponType; #else - eWeaponType weaponType = player->m_aWeapons[slot].m_nType; + eWeaponType weaponType = player->m_aWeapons[slot].m_nType; #endif #ifdef GTASA - CWeaponInfo *pWeaponInfo = CWeaponInfo::GetWeaponInfo(weaponType, player->GetWeaponSkill(weaponType)); + CWeaponInfo* pWeaponInfo = CWeaponInfo::GetWeaponInfo(weaponType, player->GetWeaponSkill(weaponType)); #else // GTA3 & GTAVC - CWeaponInfo *pWeaponInfo = CWeaponInfo::GetWeaponInfo(weaponType); + CWeaponInfo* pWeaponInfo = CWeaponInfo::GetWeaponInfo(weaponType); - if (m_bInfiniteAmmo) - { - Command(0, weaponType, 999999); - } -#endif + if(m_bInfiniteAmmo) + { + Command(0, weaponType, 999999); + } +#endif - if (m_bHugeDamage) - { - pWeaponInfo->m_nDamage = 1000; - } + if (m_bHugeDamage) + { + pWeaponInfo->m_nDamage = 1000; + } - if (m_bLongRange) - { + if (m_bLongRange) + { #ifdef GTASA - pWeaponInfo->m_fTargetRange = 1000.0f; - pWeaponInfo->m_fWeaponRange = 1000.0f; - pWeaponInfo->m_fAccuracy = 1.0f; - pWeaponInfo->m_nFlags.bReload2Start = true; + pWeaponInfo->m_fTargetRange = 1000.0f; + pWeaponInfo->m_fWeaponRange = 1000.0f; + pWeaponInfo->m_fAccuracy = 1.0f; + pWeaponInfo->m_nFlags.bReload2Start = true; #else // GTA3 & GTAVC - pWeaponInfo->m_fRange = 1000.0f; + pWeaponInfo->m_fRange = 1000.0f; #endif - } + } -#ifdef GTASA - if (m_bRapidFire && - weaponType != BY_GAME(WEAPON_MINIGUN, WEAPONTYPE_MINIGUN)) // mingun doesn't work with rapidfire - { - pWeaponInfo->m_nFlags.bContinuosFire = true; - } +#ifdef GTASA + if (m_bRapidFire && weaponType != BY_GAME(WEAPON_MINIGUN, WEAPONTYPE_MINIGUN)) // mingun doesn't work with rapidfire + { + pWeaponInfo->m_nFlags.bContinuosFire = true; - if (m_bDualWeild && (weaponType == WEAPON_PISTOL || weaponType == WEAPON_MICRO_UZI || - weaponType == WEAPON_TEC9 || weaponType == WEAPON_SAWNOFF)) - { - pWeaponInfo->m_nFlags.bTwinPistol = true; - } + } - if (m_bMoveAim) - { - pWeaponInfo->m_nFlags.bMoveAim = true; - } + if (m_bDualWeild && (weaponType == WEAPON_PISTOL || weaponType == WEAPON_MICRO_UZI || weaponType == + WEAPON_TEC9 || weaponType == WEAPON_SAWNOFF)) + { + pWeaponInfo->m_nFlags.bTwinPistol = true; + } - if (m_bMoveFire) - { - pWeaponInfo->m_nFlags.bMoveFire = true; - } + if (m_bMoveAim) + { + pWeaponInfo->m_nFlags.bMoveAim = true; + } + + if (m_bMoveFire) + { + pWeaponInfo->m_nFlags.bMoveFire = true; + } #endif - m_nCurrentWeaponSlot = slot; - } - }; + m_nCurrentWeaponSlot = slot; + } + }; } #ifdef GTASA -void Weapon::SetGangWeapon(std::string &weapon_type) +void Weapon::SetGangWeapon(std::string& weapon_type) { - m_nGangWeaponList[m_nSelectedGang][m_nSelectedWeapon] = std::stoi(weapon_type); - CGangs::SetGangWeapons(m_nSelectedGang, m_nGangWeaponList[m_nSelectedGang][0], - m_nGangWeaponList[m_nSelectedGang][1], m_nGangWeaponList[m_nSelectedGang][2]); + m_nGangWeaponList[m_nSelectedGang][m_nSelectedWeapon] = std::stoi(weapon_type); + CGangs::SetGangWeapons(m_nSelectedGang, m_nGangWeaponList[m_nSelectedGang][0], m_nGangWeaponList[m_nSelectedGang][1], + m_nGangWeaponList[m_nSelectedGang][2]); } #else // GTA3 & GTAVC // Implementation of SA opcode 0x555 static void ClearPlayerWeapon(eWeaponType weaponType) { - CPlayerPed *pPlayer = FindPlayerPed(); + CPlayerPed *pPlayer = FindPlayerPed(); #ifdef GTA3 - int weaponSlot = pPlayer->GetWeaponSlot(weaponType); + int weaponSlot = pPlayer->GetWeaponSlot(weaponType); #else - int weaponSlot = CWeaponInfo::GetWeaponInfo(weaponType)->m_WeaponSlot; + int weaponSlot = CWeaponInfo::GetWeaponInfo(weaponType)->m_WeaponSlot; #endif - if (weaponSlot != -1) - { - CWeapon *pWeapon = &pPlayer->m_aWeapons[weaponSlot]; + if ( weaponSlot != -1 ) + { + CWeapon *pWeapon = &pPlayer->m_aWeapons[weaponSlot]; #ifdef GTA3 - if (pWeapon->m_eWeaponType == weaponType) - { - if (pPlayer->m_nCurrentWeapon == weaponSlot) - { - Command(0, WEAPONTYPE_UNARMED); - } - // This doesn't work for melee weapons aka bats, chainsaw etc - pWeapon->m_eWeaponState = WEAPONSTATE_OUT_OF_AMMO; - pWeapon->m_nAmmoTotal = 0; - pWeapon->m_nAmmoInClip = 0; - } + if (pWeapon->m_eWeaponType == weaponType) + { + if (pPlayer->m_nCurrentWeapon == weaponSlot) + { + Command(0, WEAPONTYPE_UNARMED); + } + // This doesn't work for melee weapons aka bats, chainsaw etc + pWeapon->m_eWeaponState = WEAPONSTATE_OUT_OF_AMMO; + pWeapon->m_nAmmoTotal = 0; + pWeapon->m_nAmmoInClip = 0; + } #else - if (pWeapon->m_nType == weaponType) - { - if (pPlayer->m_nActiveWeaponSlot == weaponSlot) - { - CWeaponInfo *pWeaponInfo = CWeaponInfo::GetWeaponInfo(WEAPONTYPE_UNARMED); - pPlayer->SetCurrentWeapon(pWeaponInfo->m_WeaponSlot); - } - pWeapon->Shutdown(); - } + if (pWeapon->m_nType == weaponType) + { + if (pPlayer->m_nActiveWeaponSlot == weaponSlot) + { + CWeaponInfo *pWeaponInfo = CWeaponInfo::GetWeaponInfo(WEAPONTYPE_UNARMED); + pPlayer->SetCurrentWeapon(pWeaponInfo->m_WeaponSlot); + } + pWeapon->Shutdown(); + } #endif - } + } } // Implementation of opcode 0x605 (CLEO) static eWeaponType GetWeaponTypeFromModel(int model) { - eWeaponType weaponType = WEAPONTYPE_UNARMED; + eWeaponType weaponType = WEAPONTYPE_UNARMED; - for (size_t i = 0; i < 37; i++) - { + for (size_t i = 0; i < 37; i++) + { + + int temp = CallAndReturn(i); // int __cdecl CPickups::ModelForWeapon(int a1) - int temp = - CallAndReturn(i); // int __cdecl CPickups::ModelForWeapon(int a1) + if (temp == model) + { + weaponType = (eWeaponType)i; + break; + } + } - if (temp == model) - { - weaponType = (eWeaponType)i; - break; - } - } - - return weaponType; + return weaponType; } #endif #ifdef GTASA -void Weapon::GiveWeaponToPlayer(std::string &weapon_type) +void Weapon::GiveWeaponToPlayer(std::string& weapon_type) { - CPlayerPed *player = FindPlayerPed(); - int hplayer = CPools::GetPedRef(player); + CPlayerPed* player = FindPlayerPed(); + int hplayer = CPools::GetPedRef(player); - if (weapon_type == "-1") // Jetpack - { - Command(hplayer); - } - else if (weapon_type == "-2") // CellPhone - { - CStreaming::RequestModel(330, PRIORITY_REQUEST); - CStreaming::LoadAllRequestedModels(false); - player->ClearWeaponTarget(); - player->SetCurrentWeapon(WEAPON_UNARMED); - player->AddWeaponModel(330); - Command(330); - } - else - { - int iweapon_type = std::stoi(weapon_type); + if (weapon_type == "-1") // Jetpack + { + Command(hplayer); + } + else if (weapon_type == "-2") // CellPhone + { + CStreaming::RequestModel(330, PRIORITY_REQUEST); + CStreaming::LoadAllRequestedModels(false); + player->ClearWeaponTarget(); + player->SetCurrentWeapon(WEAPON_UNARMED); + player->AddWeaponModel(330); + Command(330); + } + else + { + int iweapon_type = std::stoi(weapon_type); - int model = NULL; - Command(iweapon_type, &model); + int model = NULL; + Command(iweapon_type, &model); - CStreaming::RequestModel(model, PRIORITY_REQUEST); + CStreaming::RequestModel(model, PRIORITY_REQUEST); - if (model == 363) // remote bomb - { - CStreaming::RequestModel(364, PRIORITY_REQUEST); // detonator - } + if (model == 363) // remote bomb + { + CStreaming::RequestModel(364, PRIORITY_REQUEST); // detonator + } - CStreaming::LoadAllRequestedModels(false); - Command(hplayer, iweapon_type, m_nAmmoCount); + CStreaming::LoadAllRequestedModels(false); + Command(hplayer, iweapon_type, m_nAmmoCount); - if (model == 363) // remote bomb - { - Command(364); // detonator - } + if (model == 363) // remote bomb + { + Command(364); // detonator + } - Command(model); - } + Command(model); + } } #else // GTA3 & GTAVC -void Weapon::GiveWeaponToPlayer(std::string &rootkey, std::string &name, std::string &model) +void Weapon::GiveWeaponToPlayer(std::string& rootkey, std::string& name, std::string& model) { - CPlayerPed *player = FindPlayerPed(); - int hplayer = CPools::GetPedRef(player); - int iModel = std::stoi(model); - CStreaming::RequestModel(iModel, PRIORITY_REQUEST); - CStreaming::LoadAllRequestedModels(false); - - eWeaponType weaponType = GetWeaponTypeFromModel(iModel); - Command(hplayer, weaponType, m_nAmmoCount); - Command(iModel); + CPlayerPed* player = FindPlayerPed(); + int hplayer = CPools::GetPedRef(player); + int iModel = std::stoi(model); + CStreaming::RequestModel(iModel, PRIORITY_REQUEST); + CStreaming::LoadAllRequestedModels(false); + + eWeaponType weaponType = GetWeaponTypeFromModel(iModel); + Command(hplayer, weaponType, m_nAmmoCount); + Command(iModel); #ifdef GTA3 - Command(0, weaponType); + Command(0, weaponType); #endif } #endif void Weapon::Draw() { - CPlayerPed *pPlayer = FindPlayerPed(); - uint hplayer = CPools::GetPedRef(pPlayer); + CPlayerPed* pPlayer = FindPlayerPed(); + uint hplayer = CPools::GetPedRef(pPlayer); - ImGui::Spacing(); - if (ImGui::Button("Drop weapon", Ui::GetSize(3))) - { - float x, y, z; - Command(hplayer, 0.0, 3.0, 0.0, &x, &y, &z); + ImGui::Spacing(); + if (ImGui::Button("Drop weapon", Ui::GetSize(3))) + { + float x, y, z; + Command(hplayer, 0.0, 3.0, 0.0, &x, &y, &z); #ifdef GTA3 - eWeaponType weaponType = pPlayer->m_aWeapons[pPlayer->m_nCurrentWeapon].m_eWeaponType; + eWeaponType weaponType = pPlayer->m_aWeapons[pPlayer->m_nCurrentWeapon].m_eWeaponType; #else - eWeaponType weaponType = pPlayer->m_aWeapons[pPlayer->m_nActiveWeaponSlot].m_nType; + eWeaponType weaponType = pPlayer->m_aWeapons[pPlayer->m_nActiveWeaponSlot].m_nType; #endif - if (weaponType) - { - int model = 0, pickup = 0; + if (weaponType) + { + int model = 0, pickup = 0; #ifdef GTASA - Command(weaponType, &model); + Command(weaponType, &model); #else // GTA3 & GTAVC - model = CallAndReturn( - weaponType); // int __cdecl CPickups::ModelForWeapon(int a1) + model = CallAndReturn(weaponType); // int __cdecl CPickups::ModelForWeapon(int a1) #endif - Command(model, 3, 999, x, y, z, &pickup); + Command(model, 3, 999, x, y, z, &pickup); #ifdef GTASA - Command(hplayer, weaponType); + Command(hplayer, weaponType); #else // GTA3 & GTAVC - ClearPlayerWeapon(weaponType); + ClearPlayerWeapon(weaponType); #endif - } - } - ImGui::SameLine(); - if (ImGui::Button("Remove all", Ui::GetSize(3))) - { - pPlayer->ClearWeapons(); - } + } + } + ImGui::SameLine(); + if (ImGui::Button("Remove all", Ui::GetSize(3))) + { + pPlayer->ClearWeapons(); + } - ImGui::SameLine(); - if (ImGui::Button("Remove current", Ui::GetSize(3))) - { + ImGui::SameLine(); + if (ImGui::Button("Remove current", Ui::GetSize(3))) + { #ifdef GTASA - Command(hplayer, pPlayer->m_aWeapons[pPlayer->m_nActiveWeaponSlot].m_nType); + Command(hplayer, pPlayer->m_aWeapons[pPlayer->m_nActiveWeaponSlot].m_nType); #elif GTAVC - ClearPlayerWeapon(pPlayer->m_aWeapons[pPlayer->m_nActiveWeaponSlot].m_nType); + ClearPlayerWeapon(pPlayer->m_aWeapons[pPlayer->m_nActiveWeaponSlot].m_nType); #else // GTA3 - ClearPlayerWeapon(pPlayer->m_aWeapons[pPlayer->m_nCurrentWeapon].m_eWeaponType); + ClearPlayerWeapon(pPlayer->m_aWeapons[pPlayer->m_nCurrentWeapon].m_eWeaponType); #endif - } - ImGui::Spacing(); + } + ImGui::Spacing(); - if (ImGui::BeginTabBar("Ped", ImGuiTabBarFlags_NoTooltip + ImGuiTabBarFlags_FittingPolicyScroll)) - { - if (ImGui::BeginTabItem("Checkboxes")) - { - ImGui::Spacing(); - ImGui::BeginChild("CheckboxesChild"); - ImGui::Spacing(); - ImGui::SameLine(); - ImGui::Text("Info"); - Ui::ShowTooltip("Weapon tweaks apply globally\nto every ped weapon type"); - ImGui::Columns(2, 0, false); + if (ImGui::BeginTabBar("Ped", ImGuiTabBarFlags_NoTooltip + ImGuiTabBarFlags_FittingPolicyScroll)) + { + if (ImGui::BeginTabItem("Checkboxes")) + { + ImGui::Spacing(); + ImGui::BeginChild("CheckboxesChild"); + ImGui::Spacing(); + ImGui::SameLine(); + ImGui::Text("Info"); + Ui::ShowTooltip("Weapon tweaks apply globally\nto every ped weapon type"); + ImGui::Columns(2, 0, false); #ifdef GTASA - Ui::CheckboxWithHint("Fast aim", &m_bAutoAim, - "Enables aim assist on keyboard\n\nQ = left E = right\n\nPress Q and E to switch " - "targets.\nMoving mouse removes the target!"); - if (Ui::CheckboxWithHint("Dual wield", &m_bDualWeild, - "Dual wield pistol, shawoff, uzi, tec9\n(Other weapons don't work)")) - { - if (!m_bDualWeild) - { - CWeaponInfo::LoadWeaponData(); - } - } + Ui::CheckboxWithHint("Fast aim", &m_bAutoAim, "Enables aim assist on keyboard\n\nQ = left E = right\n\nPress Q and E to switch targets.\nMoving mouse removes the target!"); + if (Ui::CheckboxWithHint("Dual wield", &m_bDualWeild, + "Dual wield pistol, shawoff, uzi, tec9\n(Other weapons don't work)")) + { + if (!m_bDualWeild) + { + CWeaponInfo::LoadWeaponData(); + } + } #endif - if (Ui::CheckboxWithHint("Huge damage", &m_bHugeDamage, - "Also enable 'Long range' if weapon range is short")) - { - if (!m_bHugeDamage) - { - CWeaponInfo::LoadWeaponData(); - } - } - if (Ui::CheckboxWithHint("Fast reload", &m_bFastReload)) - { - Command(hplayer, m_bFastReload); - } + if (Ui::CheckboxWithHint("Huge damage", &m_bHugeDamage, "Also enable 'Long range' if weapon range is short")) + { + if (!m_bHugeDamage) + { + CWeaponInfo::LoadWeaponData(); + } + } + if (Ui::CheckboxWithHint("Fast reload", &m_bFastReload)) + { + Command(hplayer, m_bFastReload); + } #ifdef GTASA - Ui::CheckboxAddress("Infinite ammo", 0x969178); - ImGui::NextColumn(); + Ui::CheckboxAddress("Infinite ammo", 0x969178); + ImGui::NextColumn(); #else - ImGui::NextColumn(); - Ui::CheckboxWithHint("Infinite ammo", &m_bInfiniteAmmo); + ImGui::NextColumn(); + Ui::CheckboxWithHint("Infinite ammo", &m_bInfiniteAmmo); #endif - if (Ui::CheckboxWithHint("Long range", &m_bLongRange)) - { - if (!m_bLongRange) - { - CWeaponInfo::LoadWeaponData(); - } - } + if (Ui::CheckboxWithHint("Long range", &m_bLongRange)) + { + if (!m_bLongRange) + { + CWeaponInfo::LoadWeaponData(); + } + } #ifdef GTASA - if (Ui::CheckboxWithHint("Move when aiming", &m_bMoveAim)) - { - if (!m_bMoveAim) - { - CWeaponInfo::LoadWeaponData(); - } - } - if (Ui::CheckboxWithHint("Move when firing", &m_bMoveFire)) - { - if (!m_bMoveFire) - { - CWeaponInfo::LoadWeaponData(); - } - } - if (Ui::CheckboxWithHint("Rapid fire", &m_bRapidFire)) - { - if (!m_bRapidFire) - { - CWeaponInfo::LoadWeaponData(); - } - } + if (Ui::CheckboxWithHint("Move when aiming", &m_bMoveAim)) + { + if (!m_bMoveAim) + { + CWeaponInfo::LoadWeaponData(); + } + } + if (Ui::CheckboxWithHint("Move when firing", &m_bMoveFire)) + { + if (!m_bMoveFire) + { + CWeaponInfo::LoadWeaponData(); + } + } + if (Ui::CheckboxWithHint("Rapid fire", &m_bRapidFire)) + { + if (!m_bRapidFire) + { + CWeaponInfo::LoadWeaponData(); + } + } #endif - ImGui::Columns(1, 0, false); - ImGui::EndChild(); - ImGui::EndTabItem(); - } - if (ImGui::BeginTabItem("Spawn")) - { - ImGui::Spacing(); - if (ImGui::InputInt("Ammo", &m_nAmmoCount)) - { - m_nAmmoCount = (m_nAmmoCount < 0) ? 0 : m_nAmmoCount; - m_nAmmoCount = (m_nAmmoCount > 99999) ? 99999 : m_nAmmoCount; - } + ImGui::Columns(1, 0, false); + ImGui::EndChild(); + ImGui::EndTabItem(); + } + if (ImGui::BeginTabItem("Spawn")) + { + ImGui::Spacing(); + if (ImGui::InputInt("Ammo", &m_nAmmoCount)) + { + m_nAmmoCount = (m_nAmmoCount < 0) ? 0 : m_nAmmoCount; + m_nAmmoCount = (m_nAmmoCount > 99999) ? 99999 : m_nAmmoCount; + } #ifdef GTASA - Ui::DrawImages( - m_WeaponData, GiveWeaponToPlayer, nullptr, - [](std::string str) { return m_WeaponData.m_pJson->m_Data[str].get(); }, - [](std::string str) { - return str != "0"; /*Unarmed*/ - }); + Ui::DrawImages(m_WeaponData, GiveWeaponToPlayer, nullptr, + [](std::string str) { return m_WeaponData.m_pJson->m_Data[str].get(); }, + [](std::string str) { return str != "0"; /*Unarmed*/ } + ); #else // GTA3 & GTAVC - Ui::DrawJSON(m_WeaponData, GiveWeaponToPlayer, nullptr); + Ui::DrawJSON(m_WeaponData, GiveWeaponToPlayer, nullptr); #endif - ImGui::EndTabItem(); - } + ImGui::EndTabItem(); + } #ifdef GTASA - if (ImGui::BeginTabItem("Gang weapon editor")) - { - ImGui::Spacing(); - Ui::ListBox("Select gang", Ped::m_GangNames, m_nSelectedGang); + if (ImGui::BeginTabItem("Gang weapon editor")) + { + ImGui::Spacing(); + Ui::ListBox("Select gang", Ped::m_GangNames, m_nSelectedGang); - ImGui::Columns(3, 0, false); - ImGui::RadioButton("Weap 1", &m_nSelectedWeapon, 0); - ImGui::NextColumn(); - ImGui::RadioButton("Weap 2", &m_nSelectedWeapon, 1); - ImGui::NextColumn(); - ImGui::RadioButton("Weap 3", &m_nSelectedWeapon, 2); - ImGui::Columns(1); + ImGui::Columns(3, 0, false); + ImGui::RadioButton("Weap 1", &m_nSelectedWeapon, 0); + ImGui::NextColumn(); + ImGui::RadioButton("Weap 2", &m_nSelectedWeapon, 1); + ImGui::NextColumn(); + ImGui::RadioButton("Weap 3", &m_nSelectedWeapon, 2); + ImGui::Columns(1); - ImGui::Spacing(); - ImGui::Text( - "Current weapon: %s", - m_WeaponData.m_pJson->m_Data[std::to_string(m_nGangWeaponList[m_nSelectedGang][m_nSelectedWeapon])] - .get() - .c_str()); - ImGui::Spacing(); - Ui::DrawImages( - m_WeaponData, SetGangWeapon, nullptr, - [](std::string str) { return m_WeaponData.m_pJson->m_Data[str].get(); }, - [](std::string str) { - return str != "-1"; /*Jetpack*/ - }); - ImGui::EndTabItem(); - } + ImGui::Spacing(); + ImGui::Text("Current weapon: %s", + m_WeaponData.m_pJson->m_Data[std::to_string(m_nGangWeaponList[m_nSelectedGang][m_nSelectedWeapon])].get< + std::string>().c_str()); + ImGui::Spacing(); + Ui::DrawImages(m_WeaponData, SetGangWeapon, nullptr, + [](std::string str) { return m_WeaponData.m_pJson->m_Data[str].get(); }, + [](std::string str) { return str != "-1"; /*Jetpack*/ } + ); + ImGui::EndTabItem(); + } #endif - ImGui::EndTabBar(); - } + ImGui::EndTabBar(); + } } diff --git a/src/weapon.h b/src/weapon.h index 8765760..d33c69e 100644 --- a/src/weapon.h +++ b/src/weapon.h @@ -5,51 +5,52 @@ class Weapon { public: #ifdef GTASA - static inline ResourceStore m_WeaponData{"weapon", eResourceType::TYPE_BOTH, ImVec2(65, 65)}; + static inline ResourceStore m_WeaponData{ "weapon", eResourceType::TYPE_BOTH, ImVec2(65, 65) }; - static inline bool m_bAutoAim; - static inline bool m_bRapidFire; - static inline bool m_bDualWeild; - static inline bool m_bMoveAim; - static inline bool m_bMoveFire; - static inline int m_nSelectedGang; + static inline bool m_bAutoAim; + static inline bool m_bRapidFire; + static inline bool m_bDualWeild; + static inline bool m_bMoveAim; + static inline bool m_bMoveFire; + static inline int m_nSelectedGang; #else // GTA3 & GTAVC - static inline ResourceStore m_WeaponData{"weapon", eResourceType::TYPE_TEXT}; - static inline bool m_bInfiniteAmmo; + static inline ResourceStore m_WeaponData{ "weapon", eResourceType::TYPE_TEXT }; + static inline bool m_bInfiniteAmmo; #endif - static inline bool m_bFastReload; - static inline bool m_bHugeDamage; - static inline bool m_bLongRange; - static inline int m_nAmmoCount = 99999; - static inline uchar m_nCurrentWeaponSlot = -1; - static inline int m_nSelectedWeapon; - + static inline bool m_bFastReload; + static inline bool m_bHugeDamage; + static inline bool m_bLongRange; + static inline int m_nAmmoCount = 99999; + static inline uchar m_nCurrentWeaponSlot = -1; + static inline int m_nSelectedWeapon; + #ifdef GTASA - static inline int m_nGangWeaponList[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 - }; + static inline int m_nGangWeaponList[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 + }; #endif - Weapon(); + Weapon(); - static void Draw(); + static void Draw(); #ifdef GTASA - static void GiveWeaponToPlayer(std::string &weapon_type); + static void GiveWeaponToPlayer(std::string& weapon_type); #else // GTA3 & GTAVC - static void GiveWeaponToPlayer(std::string &rootkey, std::string &model, std::string &name); + static void GiveWeaponToPlayer(std::string& rootkey, std::string& model, std::string& name); #endif - + #ifdef GTASA - static void SetGangWeapon(std::string &weapon_type); + static void SetGangWeapon(std::string& weapon_type); #endif }; diff --git a/tools/premake5.lua b/tools/premake5.lua index 3adb2e3..4a45ee3 100644 --- a/tools/premake5.lua +++ b/tools/premake5.lua @@ -88,6 +88,9 @@ project "CheatMenuIII" "../src/weapon.cpp", "../src/game.h", "../src/game.cpp", + "../src/timecyc.h", + "../src/visual.h", + "../src/visual.cpp", "../src/filehandler.h", "../src/filehandler.cpp", "../src/dllmain.cpp"