Reestructurant la classe Options

This commit is contained in:
2025-02-23 18:12:02 +01:00
parent 3ba4293e8a
commit 2ee0c70319
48 changed files with 898 additions and 984 deletions

View File

@@ -95,7 +95,7 @@ room_t loadRoomFile(std::string file_path, bool verbose)
enemy.flip = false;
enemy.mirror = false;
enemy.frame = -1;
enemy.palette = p_zxspectrum;
enemy.palette = Palette::ZXSPECTRUM;
do
{
@@ -123,8 +123,8 @@ room_t loadRoomFile(std::string file_path, bool verbose)
{
item_t item;
item.counter = 0;
item.color1 = stringToColor(p_zxspectrum, "yellow");
item.color2 = stringToColor(p_zxspectrum, "magenta");
item.color1 = stringToColor(Palette::ZXSPECTRUM, "yellow");
item.color2 = stringToColor(Palette::ZXSPECTRUM, "magenta");
do
{
@@ -428,7 +428,7 @@ Room::Room(room_t *room, ItemTracker *itemTracker, int *itemsPicked, bool jailEn
textureA = room->textureA;
textureB = room->textureB;
tileMap = *room->tileMap;
texture = (options.palette == p_zxspectrum) ? textureA : textureB;
texture = (options.video.palette == Palette::ZXSPECTRUM) ? textureA : textureB;
this->jailEnabled = jailEnabled;
// Inicializa variables
@@ -443,7 +443,7 @@ Room::Room(room_t *room, ItemTracker *itemTracker, int *itemsPicked, bool jailEn
for (auto &enemy : room->enemies)
{
enemy.renderer = renderer;
enemy.palette = options.palette;
enemy.palette = options.video.palette;
enemies.push_back(new Enemy(enemy));
}
@@ -455,8 +455,8 @@ Room::Room(room_t *room, ItemTracker *itemTracker, int *itemsPicked, bool jailEn
if (!itemTracker->hasBeenPicked(room->name, itemPos))
{
item.renderer = renderer;
item.color1 = stringToColor(options.palette, itemColor1);
item.color2 = stringToColor(options.palette, itemColor2);
item.color1 = stringToColor(options.video.palette, itemColor1);
item.color2 = stringToColor(options.video.palette, itemColor2);
items.push_back(new Item(item));
}
}
@@ -497,7 +497,7 @@ Room::Room(room_t *room, ItemTracker *itemTracker, int *itemsPicked, bool jailEn
fillMapTexture();
// Establece el color del borde
screen->setBorderColor(stringToColor(options.palette, room->borderColor));
screen->setBorderColor(stringToColor(options.video.palette, room->borderColor));
}
// Destructor
@@ -530,21 +530,21 @@ std::string Room::getName()
}
// Devuelve el color de la habitación
color_t Room::getBGColor()
Color Room::getBGColor()
{
return stringToColor(options.palette, bgColor);
return stringToColor(options.video.palette, bgColor);
}
// Devuelve el color del borde
color_t Room::getBorderColor()
Color Room::getBorderColor()
{
return stringToColor(options.palette, borderColor);
return stringToColor(options.video.palette, borderColor);
}
// Crea la textura con el mapeado de la habitación
void Room::fillMapTexture()
{
const color_t color = stringToColor(options.palette, bgColor);
const Color color = stringToColor(options.video.palette, bgColor);
SDL_SetRenderTarget(renderer, mapTexture);
SDL_SetRenderDrawColor(renderer, color.r, color.g, color.b, 0xFF);
SDL_RenderClear(renderer);
@@ -870,20 +870,20 @@ void Room::reLoadPalette()
// Cambia el color de los items
for (auto item : items)
{
item->setColors(stringToColor(options.palette, itemColor1), stringToColor(options.palette, itemColor2));
item->setColors(stringToColor(options.video.palette, itemColor1), stringToColor(options.video.palette, itemColor2));
}
// Cambia el color de los enemigos
for (auto enemy : enemies)
{
enemy->setPalette(options.palette);
enemy->setPalette(options.video.palette);
}
// Establece el color del borde
screen->setBorderColor(stringToColor(options.palette, borderColor));
screen->setBorderColor(stringToColor(options.video.palette, borderColor));
// Cambia la textura
texture = (options.palette == p_zxspectrum) ? textureA : textureB;
texture = (options.video.palette == Palette::ZXSPECTRUM) ? textureA : textureB;
// Pone la nueva textura a los tiles animados
for (auto tile : aTile)