Let navigate through the worldmap using Tux keys as well.
[supertux.git] / src / title.cpp
index fe63a48..9e45049 100644 (file)
@@ -80,6 +80,20 @@ static std::set<std::string> worldmap_list;
 
 static FrameRate frame_rate(100);  
 
+/* If the demo was stopped - because game started, level
+   editor was excuted, etc - call this when you get back
+   to the title code.
+ */
+void resume_demo()
+{
+  // FIXME: shouldn't be needed if GameSession
+  // didn't relay on global variables
+  titlesession->get_current_sector()->activate();
+  titlesession->set_current();
+
+  frame_rate.update();
+}
+
 void update_load_save_game_menu(Menu* pmenu)
 {
   for(int i = 2; i < 7; ++i)
@@ -161,6 +175,13 @@ void check_levels_contrib_menu()
 
     std::string map_filename = *it;
 
+    // some fading
+    fadeout(256);
+    DrawingContext context;
+      context.draw_text(white_text, "Loading...",
+                        Vector(screen->w/2, screen->h/2), CENTER_ALLIGN, LAYER_FOREGROUND1);
+      context.do_drawing();
+
     worldmap.set_map_filename(map_filename);
 
     // hack to erase the extension
@@ -174,6 +195,7 @@ void check_levels_contrib_menu()
     worldmap.display();  // run the map
 
     Menu::set_current(main_menu);
+    resume_demo();
     }
   else if (index < (int)contrib_subsets.size() + first_level_index)
     {
@@ -196,7 +218,20 @@ void check_levels_contrib_menu()
         /** get level's title */
         std::string level_title = "<no title>";
 
-        LispReader* reader = LispReader::load(subset.get_level_filename(i), "supertux-level");
+        std::string filename = subset.get_level_filename(i);
+        std::string filepath;
+        filepath = st_dir + "/levels/" + filename;
+        if (access(filepath.c_str(), R_OK) != 0)
+        {
+          filepath = datadir + "/levels/" + filename;
+          if (access(filepath.c_str(), R_OK) != 0)
+          {
+            std::cerr << "Error: Level: couldn't find level: " << filename << std::endl;
+            continue;
+          }
+        }
+        
+        LispReader* reader = LispReader::load(filepath, "supertux-level");
         if(!reader)
           {
           std::cerr << "Error: Could not open level file. Ignoring...\n";
@@ -232,26 +267,11 @@ void check_contrib_subset_menu()
           session.run();
           player_status.reset();
           Menu::set_current(main_menu);
-          titlesession->get_current_sector()->activate();
-          titlesession->set_current();
+          resume_demo();
         }
     }  
 }
 
-/* If the demo was stopped - because game started, level
-   editor was excuted, etc - call this when you get back
-   to the title code.
- */
-void resume_demo()
-{
-  // FIXME: shouldn't be needed if GameSession
-  // didn't relay on global variables
-  titlesession->get_current_sector()->activate();
-  titlesession->set_current();
-
-  frame_rate.update();
-}
-
 void draw_demo(double frame_ratio)
 {
   Sector* world  = titlesession->get_current_sector();
@@ -307,7 +327,7 @@ void title(void)
   random_timer.init(true);
   Ticks::pause_init();
 
-  titlesession = new GameSession(datadir + "/levels/misc/menu.stl", ST_GL_DEMO_GAME);
+  titlesession = new GameSession("misc/menu.stl", ST_GL_DEMO_GAME);
 
   /* Load images: */
   bkg_title = new Surface(datadir + "/images/background/arctis.jpg", false);
@@ -397,7 +417,9 @@ void title(void)
                   resume_demo();
                   break;
                 case MNID_CREDITS:
+                  fadeout(500);
                   display_text_file("CREDITS", SCROLL_SPEED_CREDITS, white_big_text , white_text, white_small_text, blue_text );
+                  fadeout(500);
                   Menu::set_current(main_menu);
                   break;
                 case MNID_QUITMAINMENU: