Bug fixes with category generation

This commit is contained in:
Grinch_ 2021-08-14 02:09:43 +06:00
parent 23bf437bff
commit 086c790a2a
4 changed files with 24 additions and 25 deletions

View File

@ -282,10 +282,14 @@ void Ped::Draw()
if (ImGui::InputInt("Health", &m_SpawnPed::m_nPedHealth))
{
if (m_SpawnPed::m_nPedHealth > 1000)
{
m_SpawnPed::m_nPedHealth = 1000;
}
if (m_SpawnPed::m_nPedHealth < 0)
{
m_SpawnPed::m_nPedHealth = 0;
}
}
Ui::ListBox("Ped type", m_SpawnPed::m_PedTypeList, m_SpawnPed::m_nSelectedPedType);
#ifdef GTASA

View File

@ -5,7 +5,23 @@
ResourceStore::ResourceStore(const char* text, eResourceType type, ImVec2 imageSize)
: m_ImageSize(imageSize)
{
if (type != eResourceType::TYPE_TEXT)
if (type == eResourceType::TYPE_TEXT
|| type == eResourceType::TYPE_BOTH)
{
m_pJson = std::make_unique<CJson>(text);
if (type == eResourceType::TYPE_TEXT)
{
// Generate categories
for (auto element : m_pJson->m_Data.items())
{
m_Categories.push_back(element.key());
}
}
}
if (type == eResourceType::TYPE_IMAGE
|| type == eResourceType::TYPE_BOTH)
{
/*
Textures need to be loaded from main thread
@ -19,22 +35,6 @@ ResourceStore::ResourceStore(const char* text, eResourceType type, ImVec2 imageS
m_bTexturesLoaded = true;
}
};
if (type == eResourceType::TYPE_BOTH)
{
goto loadJson;
}
}
else
{
loadJson:
m_pJson = std::make_unique<CJson>(text);
// Generate categories
for (auto element : m_pJson->m_Data.items())
{
m_Categories.push_back(element.key());
}
}
}
@ -68,6 +68,7 @@ void ResourceStore::LoadTextureResource(std::string&& name)
// Naming format in Txd `Category$TextureName`
std::stringstream ss(pTex->name);
std::string str;
getline(ss, str, '$');
m_ImagesList.back().get()->m_CategoryName = str;
@ -83,10 +84,9 @@ void ResourceStore::LoadTextureResource(std::string&& name)
}
// Genereate categories
std::string itemNames;
if (!std::count(m_Categories.begin(), m_Categories.end(), itemNames))
if (!std::count(m_Categories.begin(), m_Categories.end(), m_ImagesList.back().get()->m_CategoryName))
{
m_Categories.push_back(itemNames);
m_Categories.push_back(m_ImagesList.back().get()->m_CategoryName);
}
pRLL = (RwLinkList*)pEndDic;
}

View File

@ -193,10 +193,6 @@ Vehicle::Vehicle()
};
}
Vehicle::~Vehicle()
{
}
#ifdef GTASA
void Vehicle::AddComponent(const std::string& component, const bool display_message)
{

View File

@ -107,5 +107,4 @@ public:
static int GetModelFromName(const char* name);
static void Draw();
Vehicle();
~Vehicle();
};