#include "supertux/menu/contrib_world_menu.hpp"
+#include "audio/sound_manager.hpp"
+#include "gui/menu_item.hpp"
+#include "supertux/globals.hpp"
+#include "supertux/mainloop.hpp"
#include "supertux/title_screen.hpp"
#include "supertux/world.hpp"
#include "util/gettext.hpp"
-ContribWorldMenu::ContribWorldMenu(const World& current_world)
+ContribWorldMenu::ContribWorldMenu(const World& current_world) :
+ m_current_world(current_world)
{
- add_label(current_world.title);
+ add_label(m_current_world.title);
add_hl();
- for (unsigned int i = 0; i < current_world.get_num_levels(); ++i)
+ for (unsigned int i = 0; i < m_current_world.get_num_levels(); ++i)
{
/** get level's title */
- std::string filename = current_world.get_level_filename(i);
+ std::string filename = m_current_world.get_level_filename(i);
std::string title = TitleScreen::get_level_name(filename);
add_entry(i, title);
}
add_back(_("Back"));
}
+void
+ContribWorldMenu::check_menu()
+{
+ int index = check();
+ if (index != -1) {
+ if (get_item_by_id(index).kind == MN_ACTION)
+ {
+ sound_manager->stop_music();
+ GameSession* session = new GameSession(m_current_world.get_level_filename(index));
+ g_main_loop->push_screen(session);
+ }
+ }
+}
+
/* EOF */
class ContribWorldMenu : public Menu
{
private:
+ const World& m_current_world;
+
public:
ContribWorldMenu(const World& current_world);
+ void check_menu();
+
private:
ContribWorldMenu(const ContribWorldMenu&);
ContribWorldMenu& operator=(const ContribWorldMenu&);
}
}
-void
-TitleScreen::check_contrib_world_menu()
-{
- int index = contrib_world_menu->check();
- if (index != -1) {
- if (contrib_world_menu->get_item_by_id(index).kind == MN_ACTION) {
- sound_manager->stop_music();
- GameSession* session =
- new GameSession(current_world->get_level_filename(index));
- g_main_loop->push_screen(session);
- }
- }
-}
-
namespace {
bool generate_addons_menu_sorter(const Addon* a1, const Addon* a2)
{
} else if(menu == addons_menu.get()) {
check_addons_menu();
} else if (menu == contrib_world_menu.get()) {
- check_contrib_world_menu();
+ contrib_world_menu->check_menu();
}
}
#include "supertux/game_session.hpp"
class Menu;
+class ContribWorldMenu;
class World;
class CodeController;
void generate_main_menu();
void generate_contrib_menu();
void check_levels_contrib_menu();
- void check_contrib_world_menu();
void free_contrib_menu();
void generate_addons_menu();
void check_addons_menu();
private:
std::auto_ptr<Menu> main_menu;
std::auto_ptr<Menu> contrib_menu;
- std::auto_ptr<Menu> contrib_world_menu;
+ std::auto_ptr<ContribWorldMenu> contrib_world_menu;
std::auto_ptr<World> main_world;
std::vector<World*> contrib_worlds;
std::auto_ptr<Menu> addons_menu;