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

@@ -15,7 +15,7 @@
#include "core/resources/resource_cache.hpp" // Para Resource::Cache
#include "game/gameplay/room.hpp" // Para Room::Data
#include "utils/defines.hpp" // Para Tile::SIZE, PlayArea
#include "utils/utils.hpp" // Para stringToColor
#include "utils/utils.hpp"
// Constructor: construye todo el minimapa
MiniMap::MiniMap(Uint8 bg_color, Uint8 conn_color)
@@ -129,6 +129,7 @@ void MiniMap::layoutRooms() {
for (const auto& [neighbor_name, dx, dy] : neighbors) {
if (neighbor_name == "0" || neighbor_name.empty()) { continue; }
if (visited.contains(neighbor_name)) { continue; }
if (!room_map.contains(neighbor_name)) { continue; } // Room no existe en cache
GridPos neighbor_pos = {.x = pos.x + dx, .y = pos.y + dy};
auto nkey = std::make_pair(neighbor_pos.x, neighbor_pos.y);
@@ -169,14 +170,19 @@ void MiniMap::buildRoomSurfaces() {
// Genera la mini-surface de una room: 1 pixel por tile, color predominante
auto MiniMap::getRoomMiniSurface(const std::string& room_name) -> std::shared_ptr<Surface> {
auto room_data = Resource::Cache::get()->getRoom(room_name);
std::shared_ptr<Room::Data> room_data;
try {
room_data = Resource::Cache::get()->getRoom(room_name);
} catch (...) {
return nullptr; // Room no existe en cache
}
if (!room_data) { return nullptr; }
auto surface = std::make_shared<Surface>(ROOM_W, ROOM_H);
auto prev = Screen::get()->getRendererSurface();
Screen::get()->setRendererSurface(surface);
surface->clear(stringToColor(room_data->bg_color));
surface->clear(room_data->bg_color);
const auto& tile_map = room_data->tile_map;
for (int y = 0; y < ROOM_H; ++y) {
@@ -318,7 +324,7 @@ void MiniMap::render(const std::string& current_room) {
auto cur_h = static_cast<float>(CELL_H + 2);
if (cur_x >= 0 && cur_y >= 0 && cur_x + cur_w <= PlayArea::WIDTH && cur_y + cur_h <= PlayArea::HEIGHT) {
SDL_FRect highlight = {.x = cur_x, .y = cur_y, .w = cur_w, .h = cur_h};
game_surface->drawRectBorder(&highlight, stringToColor("bright_white"));
game_surface->drawRectBorder(&highlight, 15);
}
}
}