Ejemplo n.º 1
0
bool CMainFrame::UpdateTemplateMap()
{
	using namespace engine;

	m_templateMap.clear();

	engine::CoreApiPtr pCore = Project::Instance()->GetCoreApi();
	if(pCore == nullptr)
	{
		return false;
	}

	GameObjectManagerPtr pManager = pCore->GetGameObjectManager();

	for(size_t i = 0; i < pManager->GetPackageCount(); ++i)
	{
		ExtPackage* pPack = pManager->GetPackageByIndex(i);
		for(size_t ii = 0; ii < pPack->GetTemplateCount(); ++ii)
		{
			GameObjectTemplate* pTpl = pPack->GetTemplateByIndex(ii);

			m_templateMap[pTpl->GetCataLog()].push_back(pTpl);
		}
	}
	return true;
}
Ejemplo n.º 2
0
void MenuManager::Install_Menu_GameObject(QMenu* pMenu)
{
	using namespace ld3d;

	connect(pMenu->addAction("Empty"), SIGNAL(triggered()), this, SLOT(on_menu_gameobject_action()));

	pMenu->addSeparator();
	

	std::unordered_map<std::string, std::vector<ld3d::GameObjectTemplate*> >			tplMap;

	GameObjectManagerPtr pManager = m_pEditor->GetGameEngine()->GetCoreApi()->GetGameObjectManager();

	for(size_t i = 0; i < pManager->GetPackageCount(); ++i)
	{
		Package* pPack = pManager->GetPackageByIndex(i);
		for(size_t ii = 0; ii < pPack->GetTemplateCount(); ++ii)
		{
			GameObjectTemplate* pTpl = pPack->GetTemplateByIndex(ii);

			tplMap[pTpl->GetCataLog()].push_back(pTpl);
		}
	}

	for(auto v : tplMap)
	{
		if(v.second.size() == 0)
		{
			continue;
		}
		
		QString subName = QString::fromStdString(v.first);
		QMenu* pSub = pMenu->addMenu(subName);

		
		for(size_t i = 0; i < v.second.size(); ++i)
		{
			QString name = QString::fromStdString(v.second[i]->GetName());

			QAction* pAction = pSub->addAction(name);
			pAction->setData(qVariantFromValue((void*)v.second[i]));

			connect(pAction, SIGNAL(triggered()), this, SLOT(on_menu_gameobject_action()));
		}
	}
}