Afegit codi per apagar el sistema al eixir del joc
This commit is contained in:
@@ -8,6 +8,7 @@
|
|||||||
#include <SDL2/SDL_scancode.h> // for SDL_SCANCODE_0, SDL_SCANCODE_DOWN
|
#include <SDL2/SDL_scancode.h> // for SDL_SCANCODE_0, SDL_SCANCODE_DOWN
|
||||||
#include <SDL2/SDL_stdinc.h> // for SDL_bool, Uint32
|
#include <SDL2/SDL_stdinc.h> // for SDL_bool, Uint32
|
||||||
#include <SDL2/SDL_timer.h> // for SDL_GetTicks
|
#include <SDL2/SDL_timer.h> // for SDL_GetTicks
|
||||||
|
#include <cstdlib> // for system
|
||||||
#include <errno.h> // for errno, EEXIST, EACCES, ENAMETOO...
|
#include <errno.h> // for errno, EEXIST, EACCES, ENAMETOO...
|
||||||
#include <stdio.h> // for printf, perror
|
#include <stdio.h> // for printf, perror
|
||||||
#include <string.h> // for strcmp
|
#include <string.h> // for strcmp
|
||||||
@@ -697,6 +698,12 @@ int Director::run()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef ARCADE
|
||||||
|
// Comprueba si ha de apagar el sistema
|
||||||
|
if (section::options == section::Options::QUIT_SHUTDOWN)
|
||||||
|
shutdownSystem();
|
||||||
|
#endif
|
||||||
|
|
||||||
const int return_code = section::options == section::Options::QUIT_NORMAL ? 0 : 1;
|
const int return_code = section::options == section::Options::QUIT_NORMAL ? 0 : 1;
|
||||||
return return_code;
|
return return_code;
|
||||||
}
|
}
|
||||||
@@ -724,3 +731,21 @@ std::string Director::getLangFile(lang::Code code)
|
|||||||
|
|
||||||
return Asset::get()->get("en_UK.txt");
|
return Asset::get()->get("en_UK.txt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Apaga el sistema
|
||||||
|
void shutdownSystem()
|
||||||
|
{
|
||||||
|
#ifdef _WIN32
|
||||||
|
// Apaga el sistema en Windows
|
||||||
|
system("shutdown /s /t 0");
|
||||||
|
#elif __APPLE__
|
||||||
|
// Apaga el sistema en macOS
|
||||||
|
system("sudo shutdown -h now");
|
||||||
|
#elif __linux__
|
||||||
|
// Apaga el sistema en Linux
|
||||||
|
system("shutdown -h now");
|
||||||
|
#else
|
||||||
|
// Sistema operativo no compatible
|
||||||
|
#error "Sistema operativo no soportado"
|
||||||
|
#endif
|
||||||
|
}
|
||||||
@@ -76,6 +76,9 @@ private:
|
|||||||
// Obtiene una fichero a partir de un lang::Code
|
// Obtiene una fichero a partir de un lang::Code
|
||||||
std::string getLangFile(lang::Code code);
|
std::string getLangFile(lang::Code code);
|
||||||
|
|
||||||
|
// Apaga el sistema
|
||||||
|
void shutdownSystem();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// Constructor
|
// Constructor
|
||||||
Director(int argc, const char *argv[]);
|
Director(int argc, const char *argv[]);
|
||||||
|
|||||||
Reference in New Issue
Block a user