Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 5659


Ignore:
Timestamp:
Aug 18, 2009, 11:41:56 AM (15 years ago)
Author:
rgrieder
Message:

Convinced LevelManager to use the Resources rather than the file system to look for levels.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/resource2/src/orxonox/LevelManager.cc

    r5645 r5659  
    3030
    3131#include <map>
    32 #include <boost/filesystem.hpp>
     32#include <OgreResourceGroupManager.h>
    3333
    3434#include "core/CommandLine.h"
     
    135135        availableLevels_.clear();
    136136
    137         boost::filesystem::directory_iterator file(Core::getDataPathString() + "levels");
    138         boost::filesystem::directory_iterator end;
     137        availableLevels_ = *Ogre::ResourceGroupManager::getSingleton().findResourceNames(
     138            Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, "*.oxw");
    139139
    140         while (file != end)
    141         {
    142             if (!boost::filesystem::is_directory(*file) && file->string()[file->string().length()-1] != '~')
    143             {
    144                 std::string filename = file->path().leaf();
    145                 if (filename.length() > 4)
    146                     availableLevels_.push_back(filename.substr(0,filename.length()-4));
    147             }
    148             ++file;
    149         }
     140        for (std::vector<std::string>::iterator it = availableLevels_.begin(); it != availableLevels_.end();)
     141            if (it->find("old/") == 0)
     142                it = availableLevels_.erase(it);
     143            else
     144                ++it;
    150145    }
    151146}
Note: See TracChangeset for help on using the changeset viewer.