void WidgetTypes::loadValues(MyGUI::xml::ElementPtr _node, const std::string& _file, MyGUI::Version _version) { MyGUI::xml::ElementEnumerator widgets = _node->getElementEnumerator(); while (widgets.next("Value")) { std::string name = widgets->findAttribute("name"); PossibleValue* possible_value = getPossibleValue(name); // тип мерджа переменных std::string merge = widgets->findAttribute("merge"); // дополняем своими данными, по дефолту if (merge == "add") { } // удаляем и добавляем свои else if (merge == "replace") { possible_value->values.clear(); } // берем детей и крутимся MyGUI::xml::ElementEnumerator field = widgets->getElementEnumerator(); while (field.next()) { std::string key, value; if (field->getName() == "Property") { if (!field->findAttribute("key", key)) continue; possible_value->values.push_back(MyGUI::LanguageManager::getInstance().replaceTags(key)); } } } }
ResourceItemInfo::ResourceItemInfo(MyGUI::xml::ElementEnumerator _node, MyGUI::Version _version) : IResource(_node, _version) { MyGUI::xml::ElementEnumerator node = _node->getElementEnumerator(); while (node.next()) { if (node->getName() == "Name") mItemName = node->getContent(); else if (node->getName() == "Description") mItemDescription = node->getContent(); else if (node->getName() == "Image") mItemResourceImage = node->findAttribute("RefID"); }; }
void PanelControllers::loadControllerTypes(MyGUI::xml::ElementPtr _node, const std::string& _file, MyGUI::Version _version) { MyGUI::xml::ElementEnumerator controller = _node->getElementEnumerator(); while (controller.next("Controller")) { MyGUI::MapString controllerProperties; std::string name = controller->findAttribute("name"); mControllerName->addItem(name); MyGUI::xml::ElementEnumerator prop = controller->getElementEnumerator(); while (prop.next("Property")) controllerProperties[prop->findAttribute("key")] = prop->findAttribute("type"); mControllersProperties[name] = controllerProperties; } }
void PropertiesPanelView::load(MyGUI::xml::ElementEnumerator _field) { MyGUI::xml::ElementEnumerator field = _field->getElementEnumerator(); VectorPanel::iterator iter = mPanels.begin(); while (field.next()) { std::string key, value; if (field->getName() == "Property") { if (false == field->findAttribute("key", key)) continue; if (false == field->findAttribute("value", value)) continue; if ((key == MyGUI::utility::toString("Panel"/*, i*/,"Minimized")) && (iter != mPanels.end())) { (*iter)->getPanelCell()->setMinimized(MyGUI::utility::parseBool(value)); ++iter; } } } }
//=================================================================================== bool EditorState::isNeedSolutionLoad(MyGUI::xml::ElementEnumerator _field) { MyGUI::xml::ElementEnumerator field = _field->getElementEnumerator(); while (field.next()) { std::string key, value; if (field->getName() == "Property") { if (!field->findAttribute("key", key)) continue; if (!field->findAttribute("value", value)) continue; if (key == "MetaSolutionName") { return !value.empty(); } } } return false; }
void HotKeyManager::loadXml(MyGUI::xml::ElementPtr _node, const std::string& _file, MyGUI::Version _version) { MyGUI::xml::ElementEnumerator node = _node->getElementEnumerator(); while (node.next("Command")) { HotKeyCommand command; MyGUI::xml::ElementEnumerator nodeCommand = node->getElementEnumerator(); while (nodeCommand.next()) { if (nodeCommand->getName() == "Name") { command.setCommand(nodeCommand->getContent()); } /*else if (nodeCommand->getName() == "Pressed") { command.setPressed(MyGUI::utility::parseValue<bool>(nodeCommand->getContent())); }*/ else if (nodeCommand->getName() == "KeyCode") { MapKeys::const_iterator item = mKeyNames.find(nodeCommand->getContent()); if (item != mKeyNames.end()) { command.setKey((*item).second); } else { // log } } else if (nodeCommand->getName() == "Modifier") { command.setShift(nodeCommand->getContent().find("Shift") != std::string::npos); command.setControl(nodeCommand->getContent().find("Control") != std::string::npos); } } addCommand(command); } }
void DemoKeeper::loadFromFile(const std::string& _filename) { MyGUI::xml::Document doc; if (!doc.open(_filename)) return; MyGUI::xml::ElementPtr root = doc.getRoot(); if (root == nullptr || root->getName() != "AnimationGraph") return; MyGUI::xml::ElementEnumerator node = root->getElementEnumerator(); while (node.next()) { if (node->getName() == "Node") { BaseAnimationNode* anim_node = createNode(node->findAttribute("type"), node->findAttribute("name")); anim_node->deserialization(node.current()); } else if (node->getName() == "Connections") { MyGUI::xml::ElementEnumerator conn = node->getElementEnumerator(); BaseAnimationNode* anim_node = getNodeByName(node.current()->findAttribute("node")); if (anim_node) { while (conn.next("Connection")) { BaseAnimationNode* anim_node2 = getNodeByName(conn.current()->findAttribute("node")); if (anim_node2) { //соединить точки в ноде const std::string& from_point = conn.current()->findAttribute("from"); const std::string& to_point = conn.current()->findAttribute("to"); wraps::BaseGraphConnection* from_conn = anim_node->getConnectionByName(from_point, "EventOut"); if (!from_conn) from_conn = anim_node->getConnectionByName(from_point, "PositionOut"); if (!from_conn) from_conn = anim_node->getConnectionByName(from_point, "WeightOut"); wraps::BaseGraphConnection* to_conn = anim_node2->getConnectionByName(to_point, "EventIn"); if (!to_conn) to_conn = anim_node2->getConnectionByName(to_point, "PositionIn"); if (!to_conn) to_conn = anim_node2->getConnectionByName(to_point, "WeightIn"); if (from_conn && to_conn) { from_conn->addConnectionPoint(to_conn); connectPoints(anim_node, anim_node2, from_point, to_point); } } } } } else if (node->getName() == "EditorData") { MyGUI::xml::ElementEnumerator item_data = node->getElementEnumerator(); while (item_data.next("Node")) { BaseAnimationNode* anim_node = getNodeByName(item_data.current()->findAttribute("name")); if (anim_node) { anim_node->setCoord(MyGUI::IntCoord::parse(item_data.current()->findAttribute("coord"))); } } } } }
void WidgetTypes::loadWidgets(MyGUI::xml::ElementPtr _node, const std::string& _file, MyGUI::Version _version) { MyGUI::xml::ElementEnumerator widgets = _node->getElementEnumerator(); while (widgets.next("Widget")) { WidgetStyle* widget_type = getWidgetType(widgets->findAttribute("name")); widget_type->internalType = widgets->findAttribute("internal") == "true"; // берем детей и крутимся MyGUI::xml::ElementEnumerator field = widgets->getElementEnumerator(); while (field.next()) { std::string key, value, group; if (field->getName() == "Property") { if (!field->findAttribute("key", key)) continue; if (!field->findAttribute("value", value)) continue; field->findAttribute("group", group); if (key == "Skin") { std::string button_name = field->findAttribute("name"); if (button_name.empty()) button_name = value; if (group.empty()) group = DEFAULT_GOROUP_NAME; mSkinGroups[group].push_back(SkinInfo(value, widget_type->name, button_name)); widget_type->skin.push_back(value); } else if (key == "DefaultSkin") widget_type->default_skin = value; else if (key == "Parent") widget_type->parent = MyGUI::utility::parseBool(value); else if (key == "Child") widget_type->child = MyGUI::utility::parseBool(value); else if (key == "Resizeable") widget_type->resizeable = MyGUI::utility::parseBool(value); else if (key == "ItemManager") widget_type->many_items = MyGUI::utility::parseBool(value); else if (key == "Base") widget_type->base = value; } else if (field->getName() == "Parameter") { if (!field->findAttribute("key", key)) continue; if (!field->findAttribute("value", value)) continue; widget_type->parameter.push_back(MyGUI::PairString(key, value)); } else if (field->getName() == "TemplateData") { if (!field->findAttribute("key", key)) continue; if (!field->findAttribute("value", value)) continue; widget_type->templateData.push_back(MyGUI::PairString(key, value)); } else if (field->getName() == "ParameterData") { if (!field->findAttribute("key", key)) continue; if (!field->findAttribute("value", value)) continue; widget_type->parameterData.push_back(MyGUI::PairString(key, value)); } } if (widget_type->base.empty() && widget_type->name != "Widget") widget_type->base = "Widget"; } updateDeep(); }
void ExportManager::convertSkin(MyGUI::xml::Element* _from, MyGUI::xml::Element* _to) { _to->addAttribute("type", "ResourceSkin"); _to->addAttribute("name", _from->findAttribute("name")); MyGUI::xml::ElementEnumerator nodes = _from->getElementEnumerator(); while (nodes.next()) { MyGUI::UString coordValue; MyGUI::UString textureValue; MyGUI::xml::Element* node = nodes.current(); if (node->getName() == "PropertySet") { MyGUI::xml::ElementEnumerator propertyNodes = node->getElementEnumerator(); while (propertyNodes.next("Property")) { MyGUI::xml::Element* propertyNode = propertyNodes.current(); std::string name; if (propertyNode->findAttribute("name", name)) { if (name == "Coord") { MyGUI::IntCoord coord = MyGUI::IntCoord::parse(propertyNode->getContent()); coordValue = coord.size().print(); } else if (name == "Texture") { textureValue = propertyNode->getContent(); } } } _to->addAttribute("size", coordValue); _to->addAttribute("texture", textureValue); break; } else if (node->getName() == "RegionItem") { bool regionVisible = true; MyGUI::xml::ElementEnumerator regionNodes = node->getElementEnumerator(); while (regionNodes.next("PropertySet")) { MyGUI::xml::ElementEnumerator propertyNodes = regionNodes->getElementEnumerator(); while (propertyNodes.next("Property")) { MyGUI::xml::Element* propertyNode = propertyNodes.current(); std::string name; if (propertyNode->findAttribute("name", name)) { if (name == "Visible") { if (propertyNode->getContent() != "True") regionVisible = false; } else if (name == "Enabled") { if (propertyNode->getContent() != "True") regionVisible = false; } } } break; } if (!regionVisible) continue; MyGUI::xml::Element* region = _to->createChild("BasisSkin"); MyGUI::IntCoord regionCoord; MyGUI::UString regionTypeValue; MyGUI::UString regionOffsetValue; MyGUI::UString alignValue; regionNodes = node->getElementEnumerator(); while (regionNodes.next("PropertySet")) { MyGUI::xml::ElementEnumerator regionPropertyNode = regionNodes->getElementEnumerator(); while (regionPropertyNode.next("Property")) { std::string name; if (regionPropertyNode->findAttribute("name", name)) { if (name == "RegionType") { regionTypeValue = regionPropertyNode->getContent(); } else if (name == "Position") { regionCoord = MyGUI::IntCoord::parse(regionPropertyNode->getContent()); regionOffsetValue = regionCoord.print(); } else if (name == "Align") { alignValue = regionPropertyNode->getContent(); } } } bool tileHor = true; bool tileVer = true; if (regionTypeValue == "TileRect Hor") { regionTypeValue = "TileRect"; tileVer = false; } else if (regionTypeValue == "TileRect Ver") { regionTypeValue = "TileRect"; tileHor = false; } region->addAttribute("type", regionTypeValue); region->addAttribute("offset", regionOffsetValue); region->addAttribute("align", alignValue); MyGUI::xml::ElementEnumerator stateNodes = _from->getElementEnumerator(); while (stateNodes.next("StateItem")) { bool stateVisible = true; MyGUI::xml::ElementEnumerator propertySetNodes = stateNodes->getElementEnumerator(); while (propertySetNodes.next("PropertySet")) { MyGUI::xml::ElementEnumerator statePropertyNode = propertySetNodes->getElementEnumerator(); while (statePropertyNode.next("Property")) { std::string name; if (statePropertyNode->findAttribute("name", name)) { if (name == "Visible") { if (statePropertyNode->getContent() != "True") stateVisible = false; } } } break; } if (!stateVisible) continue; MyGUI::xml::Element* state = region->createChild("State"); MyGUI::UString stateOffsetValue; MyGUI::UString textColourValue; MyGUI::UString textShiftValue; propertySetNodes = stateNodes->getElementEnumerator(); while (propertySetNodes.next("PropertySet")) { MyGUI::xml::ElementEnumerator propertyNodes = propertySetNodes->getElementEnumerator(); while (propertyNodes.next("Property")) { MyGUI::xml::Element* propertyNode = propertyNodes.current(); std::string name; if (propertyNode->findAttribute("name", name)) { if (name == "Position") { MyGUI::IntCoord coord = regionCoord + MyGUI::IntPoint::parse(propertyNode->getContent()); stateOffsetValue = coord.print(); } else if (name == "TextColour") { textColourValue = propertyNode->getContent(); } else if (name == "TextShift") { textShiftValue = propertyNode->getContent(); } } } break; } MyGUI::UString stateNameValue = stateNodes->findAttribute("name"); state->addAttribute("name", convertStateName(stateNameValue)); if (regionTypeValue == "SimpleText" || regionTypeValue == "EditText") { state->addAttribute("colour", textColourValue); state->addAttribute("shift", textShiftValue); } else { state->addAttribute("offset", stateOffsetValue); if (stateNameValue == "Normal") { if (regionTypeValue == "TileRect") { MyGUI::xml::Element* prop = state->createChild("Property"); prop->addAttribute("key", "TileSize"); prop->addAttribute("value", regionCoord.size().print()); prop = state->createChild("Property"); prop->addAttribute("key", "TileH"); prop->addAttribute("value", MyGUI::utility::toString(tileHor)); prop = state->createChild("Property"); prop->addAttribute("key", "TileV"); prop->addAttribute("value", MyGUI::utility::toString(tileVer)); } } } } break; } } } }
bool BaseManager::loadBase( const string& filename, LuaVector& doScript, LuaVector& locationScript, LuaVector& loadScript ) { MyGUI::xml::Document doc; if( !doc.open(mResourcePath+filename) ) { if( !doc.open(filename) ) { MyGUI::IDataStream* pdata = MyGUI::DataManager::getInstance().getData(filename); if( pdata ) { if( !doc.open(pdata) ) { MyGUI::DataManager::getInstance().freeData(pdata); ERROR_LOG(doc.getLastError()); return false; } MyGUI::DataManager::getInstance().freeData(pdata); } else { ERROR_LOG(doc.getLastError()); return false; } } } MyGUI::xml::ElementPtr root = doc.getRoot(); if (root == nullptr || root->getName() != "base") return false; // LuaVector groups; MyGUI::xml::ElementEnumerator node = root->getElementEnumerator(); while( node.next() ) { string name = node->getName(); if( name == "script" ) { string lua; if( node->findAttribute("do",lua) ) doScript.push_back( lua ); //等到LuaManager被创建后在一起执行 if( node->findAttribute("location",lua) ) { if( find(locationScript.begin(),locationScript.end(),lua)==locationScript.end() ) locationScript.push_back( lua ); } if( node->findAttribute("load",lua) ) { loadScript.push_back(lua); } } else if( name == "group" ) { string name; if( node->findAttribute("name",name) ) { // if( find(groups.begin(),groups.end(),name)==groups.end() ) // groups.push_back(name); MyGUI::xml::ElementEnumerator child = node->getElementEnumerator(); while( child.next() ) { string type,location,recursive; if( child->getName() == "repository" ) { if( child->findAttribute("type",type) && child->findAttribute("recursive",recursive) && child->findAttribute("location",location) ) { //加入组 addGroupLocation(name,type,location,recursive=="true"?true:false); } } } } } } return true; }