Ejemplo n.º 1
0
	void BaseManager::setupResources()
	{
		MyGUI::xml::Document doc;

		if (!doc.open(std::string("resources.xml")))
			doc.getLastError();

		MyGUI::xml::ElementPtr root = doc.getRoot();
		if (root == nullptr || root->getName() != "Paths")
			return;

		MyGUI::xml::ElementEnumerator node = root->getElementEnumerator();
		while (node.next())
		{
			if (node->getName() == "Path")
			{
				if (node->findAttribute("root") != "")
				{
					bool root = MyGUI::utility::parseBool(node->findAttribute("root"));
					if (root)
						mRootMedia = node->getContent();
				}
				addResourceLocation(node->getContent(), false);
			}
		}

		addResourceLocation(getRootMedia() + "/Common/Base");
	}
Ejemplo n.º 2
0
void HotkeyManager::_load( MyGUI::xml::ElementPtr root,const string xml )
{
	if( root == nullptr || root->getName() != "HKS" )
	{
		WARNING_LOG("bad Hotkey config file "<<xml);
		return;
	}
	MyGUI::xml::ElementEnumerator node = root->getElementEnumerator();
	while( node.next() )
	{
		if( node->getName() == "hotkey" )
		{
			hotkey hk;
			if( !node->findAttribute("name",hk.mName) )
			{
				WARNING_LOG("Hotkey config file "<<xml<<" invalid hotkey node");
				continue;
			}
			node->findAttribute("caption",hk.mCaption);
			node->findAttribute("tip",hk.mTip);
			node->findAttribute("key",hk.mHotkey);
			hk.mSHotkey = getStandardHotkeyName(hk.mHotkey);
			mHotkeys.push_back( hk );
			//设置对应Widget的User string,便于其显示出正常的热键
			setWidgetHotkey( hk.mName,hk.mHotkey );
		}
	}
}
Ejemplo n.º 3
0
void Framework::loadRigid( MyGUI::xml::ElementPtr node,JointPtr parent )
{
    ObjectFactory& factory = ObjectFactory::getSingleton();
    RigidPtr rgp = boost::dynamic_pointer_cast<Rigid>(factory.createObject("Rigid"));
    if(rgp)
    {
        rgp->load(node);
        if( parent )
        {
            parent->mRigid[1] = rgp;
            parent->linkRigid(parent->mRigid[0], parent->mRigid[1]);
        }
        MyGUI::xml::ElementEnumerator ce = node->getElementEnumerator();
        while(ce.next())
        {
            MyGUI::xml::ElementPtr child = ce.current();
            if( child->getName() == "joint" )
            {
                loadJoint( child,rgp );
            }
        }
    }
    else
    {
        WARNING_LOG("Factory can't make Rigid object!");
    }
}
Ejemplo n.º 4
0
void Framework::loadJoint( MyGUI::xml::ElementPtr node,RigidPtr parent )
{
    ObjectFactory& factory = ObjectFactory::getSingleton();
    string typeName = node->findAttribute("type");
    JointPtr jpt = boost::dynamic_pointer_cast<Joint>(factory.createObject(typeName));
    if(jpt)
    {
        if( parent )
        {
            jpt->mRigid[0] = parent;
        }
        addJoint(jpt);
        jpt->load(node);
        MyGUI::xml::ElementEnumerator ce = node->getElementEnumerator();
        while(ce.next())
        {
            MyGUI::xml::ElementPtr child = ce.current();
            if( child->getName() == "rigid" )
            {
                loadRigid(child, jpt);
            }
            break;
        }
    }
    else
    {
        WARNING_LOG("Factory can't make "<<typeName);
    }
}
Ejemplo n.º 5
0
bool EditorState::isMetaSolution(const MyGUI::UString& _fileName)
{
	MyGUI::xml::Document doc;
	if (!doc.open(_fileName))
	{
		return false;
	}

	MyGUI::xml::ElementPtr root = doc.getRoot();
	if (!root || (root->getName() != "MyGUI"))
	{
		return false;
	}

	std::string type;
	if (root->findAttribute("type", type))
	{
		if (type == "MetaSolution")
		{
			return true;
		}
	}

	return false;
}
Ejemplo n.º 6
0
		//--------------------------------------------------------------------------------
		void System::Setup()
		{

			MyGUI::xml::Document doc;

			if (!doc.open(std::string("resources.xml")))
				doc.getLastError();

			MyGUI::xml::ElementPtr root = doc.getRoot();
			if (root == nullptr || root->getName() != "Paths")
				return;

			MyGUI::xml::ElementEnumerator node = root->getElementEnumerator();
			while (node.next())
			{
				if (node->getName() == "Path")
				{
					bool root = false;
					if (node->findAttribute("root") != "")
					{
						root = MyGUI::utility::parseBool(node->findAttribute("root"));
						if (root) mRootMedia = node->getContent();
					}
					mPlatform->getDataManagerPtr()->addResourceLocation(node->getContent(), false);
				}
			}
		}
void MYGUIManager::setupResources()
{
    MyGUI::xml::Document doc;
    if ( !_platform || !doc.open(_resourcePathFile) ) doc.getLastError();
    
    MyGUI::xml::ElementPtr root = doc.getRoot();
    if ( root==nullptr || root->getName()!="Paths" ) return;
    
    MyGUI::xml::ElementEnumerator node = root->getElementEnumerator();
    while ( node.next() )
    {
        if ( node->getName()=="Path" )
        {
			bool root = false, recursive = false;
			if (!node->findAttribute("root").empty())
            {
                root = MyGUI::utility::parseBool( node->findAttribute("root") );
                if ( root ) _rootMedia = node->getContent();
            }
			if (!node->findAttribute("recursive").empty())
			{
				recursive = MyGUI::utility::parseBool(node->findAttribute("recursive"));
			}
			_platform->getDataManagerPtr()->addResourceLocation(node->getContent(), recursive);
        }
    }
}
Ejemplo n.º 8
0
void Framework::load( MyGUI::xml::ElementPtr node )
{
    removeAllJoint();
    mName = node->findAttribute("name");
    MyGUI::xml::ElementEnumerator e=node->getElementEnumerator();
    while(e.next())
    {
        MyGUI::xml::ElementPtr node = e.current();
        if( node->getName() == "body" )
        {
            loadRigid(node, JointPtr());
        }
        break;
    }
}
Ejemplo n.º 9
0
	MyGUI::UString EditorState::convertProjectName(const MyGUI::UString& _fileName)
	{
		size_t pos = mFileName.find_last_of("\\/");
		MyGUI::UString shortName = pos == MyGUI::UString::npos ? mFileName : mFileName.substr(pos + 1);
		addUserTag("ResourceName", shortName);

		size_t index = _fileName.find("|");
		if (index == MyGUI::UString::npos)
			return _fileName;

		MyGUI::UString fileName = _fileName.substr(0, index);
		MyGUI::UString itemIndexName = _fileName.substr(index + 1);
		size_t itemIndex = MyGUI::utility::parseValue<size_t>(itemIndexName);

		MyGUI::xml::Document doc;
		if (!doc.open(fileName))
			return _fileName;

		MyGUI::xml::ElementPtr root = doc.getRoot();
		if ((nullptr == root) || (root->getName() != "MyGUI"))
			return _fileName;

		if (root->findAttribute("type") == "Resource")
		{
			// берем детей и крутимся
			MyGUI::xml::ElementEnumerator element = root->getElementEnumerator();
			while (element.next("Resource"))
			{
				if (element->findAttribute("type") == "ResourceLayout")
				{
					if (itemIndex == 0)
					{
						// поменять на теги
						std::string resourceName = element->findAttribute("name");
						addUserTag("ResourceName", resourceName);
						return MyGUI::utility::toString(fileName, " [", resourceName, "]");
					}
					else
					{
						itemIndex --;
					}
				}
			}
		}

		return _fileName;
	}
Ejemplo n.º 10
0
	void SettingsManager::loadSettings(const MyGUI::UString& _fileName, bool _internal)
	{
		std::string _instance = "Editor";

		MyGUI::xml::Document doc;
		if (_internal)
		{
			MyGUI::DataStreamHolder data = MyGUI::DataManager::getInstance().getData(_fileName);
			if (data.getData() != nullptr)
			{
				if (!doc.open(data.getData()))
				{
					MYGUI_LOGGING(LogSection, Error, _instance << " : " << doc.getLastError());
					return;
				}
			}
		}
		else
		{
			if (!doc.open(_fileName))
			{
				MYGUI_LOGGING(LogSection, Error, _instance << " : " << doc.getLastError());
				return;
			}
		}

		MyGUI::xml::ElementPtr root = doc.getRoot();
		if (!root || (root->getName() != "MyGUI"))
		{
			MYGUI_LOGGING(LogSection, Error, _instance << " : '" << _fileName << "', tag 'MyGUI' not found");
			return;
		}

		std::string type;
		if (root->findAttribute("type", type))
		{
			if (type == "Settings")
			{
				// берем детей и крутимся
				MyGUI::xml::ElementEnumerator field = root->getElementEnumerator();
				while (field.next())
					loadSector(field.current());
			}
		}
	}
Ejemplo n.º 11
0
	void DemoKeeper::loadFromFile(const std::string& _filename)
	{
		MyGUI::xml::Document doc;

		if (!doc.open(_filename))
			return;

		MyGUI::xml::ElementPtr root = doc.getRoot();
		if (root == nullptr || root->getName() != "AnimationGraph")
			return;

		MyGUI::xml::ElementEnumerator node = root->getElementEnumerator();
		while (node.next())
		{
			if (node->getName() == "Node")
			{
				BaseAnimationNode* anim_node = createNode(node->findAttribute("type"), node->findAttribute("name"));
				anim_node->deserialization(node.current());
			}
			else if (node->getName() == "Connections")
			{
				MyGUI::xml::ElementEnumerator conn = node->getElementEnumerator();
				BaseAnimationNode* anim_node = getNodeByName(node.current()->findAttribute("node"));
				if (anim_node)
				{
					while (conn.next("Connection"))
					{
						BaseAnimationNode* anim_node2 = getNodeByName(conn.current()->findAttribute("node"));
						if (anim_node2)
						{
							//соединить точки в ноде
							const std::string& from_point = conn.current()->findAttribute("from");
							const std::string& to_point = conn.current()->findAttribute("to");

							wraps::BaseGraphConnection* from_conn = anim_node->getConnectionByName(from_point, "EventOut");
							if (!from_conn) from_conn = anim_node->getConnectionByName(from_point, "PositionOut");
							if (!from_conn) from_conn = anim_node->getConnectionByName(from_point, "WeightOut");

							wraps::BaseGraphConnection* to_conn = anim_node2->getConnectionByName(to_point, "EventIn");
							if (!to_conn) to_conn = anim_node2->getConnectionByName(to_point, "PositionIn");
							if (!to_conn) to_conn = anim_node2->getConnectionByName(to_point, "WeightIn");

							if (from_conn && to_conn)
							{
								from_conn->addConnectionPoint(to_conn);
								connectPoints(anim_node, anim_node2, from_point, to_point);
							}
						}
					}
				}
			}
			else if (node->getName() == "EditorData")
			{
				MyGUI::xml::ElementEnumerator item_data = node->getElementEnumerator();
				while (item_data.next("Node"))
				{
					BaseAnimationNode* anim_node = getNodeByName(item_data.current()->findAttribute("name"));
					if (anim_node)
					{
						anim_node->setCoord(MyGUI::IntCoord::parse(item_data.current()->findAttribute("coord")));
					}
				}
			}
		}

	}
Ejemplo n.º 12
0
	bool BaseManager::loadBase( 
		const string& filename,
		LuaVector& doScript,
		LuaVector& locationScript,
		LuaVector& loadScript
		)
	{
		MyGUI::xml::Document doc;
		
		if( !doc.open(mResourcePath+filename) )
		{
			if( !doc.open(filename) )
			{
				MyGUI::IDataStream* pdata = MyGUI::DataManager::getInstance().getData(filename);
				if( pdata )
				{
					if( !doc.open(pdata) )
					{
						MyGUI::DataManager::getInstance().freeData(pdata);
						ERROR_LOG(doc.getLastError());
						return false;
					}
					MyGUI::DataManager::getInstance().freeData(pdata);
				}
				else
				{
					ERROR_LOG(doc.getLastError());
					return false;
				}
			}
		}
		
		MyGUI::xml::ElementPtr root = doc.getRoot();
		if (root == nullptr || root->getName() != "base")
			return false;
//		LuaVector groups;

		MyGUI::xml::ElementEnumerator node = root->getElementEnumerator();
		while( node.next() )
		{
			string name = node->getName();
			if( name == "script" )
			{
				string lua;
				if( node->findAttribute("do",lua) )
					doScript.push_back( lua ); //等到LuaManager被创建后在一起执行
				if( node->findAttribute("location",lua) )
				{
					if( find(locationScript.begin(),locationScript.end(),lua)==locationScript.end() )
						locationScript.push_back( lua );
				}
				if( node->findAttribute("load",lua) )
				{
					loadScript.push_back(lua);
				}
			}
			else if( name == "group" )
			{
				string name;
				if( node->findAttribute("name",name) )
				{
//					if( find(groups.begin(),groups.end(),name)==groups.end() )
//						groups.push_back(name);
					MyGUI::xml::ElementEnumerator child = node->getElementEnumerator();
					while( child.next() )
					{
						string type,location,recursive;
						if( child->getName() == "repository" )
						{
							if( child->findAttribute("type",type) && 
								child->findAttribute("recursive",recursive) &&
								child->findAttribute("location",location) )
							{
								//加入组
								addGroupLocation(name,type,location,recursive=="true"?true:false);
							}
						}
					}
				}
			}
		}
		return true;
	}
Ejemplo n.º 13
0
//===================================================================================
void EditorState::loadSettings(const MyGUI::UString& _fileName, bool _internal)
{
	std::string _instance = "Editor";

	MyGUI::xml::Document doc;
	if (_internal)
	{
		MyGUI::IDataStream* data = MyGUI::DataManager::getInstance().getData(_fileName);
		if (data)
		{
			PtrHolder<MyGUI::IDataStream> holder = PtrHolder<MyGUI::IDataStream>(data);

			if (!doc.open(data))
			{
				MYGUI_LOGGING(LogSection, Error, _instance << " : " << doc.getLastError());
				return;
			}
		}
	}
	else
	{
		if (!doc.open(_fileName))
		{
			MYGUI_LOGGING(LogSection, Error, _instance << " : " << doc.getLastError());
			return;
		}
	}

	MyGUI::xml::ElementPtr root = doc.getRoot();
	if (!root || (root->getName() != "MyGUI"))
	{
		MYGUI_LOGGING(LogSection, Error, _instance << " : '" << _fileName << "', tag 'MyGUI' not found");
		return;
	}

	std::string type;
	if (root->findAttribute("type", type))
	{
		if (type == "Settings")
		{
			// берем детей и крутимс¤
			MyGUI::xml::ElementEnumerator field = root->getElementEnumerator();
			while (field.next())
			{
				if (field->getName() == "PropertiesPanelView") mPropertiesPanelView->load(field);
				else if (field->getName() == "SettingsWindow") mSettingsWindow->load(field);
				else if (field->getName() == "WidgetsWindow") mWidgetsWindow->load(field);
				else if (field->getName() == "MetaSolutionWindow")
				{
					if (isNeedSolutionLoad(field))
					{
						clearWidgetWindow();
						mMetaSolutionWindow->load(field);
					}
				}
				else if (field->getName() == "RecentFile")
				{
					std::string name;
					if (!field->findAttribute("name", name)) continue;
					recentFiles.push_back(name);
				}
				else if (field->getName() == "AdditionalPath")
				{
					std::string name;
					if (!field->findAttribute("name", name)) continue;
					additionalPaths.push_back(name);
				}
			}
		}
	}
}
Ejemplo n.º 14
0
	void SettingsManager::loadSector(MyGUI::xml::ElementPtr _sectorNode)
	{
		SettingsSector* sector = getSector(_sectorNode->getName());
		sector->deserialization(_sectorNode, MyGUI::Version());
	}