bf83f161b0
Tres tareas de pulido para cerrar la Fase 1 por completo: #pragma once uniforme: - sdl_manager.hpp y game_scene.hpp pasan de #ifndef/#define guards a #pragma once. Los archivos externos (stb_vorbis.h, fkyaml_node.hpp) se mantienen intactos (codigo de terceros). Variables locales y parametros restantes (catalan -> ingles): - fitxer -> file, moviment -> movement, inici -> start - comptador -> counter, escalada -> scaled - missatges -> messages, llista -> list - alçada -> height, amplada -> width, llargada -> length - origen -> origin, distancia -> distance, valor -> value, desti -> target - neteja -> clear, presenta -> present (SDLManager) - total_enemics -> total_enemies, configurar -> configure, iniciar -> start Comentarios catalan -> castellano: - Cabeceras de fichero actualizadas con nombres nuevos (escena_joc.hpp -> game_scene.hpp, etc.) - Palabras tecnicas: trasllacio->traslacion, col-lisio->colision, inicialitzacio->inicializacion, posicio->posicion, rotacio->rotacion, velocitat->velocidad, acceleracio->aceleracion, explosio->explosion, renderitzat->renderizado, calcul->calculo, transicio->transicion, comprovacio->comprobacion, substitucio->sustitucion, utilitzacio->utilizacion, opcio->opcion, configuracio->configuracion, funcio->funcion, distancia, animacio->animacion - Determinantes y conectores: aquest->este, aquesta->esta, amb->con, sense->sin, pero->pero, mai->nunca, nomes->solo, tambe->tambien, sempre->siempre, ja->ya, mateix->mismo, vegada->vez, dintre->dentro, fora->fuera, dreta->derecha, esquerra->izquierda, sortir->salir, sortida->salida, petit->pequeno, gran->grande, nou->nuevo, vell->viejo, molt->mucho, els->los, les->las, totes les->todas las, d'->de, com->como, quan->cuando, mentre->mientras, despres->despues, abans->antes, durant->durante, fins->hasta, encara->aun, llavors->entonces, aixi->asi, perque->porque - Sustantivos: classe->clase, metode->metodo, parametre->parametro, versio->version, entitat->entidad, joc->juego, nivell->nivel, enemic->enemigo, naus->naves, bales->balas, fitxer->archivo, pentagon->pentagono, pun- tuacio->puntuacion, flotant->flotante, titol->titulo, objectiu->objetivo, mostra->muestra, tipus->tipo Strings literales preservados en valenciano segun decision del usuario: el texto del HUD del juego (puntuaciones, mensajes en pantalla, archivo de config) se mantiene en valenciano original. 70 fitxers tocats, +1117 / -1123. Compila i enllaca. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
83 lines
3.0 KiB
C++
83 lines
3.0 KiB
C++
// sdl_manager.hpp - Gestor de inicialización de SDL3
|
|
// © 2025 Port a C++20 con SDL3
|
|
|
|
#pragma once
|
|
|
|
#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 con configuración
|
|
~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
|
|
|
|
// Funciones principals (renderizado)
|
|
void clear(uint8_t r = 0, uint8_t g = 0, uint8_t b = 0);
|
|
void present();
|
|
|
|
// [NUEVO] Actualització de colors (oscil·lació)
|
|
void updateColors(float delta_time);
|
|
|
|
// [NUEVO] Actualitzar counter de FPS
|
|
void updateFPS(float delta_time);
|
|
|
|
// Getters
|
|
SDL_Renderer* getRenderer() { return renderer_; }
|
|
[[nodiscard]] float getScaleFactor() const { return zoom_factor_; }
|
|
|
|
// [NUEVO] Actualitzar título de la finestra
|
|
void setWindowTitle(const std::string& title);
|
|
|
|
// [NUEVO] Actualitzar context de renderizado (factor de 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] Funciones 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 con letterbox
|
|
|
|
// [NUEVO] Oscil·lador de colors
|
|
Rendering::ColorOscillator color_oscillator_;
|
|
};
|