forked from jaildesigner-jailgames/jaildoctors_dilemma
Arreglado un bug en el cambio de paleta durante el juego
This commit is contained in:
@@ -52,6 +52,23 @@ void Resource::freeTextures()
|
|||||||
textures.clear();
|
textures.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Libera las animaciones
|
||||||
|
void Resource::freeAnimations()
|
||||||
|
{
|
||||||
|
for (auto a : animations)
|
||||||
|
{
|
||||||
|
delete a.animation;
|
||||||
|
}
|
||||||
|
animations.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Libera todos los recursos
|
||||||
|
void Resource::free()
|
||||||
|
{
|
||||||
|
freeTextures();
|
||||||
|
freeAnimations();
|
||||||
|
}
|
||||||
|
|
||||||
// Obtiene una textura
|
// Obtiene una textura
|
||||||
Texture *Resource::getTexture(std::string name)
|
Texture *Resource::getTexture(std::string name)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -51,6 +51,12 @@ public:
|
|||||||
// Libera las texturas
|
// Libera las texturas
|
||||||
void freeTextures();
|
void freeTextures();
|
||||||
|
|
||||||
|
// Libera las animaciones
|
||||||
|
void freeAnimations();
|
||||||
|
|
||||||
|
// Libera todos los recursos
|
||||||
|
void free();
|
||||||
|
|
||||||
// Obtiene una textura
|
// Obtiene una textura
|
||||||
Texture *getTexture(std::string name);
|
Texture *getTexture(std::string name);
|
||||||
|
|
||||||
|
|||||||
@@ -845,7 +845,7 @@ void Director::runLogo()
|
|||||||
logo = new Logo(renderer, screen, resource, asset, options, section.subsection);
|
logo = new Logo(renderer, screen, resource, asset, options, section.subsection);
|
||||||
setSection(logo->run());
|
setSection(logo->run());
|
||||||
delete logo;
|
delete logo;
|
||||||
resource->freeTextures();
|
resource->free();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ejecuta la seccion de juego de la introducción
|
// Ejecuta la seccion de juego de la introducción
|
||||||
@@ -857,7 +857,7 @@ void Director::runIntro()
|
|||||||
intro = new Intro(renderer, screen, resource, asset, options);
|
intro = new Intro(renderer, screen, resource, asset, options);
|
||||||
setSection(intro->run());
|
setSection(intro->run());
|
||||||
delete intro;
|
delete intro;
|
||||||
resource->freeTextures();
|
resource->free();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ejecuta la seccion de juego con el titulo y los menus
|
// Ejecuta la seccion de juego con el titulo y los menus
|
||||||
@@ -873,7 +873,7 @@ void Director::runTitle()
|
|||||||
title = new Title(renderer, screen, resource, asset, options);
|
title = new Title(renderer, screen, resource, asset, options);
|
||||||
setSection(title->run());
|
setSection(title->run());
|
||||||
delete title;
|
delete title;
|
||||||
resource->freeTextures();
|
resource->free();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ejecuta la seccion de los creditos del juego
|
// Ejecuta la seccion de los creditos del juego
|
||||||
@@ -885,7 +885,7 @@ void Director::runCredits()
|
|||||||
credits = new Credits(renderer, screen, resource, asset, options);
|
credits = new Credits(renderer, screen, resource, asset, options);
|
||||||
setSection(credits->run());
|
setSection(credits->run());
|
||||||
delete credits;
|
delete credits;
|
||||||
resource->freeTextures();
|
resource->free();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ejecuta la seccion de la demo, donde se ven pantallas del juego
|
// Ejecuta la seccion de la demo, donde se ven pantallas del juego
|
||||||
@@ -897,7 +897,7 @@ void Director::runDemo()
|
|||||||
demo = new Demo(renderer, screen, resource, asset, options, debug);
|
demo = new Demo(renderer, screen, resource, asset, options, debug);
|
||||||
setSection(demo->run());
|
setSection(demo->run());
|
||||||
delete demo;
|
delete demo;
|
||||||
resource->freeTextures();
|
resource->free();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ejecuta la seccion de juego donde se juega
|
// Ejecuta la seccion de juego donde se juega
|
||||||
@@ -910,7 +910,7 @@ void Director::runGame()
|
|||||||
game = new Game(renderer, screen, resource, asset, options, input, debug);
|
game = new Game(renderer, screen, resource, asset, options, input, debug);
|
||||||
setSection(game->run());
|
setSection(game->run());
|
||||||
delete game;
|
delete game;
|
||||||
resource->freeTextures();
|
resource->free();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Director::run()
|
void Director::run()
|
||||||
|
|||||||
@@ -158,7 +158,6 @@ void Game::checkEventHandler()
|
|||||||
|
|
||||||
case SDL_SCANCODE_F5:
|
case SDL_SCANCODE_F5:
|
||||||
switchPalette();
|
switchPalette();
|
||||||
//reLoadTextures();
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|||||||
@@ -778,11 +778,15 @@ void Room::reLoadTexture()
|
|||||||
{
|
{
|
||||||
if (options->palette == p_zxspectrum)
|
if (options->palette == p_zxspectrum)
|
||||||
{
|
{
|
||||||
texture->loadFromFile(asset->get("standard.png"), renderer);
|
//texture->loadFromFile(asset->get("standard.png"), renderer);
|
||||||
|
texture = resource->getTexture("standard.png");
|
||||||
|
texture->reLoad();
|
||||||
}
|
}
|
||||||
else if (options->palette == p_zxarne)
|
else if (options->palette == p_zxarne)
|
||||||
{
|
{
|
||||||
texture->loadFromFile(asset->get("standard_zxarne.png"), renderer);
|
//texture->loadFromFile(asset->get("standard_zxarne.png"), renderer);
|
||||||
|
texture = resource->getTexture("standard_zxarne.png");
|
||||||
|
texture->reLoad();
|
||||||
}
|
}
|
||||||
|
|
||||||
fillMapTexture();
|
fillMapTexture();
|
||||||
@@ -815,6 +819,9 @@ void Room::reLoadPalette()
|
|||||||
|
|
||||||
// Establece el color del borde
|
// Establece el color del borde
|
||||||
screen->setBorderColor(stringToColor(options->palette, borderColor));
|
screen->setBorderColor(stringToColor(options->palette, borderColor));
|
||||||
|
|
||||||
|
// Recarga las texturas
|
||||||
|
reLoadTexture();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Obten el tamaño del tile
|
// Obten el tamaño del tile
|
||||||
|
|||||||
@@ -232,12 +232,16 @@ void Title::reLoadTextures()
|
|||||||
// Carga la textura adecuada
|
// Carga la textura adecuada
|
||||||
if (options->palette == p_zxspectrum)
|
if (options->palette == p_zxspectrum)
|
||||||
{
|
{
|
||||||
texture->loadFromFile(asset->get("loading_screen_color.png"), renderer);
|
// texture->loadFromFile(asset->get("loading_screen_color.png"), renderer);
|
||||||
|
texture = resource->getTexture("loading_screen_color.png");
|
||||||
}
|
}
|
||||||
else if (options->palette == p_zxarne)
|
else if (options->palette == p_zxarne)
|
||||||
{
|
{
|
||||||
texture->loadFromFile(asset->get("loading_screen_color_zxarne.png"), renderer);
|
// texture->loadFromFile(asset->get("loading_screen_color_zxarne.png"), renderer);
|
||||||
|
texture = resource->getTexture("loading_screen_color_zxarne.png");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
texture->reLoad();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Cambia la paleta
|
// Cambia la paleta
|
||||||
|
|||||||
Reference in New Issue
Block a user