From: Ricardo Cruz Date: Sat, 9 Oct 2004 21:25:09 +0000 (+0000) Subject: Added a "hide-from-contribs" tag for info files. X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=e156f196d7af27d46a8b201470a1bd4c2ccb6990;p=supertux.git Added a "hide-from-contribs" tag for info files. SVN-Revision: 2006 --- diff --git a/src/level_subset.cpp b/src/level_subset.cpp index e53bb1cb0..0d6d3ed7c 100644 --- a/src/level_subset.cpp +++ b/src/level_subset.cpp @@ -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); } diff --git a/src/level_subset.h b/src/level_subset.h index 4b9985ecc..cc4ac6347 100644 --- a/src/level_subset.h +++ b/src/level_subset.h @@ -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); diff --git a/src/title.cpp b/src/title.cpp index b948c5976..bb936021b 100644 --- a/src/title.cpp +++ b/src/title.cpp @@ -74,6 +74,7 @@ static GameSession* titlesession; static std::vector contrib_subsets; static LevelSubset* current_contrib_subset = 0; +static int first_level_index; static std::set 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::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::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::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::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::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()