Move some more globals to supertux/globals.hpp
[supertux.git] / src / supertux / main.cpp
index 10744f3..bef5b08 100644 (file)
@@ -42,7 +42,7 @@ namespace supertux_apple {
 #include "scripting/squirrel_util.hpp"
 #include "supertux/gameconfig.hpp"
 #include "supertux/globals.hpp"
-#include "supertux/mainloop.hpp"
+#include "supertux/screen_manager.hpp"
 #include "supertux/resources.hpp"
 #include "supertux/title_screen.hpp"
 #include "util/file_system.hpp"
@@ -66,15 +66,17 @@ Main::init_config()
 void
 Main::init_tinygettext()
 {
+  dictionary_manager = new tinygettext::DictionaryManager();
   tinygettext::Log::set_log_info_callback(0);
-  dictionary_manager.set_filesystem(std::auto_ptr<tinygettext::FileSystem>(new PhysFSFileSystem));
+  dictionary_manager->set_filesystem(std::auto_ptr<tinygettext::FileSystem>(new PhysFSFileSystem));
 
-  dictionary_manager.add_directory("locale");
-  dictionary_manager.set_charset("UTF-8");
+  dictionary_manager->add_directory("locale");
+  dictionary_manager->set_charset("UTF-8");
 
   // Config setting "locale" overrides language detection
-  if (g_config->locale != "") {
-    dictionary_manager.set_language(tinygettext::Language::from_name(g_config->locale));
+  if (g_config->locale != "") 
+  {
+    dictionary_manager->set_language(tinygettext::Language::from_name(g_config->locale));
   }
 }
 
@@ -441,7 +443,7 @@ Main::init_video()
     SDL_WM_SetIcon(icon, 0);
     SDL_FreeSurface(icon);
   }
-#ifdef DEBUG
+#ifndef NDEBUG
   else {
     log_warning << "Couldn't load icon '" << icon_fname << "'" << std::endl;
   }
@@ -499,7 +501,7 @@ Main::wait_for_event(float min_delay, float max_delay)
     while(SDL_PollEvent(&event)) {
       switch(event.type) {
         case SDL_QUIT:
-          g_main_loop->quit();
+          g_screen_manager->quit();
           break;
         case SDL_KEYDOWN:
         case SDL_JOYBUTTONDOWN:
@@ -514,7 +516,7 @@ Main::wait_for_event(float min_delay, float max_delay)
   }
 }
 
-#ifdef DEBUG
+#ifndef NDEBUG
 static Uint32 last_timelog_ticks = 0;
 static const char* last_timelog_component = 0;
 
@@ -583,7 +585,7 @@ Main::main(int argc, char** argv)
 
     timelog(0);
 
-    g_main_loop = new MainLoop();
+    g_screen_manager = new ScreenManager();
     if(g_config->start_level != "") {
       // we have a normal path specified at commandline, not a physfs path.
       // So we simply mount that path here...
@@ -594,7 +596,7 @@ Main::main(int argc, char** argv)
       if(g_config->start_level.size() > 4 &&
          g_config->start_level.compare(g_config->start_level.size() - 5, 5, ".stwm") == 0) {
         init_rand();
-        g_main_loop->push_screen(new WorldMapNS::WorldMap(
+        g_screen_manager->push_screen(new WorldMapNS::WorldMap(
                                  FileSystem::basename(g_config->start_level)));
       } else {
         init_rand();//If level uses random eg. for
@@ -610,15 +612,15 @@ Main::main(int argc, char** argv)
 
         if(g_config->record_demo != "")
           session->record_demo(g_config->record_demo);
-        g_main_loop->push_screen(session.release());
+        g_screen_manager->push_screen(session.release());
       }
     } else {
       init_rand();
-      g_main_loop->push_screen(new TitleScreen());
+      g_screen_manager->push_screen(new TitleScreen());
     }
 
     //init_rand(); PAK: this call might subsume the above 3, but I'm chicken!
-    g_main_loop->run(context);
+    g_screen_manager->run(context);
   } catch(std::exception& e) {
     log_fatal << "Unexpected exception: " << e.what() << std::endl;
     result = 1;
@@ -627,8 +629,8 @@ Main::main(int argc, char** argv)
     result = 1;
   }
 
-  delete g_main_loop;
-  g_main_loop = NULL;
+  delete g_screen_manager;
+  g_screen_manager = NULL;
 
   Resources::unload_shared();
   quit_audio();