treball en curs: correccions de tidy
This commit is contained in:
@@ -41,8 +41,8 @@
|
||||
Director::Director(int argc, const char *argv[]) {
|
||||
std::cout << "Game start" << '\n';
|
||||
// Inicializa variables
|
||||
section = new Section();
|
||||
section->name = SECTION_PROG_LOGO;
|
||||
section_ = new Section();
|
||||
section_->name = SECTION_PROG_LOGO;
|
||||
|
||||
// Inicializa las opciones del programa (defaults + dispositivos d'entrada)
|
||||
Options::init();
|
||||
@@ -54,7 +54,7 @@ Director::Director(int argc, const char *argv[]) {
|
||||
executablePath = "";
|
||||
#else
|
||||
const char *base_path = SDL_GetBasePath();
|
||||
executablePath = (base_path != nullptr) ? base_path : "";
|
||||
executable_path_ = (base_path != nullptr) ? base_path : "";
|
||||
#endif
|
||||
|
||||
// Comprueba los parametros del programa (pot activar console)
|
||||
@@ -70,13 +70,13 @@ Director::Director(int argc, const char *argv[]) {
|
||||
|
||||
// Estableix el fitxer de configuració i carrega les opcions (o crea el
|
||||
// YAML amb defaults si no existeix).
|
||||
Options::setConfigFile(systemFolder + "/config.yaml");
|
||||
Options::setConfigFile(system_folder_ + "/config.yaml");
|
||||
Options::loadFromFile();
|
||||
|
||||
// Presets de shaders (creats amb defaults si no existeixen).
|
||||
Options::setPostFXFile(systemFolder + "/postfx.yaml");
|
||||
Options::setPostFXFile(system_folder_ + "/postfx.yaml");
|
||||
Options::loadPostFXFromFile();
|
||||
Options::setCrtPiFile(systemFolder + "/crtpi.yaml");
|
||||
Options::setCrtPiFile(system_folder_ + "/crtpi.yaml");
|
||||
Options::loadCrtPiFromFile();
|
||||
|
||||
// Inicializa el sistema de recursos (pack + fallback).
|
||||
@@ -93,7 +93,7 @@ Director::Director(int argc, const char *argv[]) {
|
||||
#ifdef MACOS_BUNDLE
|
||||
const std::string PACK_PATH = executablePath + "../Resources/resources.pack";
|
||||
#else
|
||||
const std::string PACK_PATH = executablePath + "resources.pack";
|
||||
const std::string PACK_PATH = executable_path_ + "resources.pack";
|
||||
#endif
|
||||
if (!ResourceHelper::initializeResourceSystem(PACK_PATH, ENABLE_FALLBACK)) {
|
||||
std::cerr << "Fatal: resource system init failed (missing resources.pack?)" << '\n';
|
||||
@@ -102,7 +102,7 @@ Director::Director(int argc, const char *argv[]) {
|
||||
}
|
||||
|
||||
// Crea el objeto que controla los ficheros de recursos
|
||||
Asset::init(executablePath);
|
||||
Asset::init(executable_path_);
|
||||
Asset::get()->setVerbose(Options::settings.console);
|
||||
|
||||
// Si falta algún fichero no inicia el programa
|
||||
@@ -127,7 +127,7 @@ Director::Director(int argc, const char *argv[]) {
|
||||
Input::init("/gamecontrollerdb.txt");
|
||||
#else
|
||||
{
|
||||
const std::string BIN_DIR = std::filesystem::path(executablePath).parent_path().string();
|
||||
const std::string BIN_DIR = std::filesystem::path(executable_path_).parent_path().string();
|
||||
#ifdef MACOS_BUNDLE
|
||||
Input::init(BIN_DIR + "/../Resources/gamecontrollerdb.txt");
|
||||
#else
|
||||
@@ -145,7 +145,7 @@ Director::Director(int argc, const char *argv[]) {
|
||||
//
|
||||
// Por eso el constructor de Screen NO carga notificationText desde
|
||||
// Resource; se enlaza después vía `Screen::get()->initNotifications()`.
|
||||
Screen::init(window, renderer);
|
||||
Screen::init(window_, renderer_);
|
||||
|
||||
#ifndef NO_SHADERS
|
||||
if (Options::video.gpu.acceleration) {
|
||||
@@ -155,13 +155,13 @@ Director::Director(int argc, const char *argv[]) {
|
||||
|
||||
// Ahora sí, precarga todos los recursos en memoria (texturas, sonidos,
|
||||
// música, ...). Vivirán durante toda la vida de la app.
|
||||
Resource::init(renderer);
|
||||
Resource::init(renderer_);
|
||||
|
||||
// Completa el enlazado de Screen con recursos que necesitan Resource
|
||||
// inicializado (actualmente sólo el Text de las notificaciones).
|
||||
Screen::get()->initNotifications();
|
||||
|
||||
activeSection = ActiveSection::None;
|
||||
active_section_ = ActiveSection::NONE;
|
||||
}
|
||||
|
||||
Director::~Director() {
|
||||
@@ -170,10 +170,10 @@ Director::~Director() {
|
||||
// Libera las secciones primero: sus destructores tocan audio/render SDL
|
||||
// (p.ej. Intro::~Intro llama a JA_DeleteMusic) y deben ejecutarse antes
|
||||
// de SDL_Quit().
|
||||
logo.reset();
|
||||
intro.reset();
|
||||
title.reset();
|
||||
game.reset();
|
||||
logo_.reset();
|
||||
intro_.reset();
|
||||
title_.reset();
|
||||
game_.reset();
|
||||
|
||||
// Screen puede tener referencias a Text propiedad de Resource: destruir
|
||||
// Screen antes que Resource.
|
||||
@@ -185,12 +185,12 @@ Director::~Director() {
|
||||
Asset::destroy();
|
||||
Input::destroy();
|
||||
Lang::destroy();
|
||||
delete section;
|
||||
delete section_;
|
||||
|
||||
Audio::destroy();
|
||||
|
||||
SDL_DestroyRenderer(renderer);
|
||||
SDL_DestroyWindow(window);
|
||||
SDL_DestroyRenderer(renderer_);
|
||||
SDL_DestroyWindow(window_);
|
||||
|
||||
SDL_Quit();
|
||||
|
||||
@@ -270,23 +270,23 @@ auto Director::initSDL() -> bool {
|
||||
std::srand(static_cast<unsigned int>(SDL_GetTicks()));
|
||||
|
||||
// Crea la ventana
|
||||
window = SDL_CreateWindow(
|
||||
window_ = SDL_CreateWindow(
|
||||
Options::window.caption.c_str(),
|
||||
GAMECANVAS_WIDTH * Options::window.zoom,
|
||||
GAMECANVAS_HEIGHT * Options::window.zoom,
|
||||
0);
|
||||
if (window == nullptr) {
|
||||
if (window_ == nullptr) {
|
||||
if (Options::settings.console) {
|
||||
std::cout << "Window could not be created!\nSDL Error: " << SDL_GetError() << '\n';
|
||||
}
|
||||
success = false;
|
||||
} else {
|
||||
SDL_SetWindowPosition(window, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED);
|
||||
SDL_SetWindowPosition(window_, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED);
|
||||
|
||||
// Crea un renderizador para la ventana
|
||||
renderer = SDL_CreateRenderer(window, nullptr);
|
||||
renderer_ = SDL_CreateRenderer(window_, nullptr);
|
||||
|
||||
if (renderer == nullptr) {
|
||||
if (renderer_ == nullptr) {
|
||||
if (Options::settings.console) {
|
||||
std::cout << "Renderer could not be created!\nSDL Error: " << SDL_GetError() << '\n';
|
||||
}
|
||||
@@ -294,21 +294,21 @@ auto Director::initSDL() -> bool {
|
||||
} else {
|
||||
// Modo de blending por defecto (consistente con CCAE):
|
||||
// permite alpha blending para fades y notificaciones.
|
||||
SDL_SetRenderDrawBlendMode(renderer, SDL_BLENDMODE_BLEND);
|
||||
SDL_SetRenderDrawBlendMode(renderer_, SDL_BLENDMODE_BLEND);
|
||||
|
||||
// Activa vsync si es necesario
|
||||
if (Options::video.vsync) {
|
||||
SDL_SetRenderVSync(renderer, 1);
|
||||
SDL_SetRenderVSync(renderer_, 1);
|
||||
}
|
||||
|
||||
// Inicializa el color de renderizado
|
||||
SDL_SetRenderDrawColor(renderer, 0x00, 0x00, 0x00, 0xFF);
|
||||
SDL_SetRenderDrawColor(renderer_, 0x00, 0x00, 0x00, 0xFF);
|
||||
|
||||
// Establece el tamaño del buffer de renderizado
|
||||
SDL_SetRenderLogicalPresentation(renderer, GAMECANVAS_WIDTH, GAMECANVAS_HEIGHT, SDL_LOGICAL_PRESENTATION_LETTERBOX);
|
||||
SDL_SetRenderLogicalPresentation(renderer_, GAMECANVAS_WIDTH, GAMECANVAS_HEIGHT, SDL_LOGICAL_PRESENTATION_LETTERBOX);
|
||||
|
||||
// Establece el modo de mezcla
|
||||
SDL_SetRenderDrawBlendMode(renderer, SDL_BLENDMODE_BLEND);
|
||||
SDL_SetRenderDrawBlendMode(renderer_, SDL_BLENDMODE_BLEND);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -328,7 +328,7 @@ auto Director::setFileList() -> bool {
|
||||
#endif
|
||||
|
||||
// Ficheros de configuración
|
||||
Asset::get()->add(systemFolder + "/score.bin", Asset::Type::DATA, false, true);
|
||||
Asset::get()->add(system_folder_ + "/score.bin", Asset::Type::DATA, false, true);
|
||||
Asset::get()->add(PREFIX + "/data/demo/demo.bin", Asset::Type::DATA);
|
||||
|
||||
// Musicas
|
||||
@@ -470,7 +470,7 @@ void Director::createSystemFolder(const std::string &folder) {
|
||||
#elif __linux__
|
||||
struct passwd *pw = getpwuid(getuid());
|
||||
const char *homedir = pw->pw_dir;
|
||||
systemFolder = std::string(homedir) + "/.config/" + folder;
|
||||
system_folder_ = std::string(homedir) + "/.config/" + folder;
|
||||
|
||||
{
|
||||
// Intenta crear ".config", per si no existeix
|
||||
@@ -488,12 +488,12 @@ void Director::createSystemFolder(const std::string &folder) {
|
||||
(void)folder;
|
||||
#else
|
||||
struct stat st = {.st_dev = 0};
|
||||
if (stat(systemFolder.c_str(), &st) == -1) {
|
||||
if (stat(system_folder_.c_str(), &st) == -1) {
|
||||
errno = 0;
|
||||
#ifdef _WIN32
|
||||
int ret = mkdir(systemFolder.c_str());
|
||||
#else
|
||||
int ret = mkdir(systemFolder.c_str(), S_IRWXU);
|
||||
int ret = mkdir(system_folder_.c_str(), S_IRWXU);
|
||||
#endif
|
||||
|
||||
if (ret == -1) {
|
||||
@@ -522,53 +522,53 @@ void Director::createSystemFolder(const std::string &folder) {
|
||||
// Gestiona las transiciones entre secciones
|
||||
void Director::handleSectionTransition() {
|
||||
// Determina qué sección debería estar activa
|
||||
ActiveSection target_section = ActiveSection::None;
|
||||
switch (section->name) {
|
||||
ActiveSection target_section = ActiveSection::NONE;
|
||||
switch (section_->name) {
|
||||
case SECTION_PROG_LOGO:
|
||||
target_section = ActiveSection::Logo;
|
||||
target_section = ActiveSection::LOGO;
|
||||
break;
|
||||
case SECTION_PROG_INTRO:
|
||||
target_section = ActiveSection::Intro;
|
||||
target_section = ActiveSection::INTRO;
|
||||
break;
|
||||
case SECTION_PROG_TITLE:
|
||||
target_section = ActiveSection::Title;
|
||||
target_section = ActiveSection::TITLE;
|
||||
break;
|
||||
case SECTION_PROG_GAME:
|
||||
target_section = ActiveSection::Game;
|
||||
target_section = ActiveSection::GAME;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
// Si no ha cambiado, no hay nada que hacer
|
||||
if (target_section == activeSection) {
|
||||
if (target_section == active_section_) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Destruye la sección anterior
|
||||
logo.reset();
|
||||
intro.reset();
|
||||
title.reset();
|
||||
game.reset();
|
||||
logo_.reset();
|
||||
intro_.reset();
|
||||
title_.reset();
|
||||
game_.reset();
|
||||
|
||||
// Crea la nueva sección
|
||||
activeSection = target_section;
|
||||
switch (activeSection) {
|
||||
case ActiveSection::Logo:
|
||||
logo = std::make_unique<Logo>(renderer, section);
|
||||
active_section_ = target_section;
|
||||
switch (active_section_) {
|
||||
case ActiveSection::LOGO:
|
||||
logo_ = std::make_unique<Logo>(renderer_, section_);
|
||||
break;
|
||||
case ActiveSection::Intro:
|
||||
intro = std::make_unique<Intro>(renderer, section);
|
||||
case ActiveSection::INTRO:
|
||||
intro_ = std::make_unique<Intro>(renderer_, section_);
|
||||
break;
|
||||
case ActiveSection::Title:
|
||||
title = std::make_unique<Title>(renderer, section);
|
||||
case ActiveSection::TITLE:
|
||||
title_ = std::make_unique<Title>(renderer_, section_);
|
||||
break;
|
||||
case ActiveSection::Game: {
|
||||
const int NUM_PLAYERS = section->subsection == SUBSECTION_GAME_PLAY_1P ? 1 : 2;
|
||||
game = std::make_unique<Game>(NUM_PLAYERS, 0, renderer, false, section);
|
||||
case ActiveSection::GAME: {
|
||||
const int NUM_PLAYERS = section_->subsection == SUBSECTION_GAME_PLAY_1P ? 1 : 2;
|
||||
game_ = std::make_unique<Game>(NUM_PLAYERS, 0, renderer_, false, section_);
|
||||
break;
|
||||
}
|
||||
case ActiveSection::None:
|
||||
case ActiveSection::NONE:
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -581,7 +581,7 @@ auto Director::iterate() -> SDL_AppResult {
|
||||
section->name = SECTION_PROG_LOGO;
|
||||
}
|
||||
#else
|
||||
if (section->name == SECTION_PROG_QUIT) {
|
||||
if (section_->name == SECTION_PROG_QUIT) {
|
||||
return SDL_APP_SUCCESS;
|
||||
}
|
||||
#endif
|
||||
@@ -593,20 +593,20 @@ auto Director::iterate() -> SDL_AppResult {
|
||||
handleSectionTransition();
|
||||
|
||||
// Ejecuta un frame de la sección activa
|
||||
switch (activeSection) {
|
||||
case ActiveSection::Logo:
|
||||
logo->iterate();
|
||||
switch (active_section_) {
|
||||
case ActiveSection::LOGO:
|
||||
logo_->iterate();
|
||||
break;
|
||||
case ActiveSection::Intro:
|
||||
intro->iterate();
|
||||
case ActiveSection::INTRO:
|
||||
intro_->iterate();
|
||||
break;
|
||||
case ActiveSection::Title:
|
||||
title->iterate();
|
||||
case ActiveSection::TITLE:
|
||||
title_->iterate();
|
||||
break;
|
||||
case ActiveSection::Game:
|
||||
game->iterate();
|
||||
case ActiveSection::GAME:
|
||||
game_->iterate();
|
||||
break;
|
||||
case ActiveSection::None:
|
||||
case ActiveSection::NONE:
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -618,7 +618,7 @@ auto Director::handleEvent(SDL_Event *event) -> SDL_AppResult {
|
||||
#ifndef __EMSCRIPTEN__
|
||||
// Evento de salida de la aplicación
|
||||
if (event->type == SDL_EVENT_QUIT) {
|
||||
section->name = SECTION_PROG_QUIT;
|
||||
section_->name = SECTION_PROG_QUIT;
|
||||
return SDL_APP_SUCCESS;
|
||||
}
|
||||
#endif
|
||||
@@ -646,20 +646,20 @@ auto Director::handleEvent(SDL_Event *event) -> SDL_AppResult {
|
||||
Mouse::handleEvent(*event, Options::video.fullscreen);
|
||||
|
||||
// Reenvía el evento a la sección activa
|
||||
switch (activeSection) {
|
||||
case ActiveSection::Logo:
|
||||
logo->handleEvent(event);
|
||||
switch (active_section_) {
|
||||
case ActiveSection::LOGO:
|
||||
logo_->handleEvent(event);
|
||||
break;
|
||||
case ActiveSection::Intro:
|
||||
intro->handleEvent(event);
|
||||
case ActiveSection::INTRO:
|
||||
intro_->handleEvent(event);
|
||||
break;
|
||||
case ActiveSection::Title:
|
||||
title->handleEvent(event);
|
||||
case ActiveSection::TITLE:
|
||||
title_->handleEvent(event);
|
||||
break;
|
||||
case ActiveSection::Game:
|
||||
game->handleEvent(event);
|
||||
case ActiveSection::GAME:
|
||||
game_->handleEvent(event);
|
||||
break;
|
||||
case ActiveSection::None:
|
||||
case ActiveSection::NONE:
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user