X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=src%2Ftitle.cpp;h=514479d77b77759cb073ae3fea82b1580b96e301;hb=9599042661b468aae7bd34dca05441c0ebc93ad7;hp=1e5449ef35c9bf9522262fc9167cf5c6ddcc0cce;hpb=ef57479f613b900b73eba8e8f4d026aae0de25cc;p=supertux.git diff --git a/src/title.cpp b/src/title.cpp index 1e5449ef3..514479d77 100644 --- a/src/title.cpp +++ b/src/title.cpp @@ -36,7 +36,6 @@ #include #endif -#include "defines.h" #include "app/globals.h" #include "title.h" #include "video/screen.h" @@ -52,7 +51,7 @@ #include "gameloop.h" #include "worldmap.h" #include "leveleditor.h" -#include "scene.h" +#include "player_status.h" #include "tile.h" #include "sector.h" #include "object/tilemap.h" @@ -75,9 +74,6 @@ static GameSession* titlesession; static std::vector contrib_subsets; static LevelSubset* current_contrib_subset = 0; -static int first_level_index; - -static std::set worldmap_list; static FrameRate frame_rate(100); @@ -126,28 +122,17 @@ 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 = worldmap_list.begin(); - it != worldmap_list.end(); ++it) { - WorldMapNS::WorldMap worldmap; - worldmap.loadmap((*it).c_str()); - contrib_menu->additem(MN_ACTION, worldmap.get_world_title(),0,0, i); - ++i; - } - - contrib_menu->additem(MN_HL,"",0,0); - - first_level_index = i; - for (std::set::iterator it = level_subsets.begin(); it != level_subsets.end(); ++it) + 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) - { + 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; @@ -186,68 +171,52 @@ void check_levels_contrib_menu() if (index == -1) return; - if((unsigned)index < worldmap_list.size()) - { + LevelSubset& subset = * (contrib_subsets[index]); + + if(subset.has_worldmap) { 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(subset.get_worldmap_filename()); // some fading fadeout(256); DrawingContext context; - context.draw_text(white_text, "Loading...", - Vector(screen->w/2, screen->h/2), CENTER_ALLIGN, LAYER_FOREGROUND1); - context.do_drawing(); - - 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); + context.draw_text(white_text, "Loading...", + Vector(screen->w/2, screen->h/2), CENTER_ALLIGN, LAYER_FOREGROUND1); + context.do_drawing(); // TODO: slots should be available for contrib maps - worldmap.loadgame(st_save_dir + "/" + map_filename + "-slot1.stsg"); + worldmap.loadgame(st_save_dir + "/" + subset.name + "-slot1.stsg"); worldmap.display(); // run the map Menu::set_current(main_menu); resume_demo(); - } - else if (index < (int)contrib_subsets.size() + first_level_index) - { - index -= first_level_index; - if (current_subset != index) - { - current_subset = index; - // FIXME: This shouln't be busy looping - LevelSubset& subset = * (contrib_subsets[index]); - - current_contrib_subset = ⊂ - - contrib_subset_menu->clear(); - - contrib_subset_menu->additem(MN_LABEL, subset.title, 0,0); - contrib_subset_menu->additem(MN_HL,"",0,0); - - for (int i = 0; i < subset.get_num_levels(); ++i) - { - /** get level's title */ - std::string filename = subset.get_level_filename(i); - std::string title = get_level_name(filename); - contrib_subset_menu->additem(MN_ACTION, title, 0, 0, i); - } + } else if (current_subset != index) { + current_subset = index; + // FIXME: This shouln't be busy looping + LevelSubset& subset = * (contrib_subsets[index]); - contrib_subset_menu->additem(MN_HL,"",0,0); - contrib_subset_menu->additem(MN_BACK, _("Back"), 0, 0); + current_contrib_subset = ⊂ - titlesession->get_current_sector()->activate(); - titlesession->set_current(); - } + contrib_subset_menu->clear(); + + contrib_subset_menu->additem(MN_LABEL, subset.title, 0,0); + contrib_subset_menu->additem(MN_HL,"",0,0); + + for (int i = 0; i < subset.get_num_levels(); ++i) + { + /** get level's title */ + std::string filename = subset.get_level_filename(i); + std::string title = get_level_name(filename); + contrib_subset_menu->additem(MN_ACTION, title, 0, 0, i); } + + contrib_subset_menu->additem(MN_HL,"",0,0); + contrib_subset_menu->additem(MN_BACK, _("Back"), 0, 0); + + titlesession->get_current_sector()->activate(); + titlesession->set_current(); + } } void check_contrib_subset_menu() @@ -276,16 +245,16 @@ void draw_demo(float elapsed_time) world->play_music(LEVEL_MUSIC); - tux->key_event((SDLKey) keymap.right,DOWN); + tux->key_event((SDLKey) keymap.right, true); if(random_timer.check()) { random_timer.start(float(rand() % 3000 + 3000) / 1000.); walking = !walking; } else { if(walking) - tux->key_event((SDLKey) keymap.jump,UP); + tux->key_event((SDLKey) keymap.jump, false); else - tux->key_event((SDLKey) keymap.jump,DOWN); + tux->key_event((SDLKey) keymap.jump, true); } // Wrap around at the end of the level back to the beginnig @@ -316,6 +285,7 @@ void title(void) { walking = true; LevelEditor* leveleditor; + MusicRef credits_music; Ticks::pause_init(); @@ -327,9 +297,6 @@ void title(void) logo = new Surface(datadir + "/images/title/logo.png", true); img_choose_subset = new Surface(datadir + "/images/status/choose-level-subset.png", true); - /* Generating contrib maps by only using a string_list */ - worldmap_list = FileSystem::dfiles("levels/worldmap", "", "icyisland.stwm"); - titlesession->get_current_sector()->activate(); titlesession->set_current(); @@ -380,10 +347,14 @@ void title(void) context.draw_text(white_small_text, " SuperTux " PACKAGE_VERSION "\n", Vector(0, screen->h - 70), LEFT_ALLIGN, LAYER_FOREGROUND1); context.draw_text(white_small_text, - _("Copyright (c) 2003 SuperTux Devel Team\n" - "This game comes with ABSOLUTELY NO WARRANTY. This is free software, and you\n" - "are welcome to redistribute it under certain conditions; see the file COPYING\n" - "for details.\n"), Vector(0, screen->h - 70 + white_small_text->get_height()), LEFT_ALLIGN, LAYER_FOREGROUND1); + _( +"Copyright (c) 2003 SuperTux Devel Team\n" +"This game comes with ABSOLUTELY NO WARRANTY. This is free software, and you\n" +"are welcome to redistribute it under certain conditions; see the file COPYING\n" +"for details.\n" + ), + Vector(0, screen->h - 70 + white_small_text->get_height()), + LEFT_ALLIGN, LAYER_FOREGROUND1); /* Don't draw menu, if quit is true */ Menu* menu = Menu::current(); @@ -414,6 +385,8 @@ void title(void) break; case MNID_CREDITS: fadeout(500); + credits_music = SoundManager::get()->load_music(datadir + "/music/credits.ogg"); + SoundManager::get()->play_music(credits_music); display_text_file("credits.txt", SCROLL_SPEED_CREDITS, white_big_text , white_text, white_small_text, blue_text ); fadeout(500); Menu::set_current(main_menu); @@ -474,7 +447,6 @@ void title(void) /* Free surfaces: */ free_contrib_menu(); - worldmap_list.clear(); delete titlesession; delete bkg_title; delete logo;