Fase 1e: cierre de naming sweep (#pragma once, locals, comentarios castellano)
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>
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
// sdl_manager.cpp - Implementació del gestor SDL3
|
||||
// © 2025 Port a C++20 amb SDL3
|
||||
// © 2025 Port a C++20 con SDL3
|
||||
|
||||
#include "sdl_manager.hpp"
|
||||
|
||||
@@ -38,13 +38,13 @@ SDLManager::SDLManager()
|
||||
// Calcular mida màxima des del display
|
||||
calculateMaxWindowSize();
|
||||
|
||||
// Construir títol dinàmic
|
||||
// Construir título dinàmic
|
||||
std::string window_title = std::format("{} v{} ({})", Project::LONG_NAME, Project::VERSION, Project::COPYRIGHT);
|
||||
|
||||
// Crear finestra CENTRADA (SDL ho fa automàticament amb CENTERED)
|
||||
// Crear finestra CENTRADA (SDL ho hace automàticament con CENTERED)
|
||||
finestra_ =
|
||||
SDL_CreateWindow(window_title.c_str(), current_width_, current_height_,
|
||||
SDL_WINDOW_RESIZABLE // Permetre resize manual també
|
||||
SDL_WINDOW_RESIZABLE // Permetre resize manual también
|
||||
);
|
||||
|
||||
if (finestra_ == nullptr) {
|
||||
@@ -56,7 +56,7 @@ SDLManager::SDLManager()
|
||||
// IMPORTANT: Centrar explícitament la finestra
|
||||
SDL_SetWindowPosition(finestra_, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED);
|
||||
|
||||
// Crear renderer amb acceleració
|
||||
// Crear renderer con aceleración
|
||||
renderer_ = SDL_CreateRenderer(finestra_, nullptr);
|
||||
|
||||
if (renderer_ == nullptr) {
|
||||
@@ -66,7 +66,7 @@ SDLManager::SDLManager()
|
||||
return;
|
||||
}
|
||||
|
||||
// Aplicar configuració de V-Sync
|
||||
// Aplicar configuración de V-Sync
|
||||
SDL_SetRenderVSync(renderer_, Options::rendering.vsync);
|
||||
|
||||
// CRÍTIC: Configurar viewport scaling
|
||||
@@ -77,7 +77,7 @@ SDLManager::SDLManager()
|
||||
<< Defaults::Game::HEIGHT << ")" << '\n';
|
||||
}
|
||||
|
||||
// Constructor amb configuració
|
||||
// Constructor con configuración
|
||||
SDLManager::SDLManager(int width, int height, bool fullscreen)
|
||||
: finestra_(nullptr),
|
||||
renderer_(nullptr),
|
||||
@@ -102,7 +102,7 @@ SDLManager::SDLManager(int width, int height, bool fullscreen)
|
||||
// Calcular mida màxima des del display
|
||||
calculateMaxWindowSize();
|
||||
|
||||
// Construir títol dinàmic
|
||||
// Construir título dinàmic
|
||||
std::string window_title = std::format("{} v{} ({})", Project::LONG_NAME, Project::VERSION, Project::COPYRIGHT);
|
||||
|
||||
// Configurar flags de la finestra
|
||||
@@ -120,12 +120,12 @@ SDLManager::SDLManager(int width, int height, bool fullscreen)
|
||||
return;
|
||||
}
|
||||
|
||||
// Centrar explícitament la finestra (si no és fullscreen)
|
||||
// Centrar explícitament la finestra (si no es fullscreen)
|
||||
if (!is_fullscreen_) {
|
||||
SDL_SetWindowPosition(finestra_, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED);
|
||||
}
|
||||
|
||||
// Crear renderer amb acceleració
|
||||
// Crear renderer con aceleración
|
||||
renderer_ = SDL_CreateRenderer(finestra_, nullptr);
|
||||
|
||||
if (renderer_ == nullptr) {
|
||||
@@ -135,7 +135,7 @@ SDLManager::SDLManager(int width, int height, bool fullscreen)
|
||||
return;
|
||||
}
|
||||
|
||||
// Aplicar configuració de V-Sync
|
||||
// Aplicar configuración de V-Sync
|
||||
SDL_SetRenderVSync(renderer_, Options::rendering.vsync);
|
||||
|
||||
// Configurar viewport scaling
|
||||
@@ -176,7 +176,7 @@ void SDLManager::calculateMaxWindowSize() {
|
||||
const SDL_DisplayMode* mode = SDL_GetCurrentDisplayMode(display);
|
||||
|
||||
if (mode != nullptr) {
|
||||
// Deixar marge de 100px per a decoracions de l'OS
|
||||
// Deixar marge de 100px para decoracions de l'OS
|
||||
max_width_ = mode->w - 100;
|
||||
max_height_ = mode->h - 100;
|
||||
std::cout << "Display detectat: " << mode->w << "x" << mode->h
|
||||
@@ -253,9 +253,9 @@ void SDLManager::applyZoom(float new_zoom) {
|
||||
}
|
||||
|
||||
void SDLManager::updateLogicalPresentation() {
|
||||
// CANVIAT: Ja no usem SDL_SetRenderLogicalPresentation
|
||||
// CANVIAT: Ya no usem SDL_SetRenderLogicalPresentation
|
||||
// Ara renderitzem directament a resolució física per evitar pixelació irregular
|
||||
// El viewport amb letterbox es configura a updateViewport()
|
||||
// El viewport con letterbox es configura a updateViewport()
|
||||
updateViewport();
|
||||
}
|
||||
|
||||
@@ -265,7 +265,7 @@ void SDLManager::updateViewport() {
|
||||
int scaled_width = static_cast<int>(std::round(Defaults::Game::WIDTH * scale));
|
||||
int scaled_height = static_cast<int>(std::round(Defaults::Game::HEIGHT * scale));
|
||||
|
||||
// Càlcul de letterbox (centrar l'àrea escalada)
|
||||
// Cálculo de letterbox (centrar l'àrea scaled)
|
||||
int offset_x = (current_width_ - scaled_width) / 2;
|
||||
int offset_y = (current_height_ - scaled_height) / 2;
|
||||
|
||||
@@ -273,7 +273,7 @@ void SDLManager::updateViewport() {
|
||||
offset_x = std::max(offset_x, 0);
|
||||
offset_y = std::max(offset_y, 0);
|
||||
|
||||
// Configurar viewport per al renderitzat
|
||||
// Configurar viewport per al renderizado
|
||||
SDL_Rect viewport = {offset_x, offset_y, scaled_width, scaled_height};
|
||||
SDL_SetRenderViewport(renderer_, &viewport);
|
||||
|
||||
@@ -283,7 +283,7 @@ void SDLManager::updateViewport() {
|
||||
}
|
||||
|
||||
void SDLManager::updateRenderingContext() const {
|
||||
// Actualitzar el factor d'scale global per a totes les funcions de renderitzat
|
||||
// Actualitzar el factor de scale global para todas las funciones de renderizado
|
||||
Rendering::g_current_scale_factor = zoom_factor_;
|
||||
}
|
||||
|
||||
@@ -310,7 +310,7 @@ void SDLManager::decreaseWindowSize() {
|
||||
}
|
||||
|
||||
void SDLManager::applyWindowSize(int new_width, int new_height) {
|
||||
// Obtenir posició actual ABANS del resize
|
||||
// Obtenir posición actual ABANS del resize
|
||||
int old_x;
|
||||
int old_y;
|
||||
SDL_GetWindowPosition(finestra_, &old_x, &old_y);
|
||||
@@ -324,7 +324,7 @@ void SDLManager::applyWindowSize(int new_width, int new_height) {
|
||||
current_height_ = new_height;
|
||||
|
||||
// CENTRADO INTEL·LIGENT (algoritme de pollo)
|
||||
// Calcular nova posició per mantenir la finestra centrada sobre si mateixa
|
||||
// Calcular nueva posición per mantenir la finestra centrada sobre si misma
|
||||
int delta_width = old_width - new_width;
|
||||
int delta_height = old_height - new_height;
|
||||
|
||||
@@ -332,13 +332,13 @@ void SDLManager::applyWindowSize(int new_width, int new_height) {
|
||||
int new_y = old_y + (delta_height / 2);
|
||||
|
||||
// Evitar que la finestra surti de la pantalla
|
||||
constexpr int TITLEBAR_HEIGHT = 35; // Alçada aproximada de la barra de títol
|
||||
constexpr int TITLEBAR_HEIGHT = 35; // Alçada aproximada de la barra de título
|
||||
new_x = std::max(new_x, 0);
|
||||
new_y = std::max(new_y, TITLEBAR_HEIGHT);
|
||||
|
||||
SDL_SetWindowPosition(finestra_, new_x, new_y);
|
||||
|
||||
// Actualitzar viewport després del resize
|
||||
// Actualitzar viewport después del resize
|
||||
updateViewport();
|
||||
}
|
||||
|
||||
@@ -368,7 +368,7 @@ void SDLManager::toggleFullscreen() {
|
||||
Options::window.fullscreen = is_fullscreen_;
|
||||
|
||||
// Notificar al mòdul Mouse: Fullscreen requereix ocultació permanent del cursor.
|
||||
// Quan es surt de fullscreen, restaurar el comportament normal d'auto-ocultació.
|
||||
// Cuando es surt de fullscreen, restaurar el comportament normal de auto-ocultació.
|
||||
Mouse::setForceHidden(is_fullscreen_);
|
||||
}
|
||||
|
||||
@@ -387,7 +387,7 @@ bool SDLManager::handleWindowEvent(const SDL_Event& event) {
|
||||
windowed_height_ = current_height_;
|
||||
}
|
||||
|
||||
// Actualitzar viewport després del resize manual
|
||||
// Actualitzar viewport después del resize manual
|
||||
updateViewport();
|
||||
|
||||
std::cout << "Finestra redimensionada: " << current_width_
|
||||
@@ -398,12 +398,12 @@ bool SDLManager::handleWindowEvent(const SDL_Event& event) {
|
||||
return false;
|
||||
}
|
||||
|
||||
void SDLManager::neteja(uint8_t r, uint8_t g, uint8_t b) {
|
||||
void SDLManager::clear(uint8_t r, uint8_t g, uint8_t b) {
|
||||
if (renderer_ == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
// [MODIFICAT] Usar color oscil·lat del fons en lloc dels paràmetres
|
||||
// [MODIFICAT] Usar color oscil·lat del fons en lloc dels parámetros
|
||||
(void)r;
|
||||
(void)g;
|
||||
(void)b; // Suprimir warnings
|
||||
@@ -412,7 +412,7 @@ void SDLManager::neteja(uint8_t r, uint8_t g, uint8_t b) {
|
||||
SDL_RenderClear(renderer_);
|
||||
}
|
||||
|
||||
void SDLManager::presenta() {
|
||||
void SDLManager::present() {
|
||||
if (renderer_ == nullptr) {
|
||||
return;
|
||||
}
|
||||
@@ -420,7 +420,7 @@ void SDLManager::presenta() {
|
||||
SDL_RenderPresent(renderer_);
|
||||
}
|
||||
|
||||
// [NUEVO] Actualitzar colors amb oscil·lació
|
||||
// [NUEVO] Actualitzar colors con oscil·lació
|
||||
void SDLManager::updateColors(float delta_time) {
|
||||
color_oscillator_.update(delta_time);
|
||||
|
||||
@@ -428,7 +428,7 @@ void SDLManager::updateColors(float delta_time) {
|
||||
Rendering::setLineColor(color_oscillator_.getCurrentLineColor());
|
||||
}
|
||||
|
||||
// [NUEVO] Actualitzar comptador de FPS
|
||||
// [NUEVO] Actualitzar counter de FPS
|
||||
void SDLManager::updateFPS(float delta_time) {
|
||||
// Acumular time i frames
|
||||
fps_accumulator_ += delta_time;
|
||||
@@ -440,7 +440,7 @@ void SDLManager::updateFPS(float delta_time) {
|
||||
fps_frame_count_ = 0;
|
||||
fps_accumulator_ = 0.0F;
|
||||
|
||||
// Actualitzar títol de la finestra
|
||||
// Actualitzar título de la finestra
|
||||
std::string vsync_state = (Options::rendering.vsync == 1) ? "ON" : "OFF";
|
||||
std::string title = std::format("{} v{} ({}) - {} FPS - VSync: {}",
|
||||
Project::LONG_NAME,
|
||||
@@ -455,7 +455,7 @@ void SDLManager::updateFPS(float delta_time) {
|
||||
}
|
||||
}
|
||||
|
||||
// [NUEVO] Actualitzar títol de la finestra
|
||||
// [NUEVO] Actualitzar título de la finestra
|
||||
void SDLManager::setWindowTitle(const std::string& title) {
|
||||
if (finestra_ != nullptr) {
|
||||
SDL_SetWindowTitle(finestra_, title.c_str());
|
||||
@@ -476,6 +476,6 @@ void SDLManager::toggleVSync() {
|
||||
fps_accumulator_ = 0.0F;
|
||||
fps_frame_count_ = 0;
|
||||
|
||||
// Guardar configuració
|
||||
// Guardar configuración
|
||||
Options::saveToFile();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user