Trabajando en la recarga de recursos
This commit is contained in:
@@ -27,6 +27,15 @@ void Resource::loadTextures(std::vector<std::string> list)
|
||||
}
|
||||
}
|
||||
|
||||
// Vuelve a cargar las texturas
|
||||
void Resource::reLoadTextures()
|
||||
{
|
||||
for (auto texture : textures)
|
||||
{
|
||||
texture.texture->reLoad();
|
||||
}
|
||||
}
|
||||
|
||||
// Carga las animaciones desde una lista
|
||||
void Resource::loadAnimations(std::vector<std::string> list)
|
||||
{
|
||||
@@ -50,6 +59,21 @@ void Resource::loadAnimations(std::vector<std::string> list)
|
||||
}
|
||||
}
|
||||
|
||||
// Vuelve a cargar las animaciones
|
||||
void Resource::reLoadAnimations()
|
||||
{
|
||||
reLoadTextures();
|
||||
|
||||
for (auto a:animations)
|
||||
{
|
||||
// Extrae el nombre del fichero sin la extension para crear el nombre del fichero de la textura
|
||||
const size_t lastIndex = a.name.find_last_of(".");
|
||||
const std::string pngFile = a.name.substr(0, lastIndex) + ".png";
|
||||
delete a.animation;
|
||||
a.animation = new animatedSprite_t(loadAnimationFromFile(getTexture(pngFile), asset->get(a.name), options->console));
|
||||
}
|
||||
}
|
||||
|
||||
// Carga los offsets desde una lista
|
||||
void Resource::loadOffsets(std::vector<std::string> list)
|
||||
{
|
||||
@@ -62,6 +86,16 @@ void Resource::loadOffsets(std::vector<std::string> list)
|
||||
}
|
||||
}
|
||||
|
||||
// Vuelve a cargar los offsets
|
||||
void Resource::reLoadOffsets()
|
||||
{
|
||||
for (auto o:offsets)
|
||||
{
|
||||
delete o.textFile;
|
||||
o.textFile = new textFile_t(LoadTextFile(asset->get(o.name), options->console));
|
||||
}
|
||||
}
|
||||
|
||||
// Carga los mapas de tiles desde una lista
|
||||
void Resource::loadTileMaps(std::vector<std::string> list)
|
||||
{
|
||||
@@ -74,6 +108,16 @@ void Resource::loadTileMaps(std::vector<std::string> list)
|
||||
}
|
||||
}
|
||||
|
||||
// Vuelve a cargar los mapas de tiles
|
||||
void Resource::reLoadTileMaps()
|
||||
{
|
||||
for (auto tm:tileMaps)
|
||||
{
|
||||
delete tm.tileMap;
|
||||
tm.tileMap = new std::vector<int>(loadRoomTileFile(asset->get(tm.name), options->console));
|
||||
}
|
||||
}
|
||||
|
||||
// Carga las habitaciones desde una lista
|
||||
void Resource::loadRooms(std::vector<std::string> list)
|
||||
{
|
||||
@@ -97,18 +141,11 @@ void Resource::loadRooms(std::vector<std::string> list)
|
||||
}
|
||||
}
|
||||
|
||||
// Recarga las texturas
|
||||
void Resource::reLoadTextures()
|
||||
{
|
||||
for (auto texture : textures)
|
||||
{
|
||||
texture.texture->reLoad();
|
||||
}
|
||||
}
|
||||
|
||||
// Recarga las habitaciones
|
||||
// Vuelve a cargar las habitaciones
|
||||
void Resource::reLoadRooms()
|
||||
{
|
||||
reLoadTileMaps();
|
||||
|
||||
for (auto r : rooms)
|
||||
{
|
||||
delete r.room;
|
||||
@@ -127,6 +164,14 @@ void Resource::reLoadRooms()
|
||||
}
|
||||
}
|
||||
|
||||
// Vuelve a cargar todos los recursos
|
||||
void Resource::reLoad()
|
||||
{
|
||||
reLoadAnimations();
|
||||
reLoadOffsets();
|
||||
reLoadRooms();
|
||||
}
|
||||
|
||||
// Libera las texturas
|
||||
void Resource::freeTextures()
|
||||
{
|
||||
|
||||
@@ -66,24 +66,36 @@ public:
|
||||
// Carga las texturas de una lista
|
||||
void loadTextures(std::vector<std::string> list);
|
||||
|
||||
// Vuelve a cargar las texturas
|
||||
void reLoadTextures();
|
||||
|
||||
// Carga las animaciones desde una lista
|
||||
void loadAnimations(std::vector<std::string> list);
|
||||
|
||||
// Vuelve a cargar las animaciones
|
||||
void reLoadAnimations();
|
||||
|
||||
// Carga los offsets desde una lista
|
||||
void loadOffsets(std::vector<std::string> list);
|
||||
|
||||
// Vuelve a cargar los offsets
|
||||
void reLoadOffsets();
|
||||
|
||||
// Carga los mapas de tiles desde una lista
|
||||
void loadTileMaps(std::vector<std::string> list);
|
||||
|
||||
// Vuelve a cargar los mapas de tiles
|
||||
void reLoadTileMaps();
|
||||
|
||||
// Carga las habitaciones desde una lista
|
||||
void loadRooms(std::vector<std::string> list);
|
||||
|
||||
// Recarga las texturas
|
||||
void reLoadTextures();
|
||||
|
||||
// Recarga las habitaciones
|
||||
// Vuelve a cargar las habitaciones
|
||||
void reLoadRooms();
|
||||
|
||||
// Vuelve a cargar todos los recursos
|
||||
void reLoad();
|
||||
|
||||
// Libera las texturas
|
||||
void freeTextures();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user