Lint: rename de métodos privados (camelBack + traducción al inglés)
Tanda grande de identifier-naming: 47 métodos privados pasan de snake_case (en su mayoría catalán/spanish) a camelBack inglés. Solo afecta a sus archivos hpp+cpp; ningún símbolo cruza fichero (los públicos quedan para una pasada manual con VS Code). Renames por clase: - ShapeLoader: resolve_path → resolvePath. - VectorText: load_charset → loadCharset, get_shape_filename → getShapeFilename. - Shape: starts_with → startsWith (cuidado de no tocar std::string::starts_with que también usaba), extract_value → extractValue, parse_center → parseCenter, parse_points → parsePoints. - Starfield: inicialitzar_estrella → initStar, fora_area → isOutsideArea, calcular_escala → computeScale, calcular_brightness → computeBrightness. - TitleScene: actualitzar_animacio_logo → updateLogoAnimation, inicialitzar_titol → initTitle. - LogoScene: inicialitzar_lletres → initLetters, actualitzar_explosions → updateExplosions, canviar_estat → changeState, totes_lletres_completes → allLettersComplete. - SpawnController: generar_spawn_events → generateSpawnEvents, seleccionar_tipus_aleatori → selectRandomType, spawn_enemic → spawnEnemy, aplicar_multiplicadors → applyMultipliers. - ShipAnimator: actualitzar_entering/floating/exiting → updateEntering/Floating/Exiting, configurar_nau_p1/p2 → configureShipP1/P2, calcular_posicio_fora_pantalla → computeOffscreenPosition. - GameScene: dibuixar_marges → drawMargins, dibuixar_marcador → drawScoreboard, disparar_bala → fireBullet, obtenir_punt_spawn → getSpawnPoint, unir_jugador → joinPlayer, dibuixar_continue → drawContinue, dibuixar_missatge_stage → drawStageMessage. - StageLoader: parse_metadata/stage/spawn_config/distribution/multipliers/ spawn_mode → parseMetadata/Stage/SpawnConfig/Distribution/Multipliers/ SpawnMode, validar_config → validateConfig. - StageManager: canviar_estat → changeState, processar_init_hud/level_start/playing/level_completed → processInitHud/LevelStart/Playing/LevelCompleted, carregar_stage → loadStage. Métodos públicos y funciones libres (cross-file) quedan a propósito sin tocar — los renombrará el usuario con la herramienta de rename de VS Code. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -23,13 +23,13 @@ namespace {
|
||||
// Cachés locales: indexados por nombre lógico ("title.ogg", "effects/laser_shoot.wav", etc.)
|
||||
// Mantienen ownership con unique_ptr; se liberan al salir del programa.
|
||||
auto musicCache() -> std::unordered_map<std::string, std::unique_ptr<Ja::Music>>& {
|
||||
static std::unordered_map<std::string, std::unique_ptr<Ja::Music>> cache;
|
||||
return cache;
|
||||
static std::unordered_map<std::string, std::unique_ptr<Ja::Music>> cache_;
|
||||
return cache_;
|
||||
}
|
||||
|
||||
auto soundCache() -> std::unordered_map<std::string, std::unique_ptr<Ja::Sound>>& {
|
||||
static std::unordered_map<std::string, std::unique_ptr<Ja::Sound>> cache;
|
||||
return cache;
|
||||
static std::unordered_map<std::string, std::unique_ptr<Ja::Sound>> cache_;
|
||||
return cache_;
|
||||
}
|
||||
|
||||
// Normaliza el nombre añadiendo la subcarpeta correspondiente si no la trae:
|
||||
|
||||
@@ -49,27 +49,27 @@ auto Shape::parseFile(const std::string& contingut) -> bool {
|
||||
}
|
||||
|
||||
// Parse command
|
||||
if (starts_with(line, "name:")) {
|
||||
nom_ = trim(extract_value(line));
|
||||
} else if (starts_with(line, "scale:")) {
|
||||
if (startsWith(line, "name:")) {
|
||||
nom_ = trim(extractValue(line));
|
||||
} else if (startsWith(line, "scale:")) {
|
||||
try {
|
||||
escala_defecte_ = std::stof(extract_value(line));
|
||||
escala_defecte_ = std::stof(extractValue(line));
|
||||
} catch (...) {
|
||||
std::cerr << "[Shape] Warning: scale invàlida, usant 1.0" << '\n';
|
||||
escala_defecte_ = 1.0F;
|
||||
}
|
||||
} else if (starts_with(line, "center:")) {
|
||||
parse_center(extract_value(line));
|
||||
} else if (starts_with(line, "polyline:")) {
|
||||
auto points = parse_points(extract_value(line));
|
||||
} else if (startsWith(line, "center:")) {
|
||||
parseCenter(extractValue(line));
|
||||
} else if (startsWith(line, "polyline:")) {
|
||||
auto points = parsePoints(extractValue(line));
|
||||
if (points.size() >= 2) {
|
||||
primitives_.push_back({PrimitiveType::POLYLINE, points});
|
||||
} else {
|
||||
std::cerr << "[Shape] Warning: polyline con menys de 2 points ignorada"
|
||||
<< '\n';
|
||||
}
|
||||
} else if (starts_with(line, "line:")) {
|
||||
auto points = parse_points(extract_value(line));
|
||||
} else if (startsWith(line, "line:")) {
|
||||
auto points = parsePoints(extractValue(line));
|
||||
if (points.size() == 2) {
|
||||
primitives_.push_back({PrimitiveType::LINE, points});
|
||||
} else {
|
||||
@@ -100,8 +100,8 @@ auto Shape::trim(const std::string& str) const -> std::string {
|
||||
return str.substr(start, end - start + 1);
|
||||
}
|
||||
|
||||
// Helper: starts_with
|
||||
auto Shape::starts_with(const std::string& str,
|
||||
// Helper: startsWith
|
||||
auto Shape::startsWith(const std::string& str,
|
||||
const std::string& prefix) const -> bool {
|
||||
if (str.length() < prefix.length()) {
|
||||
return false;
|
||||
@@ -110,7 +110,7 @@ auto Shape::starts_with(const std::string& str,
|
||||
}
|
||||
|
||||
// Helper: extract value after ':'
|
||||
auto Shape::extract_value(const std::string& line) const -> std::string {
|
||||
auto Shape::extractValue(const std::string& line) const -> std::string {
|
||||
size_t colon = line.find(':');
|
||||
if (colon == std::string::npos) {
|
||||
return "";
|
||||
@@ -119,7 +119,7 @@ auto Shape::extract_value(const std::string& line) const -> std::string {
|
||||
}
|
||||
|
||||
// Helper: parse center "x, y"
|
||||
void Shape::parse_center(const std::string& value) {
|
||||
void Shape::parseCenter(const std::string& value) {
|
||||
std::string val = trim(value);
|
||||
size_t comma = val.find(',');
|
||||
if (comma != std::string::npos) {
|
||||
@@ -134,7 +134,7 @@ void Shape::parse_center(const std::string& value) {
|
||||
}
|
||||
|
||||
// Helper: parse points "x1,y1 x2,y2 x3,y3"
|
||||
auto Shape::parse_points(const std::string& str) const -> std::vector<Vec2> {
|
||||
auto Shape::parsePoints(const std::string& str) const -> std::vector<Vec2> {
|
||||
std::vector<Vec2> points;
|
||||
std::istringstream iss(trim(str));
|
||||
std::string pair;
|
||||
|
||||
@@ -57,10 +57,10 @@ class Shape {
|
||||
|
||||
// Helpers privats per parsejar
|
||||
[[nodiscard]] auto trim(const std::string& str) const -> std::string;
|
||||
[[nodiscard]] auto starts_with(const std::string& str, const std::string& prefix) const -> bool;
|
||||
[[nodiscard]] auto extract_value(const std::string& line) const -> std::string;
|
||||
void parse_center(const std::string& value);
|
||||
[[nodiscard]] auto parse_points(const std::string& str) const -> std::vector<Vec2>;
|
||||
[[nodiscard]] auto startsWith(const std::string& str, const std::string& prefix) const -> bool;
|
||||
[[nodiscard]] auto extractValue(const std::string& line) const -> std::string;
|
||||
void parseCenter(const std::string& value);
|
||||
[[nodiscard]] auto parsePoints(const std::string& str) const -> std::vector<Vec2>;
|
||||
};
|
||||
|
||||
} // namespace Graphics
|
||||
|
||||
@@ -68,7 +68,7 @@ void ShapeLoader::clear_cache() {
|
||||
|
||||
auto ShapeLoader::get_cache_size() -> size_t { return cache_.size(); }
|
||||
|
||||
auto ShapeLoader::resolve_path(const std::string& filename) -> std::string {
|
||||
auto ShapeLoader::resolvePath(const std::string& filename) -> std::string {
|
||||
// Si es un path absolut (comença con '/'), usar-lo directament
|
||||
if (!filename.empty() && filename[0] == '/') {
|
||||
return filename;
|
||||
|
||||
@@ -33,7 +33,7 @@ class ShapeLoader {
|
||||
static std::string base_path_; // "data/shapes/"
|
||||
|
||||
// Helpers privats
|
||||
static auto resolve_path(const std::string& filename) -> std::string;
|
||||
static auto resolvePath(const std::string& filename) -> std::string;
|
||||
};
|
||||
|
||||
} // namespace Graphics
|
||||
|
||||
@@ -66,7 +66,7 @@ Starfield::Starfield(Rendering::Renderer* renderer,
|
||||
}
|
||||
|
||||
// Inicialitzar una estrella (nueva o regenerada)
|
||||
void Starfield::inicialitzar_estrella(Estrella& estrella) const {
|
||||
void Starfield::initStar(Estrella& estrella) const {
|
||||
// Angle aleatori des del point de fuga hacia fuera
|
||||
estrella.angle = (static_cast<float>(rand()) / RAND_MAX) * 2.0F * Defaults::Math::PI;
|
||||
|
||||
@@ -80,7 +80,7 @@ void Starfield::inicialitzar_estrella(Estrella& estrella) const {
|
||||
}
|
||||
|
||||
// Verificar si una estrella está fuera de l'àrea
|
||||
auto Starfield::fora_area(const Estrella& estrella) const -> bool {
|
||||
auto Starfield::isOutsideArea(const Estrella& estrella) const -> bool {
|
||||
return (estrella.position.x < area_.x ||
|
||||
estrella.position.x > area_.x + area_.w ||
|
||||
estrella.position.y < area_.y ||
|
||||
@@ -88,7 +88,7 @@ auto Starfield::fora_area(const Estrella& estrella) const -> bool {
|
||||
}
|
||||
|
||||
// Calcular scale dinàmica segons distancia del centro
|
||||
auto Starfield::calcular_escala(const Estrella& estrella) const -> float {
|
||||
auto Starfield::computeScale(const Estrella& estrella) const -> float {
|
||||
const CapaConfig& capa = capes_[estrella.capa];
|
||||
|
||||
// Interpolació lineal basada en distancia del centro
|
||||
@@ -98,7 +98,7 @@ auto Starfield::calcular_escala(const Estrella& estrella) const -> float {
|
||||
}
|
||||
|
||||
// Calcular brightness dinàmica segons distancia del centro
|
||||
auto Starfield::calcular_brightness(const Estrella& estrella) const -> float {
|
||||
auto Starfield::computeBrightness(const Estrella& estrella) const -> float {
|
||||
// Interpolació lineal: estrelles properes (vora) més brillants
|
||||
// distancia_centre: 0.0 (centro, llunyanes) → 1.0 (vora, properes)
|
||||
float brightness_base = Defaults::Brightness::STARFIELD_MIN +
|
||||
@@ -130,8 +130,8 @@ void Starfield::update(float delta_time) {
|
||||
estrella.distancia_centre = dist_px / radi_max_;
|
||||
|
||||
// Si ha sortit de l'àrea, regenerar-la
|
||||
if (fora_area(estrella)) {
|
||||
inicialitzar_estrella(estrella);
|
||||
if (isOutsideArea(estrella)) {
|
||||
initStar(estrella);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -149,8 +149,8 @@ void Starfield::draw() {
|
||||
|
||||
for (const auto& estrella : estrelles_) {
|
||||
// Calcular scale i brightness dinàmicament
|
||||
float scale = calcular_escala(estrella);
|
||||
float brightness = calcular_brightness(estrella);
|
||||
float scale = computeScale(estrella);
|
||||
float brightness = computeBrightness(estrella);
|
||||
|
||||
// Renderizar estrella sin rotación
|
||||
Rendering::render_shape(
|
||||
|
||||
@@ -56,16 +56,16 @@ class Starfield {
|
||||
};
|
||||
|
||||
// Inicialitzar una estrella (nueva o regenerada)
|
||||
void inicialitzar_estrella(Estrella& estrella) const;
|
||||
void initStar(Estrella& estrella) const;
|
||||
|
||||
// Verificar si una estrella está fuera de l'àrea
|
||||
[[nodiscard]] auto fora_area(const Estrella& estrella) const -> bool;
|
||||
[[nodiscard]] auto isOutsideArea(const Estrella& estrella) const -> bool;
|
||||
|
||||
// Calcular scale dinàmica segons distancia del centro
|
||||
[[nodiscard]] auto calcular_escala(const Estrella& estrella) const -> float;
|
||||
[[nodiscard]] auto computeScale(const Estrella& estrella) const -> float;
|
||||
|
||||
// Calcular brightness dinàmica segons distancia del centro
|
||||
[[nodiscard]] auto calcular_brightness(const Estrella& estrella) const -> float;
|
||||
[[nodiscard]] auto computeBrightness(const Estrella& estrella) const -> float;
|
||||
|
||||
// Dades
|
||||
std::vector<Estrella> estrelles_;
|
||||
|
||||
@@ -16,13 +16,13 @@ constexpr float BASE_CHAR_HEIGHT = 40.0F; // Altura base del caràcter
|
||||
|
||||
VectorText::VectorText(Rendering::Renderer* renderer)
|
||||
: renderer_(renderer) {
|
||||
load_charset();
|
||||
loadCharset();
|
||||
}
|
||||
|
||||
void VectorText::load_charset() {
|
||||
void VectorText::loadCharset() {
|
||||
// Cargar dígitos 0-9
|
||||
for (char c = '0'; c <= '9'; c++) {
|
||||
std::string filename = get_shape_filename(c);
|
||||
std::string filename = getShapeFilename(c);
|
||||
auto shape = ShapeLoader::load(filename);
|
||||
|
||||
if (shape && shape->isValid()) {
|
||||
@@ -35,7 +35,7 @@ void VectorText::load_charset() {
|
||||
|
||||
// Cargar lletres A-Z (majúscules)
|
||||
for (char c = 'A'; c <= 'Z'; c++) {
|
||||
std::string filename = get_shape_filename(c);
|
||||
std::string filename = getShapeFilename(c);
|
||||
auto shape = ShapeLoader::load(filename);
|
||||
|
||||
if (shape && shape->isValid()) {
|
||||
@@ -50,7 +50,7 @@ void VectorText::load_charset() {
|
||||
const std::string SYMBOLS[] = {".", ",", "-", ":", "!", "?"};
|
||||
for (const auto& sym : SYMBOLS) {
|
||||
char c = sym[0];
|
||||
std::string filename = get_shape_filename(c);
|
||||
std::string filename = getShapeFilename(c);
|
||||
auto shape = ShapeLoader::load(filename);
|
||||
|
||||
if (shape && shape->isValid()) {
|
||||
@@ -79,7 +79,7 @@ void VectorText::load_charset() {
|
||||
<< '\n';
|
||||
}
|
||||
|
||||
auto VectorText::get_shape_filename(char c) const -> std::string {
|
||||
auto VectorText::getShapeFilename(char c) const -> std::string {
|
||||
// Mapeo carácter → nombre de archivo (con prefix "font/").
|
||||
// Dígitos 0-9 y mayúsculas A-Z comparten el mismo path: la shape se llama
|
||||
// como el caracter mismo, así que se agrupan en un único case.
|
||||
|
||||
@@ -50,8 +50,8 @@ class VectorText {
|
||||
Rendering::Renderer* renderer_;
|
||||
std::unordered_map<char, std::shared_ptr<Shape>> chars_;
|
||||
|
||||
void load_charset();
|
||||
[[nodiscard]] auto get_shape_filename(char c) const -> std::string;
|
||||
void loadCharset();
|
||||
[[nodiscard]] auto getShapeFilename(char c) const -> std::string;
|
||||
};
|
||||
|
||||
} // namespace Graphics
|
||||
|
||||
Reference in New Issue
Block a user