marcador provisional
This commit is contained in:
@@ -106,8 +106,7 @@ void RenderInfo::render() const {
|
||||
// Todo en lowercase
|
||||
std::ranges::transform(line, line.begin(), [](unsigned char c) { return std::tolower(c); });
|
||||
|
||||
// Constantes visuales (igual que Console)
|
||||
static constexpr Uint8 BG_COLOR = 0; // PaletteColor::BLACK
|
||||
// Constantes visuales
|
||||
static constexpr Uint8 MSG_COLOR = 9; // PaletteColor::BRIGHT_GREEN
|
||||
static constexpr int TEXT_SIZE = 6;
|
||||
static constexpr int PADDING_V = (TEXT_SIZE / 2) - 1;
|
||||
@@ -119,16 +118,6 @@ void RenderInfo::render() const {
|
||||
const int CONSOLE_Y = (Console::get() != nullptr) ? Console::get()->getVisibleHeight() : 0;
|
||||
const int Y = CONSOLE_Y + static_cast<int>(y_);
|
||||
|
||||
// Rectángulo de fondo: ancho completo, alto ajustado al texto
|
||||
const SDL_FRect RECT = {
|
||||
.x = 0.0F,
|
||||
.y = static_cast<float>(Y),
|
||||
.w = Options::game.width,
|
||||
.h = static_cast<float>(TEXT_SIZE + (PADDING_V * 2))};
|
||||
|
||||
auto game_surface = Screen::get()->getGameSurface();
|
||||
game_surface->fillRect(&RECT, BG_COLOR);
|
||||
// game_surface->drawRectBorder(&RECT, BORDER_COLOR);
|
||||
text_obj->writeDX(Text::CENTER_FLAG | Text::COLOR_FLAG,
|
||||
static_cast<int>(Options::game.width / 2),
|
||||
Y + PADDING_V,
|
||||
|
||||
@@ -219,6 +219,37 @@ void Text::writeColored(int x, int y, const std::string& text, Uint8 color, int
|
||||
}
|
||||
}
|
||||
|
||||
// Escribe texto monoespaciado con color (cada glifo centrado en una celda de ancho fijo)
|
||||
void Text::writeColoredMono(int x, int y, const std::string& text, Uint8 color, int cell_w) { // NOLINT(readability-convert-member-functions-to-static)
|
||||
int shift = 0;
|
||||
size_t pos = 0;
|
||||
|
||||
sprite_->setY(y);
|
||||
while (pos < text.size()) {
|
||||
uint32_t cp = nextCodepoint(text, pos);
|
||||
auto it = offset_.find(cp);
|
||||
if (it == offset_.end()) { it = offset_.find('?'); }
|
||||
if (it != offset_.end()) {
|
||||
const int GLYPH_OFFSET = (cell_w - it->second.w) / 2;
|
||||
sprite_->setClip(it->second.x, it->second.y, box_width_, box_height_);
|
||||
sprite_->setX(x + shift + GLYPH_OFFSET);
|
||||
sprite_->render(1, color);
|
||||
}
|
||||
shift += cell_w;
|
||||
}
|
||||
}
|
||||
|
||||
// Obtiene la longitud en pixels de una cadena monoespaciada
|
||||
auto Text::lengthMono(const std::string& text, int cell_w) const -> int {
|
||||
size_t pos = 0;
|
||||
int count = 0;
|
||||
while (pos < text.size()) {
|
||||
nextCodepoint(text, pos);
|
||||
++count;
|
||||
}
|
||||
return count * cell_w;
|
||||
}
|
||||
|
||||
// Escribe el texto con sombra
|
||||
void Text::writeShadowed(int x, int y, const std::string& text, Uint8 color, Uint8 shadow_distance, int kerning, int lenght) {
|
||||
writeColored(x + shadow_distance, y + shadow_distance, text, color, kerning, lenght);
|
||||
|
||||
@@ -48,7 +48,9 @@ class Text {
|
||||
auto writeToSurface(const std::string& text, int zoom = 1, int kerning = 1) -> std::shared_ptr<Surface>; // Escribe el texto en una textura
|
||||
auto writeDXToSurface(Uint8 flags, const std::string& text, int kerning = 1, Uint8 text_color = Uint8(), Uint8 shadow_distance = 1, Uint8 shadow_color = Uint8(), int lenght = -1) -> std::shared_ptr<Surface>; // Escribe el texto con extras en una textura
|
||||
|
||||
[[nodiscard]] auto length(const std::string& text, int kerning = 1) const -> int; // Obtiene la longitud en pixels de una cadena
|
||||
void writeColoredMono(int x, int y, const std::string& text, Uint8 color, int cell_w); // Escribe texto monoespaciado con color
|
||||
[[nodiscard]] auto length(const std::string& text, int kerning = 1) const -> int; // Obtiene la longitud en pixels de una cadena
|
||||
[[nodiscard]] auto lengthMono(const std::string& text, int cell_w) const -> int; // Obtiene la longitud en pixels de una cadena monoespaciada
|
||||
[[nodiscard]] auto getCharacterSize() const -> int; // Devuelve el tamaño del caracter
|
||||
[[nodiscard]] auto glyphWidth(uint32_t codepoint, int kerning = 0) const -> int; // Devuelve el ancho en pixels de un glifo
|
||||
[[nodiscard]] auto getGlyphClip(uint32_t codepoint) const -> SDL_FRect; // Devuelve el clip rect del glifo
|
||||
|
||||
Reference in New Issue
Block a user