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

@@ -10,14 +10,13 @@
#include "core/rendering/text.hpp" // Para Text
#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, toLower
#include "utils/utils.hpp" // Para toLower
// Constructor
EditorStatusBar::EditorStatusBar(std::string room_number)
: room_number_(std::move(room_number)) {
const float SURFACE_WIDTH = Options::game.width;
constexpr float SURFACE_HEIGHT = 6.0F * Tile::SIZE; // 48 pixels, igual que el scoreboard
constexpr float SURFACE_HEIGHT = 24.0F; // 3 líneas de 8px
surface_ = std::make_shared<Surface>(SURFACE_WIDTH, SURFACE_HEIGHT);
surface_dest_ = {.x = 0, .y = Options::game.height - SURFACE_HEIGHT, .w = SURFACE_WIDTH, .h = SURFACE_HEIGHT};
@@ -48,16 +47,26 @@ void EditorStatusBar::fillTexture() {
auto previous_renderer = Screen::get()->getRendererSurface();
Screen::get()->setRendererSurface(surface_);
surface_->clear(stringToColor("black"));
surface_->clear(0);
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");
const Uint8 LABEL_COLOR = 11;
const Uint8 VALUE_COLOR = 14;
const Uint8 DETAIL_COLOR = 13;
const Uint8 COORD_COLOR = 9;
const int RIGHT_X = static_cast<int>(Options::game.width) - LEFT_X;
// Línea 1: Número de la habitación
// Línea 1: Room number (izq) + line4 extra (centro) + tile coords + line5 drag info (der)
text->writeColored(LEFT_X, LINE1_Y, toLower(room_number_), LABEL_COLOR);
// Tile coords + drag info a la derecha
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_);
std::string right_part = TILE_X_STR + "," + TILE_Y_STR;
if (!line5_.empty()) { right_part += " " + line5_; }
if (!line4_.empty()) { right_part = toLower(line4_) + " " + right_part; }
text->writeColored(RIGHT_X - text->length(right_part), LINE1_Y, right_part, COORD_COLOR);
// Línea 2: Propiedades de room o info de enemigo
if (!line2_.empty()) {
text->writeColored(LEFT_X, LINE2_Y, toLower(line2_), DETAIL_COLOR);
@@ -68,20 +77,6 @@ void EditorStatusBar::fillTexture() {
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_);
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);
}