Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Nov 13, 2010, 11:55:23 PM (14 years ago)
Author:
dafrick
Message:

Merged releasetodo, containing a new way to describe and tag levels, back to trunk.

Location:
code/trunk
Files:
6 edited
2 copied

Legend:

Unmodified
Added
Removed
  • code/trunk

  • code/trunk/src/orxonox/CMakeLists.txt

    r7504 r7648  
    2525SET_SOURCE_FILES(ORXONOX_SRC_FILES
    2626  Level.cc
     27  LevelInfo.cc
    2728  LevelManager.cc
    2829  Main.cc
     
    5859  TOLUA_FILES
    5960    ChatInputHandler.h
     61    LevelInfo.h
    6062    LevelManager.h
    6163    MoodManager.h
  • code/trunk/src/orxonox/Level.cc

    r7163 r7648  
    7676        XMLPortObject(Level, MeshLodInformation, "lodinformation", addLodInfo, getLodInfo, xmlelement, mode);
    7777        XMLPortObjectExtended(Level, BaseObject, "", addObject, getObject, xmlelement, mode, true, false);
    78 }
     78    }
    7979
    8080    void Level::registerVariables()
  • code/trunk/src/orxonox/LevelManager.cc

    r7284 r7648  
    3232
    3333#include "util/ScopedSingletonManager.h"
     34#include "core/ClassTreeMask.h"
    3435#include "core/CommandLineParser.h"
    3536#include "core/ConfigValueIncludes.h"
     
    3738#include "core/Loader.h"
    3839#include "core/Resource.h"
     40#include "core/XMLFile.h"
    3941#include "PlayerManager.h"
    4042#include "Level.h"
     43#include "LevelInfo.h"
    4144
    4245namespace orxonox
     
    5659            ModifyConfigValue(defaultLevelName_, tset, CommandLineParser::getValue("level").getString());
    5760        }
     61
     62        this->compileAvailableLevelList();
    5863    }
    5964
     
    125130    }
    126131
    127     const std::string& LevelManager::getAvailableLevelListItem(unsigned int index) const
     132    unsigned int LevelManager::getNumberOfLevels()
    128133    {
    129         if (index >= availableLevels_.size())
    130             return BLANKSTRING;
     134        this->updateAvailableLevelList();
     135
     136        return this->availableLevels_.size();
     137    }
     138
     139    LevelInfoItem* LevelManager::getAvailableLevelListItem(unsigned int index) const
     140    {
     141        if (index >= this->availableLevels_.size())
     142            return NULL;
    131143        else
    132             return availableLevels_[index];
     144        {
     145            std::map<std::string, LevelInfoItem*>::const_iterator it = this->infos_.find(this->availableLevels_[index]);
     146            return it->second;
     147        }
    133148    }
    134149
    135150    void LevelManager::compileAvailableLevelList()
    136151    {
    137         this->availableLevels_.clear();
    138152        Ogre::StringVectorPtr levels = Resource::findResourceNames("*.oxw");
     153        // Iterate over all *.oxw level files.
    139154        for (Ogre::StringVector::const_iterator it = levels->begin(); it != levels->end(); ++it)
    140155        {
     156            //TODO: Replace with tag,
    141157            if (it->find("old/") != 0)
    142158            {
    143159                size_t pos = it->find(".oxw");
     160
     161                bool infoExists = false;
     162                // Load the LevelInfo object from the level file.
     163                XMLFile file = XMLFile(*it);
     164                ClassTreeMask mask = ClassTreeMask();
     165                mask.exclude(ClassIdentifier<BaseObject>::getIdentifier());
     166                mask.include(ClassIdentifier<LevelInfo>::getIdentifier());
     167                Loader::load(&file, mask, false);
     168                for(ObjectList<LevelInfo>::iterator item = ObjectList<LevelInfo>::begin(); item != ObjectList<LevelInfo>::end(); ++item)
     169                {
     170                    LevelInfoItem* info = item->copy();
     171                    if(info->getXMLFilename() == *it)
     172                    {
     173                        this->infos_.insert(std::pair<std::string, LevelInfoItem*>(it->substr(0, pos),info));
     174                        infoExists = true;
     175                    }
     176                }
     177                Loader::unload(&file, mask);
     178                if(!infoExists)
     179                {
     180                    this->infos_.insert(std::pair<std::string, LevelInfoItem*>(it->substr(0, pos), new LevelInfoItem(it->substr(0, pos), *it)));
     181                }
     182
    144183                this->availableLevels_.push_back(it->substr(0, pos));
    145184            }
    146185        }
    147186    }
     187
     188    void LevelManager::updateAvailableLevelList(void)
     189    {
     190        //TODO: Implement some kind of update?
     191    }
    148192}
  • code/trunk/src/orxonox/LevelManager.h

    r6746 r7648  
    3434#include <cassert>
    3535#include <list>
     36#include <map>
    3637#include <string>
    3738
     
    5960            void setDefaultLevel(const std::string& levelName); //tolua_export
    6061            const std::string& getDefaultLevel() const; //tolua_export
    61             void compileAvailableLevelList(); //tolua_export
    62             const std::string& getAvailableLevelListItem(unsigned int index) const; //tolua_export
     62            unsigned int getNumberOfLevels(void); //tolua_export
     63            LevelInfoItem* getAvailableLevelListItem(unsigned int index) const; //tolua_export
    6364
    6465            static LevelManager& getInstance()    { return Singleton<LevelManager>::getInstance(); } // tolua_export
     
    6970            void activateNextLevel();
    7071
     72            void compileAvailableLevelList(void);
     73            void updateAvailableLevelList(void);
     74
    7175            std::list<Level*> levels_s;
    7276            std::vector<std::string> availableLevels_;
     77            std::map<std::string, LevelInfoItem*> infos_;
    7378
    7479            // config values
  • code/trunk/src/orxonox/OrxonoxPrereqs.h

    r7163 r7648  
    6767    class CameraManager;
    6868    class Level;
     69    class LevelInfo;
     70    class LevelInfoItem;
    6971    class LevelManager;
    7072    class PawnManager;
Note: See TracChangeset for help on using the changeset viewer.