- afegides les habitacions de tot el joc (buides)
- minimapa mostra els numeros d'habitacio - tecla per a fer captures de pantalla
This commit is contained in:
@@ -12,6 +12,8 @@
|
||||
|
||||
#include "core/rendering/screen.hpp" // Para Screen
|
||||
#include "core/rendering/surface.hpp" // Para Surface
|
||||
#include "core/rendering/screenshot.hpp" // Para Screenshot::save
|
||||
#include "core/rendering/text.hpp" // Para Text (números de room)
|
||||
#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
|
||||
@@ -283,6 +285,25 @@ void MiniMap::drawConnections() {
|
||||
}
|
||||
}
|
||||
|
||||
// Dibuja los números de room centrados en cada celda
|
||||
void MiniMap::renderRoomNumbers(float offset_x, float offset_y) {
|
||||
auto text = Resource::Cache::get()->getText("8bithud");
|
||||
if (!text) { return; }
|
||||
|
||||
int font_h = text->getCharacterSize();
|
||||
|
||||
for (const auto& [name, mini] : room_positions_) {
|
||||
// "001.yaml" → "001"
|
||||
std::string number = name.substr(0, name.find_last_of('.'));
|
||||
|
||||
int text_w = text->length(number);
|
||||
int text_x = static_cast<int>(offset_x) + cellPixelX(mini.pos.x) + (CELL_W - text_w) / 2;
|
||||
int text_y = static_cast<int>(offset_y) + cellPixelY(mini.pos.y) + (CELL_H - font_h) / 2;
|
||||
|
||||
text->writeDX(Text::COLOR_FLAG | Text::SHADOW_FLAG, text_x, text_y, number, 1, COLOR_NUMBER_TEXT, 1, COLOR_NUMBER_SHADOW);
|
||||
}
|
||||
}
|
||||
|
||||
// Centra el viewport en una room
|
||||
void MiniMap::centerOnRoom(const std::string& room_name) {
|
||||
auto it = room_positions_.find(room_name);
|
||||
@@ -324,6 +345,9 @@ void MiniMap::render(const std::string& current_room) {
|
||||
SDL_FRect dst = {.x = vx, .y = vy, .w = static_cast<float>(map_width_ + SHADOW_OFFSET), .h = static_cast<float>(map_height_ + SHADOW_OFFSET)};
|
||||
map_surface_->render(nullptr, &dst);
|
||||
|
||||
// Números de room (sobre la surface del mapa, antes del highlight)
|
||||
if (show_numbers_) { renderRoomNumbers(vx, vy); }
|
||||
|
||||
// Highlight de la room actual (solo si está completamente visible en el play area)
|
||||
auto it = room_positions_.find(current_room);
|
||||
if (it != room_positions_.end()) {
|
||||
@@ -340,6 +364,32 @@ void MiniMap::render(const std::string& current_room) {
|
||||
|
||||
// Maneja eventos del minimapa (drag para explorar, click para navegar)
|
||||
void MiniMap::handleEvent(const SDL_Event& event, const std::string& current_room) {
|
||||
// Toggle de números de room
|
||||
if (event.type == SDL_EVENT_KEY_DOWN && event.key.key == SDLK_N && static_cast<int>(event.key.repeat) == 0) {
|
||||
show_numbers_ = !show_numbers_;
|
||||
return;
|
||||
}
|
||||
|
||||
// Captura del minimapa
|
||||
if (event.type == SDL_EVENT_KEY_DOWN && event.key.key == SDLK_S && static_cast<int>(event.key.repeat) == 0) {
|
||||
if (map_surface_) {
|
||||
// Renderizar números sobre map_surface_ si están activos
|
||||
if (show_numbers_) {
|
||||
auto prev = Screen::get()->getRendererSurface();
|
||||
Screen::get()->setRendererSurface(map_surface_);
|
||||
renderRoomNumbers(0.0F, 0.0F);
|
||||
Screen::get()->setRendererSurface(prev);
|
||||
}
|
||||
auto game_surface = Screen::get()->getRendererSurface();
|
||||
if (game_surface) { map_surface_->setPalette(game_surface->getPalette()); }
|
||||
std::string file = Screenshot::save(*map_surface_);
|
||||
if (!file.empty()) { std::cout << "MiniMap screenshot: " << file << "\n"; }
|
||||
// Recomponer para limpiar los números de la surface
|
||||
if (show_numbers_) { composeFinalSurface(); }
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (event.type == SDL_EVENT_MOUSE_BUTTON_DOWN && event.button.button == SDL_BUTTON_LEFT) {
|
||||
// Guardar posición inicial para detectar si es click o drag
|
||||
float mouse_x = 0.0F;
|
||||
|
||||
Reference in New Issue
Block a user