Implementado código de salida de la aplicación

This commit is contained in:
2024-09-09 13:51:16 +02:00
parent 922d146781
commit 83fb2f30ba
4 changed files with 9 additions and 4 deletions

View File

@@ -880,7 +880,7 @@ void Director::runDemoGame()
delete demoGame; delete demoGame;
} }
void Director::run() int Director::run()
{ {
// Bucle principal // Bucle principal
while (section->name != SECTION_PROG_QUIT) while (section->name != SECTION_PROG_QUIT)
@@ -916,6 +916,9 @@ void Director::run()
break; break;
} }
} }
const int returnCode = section->options == SECTION_OPTIONS_QUIT_NORMAL ? 0 : 1;
return returnCode;
} }
// Asigna variables a partir de dos cadenas // Asigna variables a partir de dos cadenas

View File

@@ -122,5 +122,5 @@ public:
~Director(); ~Director();
// Bucle principal // Bucle principal
void run(); int run();
}; };

View File

@@ -18,12 +18,12 @@ int main(int argc, char *argv[])
Director *director = new Director(argc, argv); Director *director = new Director(argc, argv);
// Bucle principal // Bucle principal
director->run(); const int exit = director->run();
// Destruye el objeto Director // Destruye el objeto Director
delete director; delete director;
std::cout << "\nGame end" << std::endl; std::cout << "\nGame end" << std::endl;
return 0; return exit;
} }

View File

@@ -248,6 +248,7 @@ void Title::checkInput()
if (input->checkInput(input_exit, DO_NOT_ALLOW_REPEAT, INPUT_USE_KEYBOARD)) if (input->checkInput(input_exit, DO_NOT_ALLOW_REPEAT, INPUT_USE_KEYBOARD))
{ {
section->name = SECTION_PROG_QUIT; section->name = SECTION_PROG_QUIT;
section->options = SECTION_OPTIONS_QUIT_NORMAL;
} }
// Comprueba si se ha pulsado la tecla 1 o 2 para definir los controladores // Comprueba si se ha pulsado la tecla 1 o 2 para definir los controladores
@@ -272,6 +273,7 @@ void Title::checkInput()
{ {
case SERVICE_EXIT: case SERVICE_EXIT:
section->name = SECTION_PROG_QUIT; section->name = SECTION_PROG_QUIT;
section->options = SECTION_OPTIONS_QUIT_SHUTDOWN;
break; break;
case SERVICE_SHADERS: case SERVICE_SHADERS: