Пример #1
0
void ModularZoneFactory::loadZoneTemplates(void)
{
    mZoneTemplates.clear();
    if(OgitorsRoot::getSingletonPtr()->IsSceneLoaded())
    {
        //scene is loaded, we can get the project directories

        //parse all the .zone files from the project directory
        //if I had a custom zone resmanager I could get them this way
        //pList = Ogre::ResourceGroupManager::getSingleton().findResourceNames(PROJECT_RESOURCE_GROUP,"*.zone",false);
        //maybe TODO: create .zone resourcemanager

        //Because my.zone files are not a resource I have to manaully get them:
        OFS::OfsPtr& ofsFile = OgitorsRoot::getSingletonPtr()->GetProjectFile();

        OFS::FileList list;

        ofsFile->listFilesRecursive("/", list);

        //get rid of everthing except .zone files
        list.erase(std::remove_if(list.begin(),list.end(),not_a_zonefile),list.end());

        int key = 0;
        OFS::FileList::iterator zonefile;
        for(zonefile = list.begin();zonefile!=list.end();++zonefile)
        {
            //load the .zone XML file and get the zone info
            //.
            ZoneInfo zone = this->_loadZoneDescription((*zonefile).name);
            if(!zone.mName.empty())
            {
                //make sure dependencies are available
                bool resources = false;
                //mesh:
                resources = Ogre::ResourceGroupManager::getSingletonPtr()->resourceExistsInAnyGroup(zone.mMesh);
                if(resources)
                {
                    //add to map
                    mZoneTemplates.insert(ZoneInfoMap::value_type(key,zone));
                    ++key;
                }
            }
        }
    }
}