Added a few debug messages to ResourceManager.
No longer warns about hot-loading when a resource which causes a load chain is preloaded.
This commit is contained in:
+14
-4
@@ -9,10 +9,6 @@ Resource* ResourceManager::CreateResource(std::string resourceType, std::string
|
||||
LOG_ERROR("Failed to load resource \"%s\" of type \"%s\": Type not registered", resourceName.c_str(), resourceType.c_str());
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
auto resIt = m_ResourceCache.find(resourceName);
|
||||
if (resIt != m_ResourceCache.end())
|
||||
return resIt->second;
|
||||
|
||||
// Call the factory function
|
||||
Resource* resource = facIt->second(resourceName);
|
||||
@@ -32,7 +28,16 @@ void ResourceManager::RegisterType(std::string resourceType, std::function<Resou
|
||||
|
||||
void ResourceManager::Preload(std::string resourceType, std::string resourceName)
|
||||
{
|
||||
if (IsResourceLoaded(resourceName))
|
||||
{
|
||||
LOG_WARNING("Attempted to preload resource \"%s\" multiple times!", resourceName);
|
||||
return;
|
||||
}
|
||||
|
||||
m_Preloading = true;
|
||||
LOG_INFO("Preloading resource \"%s\"", resourceName.c_str());
|
||||
CreateResource(resourceType, resourceName);
|
||||
m_Preloading = false;
|
||||
}
|
||||
|
||||
unsigned int ResourceManager::GetTypeID(std::string resourceType)
|
||||
@@ -48,3 +53,8 @@ unsigned int ResourceManager::GetNewResourceID(unsigned int typeID)
|
||||
{
|
||||
return m_ResourceCount[typeID]++;
|
||||
}
|
||||
|
||||
bool ResourceManager::IsResourceLoaded(std::string resourceName)
|
||||
{
|
||||
return m_ResourceCache.find(resourceName) != m_ResourceCache.end();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user