MyGUI
3.0.1
|
00001 00007 /* 00008 This file is part of MyGUI. 00009 00010 MyGUI is free software: you can redistribute it and/or modify 00011 it under the terms of the GNU Lesser General Public License as published by 00012 the Free Software Foundation, either version 3 of the License, or 00013 (at your option) any later version. 00014 00015 MyGUI is distributed in the hope that it will be useful, 00016 but WITHOUT ANY WARRANTY; without even the implied warranty of 00017 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00018 GNU Lesser General Public License for more details. 00019 00020 You should have received a copy of the GNU Lesser General Public License 00021 along with MyGUI. If not, see <http://www.gnu.org/licenses/>. 00022 */ 00023 #include "MyGUI_Precompiled.h" 00024 #include "MyGUI_ResourceManualPointer.h" 00025 #include "MyGUI_StaticImage.h" 00026 #include "MyGUI_CoordConverter.h" 00027 #include "MyGUI_TextureUtility.h" 00028 00029 namespace MyGUI 00030 { 00031 00032 void ResourceManualPointer::deserialization(xml::ElementPtr _node, Version _version) 00033 { 00034 Base::deserialization(_node, _version); 00035 00036 IntCoord coord; 00037 00038 // берем детей и крутимся, основной цикл 00039 xml::ElementEnumerator info = _node->getElementEnumerator(); 00040 while (info.next("Property")) 00041 { 00042 const std::string& key = info->findAttribute("key"); 00043 const std::string& value = info->findAttribute("value"); 00044 00045 if (key == "Point") mPoint = IntPoint::parse(value); 00046 else if (key == "Size") mSize = IntSize::parse(value); 00047 else if (key == "Texture") mTexture = value; 00048 else if (key == "Coord") coord = IntCoord::parse(value); 00049 } 00050 00051 mOffset = CoordConverter::convertTextureCoord( 00052 coord, 00053 texture_utility::getTextureSize(mTexture)); 00054 } 00055 00056 void ResourceManualPointer::setImage(StaticImage* _image) 00057 { 00058 _image->deleteAllItems(); 00059 _image->_setTextureName(mTexture); 00060 _image->_setUVSet(mOffset); 00061 } 00062 00063 void ResourceManualPointer::setPosition(StaticImage* _image, const IntPoint& _point) 00064 { 00065 _image->setCoord(_point.left - mPoint.left, _point.top - mPoint.top, mSize.width, mSize.height); 00066 } 00067 00068 } // namespace MyGUI