Advertisement
Guest User

Noggit Menu

a guest
Apr 20th, 2013
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.95 KB | None | 0 0
  1. void Menu::buildMenuBar()
  2. {
  3.   if( mGUImenuBar )
  4.   {
  5.     mGUIFrame->removeChild( mGUImenuBar );
  6.     delete mGUImenuBar;
  7.     mGUImenuBar = NULL;
  8.   }
  9.  
  10.   mGUImenuBar = new UIMenuBar();
  11.   mGUImenuBar->AddMenu( "File" );
  12.   mGUImenuBar->GetMenu( "File" )->AddMenuItemSwitch( "exit ESC", &gPop, true );
  13.   mGUIFrame->addChild( mGUImenuBar );
  14.  
  15.   static const char* typeToName[3] = { "Continent", "Dungeons", "Raid" };
  16.  
  17.   mGUImenuBar->AddMenu( typeToName[0] );
  18.   mGUImenuBar->AddMenu( typeToName[1] );
  19.   mGUImenuBar->AddMenu( typeToName[2] );
  20.  
  21.   for( std::vector<MapEntry>::const_iterator it = mMaps.begin(); it != mMaps.end(); ++it )
  22.   {
  23.     mGUImenuBar->GetMenu( typeToName[it->areaType] )->AddMenuItemButton( it->name, &showMap, it->mapID );
  24.   }
  25.  
  26.   static const size_t nBookmarksPerMenu = 20;
  27.   const size_t nBookmarkMenus = ( mBookmarks.size() / nBookmarksPerMenu ) + 1;
  28.  
  29.   if( mBookmarks.size() )
  30.   {
  31.     mGUImenuBar->AddMenu( "Bookmarks" );
  32.   }
  33.  
  34.   for( size_t i = 1; i < nBookmarkMenus; ++i )
  35.   {
  36.     std::stringstream name;
  37.     name << "Bookmarks (" << ( i + 1 ) << ")";
  38.     mGUImenuBar->AddMenu( name.str() );
  39.   }
  40.  
  41.   int n = -1;
  42.   for( std::vector<BookmarkEntry>::const_iterator it = mBookmarks.begin(); it != mBookmarks.end(); ++it )
  43.   {
  44.     std::stringstream name;
  45.     const int page = ( ++n / nBookmarksPerMenu );
  46.     if( page )
  47.     {
  48.       name << "Bookmarks (" << ( page + 1 ) << ")";
  49.     }
  50.     else
  51.     {
  52.       name << "Bookmarks";
  53.     }
  54.  
  55.     mGUImenuBar->GetMenu( name.str() )->AddMenuItemButton( it->name, &showBookmark, n );
  56.   }
  57. }
  58.  
  59. void Menu::createMapList()
  60. {
  61.   for( DBCFile::Iterator i = gMapDB.begin(); i != gMapDB.end(); ++i )
  62.   {
  63.     MapEntry e;
  64.     e.mapID = i->getInt( MapDB::MapID );
  65.     e.name = i->getLocalizedString( MapDB::Name );
  66.     e.areaType = i->getUInt( MapDB::AreaType );
  67.     if( e.areaType < 0 || e.areaType > 2 || !World::IsEditableWorld( e.mapID ) )
  68.       continue;
  69.  
  70.     mMaps.push_back( e );
  71.   }
  72. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement