WidgetInfo ResourceLayout::parseWidget(xml::ElementEnumerator& _widget) { WidgetInfo widgetInfo; std::string tmp; _widget->findAttribute("type", widgetInfo.type); _widget->findAttribute("skin", widgetInfo.skin); _widget->findAttribute("layer", widgetInfo.layer); if (_widget->findAttribute("align", tmp)) widgetInfo.align = Align::parse(tmp); _widget->findAttribute("name", widgetInfo.name); if (_widget->findAttribute("style", tmp)) widgetInfo.style = WidgetStyle::parse(tmp); IntCoord coord; if (_widget->findAttribute("position", tmp)) { widgetInfo.intCoord = IntCoord::parse(tmp); widgetInfo.positionType = WidgetInfo::Pixels; } else if (_widget->findAttribute("position_real", tmp)) { widgetInfo.floatCoord = FloatCoord::parse(tmp); widgetInfo.positionType = WidgetInfo::Relative; } // берем детей и крутимся xml::ElementEnumerator node = _widget->getElementEnumerator(); while (node.next()) { if (node->getName() == "Widget") { widgetInfo.childWidgetsInfo.push_back(parseWidget(node)); } else if (node->getName() == "Property") { widgetInfo.properties.push_back(PairString(node->findAttribute("key"), node->findAttribute("value"))); } else if (node->getName() == "UserString") { widgetInfo.userStrings[node->findAttribute("key")] = node->findAttribute("value"); } else if (node->getName() == "Controller") { ControllerInfo controllerInfo; controllerInfo.type = node->findAttribute("type"); xml::ElementEnumerator prop = node->getElementEnumerator(); while (prop.next("Property")) { controllerInfo.properties[prop->findAttribute("key")] = prop->findAttribute("value"); } } } return widgetInfo; }
ResourceImageSet::ResourceImageSet(xml::ElementEnumerator _node, Version _version) : IResource(_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); }; mGroups.push_back(group); }; }