Example #1
0
	void PluginManager::_load(xml::ElementPtr _node, const std::string& _file, Version _version)
	{
		xml::ElementEnumerator node = _node->getElementEnumerator();
		while (node.next())
		{
			if (node->getName() == "path")
			{
				std::string source;
				if (node->findAttribute("source", source))
					loadPlugin(source);
			}
			else if (node->getName() == "Plugin")
			{
				std::string source;

				xml::ElementEnumerator source_node = node->getElementEnumerator();
				while (source_node.next("Source"))
				{
					std::string build = source_node->findAttribute("build");
#if MYGUI_DEBUG_MODE == 1
					if (build == "Debug")
						source = source_node->getContent();
#else
					if (build != "Debug")
						source = source_node->getContent();
#endif
				}
				if (!source.empty())
					loadPlugin(source);
			}
		}
	}
Example #2
0
	void OgreFont::deserialization(xml::ElementPtr _node, Version _version)
	{
		xml::ElementEnumerator node = _node->getElementEnumerator();
		while (node.next())
		{
			if (node->getName() == "Property")
			{
				const std::string& key = node->findAttribute("key");
				const std::string& value = node->findAttribute("value");
				// 中文处理
				if (key == "Source") mSource = value;
				else if (key == "Size") mSize = utility::parseInt(value);
				else if (key == "Resolution") mResolution = utility::parseUInt(value);
				else if (key == "SpaceWidth") mSpaceWidth = utility::parseInt(value);
				else if (key == "TabWidth") mTabWidth = utility::parseInt(value);
				else if (key == "OffsetHeight") mOffsetHeight = utility::parseInt(value);
				else if (key == "SubstituteCode") mSubstituteCodePoint = utility::parseInt(value);
				else if (key == "CursorWidth") mCursorWidth = utility::parseInt(value);
				else if (key == "Distance") mDistance = utility::parseInt(value);
				else if (key == "Bold") mBold = utility::parseBool(value);
				else if (key == "Italic") mItalic = utility::parseBool(value);
			}
		}

		initialise();
	}
Example #3
0
	void OverlappedLayer::deserialization(xml::ElementPtr _node, Version _version)
	{
		mName = _node->findAttribute("name");
		if (_version >= Version(1, 2))
		{
			MyGUI::xml::ElementEnumerator propert = _node->getElementEnumerator();
			while (propert.next("Property"))
			{
				const std::string& key = propert->findAttribute("key");
				const std::string& value = propert->findAttribute("value");
				if (key == "Pick") mIsPick = utility::parseValue<bool>(value);
			}
		}
		else
		{
			mIsPick = utility::parseBool(_version < Version(1, 0) ? _node->findAttribute("peek") : _node->findAttribute("pick"));
		}
	}
	void ResourceLayout::deserialization(xml::ElementPtr _node, Version _version)
	{
		Base::deserialization(_node, _version);

		mLayoutData.clear();

		xml::ElementEnumerator widget = _node->getElementEnumerator();
		while (widget.next("Widget"))
			mLayoutData.push_back(parseWidget(widget));
	}
    void LanguageManager::_load(xml::ElementPtr _node, const std::string& _file, Version _version)
    {
        std::string default_lang;
        bool event_change = false;

        // берем детей и крутимся, основной цикл
        xml::ElementEnumerator root = _node->getElementEnumerator();
        while (root.next(XML_TYPE))
        {
            // парсим атрибуты
            root->findAttribute("default", default_lang);

            // берем детей и крутимся
            xml::ElementEnumerator info = root->getElementEnumerator();
            while (info.next("Info"))
            {
                // парсим атрибуты
                std::string name(info->findAttribute("name"));

                // доюавляем в карту пользователя
                if (name.empty())
                {
                    xml::ElementEnumerator source_info = info->getElementEnumerator();
                    while (source_info.next("Source"))
                    {
                        loadLanguage(source_info->getContent(), true);
                    }
                }
                // добавляем в карту языков
                else
                {
                    xml::ElementEnumerator source_info = info->getElementEnumerator();
                    while (source_info.next("Source"))
                    {
                        std::string file_source = source_info->getContent();
                        // добавляем в карту
                        mMapFile[name].push_back(file_source);

                        // если добавляемый файл для текущего языка, то подгружаем и оповещаем
                        if (name == mCurrentLanguageName)
                        {
                            loadLanguage(file_source, false);
                            event_change = true;
                        }
                    }
                }

            }
        }

        if (!default_lang.empty())
            setCurrentLanguage(default_lang);
        else if (event_change)
            eventChangeLanguage(mCurrentLanguageName);
    }
Example #6
0
	void ResourceManager::_loadList(xml::ElementPtr _node, const std::string& _file, Version _version)
	{
		// берем детей и крутимся, основной цикл
		xml::ElementEnumerator node = _node->getElementEnumerator();
		while (node.next(XML_TYPE_LIST))
		{
			std::string source;
			if (!node->findAttribute("file", source)) continue;
			MYGUI_LOG(Info, "Load ini file '" << source << "'");
			_loadImplement(source, false, "", INSTANCE_TYPE_NAME);
		}
	}
Example #7
0
	void RTTLayer::deserialization(xml::ElementPtr _node, Version _version)
	{
		Base::deserialization(_node, _version);

		MyGUI::xml::ElementEnumerator propert = _node->getElementEnumerator();
		while (propert.next("Property"))
		{
			const std::string& key = propert->findAttribute("key");
			const std::string& value = propert->findAttribute("value");
			if (key == "TextureSize") setTextureSize(utility::parseValue<IntSize>(value));
			if (key == "TextureName") setTextureName(value);
		}
	}
Example #8
0
	void ResourceManager::_load(xml::ElementPtr _node, const std::string& _file, Version _version)
	{
		FactoryManager& factory = FactoryManager::getInstance();

		VectorGuid vector_guid;
		// берем детей и крутимся, основной цикл
		xml::ElementEnumerator root = _node->getElementEnumerator();
		while (root.next(XML_TYPE))
		{
			// парсим атрибуты
			std::string id, type, name;
			root->findAttribute("type", type);
			root->findAttribute("name", name);
			root->findAttribute("id", id);

			Guid guid(id);
			if (!guid.empty())
			{
				if (mResourcesID.find(guid) != mResourcesID.end())
				{
					MYGUI_LOG(Warning, "dublicate resource id " << guid.print());
				}
			}

			if (mResources.find(name) != mResources.end())
			{
				MYGUI_LOG(Warning, "dublicate resource name '" << name << "'");
			}

			vector_guid.push_back(guid);

			IObject* object = factory.createObject(XML_TYPE, type);
			if (object == nullptr)
			{
				MYGUI_LOG(Error, "resource type '" << type << "' not found");
				continue;
			}

			IResourcePtr resource = object->castType<IResource>();
			resource->deserialization(root.current(), _version);

			if (!guid.empty()) mResourcesID[guid] = resource;
			if (!name.empty()) mResources[name] = resource;
		}

		if (!vector_guid.empty())
		{
			mListFileGuid[_file] = vector_guid;
		}

	}
Example #9
0
void ResourceImageSetPointer::deserialization(xml::ElementPtr _node, Version _version)
{
    Base::deserialization(_node, _version);

    // берем детей и крутимся, основной цикл
    xml::ElementEnumerator info = _node->getElementEnumerator();
    while (info.next("Property"))
    {
        const std::string& key = info->findAttribute("key");
        const std::string& value = info->findAttribute("value");

        if (key == "Point") mPoint = IntPoint::parse(value);
        else if (key == "Size") mSize = IntSize::parse(value);
        else if (key == "Resource") mImageSet = ResourceManager::getInstance().getByName(value)->castType<ResourceImageSet>();
    }
}
void ResourceManualPointer::deserialization(xml::ElementPtr _node, Version _version)
{
    Base::deserialization(_node, _version);

    // берем детей и крутимся, основной цикл
    xml::ElementEnumerator info = _node->getElementEnumerator();
    while (info.next("Property"))
    {
        const std::string& key = info->findAttribute("key");
        const std::string& value = info->findAttribute("value");

        if (key == "Point") mPoint = IntPoint::parse(value);
        else if (key == "Size") mSize = IntSize::parse(value);
        else if (key == "Texture") mTexture = value;
        else if (key == "Coord") mTextureCoord = IntCoord::parse(value);
    }
}
	void ResourceImageSet::deserialization(xml::ElementPtr _node, Version _version)
	{
		Base::deserialization(_node, _version);

		// берем детей и крутимся, основной цикл
		xml::ElementEnumerator group_node = _node->getElementEnumerator();
		while (group_node.next("Group"))
		{
			GroupImage group;
			group.name = group_node->findAttribute("name");

			group.texture = group_node->findAttribute("texture");
			// поддержка замены тегов
			if (_version >= Version(1, 1))
			{
				group.texture = LanguageManager::getInstance().replaceTags(group.texture);
			}

			group.size = IntSize::parse(group_node->findAttribute("size"));

			xml::ElementEnumerator index_node = group_node->getElementEnumerator();
			while (index_node.next("Index"))
			{
				IndexImage index;
				index.name = index_node->findAttribute("name");
				index.rate = utility::parseFloat(index_node->findAttribute("rate"));

				xml::ElementEnumerator frame_node = index_node->getElementEnumerator();
				while (frame_node.next("Frame"))
				{
					size_t count = utility::parseSizeT(frame_node->findAttribute("count"));
					const IntPoint& point = IntPoint::parse(frame_node->findAttribute("point"));
					if ((count < 1) || (count > 256)) count = 1;
					while (count > 0)
					{
						index.frames.push_back(point);
						-- count;
					}
				}

				group.indexes.push_back(index);
			}

			AddGroupImage(group);
		}
	}
Example #12
0
	void RTTLayer::deserialization(xml::ElementPtr _node, Version _version)
	{
		Base::deserialization(_node, _version);

		MyGUI::xml::ElementEnumerator propert = _node->getElementEnumerator();
		while (propert.next("Property"))
		{
			const std::string& key = propert->findAttribute("key");
			const std::string& value = propert->findAttribute("value");
			if (key == "TextureSize") setTextureSize(utility::parseValue<IntSize>(value));
#ifdef MYGUI_OGRE_PLATFORM
			else if (key == "Entity") setEntity(value);
			else if (key == "Material") setMaterial(value);
			else if (key == "SceneManager") setSceneManager(value);
			else if (key == "Camera") setCamera(value);
#endif
		}
	}
	void LanguageManager::_load(xml::ElementPtr _node, const std::string & _file, Version _version)
	{
		std::string def;

		// берем детей и крутимся, основной цикл
		xml::ElementEnumerator root = _node->getElementEnumerator();
		while (root.next(XML_TYPE)) {

			// парсим атрибуты
			root->findAttribute("default", def);

			// берем детей и крутимся
			xml::ElementEnumerator info = root->getElementEnumerator();
			while (info.next("Info")) {

				// парсим атрибуты
				std::string name(info->findAttribute("name"));

				// доюавляем в карту пользователя
				if (name.empty()) {
					xml::ElementEnumerator source_info = info->getElementEnumerator();
					while (source_info.next("Source")) {
						loadLanguage(source_info->getContent(), ResourceManager::getInstance().getResourceGroup(), true);
					};

				}
				// добавляем в карту языков
				else {
					MapListString::iterator lang = mMapFile.find(name);
					if (lang == mMapFile.end()) {
						lang = mMapFile.insert(std::make_pair(name, VectorString())).first;
					}

					xml::ElementEnumerator source_info = info->getElementEnumerator();
					while (source_info.next("Source")) {
						lang->second.push_back(source_info->getContent());
					};
				}

			};
		};

		if ( ! def.empty()) setCurrentLanguage(def);
	}
	void ResourceManualFont::deserialization(xml::ElementPtr _node, Version _version)
	{
		Base::deserialization(_node, _version);

		xml::ElementEnumerator node = _node->getElementEnumerator();
		while (node.next())
		{
			if (node->getName() == "Property")
			{
				const std::string& key = node->findAttribute("key");
				const std::string& value = node->findAttribute("value");
				if (key == "Source") mSource = value;
				else if (key == "DefaultHeight") mDefaultHeight = utility::parseInt(value);
			}
			else if (node->getName() == "Codes")
			{
				xml::ElementEnumerator range = node->getElementEnumerator();
				while (range.next("Code"))
				{
					std::string range_value;
					std::vector<std::string> parse_range;
					// описане глифов
					if (range->findAttribute("index", range_value))
					{
						Char id = 0;
						if (range_value == "cursor")
							id = FontCodeType::Cursor;
						else if (range_value == "selected")
							id = FontCodeType::Selected;
						else if (range_value == "selected_back")
							id = FontCodeType::SelectedBack;
						else
							id = utility::parseUInt(range_value);

						addGlyph(id, utility::parseValue<IntCoord>(range->findAttribute("coord")));
					}
				}
			}
		}

		// инициализируем
		initialise();
	}
Example #15
0
	void SkinManager::_load(xml::ElementPtr _node, const std::string& _file, Version _version)
	{
		// берем детей и крутимся, основной цикл со скинами
		xml::ElementEnumerator skin = _node->getElementEnumerator();
		while (skin.next(XML_TYPE))
		{
			/*std::string name = */skin->findAttribute("name");
			std::string type = skin->findAttribute("type");
			if (type.empty())
				type = "ResourceSkin";

			IObject* object = FactoryManager::getInstance().createObject(XML_TYPE_RESOURCE, type);
			if (object != nullptr)
			{
				ResourceSkin* data = object->castType<ResourceSkin>();
				data->deserialization(skin.current(), _version);

				ResourceManager::getInstance().addResource(data);
			}
		}
	}
	void LayerManager::_load(xml::ElementPtr _node, const std::string& _file, Version _version)
	{
		VectorLayer layers;
		// берем детей и крутимся, основной цикл
		xml::ElementEnumerator layer = _node->getElementEnumerator();
		while (layer.next(mCategoryName))
		{

			std::string name;

			if ( !layer->findAttribute("name", name))
			{
				MYGUI_LOG(Warning, "Attribute 'name' not found (file : " << _file << ")");
				continue;
			}

			for (VectorLayer::iterator iter = layers.begin(); iter != layers.end(); ++iter)
			{
				MYGUI_ASSERT((*iter)->getName() != name, "Layer '" << name << "' already exist (file : " << _file << ")");
			}

			std::string type = layer->findAttribute("type");
			if (type.empty() && _version <= Version(1, 0))
			{
				bool overlapped = utility::parseBool(layer->findAttribute("overlapped"));
				type = overlapped ? "OverlappedLayer" : "SharedLayer";
			}

			IObject* object = FactoryManager::getInstance().createObject(mCategoryName, type);
			MYGUI_ASSERT(object != nullptr, "factory '" << type << "' is not found");

			ILayer* item = object->castType<ILayer>();
			item->deserialization(layer.current(), _version);

			layers.push_back(item);
		}

		// теперь мержим новые и старые слои
		merge(layers);
	}
Example #17
0
void FontManager::_load(xml::ElementPtr _node, const std::string& _file, Version _version)
{
#ifndef MYGUI_DONT_USE_OBSOLETE
    loadOldFontFormat(_node, _file, _version, mXmlFontTagName);
#endif // MYGUI_DONT_USE_OBSOLETE

    xml::ElementEnumerator node = _node->getElementEnumerator();
    while (node.next())
    {
        if (node->getName() == mXmlPropertyTagName)
        {
            const std::string& key = node->findAttribute("key");
            const std::string& value = node->findAttribute("value");
#ifdef MYGUI_USE_FREETYPE
            if (key == "Default")
#else
            if (key == "DefaultGenerated")
#endif
                mDefaultName = value;
        }
    }
}
Example #18
0
	void ResourceManager::loadFromXmlNode(xml::ElementPtr _node, const std::string& _file, Version _version)
	{
		FactoryManager& factory = FactoryManager::getInstance();

		// берем детей и крутимся, основной цикл
		xml::ElementEnumerator root = _node->getElementEnumerator();
		while (root.next(XML_TYPE))
		{
			// парсим атрибуты
			std::string type, name;
			root->findAttribute("type", type);
			root->findAttribute("name", name);

			if (name.empty())
				continue;

			MapResource::iterator item = mResources.find(name);
			if (item != mResources.end())
			{
				MYGUI_LOG(Warning, "dublicate resource name '" << name << "'");

				// ресурсами могут пользоваться
				mRemovedResoures.push_back((*item).second);
				mResources.erase(item);
			}

			IObject* object = factory.createObject(XML_TYPE, type);
			if (object == nullptr)
			{
				MYGUI_LOG(Error, "resource type '" << type << "' not found");
				continue;
			}

			IResourcePtr resource = object->castType<IResource>();
			resource->deserialization(root.current(), _version);

			mResources[name] = resource;
		}
	}
	void ResourceTrueTypeFont::deserialization(xml::ElementPtr _node, Version _version)
	{
		Base::deserialization(_node, _version);

		xml::ElementEnumerator node = _node->getElementEnumerator();
		while (node.next())
		{
			if (node->getName() == "Property")
			{
				const std::string& key = node->findAttribute("key");
				const std::string& value = node->findAttribute("value");
				if (key == "Source")
					setSource(value);
				else if (key == "Size")
					setSize(utility::parseFloat(value));
				else if (key == "Resolution")
					setResolution(utility::parseUInt(value));
				else if (key == "Antialias")
					setAntialias(utility::parseBool(value));
				else if (key == "TabWidth")
					setTabWidth(utility::parseFloat(value));
				else if (key == "OffsetHeight")
					setOffsetHeight(utility::parseInt(value));
				else if (key == "SubstituteCode")
					setSubstituteCode(utility::parseInt(value));
				else if (key == "Distance")
					setDistance(utility::parseInt(value));
				else if (key == "Hinting")
					setHinting(value);
				else if (key == "SpaceWidth")
				{
					mSpaceWidth = utility::parseFloat(value);
					MYGUI_LOG(Warning, _node->findAttribute("type") << ": Property '" << key << "' in font '" << _node->findAttribute("name") << "' is deprecated; remove it to use automatic calculation.");
				}
				else if (key == "CursorWidth")
				{
					MYGUI_LOG(Warning, _node->findAttribute("type") << ": Property '" << key << "' in font '" << _node->findAttribute("name") << "' is deprecated; value ignored.");
				}
			}
			else if (node->getName() == "Codes")
			{
				// Range of inclusions.
				xml::ElementEnumerator range = node->getElementEnumerator();
				while (range.next("Code"))
				{
					std::string range_value;
					if (range->findAttribute("range", range_value))
					{
						std::vector<std::string> parse_range = utility::split(range_value);
						if (!parse_range.empty())
						{
							Char first = utility::parseUInt(parse_range[0]);
							Char last = parse_range.size() > 1 ? utility::parseUInt(parse_range[1]) : first;
							addCodePointRange(first, last);
						}
					}
				}

				// If no code points have been included, include the Unicode Basic Multilingual Plane by default before processing
				//	any exclusions.
				if (mCharMap.empty())
					addCodePointRange(0, 0xFFFF);

				// Range of exclusions.
				range = node->getElementEnumerator();
				while (range.next("Code"))
				{
					std::string range_value;
					if (range->findAttribute("hide", range_value))
					{
						std::vector<std::string> parse_range = utility::split(range_value);
						if (!parse_range.empty())
						{
							Char first = utility::parseUInt(parse_range[0]);
							Char last = parse_range.size() > 1 ? utility::parseUInt(parse_range[1]) : first;
							removeCodePointRange(first, last);
						}
					}
				}
			}
		}

		initialise();
	}
Example #20
0
	void ResourceSkin::deserialization(xml::ElementPtr _node, Version _version)
	{
		Base::deserialization(_node, _version);

		std::string stateCategory = SubWidgetManager::getInstance().getStateCategoryName();

		// парсим атрибуты скина
		std::string name, texture, tmp;
		IntSize size;
		_node->findAttribute("name", name);
		_node->findAttribute("texture", texture);
		if (_node->findAttribute("size", tmp)) size = IntSize::parse(tmp);

		LanguageManager& localizator = LanguageManager::getInstance();

		// вспомогательный класс для биндинга сабскинов
		SubWidgetBinding bind;

		// поддержка замены тегов в скинах
		if (_version >= Version(1, 1))
		{
			texture = localizator.replaceTags(texture);
		}

		setInfo(size, texture);

		// проверяем маску
		if (_node->findAttribute("mask", tmp))
			addProperty("MaskPick", tmp);

		// берем детей и крутимся, цикл с саб скинами
		xml::ElementEnumerator basis = _node->getElementEnumerator();
		while (basis.next())
		{
			if (basis->getName() == "Property")
			{
				// загружаем свойства
				std::string key, value;
				if (!basis->findAttribute("key", key))
					continue;
				if (!basis->findAttribute("value", value))
					continue;

				// поддержка замены тегов в скинах
				if (_version >= Version(1, 1))
				{
					value = localizator.replaceTags(value);
				}

				// добавляем свойство
				addProperty(key, value);
			}
			else if (basis->getName() == "Child")
			{
				ChildSkinInfo child(
					basis->findAttribute("type"),
					WidgetStyle::parse(basis->findAttribute("style")),
					basis->findAttribute("skin"),
					IntCoord::parse(basis->findAttribute("offset")),
					Align::parse(basis->findAttribute("align")),
					basis->findAttribute("layer"),
					basis->findAttribute("name")
				);

				xml::ElementEnumerator child_params = basis->getElementEnumerator();
				while (child_params.next("Property"))
					child.addParam(child_params->findAttribute("key"), child_params->findAttribute("value"));

				addChild(child);
				//continue;
			}
			else if (basis->getName() == "BasisSkin")
			{
				// парсим атрибуты
				std::string basisSkinType, tmp_str;
				IntCoord offset;
				Align align = Align::Default;
				basis->findAttribute("type", basisSkinType);
				if (basis->findAttribute("offset", tmp_str))
					offset = IntCoord::parse(tmp_str);
				if (basis->findAttribute("align", tmp_str))
					align = Align::parse(tmp_str);

				bind.create(offset, align, basisSkinType);

				// берем детей и крутимся, цикл со стейтами
				xml::ElementEnumerator state = basis->getElementEnumerator();

				// проверяем на новый формат стейтов
				bool new_format = false;
				// если версия меньше 1.0 то переименовываем стейты
				if (_version < Version(1, 0))
				{
					while (state.next())
					{
						if (state->getName() == "State")
						{
							const std::string& name_state = state->findAttribute("name");
							if ((name_state == "normal_checked") || (state->findAttribute("name") == "normal_check"))
							{
								new_format = true;
								break;
							}
						}
					}
					// обновляем
					state = basis->getElementEnumerator();
				}

				while (state.next())
				{
					if (state->getName() == "State")
					{
						// парсим атрибуты стейта
						std::string basisStateName;
						state->findAttribute("name", basisStateName);

						// если версия меньше 1.0 то переименовываем стейты
						if (_version < Version(1, 0))
						{
							// это обсолет новых типов
							if (basisStateName == "disable_check")
								basisStateName = "disabled_checked";
							else if (basisStateName == "normal_check")
								basisStateName = "normal_checked";
							else if (basisStateName == "active_check")
								basisStateName = "highlighted_checked";
							else if (basisStateName == "pressed_check")
								basisStateName = "pushed_checked";
							else if (basisStateName == "disable")
								basisStateName = "disabled";
							else if (basisStateName == "active")
								basisStateName = "highlighted";
							else if (basisStateName == "select")
								basisStateName = "pushed";
							else if (basisStateName == "pressed")
							{
								if (new_format)
									basisStateName = "pushed";
								else
									basisStateName = "normal_checked";
							}
						}

						// конвертируем инфу о стейте
						IStateInfo* data = nullptr;
						IObject* object = FactoryManager::getInstance().createObject(stateCategory, basisSkinType);
						if (object != nullptr)
						{
							data = object->castType<IStateInfo>();
							data->deserialization(state.current(), _version);
						}

						// добавляем инфо о стайте
						bind.add(basisStateName, data, name);
					}
				}

				// теперь всё вместе добавляем в скин
				addInfo(bind);
			}

		}
	}
Example #21
0
	void ResourceManualFont::deserialization(xml::ElementPtr _node, Version _version)
	{
		Base::deserialization(_node, _version);

		xml::ElementEnumerator node = _node->getElementEnumerator();
		while (node.next())
		{
			if (node->getName() == "Property")
			{
				const std::string& key = node->findAttribute("key");
				const std::string& value = node->findAttribute("value");
				if (key == "Source") mSource = value;
				else if (key == "DefaultHeight") mDefaultHeight = utility::parseInt(value);
			}
		}

		loadTexture();

		if (mTexture != nullptr)
		{
			int textureWidth = mTexture->getWidth();
			int textureHeight = mTexture->getHeight();

			node = _node->getElementEnumerator();
			while (node.next())
			{
				if (node->getName() == "Codes")
				{
					xml::ElementEnumerator element = node->getElementEnumerator();
					while (element.next("Code"))
					{
						std::string value;
						// описане глифов
						if (element->findAttribute("index", value))
						{
							Char id = 0;
							if (value == "cursor")
								id = static_cast<Char>(FontCodeType::Cursor);
							else if (value == "selected")
								id = static_cast<Char>(FontCodeType::Selected);
							else if (value == "selected_back")
								id = static_cast<Char>(FontCodeType::SelectedBack);
							else if (value == "substitute")
								id = static_cast<Char>(FontCodeType::NotDefined);
							else
								id = utility::parseUInt(value);

							float advance(utility::parseValue<float>(element->findAttribute("advance")));
							FloatPoint bearing(utility::parseValue<FloatPoint>(element->findAttribute("bearing")));

							// texture coordinates
							FloatCoord coord(utility::parseValue<FloatCoord>(element->findAttribute("coord")));

							// glyph size, default to texture coordinate size
							std::string sizeString;
							FloatSize size(coord.width, coord.height);
							if (element->findAttribute("size", sizeString))
							{
								size = utility::parseValue<FloatSize>(sizeString);
							}

							if (advance == 0.0f)
								advance = size.width;

							GlyphInfo& glyphInfo = mCharMap.insert(CharMap::value_type(id, GlyphInfo(
								id,
								size.width,
								size.height,
								advance,
								bearing.left,
								bearing.top,
								FloatRect(
									coord.left / textureWidth,
									coord.top / textureHeight,
									coord.right() / textureWidth,
									coord.bottom() / textureHeight)
								))).first->second;

							if (id == FontCodeType::NotDefined)
								mSubstituteGlyphInfo = &glyphInfo;
						}
					}
				}
			}
		}
	}
	void FontManager::_load(xml::ElementPtr _node, const std::string& _file, Version _version)
	{
		xml::ElementEnumerator font = _node->getElementEnumerator();
		while (font.next())
		{
			if (font->getName() == XML_TYPE)
			{
				std::string name;
				if (!font->findAttribute("name", name)) continue;

				std::string type;
				if (type.empty())
				{
					if (font->findAttribute("resolution").empty()) type = "ResourceManualFont";
					else type = "ResourceTrueTypeFont";
				}

				xml::Document doc;
				xml::ElementPtr root = doc.createRoot("MyGUI");
				xml::ElementPtr node = root->createChild("Resource");
				node->addAttribute("type", type);
				node->addAttribute("name", name);

				std::string tmp;
				if (font->findAttribute("source", tmp))
				{
					xml::ElementPtr prop = node->createChild("Property");
					prop->addAttribute("key", "Source");
					prop->addAttribute("value", tmp);
				}

				if (font->findAttribute("size", tmp))
				{
					xml::ElementPtr prop = node->createChild("Property");
					prop->addAttribute("key", "Size");
					prop->addAttribute("value", tmp);
				}

				if (font->findAttribute("resolution", tmp))
				{
					xml::ElementPtr prop = node->createChild("Property");
					prop->addAttribute("key", "Resolution");
					prop->addAttribute("value", tmp);
				}

				if (font->findAttribute("antialias_colour", tmp))
				{
					xml::ElementPtr prop = node->createChild("Property");
					prop->addAttribute("key", "Antialias");
					prop->addAttribute("value", tmp);
				}

				if (font->findAttribute("space_width", tmp))
				{
					xml::ElementPtr prop = node->createChild("Property");
					prop->addAttribute("key", "SpaceWidth");
					prop->addAttribute("value", tmp);
				}

				if (font->findAttribute("tab_width", tmp))
				{
					xml::ElementPtr prop = node->createChild("Property");
					prop->addAttribute("key", "TabWidth");
					prop->addAttribute("value", tmp);
				}

				if (font->findAttribute("cursor_width", tmp))
				{
					xml::ElementPtr prop = node->createChild("Property");
					prop->addAttribute("key", "CursorWidth");
					prop->addAttribute("value", tmp);
				}

				if (font->findAttribute("distance", tmp))
				{
					xml::ElementPtr prop = node->createChild("Property");
					prop->addAttribute("key", "Distance");
					prop->addAttribute("value", tmp);
				}

				if (font->findAttribute("offset_height", tmp))
				{
					xml::ElementPtr prop = node->createChild("Property");
					prop->addAttribute("key", "OffsetHeight");
					prop->addAttribute("value", tmp);
				}

				if (font->findAttribute("default_height", tmp))
				{
					xml::ElementPtr prop = node->createChild("Property");
					prop->addAttribute("key", "DefaultHeight");
					prop->addAttribute("value", tmp);
				}

				xml::ElementPtr codes = node->createChild("Codes");

				xml::ElementEnumerator codeold = font->getElementEnumerator();
				while (codeold.next("Code"))
				{
					xml::ElementPtr codenew = codes->createChild("Code");

					if (codeold->findAttribute("range", tmp))
						codenew->addAttribute("range", tmp);

					if (codeold->findAttribute("hide", tmp))
						codenew->addAttribute("hide", tmp);

					if (codeold->findAttribute("index", tmp))
						codenew->addAttribute("index", tmp);

					if (codeold->findAttribute("coord", tmp))
						codenew->addAttribute("coord", tmp);
				}

				ResourceManager::getInstance().loadFromXmlNode(root, _file, _version);
			}
			else if (font->getName() == XML_TYPE_PROPERTY)
			{
				const std::string& key = font->findAttribute("key");
				const std::string& value = font->findAttribute("value");
				if (key == "Default")
					mDefaultName = value;
			}
		}
	}
	void PointerManager::_load(xml::ElementPtr _node, const std::string& _file, Version _version)
	{
		std::string pointer;
		std::string layer;

		xml::ElementEnumerator node = _node->getElementEnumerator();
		while (node.next())
		{
			if (node->getName() == XML_TYPE)
			{
				layer = node->findAttribute("layer");
				pointer = node->findAttribute("default");

				// сохраняем
				std::string shared_text = node->findAttribute("texture");

				// берем детей и крутимся, основной цикл
				xml::ElementEnumerator info = node->getElementEnumerator();
				while (info.next("Info"))
				{
					std::string name = info->findAttribute("name");
					if (name.empty()) continue;

					std::string texture = info->findAttribute("texture");

					std::string type = (shared_text.empty() && texture.empty()) ? "ResourceImageSetPointer" : "ResourceManualPointer";

					xml::Document doc;
					xml::ElementPtr root = doc.createRoot("MyGUI");
					xml::ElementPtr newnode = root->createChild("Resource");
					newnode->addAttribute("type", type);
					newnode->addAttribute("name", name);

					std::string tmp;
					if (info->findAttribute("point", tmp))
					{
						xml::ElementPtr prop = newnode->createChild("Property");
						prop->addAttribute("key", "Point");
						prop->addAttribute("value", tmp);
					}

					if (info->findAttribute("size", tmp))
					{
						xml::ElementPtr prop = newnode->createChild("Property");
						prop->addAttribute("key", "Size");
						prop->addAttribute("value", tmp);
					}

					if (info->findAttribute("resource", tmp))
					{
						xml::ElementPtr prop = newnode->createChild("Property");
						prop->addAttribute("key", "Resource");
						prop->addAttribute("value", tmp);
					}

					if (info->findAttribute("offset", tmp))
					{
						xml::ElementPtr prop = newnode->createChild("Property");
						prop->addAttribute("key", "Coord");
						prop->addAttribute("value", tmp);
					}

					if (!shared_text.empty() || !texture.empty())
					{
						xml::ElementPtr prop = newnode->createChild("Property");
						prop->addAttribute("key", "Texture");
						prop->addAttribute("value",  shared_text.empty() ? texture : shared_text);
					}

					ResourceManager::getInstance().loadFromXmlNode(root, _file, _version);
				}

			}
			else if (node->getName() == XML_TYPE_PROPERTY)
			{
				const std::string& key = node->findAttribute("key");
				const std::string& value = node->findAttribute("value");
				if (key == "Default")
					setDefaultPointer(value);
				else if (key == "Layer")
					setLayerName(value);
				else if (key == "Skin")
					mSkinName = value;
			}
		}

		if (!layer.empty())
			setLayerName(layer);

		if (!pointer.empty())
			setDefaultPointer(pointer);

	}