Пример #1
0
bool CommandManager::executeCommand(const MyGUI::UString& _command)
{
	bool result = false;
	MyGUI::UString command = _command;
	size_t index = _command.find('.');
	MYGUI_LOG(Warning , "+++++:Menu Command apply :" << command << "+++++");
	if (index != MyGUI::UString::npos)
	{
		command = _command.substr(0, index);
		mData = _command.substr(index + 1);
	}

	MapDelegate::iterator iter = mDelegates.find(command);
	if (iter != mDelegates.end())
	{
		iter->second(command, result);
	}
	else
	{
		MYGUI_LOG(Warning, "Command '" << command << "' not found");
	}

	mData.clear();

	return result;
}
Пример #2
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;
	}
Пример #3
0
	bool EditorState::isProjectFile(const MyGUI::UString& _fileName)
	{
		size_t index = _fileName.find("|");
		return (index != MyGUI::UString::npos);
	}