Added a "hide-from-contribs" tag for info files.
authorRicardo Cruz <rick2@aeiou.pt>
Sat, 9 Oct 2004 21:25:09 +0000 (21:25 +0000)
committerRicardo Cruz <rick2@aeiou.pt>
Sat, 9 Oct 2004 21:25:09 +0000 (21:25 +0000)
SVN-Revision: 2006

src/level_subset.cpp
src/level_subset.h
src/title.cpp

index e53bb1c..0d6d3ed 100644 (file)
@@ -52,6 +52,7 @@ void LevelSubset::create(const std::string& subset_name)
   new_subset.name = subset_name;
   new_subset.title = "Unknown Title";
   new_subset.description = "No description so far.";
+  new_subset.hide_from_contribs = false;
   new_subset.save();
 }
 
@@ -67,6 +68,8 @@ void LevelSubset::read_info_file(const std::string& info_file)
       reader.read_string("title", title, true);
       reader.read_string("description", description, true);
       reader.read_string_vector("levels", levels);
+      hide_from_contribs = false;
+      reader.read_bool("hide-from-contribs", hide_from_contribs);
     }
   else
     {
@@ -154,6 +157,9 @@ LevelSubset::save()
       /* Save the description: */
       fprintf(fi,"  (description \"%s\")\n", description.c_str());
 
+      /* Save the hide from Contrbis menu boolean: */
+      fprintf(fi,"  (hide-from-contribs \"%s\")\n", hide_from_contribs ? "#t" : "#f");
+
       fprintf( fi,")");
       fclose(fi);
     }
index 4b9985e..cc4ac63 100644 (file)
@@ -59,7 +59,7 @@ public:
   std::string name;
   std::string title;
   std::string description;
-  Surface* image;
+  bool hide_from_contribs;
 
 private:
   void read_info_file(const std::string& info_file);
index b948c59..bb93602 100644 (file)
@@ -74,6 +74,7 @@ static GameSession* titlesession;
 
 static std::vector<LevelSubset*> contrib_subsets;
 static LevelSubset* current_contrib_subset = 0;
+static int first_level_index;
 
 static std::set<std::string> worldmap_list;
 
@@ -111,16 +112,7 @@ void generate_contrib_menu()
   contrib_menu->additem(MN_LABEL,_("Contrib Levels"),0,0);
   contrib_menu->additem(MN_HL,"",0,0);
   int i = 0;
-  for (std::set<std::string>::iterator it = level_subsets.begin(); it != level_subsets.end(); ++it)
-    {
-      LevelSubset* subset = new LevelSubset();
-      subset->load(*it);
-      contrib_menu->additem(MN_GOTO, subset->title, 0, contrib_subset_menu, i);
-      contrib_subsets.push_back(subset);
-      ++i;
-    }
 
-  i = level_subsets.size();
   for(std::set<std::string>::iterator it = worldmap_list.begin(); it != worldmap_list.end(); ++it)
     {
     WorldMapNS::WorldMap worldmap;
@@ -130,6 +122,23 @@ void generate_contrib_menu()
     }
 
   contrib_menu->additem(MN_HL,"",0,0);
+
+  first_level_index = i;
+  for (std::set<std::string>::iterator it = level_subsets.begin(); it != level_subsets.end(); ++it)
+    {
+      LevelSubset* subset = new LevelSubset();
+      subset->load(*it);
+      if(subset->hide_from_contribs)
+        {
+        delete subset;
+        continue;
+        }
+      contrib_menu->additem(MN_GOTO, subset->title, 0, contrib_subset_menu, i);
+      contrib_subsets.push_back(subset);
+      ++i;
+    }
+
+  contrib_menu->additem(MN_HL,"",0,0);
   contrib_menu->additem(MN_BACK,_("Back"),0,0);
 
   level_subsets.clear();
@@ -143,8 +152,32 @@ void check_levels_contrib_menu()
   if (index == -1)
     return;
 
-  if (index < (int)contrib_subsets.size())
+  if((unsigned)index < worldmap_list.size())
     {
+    WorldMapNS::WorldMap worldmap;
+    std::set<std::string>::iterator it = worldmap_list.begin();
+    for(int i = index; i > 0; --i)
+    ++it;
+
+    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);
+    }
+  else if (index < (int)contrib_subsets.size() + first_level_index)
+    {
+    index -= first_level_index;
     if (current_subset != index)
       {
       current_subset = index;
@@ -183,29 +216,6 @@ void check_levels_contrib_menu()
       titlesession->set_current();
       }
     }
-  else if((unsigned)index < worldmap_list.size() + (int)contrib_subsets.size())
-    {
-    WorldMapNS::WorldMap worldmap;
-    std::set<std::string>::iterator it = worldmap_list.begin();
-    for(int i = index - contrib_subsets.size(); i > 0; --i)
-    ++it;
-
-    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);
-    }
 }
 
 void check_contrib_subset_menu()