Didn't work. Let's try again.

This commit is contained in:
PlatinumSkink
2015-09-17 15:28:57 +02:00
parent dcb23bd199
commit b3335cff05
12 changed files with 304 additions and 78 deletions
+26
View File
@@ -107,6 +107,12 @@ public:
@tparam T Resource type.
@param resourceName Fully qualified name of the resource to fetch.
*/
//Niklas is trying to get frames to work.
template <typename T>
T* Load(std::string resourceType, std::string resourceName);
//Niklas is trying to get frames to work./end
template <typename T>
static T* Fetch(std::string resourceName);
@@ -142,6 +148,7 @@ private:
// Internal: Create a resource and cache it
template <typename T>
static T* CreateResource(std::string resourceName, Resource* parent);
Resource* CreateResource(std::string resourceType, std::string resourceName);
};
template <typename T>
@@ -161,6 +168,25 @@ T* ResourceManager::Load(std::string resourceName, Resource* parent /* = nullptr
return CreateResource<T>(resourceName, parent);
}
//Niklas is trying to get frames to work.
template <typename T>
T* ResourceManager::Load(std::string resourceType, std::string resourceName)
{
auto it = m_ResourceCache.find(std::make_pair(resourceType, resourceName));
if (it != m_ResourceCache.end())
return static_cast<T *>(it->second);
if (m_Preloading) {
LOG_INFO("Preloading resource \"%s\"", resourceName.c_str());
}
else {
LOG_WARNING("Hot-loading resource \"%s\"", resourceName.c_str());
}
return static_cast<T *>(CreateResource(resourceType, resourceName));
}
//Niklas is trying to get frames to work./end
template <typename T>
T* ResourceManager::Fetch(std::string resourceName)
{