New: refeta la lògica d'eixir o apagar el sistema
This commit is contained in:
@@ -122,10 +122,8 @@ void Director::close()
|
||||
// Libera todos los recursos de SDL
|
||||
SDL_Quit();
|
||||
|
||||
#ifdef ARCADE
|
||||
// Si está en modo arcade, apaga el sistema si corresponde
|
||||
shutdownSystem(section::options == section::Options::QUIT_WITH_CONTROLLER);
|
||||
#endif
|
||||
// Apaga el sistema
|
||||
shutdownSystem(section::options == section::Options::SHUTDOWN);
|
||||
}
|
||||
|
||||
// Carga los parametros
|
||||
@@ -671,26 +669,9 @@ int Director::run()
|
||||
}
|
||||
}
|
||||
|
||||
std::string return_code;
|
||||
switch (section::options)
|
||||
{
|
||||
case section::Options::QUIT_WITH_KEYBOARD:
|
||||
return_code = "with keyboard";
|
||||
break;
|
||||
case section::Options::QUIT_WITH_CONTROLLER:
|
||||
return_code = "with controller";
|
||||
break;
|
||||
default:
|
||||
return_code = "from event";
|
||||
break;
|
||||
}
|
||||
|
||||
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "\nGame end %s", return_code.c_str());
|
||||
|
||||
return (section::options == section::Options::QUIT_WITH_CONTROLLER) ? 1 : 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef ARCADE
|
||||
// Apaga el sistema
|
||||
void Director::shutdownSystem(bool should_shutdown)
|
||||
{
|
||||
@@ -710,5 +691,4 @@ void Director::shutdownSystem(bool should_shutdown)
|
||||
#error "Sistema operativo no soportado"
|
||||
#endif
|
||||
}
|
||||
}
|
||||
#endif // ARCADE
|
||||
}
|
||||
@@ -9,35 +9,33 @@ namespace lang
|
||||
class Director
|
||||
{
|
||||
public:
|
||||
// Constructor
|
||||
// --- Constructor y destructor ---
|
||||
Director(int argc, const char *argv[]);
|
||||
|
||||
// Destructor
|
||||
~Director();
|
||||
|
||||
// Bucle principal de la aplicación
|
||||
// --- Bucle principal ---
|
||||
int run();
|
||||
|
||||
private:
|
||||
// Variables internas
|
||||
// --- Variables internas ---
|
||||
std::string executable_path_; // Ruta del ejecutable
|
||||
std::string system_folder_; // Carpeta del sistema para almacenar datos
|
||||
|
||||
// Inicialización y cierre del sistema
|
||||
// --- Inicialización y cierre del sistema ---
|
||||
void init(); // Inicializa la aplicación
|
||||
void close(); // Cierra y libera recursos
|
||||
|
||||
// Configuración inicial
|
||||
// --- Configuración inicial ---
|
||||
void loadParams(); // Carga los parámetros del programa
|
||||
void loadScoreFile(); // Carga el fichero de puntuaciones
|
||||
void createSystemFolder(const std::string &folder); // Crea la carpeta del sistema
|
||||
|
||||
// Gestión de entrada y archivos
|
||||
// --- Gestión de entrada y archivos ---
|
||||
void bindInputs(); // Asigna botones y teclas al sistema de entrada
|
||||
void setFileList(); // Crea el índice de archivos disponibles
|
||||
void checkProgramArguments(int argc, const char *argv[]); // Verifica los parámetros del programa
|
||||
|
||||
// Diferentes secciones del programa
|
||||
// --- Secciones del programa ---
|
||||
void runLogo(); // Ejecuta la pantalla con el logo
|
||||
void runIntro(); // Ejecuta la introducción del juego
|
||||
void runTitle(); // Ejecuta la pantalla de título
|
||||
@@ -48,10 +46,9 @@ private:
|
||||
void runDemoGame(); // Ejecuta el modo demo
|
||||
void reset(); // Reinicia objetos y vuelve a la sección inicial
|
||||
|
||||
// Gestión de archivos de idioma
|
||||
// --- Gestión de archivos de idioma ---
|
||||
std::string getLangFile(lang::Code code); // Obtiene un fichero de idioma según el código
|
||||
|
||||
#ifdef ARCADE
|
||||
void shutdownSystem(bool should_shutdown); // Apaga el sistema (modo arcade)
|
||||
#endif
|
||||
// --- Apagado del sistema ---
|
||||
void shutdownSystem(bool should_shutdown); // Apaga el sistema
|
||||
};
|
||||
|
||||
@@ -12,7 +12,7 @@ namespace globalEvents
|
||||
{
|
||||
case SDL_EVENT_QUIT: // Evento de salida de la aplicación
|
||||
section::name = section::Name::QUIT;
|
||||
section::options = section::Options::QUIT_FROM_EVENT;
|
||||
section::options = section::Options::NONE;
|
||||
return;
|
||||
|
||||
case SDL_EVENT_RENDER_DEVICE_RESET:
|
||||
|
||||
@@ -17,24 +17,19 @@
|
||||
namespace globalInputs
|
||||
{
|
||||
// Termina
|
||||
void quit(section::Options code)
|
||||
void quit()
|
||||
{
|
||||
const std::string CODE = "QUIT";
|
||||
if (Notifier::get()->checkCode(CODE))
|
||||
{
|
||||
// Si la notificación de salir está activa, cambia de sección
|
||||
section::name = section::Name::QUIT;
|
||||
section::options = code;
|
||||
section::options = section::Options::NONE;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Si la notificación de salir no está activa, muestra la notificación
|
||||
#ifdef ARCADE
|
||||
const std::string TEXT = code == section::Options::QUIT_WITH_CONTROLLER ? lang::getText("[NOTIFICATIONS] 02") : lang::getText("[NOTIFICATIONS] 01");
|
||||
Notifier::get()->show({TEXT, std::string()}, -1, CODE);
|
||||
#else
|
||||
Notifier::get()->show({lang::getText("[NOTIFICATIONS] 01"), std::string()}, -1, CODE);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@@ -356,7 +351,7 @@ namespace globalInputs
|
||||
// Salir
|
||||
if (Input::get()->checkInput(InputAction::EXIT, INPUT_DO_NOT_ALLOW_REPEAT, InputDeviceToUse::KEYBOARD))
|
||||
{
|
||||
quit(section::Options::QUIT_WITH_KEYBOARD);
|
||||
quit();
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ namespace section
|
||||
// --- Enumeraciones de secciones del programa ---
|
||||
enum class Name
|
||||
{
|
||||
RESET, // Inicialización
|
||||
RESET, // Inicialización
|
||||
LOGO, // Pantalla de logo
|
||||
INTRO, // Introducción
|
||||
TITLE, // Pantalla de título/menú principal
|
||||
@@ -31,11 +31,9 @@ namespace section
|
||||
TITLE_TIME_OUT, // Timeout en el título
|
||||
TITLE_1, // Opción 1 en el título
|
||||
TITLE_2, // Opción 2 en el título
|
||||
QUIT_WITH_KEYBOARD, // Salir con teclado
|
||||
QUIT_WITH_CONTROLLER, // Salir con mando
|
||||
QUIT_FROM_EVENT, // Salir por evento
|
||||
RELOAD, // Recargar sección
|
||||
HI_SCORE_AFTER_PLAYING, // Mostrar récord tras jugar
|
||||
SHUTDOWN, // Apagar el sistema
|
||||
NONE, // Sin opción
|
||||
};
|
||||
|
||||
|
||||
@@ -263,13 +263,13 @@ void ServiceMenu::selectOption()
|
||||
else if (display_options_.at(selected_)->caption == lang::getText("[SERVICE_MENU] QUIT"))
|
||||
{
|
||||
section::name = section::Name::QUIT;
|
||||
section::options = section::Options::QUIT_WITH_KEYBOARD;
|
||||
section::options = section::Options::NONE;
|
||||
return;
|
||||
}
|
||||
else if (display_options_.at(selected_)->caption == lang::getText("[SERVICE_MENU] SHUTDOWN"))
|
||||
{
|
||||
section::name = section::Name::QUIT;
|
||||
section::options = section::Options::QUIT_WITH_CONTROLLER;
|
||||
section::options = section::Options::SHUTDOWN;
|
||||
return;
|
||||
}
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user