X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;ds=sidebyside;f=src%2Fsupertux.cpp;h=46efc59ee861084bb1e8c5fe670377cc994c40e6;hb=f54737bb28bec638b9f436d023b9f21fec2caadd;hp=d410aaa9ec7a755c38c3d62c45bf9ac4173d29f9;hpb=84160722392a024dda42bd86ca9bd85b68c49457;p=supertux.git diff --git a/src/supertux.cpp b/src/supertux.cpp index d410aaa9e..46efc59ee 100644 --- a/src/supertux.cpp +++ b/src/supertux.cpp @@ -17,53 +17,89 @@ // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA // 02111-1307, USA. +#include #include -#include +#include +#include +#include +#include -#include "defines.h" -#include "globals.h" -#include "setup.h" -#include "intro.h" +#include "app/globals.h" +#include "app/setup.h" #include "title.h" #include "gameloop.h" #include "leveleditor.h" -#include "screen.h" +#include "video/screen.h" #include "worldmap.h" #include "resources.h" +#include "video/surface.h" +#include "tile_manager.h" +#include "app/gettext.h" +#include "misc.h" +#include "utils/configfile.h" int main(int argc, char * argv[]) { - st_directory_setup(); - parseargs(argc, argv); - - st_audio_setup(); - st_video_setup(); - st_joystick_setup(); - st_general_setup(); - st_menu(); - loadshared(); +#ifndef DEBUG + try { +#endif + config = new MyConfig; + + Setup::init(PACKAGE_NAME, PACKAGE_NAME, PACKAGE_VERSION); + + Setup::parseargs(argc, argv); - if (launch_worldmap_mode) + Setup::audio(); + Setup::video(screen_width, screen_height); + Setup::joystick(); + Setup::general(); + st_menu(); + loadshared(); + + if (launch_leveleditor_mode) + { + LevelEditor leveleditor; + + if(level_startup_file) + leveleditor.run(level_startup_file); + else + leveleditor.run(); + } + else if (launch_worldmap_mode && level_startup_file) { + // hack to make it possible for someone to give an absolute path + std::string str(level_startup_file); + unsigned int i = str.find_last_of("/", str.size()); + if(i != std::string::npos) + str.erase(0, i+1); + WorldMapNS::WorldMap worldmap; + worldmap.loadmap(str); worldmap.display(); } - else if (level_startup_file) + else if (level_startup_file) { - GameSession session(level_startup_file, 1, ST_GL_LOAD_LEVEL_FILE); + GameSession session(level_startup_file, ST_GL_LOAD_LEVEL_FILE); session.run(); } - else + else { title(); } - - clearscreen(0, 0, 0); - updatescreen(); - unloadshared(); - st_shutdown(); - + unloadshared(); + Setup::general_free(); + st_menu_free(); +#ifdef DEBUG + Surface::debug_check(); +#endif + Termination::shutdown(); +#ifndef DEBUG // we want to see the backtrace in gdb when in debug mode + } catch (std::exception &e) { + std:: cerr << "Unhandled exception: " << e.what() << std::endl; + } +#endif + return 0; }