forked from jaildesigner-jailgames/jaildoctors_dilemma
Ya funciona la recarga de recursos
This commit is contained in:
@@ -22,7 +22,7 @@ void Resource::loadTextures(std::vector<std::string> list)
|
||||
|
||||
res_texture_t t;
|
||||
t.name = l;
|
||||
t.texture = new Texture(renderer, asset->get(l), options->console);
|
||||
t.texture = new Texture(renderer, asset->get(t.name), options->console);
|
||||
textures.push_back(t);
|
||||
}
|
||||
}
|
||||
@@ -42,8 +42,7 @@ void Resource::loadAnimations(std::vector<std::string> list)
|
||||
for (auto l : list)
|
||||
{
|
||||
// Extrae el nombre del fichero sin la extension para crear el nombre del fichero de la textura
|
||||
const size_t lastIndex = l.find_last_of(".");
|
||||
const std::string pngFile = l.substr(0, lastIndex) + ".png";
|
||||
const std::string pngFile = l.substr(0, l.find_last_of(".")) + ".png";
|
||||
|
||||
if (options->console)
|
||||
{
|
||||
@@ -54,7 +53,7 @@ void Resource::loadAnimations(std::vector<std::string> list)
|
||||
|
||||
res_animation_t as;
|
||||
as.name = l;
|
||||
as.animation = new animatedSprite_t(loadAnimationFromFile(getTexture(pngFile), asset->get(l), options->console));
|
||||
as.animation = new animatedSprite_t(loadAnimationFromFile(getTexture(pngFile), asset->get(as.name), options->console));
|
||||
animations.push_back(as);
|
||||
}
|
||||
}
|
||||
@@ -62,13 +61,12 @@ void Resource::loadAnimations(std::vector<std::string> list)
|
||||
// Vuelve a cargar las animaciones
|
||||
void Resource::reLoadAnimations()
|
||||
{
|
||||
reLoadTextures();
|
||||
// reLoadTextures();
|
||||
|
||||
for (auto a:animations)
|
||||
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";
|
||||
const std::string pngFile = a.name.substr(0, a.name.find_last_of(".")) + ".png";
|
||||
delete a.animation;
|
||||
a.animation = new animatedSprite_t(loadAnimationFromFile(getTexture(pngFile), asset->get(a.name), options->console));
|
||||
}
|
||||
@@ -89,7 +87,7 @@ void Resource::loadOffsets(std::vector<std::string> list)
|
||||
// Vuelve a cargar los offsets
|
||||
void Resource::reLoadOffsets()
|
||||
{
|
||||
for (auto o:offsets)
|
||||
for (auto o : offsets)
|
||||
{
|
||||
delete o.textFile;
|
||||
o.textFile = new textFile_t(LoadTextFile(asset->get(o.name), options->console));
|
||||
@@ -111,7 +109,7 @@ void Resource::loadTileMaps(std::vector<std::string> list)
|
||||
// Vuelve a cargar los mapas de tiles
|
||||
void Resource::reLoadTileMaps()
|
||||
{
|
||||
for (auto tm:tileMaps)
|
||||
for (auto tm : tileMaps)
|
||||
{
|
||||
delete tm.tileMap;
|
||||
tm.tileMap = new std::vector<int>(loadRoomTileFile(asset->get(tm.name), options->console));
|
||||
|
||||
@@ -34,13 +34,13 @@ struct res_textOffset_t
|
||||
struct res_tileMap_t
|
||||
{
|
||||
std::string name; // Nombre del mapa de tiles
|
||||
std::vector<int> *tileMap; // Vecor con los indices del mapa de tiles
|
||||
std::vector<int> *tileMap; // Vector con los indices del mapa de tiles
|
||||
};
|
||||
|
||||
struct res_room_t
|
||||
{
|
||||
std::string name; // Nombre de la habitación
|
||||
room_t *room; // Vecor con las habitaciones
|
||||
room_t *room; // Vector con las habitaciones
|
||||
};
|
||||
|
||||
// Clase Resource. Almacena recursos de disco en memoria
|
||||
|
||||
Reference in New Issue
Block a user