From 90c4285f9fdceec6f66f2f3269ce652738661c03 Mon Sep 17 00:00:00 2001 From: Grinch_ Date: Mon, 26 Jul 2021 18:58:34 +0600 Subject: [PATCH] Disable images for renderhook for now (crash fix) --- .gitignore | 96 +------------------ .vscode/launch.json | 15 ++- .vscode/settings.json | 70 +++++++++++++- .vscode/tasks.json | 41 ++++++++ Debug.bat | 6 ++ Build.bat => Release.bat | 0 src/CheatMenu.h | 2 +- src/Ui.cpp | 80 +++++++++------- src/Vehicle.cpp | 199 ++++++++++++++++++++------------------- 9 files changed, 280 insertions(+), 229 deletions(-) create mode 100644 .vscode/tasks.json create mode 100644 Debug.bat rename Build.bat => Release.bat (100%) diff --git a/.gitignore b/.gitignore index 71587c1..567609b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,95 +1 @@ -.vs/ -tools/.vs/ -tools/build/ -tools/obj/ -.vs/CheatMenu/v16/.suo -.vs/CheatMenu/v16/Browse.VC.db -.vs/CheatMenu/v16/Solution.VC.db -.vs/CheatMenu/v16/ipch/8a8161b1be2b4103.ipch -.vs/CheatMenu/v16/ipch/e9b0a2fc8cb1509e.ipch -.vs/CheatMenu/v16/ipch/e024ae0f5d73c047.ipch -.vs/CheatMenu/v16/ipch/AutoPCH/265b236fe4986752/UI.ipch -.vs/CheatMenu/v16/ipch/AutoPCH/38b746beec6fb244/IMGUI_WIDGETS.ipch -.vs/CheatMenu/v16/ipch/AutoPCH/3e1cbf187f313294/WEAPON.ipch -.vs/CheatMenu/v16/ipch/AutoPCH/756823df130098d3/HOOK.ipch -.vs/CheatMenu/v16/ipch/AutoPCH/7a8af3ed3d3a54c4/TEXTURES.ipch -.vs/CheatMenu/v16/ipch/AutoPCH/829db28faf316540/UTIL.ipch -.vs/CheatMenu/v16/ipch/AutoPCH/9c90f2807ada373e/IMGUI.ipch -.vs/CheatMenu/v16/ipch/AutoPCH/a09bb0abeabbe0f/LIBRARY.ipch -.vs/CheatMenu/v16/ipch/AutoPCH/a4014625ad130402/VEHICLE.ipch -.vs/CheatMenu/v16/ipch/AutoPCH/a40641fdc3b117af/TELEPORT.ipch -.vs/CheatMenu/v16/ipch/AutoPCH/ab7214dce69112ca/PAINT.ipch -.vs/CheatMenu/v16/ipch/AutoPCH/bbb77d6129ef6abe/CHEATMENU.ipch -.vs/CheatMenu/v16/ipch/AutoPCH/bff6ab00c8dfdfd2/GAME.ipch -.vs/CheatMenu/v16/ipch/AutoPCH/d1aef004461bf238/LIBRARY.ipch -.vs/CheatMenu/v16/ipch/AutoPCH/ee897a6fe2800285/PLAYER.ipch -.vs/CheatMenu/v16/ipch/AutoPCH/f13b890baaf60e88/NEON.ipch -.vs/CheatMenu/v16/ipch/AutoPCH/f42ec7dda8d23a7b/PED.ipch -.vs/CheatMenu2/v16/.suo -.vs/CheatMenu2/v16/Browse.VC.db -tools/.vs/CheatMenu/v16/.suo -tools/.vs/CheatMenu/v16/Browse.VC.db -tools/.vs/CheatMenu/v16/Solution.VC.db -tools/CheatMenu.sln -tools/Depend.vcxproj -tools/CheatMenu.vcxproj -tools/Depend.vcxproj.filters -build/CheatMenu.sln -build/CheatMenu.vcxproj -build/Depend.vcxproj -build/Depend.vcxproj.filters -build/bin/Depend.lib -build/bin/Depend.pdb -build/obj/Win32/Release/CheatMenu/Animation.obj -build/obj/Win32/Release/CheatMenu/CheatMenu.asi.recipe -build/obj/Win32/Release/CheatMenu/CheatMenu.obj -build/obj/Win32/Release/CheatMenu/CheatMenu.pch -build/obj/Win32/Release/CheatMenu/Game.obj -build/obj/Win32/Release/CheatMenu/Hook.obj -build/obj/Win32/Release/CheatMenu/Json.obj -build/obj/Win32/Release/CheatMenu/Menu.obj -build/obj/Win32/Release/CheatMenu/MoreEvents.obj -build/obj/Win32/Release/CheatMenu/Neon.obj -build/obj/Win32/Release/CheatMenu/Paint.obj -build/obj/Win32/Release/CheatMenu/pch.obj -build/obj/Win32/Release/CheatMenu/Ped.obj -build/obj/Win32/Release/CheatMenu/Player.obj -build/obj/Win32/Release/CheatMenu/Teleport.obj -build/obj/Win32/Release/CheatMenu/Ui.obj -build/obj/Win32/Release/CheatMenu/Updater.obj -build/obj/Win32/Release/CheatMenu/Util.obj -build/obj/Win32/Release/CheatMenu/vc142.pdb -build/obj/Win32/Release/CheatMenu/Vehicle.obj -build/obj/Win32/Release/CheatMenu/Visual.obj -build/obj/Win32/Release/CheatMenu/Weapon.obj -build/obj/Win32/Release/CheatMenu/CheatMenu.tlog/CheatMenu.lastbuildstate -build/obj/Win32/Release/CheatMenu/CheatMenu.tlog/CL.command.1.tlog -build/obj/Win32/Release/CheatMenu/CheatMenu.tlog/CL.read.1.tlog -build/obj/Win32/Release/CheatMenu/CheatMenu.tlog/CL.write.1.tlog -build/obj/Win32/Release/CheatMenu/CheatMenu.tlog/link.command.1.tlog -build/obj/Win32/Release/CheatMenu/CheatMenu.tlog/link.read.1.tlog -build/obj/Win32/Release/CheatMenu/CheatMenu.tlog/link.write.1.tlog -build/obj/Win32/Release/Depend/buffer.obj -build/obj/Win32/Release/Depend/Depend.lib.recipe -build/obj/Win32/Release/Depend/hde32.obj -build/obj/Win32/Release/Depend/hook.obj -build/obj/Win32/Release/Depend/IDaccess.obj -build/obj/Win32/Release/Depend/imgui_demo.obj -build/obj/Win32/Release/Depend/imgui_draw.obj -build/obj/Win32/Release/Depend/imgui_impl_dx9.obj -build/obj/Win32/Release/Depend/imgui_impl_dx11.obj -build/obj/Win32/Release/Depend/imgui_impl_win32.obj -build/obj/Win32/Release/Depend/imgui_tables.obj -build/obj/Win32/Release/Depend/imgui_widgets.obj -build/obj/Win32/Release/Depend/imgui.obj -build/obj/Win32/Release/Depend/kiero.obj -build/obj/Win32/Release/Depend/Library.obj -build/obj/Win32/Release/Depend/Main.obj -build/obj/Win32/Release/Depend/trampoline.obj -build/obj/Win32/Release/Depend/Depend.tlog/CL.command.1.tlog -build/obj/Win32/Release/Depend/Depend.tlog/CL.read.1.tlog -build/obj/Win32/Release/Depend/Depend.tlog/CL.write.1.tlog -build/obj/Win32/Release/Depend/Depend.tlog/Depend.lastbuildstate -build/obj/Win32/Release/Depend/Depend.tlog/Lib-link.read.1.tlog -build/obj/Win32/Release/Depend/Depend.tlog/Lib-link.write.1.tlog -build/obj/Win32/Release/Depend/Depend.tlog/Lib.command.1.tlog +build/ diff --git a/.vscode/launch.json b/.vscode/launch.json index 8897664..03db11e 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -5,10 +5,21 @@ "version": "0.2.0", "configurations": [ { - "name": "(Windows) Attach", + "name": "Launch SA", + "type": "cppvsdbg", + "request": "launch", + "program": "C:/Work/GTASanAndreas/gta_sa.exe", + "args": [], + "stopAtEntry": false, + "cwd": "C:/Work/GTASanAndreas/", + "environment": [], + "console": "internalConsole" + }, + { + "name": "Attach", "type": "cppvsdbg", "request": "attach", "processId": "${command:pickProcess}" - }, + } ] } \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json index 7fc04fd..88ce727 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -5,6 +5,74 @@ "functional": "cpp", "memory": "cpp", "thread": "cpp", - "xmemory": "cpp" + "xmemory": "cpp", + "iosfwd": "cpp", + "array": "cpp", + "atomic": "cpp", + "bit": "cpp", + "cctype": "cpp", + "charconv": "cpp", + "clocale": "cpp", + "cmath": "cpp", + "compare": "cpp", + "concepts": "cpp", + "condition_variable": "cpp", + "cstddef": "cpp", + "cstdint": "cpp", + "cstdio": "cpp", + "cstdlib": "cpp", + "cstring": "cpp", + "ctime": "cpp", + "cwchar": "cpp", + "exception": "cpp", + "filesystem": "cpp", + "format": "cpp", + "forward_list": "cpp", + "fstream": "cpp", + "initializer_list": "cpp", + "iomanip": "cpp", + "ios": "cpp", + "iostream": "cpp", + "istream": "cpp", + "iterator": "cpp", + "limits": "cpp", + "list": "cpp", + "locale": "cpp", + "map": "cpp", + "mutex": "cpp", + "new": "cpp", + "numeric": "cpp", + "optional": "cpp", + "ostream": "cpp", + "ratio": "cpp", + "shared_mutex": "cpp", + "sstream": "cpp", + "stdexcept": "cpp", + "stop_token": "cpp", + "streambuf": "cpp", + "string": "cpp", + "system_error": "cpp", + "tuple": "cpp", + "type_traits": "cpp", + "typeinfo": "cpp", + "unordered_map": "cpp", + "utility": "cpp", + "valarray": "cpp", + "vector": "cpp", + "xfacet": "cpp", + "xhash": "cpp", + "xiosbase": "cpp", + "xlocale": "cpp", + "xlocbuf": "cpp", + "xlocinfo": "cpp", + "xlocmes": "cpp", + "xlocmon": "cpp", + "xlocnum": "cpp", + "xloctime": "cpp", + "xstddef": "cpp", + "xstring": "cpp", + "xtr1common": "cpp", + "xtree": "cpp", + "xutility": "cpp" } } \ No newline at end of file diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 0000000..c7f89b2 --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,41 @@ +{ + // See https://go.microsoft.com/fwlink/?LinkId=733558 + // for the documentation about the tasks.json format + "version": "2.0.0", + "tasks": [ + { + "label": "Build Debug", + "type": "shell", + "command": "Debug.bat", + "presentation": { + "echo": true, + "reveal": "always", + "focus": false, + "panel": "shared", + "showReuseMessage": false, + "clear": true + }, + "group": { + "kind": "build", + "isDefault": true + } + }, + { + "label": "Build Release", + "type": "shell", + "command": "Release.bat", + "presentation": { + "echo": true, + "reveal": "always", + "focus": false, + "panel": "shared", + "showReuseMessage": false, + "clear": true + }, + "group": { + "kind": "build", + "isDefault": true + } + } + ] +} \ No newline at end of file diff --git a/Debug.bat b/Debug.bat new file mode 100644 index 0000000..3f0bc32 --- /dev/null +++ b/Debug.bat @@ -0,0 +1,6 @@ +@echo off +premake5.exe vs2019 +cd build +call "C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\Common7\Tools\VsDevCmd.bat" +MsBuild CheatMenu.sln /property:Configuration=Debug +cd .. diff --git a/Build.bat b/Release.bat similarity index 100% rename from Build.bat rename to Release.bat diff --git a/src/CheatMenu.h b/src/CheatMenu.h index ae67509..645aab3 100644 --- a/src/CheatMenu.h +++ b/src/CheatMenu.h @@ -4,7 +4,7 @@ Required: DirectX 9 SDK Plugin SDK - Visual Studio 2019 (v142) + Build Tools 2019 (v142) Windows SDK */ diff --git a/src/Ui.cpp b/src/Ui.cpp index ba034cd..b3b07a0 100644 --- a/src/Ui.cpp +++ b/src/Ui.cpp @@ -530,10 +530,22 @@ void Ui::DrawImages(std::vector>& img_vec, Im && (verify_func == nullptr || verify_func(text)) ) { - IDirect3DTexture9* texture = (IDirect3DTexture9*)Util::GetTextureFromRaster(img_vec[i]->m_pRwTexture); - if (ImGui::ImageButton(texture, image_size, ImVec2(0, 0), ImVec2(1, 1), 1, ImVec4(1, 1, 1, 1), - ImVec4(1, 1, 1, 1))) - on_left_click(text); + if (Globals::renderer == Render_DirectX11) + { + if (ImGui::MenuItem(model_name.c_str())) + { + on_left_click(text); + } + } + else + { + IDirect3DTexture9* texture = (IDirect3DTexture9*)Util::GetTextureFromRaster(img_vec[i]->m_pRwTexture); + if (ImGui::ImageButton(texture, image_size, ImVec2(0, 0), ImVec2(1, 1), 1, ImVec4(1, 1, 1, 1),ImVec4(1, 1, 1, 1))) + { + on_left_click(text); + } + } + if (ImGui::IsItemClicked(1) && on_right_click != nullptr) { @@ -541,43 +553,47 @@ void Ui::DrawImages(std::vector>& img_vec, Im imgPopup.value = model_name; } - if (ImGui::IsItemHovered()) + if (Globals::renderer != Render_DirectX11) { - ImDrawList* drawlist = ImGui::GetWindowDrawList(); - - ImVec2 btn_min = ImGui::GetItemRectMin(); - ImVec2 btn_max = ImGui::GetItemRectMax(); - - drawlist->AddRectFilled(btn_min, btn_max, ImGui::GetColorU32(ImGuiCol_ModalWindowDimBg)); - - ImVec2 text_size = ImGui::CalcTextSize(model_name.c_str()); - if (text_size.x < image_size.x) + if (ImGui::IsItemHovered()) { - float offsetX = (ImGui::GetItemRectSize().x - text_size.x) / 2; - drawlist->AddText(ImVec2(btn_min.x + offsetX, btn_min.y + 10), ImGui::GetColorU32(ImGuiCol_Text), - model_name.c_str()); - } - else - { - std::string buff = ""; + ImDrawList* drawlist = ImGui::GetWindowDrawList(); - std::stringstream ss(model_name); - short count = 1; + ImVec2 btn_min = ImGui::GetItemRectMin(); + ImVec2 btn_max = ImGui::GetItemRectMax(); - while (ss >> buff) + drawlist->AddRectFilled(btn_min, btn_max, ImGui::GetColorU32(ImGuiCol_ModalWindowDimBg)); + + ImVec2 text_size = ImGui::CalcTextSize(model_name.c_str()); + if (text_size.x < image_size.x) { - text_size = ImGui::CalcTextSize(buff.c_str()); float offsetX = (ImGui::GetItemRectSize().x - text_size.x) / 2; - drawlist->AddText(ImVec2(btn_min.x + offsetX, btn_min.y + 10 * count), - ImGui::GetColorU32(ImGuiCol_Text), buff.c_str()); - ++count; + drawlist->AddText(ImVec2(btn_min.x + offsetX, btn_min.y + 10), ImGui::GetColorU32(ImGuiCol_Text), + model_name.c_str()); + } + else + { + std::string buff = ""; + + std::stringstream ss(model_name); + short count = 1; + + while (ss >> buff) + { + text_size = ImGui::CalcTextSize(buff.c_str()); + float offsetX = (ImGui::GetItemRectSize().x - text_size.x) / 2; + drawlist->AddText(ImVec2(btn_min.x + offsetX, btn_min.y + 10 * count), + ImGui::GetColorU32(ImGuiCol_Text), buff.c_str()); + ++count; + } } } + + if (images_count % images_in_row != 0) + { + ImGui::SameLine(0.0, ImGui::GetStyle().ItemInnerSpacing.x); + } } - - if (images_count % images_in_row != 0) - ImGui::SameLine(0.0, ImGui::GetStyle().ItemInnerSpacing.x); - images_count++; } } diff --git a/src/Vehicle.cpp b/src/Vehicle.cpp index e6b56ed..ad1a0ef 100644 --- a/src/Vehicle.cpp +++ b/src/Vehicle.cpp @@ -1028,113 +1028,116 @@ void Vehicle::Draw() ImGui::EndChild(); ImGui::EndTabItem(); } - if (ImGui::BeginTabItem("Neons")) + if (Globals::renderer != Render_DirectX11) { - ImGui::Spacing(); - if (ImGui::Button("Remove neon", ImVec2(Ui::GetSize()))) + if (ImGui::BeginTabItem("Neons")) { - RemoveNeon(veh); - CHud::SetHelpMessage("Neon removed", false, false, false); - } - - ImGui::Spacing(); - ImGui::Columns(2, NULL, false); - - bool pulsing = IsPulsingEnabled(veh); - if (Ui::CheckboxWithHint("Pulsing neons", &pulsing)) - SetPulsing(veh, pulsing); - - Ui::CheckboxWithHint("Rainbow neons", &m_Neon::m_bRainbowEffect, "Rainbow effect to neon lights"); - ImGui::NextColumn(); - Ui::CheckboxWithHint("Traffic neons", &m_Neon::m_bApplyOnTraffic, "Adds neon lights to traffic vehicles.\n\ -Only some vehicles will have them."); - ImGui::Columns(1); - - ImGui::Spacing(); - - if (ImGui::ColorEdit3("Color picker", m_Neon::m_fColorPicker)) - InstallNeon(veh, m_Neon::m_fColorPicker[0] * 255, m_Neon::m_fColorPicker[1] * 255, - m_Neon::m_fColorPicker[2] * 255); - - 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::BeginChild("Neonss"); - - for (int color_id = 0; color_id < count; ++color_id) - { - if (Ui::ColorButton(color_id, m_CarcolsColorData[color_id], ImVec2(btnSize, btnSize))) + ImGui::Spacing(); + if (ImGui::Button("Remove neon", ImVec2(Ui::GetSize()))) { - std::vector& color = m_CarcolsColorData[color_id]; - InstallNeon(veh, color[0] * 255, color[1] * 255, color[2] * 255); - } - - if ((color_id + 1) % btnsInRow != 0) - ImGui::SameLine(0.0, 4.0); - } - - ImGui::EndChild(); - ImGui::EndTabItem(); - } - if (ImGui::BeginTabItem("Textures")) - { - Paint::UpdateNodeListRecursive(veh); - - ImGui::Spacing(); - if (ImGui::Button("Reset texture", ImVec2(Ui::GetSize()))) - { - Paint::ResetNodeTexture(veh, Paint::veh_nodes::selected); - CHud::SetHelpMessage("Texture reset", false, false, false); - } - ImGui::Spacing(); - - Ui::ListBoxStr("Component", Paint::veh_nodes::names_vec, Paint::veh_nodes::selected); - ImGui::Spacing(); - - int maxpjob, curpjob; - Command(hveh, &maxpjob); - - if (maxpjob > 0) - { - Command(hveh, &curpjob); - - if (ImGui::InputInt("Paintjob", &curpjob)) - { - if (curpjob > maxpjob) - curpjob = -1; - if (curpjob < -1) - curpjob = maxpjob - 1; - - Command(hveh, curpjob); + RemoveNeon(veh); + CHud::SetHelpMessage("Neon removed", false, false, false); } ImGui::Spacing(); + ImGui::Columns(2, NULL, false); + + bool pulsing = IsPulsingEnabled(veh); + if (Ui::CheckboxWithHint("Pulsing neons", &pulsing)) + SetPulsing(veh, pulsing); + + Ui::CheckboxWithHint("Rainbow neons", &m_Neon::m_bRainbowEffect, "Rainbow effect to neon lights"); + ImGui::NextColumn(); + Ui::CheckboxWithHint("Traffic neons", &m_Neon::m_bApplyOnTraffic, "Adds neon lights to traffic vehicles.\n\ + Only some vehicles will have them."); + ImGui::Columns(1); + + ImGui::Spacing(); + + if (ImGui::ColorEdit3("Color picker", m_Neon::m_fColorPicker)) + InstallNeon(veh, m_Neon::m_fColorPicker[0] * 255, m_Neon::m_fColorPicker[1] * 255, + m_Neon::m_fColorPicker[2] * 255); + + 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::BeginChild("Neonss"); + + for (int color_id = 0; color_id < count; ++color_id) + { + if (Ui::ColorButton(color_id, m_CarcolsColorData[color_id], ImVec2(btnSize, btnSize))) + { + std::vector& color = m_CarcolsColorData[color_id]; + InstallNeon(veh, color[0] * 255, color[1] * 255, color[2] * 255); + } + + if ((color_id + 1) % btnsInRow != 0) + ImGui::SameLine(0.0, 4.0); + } + + ImGui::EndChild(); + ImGui::EndTabItem(); } + if (ImGui::BeginTabItem("Textures")) + { + Paint::UpdateNodeListRecursive(veh); - ImGui::Spacing(); - ImGui::SameLine(); - ImGui::Checkbox("Material filter", &m_Color::m_bMatFilter); - ImGui::Spacing(); - Ui::DrawImages(m_TextureData.m_ImagesList, ImVec2(100, 80), m_TextureData.m_Categories, m_TextureData.m_Selected, - m_TextureData.m_Filter, - [](std::string& str) - { - Paint::SetNodeTexture(FindPlayerPed()->m_pVehicle, Paint::veh_nodes::selected, str, - m_Color::m_bMatFilter); - }, - nullptr, - [](std::string& str) - { - return str; - }); + ImGui::Spacing(); + if (ImGui::Button("Reset texture", ImVec2(Ui::GetSize()))) + { + Paint::ResetNodeTexture(veh, Paint::veh_nodes::selected); + CHud::SetHelpMessage("Texture reset", false, false, false); + } + ImGui::Spacing(); - ImGui::EndTabItem(); + Ui::ListBoxStr("Component", Paint::veh_nodes::names_vec, Paint::veh_nodes::selected); + ImGui::Spacing(); + + int maxpjob, curpjob; + Command(hveh, &maxpjob); + + if (maxpjob > 0) + { + Command(hveh, &curpjob); + + if (ImGui::InputInt("Paintjob", &curpjob)) + { + if (curpjob > maxpjob) + curpjob = -1; + if (curpjob < -1) + curpjob = maxpjob - 1; + + Command(hveh, curpjob); + } + + ImGui::Spacing(); + } + + ImGui::Spacing(); + ImGui::SameLine(); + ImGui::Checkbox("Material filter", &m_Color::m_bMatFilter); + ImGui::Spacing(); + Ui::DrawImages(m_TextureData.m_ImagesList, ImVec2(100, 80), m_TextureData.m_Categories, m_TextureData.m_Selected, + m_TextureData.m_Filter, + [](std::string& str) + { + Paint::SetNodeTexture(FindPlayerPed()->m_pVehicle, Paint::veh_nodes::selected, str, + m_Color::m_bMatFilter); + }, + nullptr, + [](std::string& str) + { + return str; + }); + + ImGui::EndTabItem(); + } } if (ImGui::BeginTabItem("Tune")) {