diff --git a/source/game/editor/editor_statusbar.cpp b/source/game/editor/editor_statusbar.cpp index 9538d59..37ed717 100644 --- a/source/game/editor/editor_statusbar.cpp +++ b/source/game/editor/editor_statusbar.cpp @@ -10,7 +10,7 @@ #include "core/resources/resource_cache.hpp" // Para Resource::Cache #include "game/options.hpp" // Para Options::game #include "utils/defines.hpp" // Para Tile::SIZE -#include "utils/utils.hpp" // Para stringToColor +#include "utils/utils.hpp" // Para stringToColor, toLower // Constructor EditorStatusBar::EditorStatusBar(const std::string& room_number, const std::string& room_name) @@ -33,21 +33,15 @@ void EditorStatusBar::update([[maybe_unused]] float delta_time) { fillTexture(); } -// Establece las coordenadas del ratón en tiles void EditorStatusBar::setMouseTile(int tile_x, int tile_y) { mouse_tile_x_ = tile_x; mouse_tile_y_ = tile_y; } -// Establece la información de la entidad seleccionada -void EditorStatusBar::setSelectionInfo(const std::string& info) { - selection_info_ = info; -} - -// Establece el detalle adicional -void EditorStatusBar::setSelectionDetail(const std::string& detail) { - selection_detail_ = detail; -} +void EditorStatusBar::setLine2(const std::string& text) { line2_ = text; } +void EditorStatusBar::setLine3(const std::string& text) { line3_ = text; } +void EditorStatusBar::setLine4(const std::string& text) { line4_ = text; } +void EditorStatusBar::setLine5(const std::string& text) { line5_ = text; } // Dibuja los elementos en la surface void EditorStatusBar::fillTexture() { @@ -59,28 +53,34 @@ void EditorStatusBar::fillTexture() { auto text = Resource::Cache::get()->getText("8bithud"); const Uint8 LABEL_COLOR = stringToColor("bright_cyan"); const Uint8 VALUE_COLOR = stringToColor("white"); + const Uint8 DETAIL_COLOR = stringToColor("bright_yellow"); - // Línea 1: Número y nombre de la habitación - const std::string ROOM_TEXT = toLower(room_number_ + " " + room_name_); - text->writeColored(LEFT_X, LINE1_Y, ROOM_TEXT, LABEL_COLOR); + // Línea 1: Nombre de la habitación + text->writeColored(LEFT_X, LINE1_Y, toLower(room_number_ + " " + room_name_), LABEL_COLOR); - // Línea 2: Coordenadas del ratón en tiles + // Línea 2: Propiedades de room o info de enemigo + if (!line2_.empty()) { + text->writeColored(LEFT_X, LINE2_Y, toLower(line2_), DETAIL_COLOR); + } + + // Línea 3: Conexiones+items o propiedades del enemigo + if (!line3_.empty()) { + text->writeColored(LEFT_X, LINE3_Y, toLower(line3_), VALUE_COLOR); + } + + // Línea 4: Extra + if (!line4_.empty()) { + text->writeColored(LEFT_X, LINE4_Y, toLower(line4_), DETAIL_COLOR); + } + + // Línea 5: Tile coords + drag info const std::string TILE_X_STR = (mouse_tile_x_ < 10 ? "0" : "") + std::to_string(mouse_tile_x_); const std::string TILE_Y_STR = (mouse_tile_y_ < 10 ? "0" : "") + std::to_string(mouse_tile_y_); - text->writeColored(LEFT_X, LINE2_Y, toLower("tile:"), LABEL_COLOR); - text->writeColored(LEFT_X + 30, LINE2_Y, TILE_X_STR + "," + TILE_Y_STR, VALUE_COLOR); - - // Línea 2 (continuación): info de selección o indicador de modo editor - if (!selection_info_.empty()) { - text->writeColored(LEFT_X + 60, LINE2_Y, toLower(selection_info_), stringToColor("bright_yellow")); - } else { - text->writeColored(176, LINE2_Y, toLower("editor"), stringToColor("bright_green")); - } - - // Línea 3: detalle de la selección (propiedades del enemigo) - if (!selection_detail_.empty()) { - text->writeColored(LEFT_X, LINE3_Y, toLower(selection_detail_), stringToColor("bright_white")); + std::string line5 = "tile:" + TILE_X_STR + "," + TILE_Y_STR; + if (!line5_.empty()) { + line5 += " " + line5_; } + text->writeColored(LEFT_X, LINE5_Y, toLower(line5), stringToColor("bright_green")); Screen::get()->setRendererSurface(previous_renderer); } diff --git a/source/game/editor/editor_statusbar.hpp b/source/game/editor/editor_statusbar.hpp index 17c9372..9959cb3 100644 --- a/source/game/editor/editor_statusbar.hpp +++ b/source/game/editor/editor_statusbar.hpp @@ -17,16 +17,21 @@ class EditorStatusBar { void render(); void update(float delta_time); void setMouseTile(int tile_x, int tile_y); - void setSelectionInfo(const std::string& info); - void setSelectionDetail(const std::string& detail); + void setLine2(const std::string& text); + void setLine3(const std::string& text); + void setLine4(const std::string& text); + void setLine5(const std::string& text); private: void fillTexture(); // Dibuja los elementos en la surface // Constantes de posición (en pixels dentro de la surface de 256x48) - static constexpr int LINE1_Y = 4; // Nombre de la habitación - static constexpr int LINE2_Y = 14; // Coordenadas del ratón + selección - static constexpr int LINE3_Y = 24; // Línea extra disponible + // Font 8bithud lowercase = 6px alto → 5 líneas con 8px de separación + static constexpr int LINE1_Y = 2; // Nombre de la habitación + static constexpr int LINE2_Y = 10; // Propiedades de room / enemy info + static constexpr int LINE3_Y = 18; // Conexiones+items / enemy detail + static constexpr int LINE4_Y = 26; // Extra + static constexpr int LINE5_Y = 34; // Tile coords + drag info static constexpr int LEFT_X = 4; // Margen izquierdo // Objetos @@ -34,12 +39,14 @@ class EditorStatusBar { SDL_FRect surface_dest_{}; // Rectángulo destino en pantalla // Variables - std::string room_number_; // Número de la habitación - std::string room_name_; // Nombre de la habitación - int mouse_tile_x_{0}; // Coordenada X del ratón en tiles - int mouse_tile_y_{0}; // Coordenada Y del ratón en tiles - std::string selection_info_; // Información de la entidad seleccionada (línea 2) - std::string selection_detail_; // Detalle adicional (línea 3) + std::string room_number_; // Número de la habitación + std::string room_name_; // Nombre de la habitación + int mouse_tile_x_{0}; // Coordenada X del ratón en tiles + int mouse_tile_y_{0}; // Coordenada Y del ratón en tiles + std::string line2_; // Contenido de la línea 2 + std::string line3_; // Contenido de la línea 3 + std::string line4_; // Contenido de la línea 4 + std::string line5_; // Contenido de la línea 5 }; #endif // _DEBUG diff --git a/source/game/editor/map_editor.cpp b/source/game/editor/map_editor.cpp index c9b497c..632550e 100644 --- a/source/game/editor/map_editor.cpp +++ b/source/game/editor/map_editor.cpp @@ -546,49 +546,57 @@ void MapEditor::updateStatusBarInfo() { statusbar_->setMouseTile(mouse_tile_x_, mouse_tile_y_); - std::string sel_info; - std::string sel_detail; + std::string line2; + std::string line3; + std::string line5; - // Info de drag activo (prioridad) + // Helper para conexiones compactas + auto conn = [](const std::string& r) -> std::string { + if (r == "0" || r.empty()) { return "-"; } + return r.substr(0, r.find('.')); + }; + + // Info de drag activo (línea 5, junto a tile coords) if (drag_.target != DragTarget::NONE && drag_.moved) { switch (drag_.target) { - case DragTarget::PLAYER: sel_info = "player"; break; - case DragTarget::ENEMY_INITIAL: sel_info = "enemy " + std::to_string(drag_.index); break; - case DragTarget::ENEMY_BOUND1: sel_info = "e" + std::to_string(drag_.index) + " bound1"; break; - case DragTarget::ENEMY_BOUND2: sel_info = "e" + std::to_string(drag_.index) + " bound2"; break; - case DragTarget::ITEM: sel_info = "item " + std::to_string(drag_.index); break; + case DragTarget::PLAYER: line5 = "dragging: player"; break; + case DragTarget::ENEMY_INITIAL: line5 = "dragging: enemy " + std::to_string(drag_.index); break; + case DragTarget::ENEMY_BOUND1: line5 = "dragging: e" + std::to_string(drag_.index) + " bound1"; break; + case DragTarget::ENEMY_BOUND2: line5 = "dragging: e" + std::to_string(drag_.index) + " bound2"; break; + case DragTarget::ITEM: line5 = "dragging: item " + std::to_string(drag_.index); break; case DragTarget::NONE: break; } } - // Info de enemigo seleccionado (persistente) - else if (selected_enemy_ >= 0 && selected_enemy_ < static_cast(room_data_.enemies.size())) { + + // Líneas 2-3 según selección + if (selected_enemy_ >= 0 && selected_enemy_ < static_cast(room_data_.enemies.size())) { + // Enemigo seleccionado const auto& e = room_data_.enemies[selected_enemy_]; - // Extraer nombre corto de la animación (sin .yaml) std::string anim = e.animation_path; auto dot = anim.rfind('.'); if (dot != std::string::npos) { anim = anim.substr(0, dot); } - sel_info = "enemy " + std::to_string(selected_enemy_) + ": " + anim; - sel_detail = e.color + " vx:" + std::to_string(static_cast(e.vx)) + - " vy:" + std::to_string(static_cast(e.vy)); - if (e.flip) { sel_detail += " flip"; } - if (e.mirror) { sel_detail += " mirror"; } - } - // Info de la habitación (cuando no hay nada seleccionado) - else { - // Conexiones compactas - auto conn = [](const std::string& r) -> std::string { - if (r == "0" || r.empty()) { return "-"; } - return r.substr(0, r.find('.')); - }; - sel_info = "bg:" + room_data_.bg_color + " brd:" + room_data_.border_color; - sel_detail = "u:" + conn(room_data_.upper_room) + " d:" + conn(room_data_.lower_room) + - " l:" + conn(room_data_.left_room) + " r:" + conn(room_data_.right_room) + - " itm:" + room_data_.item_color1 + "/" + room_data_.item_color2; + line2 = "enemy " + std::to_string(selected_enemy_) + ": " + anim + " " + e.color; + line3 = "vx:" + std::to_string(static_cast(e.vx)) + + " vy:" + std::to_string(static_cast(e.vy)); + if (e.flip) { line3 += " flip"; } + if (e.mirror) { line3 += " mirror"; } + } else { + // Propiedades de la habitación + std::string conv = "none"; + if (room_data_.conveyor_belt_direction < 0) { conv = "left"; } + else if (room_data_.conveyor_belt_direction > 0) { conv = "right"; } + + line2 = "bg:" + room_data_.bg_color + " brd:" + room_data_.border_color + " conv:" + conv; + line3 = "u:" + conn(room_data_.upper_room) + " d:" + conn(room_data_.lower_room) + + " l:" + conn(room_data_.left_room) + " r:" + conn(room_data_.right_room) + + " itm:" + room_data_.item_color1 + "/" + room_data_.item_color2; } - statusbar_->setSelectionInfo(sel_info); - statusbar_->setSelectionDetail(sel_detail); + statusbar_->setLine2(line2); + statusbar_->setLine3(line3); + statusbar_->setLine4(""); // Disponible para uso futuro + statusbar_->setLine5(line5); // Actualizar el prompt de la consola según la selección if (selected_enemy_ >= 0) {