This commit is contained in:
Grinch_ 2021-08-13 23:45:56 +06:00
parent d34a1ff213
commit e56f5b02c4
14 changed files with 102 additions and 87 deletions

View File

@ -6,10 +6,10 @@
"${workspaceFolder}/**", "${workspaceFolder}/**",
"${PLUGIN_SDK_DIR}/*", "${PLUGIN_SDK_DIR}/*",
"${DIRECTX9_SDK_DIR}/Include/*", "${DIRECTX9_SDK_DIR}/Include/*",
// "${PLUGIN_SDK_DIR}/plugin_sa/*", "${PLUGIN_SDK_DIR}/plugin_sa/*",
// "${PLUGIN_SDK_DIR}/plugin_sa/game_sa/*", "${PLUGIN_SDK_DIR}/plugin_sa/game_sa/*",
"${PLUGIN_SDK_DIR}/plugin_vc/*", // "${PLUGIN_SDK_DIR}/plugin_vc/*",
"${PLUGIN_SDK_DIR}/plugin_vc/game_vc/*", // "${PLUGIN_SDK_DIR}/plugin_vc/game_vc/*",
"${PLUGIN_SDK_DIR}/shared/*", "${PLUGIN_SDK_DIR}/shared/*",
"${PLUGIN_SDK_DIR}/shared/game/*", "${PLUGIN_SDK_DIR}/shared/game/*",
"C:\\Program Files (x86)\\Windows Kits\\10\\Include\\10.0.19041.0\\ucrt\\*", "C:\\Program Files (x86)\\Windows Kits\\10\\Include\\10.0.19041.0\\ucrt\\*",
@ -20,7 +20,7 @@
"IS_PLATFORM_WIN", "IS_PLATFORM_WIN",
"_CRT_SECURE_NO_WARNINGS", "_CRT_SECURE_NO_WARNINGS",
"_CRT_NON_CONFORMING_SWPRINTFS", "_CRT_NON_CONFORMING_SWPRINTFS",
"GTAVC", "GTASA",
"_DX9_SDK_INSTALLED", "_DX9_SDK_INSTALLED",
"PLUGIN_SGV_10US" "PLUGIN_SGV_10US"
], ],

View File

@ -73,7 +73,7 @@ private:
inline static VehicleExtendedData<VehData> m_VehData; inline static VehicleExtendedData<VehData> m_VehData;
protected: protected:
inline static ResourceStore m_TextureData { "textures" }; inline static ResourceStore m_TextureData { "textures", eResourceType::TYPE_IMAGE, ImVec2(100, 80) };
struct veh_nodes struct veh_nodes
{ {

View File

@ -260,8 +260,7 @@ void Ped::Draw()
{ {
ImGui::Spacing(); ImGui::Spacing();
#ifdef GTASA #ifdef GTASA
Ui::DrawImages(m_PedData.m_ImagesList, ImVec2(65, 110), m_PedData.m_Categories, m_PedData.m_Selected, Ui::DrawImages(m_PedData, SpawnPed, nullptr,
m_PedData.m_Filter, SpawnPed, nullptr,
[](std::string str) { return m_PedData.m_pJson->m_Data[str].get<std::string>(); }); [](std::string str) { return m_PedData.m_pJson->m_Data[str].get<std::string>(); });
#elif GTAVC #elif GTAVC
Ui::DrawJSON(m_PedData, SpawnPed, nullptr); Ui::DrawJSON(m_PedData, SpawnPed, nullptr);
@ -295,8 +294,7 @@ void Ped::Draw()
Weapon::m_WeaponData.m_pJson->m_Data[std::to_string(m_SpawnPed::m_nWeaponId)].get<std::string>().c_str()); Weapon::m_WeaponData.m_pJson->m_Data[std::to_string(m_SpawnPed::m_nWeaponId)].get<std::string>().c_str());
ImGui::Spacing(); ImGui::Spacing();
Ui::DrawImages(Weapon::m_WeaponData.m_ImagesList, ImVec2(65, 65), Weapon::m_WeaponData.m_Categories, Ui::DrawImages(Weapon::m_WeaponData,
Weapon::m_WeaponData.m_Selected, Weapon::m_WeaponData.m_Filter,
[](std::string str) { m_SpawnPed::m_nWeaponId = std::stoi(str); }, [](std::string str) { m_SpawnPed::m_nWeaponId = std::stoi(str); },
nullptr, nullptr,
[](std::string str) [](std::string str)

View File

@ -11,7 +11,7 @@ private:
inline static CJson m_SpecialPedJson = CJson("ped special"); inline static CJson m_SpecialPedJson = CJson("ped special");
#endif #endif
inline static ResourceStore m_PedData{"ped", eResourceType::TYPE_TEXT}; inline static ResourceStore m_PedData{"ped", eResourceType::TYPE_TEXT, ImVec2(65, 110)};
inline static bool m_bImagesLoaded; inline static bool m_bImagesLoaded;
inline static bool m_bExGangWarsInstalled; inline static bool m_bExGangWarsInstalled;
inline static int m_nPedRemoveRadius = 5; inline static int m_nPedRemoveRadius = 5;

View File

@ -534,8 +534,7 @@ void Player::Draw()
{ {
if (bClothOption == 0) if (bClothOption == 0)
{ {
Ui::DrawImages(m_ClothData.m_ImagesList, ImVec2(70, 100), m_ClothData.m_Categories, m_ClothData.m_Selected, Ui::DrawImages(m_ClothData, ChangePlayerCloth, nullptr,
m_ClothData.m_Filter, ChangePlayerCloth, nullptr,
[](std::string str) [](std::string str)
{ {
std::stringstream ss(str); std::stringstream ss(str);
@ -596,8 +595,7 @@ void Player::Draw()
} }
if (ImGui::BeginTabItem("Ped skins")) if (ImGui::BeginTabItem("Ped skins"))
{ {
Ui::DrawImages(Ped::m_PedData.m_ImagesList, ImVec2(65, 110), Ped::m_PedData.m_Categories, Ui::DrawImages(Ped::m_PedData, ChangePlayerModel, nullptr,
Ped::m_PedData.m_Selected, Ped::m_PedData.m_Filter, ChangePlayerModel, nullptr,
[](std::string str) { return Ped::m_PedData.m_pJson->m_Data[str].get<std::string>(); }); [](std::string str) { return Ped::m_PedData.m_pJson->m_Data[str].get<std::string>(); });
ImGui::EndTabItem(); ImGui::EndTabItem();
} }

View File

@ -15,7 +15,7 @@ private:
#ifdef GTASA #ifdef GTASA
inline static bool m_bAimSkinChanger; inline static bool m_bAimSkinChanger;
inline static int m_nUiBodyState; inline static int m_nUiBodyState;
inline static ResourceStore m_ClothData { "clothes" }; inline static ResourceStore m_ClothData { "clothes" , eResourceType::TYPE_IMAGE, ImVec2(70, 100)};
struct m_CustomSkins struct m_CustomSkins
{ {
inline static std::string m_Path = paths::GetGameDirPathA() + std::string("\\modloader\\Custom Skins\\");; inline static std::string m_Path = paths::GetGameDirPathA() + std::string("\\modloader\\Custom Skins\\");;

View File

@ -2,10 +2,15 @@
#include "CFileLoader.h" #include "CFileLoader.h"
#include "extensions/Paths.h" #include "extensions/Paths.h"
ResourceStore::ResourceStore(const char* text, eResourceType type) ResourceStore::ResourceStore(const char* text, eResourceType type, ImVec2 imageSize)
: m_ImageSize(imageSize)
{ {
if (type == eResourceType::TYPE_IMAGE) if (type != eResourceType::TYPE_TEXT)
{ {
/*
Textures need to be loaded from main thread
Loading it directly here doesn't work
*/
Events::processScriptsEvent += [text, this]() Events::processScriptsEvent += [text, this]()
{ {
if (!m_bTexturesLoaded) if (!m_bTexturesLoaded)
@ -14,9 +19,15 @@ ResourceStore::ResourceStore(const char* text, eResourceType type)
m_bTexturesLoaded = true; m_bTexturesLoaded = true;
} }
}; };
if (type == eResourceType::TYPE_BOTH)
{
goto loadJson;
}
} }
else else
{ {
loadJson:
m_pJson = std::make_unique<CJson>(text); m_pJson = std::make_unique<CJson>(text);
// Generate categories // Generate categories

View File

@ -40,6 +40,7 @@ enum eResourceType
{ {
TYPE_IMAGE, TYPE_IMAGE,
TYPE_TEXT, TYPE_TEXT,
TYPE_BOTH,
}; };
using TextureResourceList = std::vector<std::unique_ptr<STextureResource>>; using TextureResourceList = std::vector<std::unique_ptr<STextureResource>>;
@ -54,7 +55,8 @@ public:
std::string m_Selected = "All"; std::string m_Selected = "All";
std::unique_ptr<CJson> m_pJson; std::unique_ptr<CJson> m_pJson;
TextureResourceList m_ImagesList; TextureResourceList m_ImagesList;
ImVec2 m_ImageSize;
bool m_bTexturesLoaded = false; bool m_bTexturesLoaded = false;
ResourceStore(const char* text, eResourceType type = TYPE_IMAGE); ResourceStore(const char* text, eResourceType type = TYPE_IMAGE, ImVec2 imageSize = ImVec2(64, 64));
}; };

View File

@ -42,10 +42,10 @@ bool Ui::ListBoxStr(const char* label, std::vector<std::string>& all_items, std:
return rtn; 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 Ui::ListBoxCustomNames(const char* label, std::vector<std::string>& all_items, std::string& selected, const char* customNames[], size_t length)
{ {
bool rtn = false; bool rtn = false;
std::string display_selected = (selected == "All") ? selected : custom_names[std::stoi(selected)]; std::string display_selected = (selected == "All") ? selected : customNames[std::stoi(selected)];
if (ImGui::BeginCombo(label, display_selected.c_str())) if (ImGui::BeginCombo(label, display_selected.c_str()))
{ {
@ -57,7 +57,7 @@ bool Ui::ListBoxCustomNames(const char* label, std::vector<std::string>& all_ite
for (size_t i = 0; i < length; ++i) for (size_t i = 0; i < length; ++i)
{ {
if (ImGui::MenuItem(custom_names[i])) if (ImGui::MenuItem(customNames[i]))
{ {
selected = std::to_string(i); selected = std::to_string(i);
rtn = true; rtn = true;
@ -183,7 +183,7 @@ bool Ui::CheckboxWithHint(const char* label, bool* v, const char* hint, bool is_
// set things up // set things up
bool pressed = false; bool pressed = false;
const ImGuiStyle& style = ImGui::GetStyle(); const ImGuiStyle& style = ImGui::GetStyle();
const ImVec2 text_size = ImGui::CalcTextSize(label, nullptr, true); const ImVec2 textSize = ImGui::CalcTextSize(label, nullptr, true);
float square_sz = ImGui::GetFrameHeight(); float square_sz = ImGui::GetFrameHeight();
ImDrawList* drawlist = ImGui::GetWindowDrawList(); ImDrawList* drawlist = ImGui::GetWindowDrawList();
ImU32 color = ImGui::GetColorU32(ImGuiCol_FrameBg); ImU32 color = ImGui::GetColorU32(ImGuiCol_FrameBg);
@ -482,74 +482,79 @@ void Ui::FilterWithHint(const char* label, ImGuiTextFilter& filter, const char*
} }
} }
// clean up the code someday void Ui::DrawImages(ResourceStore &store, std::function<void(std::string&)> onLeftClick, std::function<void(std::string&)> onRightClick,
void Ui::DrawImages(std::vector<std::unique_ptr<STextureResource>>& img_vec, ImVec2 image_size, std::function<std::string(std::string&)> getName, std::function<bool(std::string&)> verifyFunc,
std::vector<std::string>& category_vec, std::string& selected_item, ImGuiTextFilter& filter, const char** customNames, size_t length)
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, const char** custom_names, size_t length)
{ {
// scale image size /*
image_size.x *= screen::GetScreenWidth() / 1366.0f; Trying to scale images based on resolutions
image_size.y *= screen::GetScreenHeight() / 768.0f; Native 1366x768
*/
store.m_ImageSize.x *= screen::GetScreenWidth() / 1366.0f;
store.m_ImageSize.y *= screen::GetScreenHeight() / 768.0f;
int images_in_row = static_cast<int>(ImGui::GetWindowContentRegionWidth() / image_size.x); int imageCount = 1;
image_size.x = ImGui::GetWindowContentRegionWidth() / images_in_row - static_cast<int>(ImGuiStyleVar_ItemSpacing) * int imagesInRow = static_cast<int>(ImGui::GetWindowContentRegionWidth() / store.m_ImageSize.x);
0.65f; store.m_ImageSize.x = ImGui::GetWindowContentRegionWidth() / imagesInRow - static_cast<int>(ImGuiStyleVar_ItemSpacing) * 0.65f;
int images_count = 1;
ImGui::Spacing(); ImGui::Spacing();
// Hide the popup if right clicked again
if (ImGui::IsMouseClicked(1)) if (ImGui::IsMouseClicked(1))
{
imgPopup.function = nullptr; imgPopup.function = nullptr;
}
ImGui::PushItemWidth(ImGui::GetContentRegionAvailWidth() / 2 - 5); ImGui::PushItemWidth(ImGui::GetContentRegionAvailWidth() / 2 - 5);
if (custom_names) if (customNames)
{ {
ListBoxCustomNames("##Categories", category_vec, selected_item, custom_names, length); ListBoxCustomNames("##Categories", store.m_Categories, store.m_Selected, customNames, length);
} }
else else
{ {
ListBoxStr("##Categories", category_vec, selected_item); ListBoxStr("##Categories", store.m_Categories, store.m_Selected);
} }
ImGui::SameLine(); ImGui::SameLine();
FilterWithHint("##Filter", filter, "Search"); FilterWithHint("##Filter", store.m_Filter, "Search");
ImGui::Spacing(); ImGui::Spacing();
ImGui::BeginChild("DrawImages"); ImGui::BeginChild("DrawImages");
for (uint i = 0; i < img_vec.size(); i++) for (uint i = 0; i < store.m_ImagesList.size(); ++i)
{ {
std::string text = img_vec[i]->m_FileName; std::string text = store.m_ImagesList[i]->m_FileName;
std::string model_name = get_name_func(text); std::string modelName = getName(text);
if (filter.PassFilter(model_name.c_str()) if (store.m_Filter.PassFilter(modelName.c_str())
&& (img_vec[i]->m_CategoryName == selected_item || selected_item == "All") && (store.m_ImagesList[i]->m_CategoryName == store.m_Selected || store.m_Selected == "All")
&& (verify_func == nullptr || verify_func(text)) && (verifyFunc == nullptr || verifyFunc(text))
) )
{ {
/*
Couldn't figure out how to laod images for Dx11
Using texts for now
*/
if (Globals::renderer == Render_DirectX11) if (Globals::renderer == Render_DirectX11)
{ {
if (ImGui::MenuItem(model_name.c_str())) if (ImGui::MenuItem(modelName.c_str()))
{ {
on_left_click(text); onLeftClick(text);
} }
} }
else else
{ {
if (ImGui::ImageButton(img_vec[i]->m_pTexture, image_size, ImVec2(0, 0), ImVec2(1, 1), 1, ImVec4(1, 1, 1, 1), ImVec4(1, 1, 1, 1))) if (ImGui::ImageButton(store.m_ImagesList[i]->m_pTexture, store.m_ImageSize, ImVec2(0, 0), ImVec2(1, 1), 1, ImVec4(1, 1, 1, 1), ImVec4(1, 1, 1, 1)))
{ {
on_left_click(text); onLeftClick(text);
} }
} }
// Right click popup
if (ImGui::IsItemClicked(1) && on_right_click != nullptr) if (ImGui::IsItemClicked(1) && onRightClick != nullptr)
{ {
imgPopup.function = on_right_click; imgPopup.function = onRightClick;
imgPopup.value = model_name; imgPopup.value = modelName;
} }
if (Globals::renderer != Render_DirectX11) if (Globals::renderer != Render_DirectX11)
@ -558,45 +563,46 @@ void Ui::DrawImages(std::vector<std::unique_ptr<STextureResource>>& img_vec, ImV
{ {
ImDrawList* drawlist = ImGui::GetWindowDrawList(); ImDrawList* drawlist = ImGui::GetWindowDrawList();
ImVec2 btn_min = ImGui::GetItemRectMin(); // Drawing selected overlay
ImVec2 btn_max = ImGui::GetItemRectMax(); ImVec2 btnMin = ImGui::GetItemRectMin();
ImVec2 btnMax = ImGui::GetItemRectMax();
drawlist->AddRectFilled(btnMin, btnMax, ImGui::GetColorU32(ImGuiCol_ModalWindowDimBg));
drawlist->AddRectFilled(btn_min, btn_max, ImGui::GetColorU32(ImGuiCol_ModalWindowDimBg)); // Calculating and drawing text over the image
ImVec2 textSize = ImGui::CalcTextSize(modelName.c_str());
ImVec2 text_size = ImGui::CalcTextSize(model_name.c_str()); if (textSize.x < store.m_ImageSize.x)
if (text_size.x < image_size.x)
{ {
float offsetX = (ImGui::GetItemRectSize().x - text_size.x) / 2; float offsetX = (ImGui::GetItemRectSize().x - textSize.x) / 2;
drawlist->AddText(ImVec2(btn_min.x + offsetX, btn_min.y + 10), ImGui::GetColorU32(ImGuiCol_Text), drawlist->AddText(ImVec2(btnMin.x + offsetX, btnMin.y + 10), ImGui::GetColorU32(ImGuiCol_Text),
model_name.c_str()); modelName.c_str());
} }
else else
{ {
std::string buff = ""; std::string buff = "";
std::stringstream ss(modelName);
std::stringstream ss(model_name);
short count = 1; short count = 1;
while (ss >> buff) while (ss >> buff)
{ {
text_size = ImGui::CalcTextSize(buff.c_str()); textSize = ImGui::CalcTextSize(buff.c_str());
float offsetX = (ImGui::GetItemRectSize().x - text_size.x) / 2; float offsetX = (ImGui::GetItemRectSize().x - textSize.x) / 2;
drawlist->AddText(ImVec2(btn_min.x + offsetX, btn_min.y + 10 * count), drawlist->AddText(ImVec2(btnMin.x + offsetX, btnMin.y + 10 * count),
ImGui::GetColorU32(ImGuiCol_Text), buff.c_str()); ImGui::GetColorU32(ImGuiCol_Text), buff.c_str());
++count; ++count;
} }
} }
} }
if (images_count % images_in_row != 0) if (imageCount % imagesInRow != 0)
{ {
ImGui::SameLine(0.0, ImGui::GetStyle().ItemInnerSpacing.x); ImGui::SameLine(0.0, ImGui::GetStyle().ItemInnerSpacing.x);
} }
} }
images_count++; imageCount++;
} }
} }
// Draw popup code
if (imgPopup.function != nullptr) if (imgPopup.function != nullptr)
{ {
if (ImGui::BeginPopupContextWindow()) if (ImGui::BeginPopupContextWindow())
@ -604,11 +610,14 @@ void Ui::DrawImages(std::vector<std::unique_ptr<STextureResource>>& img_vec, ImV
ImGui::Text(imgPopup.value.c_str()); ImGui::Text(imgPopup.value.c_str());
ImGui::Separator(); ImGui::Separator();
if (ImGui::MenuItem("Remove")) if (ImGui::MenuItem("Remove"))
{
imgPopup.function(imgPopup.value); imgPopup.function(imgPopup.value);
}
if (ImGui::MenuItem("Close")) if (ImGui::MenuItem("Close"))
{
imgPopup.function = nullptr; imgPopup.function = nullptr;
}
ImGui::EndPopup(); ImGui::EndPopup();
} }

View File

@ -51,9 +51,7 @@ public:
static void DrawJSON(ResourceStore& data, static void DrawJSON(ResourceStore& data,
std::function<void(std::string&, std::string&, std::string&)> func_left_click, std::function<void(std::string&, std::string&, std::string&)> func_left_click,
std::function<void(std::string&, std::string&, std::string&)> func_right_click); std::function<void(std::string&, std::string&, std::string&)> func_right_click);
static void DrawImages(std::vector<std::unique_ptr<STextureResource>>& img_vec, ImVec2 image_size, static void DrawImages(ResourceStore &store, std::function<void(std::string&)> on_left_click,
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<void(std::string&)> on_right_click,
std::function<std::string(std::string&)> get_name_func, std::function<std::string(std::string&)> get_name_func,
std::function<bool(std::string&)> verify_func = nullptr, std::function<bool(std::string&)> verify_func = nullptr,

View File

@ -1106,8 +1106,7 @@ void Vehicle::Draw()
ImGui::SetNextItemWidth(ImGui::GetWindowContentRegionWidth() - 2.5); ImGui::SetNextItemWidth(ImGui::GetWindowContentRegionWidth() - 2.5);
ImGui::InputTextWithHint("##LicenseText", "License plate text", m_Spawner::m_nLicenseText, 9); ImGui::InputTextWithHint("##LicenseText", "License plate text", m_Spawner::m_nLicenseText, 9);
Ui::DrawImages(m_Spawner::m_VehData.m_ImagesList, ImVec2(100, 75), m_Spawner::m_VehData.m_Categories, Ui::DrawImages(m_Spawner::m_VehData, SpawnVehicle, nullptr,
m_Spawner::m_VehData.m_Selected, m_Spawner::m_VehData.m_Filter, SpawnVehicle, nullptr,
[](std::string str) [](std::string str)
{ {
return GetNameFromModel(std::stoi(str)); return GetNameFromModel(std::stoi(str));
@ -1320,8 +1319,7 @@ void Vehicle::Draw()
ImGui::SameLine(); ImGui::SameLine();
ImGui::Checkbox("Material filter", &m_Color::m_bMatFilter); ImGui::Checkbox("Material filter", &m_Color::m_bMatFilter);
ImGui::Spacing(); ImGui::Spacing();
Ui::DrawImages(m_TextureData.m_ImagesList, ImVec2(100, 80), m_TextureData.m_Categories, m_TextureData.m_Selected, Ui::DrawImages(m_TextureData,
m_TextureData.m_Filter,
[](std::string& str) [](std::string& str)
{ {
Paint::SetNodeTexture(FindPlayerPed()->m_pVehicle, Paint::veh_nodes::selected, str, Paint::SetNodeTexture(FindPlayerPed()->m_pVehicle, Paint::veh_nodes::selected, str,
@ -1339,8 +1337,7 @@ void Vehicle::Draw()
if (ImGui::BeginTabItem("Tune")) if (ImGui::BeginTabItem("Tune"))
{ {
ImGui::Spacing(); ImGui::Spacing();
Ui::DrawImages(m_TuneData.m_ImagesList, ImVec2(100, 80), m_TuneData.m_Categories, m_TuneData.m_Selected, Ui::DrawImages(m_TuneData,
m_TuneData.m_Filter,
[](std::string& str) { AddComponent(str); }, [](std::string& str) { AddComponent(str); },
[](std::string& str) { RemoveComponent(str); }, [](std::string& str) { RemoveComponent(str); },
[](std::string& str) { return str; }, [](std::string& str) { return str; },

View File

@ -41,13 +41,13 @@ private:
inline static bool m_bApplyOnTraffic; inline static bool m_bApplyOnTraffic;
inline static uint m_bTrafficTimer; inline static uint m_bTrafficTimer;
}; };
inline static ResourceStore m_TuneData { "components" }; inline static ResourceStore m_TuneData { "components", eResourceType::TYPE_IMAGE, ImVec2(100, 80) };
#endif #endif
struct m_Spawner struct m_Spawner
{ {
#ifdef GTASA #ifdef GTASA
inline static ResourceStore m_VehData { "vehicles" }; inline static ResourceStore m_VehData { "vehicles", eResourceType::TYPE_IMAGE, ImVec2(100, 75)};
#elif GTAVC #elif GTAVC
inline static ResourceStore m_VehData{"vehicle", eResourceType::TYPE_TEXT}; inline static ResourceStore m_VehData{"vehicle", eResourceType::TYPE_TEXT};
#endif #endif

View File

@ -230,8 +230,7 @@ void Weapon::Draw()
m_WeaponData.m_pJson->m_Data[std::to_string(m_nGangWeaponList[m_nSelectedGang][m_nSelectedWeapon])].get< m_WeaponData.m_pJson->m_Data[std::to_string(m_nGangWeaponList[m_nSelectedGang][m_nSelectedWeapon])].get<
std::string>().c_str()); std::string>().c_str());
ImGui::Spacing(); ImGui::Spacing();
Ui::DrawImages(m_WeaponData.m_ImagesList, ImVec2(65, 65), m_WeaponData.m_Categories, m_WeaponData.m_Selected, Ui::DrawImages(m_WeaponData, SetGangWeapon, nullptr,
m_WeaponData.m_Filter, SetGangWeapon, nullptr,
[](std::string str) { return m_WeaponData.m_pJson->m_Data[str].get<std::string>(); }, [](std::string str) { return m_WeaponData.m_pJson->m_Data[str].get<std::string>(); },
[](std::string str) { return str != "-1"; /*Jetpack*/ } [](std::string str) { return str != "-1"; /*Jetpack*/ }
); );
@ -245,8 +244,7 @@ void Weapon::Draw()
m_nAmmoCount = (m_nAmmoCount < 0) ? 0 : m_nAmmoCount; m_nAmmoCount = (m_nAmmoCount < 0) ? 0 : m_nAmmoCount;
m_nAmmoCount = (m_nAmmoCount > 99999) ? 99999 : m_nAmmoCount; m_nAmmoCount = (m_nAmmoCount > 99999) ? 99999 : m_nAmmoCount;
} }
Ui::DrawImages(m_WeaponData.m_ImagesList, ImVec2(65, 65), m_WeaponData.m_Categories, m_WeaponData.m_Selected, Ui::DrawImages(m_WeaponData, GiveWeaponToPlayer, nullptr,
m_WeaponData.m_Filter, GiveWeaponToPlayer, nullptr,
[](std::string str) { return m_WeaponData.m_pJson->m_Data[str].get<std::string>(); }, [](std::string str) { return m_WeaponData.m_pJson->m_Data[str].get<std::string>(); },
[](std::string str) { return str != "0"; /*Unarmed*/ } [](std::string str) { return str != "0"; /*Unarmed*/ }
); );

View File

@ -3,7 +3,11 @@
class Weapon class Weapon
{ {
public: public:
#ifdef GTASA
inline static ResourceStore m_WeaponData{ "weapon", eResourceType::TYPE_BOTH, ImVec2(65, 65) };
#elif GTAVC
inline static ResourceStore m_WeaponData{ "weapon", eResourceType::TYPE_TEXT }; inline static ResourceStore m_WeaponData{ "weapon", eResourceType::TYPE_TEXT };
#endif
inline static bool m_bAutoAim; inline static bool m_bAutoAim;
inline static bool m_bFastReload; inline static bool m_bFastReload;
inline static bool m_bHugeDamage; inline static bool m_bHugeDamage;