llevat soport per a colors amb nom

This commit is contained in:
2026-04-06 09:14:36 +02:00
parent c4a26ffa0f
commit cdf0665458
121 changed files with 676 additions and 5754 deletions

View File

@@ -14,7 +14,7 @@
#include "game/gameplay/scoreboard.hpp" // Para Scoreboard::Data
#include "game/gameplay/tilemap_renderer.hpp" // Para TilemapRenderer
#include "utils/defines.hpp" // Para TILE_SIZE
#include "utils/utils.hpp" // Para stringToColor
#include "utils/utils.hpp"
// Constructor
Room::Room(const std::string& room_path, std::shared_ptr<Scoreboard::Data> data)
@@ -35,7 +35,7 @@ Room::Room(const std::string& room_path, std::shared_ptr<Scoreboard::Data> data)
tilemap_renderer_ = std::make_unique<TilemapRenderer>(tile_map_, tile_set_width_, surface_, bg_color_, conveyor_belt_direction_);
tilemap_renderer_->initialize(collision_map_.get()); // Inicializa (crea map_surface, pinta tiles, busca animados)
Screen::get()->setBorderColor(stringToColor(border_color_)); // Establece el color del borde
Screen::get()->setBorderColor(border_color_); // Establece el color del borde
}
// Destructor
@@ -46,8 +46,8 @@ void Room::initializeRoom(const Data& room) {
number_ = room.number;
bg_color_ = room.bg_color;
border_color_ = room.border_color;
item_color1_ = room.item_color1.empty() ? "yellow" : room.item_color1;
item_color2_ = room.item_color2.empty() ? "magenta" : room.item_color2;
item_color1_ = room.item_color1;
item_color2_ = room.item_color2;
upper_room_ = room.upper_room;
lower_room_ = room.lower_room;
left_room_ = room.left_room;
@@ -71,8 +71,8 @@ void Room::initializeRoom(const Data& room) {
if (!ItemTracker::get()->hasBeenPicked(room.number, ITEM_POS)) {
// Crear una copia local de los datos del item
Item::Data item_copy = item;
item_copy.color1 = stringToColor(item_color1_);
item_copy.color2 = stringToColor(item_color2_);
item_copy.color1 = item_color1_;
item_copy.color2 = item_color2_;
// Crear el objeto Item usando la copia modificada
item_manager_->addItem(std::make_shared<Item>(item_copy));
@@ -142,21 +142,19 @@ void Room::setTile(int index, int tile_value) {
}
// Cambia color de fondo y redibuja el mapa (para editor)
void Room::setBgColor(const std::string& color) {
void Room::setBgColor(Uint8 color) {
bg_color_ = color;
tilemap_renderer_->setBgColor(color);
tilemap_renderer_->redrawMap(collision_map_.get());
}
// Cambia colores de items en vivo (para editor)
void Room::setItemColors(const std::string& color1, const std::string& color2) {
void Room::setItemColors(Uint8 color1, Uint8 color2) {
item_color1_ = color1;
item_color2_ = color2;
Uint8 c1 = stringToColor(color1);
Uint8 c2 = stringToColor(color2);
auto* item_mgr = item_manager_.get();
for (int i = 0; i < item_mgr->getCount(); ++i) {
item_mgr->getItem(i)->setColors(c1, c2);
item_mgr->getItem(i)->setColors(color1, color2);
}
}
#endif