treball en curs: correccions de tidy

This commit is contained in:
2026-05-16 17:19:40 +02:00
parent 3421f34a84
commit ee2dd0bc2c
30 changed files with 1220 additions and 1479 deletions
+13 -7
View File
@@ -30,19 +30,19 @@ Lang::Lang() = default;
Lang::~Lang() = default;
// Inicializa los textos del juego en el idioma seleccionado
auto Lang::setLang(Uint8 lang) -> bool {
auto Lang::setLang(Code lang) -> bool {
std::string file;
switch (lang) {
case es_ES:
case Code::ES_ES:
file = Asset::get()->get("es_ES.txt");
break;
case en_UK:
case Code::EN_UK:
file = Asset::get()->get("en_UK.txt");
break;
case ba_BA:
case Code::BA_BA:
file = Asset::get()->get("ba_BA.txt");
break;
@@ -51,7 +51,7 @@ auto Lang::setLang(Uint8 lang) -> bool {
break;
}
for (auto &mTextString : mTextStrings) {
for (auto &mTextString : text_strings_) {
mTextString = "";
}
@@ -80,7 +80,7 @@ auto Lang::setLang(Uint8 lang) -> bool {
if (index >= MAX_TEXT_STRINGS) {
break;
}
mTextStrings[index] = line;
text_strings_[index] = line;
index++;
}
}
@@ -90,5 +90,11 @@ auto Lang::setLang(Uint8 lang) -> bool {
// Obtiene la cadena de texto del indice
auto Lang::getText(int index) -> std::string {
return mTextStrings[index];
return text_strings_[index];
}
// Devuelve el siguiente idioma del ciclo (wrap-around)
auto Lang::nextLanguage(Code c) -> Code {
const int NEXT = (static_cast<int>(c) + 1) % MAX_LANGUAGES;
return static_cast<Code>(NEXT);
}
+40 -41
View File
@@ -1,41 +1,40 @@
#pragma once
#include <SDL3/SDL.h>
#include <string> // for string, basic_string
// Códigos de idioma
constexpr int es_ES = 0;
constexpr int ba_BA = 1;
constexpr int en_UK = 2;
constexpr int MAX_LANGUAGES = 3;
// Textos
constexpr int MAX_TEXT_STRINGS = 100;
// Clase Lang
class Lang {
private:
std::string mTextStrings[MAX_TEXT_STRINGS]; // Vector con los textos
// Constructor privado (usar Lang::init)
Lang();
// Instancia única
static Lang *instance;
public:
// Singleton API
static void init(); // Crea la instancia
static void destroy(); // Libera la instancia
static auto get() -> Lang *; // Obtiene el puntero a la instancia
// Destructor
~Lang();
// Inicializa los textos del juego en el idioma seleccionado
auto setLang(Uint8 lang) -> bool;
// Obtiene la cadena de texto del indice
auto getText(int index) -> std::string;
};
#pragma once
#include <SDL3/SDL.h>
#include <cstdint> // for uint8_t
#include <string> // for string, basic_string
// Clase Lang
class Lang {
public:
// Códigos de idioma (basados en la convención IETF de los ficheros de locale)
enum class Code : std::uint8_t {
ES_ES = 0,
BA_BA = 1,
EN_UK = 2,
};
static constexpr int MAX_LANGUAGES = 3; // Número total de idiomas disponibles
// Singleton API
static void init(); // Crea la instancia
static void destroy(); // Libera la instancia
static auto get() -> Lang *; // Obtiene el puntero a la instancia
~Lang(); // Destructor
auto setLang(Code lang) -> bool; // Inicializa los textos del juego en el idioma seleccionado
auto getText(int index) -> std::string; // Obtiene la cadena de texto del indice
static auto nextLanguage(Code c) -> Code; // Devuelve el siguiente idioma del ciclo
private:
static constexpr int MAX_TEXT_STRINGS = 100;
std::string text_strings_[MAX_TEXT_STRINGS]; // Vector con los textos
static Lang *instance; // Instancia única
Lang(); // Constructor privado (usar Lang::init)
};