Precarga de los ficheros .txt con los offsets del texto
This commit is contained in:
@@ -16,7 +16,7 @@ void Resource::loadTextures(std::vector<std::string> list)
|
||||
{
|
||||
texture_t t;
|
||||
t.name = l;
|
||||
t.texture = new Texture(renderer, asset->get(t.name));
|
||||
t.texture = new Texture(renderer, asset->get(l));
|
||||
textures.push_back(t);
|
||||
}
|
||||
}
|
||||
@@ -33,6 +33,18 @@ void Resource::loadAnimations(std::vector<std::string> list)
|
||||
}
|
||||
}
|
||||
|
||||
// Carga los offsets desde una lista
|
||||
void Resource::loadOffsets(std::vector<std::string> list)
|
||||
{
|
||||
for (auto l : list)
|
||||
{
|
||||
textOffset_t to;
|
||||
to.name = l;
|
||||
to.textFile = new textFile_t(LoadTextFile(asset->get(l)));
|
||||
offsets.push_back(to);
|
||||
}
|
||||
}
|
||||
|
||||
// Recarga las texturas
|
||||
void Resource::reLoadTextures()
|
||||
{
|
||||
@@ -62,11 +74,22 @@ void Resource::freeAnimations()
|
||||
animations.clear();
|
||||
}
|
||||
|
||||
// Libera los offsets
|
||||
void Resource::freeOffsets()
|
||||
{
|
||||
for (auto o : offsets)
|
||||
{
|
||||
delete o.textFile;
|
||||
}
|
||||
offsets.clear();
|
||||
}
|
||||
|
||||
// Libera todos los recursos
|
||||
void Resource::free()
|
||||
{
|
||||
freeTextures();
|
||||
freeAnimations();
|
||||
freeOffsets();
|
||||
}
|
||||
|
||||
// Obtiene una textura
|
||||
@@ -97,6 +120,22 @@ animatedSprite_t *Resource::getAnimation(std::string name)
|
||||
}
|
||||
}
|
||||
|
||||
std::cout << "NOT FOUND: " << name << std::endl;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// Obtiene un offset
|
||||
textFile_t *Resource::getOffset(std::string name)
|
||||
{
|
||||
for (auto offset : offsets)
|
||||
{
|
||||
if (offset.name.find(name) != std::string::npos)
|
||||
{
|
||||
std::cout << "CACHE: " << name << std::endl;
|
||||
return offset.textFile;
|
||||
}
|
||||
}
|
||||
|
||||
std::cout << "NOT FOUND: " << name << std::endl;
|
||||
return nullptr;
|
||||
}
|
||||
Reference in New Issue
Block a user