4e5ab6be1d
Métodos privados que no consultan estado de la instancia pasan a 'static' en la declaración del header. Las definiciones en el .cpp pierden el 'const' trailing (incompatible con static). Cero callsites afectados: las llamadas via 'this->method()' o sin qualifier siguen siendo válidas para métodos estáticos. Aplicado en: - Shape: trim, startsWith, extractValue, parsePoints. - VectorText: getShapeFilename, get_text_width, get_text_height. - Pack: readFile, calculateChecksum, encryptData. - DebrisManager: computeExplosionDirection. - Enemy: attemptSafeSpawn. - LogoScene / TitleScene: checkSkipButtonPressed (consulta Input singleton). - SpawnController: get_enemics_vius. - StageManager: processPlaying. - ShipAnimator: updateEntering, updateFloating, updateExiting, configureShipP1, configureShipP2, computeOffscreenPosition. - Director: run (los miembros executable_path_ / system_folder_ se fijan en el ctor y no se vuelven a leer en el loop principal). Verificado previamente con grep que ningún '&Class::method' los usa como function pointer (cambiar a estático cambiaría su tipo). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
68 lines
2.5 KiB
C++
68 lines
2.5 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. Son estáticos: no necesitan estado
|
|
// de instancia, trabajan sobre el string pasado por parámetro.
|
|
[[nodiscard]] static auto trim(const std::string& str) -> std::string;
|
|
[[nodiscard]] static auto startsWith(const std::string& str, const std::string& prefix) -> bool;
|
|
[[nodiscard]] static auto extractValue(const std::string& line) -> std::string;
|
|
void parseCenter(const std::string& value);
|
|
[[nodiscard]] static auto parsePoints(const std::string& str) -> std::vector<Vec2>;
|
|
};
|
|
|
|
} // namespace Graphics
|