-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Game: Move main function into its own file
- Loading branch information
1 parent
c432ac7
commit 62b1f99
Showing
4 changed files
with
93 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
//******************************************************************************************** | ||
//* | ||
//* This file is part of Egoboo. | ||
//* | ||
//* Egoboo is free software: you can redistribute it and/or modify it | ||
//* under the terms of the GNU General Public License as published by | ||
//* the Free Software Foundation, either version 3 of the License, or | ||
//* (at your option) any later version. | ||
//* | ||
//* Egoboo is distributed in the hope that it will be useful, but | ||
//* WITHOUT ANY WARRANTY; without even the implied warranty of | ||
//* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
//* General Public License for more details. | ||
//* | ||
//* You should have received a copy of the GNU General Public License | ||
//* along with Egoboo. If not, see <https://www.gnu.org/licenses/>. | ||
//* | ||
//******************************************************************************************** | ||
/// @author Johan Jansen | ||
/// @author Michael Heilmann | ||
|
||
#include "game/Core/GameEngine.hpp" | ||
#include "game/GUI/UIManager.hpp" | ||
|
||
/** | ||
* @brief | ||
* The entry point of the program. | ||
* @param argc | ||
* the number of command-line arguments (number of elements in the array pointed by @a argv) | ||
* @param argv | ||
* the command-line arguments (a static constant array of @a argc pointers to static constant zero-terminated strings) | ||
* @return | ||
* EXIT_SUCCESS upon regular termination, EXIT_FAILURE otherwise | ||
*/ | ||
int SDL_main(int argc, char **argv) | ||
{ | ||
try | ||
{ | ||
Ego::Core::System::initialize(std::string(argv[0])); | ||
try | ||
{ | ||
_gameEngine = std::make_unique<GameEngine>(); | ||
|
||
_gameEngine->start(); | ||
} | ||
catch (...) | ||
{ | ||
Ego::Core::System::uninitialize(); | ||
std::rethrow_exception(std::current_exception()); | ||
} | ||
Ego::Core::System::uninitialize(); | ||
} | ||
catch (const id::exception& ex) | ||
{ | ||
std::cerr << "unhandled exception: " << std::endl | ||
<< ex.to_string() << std::endl; | ||
|
||
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, | ||
"Unhandled Exception", | ||
ex.to_string().c_str(), | ||
nullptr); | ||
|
||
return EXIT_FAILURE; | ||
} | ||
catch (const std::exception& ex) | ||
{ | ||
std::cerr << "unhandled exception: " << std::endl | ||
<< ex.what() << std::endl; | ||
|
||
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, | ||
"Unhandled asException", | ||
ex.what(), | ||
nullptr); | ||
|
||
return EXIT_FAILURE; | ||
} | ||
catch (...) | ||
{ | ||
std::cerr << "unhandled exception" << std::endl; | ||
|
||
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, | ||
"Unhandled Exception", | ||
"Unknown exception type", | ||
nullptr); | ||
|
||
return EXIT_FAILURE; | ||
} | ||
return EXIT_SUCCESS; | ||
} |