Fix crashes with cloth picker and more fixes
This commit is contained in:
parent
c1c4951e85
commit
acedf1a14c
2
.gitignore
vendored
2
.gitignore
vendored
@ -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
|
||||
|
Binary file not shown.
@ -4,7 +4,6 @@
|
||||
"Stepsit_loop": "ATTRACTORS",
|
||||
"Stepsit_out": "ATTRACTORS"
|
||||
},
|
||||
"All": {},
|
||||
"BAR": {
|
||||
"BARman_idle": "BAR",
|
||||
"Barcustom_get": "BAR",
|
||||
|
@ -1,5 +1,4 @@
|
||||
{
|
||||
"All": {},
|
||||
"Arena missions": {
|
||||
"Beat the Cock!": "130",
|
||||
"Blood Ring": "128",
|
||||
|
@ -1,5 +1,5 @@
|
||||
{
|
||||
"All": {
|
||||
"Misc": {
|
||||
"120": "People wasted by others",
|
||||
"121": "People you've wasted",
|
||||
"131": "Total number of wanted stars attained",
|
||||
|
@ -1,5 +1,4 @@
|
||||
{
|
||||
"All": {},
|
||||
"Bribes": {
|
||||
"Bribe 1": "0, 2743, 1316, 8",
|
||||
"Bribe 10": "0, 1592.91, 2053.83, 10.26",
|
||||
|
@ -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
|
||||
{
|
||||
|
@ -29,13 +29,10 @@ bool Ui::ListBoxStr(const char* label, std::vector<std::string>& 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<std::string>& all_items, std:
|
||||
return rtn;
|
||||
}
|
||||
|
||||
bool Ui::ListBoxCustomNames(const char* label, std::vector<std::string>& 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<std::string>& combo_items, std::string& selected_item,
|
||||
ImGuiTextFilter& filter,
|
||||
std::function<void(std::string&, std::string&, std::string&)> func_left_click,
|
||||
std::function<void(std::string&, std::string&, std::string&)> func_right_click)
|
||||
ImGuiTextFilter& filter,
|
||||
std::function<void(std::string&, std::string&, std::string&)> func_left_click,
|
||||
std::function<void(std::string&, std::string&, std::string&)> func_right_click)
|
||||
{
|
||||
ImGui::PushItemWidth(ImGui::GetContentRegionAvailWidth() / 2 - 5);
|
||||
ListBoxStr("##Categories", combo_items, selected_item);
|
||||
@ -462,7 +486,7 @@ void Ui::DrawImages(std::vector<std::unique_ptr<STextureStructure>>& img_vec, Im
|
||||
std::vector<std::string>& category_vec, std::string& selected_item, ImGuiTextFilter& filter,
|
||||
std::function<void(std::string&)> on_left_click, std::function<void(std::string&)> on_right_click,
|
||||
std::function<std::string(std::string&)> get_name_func,
|
||||
std::function<bool(std::string&)> verify_func)
|
||||
std::function<bool(std::string&)> 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<std::unique_ptr<STextureStructure>>& 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");
|
||||
|
||||
|
@ -52,12 +52,13 @@ public:
|
||||
ImGuiTextFilter& filter,
|
||||
std::function<void(std::string&, std::string&, std::string&)> func_left_click,
|
||||
std::function<void(std::string&, std::string&, std::string&)> func_right_click);
|
||||
static void DrawImages(std::vector<std::unique_ptr<STextureStructure>>& img_vec, ImVec2 image_size,
|
||||
std::vector<std::string>& category_vec, std::string& selected_item, ImGuiTextFilter& filter,
|
||||
std::function<void(std::string&)> on_left_click,
|
||||
std::function<void(std::string&)> on_right_click,
|
||||
std::function<std::string(std::string&)> get_name_func,
|
||||
std::function<bool(std::string&)> verify_func = nullptr);
|
||||
static void DrawImages( std::vector<std::unique_ptr<STextureStructure>>& img_vec, ImVec2 image_size,
|
||||
std::vector<std::string>& category_vec, std::string& selected_item, ImGuiTextFilter& filter,
|
||||
std::function<void(std::string&)> on_left_click,
|
||||
std::function<void(std::string&)> on_right_click,
|
||||
std::function<std::string(std::string&)> get_name_func,
|
||||
std::function<bool(std::string&)> verify_func = nullptr,
|
||||
const char** custom_names = nullptr, size_t length = 0);
|
||||
|
||||
template <typename T>
|
||||
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<std::string>& all_items, int& selected);
|
||||
static bool ListBoxStr(const char* label, std::vector<std::string>& all_items, std::string& selected);
|
||||
static bool ListBoxCustomNames(const char* label, std::vector<std::string>& all_items, std::string& selected, const char* custom_names[] = nullptr, size_t length = 0);
|
||||
|
||||
static void RadioButtonAddress(const char* label, std::vector<NamedMemory>& named_mem);
|
||||
static void RadioButtonAddressEx(const char* label, int addr, std::vector<NamedValue>& named_val);
|
||||
|
@ -1,6 +1,5 @@
|
||||
#include "pch.h"
|
||||
#include "Util.h"
|
||||
#include "../Depend/imgui/stb_image.h"
|
||||
#include <CCutsceneMgr.h>
|
||||
#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<SSearchData*>(data);
|
||||
sdata->m_ImagesList.push_back(std::make_unique<STextureStructure>());
|
||||
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<SSearchData*>(data);
|
||||
sdata->m_ImagesList.push_back(std::make_unique<STextureStructure>());
|
||||
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<SSearchData*>(data);
|
||||
sdata->m_ImagesList.push_back(std::make_unique<STextureStructure>());
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user