Bugfix: its finally possible to open a levelsubset.
[supertux.git] / src / title.cpp
index 3054667..b948c59 100644 (file)
@@ -114,7 +114,7 @@ void generate_contrib_menu()
   for (std::set<std::string>::iterator it = level_subsets.begin(); it != level_subsets.end(); ++it)
     {
       LevelSubset* subset = new LevelSubset();
-      subset->load((*it).c_str());
+      subset->load(*it);
       contrib_menu->additem(MN_GOTO, subset->title, 0, contrib_subset_menu, i);
       contrib_subsets.push_back(subset);
       ++i;
@@ -167,7 +167,7 @@ void check_levels_contrib_menu()
         if(!reader)
           {
           std::cerr << "Error: Could not open level file. Ignoring...\n";
-          return;
+          continue;
           }
 
         reader->read_string("name", level_title, true);
@@ -189,8 +189,20 @@ void check_levels_contrib_menu()
     std::set<std::string>::iterator it = worldmap_list.begin();
     for(int i = index - contrib_subsets.size(); i > 0; --i)
     ++it;
-    worldmap.loadmap((*it));
-    worldmap.display();
+
+    std::string map_filename = *it;
+
+    worldmap.set_map_filename(map_filename);
+
+    // hack to erase the extension
+    unsigned int ext_pos = it->find_last_of(".");
+    if(ext_pos != std::string::npos)
+      map_filename.erase(ext_pos, map_filename.size() - ext_pos);
+
+    // TODO: slots should be available for contrib maps
+    worldmap.loadgame(st_save_dir + "/" + map_filename + "-slot1.stsg");
+
+    worldmap.display();  // run the map
 
     Menu::set_current(main_menu);
     }
@@ -379,8 +391,8 @@ void title(void)
               if(event.key.keysym.sym == SDLK_DELETE)
                 {
                 int slot = menu->get_active_item_id();
-               std::stringstream stream;
-               stream << slot;
+                std::stringstream stream;
+                stream << slot;
                 std::string str = _("Are you sure you want to delete slot") + stream.str() + "?";
                 
                 if(confirm_dialog(bkg_title, str.c_str()))