clang-tidy

This commit is contained in:
2025-08-10 14:13:11 +02:00
parent 0204a8896a
commit c727cb6541
21 changed files with 255 additions and 209 deletions

View File

@@ -55,17 +55,17 @@ Text::Text(std::shared_ptr<Texture> texture, std::shared_ptr<Text::File> text_fi
// Escribe texto en pantalla
void Text::write(int x, int y, const std::string &text, int kerning, int length) {
int shift = 0;
const std::string_view visible_text = (length == -1) ? std::string_view(text) : std::string_view(text).substr(0, length);
const std::string_view VISIBLE_TEXT = (length == -1) ? std::string_view(text) : std::string_view(text).substr(0, length);
sprite_->setY(y);
for (const auto ch : visible_text) {
const auto index = static_cast<unsigned char>(ch);
for (const auto CH : VISIBLE_TEXT) {
const auto INDEX = static_cast<unsigned char>(CH);
if (index < offset_.size()) {
sprite_->setSpriteClip(offset_[index].x, offset_[index].y, box_width_, box_height_);
if (INDEX < offset_.size()) {
sprite_->setSpriteClip(offset_[INDEX].x, offset_[INDEX].y, box_width_, box_height_);
sprite_->setX(x + shift);
sprite_->render();
shift += offset_[index].w + kerning;
shift += offset_[INDEX].w + kerning;
}
}
}
@@ -73,20 +73,20 @@ void Text::write(int x, int y, const std::string &text, int kerning, int length)
// Escribe el texto al doble de tamaño
void Text::write2X(int x, int y, const std::string &text, int kerning, int length) {
int shift = 0;
const std::string_view visible_text = (length == -1) ? std::string_view(text) : std::string_view(text).substr(0, length);
const std::string_view VISIBLE_TEXT = (length == -1) ? std::string_view(text) : std::string_view(text).substr(0, length);
for (const auto ch : visible_text) {
const auto index = static_cast<unsigned char>(ch);
for (const auto CH : VISIBLE_TEXT) {
const auto INDEX = static_cast<unsigned char>(CH);
if (index < offset_.size()) {
if (INDEX < offset_.size()) {
SDL_FRect rect = {
static_cast<float>(offset_[index].x),
static_cast<float>(offset_[index].y),
static_cast<float>(offset_[INDEX].x),
static_cast<float>(offset_[INDEX].y),
static_cast<float>(box_width_),
static_cast<float>(box_height_)};
sprite_->getTexture()->render(x + shift, y, &rect, 2.0F, 2.0F);
shift += (offset_[index].w + kerning) * 2;
shift += (offset_[INDEX].w + kerning) * 2;
}
}
}
@@ -190,11 +190,11 @@ auto Text::length(const std::string &text, int kerning) const -> int {
int shift = 0;
for (const auto &ch : text) {
// Convertimos a unsigned char para obtener el valor ASCII correcto (0-255)
const auto index = static_cast<unsigned char>(ch);
const auto INDEX = static_cast<unsigned char>(ch);
// Verificamos si el carácter está dentro de los límites del array
if (index < offset_.size()) {
shift += (offset_[index].w + kerning);
if (INDEX < offset_.size()) {
shift += (offset_[INDEX].w + kerning);
}
}