diff --git a/.vscode/tasks.json b/.vscode/tasks.json index 315c4ed..6496d05 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -246,5 +246,32 @@ } }, }, + { + "label": "Format Code", + "type": "shell", + "command": "${workspaceFolder}/tools/FormatCode.bat", + "presentation": { + "echo": true, + "reveal": "always", + "focus": false, + "panel": "shared", + "showReuseMessage": false, + "clear": true + }, + "group": { + "kind": "build", + "isDefault": true + }, + "windows": { + "options": { + "shell": { + "executable": "cmd.exe", + "args": [ + "/d", "/c" + ] + } + } + }, + }, ] } \ No newline at end of file diff --git a/src/animation.cpp b/src/animation.cpp index cfedcbe..1675ee9 100644 --- a/src/animation.cpp +++ b/src/animation.cpp @@ -18,23 +18,23 @@ #ifdef GTASA 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); } #elif GTAVC @@ -43,321 +43,321 @@ void Animation::PlayCutscene(std::string& rootKey, std::string& cutsceneId, std: static auto OLD_CStreaming_RemoveModel = (bool(__cdecl*)(int))0x40D6E0; static bool NEW_CStreaming_RemoveModel(int modelID) { - // Check if it's IFP animation block - if (modelID >= 7916 && modelID <= 7950) - { - // Do not unload the animation block - return true; - } - return OLD_CStreaming_RemoveModel(modelID); + // Check if it's IFP animation block + if (modelID >= 7916 && modelID <= 7950) + { + // Do not unload the animation block + return true; + } + return OLD_CStreaming_RemoveModel(modelID); } void Animation::_PlayAnimation(RpClump* pClump, int animGroup, int animID, float blend) { - if (animGroup < CAnimManager::ms_numAnimAssocDefinitions) - { - CAnimationStyleDescriptor* pAnimDef = &CAnimManager::ms_aAnimAssocDefinitions[animGroup]; - if (pAnimDef) - { - if (!_LoadAnimationBlock(pAnimDef->blockName)) - { - return; - } - } - } + if (animGroup < CAnimManager::ms_numAnimAssocDefinitions) + { + CAnimationStyleDescriptor* pAnimDef = &CAnimManager::ms_aAnimAssocDefinitions[animGroup]; + if (pAnimDef) + { + if (!_LoadAnimationBlock(pAnimDef->blockName)) + { + return; + } + } + } - CAnimBlendAssociation* pAnimAssoc = RpAnimBlendClumpGetFirstAssociation(pClump); - while (pAnimAssoc) - { - if (pAnimAssoc->m_nAnimId == animID && pAnimAssoc->m_nAnimGroup == animGroup) - { - // Destroy the animation - pAnimAssoc->~CAnimBlendAssociation(); - break; - } - pAnimAssoc = RpAnimBlendGetNextAssociation(pAnimAssoc); - } - pAnimAssoc = CAnimManager::BlendAnimation(pClump, animGroup, animID, blend); - pAnimAssoc->m_nFlags = ANIMATION_STARTED | ANIMATION_MOVEMENT; - - if (m_Loop) - { - pAnimAssoc->m_nFlags |= ANIMATION_LOOPED; - } + CAnimBlendAssociation* pAnimAssoc = RpAnimBlendClumpGetFirstAssociation(pClump); + while (pAnimAssoc) + { + if (pAnimAssoc->m_nAnimId == animID && pAnimAssoc->m_nAnimGroup == animGroup) + { + // Destroy the animation + pAnimAssoc->~CAnimBlendAssociation(); + break; + } + pAnimAssoc = RpAnimBlendGetNextAssociation(pAnimAssoc); + } + pAnimAssoc = CAnimManager::BlendAnimation(pClump, animGroup, animID, blend); + pAnimAssoc->m_nFlags = ANIMATION_STARTED | ANIMATION_MOVEMENT; - if (m_bSecondary) - { - pAnimAssoc->m_nFlags |= ANIMATION_PARTIAL; - } + if (m_Loop) + { + pAnimAssoc->m_nFlags |= ANIMATION_LOOPED; + } + + if (m_bSecondary) + { + pAnimAssoc->m_nFlags |= ANIMATION_PARTIAL; + } } bool Animation::_LoadAnimationBlock(const char* szBlockName) { - CAnimBlock* pAnimBlock = CAnimManager::GetAnimationBlock(szBlockName); - if (pAnimBlock) - { - if (!pAnimBlock->bLoaded) - { - int animIndex = ((unsigned char*)pAnimBlock - (unsigned char*)CAnimManager::ms_aAnimBlocks) / 32; - CStreaming::RequestModel(7916 + animIndex, 0x20 | MISSION_REQUIRED | PRIORITY_REQUEST); - CStreaming::LoadAllRequestedModels(true); - if (pAnimBlock->bLoaded) - { - return true; - } - } - else - { - return true; - } - } - return false; + CAnimBlock* pAnimBlock = CAnimManager::GetAnimationBlock(szBlockName); + if (pAnimBlock) + { + if (!pAnimBlock->bLoaded) + { + int animIndex = ((unsigned char*)pAnimBlock - (unsigned char*)CAnimManager::ms_aAnimBlocks) / 32; + CStreaming::RequestModel(7916 + animIndex, 0x20 | MISSION_REQUIRED | PRIORITY_REQUEST); + CStreaming::LoadAllRequestedModels(true); + if (pAnimBlock->bLoaded) + { + return true; + } + } + else + { + return true; + } + } + return false; } -#else // GTA III +#else void Animation::_PlayAnimation(RpClump* pClump, int animGroup, int animID, float blend) { - CAnimBlendAssociation* pAnimStaticAssoc = CAnimManager::GetAnimAssociation((AssocGroupId)animGroup, (AnimationId)animID); - CAnimBlendAssociation* pAnimAssoc = RpAnimBlendClumpGetFirstAssociation(pClump); - while (pAnimAssoc) - { - if (pAnimAssoc->m_nAnimID == pAnimStaticAssoc->m_nAnimID && pAnimAssoc->m_pAnimBlendHierarchy == pAnimStaticAssoc->m_pAnimBlendHierarchy) - { - // Destroy the animation - pAnimAssoc->FreeAnimBlendNodeArray(); - break; - } - pAnimAssoc = RpAnimBlendGetNextAssociation(pAnimAssoc); - } - pAnimAssoc = CAnimManager::BlendAnimation(pClump, (AssocGroupId)animGroup, (AnimationId)animID, blend); - pAnimAssoc->m_nFlags = 0x1 | 0x20; - - if (m_Loop) - { - pAnimAssoc->m_nFlags |= 0x2; - } + CAnimBlendAssociation* pAnimStaticAssoc = CAnimManager::GetAnimAssociation((AssocGroupId)animGroup, (AnimationId)animID); + CAnimBlendAssociation* pAnimAssoc = RpAnimBlendClumpGetFirstAssociation(pClump); + while (pAnimAssoc) + { + if (pAnimAssoc->m_nAnimID == pAnimStaticAssoc->m_nAnimID && pAnimAssoc->m_pAnimBlendHierarchy == pAnimStaticAssoc->m_pAnimBlendHierarchy) + { + // Destroy the animation + pAnimAssoc->FreeAnimBlendNodeArray(); + break; + } + pAnimAssoc = RpAnimBlendGetNextAssociation(pAnimAssoc); + } + pAnimAssoc = CAnimManager::BlendAnimation(pClump, (AssocGroupId)animGroup, (AnimationId)animID, blend); + pAnimAssoc->m_nFlags = 0x1 | 0x20; - if (m_bSecondary) - { - pAnimAssoc->m_nFlags |= 0x10; - } + if (m_Loop) + { + pAnimAssoc->m_nFlags |= 0x2; + } + + if (m_bSecondary) + { + pAnimAssoc->m_nFlags |= 0x10; + } } #endif void Animation::PlayAnimation(std::string& ifp, std::string& anim, std::string& value) { - CPlayerPed *pPlayer = FindPlayerPed(); + CPlayerPed *pPlayer = FindPlayerPed(); - if (!pPlayer) - { - return; - } + if (!pPlayer) + { + return; + } #ifdef GTASA - int hplayer = CPools::GetPedRef(pPlayer); + int hplayer = CPools::GetPedRef(pPlayer); - 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()); + } -#else // GTA VC & III - if (pPlayer) - { - int groupID, animID; - sscanf(value.c_str(), "%d$%d,", &groupID, &animID); - _PlayAnimation(pPlayer->m_pRwClump, groupID, animID, 4.0f); - } +#else + if (pPlayer) + { + int groupID, animID; + sscanf(value.c_str(), "%d$%d,", &groupID, &animID); + _PlayAnimation(pPlayer->m_pRwClump, groupID, animID, 4.0f); + } #endif } Animation::Animation() { #ifdef GTASA - 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; + } + } + }; #elif GTAVC - // mov al, 01 - // ret - // nop (2x) - patch::SetRaw(0x40C9C0, (void*)"\xB0\x01\xC3\x90\x90", 5); - // // ret - // // nop (3x) - patch::SetRaw(0x404950, (void*)"\xC3\x90\x90\x90", 4); - - MH_CreateHook((void*)0x40D6E0, NEW_CStreaming_RemoveModel, (void**)&OLD_CStreaming_RemoveModel); - MH_EnableHook((void*)0x40D6E0); + // mov al, 01 + // ret + // nop (2x) + patch::SetRaw(0x40C9C0, (void*)"\xB0\x01\xC3\x90\x90", 5); + // // ret + // // nop (3x) + patch::SetRaw(0x404950, (void*)"\xC3\x90\x90\x90", 4); + + MH_CreateHook((void*)0x40D6E0, NEW_CStreaming_RemoveModel, (void**)&OLD_CStreaming_RemoveModel); + MH_EnableHook((void*)0x40D6E0); #endif } 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) - { + if (ImGui::BeginTabItem("Anims")) + { + ImGui::Spacing(); + if (ImGui::Button("Stop animation", Ui::GetSize())) + { + if (hPlayer) + { #ifdef GTASA - Command(hPlayer); + Command(hPlayer); #else - _PlayAnimation(pPlayer->m_pRwClump, ANIM_GROUP_MAN, ANIM_MAN_IDLE_STANCE, 4.0f); + _PlayAnimation(pPlayer->m_pRwClump, ANIM_GROUP_MAN, ANIM_MAN_IDLE_STANCE, 4.0f); #endif - } - } + } + } - 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::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::BeginChild("Anims Child")) + { + ImGui::Spacing(); + Ui::DrawJSON(m_AnimData, PlayAnimation, RemoveAnimation); + ImGui::EndChild(); + } + 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(); + } #ifdef GTASA - 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("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("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("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(); - } + if (ImGui::BeginChild("Cutscene Child")) + { + ImGui::Spacing(); + Ui::DrawJSON(m_Cutscene::m_Data, PlayCutscene, nullptr); + ImGui::EndChild(); + } + ImGui::EndTabItem(); + } #endif - ImGui::EndTabBar(); - } + ImGui::EndTabBar(); + } } 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); + } } \ No newline at end of file diff --git a/src/animation.h b/src/animation.h index d8ad036..ef77b02 100644 --- a/src/animation.h +++ b/src/animation.h @@ -5,50 +5,50 @@ 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 + // 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 #ifdef GTASA - // 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; - }; + // 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" - }; + 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" + }; #endif protected: - Animation(); + Animation(); public: - static void Draw(); - static void PlayAnimation(std::string& rootKey, std::string& anim, std::string& ifp); - static void RemoveAnimation(std::string& rootKey, std::string& anim, std::string& ifp); + static void Draw(); + static void PlayAnimation(std::string& rootKey, std::string& anim, std::string& ifp); + static void RemoveAnimation(std::string& rootKey, std::string& anim, std::string& ifp); #ifdef GTASA - static void PlayCutscene(std::string& rootKey, std::string& cutsceneId, std::string& interior); + static void PlayCutscene(std::string& rootKey, std::string& cutsceneId, std::string& interior); #elif GTAVC - static bool _LoadAnimationBlock(const char* szBlockName); + static bool _LoadAnimationBlock(const char* szBlockName); #endif #ifndef GTASA - static void _PlayAnimation(RpClump* pClump, int animGroup, int animID, float blend); + static void _PlayAnimation(RpClump* pClump, int animGroup, int animID, float blend); #endif }; \ No newline at end of file diff --git a/src/cheatmenu.cpp b/src/cheatmenu.cpp index cce0e1a..5a6f65f 100644 --- a/src/cheatmenu.cpp +++ b/src/cheatmenu.cpp @@ -6,255 +6,255 @@ 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) - { - ImGui::SetNextWindowSize(m_fMenuSize); + 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) + { + ImGui::SetNextWindowSize(m_fMenuSize); - if (ImGui::Begin(MENU_TITLE, NULL, ImGuiWindowFlags_NoCollapse || ImGuiWindowFlags_NoTitleBar)) - { - m_bShowMenu = !Ui::DrawTitleBar(); - ImGui::PushStyleVar(ImGuiStyleVar_WindowMinSize, ImVec2(250, 350)); - ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, - ImVec2(ImGui::GetWindowWidth() / 85, ImGui::GetWindowHeight() / 200)); + if (ImGui::Begin(MENU_TITLE, NULL, ImGuiWindowFlags_NoCollapse || ImGuiWindowFlags_NoTitleBar)) + { + m_bShowMenu = !Ui::DrawTitleBar(); + ImGui::PushStyleVar(ImGuiStyleVar_WindowMinSize, ImVec2(250, 350)); + ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, + ImVec2(ImGui::GetWindowWidth() / 85, ImGui::GetWindowHeight() / 200)); - if (Updater::IsUpdateAvailable()) - { - ShowUpdateScreen(); - } - else - { - Ui::DrawHeaders(header); - - if (Ui::m_HeaderId == -1) - { - ShowWelcomeScreen(); - } - } + if (Updater::IsUpdateAvailable()) + { + ShowUpdateScreen(); + } + else + { + Ui::DrawHeaders(header); - if (m_bSizeChangedExternal) - { - m_bSizeChangedExternal = false; - } - else - { - m_fMenuSize = ImGui::GetWindowSize(); - } - gConfig.SetValue("window.sizeX", m_fMenuSize.x); - gConfig.SetValue("window.sizeY", m_fMenuSize.y); + if (Ui::m_HeaderId == -1) + { + ShowWelcomeScreen(); + } + } - ImGui::PopStyleVar(2); - ImGui::End(); - } - } + if (m_bSizeChangedExternal) + { + m_bSizeChangedExternal = false; + } + else + { + m_fMenuSize = ImGui::GetWindowSize(); + } + gConfig.SetValue("window.sizeX", m_fMenuSize.x); + gConfig.SetValue("window.sizeY", m_fMenuSize.y); + + ImGui::PopStyleVar(2); + ImGui::End(); + } + } #ifdef GTASA - else - { - DrawShortcutsWindow(); - } + else + { + DrawShortcutsWindow(); + } #endif - } - } - DrawOverlay(); + } + } + DrawOverlay(); } CheatMenu::CheatMenu() { - ImGui::CreateContext(); - ApplyStyle(); - pCallbackFunc = std::bind(&DrawWindow); + ImGui::CreateContext(); + ApplyStyle(); + pCallbackFunc = std::bind(&DrawWindow); - // Load menu settings - Ui::m_HeaderId = gConfig.GetValue("window.idnum", -1); - 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.idnum", -1); + 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::ShowWelcomeScreen() { - ImGui::BeginChild("WelcomeScreen"); - ImGui::NewLine(); + ImGui::BeginChild("WelcomeScreen"); + ImGui::NewLine(); - Ui::CenterdText("Welcome to Cheat Menu"); - Ui::CenterdText("Author: Grinch_"); + Ui::CenterdText("Welcome to Cheat Menu"); + Ui::CenterdText("Author: Grinch_"); - ImGui::NewLine(); - ImGui::TextWrapped("Please ensure you have the latest version from GitHub."); - ImGui::NewLine(); - if (ImGui::Button("Discord server", ImVec2(Ui::GetSize(2)))) - { - ShellExecute(nullptr, "open", DISCORD_INVITE, nullptr, nullptr, SW_SHOWNORMAL); - } + ImGui::NewLine(); + ImGui::TextWrapped("Please ensure you have the latest version from GitHub."); + ImGui::NewLine(); + if (ImGui::Button("Discord server", ImVec2(Ui::GetSize(2)))) + { + ShellExecute(nullptr, "open", DISCORD_INVITE, nullptr, nullptr, SW_SHOWNORMAL); + } - ImGui::SameLine(); + ImGui::SameLine(); - if (ImGui::Button("GitHub repo", ImVec2(Ui::GetSize(2)))) - { - ShellExecute(nullptr, "open", GITHUB_LINK, nullptr, nullptr, SW_SHOWNORMAL); - } + if (ImGui::Button("GitHub repo", ImVec2(Ui::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)); - Ui::CenterdText("Copyright Grinch_ 2019-2022. All rights reserved."); - ImGui::EndChild(); + ImGui::NewLine(); + ImGui::TextWrapped("If you find bugs or have suggestions, you can let me know on discord :)"); + ImGui::Dummy(ImVec2(0, 30)); + Ui::CenterdText("Copyright Grinch_ 2019-2022. All rights reserved."); + ImGui::EndChild(); } void CheatMenu::ShowUpdateScreen() { - ImGui::BeginChild("UPdateScreen"); - std::string ver = Updater::GetUpdateVersion(); - 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: " + ver); - 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::BeginChild("UPdateScreen"); + std::string ver = Updater::GetUpdateVersion(); + 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: " + ver); + 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/" + - ver).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/" + + ver).c_str(), NULL, NULL, SW_SHOWNORMAL); + } - ImGui::SameLine(); + ImGui::SameLine(); - if (ImGui::Button("Hide page", Ui::GetSize(3))) - { - Updater::ResetUpdaterState(); - } - ImGui::EndChild(); + if (ImGui::Button("Hide page", Ui::GetSize(3))) + { + Updater::ResetUpdaterState(); + } + ImGui::EndChild(); } void CheatMenu::ApplyStyle() { - ImGuiStyle* style = &ImGui::GetStyle(); - ImVec4* colors = style->Colors; + ImGuiStyle* style = &ImGui::GetStyle(); + ImVec4* colors = style->Colors; - style->WindowPadding = ImVec2(8, 8); - style->WindowRounding = 5.0f; - style->FramePadding = ImVec2(8, 8); - style->FrameRounding = 5.0f; - style->PopupRounding = 5.0f; - style->ItemSpacing = ImVec2(7, 7); - style->ItemInnerSpacing = ImVec2(7, 7); - style->IndentSpacing = 25.0f; - style->ScrollbarSize = 12.0f; - style->ScrollbarRounding = 10.0f; - style->GrabMinSize = 5.0f; - style->GrabRounding = 3.0f; + style->WindowPadding = ImVec2(8, 8); + style->WindowRounding = 5.0f; + style->FramePadding = ImVec2(8, 8); + style->FrameRounding = 5.0f; + style->PopupRounding = 5.0f; + style->ItemSpacing = ImVec2(7, 7); + style->ItemInnerSpacing = ImVec2(7, 7); + style->IndentSpacing = 25.0f; + style->ScrollbarSize = 12.0f; + style->ScrollbarRounding = 10.0f; + style->GrabMinSize = 5.0f; + style->GrabRounding = 3.0f; - style->ChildBorderSize = 0; - style->WindowBorderSize = 0; - style->FrameBorderSize = 0; - style->TabBorderSize = 0; - style->PopupBorderSize = 0; + style->ChildBorderSize = 0; + style->WindowBorderSize = 0; + style->FrameBorderSize = 0; + style->TabBorderSize = 0; + style->PopupBorderSize = 0; - style->Colors[ImGuiCol_Text] = ImVec4(0.80f, 0.80f, 0.83f, 1.00f); - style->Colors[ImGuiCol_TextDisabled] = ImVec4(0.35f, 0.33f, 0.3f, 1.00f); - style->Colors[ImGuiCol_WindowBg] = ImVec4(0.06f, 0.05f, 0.06f, 0.95f); - style->Colors[ImGuiCol_ChildBg] = ImVec4(0.0f, 0.0f, 0.0f, 0.0f); - style->Colors[ImGuiCol_PopupBg] = ImVec4(0.06f, 0.05f, 0.06f, 0.95f); - style->Colors[ImGuiCol_Border] = ImVec4(0.12f, 0.12f, 0.12f, 1.0f); - style->Colors[ImGuiCol_BorderShadow] = ImVec4(0.20f, 0.20f, 0.20f, 1.00f); - style->Colors[ImGuiCol_FrameBg] = ImVec4(0.15f, 0.15f, 0.15f, 0.95f); - style->Colors[ImGuiCol_FrameBgHovered] = ImVec4(0.25f, 0.25f, 0.25f, 1.00f); - style->Colors[ImGuiCol_FrameBgActive] = ImVec4(0.20f, 0.20f, 0.20f, 1.00f); - style->Colors[ImGuiCol_TitleBg] = ImVec4(0.12f, 0.12f, 0.12f, 0.94f); - style->Colors[ImGuiCol_TitleBgCollapsed] = ImVec4(1.00f, 0.98f, 0.95f, 0.75f); - style->Colors[ImGuiCol_TitleBgActive] = ImVec4(0.07f, 0.07f, 0.09f, 1.00f); - style->Colors[ImGuiCol_MenuBarBg] = ImVec4(0.15f, 0.15f, 0.15f, 0.95f); - style->Colors[ImGuiCol_ScrollbarBg] = ImVec4(0.15f, 0.15f, 0.15f, 0.95f); - style->Colors[ImGuiCol_ScrollbarGrab] = ImVec4(0.5f, 0.5f, 0.5f, 0.3f); - style->Colors[ImGuiCol_ScrollbarGrabHovered] = ImVec4(0.7f, 0.7f, 0.7f, 0.3f); - style->Colors[ImGuiCol_ScrollbarGrabActive] = ImVec4(0.9f, 0.9f, 0.9f, 0.3f); - style->Colors[ImGuiCol_CheckMark] = ImVec4(0.80f, 0.80f, 0.83f, 0.31f); - style->Colors[ImGuiCol_SliderGrab] = ImVec4(0.80f, 0.80f, 0.83f, 0.31f); - style->Colors[ImGuiCol_SliderGrabActive] = ImVec4(0.80f, 0.80f, 0.83f, 0.31f); - style->Colors[ImGuiCol_Separator] = ImVec4(0.15f, 0.15f, 0.15f, 0.95f); - style->Colors[ImGuiCol_Button] = ImVec4(0.15f, 0.15f, 0.15f, 0.95f); - style->Colors[ImGuiCol_ButtonHovered] = ImVec4(0.25f, 0.25f, 0.25f, 1.00f); - style->Colors[ImGuiCol_ButtonActive] = ImVec4(0.20f, 0.20f, 0.20f, 1.00f); - style->Colors[ImGuiCol_Tab] = ImVec4(0.15f, 0.15f, 0.15f, 0.95f); - style->Colors[ImGuiCol_TabHovered] = ImVec4(0.25f, 0.25f, 0.25f, 1.00f); - style->Colors[ImGuiCol_TabActive] = ImVec4(0.20f, 0.20f, 0.20f, 1.00f); - style->Colors[ImGuiCol_Header] = ImVec4(0.0f, 0.0f, 0.0f, 0.0f); - style->Colors[ImGuiCol_HeaderHovered] = ImVec4(0.25f, 0.25f, 0.25f, 1.00f); - style->Colors[ImGuiCol_HeaderActive] = ImVec4(0.06f, 0.05f, 0.07f, 1.00f); - style->Colors[ImGuiCol_ResizeGrip] = ImVec4(0.12f, 0.12f, 0.12f, 0.00f); - style->Colors[ImGuiCol_ResizeGripHovered] = ImVec4(0.25f, 0.25f, 0.25f, 1.00f); - style->Colors[ImGuiCol_ResizeGripActive] = ImVec4(0.20f, 0.20f, 0.20f, 1.00f); - style->Colors[ImGuiCol_PlotLines] = ImVec4(0.40f, 0.39f, 0.38f, 0.63f); - style->Colors[ImGuiCol_PlotLinesHovered] = ImVec4(0.25f, 1.00f, 0.00f, 1.00f); - style->Colors[ImGuiCol_PlotHistogram] = ImVec4(0.40f, 0.39f, 0.38f, 0.63f); - style->Colors[ImGuiCol_PlotHistogramHovered] = ImVec4(0.25f, 1.00f, 0.00f, 1.00f); - style->Colors[ImGuiCol_TextSelectedBg] = ImVec4(0.06f, 0.05f, 0.06f, 0.95f); - style->Colors[ImGuiCol_ModalWindowDimBg] = ImVec4(0.20f, 0.20f, 0.20f, 0.6f); + style->Colors[ImGuiCol_Text] = ImVec4(0.80f, 0.80f, 0.83f, 1.00f); + style->Colors[ImGuiCol_TextDisabled] = ImVec4(0.35f, 0.33f, 0.3f, 1.00f); + style->Colors[ImGuiCol_WindowBg] = ImVec4(0.06f, 0.05f, 0.06f, 0.95f); + style->Colors[ImGuiCol_ChildBg] = ImVec4(0.0f, 0.0f, 0.0f, 0.0f); + style->Colors[ImGuiCol_PopupBg] = ImVec4(0.06f, 0.05f, 0.06f, 0.95f); + style->Colors[ImGuiCol_Border] = ImVec4(0.12f, 0.12f, 0.12f, 1.0f); + style->Colors[ImGuiCol_BorderShadow] = ImVec4(0.20f, 0.20f, 0.20f, 1.00f); + style->Colors[ImGuiCol_FrameBg] = ImVec4(0.15f, 0.15f, 0.15f, 0.95f); + style->Colors[ImGuiCol_FrameBgHovered] = ImVec4(0.25f, 0.25f, 0.25f, 1.00f); + style->Colors[ImGuiCol_FrameBgActive] = ImVec4(0.20f, 0.20f, 0.20f, 1.00f); + style->Colors[ImGuiCol_TitleBg] = ImVec4(0.12f, 0.12f, 0.12f, 0.94f); + style->Colors[ImGuiCol_TitleBgCollapsed] = ImVec4(1.00f, 0.98f, 0.95f, 0.75f); + style->Colors[ImGuiCol_TitleBgActive] = ImVec4(0.07f, 0.07f, 0.09f, 1.00f); + style->Colors[ImGuiCol_MenuBarBg] = ImVec4(0.15f, 0.15f, 0.15f, 0.95f); + style->Colors[ImGuiCol_ScrollbarBg] = ImVec4(0.15f, 0.15f, 0.15f, 0.95f); + style->Colors[ImGuiCol_ScrollbarGrab] = ImVec4(0.5f, 0.5f, 0.5f, 0.3f); + style->Colors[ImGuiCol_ScrollbarGrabHovered] = ImVec4(0.7f, 0.7f, 0.7f, 0.3f); + style->Colors[ImGuiCol_ScrollbarGrabActive] = ImVec4(0.9f, 0.9f, 0.9f, 0.3f); + style->Colors[ImGuiCol_CheckMark] = ImVec4(0.80f, 0.80f, 0.83f, 0.31f); + style->Colors[ImGuiCol_SliderGrab] = ImVec4(0.80f, 0.80f, 0.83f, 0.31f); + style->Colors[ImGuiCol_SliderGrabActive] = ImVec4(0.80f, 0.80f, 0.83f, 0.31f); + style->Colors[ImGuiCol_Separator] = ImVec4(0.15f, 0.15f, 0.15f, 0.95f); + style->Colors[ImGuiCol_Button] = ImVec4(0.15f, 0.15f, 0.15f, 0.95f); + style->Colors[ImGuiCol_ButtonHovered] = ImVec4(0.25f, 0.25f, 0.25f, 1.00f); + style->Colors[ImGuiCol_ButtonActive] = ImVec4(0.20f, 0.20f, 0.20f, 1.00f); + style->Colors[ImGuiCol_Tab] = ImVec4(0.15f, 0.15f, 0.15f, 0.95f); + style->Colors[ImGuiCol_TabHovered] = ImVec4(0.25f, 0.25f, 0.25f, 1.00f); + style->Colors[ImGuiCol_TabActive] = ImVec4(0.20f, 0.20f, 0.20f, 1.00f); + style->Colors[ImGuiCol_Header] = ImVec4(0.0f, 0.0f, 0.0f, 0.0f); + style->Colors[ImGuiCol_HeaderHovered] = ImVec4(0.25f, 0.25f, 0.25f, 1.00f); + style->Colors[ImGuiCol_HeaderActive] = ImVec4(0.06f, 0.05f, 0.07f, 1.00f); + style->Colors[ImGuiCol_ResizeGrip] = ImVec4(0.12f, 0.12f, 0.12f, 0.00f); + style->Colors[ImGuiCol_ResizeGripHovered] = ImVec4(0.25f, 0.25f, 0.25f, 1.00f); + style->Colors[ImGuiCol_ResizeGripActive] = ImVec4(0.20f, 0.20f, 0.20f, 1.00f); + style->Colors[ImGuiCol_PlotLines] = ImVec4(0.40f, 0.39f, 0.38f, 0.63f); + style->Colors[ImGuiCol_PlotLinesHovered] = ImVec4(0.25f, 1.00f, 0.00f, 1.00f); + style->Colors[ImGuiCol_PlotHistogram] = ImVec4(0.40f, 0.39f, 0.38f, 0.63f); + style->Colors[ImGuiCol_PlotHistogramHovered] = ImVec4(0.25f, 1.00f, 0.00f, 1.00f); + style->Colors[ImGuiCol_TextSelectedBg] = ImVec4(0.06f, 0.05f, 0.06f, 0.95f); + style->Colors[ImGuiCol_ModalWindowDimBg] = ImVec4(0.20f, 0.20f, 0.20f, 0.6f); } void CheatMenu::ResetMenuSize() { - m_fMenuSize.x = screen::GetScreenWidth() / 4.0f; - m_fMenuSize.y = screen::GetScreenHeight() / 1.2f; - m_bSizeChangedExternal = true; + m_fMenuSize.x = screen::GetScreenWidth() / 4.0f; + m_fMenuSize.y = screen::GetScreenHeight() / 1.2f; + m_bSizeChangedExternal = true; } diff --git a/src/dllmain.cpp b/src/dllmain.cpp index a1b12e2..9259d21 100644 --- a/src/dllmain.cpp +++ b/src/dllmain.cpp @@ -6,97 +6,97 @@ void MenuThread(void* param) { - static bool gameInit; + static bool gameInit; - // Wait till game init - Events::initRwEvent += [] - { - gameInit = true; - }; + // Wait till game init + Events::initRwEvent += [] + { + gameInit = true; + }; - while (!gameInit) - { - Sleep(1000); - } + while (!gameInit) + { + Sleep(1000); + } - /* - Had to put this in place since some people put the folder in root - directory and the asi in modloader. Why?? - */ - if (!std::filesystem::is_directory(PLUGIN_PATH((char*)"CheatMenu"))) - { - gLog << "Error: CheatMenu folder not found. You need to put both \"CheatMenu.asi\" & \"CheatMenu\" folder in the same directory" << std::endl; - MessageBox(RsGlobal.ps->window, "CheatMenu folder not found. You need to put both \"CheatMenu.asi\" & \"CheatMenu\" folder in the same directory", "CheatMenu", MB_ICONERROR); - return; - } + /* + Had to put this in place since some people put the folder in root + directory and the asi in modloader. Why?? + */ + if (!std::filesystem::is_directory(PLUGIN_PATH((char*)"CheatMenu"))) + { + gLog << "Error: CheatMenu folder not found. You need to put both \"CheatMenu.asi\" & \"CheatMenu\" folder in the same directory" << std::endl; + MessageBox(RsGlobal.ps->window, "CheatMenu folder not found. You need to put both \"CheatMenu.asi\" & \"CheatMenu\" folder in the same directory", "CheatMenu", MB_ICONERROR); + return; + } - /* - Need SilentPatch since all gta games have issues with mouse input - Implementing mouse fix is a headache anyway - */ - if (!GetModuleHandle(BY_GAME("SilentPatchSA.asi" ,"SilentPatchVC.asi" ,"SilentPatchIII.asi"))) - { - gLog << "Error: SilentPatch not found. Please install it from here https://gtaforums.com/topic/669045-silentpatch/" << std::endl; - int msgID = MessageBox(RsGlobal.ps->window, "SilentPatch not found. Do you want to install Silent Patch? (Game restart required)", "CheatMenu", MB_OKCANCEL | MB_DEFBUTTON1); + /* + Need SilentPatch since all gta games have issues with mouse input + Implementing mouse fix is a headache anyway + */ + if (!GetModuleHandle(BY_GAME("SilentPatchSA.asi","SilentPatchVC.asi","SilentPatchIII.asi"))) + { + gLog << "Error: SilentPatch not found. Please install it from here https://gtaforums.com/topic/669045-silentpatch/" << std::endl; + int msgID = MessageBox(RsGlobal.ps->window, "SilentPatch not found. Do you want to install Silent Patch? (Game restart required)", "CheatMenu", MB_OKCANCEL | MB_DEFBUTTON1); - if (msgID == IDOK) - { - ShellExecute(nullptr, "open", "https://gtaforums.com/topic/669045-silentpatch/", nullptr, nullptr, SW_SHOWNORMAL); - }; - return; - } + if (msgID == IDOK) + { + ShellExecute(nullptr, "open", "https://gtaforums.com/topic/669045-silentpatch/", nullptr, nullptr, SW_SHOWNORMAL); + }; + return; + } #ifdef GTASA /* TODO: Find a better way Since you could still name it something else */ - if (GetModuleHandle("SAMP.dll") || GetModuleHandle("SAMP.asi")) - { - gLog << "Error: CheatMenu doesn't support SAMP" << std::endl; - MessageBox(RsGlobal.ps->window, "SAMP detected. Exiting CheatMenu.", "CheatMenu", MB_ICONERROR); - return; - } - CFastman92limitAdjuster::Init(); + if (GetModuleHandle("SAMP.dll") || GetModuleHandle("SAMP.asi")) + { + gLog << "Error: CheatMenu doesn't support SAMP" << std::endl; + 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); + // 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::CheckUpdate(); - gConfig.SetValue("config.last_update_checked", tstruct.tm_mday); - } + if (lastCheckDate != tstruct.tm_mday) + { + Updater::CheckUpdate(); + gConfig.SetValue("config.last_update_checked", tstruct.tm_mday); + } - while (true) - { - Sleep(5000); - Updater::Process(); - } + while (true) + { + Sleep(5000); + Updater::Process(); + } } BOOL WINAPI DllMain(HINSTANCE hDllHandle, DWORD nReason, LPVOID Reserved) { - if (nReason == DLL_PROCESS_ATTACH) - { - if (GetGameVersion() == BY_GAME(GAME_10US_HOODLUM, GAME_10EN, GAME_10EN)) - { - CreateThread(nullptr, NULL, (LPTHREAD_START_ROUTINE)&MenuThread, nullptr, NULL, nullptr); - } - else - { - gLog << "Error: Unknown game version. GTA " << BY_GAME("SA v1.0 US Hoodlum", "VC v1.0 EN", "III v1.0 EN") << " is required." << std::endl; - MessageBox(HWND_DESKTOP, "Unknown game version. GTA " BY_GAME("SA v1.0 US Hoodlum", "VC v1.0 EN", "III v1.0 EN") " is required.", "CheatMenu", MB_ICONERROR); - } - } + if (nReason == DLL_PROCESS_ATTACH) + { + if (GetGameVersion() == BY_GAME(GAME_10US_HOODLUM, GAME_10EN, GAME_10EN)) + { + CreateThread(nullptr, NULL, (LPTHREAD_START_ROUTINE)&MenuThread, nullptr, NULL, nullptr); + } + else + { + gLog << "Error: Unknown game version. GTA " << BY_GAME("SA v1.0 US Hoodlum", "VC v1.0 EN", "III v1.0 EN") << " is required." << std::endl; + MessageBox(HWND_DESKTOP, "Unknown game version. GTA " BY_GAME("SA v1.0 US Hoodlum", "VC v1.0 EN", "III v1.0 EN") " is required.", "CheatMenu", MB_ICONERROR); + } + } - return TRUE; + return TRUE; } \ No newline at end of file diff --git a/src/filehandler.cpp b/src/filehandler.cpp index 9604ff5..711ac66 100644 --- a/src/filehandler.cpp +++ b/src/filehandler.cpp @@ -4,183 +4,183 @@ // TODO: Clean up this mess, use structures instead? 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) { - std::string m_FilePath = GAME_PATH((char*)"/data/carcols.dat"); - if (!std::filesystem::exists(m_FilePath)) - { - gLog << "Carcols.dat not found"; - return; - } + std::string m_FilePath = GAME_PATH((char*)"/data/carcols.dat"); + if (!std::filesystem::exists(m_FilePath)) + { + gLog << "Carcols.dat not found"; + return; + } - std::ifstream file(m_FilePath); - std::string line; - bool isCar, isCol; - int count = 0; + std::ifstream file(m_FilePath); + std::string line; + bool isCar, isCol; + int count = 0; - while (getline(file, line)) - { - // skip commented & empty lines - if (line[0] == '#' || line == "") - { - continue; - } + while (getline(file, line)) + { + // skip commented & empty lines + if (line[0] == '#' || line == "") + { + continue; + } - // section blocks - if (line[0] == 'c' && line[1] == 'a' && line[2] == 'r') - { - isCar = true; - continue; - } + // section blocks + if (line[0] == 'c' && line[1] == 'a' && line[2] == 'r') + { + isCar = true; + continue; + } - if (line[0] == 'c' && line[1] == 'o' && line[2] == 'l') - { - isCol = true; - continue; - } + if (line[0] == 'c' && line[1] == 'o' && line[2] == 'l') + { + isCol = true; + continue; + } - if (line[0] == 'e' && line[1] == 'n' && line[2] == 'd') - { - isCar = false; - isCol = false; - continue; - } + if (line[0] == 'e' && line[1] == 'n' && line[2] == 'd') + { + isCar = false; + isCol = false; + continue; + } - if (isCol) - { - try - { - std::string temp; - std::stringstream ss(line); + if (isCol) + { + try + { + std::string temp; + std::stringstream ss(line); - // fix one instance where . is used instead of , - std::replace(temp.begin(), temp.end(), '.', ','); + // fix one instance where . is used instead of , + 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); + // 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); - storeVec.push_back({r / 255.0f, g / 255.0f, b / 255.0f}); - ++count; - } - catch (...) - { - gLog << "Error parsing carcols.dat, " << line << std::endl; - } - } - } + storeVec.push_back({r / 255.0f, g / 255.0f, b / 255.0f}); + ++count; + } + catch (...) + { + gLog << "Error parsing carcols.dat, " << line << std::endl; + } + } + } - file.close(); + file.close(); } void FileHandler::FetchHandlingID(std::map& storeMap) { - std::string m_FilePath = GAME_PATH((char*)"/data/vehicles.ide"); - if (!std::filesystem::exists(m_FilePath)) - { + std::string m_FilePath = GAME_PATH((char*)"/data/vehicles.ide"); + if (!std::filesystem::exists(m_FilePath)) + { gLog << "Vehicle.ide not found"; - return; + return; } - std::ifstream file(m_FilePath); - std::string 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; - } + std::ifstream file(m_FilePath); + std::string 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; + } - // running inside try block to handle user errors, mostly commas - try - { - std::string temp; - std::stringstream ss(line); + // running inside try block to handle user errors, mostly commas + 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(); + file.close(); } \ No newline at end of file diff --git a/src/fontmgr.cpp b/src/fontmgr.cpp index a05dcd8..1c3dce8 100644 --- a/src/fontmgr.cpp +++ b/src/fontmgr.cpp @@ -5,10 +5,10 @@ ImFont* FontMgr::GetFont(const char* fontName) { for (auto &data : m_vecFonts) { - if (data.m_path == std::string(fontName)) - { - return data.m_pFont; - } + if (data.m_path == std::string(fontName)) + { + return data.m_pFont; + } } return nullptr; @@ -21,7 +21,7 @@ ImFont* FontMgr::LoadFont(const char* fontName, float fontMul) std::string fullPath = std::string(PLUGIN_PATH((char*)"CheatMenu/fonts/")) + fontName + ".ttf"; m_vecFonts.push_back({io.Fonts->AddFontFromFileTTF(fullPath.c_str(), fontSize), fontSize, fontMul, - std::string(fontName)}); + std::string(fontName)}); io.Fonts->Build(); return m_vecFonts.back().m_pFont; diff --git a/src/fontmgr.h b/src/fontmgr.h index faf4329..8979f2c 100644 --- a/src/fontmgr.h +++ b/src/fontmgr.h @@ -22,7 +22,7 @@ public: static ImFont* GetFont(const char* fontName); static ImFont* LoadFont(const char* fontName, float fontMul = 1.0f); - + // ImGui::GetIO().Default font must be loaded after unloading all fonts static void UnloadFonts(); static void ReloadFonts(); diff --git a/src/game.cpp b/src/game.cpp index a283b1a..62b4aa7 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -14,645 +14,646 @@ 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) { - 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 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 delta = (CTimer::m_snTimeInMillisecondsNonClipped - + CTimer::m_snPreviousTimeInMillisecondsNonClipped); - 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 + int ratio = 1 / (1 + (delta * m_Freecam::m_nMul)); + int speed = m_Freecam::m_nMul + m_Freecam::m_nMul * ratio * delta; - CVector player_pos = player->GetPosition(); - CPad::GetPad(0)->DisablePlayerControls = true; + if (!m_Freecam::m_bInitDone) + { + CPlayerPed* player = FindPlayerPed(-1); + Command(0, true); - 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_bHudState = patch::Get(0xBA6769); // hud + m_Freecam::m_bRadarState = patch::Get(0xBA676C); // radar + patch::Set(0xBA6769, 0); // hud + patch::Set(0xBA676C, 2); // radar - Command(m_Freecam::m_nPed, true); - Command(m_Freecam::m_nPed, false); - Command(m_Freecam::m_nPed, false); + CVector player_pos = player->GetPosition(); + CPad::GetPad(0)->DisablePlayerControls = true; - m_Freecam::m_fTotalMouse.x = player->GetHeading() + 89.6f; - m_Freecam::m_fTotalMouse.y = 0; + 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_bInitDone = true; - player_pos.z -= 20; - m_Freecam::m_pPed->SetPosn(player_pos); + Command(m_Freecam::m_nPed, true); + Command(m_Freecam::m_nPed, false); + Command(m_Freecam::m_nPed, false); - TheCamera.LerpFOV(TheCamera.FindCamFOV(), m_Freecam::m_fFOV, 1000, true); - Command(true); - } + m_Freecam::m_fTotalMouse.x = player->GetHeading() + 89.6f; + m_Freecam::m_fTotalMouse.y = 0; - CVector pos = m_Freecam::m_pPed->GetPosition(); + m_Freecam::m_bInitDone = true; + player_pos.z -= 20; + m_Freecam::m_pPed->SetPosn(player_pos); - 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; + TheCamera.LerpFOV(TheCamera.FindCamFOV(), m_Freecam::m_fFOV, 1000, true); + Command(true); + } - if (m_Freecam::m_fTotalMouse.x > 150) - { - m_Freecam::m_fTotalMouse.y = 150; - } + CVector pos = m_Freecam::m_pPed->GetPosition(); - if (m_Freecam::m_fTotalMouse.y < -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 (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.x > 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 (m_Freecam::m_fTotalMouse.y < -150) + { + m_Freecam::m_fTotalMouse.y = -150; + } - if (KeyPressed(VK_RCONTROL)) - { - speed /= 2; - } + 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_RSHIFT)) - { - 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_KEY_I) || KeyPressed(VK_KEY_K)) - { - if (KeyPressed(VK_KEY_K)) - { - speed *= -1; - } + if (KeyPressed(VK_RCONTROL)) + { + 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_RSHIFT)) + { + speed *= 2; + } - if (KeyPressed(VK_KEY_J) || KeyPressed(VK_KEY_L)) - { - if (KeyPressed(VK_KEY_J)) - { - speed *= -1; - } + if (KeyPressed(VK_KEY_I) || KeyPressed(VK_KEY_K)) + { + if (KeyPressed(VK_KEY_K)) + { + speed *= -1; + } - float angle; - Command(m_Freecam::m_nPed, &angle); - angle -= 90; + 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); + } - pos.x += speed * cos(angle * 3.14159f / 180.0f); - pos.y += speed * sin(angle * 3.14159f / 180.0f); - } + if (KeyPressed(VK_KEY_J) || KeyPressed(VK_KEY_L)) + { + if (KeyPressed(VK_KEY_J)) + { + speed *= -1; + } - if (CPad::NewMouseControllerState.wheelUp) - { - if (m_Freecam::m_fFOV > 10.0f) - { - m_Freecam::m_fFOV -= 2.0f * speed; - } + float angle; + Command(m_Freecam::m_nPed, &angle); + angle -= 90; - TheCamera.LerpFOV(TheCamera.FindCamFOV(), m_Freecam::m_fFOV, 250, true); - Command(true); - } + pos.x += speed * cos(angle * 3.14159f / 180.0f); + pos.y += speed * sin(angle * 3.14159f / 180.0f); + } - if (CPad::NewMouseControllerState.wheelDown) - { - if (m_Freecam::m_fFOV < 115.0f) - { - m_Freecam::m_fFOV += 2.0f * speed; - } + if (CPad::NewMouseControllerState.wheelUp) + { + if (m_Freecam::m_fFOV > 10.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); + } - 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); + 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); } void Game::ClearFreecamStuff() { - m_Freecam::m_bInitDone = false; - Command(0, false); - patch::Set(BY_GAME(0xBA6769, 0x86963A, NULL), 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, NULL), 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); -#else // GTA3 - patch::Nop(0x5841B8, 5); - patch::Nop(0x5841C7, 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 + 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); -#else // GTA3 - patch::SetRaw(0x5841B8, (char*)"\x88\xD8\x89\xF1\x50", 5); - patch::SetRaw(0x5841C7, (char*)"\xE8\x84\xE2\xF0\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 + 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>(); - } -#else // GTA3 & GTAVC - 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); - } + ImGui::SameLine(); + if (ImGui::Button("Very sunny", Ui::GetSize(3))) + { + Call<0x438F50>(); + } +#else + 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); - } + if (ImGui::Button("Foggy", Ui::GetSize(3))) + { + CWeather::ForceWeatherNow(3); + } #ifdef GTAVC ImGui::SameLine(); if (ImGui::Button("Extra sunny", Ui::GetSize(3))) @@ -671,113 +672,113 @@ Lowers armour, health, stamina etc.")) } #endif #endif - ImGui::Spacing(); - ImGui::Separator(); - } - ImGui::EndTabItem(); - } - if (ImGui::BeginTabItem("Missions")) - { - ImGui::Spacing(); + 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 6621d7b..1ab5d23 100644 --- a/src/game.h +++ b/src/game.h @@ -4,65 +4,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" - }; + 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; + }; - 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 e015d63..0a01446 100644 --- a/src/hook.cpp +++ b/src/hook.cpp @@ -11,252 +11,252 @@ 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) { - ImGui_ImplDX9_InvalidateDeviceObjects(); + ImGui_ImplDX9_InvalidateDeviceObjects(); - return oReset(pDevice, pPresentationParameters); + return oReset(pDevice, pPresentationParameters); } void Hook::RenderFrame(void* ptr) { - if (!ImGui::GetCurrentContext()) - { - ImGui::CreateContext(); - } + if (!ImGui::GetCurrentContext()) + { + ImGui::CreateContext(); + } - 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); - // Scale the menu if game resolution changed - static ImVec2 fScreenSize = ImVec2(-1, -1); - ImVec2 size(screen::GetScreenWidth(), screen::GetScreenHeight()); - if (fScreenSize.x != size.x && fScreenSize.y != size.y) - { - FontMgr::ReloadFonts(); + // Scale the menu if game resolution changed + static ImVec2 fScreenSize = ImVec2(-1, -1); + ImVec2 size(screen::GetScreenWidth(), screen::GetScreenHeight()); + if (fScreenSize.x != size.x && fScreenSize.y != size.y) + { + FontMgr::ReloadFonts(); - 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, 5 * scaleY); - style->ItemSpacing = ImVec2(8 * scaleX, 4 * scaleY); - style->ScrollbarSize = 12 * scaleX; - style->IndentSpacing = 20 * scaleX; - style->ItemInnerSpacing = ImVec2(5 * scaleX, 5 * scaleY); + style->FramePadding = ImVec2(5 * scaleX, 5 * scaleY); + style->ItemSpacing = ImVec2(8 * scaleX, 4 * scaleY); + style->ScrollbarSize = 12 * scaleX; + style->IndentSpacing = 20 * scaleX; + style->ItemInnerSpacing = ImVec2(5 * scaleX, 5 * 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 (pCallbackFunc != nullptr) - { - pCallbackFunc(); - } + if (pCallbackFunc != nullptr) + { + pCallbackFunc(); + } - 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; - ImGui_ImplWin32_Init(RsGlobal.ps->window); + if (gRenderer == Render_DirectX9) + { + ImGui_ImplDX9_RenderDrawData(ImGui::GetDrawData()); + } + else + { + ImGui_ImplDX11_RenderDrawData(ImGui::GetDrawData()); + } + } + else + { + bInit = true; + 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(); - // Loading fonts - io.FontDefault = FontMgr::LoadFont("text", 1.0f); - FontMgr::LoadFont("title", 2.0f); - FontMgr::LoadFont("header", 1.25f); - - io.IniFilename = nullptr; - io.LogFilename = nullptr; - io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; - oWndProc = (WNDPROC)SetWindowLongPtr(RsGlobal.ps->window, GWL_WNDPROC, (LRESULT)WndProc); - } + // Loading fonts + io.FontDefault = FontMgr::LoadFont("text", 1.0f); + FontMgr::LoadFont("title", 2.0f); + FontMgr::LoadFont("header", 1.25f); + + io.IniFilename = nullptr; + io.LogFilename = nullptr; + io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; + oWndProc = (WNDPROC)SetWindowLongPtr(RsGlobal.ps->window, GWL_WNDPROC, (LRESULT)WndProc); + } } HRESULT Hook::Dx9Handler(IDirect3DDevice9* pDevice) { - RenderFrame(pDevice); - return oEndScene(pDevice); + RenderFrame(pDevice); + return oEndScene(pDevice); } 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 = patch::Get(BY_GAME(0xBA6818, 0x86968B, 0x5F03D8)); + // Disable player controls for controllers + bool bMouseDisabled = false; + bool isController = patch::Get(BY_GAME(0xBA6818, 0x86968B, 0x5F03D8)); #ifdef GTA3 - isController = !isController; + isController = !isController; #endif - if (isController && (state || bMouseDisabled)) - { + if (isController && (state || 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 (state) - { - bMouseDisabled = true; + if (pad) + { + if (state) + { + bMouseDisabled = true; #ifdef GTA3 - pad->m_bDisablePlayerControls = true; + pad->m_bDisablePlayerControls = true; #else //GTAVC & GTASA - pad->DisablePlayerControls = true; + pad->DisablePlayerControls = true; #endif - } - else - { - bMouseDisabled = false; + } + else + { + bMouseDisabled = false; #ifdef GTA3 - pad->m_bDisablePlayerControls = false; + pad->m_bDisablePlayerControls = false; #else //GTAVC & GTASA - pad->DisablePlayerControls = false; + pad->DisablePlayerControls = false; #endif - } - } - } + } + } + } - if (m_bMouseVisibility != state) - { - ImGui::GetIO().MouseDrawCursor = state; + if (m_bMouseVisibility != state) + { + ImGui::GetIO().MouseDrawCursor = state; - if (state) - { - - patch::SetUChar(BY_GAME(0x6194A0, 0x6020A0, 0x580D20), 0xC3); // psSetMousePos - patch::Nop(BY_GAME(0x541DD7, 0x4AB6CA, 0x49272F), 5); // don't call CPad::UpdateMouse() - } - else - { - - patch::SetUChar(BY_GAME(0x6194A0, 0x6020A0, 0x580D20), BY_GAME(0xE9, 0x53, 0x53)); + if (state) + { + + patch::SetUChar(BY_GAME(0x6194A0, 0x6020A0, 0x580D20), 0xC3); // psSetMousePos + patch::Nop(BY_GAME(0x541DD7, 0x4AB6CA, 0x49272F), 5); // don't call CPad::UpdateMouse() + } + else + { + + patch::SetUChar(BY_GAME(0x6194A0, 0x6020A0, 0x580D20), BY_GAME(0xE9, 0x53, 0x53)); #ifdef GTASA - patch::SetRaw(0x541DD7, (char*)"\xE8\xE4\xD5\xFF\xFF", 5); + patch::SetRaw(0x541DD7, (char*)"\xE8\xE4\xD5\xFF\xFF", 5); #elif GTAVC - patch::SetRaw(0x4AB6CA, (char*)"\xE8\x51\x21\x00\x00", 5); -#else // GTA3 - patch::SetRaw(0x49272F, (char*)"\xE8\x6C\xF5\xFF\xFF", 5); + patch::SetRaw(0x4AB6CA, (char*)"\xE8\x51\x21\x00\x00", 5); +#else + patch::SetRaw(0x49272F, (char*)"\xE8\x6C\xF5\xFF\xFF", 5); #endif - } + } - CPad::NewMouseControllerState.X = 0; - CPad::NewMouseControllerState.Y = 0; + CPad::NewMouseControllerState.X = 0; + CPad::NewMouseControllerState.Y = 0; #ifdef GTA3 - CPad::GetPad(0)->ClearMouseHistory(); -#else // GTAVC & GTASA - CPad::ClearMouseHistory(); + CPad::GetPad(0)->ClearMouseHistory(); +#else + CPad::ClearMouseHistory(); #endif - CPad::UpdatePads(); - m_bMouseVisibility = state; - } + CPad::UpdatePads(); + m_bMouseVisibility = state; + } } Hook::Hook() { - // 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 + { + + 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(); } \ No newline at end of file diff --git a/src/hook.h b/src/hook.h index db85e48..300e57c 100644 --- a/src/hook.h +++ b/src/hook.h @@ -10,23 +10,23 @@ extern IMGUI_IMPL_API LRESULT ImGui_ImplWin32_WndProcHandler(HWND hWnd, UINT msg 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 pCallbackFunc = nullptr; + static inline bool m_bShowMouse = false; + static inline std::function pCallbackFunc = nullptr; - Hook(); - ~Hook(); + Hook(); + ~Hook(); }; diff --git a/src/hotkeys.cpp b/src/hotkeys.cpp index 2f36497..aff2459 100644 --- a/src/hotkeys.cpp +++ b/src/hotkeys.cpp @@ -17,124 +17,124 @@ Hotkey vehInstantStop; 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()*1.35f))) - { - if (!active) - { - m_CurrentHotkey = label; - } - } + if (ImGui::Button((text + std::string("##") + std::string(label)).c_str(), + ImVec2(ImGui::GetWindowContentRegionWidth() / 3.5, ImGui::GetFrameHeight()*1.35f))) + { + 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 46e468e..f880bf6 100644 --- a/src/hotkeys.h +++ b/src/hotkeys.h @@ -14,9 +14,9 @@ private: public: int m_key1; int m_key2; - + Hotkey(int key1 = -1, int key2 = -1) - : m_key1(key1), m_key2(key2) + : m_key1(key1), m_key2(key2) {} // Draws ui to change the hotkeys from frontend diff --git a/src/json.cpp b/src/json.cpp index 6a6e5f9..aa1c581 100644 --- a/src/json.cpp +++ b/src/json.cpp @@ -3,45 +3,45 @@ 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 579f10a..10c5fa6 100644 --- a/src/json.h +++ b/src/json.h @@ -3,121 +3,121 @@ /* Wrapper class for nlohmann::json - Contains helper methods + 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; - } - } + // 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; + template <> + void SetValue(std::string&& key, std::string& 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 = val; - } + *json = val; + } - /* - Saves json data to disk - */ - void WriteToDisk(); - CJson(const char* text = ""); + /* + Saves json data to disk + */ + void WriteToDisk(); + CJson(const char* text = ""); }; diff --git a/src/menu.cpp b/src/menu.cpp index c05c033..073c137 100644 --- a/src/menu.cpp +++ b/src/menu.cpp @@ -14,608 +14,607 @@ 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 = (DisplayPos)gConfig.GetValue("overlay.selected_pos", (int)DisplayPos::BOTTOM_RIGHT); - m_Overlay::fPosX = gConfig.GetValue("overlay.pox", 0); - m_Overlay::fPosY = gConfig.GetValue("overlay.posy", 0); - m_Overlay::textColor[0] = gConfig.GetValue("overlay.text_color.r", 1.0f); - m_Overlay::textColor[1] = gConfig.GetValue("overlay.text_color.g", 1.0f); - m_Overlay::textColor[2] = gConfig.GetValue("overlay.text_color.b", 1.0f); - m_Overlay::textColor[3] = gConfig.GetValue("overlay.text_color.a", 1.0f); + // 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 = (DisplayPos)gConfig.GetValue("overlay.selected_pos", (int)DisplayPos::BOTTOM_RIGHT); + m_Overlay::fPosX = gConfig.GetValue("overlay.pox", 0); + m_Overlay::fPosY = gConfig.GetValue("overlay.posy", 0); + m_Overlay::textColor[0] = gConfig.GetValue("overlay.text_color.r", 1.0f); + m_Overlay::textColor[1] = gConfig.GetValue("overlay.text_color.g", 1.0f); + m_Overlay::textColor[2] = gConfig.GetValue("overlay.text_color.b", 1.0f); + m_Overlay::textColor[3] = gConfig.GetValue("overlay.text_color.a", 1.0f); - // 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 == DisplayPos::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 == DisplayPos::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 == DisplayPos::TOP_LEFT) - { - pos = ImVec2(offset, offset); - pivot = ImVec2(0.0f, 0.0f); - } + if (m_Overlay::mSelectedPos == DisplayPos::TOP_LEFT) + { + pos = ImVec2(offset, offset); + pivot = ImVec2(0.0f, 0.0f); + } - if (m_Overlay::mSelectedPos == DisplayPos::TOP_RIGHT) - { - pos = ImVec2(io.DisplaySize.x - offset, offset); - pivot = ImVec2(1.0f, 0.0f); - } + if (m_Overlay::mSelectedPos == DisplayPos::TOP_RIGHT) + { + pos = ImVec2(io.DisplaySize.x - offset, offset); + pivot = ImVec2(1.0f, 0.0f); + } - if (m_Overlay::mSelectedPos == DisplayPos::BOTTOM_LEFT) - { - pos = ImVec2(offset, io.DisplaySize.y - offset); - pivot = ImVec2(0.0f, 1.0f); - } + if (m_Overlay::mSelectedPos == DisplayPos::BOTTOM_LEFT) + { + pos = ImVec2(offset, io.DisplaySize.y - offset); + pivot = ImVec2(0.0f, 1.0f); + } - if (m_Overlay::mSelectedPos == DisplayPos::BOTTOM_RIGHT) - { - pos = ImVec2(io.DisplaySize.x - offset, io.DisplaySize.y - offset); - pivot = ImVec2(1.0f, 1.0f); - } + if (m_Overlay::mSelectedPos == DisplayPos::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::PushStyleColor(ImGuiCol_Text, *(ImVec4*)&m_Overlay::textColor); - if (m_bShowMenu && ImGui::Begin("Overlay", nullptr, window_flags)) - { - CVector pos{0,0,0}; - pos = pPlayer->GetPosition(); + ImGui::SetNextWindowBgAlpha(m_Overlay::bTransparent ? 0.0f : 0.5f); + ImGui::PushStyleColor(ImGuiCol_Text, *(ImVec4*)&m_Overlay::textColor); + if (m_bShowMenu && ImGui::Begin("Overlay", nullptr, window_flags)) + { + CVector pos{0,0,0}; + pos = pPlayer->GetPosition(); - size_t game_ms = CTimer::m_snTimeInMilliseconds; - static size_t interval = 0; - if (game_ms - interval > 1000) - { - m_Overlay::fCpuUsage = static_cast(Util::GetCurrentCPUUsage()); + size_t game_ms = CTimer::m_snTimeInMilliseconds; + static size_t interval = 0; + if (game_ms - interval > 1000) + { + 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)); - - m_Overlay::mFPS = static_cast(BY_GAME(CTimer::game_FPS, io.Framerate, io.Framerate)); - interval = game_ms; - } + 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)); - if (m_Overlay::bCoord) - { - ImGui::Text("Coord: %.2f, %.2f, %.2f", pos.x, pos.y, pos.z); - } + m_Overlay::mFPS = static_cast(BY_GAME(CTimer::game_FPS, io.Framerate, io.Framerate)); + interval = game_ms; + } - if (m_Overlay::bCpuUsage) - { - ImGui::Text("CPU usage: %.2f%%", m_Overlay::fCpuUsage); - } + if (m_Overlay::bCoord) + { + ImGui::Text("Coord: %.2f, %.2f, %.2f", pos.x, pos.y, pos.z); + } - if (m_Overlay::bFPS) - { - ImGui::Text("Frames: %d", m_Overlay::mFPS); - } + if (m_Overlay::bCpuUsage) + { + ImGui::Text("CPU usage: %.2f%%", m_Overlay::fCpuUsage); + } - if (m_Overlay::bLocName) - { - ImGui::Text("Location: %s", Util::GetLocationName(&pos).c_str()); - } + if (m_Overlay::bFPS) + { + ImGui::Text("Frames: %d", m_Overlay::mFPS); + } - if (m_Overlay::bMemUsage) - { - ImGui::Text("RAM usage: %.2f%%", m_Overlay::fMemUsage); - } + if (m_Overlay::bLocName) + { + ImGui::Text("Location: %s", Util::GetLocationName(&pos).c_str()); + } - 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::bMemUsage) + { + ImGui::Text("RAM usage: %.2f%%", m_Overlay::fMemUsage); + } - 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 (pPlayer->m_pVehicle && pPlayer->m_pVehicle->m_pDriver == pPlayer) + { + if (m_Overlay::bVehHealth) + { + ImGui::Text("Veh Health: %.f", pPlayer->m_pVehicle->m_fHealth); + } - ImVec2 windowPos = ImGui::GetWindowPos(); - m_Overlay::fPosX = windowPos.x; - m_Overlay::fPosY = windowPos.y; + if (m_Overlay::bVehSpeed) + { + int speed = pPlayer->m_pVehicle->m_vecMoveSpeed.Magnitude() * 50.0f; // 02E3 - GET_CAR_SPEED + ImGui::Text("Veh Speed: %d", speed); + } + } - ImGui::End(); - } - ImGui::PopStyleColor(); - } + ImVec2 windowPos = ImGui::GetWindowPos(); + m_Overlay::fPosX = windowPos.x; + m_Overlay::fPosY = windowPos.y; + + ImGui::End(); + } + ImGui::PopStyleColor(); + } } 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(ImGui::GetContentRegionMax().x); + ImGui::SetNextItemWidth(ImGui::GetContentRegionMax().x); - 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::IsAnyItemActive()) - { - ImGui::SetKeyboardFocusHere(-1); - } - ImGui::PopStyleVar(2); - ImGui::End(); - } + 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::IsAnyItemActive()) + { + ImGui::SetKeyboardFocusHere(-1); + } + 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() { - ImGui::Spacing(); - if (ImGui::Button("Reset config", ImVec2(Ui::GetSize(2)))) - { - gConfig.m_Data.clear(); - SetHelpMessage("Config has been reset. Restart the game for it to take effect.", false, false, false); - } - ImGui::SameLine(); - if (ImGui::Button("Reset size", ImVec2(Ui::GetSize(2)))) - { - CheatMenu::ResetMenuSize(); - SetHelpMessage("Menu size reset", false, false, false); - } + ImGui::Spacing(); + if (ImGui::Button("Reset config", ImVec2(Ui::GetSize(2)))) + { + gConfig.m_Data.clear(); + SetHelpMessage("Config has been reset. Restart the game for it to take effect.", false, false, false); + } + ImGui::SameLine(); + if (ImGui::Button("Reset size", ImVec2(Ui::GetSize(2)))) + { + CheatMenu::ResetMenuSize(); + } - ImGui::Spacing(); - if (ImGui::BeginTabBar("Menu", ImGuiTabBarFlags_NoTooltip + ImGuiTabBarFlags_FittingPolicyScroll)) - { - if (ImGui::BeginTabItem("Overlay")) - { - ImGui::Spacing(); - ImGui::Spacing(); - ImGui::SameLine(); - if (Ui::ListBox("Position", m_Overlay::posNames, (int&)m_Overlay::mSelectedPos)) - { - gConfig.SetValue("overlay.selected_pos", m_Overlay::mSelectedPos); - } + ImGui::Spacing(); + if (ImGui::BeginTabBar("Menu", ImGuiTabBarFlags_NoTooltip + ImGuiTabBarFlags_FittingPolicyScroll)) + { + if (ImGui::BeginTabItem("Overlay")) + { + ImGui::Spacing(); + ImGui::Spacing(); + ImGui::SameLine(); + if (Ui::ListBox("Position", m_Overlay::posNames, (int&)m_Overlay::mSelectedPos)) + { + gConfig.SetValue("overlay.selected_pos", m_Overlay::mSelectedPos); + } - ImGui::Spacing(); - ImGui::SameLine(); - if (ImGui::ColorEdit4("Text color", m_Overlay::textColor)) - { - gConfig.SetValue("overlay.text_color.r", m_Overlay::textColor[0]); - gConfig.SetValue("overlay.text_color.g", m_Overlay::textColor[1]); - gConfig.SetValue("overlay.text_color.b", m_Overlay::textColor[2]); - gConfig.SetValue("overlay.text_color.a", m_Overlay::textColor[3]); - } + ImGui::Spacing(); + ImGui::SameLine(); + if (ImGui::ColorEdit4("Text color", m_Overlay::textColor)) + { + gConfig.SetValue("overlay.text_color.r", m_Overlay::textColor[0]); + gConfig.SetValue("overlay.text_color.g", m_Overlay::textColor[1]); + gConfig.SetValue("overlay.text_color.b", m_Overlay::textColor[2]); + gConfig.SetValue("overlay.text_color.a", m_Overlay::textColor[3]); + } - 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("Teleport")) - { - ImGui::Spacing(); - ImGui::TextWrapped("Teleports player to specified coordinates.\nExample: tp x y z"); - 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("Teleport")) + { + ImGui::Spacing(); + ImGui::TextWrapped("Teleports player to specified coordinates.\nExample: tp x y z"); + 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)))) - { - Updater::CheckUpdate(); - } + if (ImGui::Button("Check update", ImVec2(Ui::GetSize(3)))) + { + Updater::CheckUpdate(); + } - 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); - } - ImGui::Spacing(); + if (ImGui::Button("GitHub repo", ImVec2(Ui::GetSize(3)))) + { + ShellExecute(nullptr, "open", GITHUB_LINK, nullptr, nullptr, SW_SHOWNORMAL); + } + 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 13e8961..59548c8 100644 --- a/src/menu.h +++ b/src/menu.h @@ -4,49 +4,49 @@ class Menu { private: - enum class DisplayPos - { - CUSTOM, - TOP_LEFT, - TOP_RIGHT, - BOTTOM_LEFT, - BOTTOM_RIGHT - }; + enum DisplayPos + { + CUSTOM, + TOP_LEFT, + TOP_RIGHT, + BOTTOM_LEFT, + BOTTOM_RIGHT + }; - struct m_Overlay - { - static inline bool bCoord; - static inline bool bFPS; - static inline int mFPS; - static inline bool bLocName; - static inline bool bTransparent; - static inline bool bVehHealth; - static inline bool bVehSpeed; - static inline bool bCpuUsage; - static inline float fCpuUsage; - static inline bool bMemUsage; - static inline float fMemUsage; - static inline std::vector posNames = - { - "Custom", "Top left", "Top right", "Bottom left", "Bottom right" - }; - static inline DisplayPos mSelectedPos = DisplayPos::BOTTOM_RIGHT; - static inline float fPosX; - static inline float fPosY; - static inline int mTotalRam = 0; - static inline float textColor[4] = {1.0f, 1.0f, 1.0f, 1.0f}; - }; + struct m_Overlay + { + static inline bool bCoord; + static inline bool bFPS; + static inline int mFPS; + static inline bool bLocName; + static inline bool bTransparent; + static inline bool bVehHealth; + static inline bool bVehSpeed; + static inline bool bCpuUsage; + static inline float fCpuUsage; + static inline bool bMemUsage; + static inline float fMemUsage; + static inline std::vector posNames = + { + "Custom", "Top left", "Top right", "Bottom left", "Bottom right" + }; + static inline DisplayPos mSelectedPos = DisplayPos::BOTTOM_RIGHT; + static inline float fPosX; + static inline float fPosY; + static inline int mTotalRam = 0; + static inline float textColor[4] = {1.0f, 1.0f, 1.0f, 1.0f}; + }; public: - struct m_Commands - { - static inline bool m_bShowMenu; - static inline char m_nInputBuffer[INPUT_BUFFER_SIZE] = ""; - }; + struct m_Commands + { + static inline bool m_bShowMenu; + 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/neon.cpp b/src/neon.cpp index 7348015..4e38ccb 100644 --- a/src/neon.cpp +++ b/src/neon.cpp @@ -4,275 +4,276 @@ // 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 + 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 }; // Thanks DKPac22 static RwTexture* 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 Neon::InitHooks() { - if (m_bInit) - { - return; - } + static bool init; + if (init) + { + return; + } - Events::processScriptsEvent += [] - { - if (!m_pNeonTexture) - { - m_pNeonTexture = LoadTextureFromMemory((char*)neon_mask, sizeof(neon_mask)); - } - }; + Events::processScriptsEvent += [] + { + if (!m_pNeonTexture) + { + m_pNeonTexture = 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; + } + } + } + }; - m_bInit = true; + init = true; } void Neon::RemoveHooks() { - if (m_pNeonTexture) - { - RwTextureDestroy(m_pNeonTexture); - m_pNeonTexture = nullptr; - } + if (m_pNeonTexture) + { + RwTextureDestroy(m_pNeonTexture); + m_pNeonTexture = nullptr; + } } bool Neon::IsInstalled(CVehicle* pVeh) { - return m_VehNeon.Get(pVeh).m_bNeonInstalled; + return m_VehNeon.Get(pVeh).m_bNeonInstalled; } 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) { - m_VehNeon.Get(pVeh).m_bPulsing = state; + m_VehNeon.Get(pVeh).m_bPulsing = state; } void Neon::Install(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::Remove(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 0203389..2387ede 100644 --- a/src/neon.h +++ b/src/neon.h @@ -11,36 +11,35 @@ 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 bool m_bInit; + static inline RwTexture* m_pNeonTexture = nullptr; // pointer to the neon mask texture + static inline VehicleExtendedData m_VehNeon; public: - Neon() = delete; - Neon(Neon&) = delete; + Neon() = delete; + Neon(Neon&) = delete; - static void InitHooks(); - static void Install(CVehicle* veh, int red, int green, int blue); - static bool IsInstalled(CVehicle* veh); - static bool IsPulsingEnabled(CVehicle* veh); - static void SetPulsing(CVehicle* veh, bool state); - static void RemoveHooks(); - static void Remove(CVehicle* veh); + static void InitHooks(); + static void Install(CVehicle* veh, int red, int green, int blue); + static bool IsInstalled(CVehicle* veh); + static bool IsPulsingEnabled(CVehicle* veh); + static void SetPulsing(CVehicle* veh, bool state); + static void RemoveHooks(); + static void Remove(CVehicle* veh); }; diff --git a/src/paint.cpp b/src/paint.cpp index 87ec730..0131f5a 100644 --- a/src/paint.cpp +++ b/src/paint.cpp @@ -29,272 +29,280 @@ void Paint::InitHooks() { - Events::vehicleRenderEvent.before += [](CVehicle* pVeh) - { - VehData& data = m_VehData.Get(pVeh); + static bool init; - // 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); + if (init) + { + return; + } - data.primary_color = pVeh->m_nPrimaryColor; - data.secondary_color = pVeh->m_nSecondaryColor; - } + Events::vehicleRenderEvent.before += [](CVehicle* pVeh) + { + VehData& data = m_VehData.Get(pVeh); - 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; - } - } - }; + // 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; + } + + 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; + } + } + }; + init = true; } 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) { - 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) { - 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) { - 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) { - 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::GenerateNodeList(CVehicle* pVeh, std::vector& names_vec) { - 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(names_vec.begin(), names_vec.end(), name) != names_vec.end())) - names_vec.push_back(name); - }); + if (!(std::find(names_vec.begin(), names_vec.end(), name) != names_vec.end())) + names_vec.push_back(name); + }); } void Paint::SetNodeColor(CVehicle* pVeh, std::string node_name, CRGBA color, bool filter_mat) { - RwFrame* frame = (RwFrame*)pVeh->m_pRwClump->object.parent; + 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) { - 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) { - 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) { - 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 57bb98a..2c869d3 100644 --- a/src/paint.h +++ b/src/paint.h @@ -28,58 +28,58 @@ 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; - static void NodeWrapperRecursive(RwFrame* frame, CVehicle* pVeh, std::function func); + 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; + static void NodeWrapperRecursive(RwFrame* frame, CVehicle* pVeh, std::function func); public: - static inline ResourceStore m_TextureData { "textures", eResourceType::TYPE_IMAGE, ImVec2(100, 80) }; + static inline ResourceStore m_TextureData { "textures", eResourceType::TYPE_IMAGE, ImVec2(100, 80) }; - static void InitHooks(); - static void GenerateNodeList(CVehicle* pVeh, std::vector& names_vec); - static void SetNodeColor(CVehicle* pVeh, std::string node_name, CRGBA color, bool filter_mat = false); - static void SetNodeTexture(CVehicle* pVeh, std::string node_name, std::string texturename, bool filter_mat = false); - static void ResetNodeColor(CVehicle* veh, std::string node_name); - static void ResetNodeTexture(CVehicle* pVeh, std::string node_name); + static void InitHooks(); + static void GenerateNodeList(CVehicle* pVeh, std::vector& names_vec); + 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 4b6a86f..93cad05 100644 --- a/src/pch.h +++ b/src/pch.h @@ -79,9 +79,9 @@ using namespace plugin; enum eRenderer { - Render_DirectX9, - Render_DirectX11, - Render_Unknown + Render_DirectX9, + Render_DirectX11, + Render_Unknown }; static eRenderer gRenderer = Render_Unknown; @@ -94,14 +94,14 @@ 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); -#else // GTA3 - const size_t size = strlen(message)+1; + CHud::SetHelpMessage(message, b1, b2); +#else + const size_t size = strlen(message)+1; wchar_t* wc = new wchar_t[size]; mbstowcs(wc, message, size); - CHud::SetHelpMessage(wc, b1); - delete wc; + CHud::SetHelpMessage(wc, b1); + delete wc; #endif } \ No newline at end of file diff --git a/src/ped.cpp b/src/ped.cpp index 1885092..0c6a414 100644 --- a/src/ped.cpp +++ b/src/ped.cpp @@ -12,395 +12,406 @@ 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) - { + TODO: Implement in VC too + */ + Events::pedRenderEvent += [](CPed *ped) + { - if (m_bBigHead || m_bThinBody) - { - auto animHier = GetAnimHierarchyFromSkinClump (ped->m_pRwClump); - auto matrices = RpHAnimHierarchyGetMatrixArray (animHier); + 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); - } - } - } - }; + 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) -#else // GTA3 & GTAVC +#else 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 > 9) - { - currentSlot = 1; - } - } -#else // GTA3 & GTAVC - if (cat == "Special") // Special model - { -#ifdef GTA3 - SetHelpMessage("Spawning special peds isn't implemented yet.", false, false, false); - return; -#else // GTAVC - Command(currentSlot, model.c_str()); - Command(); - - Command(m_SpawnPed::m_nSelectedPedType + 4, 108+currentSlot, pos.x, pos.y, pos.z + 1, &hplayer); - Command(currentSlot); - - ++currentSlot; - if (currentSlot > 21) - { - currentSlot = 1; - } -#endif - } -#endif - 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); - } - - 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; -#ifdef GTA3 - ped->m_nWepAccuracy = m_SpawnPed::m_nAccuracy; + // SA has 10 slots + ++currentSlot; + if (currentSlot > 9) + { + currentSlot = 1; + } + } #else - ped->m_nWeaponAccuracy = m_SpawnPed::m_nAccuracy; + if (cat == "Special") // Special model + { +#ifdef GTA3 + SetHelpMessage("Spawning special peds isn't implemented yet.", false, false, false); + return; +#else + Command(currentSlot, model.c_str()); + Command(); + + Command(m_SpawnPed::m_nSelectedPedType + 4, 108+currentSlot, pos.x, pos.y, pos.z + 1, &hplayer); + Command(currentSlot); + + ++currentSlot; + if (currentSlot > 21) + { + currentSlot = 1; + } #endif - ped->m_fHealth = m_SpawnPed::m_nPedHealth; + } +#endif + 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); + } + + 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; +#ifdef GTA3 + ped->m_nWepAccuracy = m_SpawnPed::m_nAccuracy; +#else + ped->m_nWeaponAccuracy = m_SpawnPed::m_nAccuracy; +#endif + 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); -#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); + Ui::CheckboxAddress("No prostitutes", 0xA10B99); + Ui::CheckboxAddress("Slut magnet", 0xA10B5F); + ImGui::NextColumn(); + Ui::CheckboxAddress("Weapons for all", 0xA10AB3); +#else + // 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_GangList[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")) + { + static int removeRadius = 5; + ImGui::InputInt("Radius", &removeRadius); + 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()) < removeRadius + && 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(); }); -#else // GTA3 & GTAVC - Ui::DrawJSON(m_PedData, SpawnPed, nullptr); + Ui::DrawImages(m_PedData, SpawnPed, nullptr, + [](std::string str) + { + return m_PedData.m_pJson->m_Data[str].get(); + }); +#else + 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*/ } - ); -#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::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 + 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 97ad6f5..57a1c7a 100644 --- a/src/ped.h +++ b/src/ped.h @@ -5,62 +5,59 @@ 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 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 bool m_bExGangWarsInstalled; + static inline bool m_bBigHead; + static inline bool m_bThinBody; + static inline std::vector m_GangList = + { + "Ballas", "Grove street families", "Los santos vagos", "San fierro rifa", + "Da nang boys", "Mafia", "Mountain cloud triad", "Varrio los aztecas", "Gang9", "Gang10" + }; #endif - 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 = - { + + 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" -#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 (crash)", "Cubans", "Haitians", "Streetwannabe's", "Diaz' Gang", + "Security Guards", "Biker Gang", "Vercetti Gang", "Golfers", "Gang 9", "Emergency", + "Fireman", "Criminal", "Unused", "Prostitute", "Special" +#else + "Civ Male", "Civ Female", "Cop", "Leones", "Triads", "Diablos", "Yakuza", "Yardies", "Colombians", + "Hoods", "unused", "unused", "Emergency", "Fireman", "Criminal", "unused", "Prostitute", "Special" #endif - }; - }; - - friend class Player; -#ifdef GTASA - friend class Weapon; -#endif - + }; + }; public: - Ped(); - ~Ped(); - static void Draw(); #ifdef GTASA - 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 inline CJson m_SpecialPedJson = CJson("ped special"); + static inline ResourceStore m_PedData{"ped", eResourceType::TYPE_BOTH, ImVec2(65, 110)}; +#else + static inline ResourceStore m_PedData {"ped", eResourceType::TYPE_TEXT}; +#endif + + Ped(); + ~Ped(); + static void Draw(); + +#ifdef GTASA + static void SpawnPed(std::string& model); + static void BigHeadEffect(CPed *ped); +#else + static void SpawnPed(std::string& cat, std::string& name, std::string& model); #endif }; diff --git a/src/player.cpp b/src/player.cpp index 529b341..66e7c04 100644 --- a/src/player.cpp +++ b/src/player.cpp @@ -3,38 +3,39 @@ #include "menu.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" + "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); } @@ -44,63 +45,63 @@ static inline void PlayerModelBrokenFix() */ 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); - - // 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; - } + CVehicle *vehicle = FindPlayerVehicle(-1, false); - if (speed < 0.0f) - { - speed = 0.0f; - } - curOffset += speed; - } + // 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; + } - CVector playerOffset = CVector (pos.x, pos.y, pos.z + 2.0f); - CVector cameraPos - = CVector (playerOffset.x, playerOffset.y, playerOffset.z + curOffset); + if (speed < 0.0f) + { + speed = 0.0f; + } + curOffset += speed; + } - CColPoint outColPoint; - CEntity * outEntity; + CVector playerOffset = CVector (pos.x, pos.y, pos.z + 2.0f); + CVector cameraPos + = CVector (playerOffset.x, playerOffset.y, playerOffset.z + curOffset); - // TODO: Which variable? X, Y or Z for the look direction? + CColPoint outColPoint; + CEntity * outEntity; - 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); - } + // TODO: Which variable? X, Y or Z for the look direction? - Command (pos.x, pos.y, - pos.z, 2); + 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); + } - TheCamera.m_fGenerationDistMultiplier = 10.0f; - TheCamera.m_fLODDistMultiplier = 10.0f; + Command (pos.x, pos.y, + pos.z, 2); + + TheCamera.m_fGenerationDistMultiplier = 10.0f; + TheCamera.m_fLODDistMultiplier = 10.0f; } #endif @@ -108,748 +109,745 @@ Player::Player() { #ifdef GTASA // Fix player model being broken after rebuild - patch::RedirectCall(0x5A834D, &PlayerModelBrokenFix); - m_bAimSkinChanger = gConfig.GetValue("aim_skin_changer", false); + 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_bAutoHeal) - { - static uint lastDmgTimer = 0; - static uint lastHealTimer = 0; - static float health = 0; - float maxHealth = BY_GAME(player->m_fMaxHealth, 100, 100); + if (m_bAutoHeal) + { + static uint lastDmgTimer = 0; + static uint lastHealTimer = 0; + static float health = 0; + float maxHealth = BY_GAME(player->m_fMaxHealth, 100, 100); - if (player->m_fHealth != health) - { - health = player->m_fHealth; - lastDmgTimer = timer; - } + if (player->m_fHealth != health) + { + health = player->m_fHealth; + lastDmgTimer = timer; + } - if (player->m_fHealth != maxHealth - && timer - lastDmgTimer > 5000 - && timer - lastHealTimer > 1000 - ) - { - player->m_fHealth += 0.2f; - lastHealTimer = timer; - health = player->m_fHealth; - } - } + if (player->m_fHealth != maxHealth + && timer - lastDmgTimer > 5000 + && timer - lastHealTimer > 1000 + ) + { + player->m_fHealth += 0.2f; + lastHealTimer = timer; + health = player->m_fHealth; + } + } - 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), 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; -#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_nFlags.bBulletProof = 1; + player->m_nFlags.bCollisionProof = 1; + player->m_nFlags.bExplosionProof = 1; + player->m_nFlags.bFireProof = 1; + player->m_nFlags.bMeleeProof = 1; +#else + 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; -#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_nFlags.bBulletProof = 0; + player->m_nFlags.bCollisionProof = 0; + player->m_nFlags.bExplosionProof = 0; + player->m_nFlags.bFireProof = 0; + player->m_nFlags.bMeleeProof = 0; +#else + 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) { - 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) { - 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); - - CStreaming::SetSpecialCharIsDeletable(291); - } - else - { - int imodel = std::stoi(model); + player->SetModelIndex(291); - CStreaming::RequestModel(imodel, eStreamingFlags::PRIORITY_REQUEST); - CStreaming::LoadAllRequestedModels(false); - player->SetModelIndex(imodel); - CStreaming::SetModelIsDeletable(imodel); - } - Util::ClearCharTasksVehCheck(player); - } + 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); + } } -#else // GTA3 & GTAVC +#else void Player::ChangePlayerModel(std::string& cat, std::string& key, std::string& val) { - CPlayerPed* player = FindPlayerPed(); + CPlayerPed* player = FindPlayerPed(); #ifdef GTAVC - player->Undress(val.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->DeleteRwObject(); - player->SetModelIndex(imodel); - CStreaming::SetModelIsDeletable(imodel); - } + player->Undress(val.c_str()); + CStreaming::LoadAllRequestedModels(false); + player->Dress(); +#else + 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->DeleteRwObject(); + 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); - Ui::CheckboxWithHint("Auto heal", &m_bAutoHeal, "Player will heal when not taken damage for 5 seconds"); + ImGui::Columns(2, 0, false); + Ui::CheckboxWithHint("Auto heal", &m_bAutoHeal, "Player will heal when not taken damage for 5 seconds"); #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; -#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; -#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); -#else // GTA3 & GTAVC - Ui::CheckboxAddress("Infinite sprint", BY_GAME(NULL, (int)&pInfo->m_bNeverGetsTired, (int)&pInfo->m_bInfiniteSprint)); -#endif - - 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); - - 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) - { -#ifdef GTA3 - pPlayer->m_pWanted->SetWantedLevel(0); + 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 - pPlayer->m_pWanted->CheatWantedLevel(0); + 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 - 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); + } +#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); #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); + Ui::CheckboxAddress("Infinite sprint", BY_GAME(NULL, (int)&pInfo->m_bNeverGetsTired, (int)&pInfo->m_bInfiniteSprint)); #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"); - ImGui::Columns(1); + ImGui::NextColumn(); - ImGui::NewLine(); - ImGui::TextWrapped("Player flags,"); - - 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; - } - - 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; - } - - 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.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(); - } - - if (ImGui::BeginTabItem("Menus")) - { - ImGui::BeginChild("PlayerMenus"); - - 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 (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); - ImGui::NextColumn(); - - if (ImGui::RadioButton("Muscle", &m_nUiBodyState, 1)) - CCheat::MuscleCheat(); - - ImGui::NextColumn(); - - if (ImGui::RadioButton("Skinny", &m_nUiBodyState, 0)) - CCheat::SkinnyCheat(); - - ImGui::Columns(1); - } - else - { - ImGui::TextWrapped("You need to be in CJ skin."); - ImGui::Spacing(); - - if (ImGui::Button("Change to CJ skin", ImVec2(Ui::GetSize(1)))) - { - pPlayer->SetModelIndex(0); - Util::ClearCharTasksVehCheck(pPlayer); - } - } - ImGui::Spacing(); - ImGui::Separator(); - } - - Ui::EditStat("Energy", STAT_ENERGY); - Ui::EditStat("Fat", STAT_FAT); + bool never_wanted = patch::Get(0x969171, false); + if (Ui::CheckboxWithHint("Never wanted", &never_wanted)) + { + CCheat::NotWantedCheat(); + } +#else + static bool neverWanted = false; + if (Ui::CheckboxWithHint("Never wanted", &neverWanted)) + { + if (neverWanted) + { +#ifdef GTA3 + pPlayer->m_pWanted->SetWantedLevel(0); +#else + pPlayer->m_pWanted->CheatWantedLevel(0); #endif - Ui::EditReference("Health", pPlayer->m_fHealth, 0, 100, BY_GAME(static_cast(pPlayer->m_fMaxHealth), 100, 100)); + 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); +#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); +#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"); + + ImGui::Columns(1); + + ImGui::NewLine(); + ImGui::TextWrapped("Player flags,"); + + 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; + } + + 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; + } + + 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.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(); + } + + if (ImGui::BeginTabItem("Menus")) + { + ImGui::BeginChild("PlayerMenus"); + + Ui::EditReference("Armour", pPlayer->m_fArmour, 0, 100, 150); #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); -#else // GTA3 & GTAVC - int money = pInfo->m_nMoney; - Ui::EditAddress("Money", (int)&money, -9999999, 0, 99999999); - pInfo->m_nMoney = money; - pInfo->m_nDisplayMoney = money; + 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(); + + if (ImGui::RadioButton("Muscle", &m_nUiBodyState, 1)) + CCheat::MuscleCheat(); + + ImGui::NextColumn(); + + if (ImGui::RadioButton("Skinny", &m_nUiBodyState, 0)) + CCheat::SkinnyCheat(); + + ImGui::Columns(1); + } + else + { + ImGui::TextWrapped("You need to be in CJ skin."); + ImGui::Spacing(); + + if (ImGui::Button("Change to CJ skin", ImVec2(Ui::GetSize(1)))) + { + pPlayer->SetModelIndex(0); + Util::ClearCharTasksVehCheck(pPlayer); + } + } + ImGui::Spacing(); + ImGui::Separator(); + } + + 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)); +#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); +#else + 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; -#else // GTA3 & GTAVC - int val = pPlayer->m_pWanted->m_nWantedLevel; - int max_wl = 6; + 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 + 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); -#else // GTA3 - pPlayer->m_pWanted->SetWantedLevel(val); + pPlayer->m_pWanted->CheatWantedLevel(val); +#else + 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); -#else // GTA3 - pPlayer->m_pWanted->SetWantedLevel(0); + pPlayer->m_pWanted->CheatWantedLevel(0); +#else + 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); -#else // GTA3 - pPlayer->m_pWanted->SetWantedLevel(0); + pPlayer->m_pWanted->CheatWantedLevel(0); +#else + 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); -#else // GTA3 - pPlayer->m_pWanted->SetWantedLevel(max_wl); + pPlayer->m_pWanted->CheatWantedLevel(max_wl); +#else + 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")) + { + if (pPlayer->m_nModelIndex == 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 + { + ImGui::TextWrapped("You need to be in CJ skin."); + ImGui::Spacing(); - return temp; - }, nullptr, cloth_category, sizeof(cloth_category) / sizeof(const char*)); - } - else - { - size_t count = 0; + if (ImGui::Button("Change to CJ skin", ImVec2(Ui::GetSize(1)))) + { + pPlayer->SetModelIndex(0); + Util::ClearCharTasksVehCheck(pPlayer); + } + } + ImGui::EndTabItem(); + } + if (pPlayer->m_nModelIndex == 0 + && ImGui::BeginTabItem("Remove Clothes")) + { + ImGui::TextWrapped("If CJ is wearing a full suit, click 'Extras' or 'Remove all' to remove it."); + ImGui::Spacing(); - 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); - } + ImGui::BeginChild("ClothesRemove"); + 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 (count % 2 != 0) - { - ImGui::SameLine(); - } - ++count; - } + if (count % 2 != 0) + { + ImGui::SameLine(); + } + ++count; + } + ImGui::EndChild(); + 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(); - 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 (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\ @@ -859,31 +857,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(); - } -#else // GTA3 & GTA - if (ImGui::BeginTabItem("Skins")) - { - ImGui::Spacing(); -#ifdef GTA3 - ImGui::TextWrapped("Player must be frozen to change skins."); - CPad::GetPad(0)->m_bDisablePlayerControls = true; + 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 - ImGui::TextWrapped("Only contains the skins that works."); + if (ImGui::BeginTabItem("Skins")) + { + ImGui::Spacing(); +#ifdef GTA3 + ImGui::TextWrapped("Player must be frozen to change skins."); + CPad::GetPad(0)->m_bDisablePlayerControls = true; +#else + 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 eeaa41a..a5846c3 100644 --- a/src/player.h +++ b/src/player.h @@ -4,46 +4,46 @@ class Player { private: - static inline bool m_bAutoHeal; - 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_bAutoHeal; + 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; - }; -#else // GTA3 & GTAVC - static inline ResourceStore skinData{ BY_GAME(NULL, "skin", "ped"), eResourceType::TYPE_TEXT }; + struct m_TopDownCamera + { + static inline bool m_bEnabled = false; + static inline float m_fOffset = 40.0f; + }; +#else + 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(); -#else // GTA3 & GTAVC - static void ChangePlayerModel(std::string& cat, std::string& name, std::string& id); + static void ChangePlayerModel(std::string& model); + static void ChangePlayerCloth(std::string& model); + static void TopDownCameraView(); +#else + static void ChangePlayerModel(std::string& cat, std::string& name, std::string& id); #endif }; diff --git a/src/resourcestore.cpp b/src/resourcestore.cpp index 2fea024..a212837 100644 --- a/src/resourcestore.cpp +++ b/src/resourcestore.cpp @@ -3,10 +3,10 @@ #include "extensions/Paths.h" ResourceStore::ResourceStore(const char* text, eResourceType type, ImVec2 imageSize) -: m_ImageSize(imageSize) + : m_ImageSize(imageSize) { if (type == eResourceType::TYPE_TEXT - || type == eResourceType::TYPE_BOTH) + || type == eResourceType::TYPE_BOTH) { m_pJson = std::make_unique(text); @@ -19,11 +19,11 @@ ResourceStore::ResourceStore(const char* text, eResourceType type, ImVec2 imageS } } } - + if (type == eResourceType::TYPE_IMAGE - || type == eResourceType::TYPE_BOTH) + || type == eResourceType::TYPE_BOTH) { - /* + /* Textures need to be loaded from main thread Loading it directly here doesn't work */ @@ -40,18 +40,18 @@ ResourceStore::ResourceStore(const char* text, eResourceType type, ImVec2 imageS 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) { std::string fullPath = PLUGIN_PATH((char*)"CheatMenu\\") + name + ".txd"; - RwTexDictionary* pRwTexDictionary = CFileLoader::LoadTexDictionary(fullPath.c_str()); + RwTexDictionary* pRwTexDictionary = CFileLoader::LoadTexDictionary(fullPath.c_str()); - if (pRwTexDictionary) - { + if (pRwTexDictionary) + { RwLinkList *pRLL = (RwLinkList*)pRwTexDictionary->texturesInDict.link.next; RwTexDictionary *pEndDic; do @@ -61,7 +61,7 @@ void ResourceStore::LoadTextureResource(std::string&& name) 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); @@ -91,5 +91,5 @@ void ResourceStore::LoadTextureResource(std::string&& name) 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 db089c1..72fd67c 100644 --- a/src/resourcestore.h +++ b/src/resourcestore.h @@ -10,41 +10,41 @@ */ 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>; @@ -54,13 +54,13 @@ private: 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 028c731..746c572 100644 --- a/src/teleport.cpp +++ b/src/teleport.cpp @@ -10,284 +10,284 @@ tRadarTrace* CRadar::ms_RadarTrace = reinterpret_cast(patch::GetPo 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; -#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; + 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 + 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), player->Teleport(m_Teleport::m_fPos)); - } - else - { - BY_GAME(player->Teleport(m_Teleport::m_fPos, false), player->Teleport(m_Teleport::m_fPos), 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), pVeh->Teleport(m_Teleport::m_fPos), player->Teleport(m_Teleport::m_fPos)); + } + else + { + BY_GAME(player->Teleport(m_Teleport::m_fPos, false), player->Teleport(m_Teleport::m_fPos), 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->m_nVehicleClass == VEHICLE_BIKE) - reinterpret_cast(pVeh)->PlaceOnRoadProperly(); - else if (pVeh->m_nVehicleClass != VEHICLE_BOAT) - reinterpret_cast(pVeh)->PlaceOnRoadProperly(); + if (pVeh && pPlayer->m_nPedFlags.bInVehicle) + { + pVeh->Teleport(pos, false); - BY_GAME(pVeh->m_nAreaCode, pVeh->m_nInterior, NULL) = interior_id; - } - else - { - pPlayer->Teleport(pos, false); - } -#else // GTA3 & GTAVC - if (pVeh && pPlayer->m_pVehicle) - { + 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, NULL) = interior_id; + } + else + { + pPlayer->Teleport(pos, false); + } +#else + 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; - Command(interior_id); + BY_GAME(pPlayer->m_nAreaCode, pPlayer->m_nInterior, NULL) = interior_id; + Command(interior_id); #endif } 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) { - 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 07533b9..af9497f 100644 --- a/src/teleport.h +++ b/src/teleport.h @@ -5,38 +5,38 @@ 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 b142f12..099b69b 100644 --- a/src/timecycle.h +++ b/src/timecycle.h @@ -130,7 +130,7 @@ uchar *m_nBlurRed = (uchar *)0x94B790; uchar *m_nBlurGreen = (uchar *)0x8621A0; uchar *m_nBlurBlue = (uchar *)0x945728; -#else // GTA3 +#else int *m_nAmbientRed = (int *)0x86AF78; int *m_nAmbientGreen = (int *)0x665308; diff --git a/src/ui.cpp b/src/ui.cpp index 3dd3ba3..13b7d3b 100644 --- a/src/ui.cpp +++ b/src/ui.cpp @@ -7,46 +7,46 @@ // Really messy code, cleanup someday bool Ui::DrawTitleBar() { - ImGuiContext& g = *GImGui; - ImGuiWindow* window = g.CurrentWindow; - ImGuiID id = window->GetID("#CLOSE"); + ImGuiContext& g = *GImGui; + ImGuiWindow* window = g.CurrentWindow; + ImGuiID id = window->GetID("#CLOSE"); - ImGui::PushFont(FontMgr::GetFont("title")); - CenterdText(MENU_TITLE); + ImGui::PushFont(FontMgr::GetFont("title")); + CenterdText(MENU_TITLE); - if (!ImGui::IsWindowHovered(ImGuiHoveredFlags_RootWindow | ImGuiHoveredFlags_ChildWindows - | ImGuiHoveredFlags_AllowWhenBlockedByPopup | ImGuiHoveredFlags_AllowWhenBlockedByActiveItem)) - { - ImGui::PopFont(); - return false; - } + if (!ImGui::IsWindowHovered(ImGuiHoveredFlags_RootWindow | ImGuiHoveredFlags_ChildWindows + | ImGuiHoveredFlags_AllowWhenBlockedByPopup | ImGuiHoveredFlags_AllowWhenBlockedByActiveItem)) + { + ImGui::PopFont(); + return false; + } - ImVec2 rectMin = ImGui::GetItemRectMin(); // get pos of title text - ImGuiStyle& Style = ImGui::GetStyle(); - float framePadding = Style.FramePadding.x; - float fontSize = ImGui::GetFontSize(); - ImRect title_bar_rect = window->TitleBarRect(); - ImVec2 pos = ImVec2(title_bar_rect.Max.x - framePadding*2 - fontSize, title_bar_rect.Min.y); + ImVec2 rectMin = ImGui::GetItemRectMin(); // get pos of title text + ImGuiStyle& Style = ImGui::GetStyle(); + float framePadding = Style.FramePadding.x; + float fontSize = ImGui::GetFontSize(); + ImRect title_bar_rect = window->TitleBarRect(); + ImVec2 pos = ImVec2(title_bar_rect.Max.x - framePadding*2 - fontSize, title_bar_rect.Min.y); - // drawing the close button + // drawing the close button const ImRect bb(pos, pos + ImVec2(g.FontSize, g.FontSize) + g.Style.FramePadding * 2.0f); ImRect bb_interact = bb; const float area_to_visible_ratio = window->OuterRectClipped.GetArea() / bb.GetArea(); - if (area_to_visible_ratio < 1.5f) - { - bb_interact.Expand(ImFloor(bb_interact.GetSize() * -0.25f)); - } + if (area_to_visible_ratio < 1.5f) + { + bb_interact.Expand(ImFloor(bb_interact.GetSize() * -0.25f)); + } bool hovered, held; bool pressed = ImGui::ButtonBehavior(bb_interact, id, &hovered, &held); - float cross_extent = (fontSize * 0.3f) - 1.0f; - ImVec2 closePos = ImVec2(bb.GetCenter().x - cross_extent, rectMin.y); + float cross_extent = (fontSize * 0.3f) - 1.0f; + ImVec2 closePos = ImVec2(bb.GetCenter().x - cross_extent, rectMin.y); ImU32 closeCol = ImGui::GetColorU32(held || hovered ? ImVec4(0.80f, 0.0f, 0.0f, 1.0f) : ImVec4(0.80f, 0.80f, 0.80f, 1.00f)); - window->DrawList->AddText(closePos, closeCol, "X"); - ImGui::PopFont(); + window->DrawList->AddText(closePos, closeCol, "X"); + ImGui::PopFont(); - return pressed; + return pressed; } bool Ui::RoundedImageButton(ImTextureID user_texture_id, ImVec2& size, const char* hover_text, int frame_padding, const ImVec4& bg_col, const ImVec4& tint_col) @@ -59,918 +59,918 @@ bool Ui::RoundedImageButton(ImTextureID user_texture_id, ImVec2& size, const cha // Default to using texture ID as ID. User can still push string/integer prefixes. ImGui::PushID((void*)(intptr_t)user_texture_id); const ImGuiID id = window->GetID("#image"); - ImGui::PopID(); + ImGui::PopID(); ImVec2 padding = (frame_padding >= 0) ? ImVec2((float)frame_padding, (float)frame_padding) : g.Style.FramePadding; - if (window->SkipItems) - return false; + if (window->SkipItems) + return false; - const ImRect bb(window->DC.CursorPos, window->DC.CursorPos + size + padding * 2); - ImGui::ItemSize(bb); - if (!ImGui::ItemAdd(bb, id)) - return false; + const ImRect bb(window->DC.CursorPos, window->DC.CursorPos + size + padding * 2); + ImGui::ItemSize(bb); + if (!ImGui::ItemAdd(bb, id)) + return false; - bool hovered, held; - bool pressed = ImGui::ButtonBehavior(bb, id, &hovered, &held); + bool hovered, held; + bool pressed = ImGui::ButtonBehavior(bb, id, &hovered, &held); - // Render - const ImU32 col = ImGui::GetColorU32((held && hovered) ? ImGuiCol_ButtonActive : hovered ? ImGuiCol_ButtonHovered : ImGuiCol_Button); - ImGui::RenderNavHighlight(bb, id); - ImGui::RenderFrame(bb.Min, bb.Max, col, true, ImClamp((float)ImMin(padding.x, padding.y), 0.0f, g.Style.FrameRounding)); - if (bg_col.w > 0.0f) - window->DrawList->AddRectFilled(bb.Min + padding, bb.Max - padding, ImGui::GetColorU32(bg_col)); + // Render + const ImU32 col = ImGui::GetColorU32((held && hovered) ? ImGuiCol_ButtonActive : hovered ? ImGuiCol_ButtonHovered : ImGuiCol_Button); + ImGui::RenderNavHighlight(bb, id); + ImGui::RenderFrame(bb.Min, bb.Max, col, true, ImClamp((float)ImMin(padding.x, padding.y), 0.0f, g.Style.FrameRounding)); + if (bg_col.w > 0.0f) + window->DrawList->AddRectFilled(bb.Min + padding, bb.Max - padding, ImGui::GetColorU32(bg_col)); - window->DrawList->AddImageRounded(user_texture_id, bb.Min + padding, bb.Max - padding, ImVec2(0, 0), ImVec2(1, 1), ImGui::GetColorU32(tint_col), 5.0f); + window->DrawList->AddImageRounded(user_texture_id, bb.Min + padding, bb.Max - padding, ImVec2(0, 0), ImVec2(1, 1), ImGui::GetColorU32(tint_col), 5.0f); - if (ImGui::IsItemHovered()) - { - ImDrawList* drawlist = ImGui::GetWindowDrawList(); + 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), 8.0f); + // Drawing selected overlay + ImVec2 btnMin = ImGui::GetItemRectMin(); + ImVec2 btnMax = ImGui::GetItemRectMax(); + drawlist->AddRectFilled(btnMin, btnMax, ImGui::GetColorU32(ImGuiCol_ModalWindowDimBg), 8.0f); - // Calculating and drawing text over the image - ImVec2 textSize = ImGui::CalcTextSize(hover_text); - if (textSize.x < size.x) - { - float offsetX = (ImGui::GetItemRectSize().x - textSize.x) / 2; - drawlist->AddText(ImVec2(btnMin.x + offsetX, btnMin.y + 10), ImGui::GetColorU32(ImGuiCol_Text), hover_text); - } - else - { - std::string buff = ""; - std::stringstream ss(hover_text); - short count = 1; + // Calculating and drawing text over the image + ImVec2 textSize = ImGui::CalcTextSize(hover_text); + if (textSize.x < size.x) + { + float offsetX = (ImGui::GetItemRectSize().x - textSize.x) / 2; + drawlist->AddText(ImVec2(btnMin.x + offsetX, btnMin.y + 10), ImGui::GetColorU32(ImGuiCol_Text), hover_text); + } + else + { + std::string buff = ""; + std::stringstream ss(hover_text); + 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; + } + } + } - return pressed; + return pressed; } 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 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 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) { - ImVec2 size = ImGui::CalcTextSize(text.c_str()); - ImGui::NewLine(); - ImGui::SameLine( - ((ImGui::GetWindowContentRegionWidth() - size.x) / 2) - ); + ImVec2 size = ImGui::CalcTextSize(text.c_str()); + ImGui::NewLine(); + ImGui::SameLine( + ((ImGui::GetWindowContentRegionWidth() - size.x) / 2) + ); - ImGui::Text(text.c_str()); + ImGui::Text(text.c_str()); } void Ui::DrawHeaders(CallbackTable& data) { - static void* pCallback; - ImVec2 size = GetSize(3, false); - ImGuiStyle &style = ImGui::GetStyle(); + static void* pCallback; + ImVec2 size = GetSize(3, false); + ImGuiStyle &style = ImGui::GetStyle(); - ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(0, 0)); - ImGui::PushFont(FontMgr::GetFont("header")); + ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(0, 0)); + ImGui::PushFont(FontMgr::GetFont("header")); - ImDrawList *pDrawList = ImGui::GetWindowDrawList(); - for (size_t i = 0; i < data.size(); ++i) - { - const char* btn_text = data[i].first.c_str(); + ImDrawList *pDrawList = ImGui::GetWindowDrawList(); + for (size_t i = 0; i < data.size(); ++i) + { + const char* btn_text = data[i].first.c_str(); - ImVec4 color; - if (i == m_HeaderId) - { - color = style.Colors[ImGuiCol_ButtonActive]; - pCallback = data[i].second; - } - else - { - color = style.Colors[ImGuiCol_Button]; - } + ImVec4 color; + if (i == m_HeaderId) + { + color = style.Colors[ImGuiCol_ButtonActive]; + pCallback = data[i].second; + } + else + { + color = style.Colors[ImGuiCol_Button]; + } - if (ImGui::InvisibleButton(btn_text, size)) - { - m_HeaderId = i; - gConfig.SetValue("window.idnum", m_HeaderId); - pCallback = data[i].second; - } + if (ImGui::InvisibleButton(btn_text, size)) + { + m_HeaderId = i; + gConfig.SetValue("window.idnum", m_HeaderId); + pCallback = data[i].second; + } - if (ImGui::IsItemHovered()) - { - color = style.Colors[ImGuiCol_ButtonHovered]; - } + if (ImGui::IsItemHovered()) + { + color = style.Colors[ImGuiCol_ButtonHovered]; + } - // hardcoded - ImDrawFlags flags = ImDrawFlags_RoundCornersNone; - if (i == 0) flags = ImDrawFlags_RoundCornersTopLeft; - if (i == 2) flags = ImDrawFlags_RoundCornersTopRight; - if (i == 6) flags = ImDrawFlags_RoundCornersBottomLeft; - if (i == 8) flags = ImDrawFlags_RoundCornersBottomRight; - - ImVec2 min = ImGui::GetItemRectMin(); - ImVec2 max = ImGui::GetItemRectMax(); - ImVec2 size = ImGui::CalcTextSize(btn_text); - pDrawList->AddRectFilled(min, max, ImGui::GetColorU32(color), style.FrameRounding, flags); - ImGui::RenderTextClipped(min + style.FramePadding, max - style.FramePadding, btn_text, NULL, &size, style.ButtonTextAlign); + // hardcoded + ImDrawFlags flags = ImDrawFlags_RoundCornersNone; + if (i == 0) flags = ImDrawFlags_RoundCornersTopLeft; + if (i == 2) flags = ImDrawFlags_RoundCornersTopRight; + if (i == 6) flags = ImDrawFlags_RoundCornersBottomLeft; + if (i == 8) flags = ImDrawFlags_RoundCornersBottomRight; - if (i % 3 != 2) - { - ImGui::SameLine(); - } - } - ImGui::PopFont(); - ImGui::PopStyleVar(); - ImGui::Dummy(ImVec2(0, 10)); + ImVec2 min = ImGui::GetItemRectMin(); + ImVec2 max = ImGui::GetItemRectMax(); + ImVec2 size = ImGui::CalcTextSize(btn_text); + pDrawList->AddRectFilled(min, max, ImGui::GetColorU32(color), style.FrameRounding, flags); + ImGui::RenderTextClipped(min + style.FramePadding, max - style.FramePadding, btn_text, NULL, &size, style.ButtonTextAlign); - if (m_HeaderId != -1) - { - if (pCallback != nullptr && ImGui::BeginChild("TABSBAR")) - { - static_cast(pCallback)(); - ImGui::EndChild(); - } - } + if (i % 3 != 2) + { + ImGui::SameLine(); + } + } + ImGui::PopFont(); + ImGui::PopStyleVar(); + ImGui::Dummy(ImVec2(0, 10)); + + if (m_HeaderId != -1) + { + if (pCallback != nullptr && ImGui::BeginChild("TABSBAR")) + { + static_cast(pCallback)(); + ImGui::EndChild(); + } + } } 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) { - // 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); - - // process the button states - if (ImGui::InvisibleButton(slabel.c_str(), ImVec2(square_sz, square_sz)) && !is_disabled) - { - pressed = true; - *v = !*v; - } + ImGui::BeginDisabled(is_disabled); - if (ImGui::IsItemHovered() && !is_disabled) - color = ImGui::GetColorU32(ImGuiCol_FrameBgHovered); + // process the button states + if (ImGui::InvisibleButton(slabel.c_str(), ImVec2(square_sz, square_sz)) && !is_disabled) + { + pressed = true; + *v = !*v; + } - // draw the button - ImVec2 min = ImGui::GetItemRectMin(); - ImVec2 max = ImGui::GetItemRectMax(); - drawlist->AddRectFilled(min, max, color, ImGui::GetStyle().FrameRounding); + if (ImGui::IsItemHovered() && !is_disabled) + color = ImGui::GetColorU32(ImGuiCol_FrameBgHovered); - int pad = static_cast(square_sz / 6.0); - pad = (pad < 1) ? 1 : pad; + // draw the button + ImVec2 min = ImGui::GetItemRectMin(); + ImVec2 max = ImGui::GetItemRectMax(); + drawlist->AddRectFilled(min, max, color, ImGui::GetStyle().FrameRounding); - 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; + int pad = static_cast(square_sz / 6.0); + pad = (pad < 1) ? 1 : pad; - auto pos = ImVec2(min.x + pad, min.y + pad); - pos.x = pos.x + thickness * 0.25; - pos.y = pos.y + thickness * 0.25; + 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; - float third = sz / 3.0; - float bx = pos.x + third; - float by = pos.y + sz - third * 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; - 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); - } + float third = sz / 3.0; + float bx = pos.x + third; + float by = pos.y + sz - third * 0.5; - // 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 / 2), ImGui::GetColorU32(ImGuiCol_Text), label); + 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 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 / 2), ImGui::GetColorU32(ImGuiCol_TextDisabled), - "?"); + // 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 / 2), ImGui::GetColorU32(ImGuiCol_Text), label); - if (ImGui::IsItemHovered() && !is_disabled) - { - ImGui::BeginTooltip(); - ImGui::Text(hint); - ImGui::Spacing(); - ImGui::EndTooltip(); - } - } + // 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 / 2), ImGui::GetColorU32(ImGuiCol_TextDisabled), + "?"); - ImGui::EndDisabled(); + if (ImGui::IsItemHovered() && !is_disabled) + { + ImGui::BeginTooltip(); + ImGui::Text(hint); + ImGui::Spacing(); + ImGui::EndTooltip(); + } + } - return pressed; + ImGui::EndDisabled(); + + return pressed; } 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 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 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) + 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 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) + 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(); + 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); - } + func_left_click(root_key, data_key, data_val); + } - if (ImGui::IsItemClicked(1) && func_right_click != nullptr) - { - jsonPopup.function = func_right_click; - jsonPopup.root = root.key(); - jsonPopup.key = name; - jsonPopup.value = _data.value(); - } - } - } - } - } + if (ImGui::IsItemClicked(1) && func_right_click != nullptr) + { + jsonPopup.function = func_right_click; + jsonPopup.root = root.key(); + jsonPopup.key = name; + jsonPopup.value = _data.value(); + } + } + } + } + } - if (jsonPopup.function != nullptr) - { - if (ImGui::BeginPopupContextWindow()) - { - ImGui::Text(jsonPopup.key.c_str()); - ImGui::Separator(); - if (ImGui::MenuItem("Remove")) - jsonPopup.function(jsonPopup.root, jsonPopup.key, jsonPopup.value); + if (jsonPopup.function != nullptr) + { + if (ImGui::BeginPopupContextWindow()) + { + ImGui::Text(jsonPopup.key.c_str()); + ImGui::Separator(); + if (ImGui::MenuItem("Remove")) + jsonPopup.function(jsonPopup.root, jsonPopup.key, jsonPopup.value); - if (ImGui::MenuItem("Close")) - jsonPopup.function = nullptr; + if (ImGui::MenuItem("Close")) + jsonPopup.function = nullptr; - ImGui::EndPopup(); - } - } - ImGui::EndChild(); + 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) { - 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) { - 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) + 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"); - if (gRenderer == Render_DirectX9) - { - ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(3, 3)); - ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(3, 3)); - ImGui::PushStyleVar(ImGuiStyleVar_ItemInnerSpacing, ImVec2(3, 3)); - ImGui::PushStyleVar(ImGuiStyleVar_IndentSpacing, 10.0f); - } + ImGui::BeginChild("DrawImages"); + if (gRenderer == Render_DirectX9) + { + ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(3, 3)); + ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(3, 3)); + ImGui::PushStyleVar(ImGuiStyleVar_ItemInnerSpacing, ImVec2(3, 3)); + ImGui::PushStyleVar(ImGuiStyleVar_IndentSpacing, 10.0f); + } - for (uint i = 0; i < store.m_ImagesList.size(); ++i) - { - std::string text = store.m_ImagesList[i]->m_FileName; - std::string modelName = getName(text); + 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 (Ui::RoundedImageButton(store.m_ImagesList[i]->m_pTexture, m_ImageSize, modelName.c_str(), 0, ImVec4(0, 0, 0, 0), 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 (Ui::RoundedImageButton(store.m_ImagesList[i]->m_pTexture, m_ImageSize, modelName.c_str(), 0, ImVec4(0, 0, 0, 0), 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 (imageCount % imagesInRow != 0) - { - ImGui::SameLine(0.0, ImGui::GetStyle().ItemInnerSpacing.x); - } - } - imageCount++; - } - } + if (gRenderer != Render_DirectX11) + { + if (imageCount % imagesInRow != 0) + { + ImGui::SameLine(0.0, ImGui::GetStyle().ItemInnerSpacing.x); + } + } + imageCount++; + } + } - if (gRenderer == Render_DirectX9) - { - ImGui::PopStyleVar(4); - } + if (gRenderer == Render_DirectX9) + { + ImGui::PopStyleVar(4); + } - // 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) { - 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) { - 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) { - 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) { - 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) { - 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) { - 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) + 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(); + ImGui::Spacing(); - if (ImGui::Button(("Minimum##" + std::string(label)).c_str(), GetSize(items))) - patch::Set(address, min / mul, false); + if (ImGui::Button(("Minimum##" + std::string(label)).c_str(), GetSize(items))) + patch::Set(address, min / mul, false); - if (items == 3) - { - ImGui::SameLine(); + if (items == 3) + { + ImGui::SameLine(); - if (ImGui::Button(("Default##" + std::string(label)).c_str(), GetSize(items))) - patch::Set(address, def / mul, false); - } + if (ImGui::Button(("Default##" + std::string(label)).c_str(), GetSize(items))) + patch::Set(address, def / mul, false); + } - ImGui::SameLine(); + ImGui::SameLine(); - if (ImGui::Button(("Maximum##" + std::string(label)).c_str(), GetSize(items))) - patch::Set(address, max / mul, false); + if (ImGui::Button(("Maximum##" + std::string(label)).c_str(), GetSize(items))) + patch::Set(address, max / mul, false); - ImGui::Spacing(); - ImGui::Separator(); - } + ImGui::Spacing(); + ImGui::Separator(); + } } 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 9a0c84d..ad076fc 100644 --- a/src/ui.h +++ b/src/ui.h @@ -5,205 +5,205 @@ 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 root; - std::string value; - }; + struct JsonPopUpData + { + std::function function; + std::string key; + std::string root; + std::string value; + }; - struct ImgPopUpData - { - std::function function; - std::string value; - }; - static inline int m_HeaderId; - static inline JsonPopUpData jsonPopup; - static inline ImgPopUpData imgPopup; + struct ImgPopUpData + { + std::function function; + std::string value; + }; + static inline int m_HeaderId; + static inline JsonPopUpData jsonPopup; + static inline ImgPopUpData imgPopup; - Ui() = delete; - Ui(Ui&) = delete; + 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); + 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); - 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 bool DrawTitleBar(); - 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); + static bool DrawTitleBar(); + 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 bool RoundedImageButton(ImTextureID user_texture_id, ImVec2& size, const char* hover_text, int frame_padding, const ImVec4& bg_col, const ImVec4& tint_col); - static void ColorPickerAddress(const char* label, int base_addr, ImVec4&& default_color); - static void ShowTooltip(const char* text); + static void RadioButtonAddress(const char* label, std::vector& named_mem); + static void RadioButtonAddressEx(const char* label, int addr, std::vector& named_val); + static bool RoundedImageButton(ImTextureID user_texture_id, ImVec2& size, const char* hover_text, int frame_padding, const ImVec4& bg_col, const ImVec4& tint_col); + 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) { - 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) { - 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 8ca83e1..619039c 100644 --- a/src/updater.cpp +++ b/src/updater.cpp @@ -4,64 +4,64 @@ bool Updater::IsUpdateAvailable() { - return Updater::curState == States::FOUND; + return Updater::curState == States::FOUND; } void Updater::ResetUpdaterState() { - Updater::curState = States::IDLE; + Updater::curState = States::IDLE; } std::string Updater::GetUpdateVersion() { - return Updater::latestVer; + return Updater::latestVer; } void Updater::CheckUpdate() { - if (Updater::curState == States::IDLE) - { - Updater::curState = States::CHECKING; - } + if (Updater::curState == States::IDLE) + { + Updater::curState = States::CHECKING; + } } void Updater::Process() { - if (Updater::curState != States::CHECKING) - { - return; - } - - 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 (Updater::curState != States::CHECKING) + { + return; + } - if (res == E_OUTOFMEMORY || res == INET_E_DOWNLOAD_FAILURE) - { - SetHelpMessage("Failed to check for updates", false, false, false); - return; - } - - CJson verinfo = CJson("versioninfo"); + 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); - // fetch the version number - if (verinfo.m_Data.empty()) - { - latestVer = MENU_VERSION_NUMBER; - } - else - { - latestVer = verinfo.m_Data.items().begin().value()["name"].get(); - } + if (res == E_OUTOFMEMORY || res == INET_E_DOWNLOAD_FAILURE) + { + SetHelpMessage("Failed to check for updates", false, false, false); + return; + } - if (latestVer > MENU_VERSION_NUMBER) - { - SetHelpMessage("Update found", false, false, false); - curState = States::FOUND; - } - else - { - SetHelpMessage("No update found.", false, false, false); - Updater::curState = States::IDLE; - } + CJson verinfo = CJson("versioninfo"); + + // fetch the version number + if (verinfo.m_Data.empty()) + { + latestVer = MENU_VERSION_NUMBER; + } + else + { + latestVer = verinfo.m_Data.items().begin().value()["name"].get(); + } + + if (latestVer > MENU_VERSION_NUMBER) + { + SetHelpMessage("Update found", false, false, false); + curState = States::FOUND; + } + else + { + SetHelpMessage("No update found.", false, false, false); + Updater::curState = States::IDLE; + } } diff --git a/src/updater.h b/src/updater.h index 99cb6ab..b87d4c0 100644 --- a/src/updater.h +++ b/src/updater.h @@ -7,25 +7,25 @@ class Updater { private: - enum class States - { - IDLE, - CHECKING, - FOUND - }; - static inline States curState = States::IDLE; - static inline std::string latestVer; - + enum class States + { + IDLE, + CHECKING, + FOUND + }; + static inline States curState = States::IDLE; + static inline std::string latestVer; + public: - Updater() = delete; - Updater(const Updater&) = delete; + Updater() = delete; + Updater(const Updater&) = delete; - static void CheckUpdate(); - static std::string GetUpdateVersion(); - static bool IsUpdateAvailable(); + static void CheckUpdate(); + static std::string GetUpdateVersion(); + static bool IsUpdateAvailable(); - // Needs to run in it's own thread to prevent the game from freezing - static void Process(); - static void ResetUpdaterState(); + // Needs to run in it's own thread to prevent the game from freezing + static void Process(); + static void ResetUpdaterState(); }; diff --git a/src/util.cpp b/src/util.cpp index c4ff2c1..b03f6e7 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -6,191 +6,191 @@ std::string Util::GetLocationName(CVector* pos) { #ifdef GTASA - CPlayerPed *pPlayer = FindPlayerPed(); - int hplayer = CPools::GetPedRef(pPlayer); + CPlayerPed *pPlayer = FindPlayerPed(); + 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 - return "Vice City"; + return "Vice City"; #else - return "Liberty City"; + return "Liberty City"; #endif } #ifdef GTASA 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() { -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; -#else // GTAVC & GTA3 - - CVehicle *pClosestVeh = nullptr; - float distance = 999.0f; + return veh; + } + return nullptr; +#else - CVector playerPos = player->GetPosition(); + CVehicle *pClosestVeh = nullptr; + float distance = 999.0f; - for (CVehicle *pVeh : CPools::ms_pVehiclePool) - { - CVector pos = pVeh->GetPosition(); - float dist = DistanceBetweenPoints(playerPos, pos); + CVector playerPos = player->GetPosition(); - if (dist < distance) - { - pClosestVeh = pVeh; - distance = dist; - } - } - return pClosestVeh; + for (CVehicle *pVeh : CPools::ms_pVehiclePool) + { + CVector pos = pVeh->GetPosition(); + float dist = DistanceBetweenPoints(playerPos, pos); + + if (dist < distance) + { + pClosestVeh = pVeh; + distance = dist; + } + } + return pClosestVeh; #endif } 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; -#else // GTA3 & GTAVC - return player->m_apNearPeds[0]; + return ped; + } + return nullptr; +#else + 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) { - 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 05ea154..d0f4b83 100644 --- a/src/util.h +++ b/src/util.h @@ -5,27 +5,27 @@ class Util { private: - static inline PDH_HQUERY cpuQuery; - static inline PDH_HCOUNTER cpuTotal; - static inline ULARGE_INTEGER lastCPU, lastSysCPU, lastUserCPU; - static inline int numProcessors; - static inline HANDLE self; + static inline PDH_HQUERY cpuQuery; + static inline PDH_HCOUNTER cpuTotal; + static inline ULARGE_INTEGER lastCPU, lastSysCPU, lastUserCPU; + static inline int numProcessors; + static inline HANDLE self; public: - Util() = delete; - Util(Util&) = delete; + Util() = delete; + Util(Util&) = delete; #ifdef GTASA - static void ClearCharTasksVehCheck(CPed* ped); - static int GetLargestGangInZone(); + static void ClearCharTasksVehCheck(CPed* ped); + static int GetLargestGangInZone(); #endif - static CPed* GetClosestPed(); - static CVehicle* GetClosestVehicle(); - static void GetCPUUsageInit(); - static double GetCurrentCPUUsage(); - static std::string GetLocationName(CVector* pos); - static bool IsOnCutscene(); - static bool IsOnMission(); - static void RainbowValues(int& r, int& g, int& b, float speed); + static CPed* GetClosestPed(); + static CVehicle* GetClosestVehicle(); + static void GetCPUUsageInit(); + static double GetCurrentCPUUsage(); + static std::string GetLocationName(CVector* pos); + static bool IsOnCutscene(); + static bool IsOnMission(); + static void RainbowValues(int& r, int& g, int& b, float speed); }; diff --git a/src/vehicle.cpp b/src/vehicle.cpp index 45baf17..496af70 100644 --- a/src/vehicle.cpp +++ b/src/vehicle.cpp @@ -15,1356 +15,1368 @@ void Vehicle::FixVehicle(CVehicle *pVeh) { #ifdef GTASA - pVeh->Fix(); -#else // GTA3 & GTAVC - switch (pVeh->m_nVehicleClass) - { - case VEHICLE_AUTOMOBILE: - { - reinterpret_cast(pVeh)->Fix(); - break; - } + pVeh->Fix(); +#else + 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; } void FlipVehicle() { - CPlayerPed* pPlayer = FindPlayerPed(); + CPlayerPed* pPlayer = FindPlayerPed(); #ifdef GTASA - if (pPlayer->m_nPedFlags.bInVehicle) - { - int hveh = CPools::GetVehicleRef(pPlayer->m_pVehicle); - float roll; + 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 + } #elif GTAVC - if (pPlayer->m_bInVehicle) - { - float x,y,z; - pPlayer->m_pVehicle->m_placement.GetOrientation(x, y, z); - y += 135.0f; - pPlayer->m_pVehicle->m_placement.SetOrientation(x, y, z); - } -#else // GTA3 - if (pPlayer->m_bInVehicle) - { - float x,y,z; - pPlayer->m_pVehicle->GetOrientation(x, y, z); - y += 135.0f; - pPlayer->m_pVehicle->SetOrientation(x, y, z); - } + if (pPlayer->m_bInVehicle) + { + float x,y,z; + pPlayer->m_pVehicle->m_placement.GetOrientation(x, y, z); + y += 135.0f; + pPlayer->m_pVehicle->m_placement.SetOrientation(x, y, z); + } +#else + if (pPlayer->m_bInVehicle) + { + float x,y,z; + pPlayer->m_pVehicle->GetOrientation(x, y, z); + y += 135.0f; + pPlayer->m_pVehicle->SetOrientation(x, y, z); + } #endif } Vehicle::Vehicle() { #ifdef GTASA - FileHandler::FetchHandlingID(m_VehicleIDE); - Neon::InitHooks(); - Paint::InitHooks(); + FileHandler::FetchHandlingID(m_VehicleIDE); + Neon::InitHooks(); + Paint::InitHooks(); #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); - if (flipVeh.Pressed()) - { - FlipVehicle(); - } + if (flipVeh.Pressed()) + { + FlipVehicle(); + } - 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, NULL) == 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, NULL) == 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); - Neon::Install(pVeh, red, green, blue); - m_Neon::m_nRainbowTimer = timer; - } + Util::RainbowValues(red, green, blue, 0.25); + Neon::Install(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 && !Neon::IsInstalled(veh) && veh->m_pDriver != pPlayer) - { - Neon::Install(veh, Random(0, 255), Random(0, 255), Random(0, 255)); - } - } - m_Neon::m_bTrafficTimer = timer; - } + if (chance == 1 && !Neon::IsInstalled(veh) && veh->m_pDriver != pPlayer) + { + Neon::Install(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 - }; + }; } Vehicle::~Vehicle() { #ifdef GTASA - Neon::RemoveHooks(); + Neon::RemoveHooks(); #endif } #ifdef GTASA 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) { - 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) -#else // GTA3 & GTAVC +#else 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); - } -#else // GTA3 & GTAVC - Command(hveh); + if (pveh->m_nVehicleClass == VEHICLE_TRAIN) + { + Command(hveh); + } + else + { + Command(hveh); + } +#else + 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 + float x,y,z; + player->GetOrientation(x, y, z); + veh->SetOrientation(x, y, z); #endif - Command(hplayer, hveh); + Command(hplayer, hveh); #ifndef GTA3 - Command(hveh, speed); + Command(hveh, speed); #endif - } - else - { + } + else + { #ifdef GTASA - 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, CVector(0, 10, 0)); +#else + 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 + 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, NULL) = interior; + BY_GAME(veh->m_nAreaCode, veh->m_nInterior, NULL) = interior; #endif - Command(CPools::GetVehicleRef(veh)); - CStreaming::SetModelIsDeletable(imodel); + Command(CPools::GetVehicleRef(veh)); + CStreaming::SetModelIsDeletable(imodel); #ifdef GTASA - } - veh->m_nVehicleFlags.bHasBeenOwnedByPlayer = true; -#else // GTA3 & GTAVC - Command(); + } + veh->m_nVehicleFlags.bHasBeenOwnedByPlayer = true; +#else + 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 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(3)))) - { - 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(3)))) + { + 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(3)))) - { - if (pPlayer && pVeh) - { - FixVehicle(pVeh); - } - } + if (ImGui::Button("Fix vehicle", ImVec2(Ui::GetSize(3)))) + { + if (pPlayer && pVeh) + { + FixVehicle(pVeh); + } + } - ImGui::SameLine(); + ImGui::SameLine(); - if (ImGui::Button("Flip vehicle", ImVec2(Ui::GetSize(3)))) - { - FlipVehicle(); - } + if (ImGui::Button("Flip vehicle", ImVec2(Ui::GetSize(3)))) + { + FlipVehicle(); + } - 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 #ifndef GTA3 - 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("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)); #endif - Ui::CheckboxAddress("Cars fly", BY_GAME(0x969160, 0xA10B28, 0x95CD75)); - Ui::CheckboxWithHint("Cars heavy", &m_bVehHeavy); - if (Ui::CheckboxWithHint("Damage proof", &m_bNoDamage, - "Every vehicle entered will be damage proof\nBullet, Collision, Explosion, Fire, Meele etc")) - { - if (pVeh && !m_bNoDamage) - { + Ui::CheckboxAddress("Cars fly", BY_GAME(0x969160, 0xA10B28, 0x95CD75)); + Ui::CheckboxWithHint("Cars heavy", &m_bVehHeavy); + 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; -#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_nFlags.bBulletProof = false; + pVeh->m_nFlags.bExplosionProof = false; + pVeh->m_nFlags.bFireProof = false; + pVeh->m_nFlags.bCollisionProof = false; + pVeh->m_nFlags.bMeleeProof = false; +#else + 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, NULL)); + Ui::CheckboxAddress("Drive on water", BY_GAME(0x969152, 0xA10B81, NULL)); #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, NULL)); + Ui::CheckboxAddress("Green traffic lights", BY_GAME(0x96914E, 0xA10ADC, NULL)); #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, "Peds inside won't drown if the vehicle\nis submerged in water"); - Ui::CheckboxAddress("Wheels only", BY_GAME(0x96914B, 0xA10B70, 0x95CD78)); - ImGui::Columns(1); + Ui::CheckboxWithHint("Watertight car", &m_bVehWatertight, "Peds inside won't drown if the vehicle\nis submerged in water"); + 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; - } - - 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; - } + pVeh->m_nVehicleFlags.bEngineOn = 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.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; + } - ImGui::NextColumn(); + 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(); #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::Columns(1); + } + + ImGui::EndChild(); + ImGui::EndTabItem(); + } + if (ImGui::BeginTabItem("Menus")) + { + ImGui::Spacing(); + ImGui::BeginChild("MenusChild"); - 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"); - } + } + 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(); + } - 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, NULL)}, - {"Pink", BY_GAME(0x969150, 0xA10B26, NULL)} - }; - Ui::RadioButtonAddress("Color", color); - ImGui::Spacing(); + static std::vector color + { + {"Black", BY_GAME(0x969151, 0xA10B82, NULL)}, + {"Pink", BY_GAME(0x969150, 0xA10B26, NULL)} + }; + 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)); - }); -#else // GTA3 & GTAVC - Ui::DrawJSON(m_Spawner::m_VehData, SpawnVehicle, nullptr); + Ui::DrawImages(m_Spawner::m_VehData, SpawnVehicle, nullptr, + [](std::string str) + { + return GetNameFromModel(std::stoi(str)); + }); +#else + 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::GenerateNodeList(veh, m_Paint::m_vecNames); + Paint::GenerateNodeList(veh, m_Paint::m_vecNames); - ImGui::Spacing(); - if (ImGui::Button("Reset color", ImVec2(Ui::GetSize()))) - { - Paint::ResetNodeColor(veh, m_Paint::m_Selected); - SetHelpMessage("Color reset", false, false, false); - } - ImGui::Spacing(); + ImGui::Spacing(); + if (ImGui::Button("Reset color", ImVec2(Ui::GetSize()))) + { + Paint::ResetNodeColor(veh, m_Paint::m_Selected); + SetHelpMessage("Color reset", false, false, false); + } + ImGui::Spacing(); - Ui::ListBoxStr("Component", m_Paint::m_vecNames, m_Paint::m_Selected); + Ui::ListBoxStr("Component", m_Paint::m_vecNames, m_Paint::m_Selected); - if (ImGui::ColorEdit3("Color picker", m_Paint::m_fColorPicker)) - { - uchar r = m_Paint::m_fColorPicker[0] * 255; - uchar g = m_Paint::m_fColorPicker[1] * 255; - uchar b = m_Paint::m_fColorPicker[2] * 255; - Paint::SetNodeColor(veh, m_Paint::m_Selected, { r, g, b, 255 }, m_Paint::m_bMatFilter); - } + if (ImGui::ColorEdit3("Color picker", m_Paint::m_fColorPicker)) + { + uchar r = m_Paint::m_fColorPicker[0] * 255; + uchar g = m_Paint::m_fColorPicker[1] * 255; + uchar b = m_Paint::m_fColorPicker[2] * 255; + Paint::SetNodeColor(veh, m_Paint::m_Selected, { r, g, b, 255 }, m_Paint::m_bMatFilter); + } #endif - ImGui::Spacing(); - ImGui::Columns(2, NULL, false); + ImGui::Spacing(); + ImGui::Columns(2, NULL, false); #ifdef GTASA - ImGui::Checkbox("Material filter", &m_Paint::m_bMatFilter); - ImGui::RadioButton("Primary", &m_Paint::m_nRadioButton, 1); - ImGui::RadioButton("Secondary", &m_Paint::m_nRadioButton, 2); - ImGui::NextColumn(); - ImGui::NewLine(); - ImGui::RadioButton("Tertiary", &m_Paint::m_nRadioButton, 3); - ImGui::RadioButton("Quaternary", &m_Paint::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::Checkbox("Material filter", &m_Paint::m_bMatFilter); + ImGui::RadioButton("Primary", &m_Paint::m_nRadioButton, 1); + ImGui::RadioButton("Secondary", &m_Paint::m_nRadioButton, 2); + ImGui::NextColumn(); + ImGui::NewLine(); + ImGui::RadioButton("Tertiary", &m_Paint::m_nRadioButton, 3); + ImGui::RadioButton("Quaternary", &m_Paint::m_nRadioButton, 4); +#else + 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_Paint::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_Paint::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()))) - { - Neon::Remove(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()))) + { + Neon::Remove(veh); + SetHelpMessage("Neon removed", false, false, false); + } - ImGui::Spacing(); - ImGui::Columns(2, NULL, false); + ImGui::Spacing(); + ImGui::Columns(2, NULL, false); - bool pulsing = Neon::IsPulsingEnabled(veh); - if (Ui::CheckboxWithHint("Pulsing neons", &pulsing)) - { - Neon::SetPulsing(veh, pulsing); - } + bool pulsing = Neon::IsPulsingEnabled(veh); + if (Ui::CheckboxWithHint("Pulsing neons", &pulsing)) + { + Neon::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)) - { - Neon::Install(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)) + { + Neon::Install(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:"); - 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::Spacing(); + ImGui::Text("Select neon preset:"); - ImGui::BeginChild("Neonss"); + 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; - 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]; - Neon::Install(veh, color[0] * 255, color[1] * 255, color[2] * 255); - } + ImGui::BeginChild("Neonss"); - if ((color_id + 1) % btnsInRow != 0) - { - ImGui::SameLine(0.0, 4.0); - } - } + 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]; + Neon::Install(veh, color[0] * 255, color[1] * 255, color[2] * 255); + } - ImGui::EndChild(); - ImGui::EndTabItem(); - } - if (ImGui::BeginTabItem("Textures")) - { - Paint::GenerateNodeList(veh, m_Paint::m_vecNames); + if ((color_id + 1) % btnsInRow != 0) + { + ImGui::SameLine(0.0, 4.0); + } + } - ImGui::Spacing(); - if (ImGui::Button("Reset texture", ImVec2(Ui::GetSize()))) - { - Paint::ResetNodeTexture(veh, m_Paint::m_Selected); - SetHelpMessage("Texture reset", false, false, false); - } - ImGui::Spacing(); + ImGui::EndChild(); + ImGui::EndTabItem(); + } + if (ImGui::BeginTabItem("Textures")) + { + Paint::GenerateNodeList(veh, m_Paint::m_vecNames); - Ui::ListBoxStr("Component", m_Paint::m_vecNames, m_Paint::m_Selected); - ImGui::Spacing(); + ImGui::Spacing(); + if (ImGui::Button("Reset texture", ImVec2(Ui::GetSize()))) + { + Paint::ResetNodeTexture(veh, m_Paint::m_Selected); + SetHelpMessage("Texture reset", false, false, false); + } + ImGui::Spacing(); - int maxpjob, curpjob; - Command(hveh, &maxpjob); + Ui::ListBoxStr("Component", m_Paint::m_vecNames, m_Paint::m_Selected); + ImGui::Spacing(); - if (maxpjob > 0) - { - Command(hveh, &curpjob); + int maxpjob, curpjob; + Command(hveh, &maxpjob); - if (ImGui::InputInt("Paintjob", &curpjob)) - { - if (curpjob > maxpjob) - curpjob = -1; - if (curpjob < -1) - curpjob = maxpjob - 1; + if (maxpjob > 0) + { + Command(hveh, &curpjob); - Command(hveh, curpjob); - } + if (ImGui::InputInt("Paintjob", &curpjob)) + { + if (curpjob > maxpjob) + curpjob = -1; + if (curpjob < -1) + curpjob = maxpjob - 1; - ImGui::Spacing(); - } + Command(hveh, curpjob); + } - ImGui::Spacing(); - ImGui::SameLine(); - ImGui::Checkbox("Material filter", &m_Paint::m_bMatFilter); - ImGui::Spacing(); - Ui::DrawImages(Paint::m_TextureData, - [](std::string& str) - { - Paint::SetNodeTexture(FindPlayerPed()->m_pVehicle, m_Paint::m_Selected, str, - m_Paint::m_bMatFilter); - }, - nullptr, - [](std::string& str) - { - return str; - }); + ImGui::Spacing(); + } - 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::Spacing(); + ImGui::SameLine(); + ImGui::Checkbox("Material filter", &m_Paint::m_bMatFilter); + ImGui::Spacing(); + Ui::DrawImages(Paint::m_TextureData, + [](std::string& str) + { + Paint::SetNodeTexture(FindPlayerPed()->m_pVehicle, m_Paint::m_Selected, str, + m_Paint::m_bMatFilter); + }, + nullptr, + [](std::string& str) + { + return str; + }); - ImGui::EndTabItem(); - } - if (ImGui::BeginTabItem("Handling")) - { - ImGui::Spacing(); + 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); + } + ); - CBaseModelInfo* info = CModelInfo::GetModelInfo(pPlayer->m_pVehicle->m_nModelIndex); - int pHandling = patch::Get((int)info + 0x4A, false); - pHandling *= 0xE0; - pHandling += 0xC2B9DC; + ImGui::EndTabItem(); + } + if (ImGui::BeginTabItem("Handling")) + { + ImGui::Spacing(); - if (ImGui::Button("Reset handling", ImVec2(Ui::GetSize(3)))) - { - gHandlingDataMgr.LoadHandlingData(); - SetHelpMessage("Handling reset", false, false, false); - } + CBaseModelInfo* info = CModelInfo::GetModelInfo(pPlayer->m_pVehicle->m_nModelIndex); + int pHandling = patch::Get((int)info + 0x4A, false); + pHandling *= 0xE0; + pHandling += 0xC2B9DC; - ImGui::SameLine(); + if (ImGui::Button("Reset handling", ImVec2(Ui::GetSize(3)))) + { + gHandlingDataMgr.LoadHandlingData(); + SetHelpMessage("Handling reset", 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("Save to file", ImVec2(Ui::GetSize(3)))) + { + FileHandler::GenerateHandlingFile(pHandling, m_VehicleIDE); + SetHelpMessage("Handling saved", false, false, false); + } - if (ImGui::Button("Read more", ImVec2(Ui::GetSize(3)))) - ShellExecute(NULL, "open", "https://projectcerbera.com/gta/sa/tutorials/handling", NULL, NULL, - SW_SHOWNORMAL); + ImGui::SameLine(); - ImGui::Spacing(); + if (ImGui::Button("Read more", ImVec2(Ui::GetSize(3)))) + ShellExecute(NULL, "open", "https://projectcerbera.com/gta/sa/tutorials/handling", NULL, NULL, + SW_SHOWNORMAL); - ImGui::BeginChild("HandlingChild"); + ImGui::Spacing(); - static std::vector abs{ {"On", 1}, {"Off", 0} }; - Ui::EditRadioButtonAddressEx("Abs", pHandling + 0x9C, abs); + ImGui::BeginChild("HandlingChild"); - 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 abs{ {"On", 1}, {"Off", 0} }; + Ui::EditRadioButtonAddressEx("Abs", pHandling + 0x9C, abs); - 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("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("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 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 engine_type{ {"Petrol", 80}, {"Diseal", 68}, {"Electric", 69} }; - Ui::EditRadioButtonAddressEx("Engine type", pHandling + 0x75, engine_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); - std::vector front_lights{ {"Long", 0}, {"Small", 1}, {"Big", 2}, {"Tall", 3} }; - Ui::EditRadioButtonAddressEx("Front lights", pHandling + 0xDC, front_lights); + static std::vector engine_type{ {"Petrol", 80}, {"Diseal", 68}, {"Electric", 69} }; + Ui::EditRadioButtonAddressEx("Engine type", pHandling + 0x75, engine_type); - Ui::EditFloat("Force level", pHandling + 0xAC, -10.0f, -10.0f, 10.0f); // test later + std::vector front_lights{ {"Long", 0}, {"Small", 1}, {"Big", 2}, {"Tall", 3} }; + Ui::EditRadioButtonAddressEx("Front lights", pHandling + 0xDC, front_lights); - Ui::EditBits("Handling flags", pHandling + 0xD0, m_HandlingFlagNames); + Ui::EditFloat("Force level", pHandling + 0xAC, -10.0f, -10.0f, 10.0f); // test later - 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::EditBits("Handling flags", pHandling + 0xD0, m_HandlingFlagNames); - ///fcommon.UpdateAddress({ name = 'Max velocity',address = phandling + 0x84 ,size = 4,min = 0,max = 2,is_float = true,cvalue = 0.01 , save = false }) + 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::EditBits("Model flags", pHandling + 0xCC, m_ModelFlagNames); + ///fcommon.UpdateAddress({ name = 'Max velocity',address = phandling + 0x84 ,size = 4,min = 0,max = 2,is_float = true,cvalue = 0.01 , save = false }) - 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::EditBits("Model flags", pHandling + 0xCC, m_ModelFlagNames); - static std::vector rear_lights{ {"Long", 0}, {"Small", 1}, {"Big", 2}, {"Tall", 3} }; - Ui::EditRadioButtonAddressEx("Rear lights", pHandling + 0xDD, rear_lights); + 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::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); + static std::vector rear_lights{ {"Long", 0}, {"Small", 1}, {"Big", 2}, {"Tall", 3} }; + Ui::EditRadioButtonAddressEx("Rear lights", pHandling + 0xDD, rear_lights); - ImGui::EndChild(); + 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::EndTabItem(); - } + ImGui::EndChild(); + + ImGui::EndTabItem(); + } #endif - } - ImGui::EndTabBar(); - } + } + ImGui::EndTabBar(); + } } \ No newline at end of file diff --git a/src/vehicle.h b/src/vehicle.h index 5c368a9..18e3f87 100644 --- a/src/vehicle.h +++ b/src/vehicle.h @@ -4,101 +4,101 @@ class Vehicle { 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_Paint - { - static inline bool m_bMatFilter = true; - static inline int m_nRadioButton = 1; - static inline float m_fColorPicker[3]{ 0, 0, 0 }; - static inline std::vector m_vecNames{"Default"}; - static inline std::string m_Selected = "Default"; - }; - -#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_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_Paint + { + static inline bool m_bMatFilter = true; + static inline int m_nRadioButton = 1; + static inline float m_fColorPicker[3] { 0, 0, 0 }; + static inline std::vector m_vecNames{"Default"}; + static inline std::string m_Selected = "Default"; + }; - struct m_Spawner - { #ifdef GTASA - 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 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_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" - }; + struct m_Spawner + { +#ifdef GTASA + static inline ResourceStore m_VehData { "vehicles", eResourceType::TYPE_IMAGE, ImVec2(100, 75)}; +#else + 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 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" - }; +#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" + }; #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); -#else // GTA3 & GTAVC - static void SpawnVehicle(std::string& rootkey, std::string& vehName, std::string& model); + static void SpawnVehicle(std::string& name); +#else + 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(); - ~Vehicle(); + static std::string GetNameFromModel(int model); + static int GetModelFromName(const char* name); + static void Draw(); + Vehicle(); + ~Vehicle(); }; diff --git a/src/visual.cpp b/src/visual.cpp index c593906..93c3682 100644 --- a/src/visual.cpp +++ b/src/visual.cpp @@ -13,226 +13,227 @@ #define TOTAL_WEATHERS 23 #elif GTAVC #define TOTAL_WEATHERS 7 -#else // GTA3 +#else #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) { #ifdef GTASA - T* arr = static_cast(patch::GetPointer(int(addr))); -#else // GTA3 & GTAVC - T* arr = static_cast(addr); + T* arr = static_cast(patch::GetPointer(int(addr))); +#else + 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 = TOTAL_WEATHERS * j + i; + int val = TOTAL_WEATHERS * 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; - } - } -#else // GTA3 & GTAVC - std::ofstream file = std::ofstream("timecyc.dat"); + 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; + } + } +#else + std::ofstream file = std::ofstream("timecyc.dat"); - for (uint i = 0; i < TOTAL_WEATHERS; ++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 < TOTAL_WEATHERS; ++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"; #ifdef GTAVC - case 4: - buffer = "\n// EXTRA SUNNY\n"; - case 5: - buffer = "\n// HURRICANE\n"; - case 6: - buffer = "\n// EXTRA COLORS (INTERIORS)\n// These colours do not belong to a weather type but can be set by the level designers for interiors.\n"; + case 4: + buffer = "\n// EXTRA SUNNY\n"; + case 5: + buffer = "\n// HURRICANE\n"; + case 6: + buffer = "\n// EXTRA COLORS (INTERIORS)\n// These colours do not belong to a weather type but can be set by the level designers for interiors.\n"; #endif - } + } #ifdef GTA3 - buffer += "// Amb Dir Sky top Sky bot SunCore SunCorona SunSz SprSz SprBght Shdw LightShd TreeShd FarClp FogSt LightOnGround LowCloudsRGB TopCloudRGB BottomCloudRGB PostFx"; -#else // GTAVC - 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 Dir Sky top Sky bot SunCore SunCorona SunSz SprSz SprBght Shdw LightShd TreeShd FarClp FogSt LightOnGround LowCloudsRGB TopCloudRGB BottomCloudRGB PostFx"; +#else + 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"; #endif - file << buffer << std::endl; + file << buffer << std::endl; - for (size_t j = 0; j < 24; ++j) - { + for (size_t j = 0; j < 24; ++j) + { -#ifdef GTAVC - if (i == 6) //EXTRA COLORS - { - buffer = "// Extra Color " + std::to_string(j); - - static std::string intNames[] = { - "Maibu Club", "Strip Club", "Hotel", "Bank", "Police HQ", "Mall", "Rifle Range", "Mansion", "Dirtring", "Blood ring", - "Hotring", "Concert Hall", "Auntie Poulets", "Intro at Docks", "Biker Bar", "Intro Cafe Dark Room", "Studio" - }; - - if (j < 18) - { - buffer += "(" + intNames[j] + ")"; - } - } - else - { -#endif - buffer = "// " + std::to_string(j) + " "; - if (j < 12) - { - buffer += "AM\n"; - } - else - { - buffer += "PM\n"; - } #ifdef GTAVC - } + if (i == 6) //EXTRA COLORS + { + buffer = "// Extra Color " + std::to_string(j); + + static std::string intNames[] = + { + "Maibu Club", "Strip Club", "Hotel", "Bank", "Police HQ", "Mall", "Rifle Range", "Mansion", "Dirtring", "Blood ring", + "Hotring", "Concert Hall", "Auntie Poulets", "Intro at Docks", "Biker Bar", "Intro Cafe Dark Room", "Studio" + }; + + if (j < 18) + { + buffer += "(" + intNames[j] + ")"; + } + } + else + { +#endif + buffer = "// " + std::to_string(j) + " "; + if (j < 12) + { + buffer += "AM\n"; + } + else + { + buffer += "PM\n"; + } +#ifdef GTAVC + } #endif #ifdef GTA3 - size_t val = i + TOTAL_WEATHERS*j; - buffer += std::format("{} {} {}\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_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), GetTCVal(m_fSpriteSize, val), GetTCVal(m_fSpriteBrightness, val), - GetTCVal(m_nShadowStrength, val), GetTCVal(m_nLightShadowStrength, val), GetTCVal(m_nTreeShadowStrength, val), - GetTCVal(m_fFarClip, val), GetTCVal(m_fFogStart, val), GetTCVal(m_fLightsOnGroundBrightness, val), - 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_fPostFxRed, val), GetTCVal(m_fPostFxGreen, val), GetTCVal(m_fPostFxBlue, val), GetTCVal(m_fPostFxAlpha, val) - ); + size_t val = i + TOTAL_WEATHERS*j; + buffer += std::format("{} {} {}\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_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), GetTCVal(m_fSpriteSize, val), GetTCVal(m_fSpriteBrightness, val), + GetTCVal(m_nShadowStrength, val), GetTCVal(m_nLightShadowStrength, val), GetTCVal(m_nTreeShadowStrength, val), + GetTCVal(m_fFarClip, val), GetTCVal(m_fFogStart, val), GetTCVal(m_fLightsOnGroundBrightness, val), + 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_fPostFxRed, val), GetTCVal(m_fPostFxGreen, val), GetTCVal(m_fPostFxBlue, val), GetTCVal(m_fPostFxAlpha, val) + ); #elif GTAVC - size_t val = TOTAL_WEATHERS * 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) - ); + size_t val = TOTAL_WEATHERS * 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) + ); +#endif + file << buffer << std::endl; + } + } #endif - file << buffer << std::endl; - } - } -#endif } int Visual::CalcArrayIndex() @@ -264,190 +265,190 @@ int Visual::CalcArrayIndex() hour = 7; } #endif - return TOTAL_WEATHERS * hour + CWeather::OldWeatherType; + return TOTAL_WEATHERS * hour + CWeather::OldWeatherType; } template bool Visual::TimeCycColorEdit3(const char* label, T* r, T* g, T* 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))); -#else // GTA3 & 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 + 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; } 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))); -#else // GTA3 & GTAVC - T* arr = static_cast(ptr); + // Compatable with 24h TimeCyc + T* arr = static_cast(patch::GetPointer(int(ptr))); +#else + 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); } template bool Visual::TimeCycColorEdit4(const char* label, T* r, T* g, T* b, T* 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))); -#else // GTA3 & 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 + 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)) - { - 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); - } + 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(); + ImGui::NextColumn(); - if (Ui::CheckboxWithHint("Hide veh names", &CHud::bScriptDontDisplayVehicleName)) - { - Command(!CHud::bScriptDontDisplayVehicleName); - } + 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); + Ui::CheckboxAddressEx("Hide wanted level", 0x58DD1B, 0x90, 1); - // 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); + 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); - // 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); - } + // 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); - 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); + // restore CWaterLevel::GetWaterLevelNoWaves + plugin::patch::SetRaw(0x6E8580, (char*)"\x51\xD9\x44", 3); + } + } - ImGui::NextColumn(); + bool radar_state = (patch::Get(0xBA676C) != 2); + if (Ui::CheckboxWithHint("Show radar", &radar_state)) + { + patch::Set(0xBA676C, radar_state == true ? 0 : 2); + } - Ui::CheckboxAddress("Green scanlines", 0xA10B69); - Ui::CheckboxAddress("White scanlines", 0xA10B68); -#else // GTA3 - static bool hideHud, hideRadar; + 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 + static bool hideHud, hideRadar; if (Ui::CheckboxWithHint("Hide hud", &hideHud)) { if (hideHud) @@ -472,196 +473,197 @@ void Visual::Draw() } Ui::CheckboxWithHint("Lock weather", &m_bLockWeather); #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 change the game hud. i.e. Mobile Hud, GTA 5 Hud, VHud 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(255, 255, 255, 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 change the game hud. i.e. Mobile Hud, GTA 5 Hud, VHud 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(255, 255, 255, 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")) -#else // GTA3 & GTAVC - if (ImGui::BeginTabItem("Timecyc")) + if (m_nTimecycHour == 8 ? ImGui::BeginTabItem("Timecyc") : ImGui::BeginTabItem("Timecyc 24h")) +#else + 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; - if (Game::m_bSyncTime) - { - ImGui::BeginDisabled(Game::m_bSyncTime); - } + if (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, 0x473460), (char *)"\xEB\xEF", 2); @@ -671,12 +673,12 @@ void Visual::Draw() 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(); @@ -706,7 +708,7 @@ void Visual::Draw() TimeCycColorEdit4("PostFx 1", m_fPostFx1Red, m_fPostFx1Green, m_fPostFx1Blue, m_fPostFx1Alpha); TimeCycColorEdit4("PostFx 2", m_fPostFx2Red, m_fPostFx2Green, m_fPostFx2Blue, m_fPostFx1Alpha); #elif GTA3 - TimeCycColorEdit4("PostFx", m_fPostFxRed, m_fPostFxGreen, m_fPostFxBlue, m_fPostFxAlpha); + TimeCycColorEdit4("PostFx", m_fPostFxRed, m_fPostFxGreen, m_fPostFxBlue, m_fPostFxAlpha); #endif TimeCycColorEdit3("Sky bottom", m_nSkyBottomRed, m_nSkyBottomGreen, m_nSkyBottomBlue); @@ -719,11 +721,11 @@ void Visual::Draw() #endif 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); @@ -752,16 +754,16 @@ void Visual::Draw() #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 803d295..be8047c 100644 --- a/src/visual.h +++ b/src/visual.h @@ -4,41 +4,41 @@ 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 - { + // Timecyc stuff + static inline int m_nTimecycHour = 8; + static inline std::vector m_WeatherNames + { #ifdef GTASA - "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" + "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" #else - "SUNNY", "CLOUDY", "RAINY", "FOGGY" + "SUNNY", "CLOUDY", "RAINY", "FOGGY" #ifdef GTAVC - ,"EXTRA_SUNNY", "HURRICANE", "EXTRACOLORS" + ,"EXTRA_SUNNY", "HURRICANE", "EXTRACOLORS" #endif #endif - }; + }; - static void GenerateTimecycFile(); - static int CalcArrayIndex(); - template - static bool TimeCycColorEdit3(const char* label, T* r, T* g, T* b, ImGuiColorEditFlags flags = 0); - template - static bool TimeCycColorEdit4(const char* label, T* r, T* g, T* b, T* a, ImGuiColorEditFlags flags = 0); - template - static void TimecycSlider(const char* label, T* data, int min, int max); + static void GenerateTimecycFile(); + static int CalcArrayIndex(); + template + static bool TimeCycColorEdit3(const char* label, T* r, T* g, T* b, ImGuiColorEditFlags flags = 0); + template + static bool TimeCycColorEdit4(const char* label, T* r, T* g, T* b, T* 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(); }; \ No newline at end of file diff --git a/src/vkeys.h b/src/vkeys.h index aa43882..5ed2d62 100644 --- a/src/vkeys.h +++ b/src/vkeys.h @@ -41,170 +41,170 @@ 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" + "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 b16c3dd..ad4ab12 100644 --- a/src/weapon.cpp +++ b/src/weapon.cpp @@ -2,402 +2,413 @@ #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)); -#else // GTA3 & GTAVC - CWeaponInfo* pWeaponInfo = CWeaponInfo::GetWeaponInfo(weaponType); + CWeaponInfo* pWeaponInfo = CWeaponInfo::GetWeaponInfo(weaponType, player->GetWeaponSkill(weaponType)); +#else + 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; -#else // GTA3 & GTAVC - pWeaponInfo->m_fRange = 1000.0f; + pWeaponInfo->m_fTargetRange = 1000.0f; + pWeaponInfo->m_fWeaponRange = 1000.0f; + pWeaponInfo->m_fAccuracy = 1.0f; + pWeaponInfo->m_nFlags.bReload2Start = true; +#else + pWeaponInfo->m_fRange = 1000.0f; #endif - } + } -#ifdef GTASA - if (m_bRapidFire && weaponType != WEAPON_FTHROWER && weaponType != WEAPON_MINIGUN) // mingun & flamethrower doesn't work with rapidfire - { - pWeaponInfo->m_nFlags.bContinuosFire = true; - } +#ifdef GTASA + if (m_bRapidFire && weaponType != WEAPON_FTHROWER && weaponType != WEAPON_MINIGUN) // mingun & flamethrower 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_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_bMoveAim) + { + pWeaponInfo->m_nFlags.bMoveAim = true; + } - if (m_bMoveFire) - { - pWeaponInfo->m_nFlags.bMoveFire = 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) { - 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 +#else // 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++) - { - - int temp = CallAndReturn(i); // int __cdecl CPickups::ModelForWeapon(int a1) + for (size_t i = 0; i < 37; i++) + { - if (temp == model) - { - weaponType = (eWeaponType)i; - break; - } - } + int temp = CallAndReturn(i); // int __cdecl CPickups::ModelForWeapon(int a1) - return weaponType; + if (temp == model) + { + weaponType = (eWeaponType)i; + break; + } + } + + return weaponType; } #endif #ifdef GTASA 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 +#else 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); -#else // GTA3 & GTAVC - model = CallAndReturn(weaponType); // int __cdecl CPickups::ModelForWeapon(int a1) + Command(weaponType, &model); +#else + 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); -#else // GTA3 & GTAVC - ClearPlayerWeapon(weaponType); + Command(hplayer, weaponType); +#else + 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); -#else // GTA3 - ClearPlayerWeapon(pPlayer->m_aWeapons[pPlayer->m_nCurrentWeapon].m_eWeaponType); -#endif - } - 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); -#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(); - } - } -#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); - } - -#ifdef GTASA - Ui::CheckboxAddress("Infinite ammo", 0x969178); - ImGui::NextColumn(); + ClearPlayerWeapon(pPlayer->m_aWeapons[pPlayer->m_nActiveWeaponSlot].m_nType); #else - ImGui::NextColumn(); - Ui::CheckboxWithHint("Infinite ammo", &m_bInfiniteAmmo); + ClearPlayerWeapon(pPlayer->m_aWeapons[pPlayer->m_nCurrentWeapon].m_eWeaponType); #endif - 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(); - } - } -#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; - } -#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*/ } - ); -#else // GTA3 & GTAVC - Ui::DrawJSON(m_WeaponData, GiveWeaponToPlayer, nullptr); -#endif - ImGui::EndTabItem(); - } -#ifdef GTASA - if (ImGui::BeginTabItem("Gang weapon editor")) - { - ImGui::Spacing(); - Ui::ListBox("Select gang", Ped::m_GangNames, m_nSelectedGang); + } + ImGui::Spacing(); - 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< - 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(); - } + 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(); + } + } #endif - ImGui::EndTabBar(); - } + 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(); +#else + ImGui::NextColumn(); + Ui::CheckboxWithHint("Infinite ammo", &m_bInfiniteAmmo); +#endif + 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(); + } + } +#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; + } +#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*/ + } + ); +#else + Ui::DrawJSON(m_WeaponData, GiveWeaponToPlayer, nullptr); +#endif + ImGui::EndTabItem(); + } +#ifdef GTASA + if (ImGui::BeginTabItem("Gang weapon editor")) + { + ImGui::Spacing(); + Ui::ListBox("Select gang", m_GangList, 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::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(); + } } diff --git a/src/weapon.h b/src/weapon.h index 32c7e23..942856d 100644 --- a/src/weapon.h +++ b/src/weapon.h @@ -1,49 +1,55 @@ #pragma once -#include "CWeapon.h" +#include "pch.h" 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 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 - }; -#else // GTA3 & GTAVC - static inline ResourceStore m_WeaponData{ "weapon", eResourceType::TYPE_TEXT }; - static inline bool m_bInfiniteAmmo; + 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 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 std::vector m_GangList = + { + "Ballas", "Grove street families", "Los santos vagos", "San fierro rifa", + "Da nang boys", "Mafia", "Mountain cloud triad", "Varrio los aztecas", "Gang9", "Gang10" + }; +#else + 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; - Weapon(); - static void Draw(); + Weapon(); + static void Draw(); #ifdef GTASA - static void GiveWeaponToPlayer(std::string& weapon_type); - static void SetGangWeapon(std::string& weapon_type); -#else // GTA3 & GTAVC - static void GiveWeaponToPlayer(std::string& rootkey, std::string& model, std::string& name); + static void GiveWeaponToPlayer(std::string& weapon_type); + static void SetGangWeapon(std::string& weapon_type); +#else + static void GiveWeaponToPlayer(std::string& rootkey, std::string& model, std::string& name); #endif }; diff --git a/tools/AStyle.exe b/tools/AStyle.exe new file mode 100644 index 0000000..2dc842c Binary files /dev/null and b/tools/AStyle.exe differ diff --git a/tools/FormatCode.bat b/tools/FormatCode.bat new file mode 100644 index 0000000..dff0aa1 --- /dev/null +++ b/tools/FormatCode.bat @@ -0,0 +1,2 @@ +start tools/AStyle.exe --style=allman -n --recursive src/*.cpp src/*.h + \ No newline at end of file