[Super-tux-commit] supertux/src level_subset.h,1.5,1.6 level_subset.cpp,1.12,1.13 title.cpp,1.123,1.
Brought to you by:
wkendrick
From: Ricardo C. <rm...@us...> - 2004-10-09 21:25:26
|
Update of /cvsroot/super-tux/supertux/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv695/src Modified Files: level_subset.h level_subset.cpp title.cpp Log Message: Added a "hide-from-contribs" tag for info files. Index: title.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/title.cpp,v retrieving revision 1.123 retrieving revision 1.124 diff -u -d -r1.123 -r1.124 --- title.cpp 9 Oct 2004 15:32:06 -0000 1.123 +++ title.cpp 9 Oct 2004 21:25:09 -0000 1.124 @@ -74,6 +74,7 @@ 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 @@ 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 @@ } 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 @@ 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 @@ 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() Index: level_subset.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/level_subset.cpp,v retrieving revision 1.12 retrieving revision 1.13 diff -u -d -r1.12 -r1.13 --- level_subset.cpp 9 Oct 2004 15:32:06 -0000 1.12 +++ level_subset.cpp 9 Oct 2004 21:25:09 -0000 1.13 @@ -52,6 +52,7 @@ 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 @@ 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 @@ /* 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: level_subset.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/level_subset.h,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- level_subset.h 24 Sep 2004 15:10:10 -0000 1.5 +++ level_subset.h 9 Oct 2004 21:25:09 -0000 1.6 @@ -59,7 +59,7 @@ 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); |