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();
}
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
{
/* 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);
}
static std::vector<LevelSubset*> contrib_subsets;
static LevelSubset* current_contrib_subset = 0;
+static int first_level_index;
static std::set<std::string> worldmap_list;
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;
}
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();
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;
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()