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;
|
res_texture_t t;
|
||||||
t.name = l;
|
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);
|
textures.push_back(t);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -42,8 +42,7 @@ void Resource::loadAnimations(std::vector<std::string> list)
|
|||||||
for (auto l : list)
|
for (auto l : list)
|
||||||
{
|
{
|
||||||
// Extrae el nombre del fichero sin la extension para crear el nombre del fichero de la textura
|
// 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, l.find_last_of(".")) + ".png";
|
||||||
const std::string pngFile = l.substr(0, lastIndex) + ".png";
|
|
||||||
|
|
||||||
if (options->console)
|
if (options->console)
|
||||||
{
|
{
|
||||||
@@ -54,7 +53,7 @@ void Resource::loadAnimations(std::vector<std::string> list)
|
|||||||
|
|
||||||
res_animation_t as;
|
res_animation_t as;
|
||||||
as.name = l;
|
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);
|
animations.push_back(as);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -62,13 +61,12 @@ void Resource::loadAnimations(std::vector<std::string> list)
|
|||||||
// Vuelve a cargar las animaciones
|
// Vuelve a cargar las animaciones
|
||||||
void Resource::reLoadAnimations()
|
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
|
// 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, a.name.find_last_of(".")) + ".png";
|
||||||
const std::string pngFile = a.name.substr(0, lastIndex) + ".png";
|
|
||||||
delete a.animation;
|
delete a.animation;
|
||||||
a.animation = new animatedSprite_t(loadAnimationFromFile(getTexture(pngFile), asset->get(a.name), options->console));
|
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
|
// Vuelve a cargar los offsets
|
||||||
void Resource::reLoadOffsets()
|
void Resource::reLoadOffsets()
|
||||||
{
|
{
|
||||||
for (auto o:offsets)
|
for (auto o : offsets)
|
||||||
{
|
{
|
||||||
delete o.textFile;
|
delete o.textFile;
|
||||||
o.textFile = new textFile_t(LoadTextFile(asset->get(o.name), options->console));
|
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
|
// Vuelve a cargar los mapas de tiles
|
||||||
void Resource::reLoadTileMaps()
|
void Resource::reLoadTileMaps()
|
||||||
{
|
{
|
||||||
for (auto tm:tileMaps)
|
for (auto tm : tileMaps)
|
||||||
{
|
{
|
||||||
delete tm.tileMap;
|
delete tm.tileMap;
|
||||||
tm.tileMap = new std::vector<int>(loadRoomTileFile(asset->get(tm.name), options->console));
|
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
|
struct res_tileMap_t
|
||||||
{
|
{
|
||||||
std::string name; // Nombre del mapa de tiles
|
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
|
struct res_room_t
|
||||||
{
|
{
|
||||||
std::string name; // Nombre de la habitación
|
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
|
// Clase Resource. Almacena recursos de disco en memoria
|
||||||
|
|||||||
Reference in New Issue
Block a user