Disable images for renderhook for now (crash fix)

This commit is contained in:
Grinch_ 2021-07-26 18:58:34 +06:00
parent 64f76e8adc
commit 90c4285f9f
9 changed files with 280 additions and 229 deletions

96
.gitignore vendored
View File

@ -1,95 +1 @@
.vs/ build/
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

15
.vscode/launch.json vendored
View File

@ -5,10 +5,21 @@
"version": "0.2.0", "version": "0.2.0",
"configurations": [ "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", "type": "cppvsdbg",
"request": "attach", "request": "attach",
"processId": "${command:pickProcess}" "processId": "${command:pickProcess}"
}, }
] ]
} }

70
.vscode/settings.json vendored
View File

@ -5,6 +5,74 @@
"functional": "cpp", "functional": "cpp",
"memory": "cpp", "memory": "cpp",
"thread": "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"
} }
} }

41
.vscode/tasks.json vendored Normal file
View File

@ -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
}
}
]
}

6
Debug.bat Normal file
View File

@ -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 ..

View File

@ -4,7 +4,7 @@
Required: Required:
DirectX 9 SDK DirectX 9 SDK
Plugin SDK Plugin SDK
Visual Studio 2019 (v142) Build Tools 2019 (v142)
Windows SDK Windows SDK
*/ */

View File

@ -530,10 +530,22 @@ void Ui::DrawImages(std::vector<std::unique_ptr<STextureStructure>>& img_vec, Im
&& (verify_func == nullptr || verify_func(text)) && (verify_func == nullptr || verify_func(text))
) )
{ {
IDirect3DTexture9* texture = (IDirect3DTexture9*)Util::GetTextureFromRaster(img_vec[i]->m_pRwTexture); if (Globals::renderer == Render_DirectX11)
if (ImGui::ImageButton(texture, image_size, ImVec2(0, 0), ImVec2(1, 1), 1, ImVec4(1, 1, 1, 1), {
ImVec4(1, 1, 1, 1))) if (ImGui::MenuItem(model_name.c_str()))
on_left_click(text); {
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) if (ImGui::IsItemClicked(1) && on_right_click != nullptr)
{ {
@ -541,43 +553,47 @@ void Ui::DrawImages(std::vector<std::unique_ptr<STextureStructure>>& img_vec, Im
imgPopup.value = model_name; imgPopup.value = model_name;
} }
if (ImGui::IsItemHovered()) if (Globals::renderer != Render_DirectX11)
{ {
ImDrawList* drawlist = ImGui::GetWindowDrawList(); if (ImGui::IsItemHovered())
ImVec2 btn_min = ImGui::GetItemRectMin();
ImVec2 btn_max = ImGui::GetItemRectMax();
drawlist->AddRectFilled(btn_min, btn_max, ImGui::GetColorU32(ImGuiCol_ModalWindowDimBg));
ImVec2 text_size = ImGui::CalcTextSize(model_name.c_str());
if (text_size.x < image_size.x)
{ {
float offsetX = (ImGui::GetItemRectSize().x - text_size.x) / 2; ImDrawList* drawlist = ImGui::GetWindowDrawList();
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); ImVec2 btn_min = ImGui::GetItemRectMin();
short count = 1; 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; float offsetX = (ImGui::GetItemRectSize().x - text_size.x) / 2;
drawlist->AddText(ImVec2(btn_min.x + offsetX, btn_min.y + 10 * count), drawlist->AddText(ImVec2(btn_min.x + offsetX, btn_min.y + 10), ImGui::GetColorU32(ImGuiCol_Text),
ImGui::GetColorU32(ImGuiCol_Text), buff.c_str()); model_name.c_str());
++count; }
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++; images_count++;
} }
} }

View File

@ -1028,113 +1028,116 @@ void Vehicle::Draw()
ImGui::EndChild(); ImGui::EndChild();
ImGui::EndTabItem(); ImGui::EndTabItem();
} }
if (ImGui::BeginTabItem("Neons")) if (Globals::renderer != Render_DirectX11)
{ {
ImGui::Spacing(); if (ImGui::BeginTabItem("Neons"))
if (ImGui::Button("Remove neon", ImVec2(Ui::GetSize())))
{ {
RemoveNeon(veh); ImGui::Spacing();
CHud::SetHelpMessage("Neon removed", false, false, false); if (ImGui::Button("Remove neon", ImVec2(Ui::GetSize())))
}
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<float>& color = m_CarcolsColorData[color_id]; RemoveNeon(veh);
InstallNeon(veh, color[0] * 255, color[1] * 255, color[2] * 255); CHud::SetHelpMessage("Neon removed", false, false, false);
}
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<Commands::GET_NUM_AVAILABLE_PAINTJOBS>(hveh, &maxpjob);
if (maxpjob > 0)
{
Command<Commands::GET_CURRENT_VEHICLE_PAINTJOB>(hveh, &curpjob);
if (ImGui::InputInt("Paintjob", &curpjob))
{
if (curpjob > maxpjob)
curpjob = -1;
if (curpjob < -1)
curpjob = maxpjob - 1;
Command<Commands::GIVE_VEHICLE_PAINTJOB>(hveh, curpjob);
} }
ImGui::Spacing(); 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<float>& 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::Spacing();
ImGui::SameLine(); if (ImGui::Button("Reset texture", ImVec2(Ui::GetSize())))
ImGui::Checkbox("Material filter", &m_Color::m_bMatFilter); {
ImGui::Spacing(); Paint::ResetNodeTexture(veh, Paint::veh_nodes::selected);
Ui::DrawImages(m_TextureData.m_ImagesList, ImVec2(100, 80), m_TextureData.m_Categories, m_TextureData.m_Selected, CHud::SetHelpMessage("Texture reset", false, false, false);
m_TextureData.m_Filter, }
[](std::string& str) ImGui::Spacing();
{
Paint::SetNodeTexture(FindPlayerPed()->m_pVehicle, Paint::veh_nodes::selected, str,
m_Color::m_bMatFilter);
},
nullptr,
[](std::string& str)
{
return str;
});
ImGui::EndTabItem(); Ui::ListBoxStr("Component", Paint::veh_nodes::names_vec, Paint::veh_nodes::selected);
ImGui::Spacing();
int maxpjob, curpjob;
Command<Commands::GET_NUM_AVAILABLE_PAINTJOBS>(hveh, &maxpjob);
if (maxpjob > 0)
{
Command<Commands::GET_CURRENT_VEHICLE_PAINTJOB>(hveh, &curpjob);
if (ImGui::InputInt("Paintjob", &curpjob))
{
if (curpjob > maxpjob)
curpjob = -1;
if (curpjob < -1)
curpjob = maxpjob - 1;
Command<Commands::GIVE_VEHICLE_PAINTJOB>(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")) if (ImGui::BeginTabItem("Tune"))
{ {