diff options
author | rachytski <siarhei.rachytski@gmail.com> | 2012-11-09 17:40:13 +0400 |
---|---|---|
committer | Alex Zolotarev <alex@maps.me> | 2015-09-23 01:46:45 +0300 |
commit | bcc94857d7b9f092148dea4a2a9b90c592f43a75 (patch) | |
tree | 7bf4c63e9b28fd0b00dfdcffcada9bb2c637b935 /graphics/skin_loader.hpp | |
parent | 771f47410fa67f271cf425a2b1a9a0ed6119b4ea (diff) |
renamed yg into graphics.
Diffstat (limited to 'graphics/skin_loader.hpp')
-rw-r--r-- | graphics/skin_loader.hpp | 113 |
1 files changed, 113 insertions, 0 deletions
diff --git a/graphics/skin_loader.hpp b/graphics/skin_loader.hpp new file mode 100644 index 0000000000..6bbff02a34 --- /dev/null +++ b/graphics/skin_loader.hpp @@ -0,0 +1,113 @@ +/// @author Siarhei Rachytski +#pragma once + +//#include "resource_style.hpp" +//#include "skin.hpp" +//#include "../geometry/rect2d.hpp" +//#include "../base/base.hpp" +//#include "../std/string.hpp" +//#include "../std/list.hpp" +//#include "../std/map.hpp" +//#include "../std/vector.hpp" +#include "../std/shared_ptr.hpp" +//#include "../std/utility.hpp" + +/// @example +/// <?xml version="1.0" ?> +/// <skin> +/// <texture id="0" height="512" width="512" file="basic.png"> +/// <fontStyle charID="-1" xAdvance="17" xOffset="-1" yOffset="-7"> +/// <resourceStyle height="29" width="18" x="152" y="93"/> +/// </fontStyle> +/// ... +/// <fontStyle charID="35" xAdvance="23" xOffset="0" yOffset="-2"> +/// <resourceStyle height="25" width="23" x="537" y="171"/> +/// </fontStyle> +/// </texture> +/// <texture id="1" height="512" width="512" file="dejavu-sans-12pt.png"> +/// ... +/// </texture> +/// </skin> + +namespace graphics +{ + namespace gl + { + class BaseTexture; + } + + class ResourceManager; + class SkinPage; + struct ResourceStyle; + struct GlyphStyle; + + class SkinLoader + { + private: + + enum EMode + { + ERoot, + EPage, + ESkin, + EFontStyle, + EPointStyle, + ELineStyle, + EResourceStyle + }; + + list<EMode> m_mode; + +/// resourceStyle-specific parameters + int32_t m_id; + uint32_t m_texX; + uint32_t m_texY; + uint32_t m_texWidth; + uint32_t m_texHeight; + m2::RectU m_texRect; + +/// glyphInfo and glyphMaskInfo specific parameters + int8_t m_xOffset; + int8_t m_yOffset; + int8_t m_xAdvance; + + shared_ptr<GlyphStyle> m_glyphInfo; + shared_ptr<GlyphStyle> m_glyphMaskInfo; + +/// pointStyle-specific parameters + string m_styleID; + +/// skin-specific parameters + + vector<shared_ptr<SkinPage> > m_pages; + +/// skin-page specific parameters + string m_fileName; + + typedef list<pair<int32_t, shared_ptr<ResourceStyle> > > TStylesList; + + TStylesList m_stylesList; + + shared_ptr<ResourceManager> m_resourceManager; + Skin * m_skin; + + public: + + SkinLoader(shared_ptr<ResourceManager> const & resourceManager); + + bool Push(string const & element); + void Pop(string const & element); + void AddAttr(string const & attribute, string const & value); + void CharData(string const &) {} + + void popPointStyle(); + void popSkin(); + void pushPage(); + void popPage(); + + void pushResourceStyle(); + void popResourceStyle(); + + Skin * skin(); + }; +} |