Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Mar 15, 2011, 9:47:11 PM (13 years ago)
Author:
landauf
Message:

merged usability branch back to trunk

incomplete summary of the changes in this branch:

  • enhanced keyboard navigation in GUIs
  • implemented new graphics menu and changeable window size at runtime
  • added developer mode
  • HUD shows if game is paused, game pauses if ingame menu is opened
  • removed a few obsolete commands and hid some that are more for internal use
  • numpad works in console and gui
  • faster loading of level info
  • enhanced usage of compositors (Shader class)
  • improved camera handling, configurable FOV and aspect ratio
Location:
code/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/trunk

  • code/trunk/src/orxonox/LevelManager.cc

    r7839 r8079  
    7575    LevelManager::~LevelManager()
    7676    {
     77        // Delete all the LevelInfoItem objects because the LevelManager created them
     78        std::set<LevelInfoItem*, LevelInfoCompare>::iterator it = availableLevels_.begin();
     79        for (; it != availableLevels_.end(); ++it)
     80            delete *it;
    7781    }
    7882
     
    237241    void LevelManager::compileAvailableLevelList()
    238242    {
     243        // Get all files matching the level criteria
    239244        Ogre::StringVectorPtr levels = Resource::findResourceNames("*.oxw");
    240         // Iterate over all *.oxw level files.
     245
     246        // We only want to load as little as possible
     247        ClassTreeMask mask;
     248        mask.exclude(Class(BaseObject));
     249        mask.include(Class(LevelInfo));
     250
     251        // Iterate over all the found *.oxw files
    241252        COUT(3) << "Loading LevelInfos..." << std::endl;
     253        std::set<std::string> names;
    242254        for (Ogre::StringVector::const_iterator it = levels->begin(); it != levels->end(); ++it)
    243255        {
    244             //TODO: Replace with tag?
     256            // TODO: Replace with tag?
    245257            if (it->find("old/") != 0)
    246258            {
    247                 size_t pos = it->find(".oxw");
     259                LevelInfoItem* info = NULL;
    248260
    249261                // Load the LevelInfo object from the level file.
    250                 bool infoExists = false;
    251262                XMLFile file = XMLFile(*it);
    252                 ClassTreeMask mask = ClassTreeMask();
    253                 mask.exclude(ClassIdentifier<BaseObject>::getIdentifier());
    254                 mask.include(ClassIdentifier<LevelInfo>::getIdentifier());
    255                 Loader::load(&file, mask, false);
    256                 // Iterate over all LevelInfos.
     263                Loader::load(&file, mask, false, true);
     264
     265                // Find the LevelInfo object we've just loaded (if there was one)
    257266                for(ObjectList<LevelInfo>::iterator item = ObjectList<LevelInfo>::begin(); item != ObjectList<LevelInfo>::end(); ++item)
     267                    if(item->getXMLFilename() == *it)
     268                        info = item->copy();
     269
     270                // We don't need the loaded stuff anymore
     271                Loader::unload(&file);
     272
     273                if(info == NULL)
    258274                {
    259                     LevelInfoItem* info = item->copy();
    260                     if(info->getXMLFilename() == *it) // If the LevelInfo for this level exists we insert it into the list of available levels.
    261                     {
    262                         this->availableLevels_.insert(info);
    263                         infoExists = true;
    264                     }
     275                    // Create a default LevelInfoItem object that merely contains the name
     276                    std::string filenameWOExtension = it->substr(0, it->find(".oxw"));
     277                    info = new LevelInfoItem(filenameWOExtension, *it);
    265278                }
    266                 Loader::unload(&file, mask);
    267                 if(!infoExists) // If the LevelInfo for this level doesn't exist, we create a new one and insert it into the list of available levels.
    268                     this->availableLevels_.insert(new LevelInfoItem(it->substr(0, pos), *it));
     279
     280                // Warn about levels with the same name.
     281                if(!names.insert(info->getName()).second)
     282                    COUT(2) << "Warning: Multiple levels (" << info->getXMLFilename() << ") with name '" << info->getName() << "' found!" << std::endl;
     283
     284                // Warn about multiple items so that it gets fixed quickly
     285                if(availableLevels_.find(info) != availableLevels_.end())
     286                {
     287                    COUT(2) << "Warning: Multiple levels (" << info->getXMLFilename() << ") with same name '" << info->getName() << "' and filename found! Exluding..." << std::endl;
     288                    // Delete LevelInfoItem to avoid a dangling pointer
     289                    delete info;
     290                }
     291                else
     292                    this->availableLevels_.insert(info);
    269293            }
    270294        }
Note: See TracChangeset for help on using the changeset viewer.