From acedf1a14cf175f74c97fef3ce7dc0bc50df8e96 Mon Sep 17 00:00:00 2001 From: Grinch_ Date: Sat, 17 Jul 2021 19:42:09 +0600 Subject: [PATCH] Fix crashes with cloth picker and more fixes --- .gitignore | 2 + CheatMenu/CheatMenu/clothes.txd | Bin 6165992 -> 6165992 bytes CheatMenu/CheatMenu/json/animation.json | 1 - CheatMenu/CheatMenu/json/mission.json | 1 - CheatMenu/CheatMenu/json/stat.json | 2 +- CheatMenu/CheatMenu/json/teleport.json | 1 - CheatMenu/Player.cpp | 27 +++++++++- CheatMenu/Ui.cpp | 54 ++++++++++++++++---- CheatMenu/Ui.h | 14 +++--- CheatMenu/Util.cpp | 64 +++++++++++++++++------- CheatMenu/Util.h | 2 +- 11 files changed, 125 insertions(+), 43 deletions(-) diff --git a/.gitignore b/.gitignore index e53d784..fd0ac76 100644 --- a/.gitignore +++ b/.gitignore @@ -68,3 +68,5 @@ Depend/x64/Debug/Depend.tlog/CL.command.1.tlog Depend/x64/Debug/Depend.tlog/CL.read.1.tlog Depend/x64/Debug/Depend.tlog/CL.write.1.tlog Depend/x64/Debug/Depend.tlog/Depend.lastbuildstate +CheatMenu/CheatMenu/json/versioninfo.json +CheatMenu/CheatMenu/json/config.json diff --git a/CheatMenu/CheatMenu/clothes.txd b/CheatMenu/CheatMenu/clothes.txd index e3642f54ecbad1bb16dd1dd24b0582125fbd4d84..bb3cc0b27ab91f0d4a2af573ee00744dc435abd9 100644 GIT binary patch delta 7091 zcmaKxe^69cmdC516@=zDh?-7Bd?HGNbn{D8qAfp#78Dc^WhM%bSr-Io zyMUm_WhPG}z_U;QQz3%tBLX;&AQ%`DKr@UWVzySPL9FA! zb#!>P_PCL>nmMI|W-Zu8{~&;_3qjT$0ov{$=m~#W3?}?#0G`zXn5q#}pAf)#0>Quo z0W=R0L>OM-HLQkL0JPdUAY)5s@20D_zCw&-^em@TN70rwEN_AgI13fb$xHfuK-cLo+=TKt!Pc)yvcRL|F_X#sjni&cMXzbhX;X*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y&(JTE9)FhHoLD-u3Gu>9W71aTmgc*Ib|m5l^!25teKVSn>TAk# zD1FH02kx)WG8R`+`jMOeN?+>ML+y^lvVCOyk1NFbZEdYv>l&Jwq$K<=J3lLj`@;F3 zJ+QKjbcW5whrl1M$mkZD_(>3MH3kbocsFByaC5h?91?v~Yoo2HWfOj4u*-ot8sMR+ z2Q~MwH~K|NxwW<3X13axWTw7#XUn!GTXU zujl2!O>lG$JUb!v)yJzc0GpVSoSDU3*Vb&d zwpkhBJM!v>wfK>DD>@&3*shYCnH^N_+D5kGkJZ%IRFc{ze?Xd@)8-#llBQI-kr^&a z1Dwi@l*E)DL~suZ@>nEM%kwyfTWo@hjaO&hB1ya1hf%{$@DGOM`n?AKmElW6Cb=;`PXV1@8Z^lwVV|Fu2}rD@FwL60OtLjRe*tu@$x~B= zy%PzS%h2vT+C+2CjYH=-31R;q7ojW&1JBR$5-2B4czz~e3OcR5Am8m?m@jePg*a;G z!k%6EizyTP?_2?_`#`?LeZuVoof8r(yRrbgRTe}ilm5bWD&L%)ZTK4zLxv02;q$(e zHBWON+Ix)asvi-^v5OpukKx~-@#(}GHfS%rrLCzE^{SIK_;BlF&0j@GuUzkzdWNm1 zq^5m5zGy#u!X2QpWW2Uzsnej%B#!!F* z++ElJR}2Mx)O#ag#!hHw> o=Dqt%L*mOvDMHF7P`*-l{H_&B& all_items, std: { for (std::string current_item : all_items) { - if (current_item != label) + if (ImGui::MenuItem(current_item.c_str())) { - if (ImGui::MenuItem(current_item.c_str())) - { - selected = current_item; - rtn = true; - } + selected = current_item; + rtn = true; } } ImGui::EndCombo(); @@ -44,6 +41,33 @@ bool Ui::ListBoxStr(const char* label, std::vector& all_items, std: return rtn; } +bool Ui::ListBoxCustomNames(const char* label, std::vector& all_items, std::string& selected, const char* custom_names[], size_t length) +{ + bool rtn = false; + std::string display_selected = (selected == "All") ? selected: custom_names[std::stoi(selected)]; + + 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(custom_names[i])) + { + selected = std::to_string(i); + rtn = true; + break; + } + } + ImGui::EndCombo(); + } + return rtn; +} + ImVec2 Ui::GetSize(short count, bool spacing) { if (count == 1) @@ -323,9 +347,9 @@ bool Ui::CheckboxBitFlag(const char* label, uint flag, const char* hint) } void Ui::DrawJSON(CJson& json, std::vector& combo_items, std::string& selected_item, - ImGuiTextFilter& filter, - std::function func_left_click, - std::function func_right_click) + ImGuiTextFilter& filter, + std::function func_left_click, + std::function func_right_click) { ImGui::PushItemWidth(ImGui::GetContentRegionAvailWidth() / 2 - 5); ListBoxStr("##Categories", combo_items, selected_item); @@ -462,7 +486,7 @@ void Ui::DrawImages(std::vector>& img_vec, Im std::vector& category_vec, std::string& selected_item, ImGuiTextFilter& filter, std::function on_left_click, std::function on_right_click, std::function get_name_func, - std::function verify_func) + std::function verify_func, const char** custom_names, size_t length) { // scale image size image_size.x *= screen::GetScreenWidth() / 1366.0f; @@ -480,7 +504,15 @@ void Ui::DrawImages(std::vector>& img_vec, Im imgPopup.function = nullptr; ImGui::PushItemWidth(ImGui::GetContentRegionAvailWidth() / 2 - 5); - ListBoxStr("##Categories", category_vec, selected_item); + if (custom_names) + { + ListBoxCustomNames("##Categories", category_vec, selected_item, custom_names, length); + } + else + { + ListBoxStr("##Categories", category_vec, selected_item); + } + ImGui::SameLine(); FilterWithHint("##Filter", filter, "Search"); diff --git a/CheatMenu/Ui.h b/CheatMenu/Ui.h index 28dcb1d..fd4191e 100644 --- a/CheatMenu/Ui.h +++ b/CheatMenu/Ui.h @@ -52,12 +52,13 @@ public: ImGuiTextFilter& filter, std::function func_left_click, std::function func_right_click); - static void DrawImages(std::vector>& img_vec, ImVec2 image_size, - std::vector& category_vec, std::string& selected_item, ImGuiTextFilter& filter, - std::function on_left_click, - std::function on_right_click, - std::function get_name_func, - std::function verify_func = nullptr); + static void DrawImages( std::vector>& img_vec, ImVec2 image_size, + std::vector& category_vec, std::string& selected_item, ImGuiTextFilter& filter, + std::function on_left_click, + std::function on_right_click, + std::function get_name_func, + std::function verify_func = nullptr, + const char** custom_names = nullptr, size_t length = 0); template static void EditAddress(const char* label, int address, int min = 0, int def = 0, int max = 100); @@ -79,6 +80,7 @@ public: 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); diff --git a/CheatMenu/Util.cpp b/CheatMenu/Util.cpp index d8295d6..8dd094e 100644 --- a/CheatMenu/Util.cpp +++ b/CheatMenu/Util.cpp @@ -1,6 +1,5 @@ #include "pch.h" #include "Util.h" -#include "../Depend/imgui/stb_image.h" #include #include "psapi.h" #include "CFileLoader.h" @@ -29,7 +28,7 @@ struct RwRasterEx : public RwRaster RwD3D9Raster *renderResource; }; -void Util::LoadTextureDirectory(SSearchData& data, char *path) +void Util::LoadTextureDirectory(SSearchData& data, char *path, bool pass_full_name) { RwTexDictionary* pRwTexDictionary = &data.txd; @@ -37,27 +36,54 @@ void Util::LoadTextureDirectory(SSearchData& data, char *path) if (pRwTexDictionary) { - RwTexDictionaryForAllTextures(pRwTexDictionary, [](RwTexture* tex, void* data) + // FIX ME + if (pass_full_name) { - SSearchData* sdata = reinterpret_cast(data); - sdata->m_ImagesList.push_back(std::make_unique()); - sdata->m_ImagesList.back().get()->m_pRwTexture = tex; - sdata->m_ImagesList.back().get()->m_pTexture = GetTextureFromRaster(tex); - - std::stringstream ss(tex->name); - std::string str; - getline(ss, str, '$'); - sdata->m_ImagesList.back().get()->m_CategoryName = str; - if (!std::count(sdata->m_Categories.begin(), sdata->m_Categories.end(), str)) + RwTexDictionaryForAllTextures(pRwTexDictionary, [](RwTexture* tex, void* data) { - sdata->m_Categories.push_back(str); - } - getline(ss, str); - sdata->m_ImagesList.back().get()->m_FileName = str; + SSearchData* sdata = reinterpret_cast(data); + sdata->m_ImagesList.push_back(std::make_unique()); + sdata->m_ImagesList.back().get()->m_pRwTexture = tex; + sdata->m_ImagesList.back().get()->m_pTexture = GetTextureFromRaster(tex); - return tex; + std::stringstream ss(tex->name); + std::string str; + getline(ss, str, '$'); - }, &data); + sdata->m_ImagesList.back().get()->m_CategoryName = str; + if (!std::count(sdata->m_Categories.begin(), sdata->m_Categories.end(), str)) + { + sdata->m_Categories.push_back(str); + } + sdata->m_ImagesList.back().get()->m_FileName = tex->name; + + return tex; + }, &data); + } + else + { + RwTexDictionaryForAllTextures(pRwTexDictionary, [](RwTexture* tex, void* data) + { + SSearchData* sdata = reinterpret_cast(data); + sdata->m_ImagesList.push_back(std::make_unique()); + sdata->m_ImagesList.back().get()->m_pRwTexture = tex; + sdata->m_ImagesList.back().get()->m_pTexture = GetTextureFromRaster(tex); + + std::stringstream ss(tex->name); + std::string str; + getline(ss, str, '$'); + + sdata->m_ImagesList.back().get()->m_CategoryName = str; + if (!std::count(sdata->m_Categories.begin(), sdata->m_Categories.end(), str)) + { + sdata->m_Categories.push_back(str); + } + getline(ss, str); + sdata->m_ImagesList.back().get()->m_FileName = str; + + return tex; + }, &data); + } } } diff --git a/CheatMenu/Util.h b/CheatMenu/Util.h index f33a573..1ac0603 100644 --- a/CheatMenu/Util.h +++ b/CheatMenu/Util.h @@ -22,6 +22,6 @@ public: static void GetCPUUsageInit(); static double GetCurrentCPUUsage(); static void* GetTextureFromRaster(RwTexture* pTexture); - static void LoadTextureDirectory(SSearchData& data, char* path); + static void LoadTextureDirectory(SSearchData& data, char* path, bool pass_full_name = false); static RwTexture* LoadTextureFromMemory(char* data, unsigned int size); };