示例#1
0
void MainWindow::updateLevels()
{
    try
    {
        ClientPluginManager& pluginManager = EditorGlobals::mGrid->getActiveServer().getPluginManager();
        LevelManager& levelManager = pluginManager.getPlugin<LevelManager>();
        ResourceManager& resourceManager = pluginManager.getPlugin<ResourceManager>();
        Ogre::StringVectorPtr levels = levelManager.list();

        int numListLevels = qMin( levels->size(), (std::size_t)cMaxLevels );

        for( int i = 0; i < numListLevels; ++i ) 
        {
            Path filePath = resourceManager.getResourcePath() / levels->at( i );
            QString file = QString( filePath.string().c_str() );
            QString text = tr( "&%1 %2" ).arg( i + 1 ).arg( strippedName( file ) );
            mLevelActions[i]->setText( text );
            mLevelActions[i]->setData( file );
            mLevelActions[i]->setVisible( true );
        }

        for( int i = numListLevels; i < cMaxLevels; ++i )
            mLevelActions[i]->setVisible( false );
    }
    catch( Exception e )
    {
        // Ignore error	
    }
}
示例#2
0
bool CMainFrame::_CreateMeshPanel( CImageList& imageList, Ogre::StringVectorPtr& meshNames )
{
	if (!m_resourceSelector.Create(WS_CHILD|WS_VISIBLE, CRect(200,100,400,300), this, IDS_ResourceSelector))
		return false;

	m_resourceSelector.SetOwner(this);
	m_resourceSelector.SetIconSize(CSize(MESH_ICON_SIZE, MESH_ICON_SIZE));
	CXTPTaskPanelGroup* pGroup = m_resourceSelector.AddGroup(IDS_ResourceSelector_Mesh);

	int itemCount = imageList.GetImageCount();
 	m_resourceSelector.GetImageManager()->SetImageList(imageList.Detach(), 0);
	
	for (int i=0; i<itemCount; ++i)
	{
		std::wstring meshname(Utility::EngineToUnicode(meshNames->at(i)));
		meshname.erase(meshname.length()-5);
		// Add folder entries
		CXTPTaskPanelGroupItem* pItem = pGroup->AddLinkItem(i, 0);
		pItem->SetIconIndex(i);
		pItem->SetCaption(meshname.c_str());
	}
					
	m_resourceSelector.SetBehaviour(xtpTaskPanelBehaviourList);
	m_resourceSelector.SetSelectItemOnFocus(TRUE);
	m_resourceSelector.SetMultiColumn(TRUE);
	m_resourceSelector.SetColumnWidth(RES_SELECTOR_COLUMN_WIDTH);
	m_resourceSelector.GetAt(0)->SetExpanded(TRUE);
	//拖拽支持
	m_resourceSelector.AllowDrag(xtpTaskItemAllowDragCopyOutsideControl);

	return true;
}
示例#3
0
 void ResourceManager::DestroyAssetGroup(const String& GroupName)
 {
     for( std::vector<String>::iterator it = ResourceGroups.begin() ; it != ResourceGroups.end() ; it++ )
     {
         if(GroupName == (*it))
         {
             ResourceGroups.erase(it);
             break;
         }
     }
     /// @todo This is a bit of a hack, but needs to be here until we can upgrade our resource system.
     Ogre::StringVectorPtr ResourceNames = this->OgreResource->listResourceNames(GroupName,false);
     for( Whole X = 0 ; X < ResourceNames->size() ; ++X )
     {
         if(ResourceNames->at(X).find(".mesh"))
         {
             MeshManager::GetSingletonPtr()->UnloadMesh(ResourceNames->at(X));
         }
     }
     this->OgreResource->destroyResourceGroup(GroupName);
 }
void aiBehaviorTreeTemplateManager::LoadAll()
{
	Ogre::StringVectorPtr loc = Ogre::ResourceGroupManager::getSingleton().findResourceLocation("BehaviorTemplate", "*Behaviors");
	const STRING filename = loc->at(0) + "\\Script\\";

	//加载全局黑板xml
	Ogre::DataStreamPtr stream = Ogre::ResourceGroupManager::getSingleton().openResource("RaceGlobal.xml", "BehaviorTemplate");
	char* szData = strdup(stream->getAsString().c_str());

	rapidxml::xml_document<> XMLDoc;
	XMLDoc.parse<0>(szData);
	rapidxml::xml_node<>* pNode = XMLDoc.first_node("Root")->first_node("BlackBoard");

	while(pNode)
	{
		const STRING raceName = pNode->first_attribute("race")->value();
		rapidxml::xml_node<>* pVarNode = pNode->first_node("Variable");

		eGameRace race;
		if(raceName == "Terran") race = eGameRace_Terran;
		else if(raceName == "Zerg") race = eGameRace_Zerg;
		else assert(0);

		aiBlackBoard* bb = new aiBlackBoard;
		bb->LoadParams(pVarNode);
		m_globalBBs.insert(std::make_pair(race, bb));

		//脚本
		const char* szFilename = XMLDoc.first_node("Root")->first_node("Script")->first_attribute("filename")->value();
		const STRING filepath = filename + szFilename;
		SCRIPTNAMAGER.DoFile(filepath);

		pNode = pNode->next_sibling("BlackBoard");
	}

	free(szData);
	XMLDoc.clear();

	//加载各单位行为树xml
	Ogre::StringVectorPtr files = Ogre::ResourceGroupManager::getSingleton().findResourceNames("BehaviorTemplate", "*.xml");
	auto iter = std::find(files->begin(), files->end(), "RaceGlobal.xml");
	files->erase(iter);
	for (auto iter=files->begin(); iter!=files->end(); ++iter)
	{
		aiBehaviorTreeTemplate* pTmpl = new aiBehaviorTreeTemplate;
		const STRING name = pTmpl->Load(*iter);
		m_bts.insert(std::make_pair(name, pTmpl));
	}
}