From 88098c1f5b05cb33f23605319ffef800319bca5f Mon Sep 17 00:00:00 2001 From: Ricardo Cruz Date: Wed, 14 Jul 2004 09:46:19 +0000 Subject: [PATCH] Merged the two worldmap and level subset contrib menu. In the future, it would be a good idea to make level subset dealing with both levels and worldmaps. SVN-Revision: 1573 --- src/menu.cpp | 1 - src/menu.h | 2 -- src/setup.cpp | 3 -- src/title.cpp | 105 ++++++++++++++++++++++++---------------------------------- 4 files changed, 43 insertions(+), 68 deletions(-) diff --git a/src/menu.cpp b/src/menu.cpp index d0eb6a87e..a4e7ceb8b 100644 --- a/src/menu.cpp +++ b/src/menu.cpp @@ -59,7 +59,6 @@ Menu* options_joystick_menu = 0; Menu* highscore_menu = 0; Menu* load_game_menu = 0; Menu* save_game_menu = 0; -Menu* contrib_worldmap_menu = 0; Menu* contrib_menu = 0; Menu* contrib_subset_menu = 0; diff --git a/src/menu.h b/src/menu.h index 8957f105e..15d78ee1b 100644 --- a/src/menu.h +++ b/src/menu.h @@ -33,7 +33,6 @@ enum MainMenuIDs { MNID_STARTGAME, - MNID_WORLDMAP_CONTRIB, MNID_LEVELS_CONTRIB, MNID_OPTIONMENU, MNID_LEVELEDITOR, @@ -236,7 +235,6 @@ extern Surface* back; extern Surface* arrow_left; extern Surface* arrow_right; -extern Menu* contrib_worldmap_menu; extern Menu* contrib_menu; extern Menu* contrib_subset_menu; extern Menu* main_menu; diff --git a/src/setup.cpp b/src/setup.cpp index 1a5698b45..9c6ed63a9 100644 --- a/src/setup.cpp +++ b/src/setup.cpp @@ -383,13 +383,11 @@ void st_menu(void) game_menu = new Menu(); highscore_menu = new Menu(); contrib_menu = new Menu(); - contrib_worldmap_menu = new Menu(); contrib_subset_menu = new Menu(); worldmap_menu = new Menu(); main_menu->set_pos(screen->w/2, 335); main_menu->additem(MN_GOTO, _("Start Game"),0,load_game_menu, MNID_STARTGAME); - main_menu->additem(MN_GOTO, _("Contrib Worlds"),0,contrib_worldmap_menu, MNID_WORLDMAP_CONTRIB); main_menu->additem(MN_GOTO, _("Contrib Levels"),0,contrib_menu, MNID_LEVELS_CONTRIB); main_menu->additem(MN_GOTO, _("Options"),0,options_menu, MNID_OPTIONMENU); main_menu->additem(MN_ACTION, _("Level Editor"),0,0, MNID_LEVELEDITOR); @@ -643,7 +641,6 @@ void st_general_free(void) delete options_keys_menu; delete options_joystick_menu; delete highscore_menu; - delete contrib_worldmap_menu; delete contrib_menu; delete contrib_subset_menu; delete worldmap_menu; diff --git a/src/title.cpp b/src/title.cpp index 71d6bcccd..5d195206b 100644 --- a/src/title.cpp +++ b/src/title.cpp @@ -102,10 +102,17 @@ void generate_contrib_menu() LevelSubset* subset = new LevelSubset(); subset->load(level_subsets.item[i]); contrib_menu->additem(MN_GOTO, subset->title.c_str(), i, - contrib_subset_menu, i+1); + contrib_subset_menu, i); contrib_subsets.push_back(subset); } + for(int i = 0; i < worldmap_list.num_items; i++) + { + WorldMapNS::WorldMap worldmap; + worldmap.loadmap(worldmap_list.item[i]); + contrib_menu->additem(MN_ACTION, worldmap.get_world_title(),0,0, i + level_subsets.num_items); + } + contrib_menu->additem(MN_HL,"",0,0); contrib_menu->additem(MN_BACK,_("Back"),0,0); @@ -117,43 +124,46 @@ void check_levels_contrib_menu() static int current_subset = -1; int index = contrib_menu->check(); - if (index != -1) + if (index == -1) + return; + + if (index < (int)contrib_subsets.size()) { - index -= 1; - if (index >= 0 && index <= int(contrib_subsets.size())) - { - if (current_subset != index) - { - current_subset = index; - // FIXME: This shouln't be busy looping - LevelSubset& subset = * (contrib_subsets[index]); + if (current_subset != index) + { + current_subset = index; + // FIXME: This shouln't be busy looping + LevelSubset& subset = * (contrib_subsets[index]); - current_contrib_subset = ⊂ + current_contrib_subset = ⊂ - contrib_subset_menu->clear(); + contrib_subset_menu->clear(); - contrib_subset_menu->additem(MN_LABEL, subset.title, 0,0); - contrib_subset_menu->additem(MN_HL,"",0,0); + 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) - { - Level* level = new Level; - level->load(subset.get_level_filename(i)); - contrib_subset_menu->additem(MN_ACTION, level->get_name(), 0, 0, i); - delete level; - } - - 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(); - } - } - else + for (int i = 0; i < subset.get_num_levels(); ++i) { - // Back button + Level* level = new Level; + level->load(subset.get_level_filename(i)); + contrib_subset_menu->additem(MN_ACTION, level->get_name(), 0, 0, i); + delete level; } + + 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(); + } + } + else if(index < worldmap_list.num_items + (int)contrib_subsets.size()) + { + WorldMapNS::WorldMap worldmap; + worldmap.loadmap(worldmap_list.item[index - contrib_subsets.size()]); + worldmap.display(); + + Menu::set_current(main_menu); } } @@ -177,19 +187,6 @@ void check_contrib_subset_menu() } } -void check_contrib_worldmap_menu() -{ - int index = contrib_worldmap_menu->check(); - if (index != -1) - { - WorldMapNS::WorldMap worldmap; - worldmap.loadmap(worldmap_list.item[index]); - worldmap.display(); - - Menu::set_current(main_menu); - } -} - void draw_demo(double frame_ratio) { Sector* world = titlesession->get_current_sector(); @@ -252,18 +249,7 @@ void title(void) img_choose_subset = new Surface(datadir + "/images/status/choose-level-subset.png", true); /* Generating contrib maps by only using a string_list */ - worldmap_list = dfiles("levels/worldmap", NULL, NULL); - - contrib_worldmap_menu->additem(MN_LABEL, _("Contrib Worlds"), 0,0); - contrib_worldmap_menu->additem(MN_HL, "", 0,0); - for(int i = 0; i < worldmap_list.num_items; i++) - { - WorldMapNS::WorldMap worldmap; - worldmap.loadmap(worldmap_list.item[i]); - contrib_worldmap_menu->additem(MN_ACTION, worldmap.get_world_title(),0,0,i); - } - contrib_worldmap_menu->additem(MN_HL,"",0,0); - contrib_worldmap_menu->additem(MN_BACK,"Back",0,0); + worldmap_list = dfiles("levels/worldmap", NULL, "icyisland.stwm"); titlesession->get_current_sector()->activate(); titlesession->set_current(); @@ -330,8 +316,6 @@ void title(void) // Start Game, ie. goto the slots menu update_load_save_game_menu(load_game_menu); break; - case MNID_WORLDMAP_CONTRIB: - break; case MNID_LEVELS_CONTRIB: // Contrib Menu puts("Entering contrib menu"); @@ -393,10 +377,6 @@ void title(void) { check_contrib_subset_menu(); } - else if(menu == contrib_worldmap_menu) - { - check_contrib_worldmap_menu(); - } } mouse_cursor->draw(context); @@ -414,6 +394,7 @@ void title(void) /* Free surfaces: */ free_contrib_menu(); + string_list_free(&worldmap_list); delete titlesession; delete bkg_title; delete logo; -- 2.11.0