Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 9798 in orxonox.OLD for branches


Ignore:
Timestamp:
Sep 24, 2006, 11:55:20 AM (18 years ago)
Author:
bensch
Message:

modular KeepLevel implementation

Location:
branches/new_class_id/src
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • branches/new_class_id/src/lib/util/loading/new_resource_manager.cc

    r9797 r9798  
    4949  //this->unloadAllByPriority(RP_GAME);
    5050
    51 //   if (!this->resourceList.empty())
    52 //     PRINTF(1)("Not removed all Resources, since there are still %d resources registered\n", this->resourceList.size());
     51  //   if (!this->resourceList.empty())
     52  //     PRINTF(1)("Not removed all Resources, since there are still %d resources registered\n", this->resourceList.size());
    5353
    5454  NewResourceManager::_singletonRef = NULL;
     
    110110
    111111
     112
     113unsigned int NewResourceManager::addKeepLevelName(const std::string& keepLevelName)
     114{
     115  this->_keepLevelNames.push_back(keepLevelName);
     116  return _keepLevelNames.size()-1;
     117}
     118
     119unsigned int NewResourceManager::getKeepLevelID(const std::string& keepLevelName) const
     120{
     121  for (unsigned int i = 0; i < this->_keepLevelNames.size(); ++i)
     122    if (this->_keepLevelNames[i] == keepLevelName)
     123      return i;
     124
     125  PRINTF(2)("KeepLevel '%s' not found. Using 0 instead\n", keepLevelName.c_str());
     126  return 0;
     127}
     128
     129const std::string& NewResourceManager::getKeepLevelID(unsigned int keepLevelID) const
     130{
     131  assert(keepLevelID < this->_keepLevelNames.size());
     132  return this->_keepLevelNames[keepLevelID];
     133}
     134
     135
    112136/**
    113137 * @brief outputs debug information about the NewResourceManager
     
    118142  PRINT(0)("= RESOURCE-MANAGER DEBUG INFORMATION =\n");
    119143  PRINT(0)("======================================\n");
    120   PRINT(0)("Listing %d Types: \n", this->_resourceTypes.size());
     144  PRINT(0)(" MainGlobal search path is %s\n", this->_mainGlobalPath.name().c_str());
     145  if(!this->_globalPaths.empty())
     146  {
     147    PRINT(0)(" Additional Global search Paths are: ");
     148    for (unsigned int i = 0; i < this->_globalPaths.size(); ++i)
     149      PRINT(0)("'%s' ", this->_globalPaths[i].name().c_str());
     150    PRINT(0)("\n");
     151  }
     152  PRINT(0)(" Listing %d Types: \n", this->_resourceTypes.size());
    121153  std::vector<Resources::Type*>::const_iterator it;
    122154  for (it = this->_resourceTypes.begin(); it != this->_resourceTypes.end(); ++it)
     
    127159  }
    128160
     161  PRINT(0)("KeepLevels are: ");
     162  for (unsigned int i = 0; i < this->_keepLevelNames.size(); ++i)
     163    PRINT(0)("%d:'%s'  ", i, this->_keepLevelNames[i].c_str());
     164  PRINT(0)("\n");
    129165  PRINT(0)("==================================RM==\n");
    130166}
  • branches/new_class_id/src/lib/util/loading/new_resource_manager.h

    r9797 r9798  
    2626  void registerType(Resources::Type* type);
    2727
    28   void addKeepLevel(unsigned int i, const std::string& keepLevel);
     28  unsigned int addKeepLevelName(const std::string& keepLevelName);
     29  unsigned int getKeepLevelID(const std::string& keepLevelName) const;
     30  const std::string& getKeepLevelID(unsigned int keepLevelID) const;
    2931
    3032  const std::vector<Resources::Type*> resourceTypes() const { return _resourceTypes; };
     
    5557  std::vector<Directory>             _globalPaths;
    5658
    57   std::vector<Resources::KeepLevel>  _keepLevels;
     59  std::vector<std::string>           _keepLevelNames;
    5860};
    5961
  • branches/new_class_id/src/lib/util/loading/resource.cc

    r9795 r9798  
    109109//// KEEPLEVEL ////
    110110///////////////////
    111 std::vector<std::string> Resources::KeepLevel::_keepLevelNames;
    112 void Resources::KeepLevel::defineKeepLevelName(unsigned int level, const std::string& name)
     111Resources::KeepLevel::KeepLevel(const std::string& keepLevelName)
    113112{
    114   if (_keepLevelNames.size() <= level)
    115     _keepLevelNames.resize(level+1);
    116   _keepLevelNames[level] = name;
     113  this->_keepLevel = NewResourceManager::getInstance()->getKeepLevelID(keepLevelName);
    117114}
     115
    118116
    119117
  • branches/new_class_id/src/lib/util/loading/resource.h

    r9793 r9798  
    2222    KeepLevel(const std::string& keepLevelName);
    2323
    24     static void defineKeepLevelName(unsigned int level, const std::string& name);
     24    unsigned int keepLevel() const { return _keepLevel; };
    2525  private:
    2626    unsigned int                        _keepLevel;
    27   private:
    28     static std::vector<std::string>     _keepLevelNames;
    2927  };
    3028
  • branches/new_class_id/src/orxonox.cc

    r9797 r9798  
    370370  NewResourceManager::getInstance()->addResourceSubPath("Texture", "pictures");
    371371
     372  NewResourceManager::getInstance()->addKeepLevelName("Imediately");
     373  NewResourceManager::getInstance()->addKeepLevelName("LevelEnd");
     374  NewResourceManager::getInstance()->addKeepLevelName("CampaignEnd");
     375  NewResourceManager::getInstance()->addKeepLevelName("GameEnd");
     376
     377
    372378  NewResourceManager::getInstance()->debug();
    373379  //  DynamicLoader::loadDyLib("libtest.so");
Note: See TracChangeset for help on using the changeset viewer.