6d0df85e5e
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>
67 lines
2.4 KiB
C++
67 lines
2.4 KiB
C++
// shape.hpp - Sistema de formes vectorials
|
|
// © 2026 JailDesigner
|
|
|
|
#pragma once
|
|
|
|
#include <cstdint>
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
#include "core/types.hpp"
|
|
|
|
namespace Graphics {
|
|
|
|
// Tipo de primitiva dins de una shape
|
|
enum class PrimitiveType : std::uint8_t {
|
|
POLYLINE, // Secuencia de points connectats
|
|
LINE // Línia individual (2 points)
|
|
};
|
|
|
|
// Primitiva individual (polyline o line)
|
|
struct ShapePrimitive {
|
|
PrimitiveType type;
|
|
std::vector<Vec2> points; // 2+ points per polyline, exactament 2 per line
|
|
};
|
|
|
|
// Clase Shape - representa una shape vectorial carregada desde .shp
|
|
class Shape {
|
|
public:
|
|
// Constructors
|
|
Shape() = default;
|
|
explicit Shape(const std::string& filepath);
|
|
|
|
// Carregar shape desde file .shp
|
|
auto load(const std::string& filepath) -> bool;
|
|
|
|
// Parsejar shape desde buffer de memòria (per al sistema de recursos)
|
|
auto parseFile(const std::string& contingut) -> bool;
|
|
|
|
// Getters
|
|
[[nodiscard]] auto get_primitives() const -> const std::vector<ShapePrimitive>& {
|
|
return primitives_;
|
|
}
|
|
[[nodiscard]] auto getCenter() const -> const Vec2& { return center_; }
|
|
[[nodiscard]] auto get_escala_defecte() const -> float { return escala_defecte_; }
|
|
[[nodiscard]] auto isValid() const -> bool { return !primitives_.empty(); }
|
|
|
|
// Info de depuració
|
|
[[nodiscard]] auto getName() const -> const std::string& { return nom_; }
|
|
[[nodiscard]] auto getNumPrimitives() const -> size_t { return primitives_.size(); }
|
|
|
|
private:
|
|
std::vector<ShapePrimitive> primitives_;
|
|
Vec2 center_; // Centro/origin de la shape
|
|
float escala_defecte_{1.0F}; // Escala per defecte (normalment 1.0). Inicializada para
|
|
// que el ctor por defecto no deje el campo indeterminado.
|
|
std::string nom_; // Nom de la shape (per depuració)
|
|
|
|
// Helpers privats per parsejar
|
|
[[nodiscard]] auto trim(const std::string& str) const -> std::string;
|
|
[[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
|