treballant en el minimapa

This commit is contained in:
2026-04-02 18:46:28 +02:00
parent 3c3e012386
commit c14774478c
5 changed files with 419 additions and 2 deletions

View File

@@ -100,6 +100,13 @@ auto MapEditor::showGrid(bool show) -> std::string {
return show ? "Grid ON" : "Grid OFF";
}
void MapEditor::toggleMiniMap() {
if (!mini_map_) {
mini_map_ = std::make_unique<MiniMap>();
}
mini_map_visible_ = !mini_map_visible_;
}
// Entra en modo editor
void MapEditor::enter(std::shared_ptr<Room> room, std::shared_ptr<Player> player, const std::string& room_path, std::shared_ptr<Scoreboard::Data> scoreboard_data) {
if (active_) { return; }
@@ -285,9 +292,11 @@ void MapEditor::render() {
// Renderizar highlight de selección (encima de los sprites)
renderSelectionHighlight();
// Tile picker (encima de todo en el play area)
// Tile picker o mini mapa (encima de todo en el play area)
if (tile_picker_.isOpen()) {
tile_picker_.render();
} else if (mini_map_visible_ && mini_map_) {
mini_map_->render(room_path_);
}
// Renderizar barra de estado del editor (reemplaza al scoreboard)
@@ -304,6 +313,20 @@ void MapEditor::handleEvent(const SDL_Event& event) {
return;
}
// Si el mini mapa está visible, cerrarlo con click o ESC
if (mini_map_visible_) {
if (event.type == SDL_EVENT_MOUSE_BUTTON_DOWN ||
(event.type == SDL_EVENT_KEY_DOWN && event.key.key == SDLK_ESCAPE)) {
mini_map_visible_ = false;
return;
}
if (event.type == SDL_EVENT_KEY_DOWN && event.key.key == SDLK_M) {
mini_map_visible_ = false;
return;
}
return; // Bloquear otros eventos mientras el minimapa está visible
}
// ESC: desactivar brush
if (event.type == SDL_EVENT_KEY_DOWN && event.key.key == SDLK_ESCAPE && brush_tile_ != NO_BRUSH) {
brush_tile_ = NO_BRUSH;
@@ -316,6 +339,12 @@ void MapEditor::handleEvent(const SDL_Event& event) {
return;
}
// M: toggle mini mapa
if (event.type == SDL_EVENT_KEY_DOWN && event.key.key == SDLK_M && static_cast<int>(event.key.repeat) == 0) {
toggleMiniMap();
return;
}
// Click derecho: abrir TilePicker del mapa
if (event.type == SDL_EVENT_MOUSE_BUTTON_DOWN && event.button.button == SDL_BUTTON_RIGHT) {
// Deseleccionar entidades