Files
orni-attack/source/core/rendering/sdl_manager.hpp
T
JailDesigner 7ee359b910 Fase 1d: rename del codi restant (effects, stage_system, locals)
Sweep final del naming a CamelCase/camelBack/lower_case:

Fitxers renombrats:
- effects/gestor_puntuacio_flotant.{hpp,cpp} -> floating_score_manager.{hpp,cpp}
- effects/puntuacio_flotant.hpp -> floating_score.hpp

Tipus (CamelCase):
- GestorPuntuacioFlotant -> FloatingScoreManager
- PuntuacioFlotant -> FloatingScore
- ConfigStage -> StageConfig
- ConfigSistemaStages -> StageSystemConfig
- NauTitol -> TitleShip
- EstatNau -> ShipState

Metodes publics (camelBack):
- obte_renderer -> getRenderer
- get_num_actius -> getActiveCount
- calcular_direccio_explosio -> computeExplosionDirection
- trobar_slot_lliure -> findFreeSlot
- explotar -> explode
- reiniciar -> reset
- es_valida -> isValid
- parsejar_fitxer -> parseFile
- carregar -> load
- crear_explosio -> createExplosion
- registrar_puntuacio -> registerScore
- construir_marcador -> buildScoreboard
- render_centered -> renderCentered

Camps struct publics (snake_case):
- actiu/actius -> active
- rotacio -> rotation, rotacio_visual -> visual_rotation
- acceleracio -> acceleration
- velocitat -> velocity
- escala/escala_inicial/objectiu/actual -> scale/initial_scale/...
- posicio/posicio_inicial/objectiu/actual -> position/initial_position/...
- fase_oscilacio -> oscillation_phase
- temps_estat -> state_time
- jugador_id -> player_id
- estat -> state
- brillantor -> brightness
- tipus -> type

Camps privats (sufix _):
- naus_ -> ships_, orni_ -> enemies_, bales_ -> bullets_
- gestor_puntuacio_ -> floating_score_manager_
- punt_mort_ -> death_position_, punt_spawn_ -> spawn_position_
- itocado_per_jugador_ -> hit_timer_per_player_
- vides_per_jugador_ -> lives_per_player_
- puntuacio_per_jugador_ -> score_per_player_
- estat_game_over_ -> game_over_state_
- continues_usados_ -> continues_used_

Constants:
- MARGE_ESQ/DRET/DALT/BAIX -> MARGIN_LEFT/RIGHT/TOP/BOTTOM

Variables locals i parametres comuns (snake_case):
- nau -> ship, enemic -> enemy, bala -> bullet
- forma -> shape, punt(s) -> point(s)
- jugador -> player, partida -> match
- temps -> time, missatge -> message

Diff: 59 fitxers, +1000/-1000 (simetric). Compila i enllaça.

Pendents per a futures fases (no bloquejants):
- Comentaris de capçalera en catala -> castella
- Variables locals/parametres minoritaris en catala
- Include guards (queden alguns #ifndef en lloc de #pragma once)

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-19 11:44:45 +02:00

86 lines
3.1 KiB
C++

// sdl_manager.hpp - Gestor d'inicialització de SDL3
// © 2025 Port a C++20 amb SDL3
#ifndef SDL_MANAGER_HPP
#define SDL_MANAGER_HPP
#include <SDL3/SDL.h>
#include <cstdint>
#include <string>
#include "core/rendering/color_oscillator.hpp"
class SDLManager {
public:
SDLManager(); // Constructor per defecte (usa Defaults::)
SDLManager(int width, int height, bool fullscreen); // Constructor amb configuració
~SDLManager();
// No permetre còpia ni assignació
SDLManager(const SDLManager&) = delete;
SDLManager& operator=(const SDLManager&) = delete;
// [NUEVO] Gestió de finestra dinàmica
void increaseWindowSize(); // F2: +100px
void decreaseWindowSize(); // F1: -100px
void toggleFullscreen(); // F3
void toggleVSync(); // F4
bool handleWindowEvent(const SDL_Event& event); // Per a SDL_EVENT_WINDOW_RESIZED
// Funcions principals (renderitzat)
void neteja(uint8_t r = 0, uint8_t g = 0, uint8_t b = 0);
void presenta();
// [NUEVO] Actualització de colors (oscil·lació)
void updateColors(float delta_time);
// [NUEVO] Actualitzar comptador de FPS
void updateFPS(float delta_time);
// Getters
SDL_Renderer* getRenderer() { return renderer_; }
[[nodiscard]] float getScaleFactor() const { return zoom_factor_; }
// [NUEVO] Actualitzar títol de la finestra
void setWindowTitle(const std::string& title);
// [NUEVO] Actualitzar context de renderitzat (factor d'scale global)
void updateRenderingContext() const;
private:
SDL_Window* finestra_;
SDL_Renderer* renderer_;
// [NUEVO] Variables FPS
float fps_accumulator_;
int fps_frame_count_;
int fps_display_;
// [NUEVO] Estat de la finestra
int current_width_; // Mida física actual
int current_height_;
bool is_fullscreen_;
int max_width_; // Calculat des del display
int max_height_;
// [ZOOM SYSTEM]
float zoom_factor_; // Current zoom (0.5x to max_zoom_)
int windowed_width_; // Saved size before fullscreen
int windowed_height_; // Saved size before fullscreen
float max_zoom_; // Maximum zoom (calculated from display)
// [NUEVO] Funcions internes
void calculateMaxWindowSize(); // Llegir resolució del display
void calculateMaxZoom(); // Calculate max zoom from display
void applyZoom(float new_zoom); // Apply zoom and resize window
void applyWindowSize(int width, int height); // Canviar mida + centrar
void updateLogicalPresentation(); // Actualitzar viewport
void updateViewport(); // Configurar viewport amb letterbox
// [NUEVO] Oscil·lador de colors
Rendering::ColorOscillator color_oscillator_;
};
#endif // SDL_MANAGER_HPP