|
@@ -1,3 +1,28 @@
|
|
|
|
|
+/*
|
|
|
|
|
+Copyright (c) 2012 Daniele Bartolini, Simone Boscaratto
|
|
|
|
|
+
|
|
|
|
|
+Permission is hereby granted, free of charge, to any person
|
|
|
|
|
+obtaining a copy of this software and associated documentation
|
|
|
|
|
+files (the "Software"), to deal in the Software without
|
|
|
|
|
+restriction, including without limitation the rights to use,
|
|
|
|
|
+copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
|
+copies of the Software, and to permit persons to whom the
|
|
|
|
|
+Software is furnished to do so, subject to the following
|
|
|
|
|
+conditions:
|
|
|
|
|
+
|
|
|
|
|
+The above copyright notice and this permission notice shall be
|
|
|
|
|
+included in all copies or substantial portions of the Software.
|
|
|
|
|
+
|
|
|
|
|
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
|
|
|
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
|
|
|
|
+OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
|
|
|
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
|
|
|
|
+HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
|
|
|
|
+WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
|
|
|
+FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
|
|
|
|
+OTHER DEALINGS IN THE SOFTWARE.
|
|
|
|
|
+*/
|
|
|
|
|
+
|
|
|
#include "ResourceLoader.h"
|
|
#include "ResourceLoader.h"
|
|
|
#include "ResourceManager.h"
|
|
#include "ResourceManager.h"
|
|
|
#include "String.h"
|
|
#include "String.h"
|
|
@@ -9,8 +34,10 @@
|
|
|
namespace crown
|
|
namespace crown
|
|
|
{
|
|
{
|
|
|
|
|
|
|
|
-ResourceLoader::ResourceLoader(ResourceManager* resource_manager) :
|
|
|
|
|
|
|
+//-----------------------------------------------------------------------------
|
|
|
|
|
+ResourceLoader::ResourceLoader(ResourceManager* resource_manager, Filesystem* filesystem) :
|
|
|
m_resource_manager(resource_manager),
|
|
m_resource_manager(resource_manager),
|
|
|
|
|
+ m_filesystem(filesystem),
|
|
|
m_resources(m_allocator)
|
|
m_resources(m_allocator)
|
|
|
{
|
|
{
|
|
|
m_config_hash = hash::fnv1a_32("config", string::strlen("config"));
|
|
m_config_hash = hash::fnv1a_32("config", string::strlen("config"));
|
|
@@ -18,10 +45,12 @@ ResourceLoader::ResourceLoader(ResourceManager* resource_manager) :
|
|
|
m_mesh_hash = hash::fnv1a_32("mesh", string::strlen("mesh"));
|
|
m_mesh_hash = hash::fnv1a_32("mesh", string::strlen("mesh"));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+//-----------------------------------------------------------------------------
|
|
|
ResourceLoader::~ResourceLoader()
|
|
ResourceLoader::~ResourceLoader()
|
|
|
{
|
|
{
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+//-----------------------------------------------------------------------------
|
|
|
void ResourceLoader::load(ResourceId name)
|
|
void ResourceLoader::load(ResourceId name)
|
|
|
{
|
|
{
|
|
|
m_resources.push_back(name);
|
|
m_resources.push_back(name);
|
|
@@ -30,11 +59,13 @@ void ResourceLoader::load(ResourceId name)
|
|
|
m_resource_manager->loading(name);
|
|
m_resource_manager->loading(name);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+//-----------------------------------------------------------------------------
|
|
|
void ResourceLoader::unload(ResourceId name)
|
|
void ResourceLoader::unload(ResourceId name)
|
|
|
{
|
|
{
|
|
|
// do something
|
|
// do something
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+//-----------------------------------------------------------------------------
|
|
|
void ResourceLoader::flush()
|
|
void ResourceLoader::flush()
|
|
|
{
|
|
{
|
|
|
while (m_resources.size() > 0)
|
|
while (m_resources.size() > 0)
|
|
@@ -49,6 +80,7 @@ void ResourceLoader::flush()
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+//-----------------------------------------------------------------------------
|
|
|
void* ResourceLoader::load_by_type(ResourceId name)
|
|
void* ResourceLoader::load_by_type(ResourceId name)
|
|
|
{
|
|
{
|
|
|
if (name.name == m_config_hash)
|
|
if (name.name == m_config_hash)
|
|
@@ -58,8 +90,10 @@ void* ResourceLoader::load_by_type(ResourceId name)
|
|
|
|
|
|
|
|
if (name.name == m_texture_hash)
|
|
if (name.name == m_texture_hash)
|
|
|
{
|
|
{
|
|
|
- return TextureResource::load(NULL);
|
|
|
|
|
|
|
+ return TextureResource::load(&m_resource_archive, name.name);
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ return NULL;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
} // namespace crown
|
|
} // namespace crown
|