MyGUI 3.5.3
MyGUI_CommonStateInfo.cpp
Go to the documentation of this file.
1/*
2 * This source file is part of MyGUI. For the latest info, see http://mygui.info/
3 * Distributed under the MIT License
4 * (See accompanying file COPYING.MIT or copy at http://opensource.org/licenses/MIT)
5 */
6
8#include "MyGUI_XmlDocument.h"
10
11#include <pugixml.hpp>
12
13namespace MyGUI
14{
15
16 void SubSkinStateInfo::deserialization(xml::ElementPtr _node, Version _version)
17 {
18 std::string texture{_node.node().parent().parent().attribute("texture").value()};
19
20 // tags replacement support for Skins
21 if (_version >= Version(1, 1))
22 {
23 texture = LanguageManager::getInstance().replaceTags(texture);
24 }
25
26 const IntSize& size = RenderManager::getInstance().getTextureSize(texture);
27 IntCoord coord = IntCoord::parse(_node.node().attribute("offset").value());
28 mRect = CoordConverter::convertTextureCoord(coord, size);
29 }
30
31 void TileRectStateInfo::deserialization(xml::ElementPtr _node, Version _version)
32 {
33 std::string texture{_node.node().parent().parent().attribute("texture").value()};
34
35 // tags replacement support for Skins
36 if (_version >= Version(1, 1))
37 {
38 texture = LanguageManager::getInstance().replaceTags(texture);
39 }
40
41 const IntSize& size = RenderManager::getInstance().getTextureSize(texture);
42 IntCoord coord = IntCoord::parse(_node.node().attribute("offset").value());
43 mRect = CoordConverter::convertTextureCoord(coord, size);
44
45 for (auto prop : _node.node().children("Property"))
46 {
47 std::string_view key = prop.attribute("key").value();
48 std::string_view value = prop.attribute("value").value();
49 if (key == "TileH")
50 mTileH = utility::parseBool(value);
51 else if (key == "TileV")
52 mTileV = utility::parseBool(value);
53 else if (key == "TileSize")
54 mTileSize = IntSize::parse(value);
55 }
56 }
57
58#ifndef MYGUI_DONT_USE_OBSOLETE
59 void RotatingSkinStateInfo::deserialization(xml::ElementPtr _node, Version _version)
60 {
61 for (auto prop : _node.node().children("Property"))
62 {
63 std::string_view key = prop.attribute("key").value();
64 std::string_view value = prop.attribute("value").value();
65 if (key == "Angle")
66 mAngle = utility::parseFloat(value);
67 if (key == "Center")
68 mCenter = IntPoint::parse(value);
69 }
70
71 std::string texture{_node.node().parent().parent().attribute("texture").value()};
72
73 // tags replacement support for Skins
74 if (_version >= Version(1, 1))
75 {
76 texture = LanguageManager::getInstance().replaceTags(texture);
77 }
78
79 const IntSize& size = RenderManager::getInstance().getTextureSize(texture);
80 IntCoord coord = IntCoord::parse(_node.node().attribute("offset").value());
81 mRect = CoordConverter::convertTextureCoord(coord, size);
82 }
83#endif // MYGUI_DONT_USE_OBSOLETE
84
85 void EditTextStateInfo::deserialization(xml::ElementPtr _node, Version _version)
86 {
87 mShift = utility::parseBool(_node.node().attribute("shift").value());
88
89 std::string colour{_node.node().attribute("colour").value()};
90 if (_version >= Version(1, 1))
91 {
92 colour = LanguageManager::getInstance().replaceTags(colour);
93 }
94
95 mColour = Colour::parse(colour);
96 }
97
98} // namespace MyGUI
bool parseBool(std::string_view _value)
float parseFloat(std::string_view _value)
types::TCoord< int > IntCoord
Definition MyGUI_Types.h:35
types::TSize< int > IntSize
Definition MyGUI_Types.h:29
static TCoord< int > parse(std::string_view _value)
static TPoint< int > parse(std::string_view _value)
static TSize< int > parse(std::string_view _value)