ContribMenu Class Reference

#include <contrib_menu.hpp>

Inherits Menu.

List of all members.

Public Member Functions

 ContribMenu ()
 ~ContribMenu ()
void check_menu ()

Private Member Functions

 ContribMenu (const ContribMenu &)
ContribMenuoperator= (const ContribMenu &)

Private Attributes

std::auto_ptr< ContribWorldMenum_contrib_world_menu
std::vector< World * > m_contrib_worlds


Detailed Description

Definition at line 25 of file contrib_menu.hpp.


Constructor & Destructor Documentation

ContribMenu::ContribMenu (  ) 

Definition at line 27 of file contrib_menu.cpp.

References _(), Menu::add_back(), Menu::add_entry(), Menu::add_hl(), Menu::add_label(), log_info, and m_contrib_worlds.

00027                          :
00028   m_contrib_world_menu(),
00029   m_contrib_worlds()
00030 {
00032   std::vector<std::string> level_worlds;
00033   char** files = PHYSFS_enumerateFiles("levels/");
00034   for(const char* const* filename = files; *filename != 0; ++filename) {
00035     std::string filepath = std::string("levels/") + *filename;
00036     if(PHYSFS_isDirectory(filepath.c_str()))
00037       level_worlds.push_back(filepath);
00038   }
00039   PHYSFS_freeList(files);
00040 
00041   add_label(_("Contrib Levels"));
00042   add_hl();
00043 
00044   int i = 0;
00045   for (std::vector<std::string>::const_iterator it = level_worlds.begin(); it != level_worlds.end(); ++it)
00046   {
00047     try
00048     {
00049       std::auto_ptr<World> world (new World());
00050       world->load(*it + "/info");
00051       if (!world->hide_from_contribs) 
00052       {
00053         add_entry(i++, world->get_title());
00054         m_contrib_worlds.push_back(world.release());
00055       }
00056     }
00057     catch(std::exception& e)
00058     {
00059       log_info << "Couldn't parse levelset info for '" << *it << "': " << e.what() << std::endl;
00060     }
00061   }
00062 
00063   add_hl();
00064   add_back(_("Back"));
00065 }

ContribMenu::~ContribMenu (  ) 

Definition at line 67 of file contrib_menu.cpp.

References m_contrib_worlds.

00068 {
00069   for(std::vector<World*>::iterator i = m_contrib_worlds.begin(); i != m_contrib_worlds.end(); ++i)
00070   {
00071     delete *i;
00072   }
00073   m_contrib_worlds.clear();
00074 }

ContribMenu::ContribMenu ( const ContribMenu  )  [private]


Member Function Documentation

void ContribMenu::check_menu (  )  [virtual]

Implements Menu.

Definition at line 77 of file contrib_menu.cpp.

References Menu::check(), World::is_levelset, m_contrib_world_menu, m_contrib_worlds, MenuManager::push_current(), and TitleScreen::start_game().

00078 {
00079   int index = check();
00080   if (index != -1)
00081   {
00082     World* world = m_contrib_worlds[index];
00083     
00084     if (!world->is_levelset) 
00085     {
00086       TitleScreen::start_game(world);
00087     }
00088     else 
00089     {
00090       m_contrib_world_menu.reset(new ContribWorldMenu(*world));
00091       MenuManager::push_current(m_contrib_world_menu.get());
00092     }
00093   }
00094 }

ContribMenu& ContribMenu::operator= ( const ContribMenu  )  [private]


Member Data Documentation

std::auto_ptr<ContribWorldMenu> ContribMenu::m_contrib_world_menu [private]

Definition at line 28 of file contrib_menu.hpp.

Referenced by check_menu().

std::vector<World*> ContribMenu::m_contrib_worlds [private]

Definition at line 29 of file contrib_menu.hpp.

Referenced by check_menu(), ContribMenu(), and ~ContribMenu().


The documentation for this class was generated from the following files:
Generated on Mon Jun 9 03:38:29 2014 for SuperTux by  doxygen 1.5.1