Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jul 30, 2009, 2:10:44 PM (15 years ago)
Author:
rgrieder
Message:

Merged resource branch back to the trunk. Changes:

  • Automated graphics loading by evaluating whether a GameState requires it
  • Using native Tcl library (x3n)

Windows users: Update your dependency package!

Location:
code/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/trunk

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

    r3280 r3370  
    3030
    3131#include <map>
     32#include <boost/filesystem.hpp>
    3233
    3334#include "core/CommandLine.h"
    3435#include "core/ConfigValueIncludes.h"
     36#include "core/Core.h"
    3537#include "core/CoreIncludes.h"
     38#include "core/Loader.h"
    3639#include "PlayerManager.h"
    3740#include "objects/Level.h"
     
    4245    SetCommandLineArgument(level, "").shortcut("l").information("Default level file (overrides LevelManager::defaultLevelName_ configValue)");
    4346
    44     LevelManager* LevelManager::singletonRef_s = 0;
     47    LevelManager* LevelManager::singletonPtr_s = 0;
    4548
    4649    LevelManager::LevelManager()
    4750    {
    48         assert(singletonRef_s == 0);
    49         singletonRef_s = this;
    50 
    5151        RegisterRootObject(LevelManager);
    5252        this->setConfigValues();
     
    6161    LevelManager::~LevelManager()
    6262    {
    63         assert(singletonRef_s != 0);
    64         singletonRef_s = 0;
    6563    }
    6664
     
    120118    }
    121119
    122     const std::string& LevelManager::getDefaultLevel()
     120    const std::string& LevelManager::getDefaultLevel() const
    123121    {
    124122        return defaultLevelName_;
    125123    }
     124
     125    std::string LevelManager::getAvailableLevelListItem(unsigned int index) const
     126    {
     127        if (index >= availableLevels_.size())
     128            return std::string();
     129        else
     130            return availableLevels_[index];
     131    }
     132
     133    void LevelManager::compileAvailableLevelList()
     134    {
     135        availableLevels_.clear();
     136
     137        boost::filesystem::directory_iterator file(Core::getMediaPathString() + "levels");
     138        boost::filesystem::directory_iterator end;
     139
     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        }
     150    }
    126151}
Note: See TracChangeset for help on using the changeset viewer.