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 e3642f5..bb3cc0b 100644 Binary files a/CheatMenu/CheatMenu/clothes.txd and b/CheatMenu/CheatMenu/clothes.txd differ diff --git a/CheatMenu/CheatMenu/json/animation.json b/CheatMenu/CheatMenu/json/animation.json index 698531b..1d19ee6 100644 --- a/CheatMenu/CheatMenu/json/animation.json +++ b/CheatMenu/CheatMenu/json/animation.json @@ -4,7 +4,6 @@ "Stepsit_loop": "ATTRACTORS", "Stepsit_out": "ATTRACTORS" }, - "All": {}, "BAR": { "BARman_idle": "BAR", "Barcustom_get": "BAR", diff --git a/CheatMenu/CheatMenu/json/mission.json b/CheatMenu/CheatMenu/json/mission.json index c526882..9a4458b 100644 --- a/CheatMenu/CheatMenu/json/mission.json +++ b/CheatMenu/CheatMenu/json/mission.json @@ -1,5 +1,4 @@ { - "All": {}, "Arena missions": { "Beat the Cock!": "130", "Blood Ring": "128", diff --git a/CheatMenu/CheatMenu/json/stat.json b/CheatMenu/CheatMenu/json/stat.json index 720cdae..6ff7e24 100644 --- a/CheatMenu/CheatMenu/json/stat.json +++ b/CheatMenu/CheatMenu/json/stat.json @@ -1,5 +1,5 @@ { - "All": { + "Misc": { "120": "People wasted by others", "121": "People you've wasted", "131": "Total number of wanted stars attained", diff --git a/CheatMenu/CheatMenu/json/teleport.json b/CheatMenu/CheatMenu/json/teleport.json index a624d79..4f5836a 100644 --- a/CheatMenu/CheatMenu/json/teleport.json +++ b/CheatMenu/CheatMenu/json/teleport.json @@ -1,5 +1,4 @@ { - "All": {}, "Bribes": { "Bribe 1": "0, 2743, 1316, 8", "Bribe 10": "0, 1592.91, 2053.83, 10.26", diff --git a/CheatMenu/Player.cpp b/CheatMenu/Player.cpp index a1ff7c1..603cb2b 100644 --- a/CheatMenu/Player.cpp +++ b/CheatMenu/Player.cpp @@ -5,6 +5,29 @@ #include "Ui.h" #include "Util.h" +// hardcoded cloth category names +const char* cloth_category[18] = +{ + "Shirts", // 0 + "Heads", // 1 + "Trousers", // 2 + "Shoes", //3 + "Tattoos left lower arm", // 4 + "Tattoos left upper arm", // 5 + "Tattoos right upper arm", // 6 + "Tattoos right lower arm", // 7 + "Tattoos back", // 8 + "Tattoos left chest", // 9 + "Tattoos right chest", // 10 + "Tattoos stomach", // 11 + "Tattoos lower back", // 12 + "Necklaces", // 13 + "Watches", // 13 + "Glasses", // 15 + "Hats", // 16 + "Extras" // 17 +}; + inline static void PlayerModelBrokenFix() { CPlayerPed* pPlayer = FindPlayerPed(); @@ -50,7 +73,7 @@ Player::Player() if (!m_bImagesLoaded) { - Util::LoadTextureDirectory(m_ClothData, PLUGIN_PATH((char*)"CheatMenu\\clothes.txd")); + Util::LoadTextureDirectory(m_ClothData, PLUGIN_PATH((char*)"CheatMenu\\clothes.txd"), true); m_bImagesLoaded = true; } @@ -383,7 +406,7 @@ void Player::Draw() getline(ss, temp, '$'); return temp; - }); + }, nullptr, cloth_category, sizeof(cloth_category)/ sizeof(const char*)); } else { diff --git a/CheatMenu/Ui.cpp b/CheatMenu/Ui.cpp index 026080d..0bd463d 100644 --- a/CheatMenu/Ui.cpp +++ b/CheatMenu/Ui.cpp @@ -29,13 +29,10 @@ bool Ui::ListBoxStr(const char* label, std::vector& 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); };