xmlpp::Element* cRokko::Save_To_XML_Node(xmlpp::Element* p_element) { xmlpp::Element* p_node = cEnemy::Save_To_XML_Node(p_element); Add_Property(p_node, "direction", Get_Direction_Name(m_start_direction)); Add_Property(p_node, "speed", m_speed); return p_node; }
xmlpp::Element* cFlyon::Save_To_XML_Node(xmlpp::Element* p_element) { xmlpp::Element* p_node = cEnemy::Save_To_XML_Node(p_element); Add_Property(p_node, "direction", Get_Direction_Name(m_start_direction)); Add_Property(p_node, "image_dir", path_to_utf8(m_img_dir)); Add_Property(p_node, "max_distance", static_cast<int>(m_max_distance)); Add_Property(p_node, "speed", m_speed); return p_node; }
xmlpp::Element* cBonusBox::Save_To_XML_Node(xmlpp::Element* p_element) { xmlpp::Element* p_node = cBaseBox::Save_To_XML_Node(p_element); // force best possible item Add_Property(p_node, "force_best_item", m_force_best_item); // gold color if (box_type == TYPE_GOLDPIECE) Add_Property(p_node, "gold_color", Get_Color_Name(m_gold_color)); return p_node; }
//--------------------------------------------------------- void CSG_MetaData::_Load(wxXmlNode *pNode) { m_Name = pNode->GetName ().wc_str(); m_Content = pNode->GetNodeContent().wc_str(); //----------------------------------------------------- wxXmlAttribute *pProperty = pNode->GetAttributes(); while( pProperty ) { Add_Property(&pProperty->GetName(), &pProperty->GetValue()); pProperty = pProperty->GetNext(); } //----------------------------------------------------- wxXmlNode *pChild = pNode->GetChildren(); while( pChild ) { if( pChild->GetType() != wxXML_TEXT_NODE ) { Add_Child()->_Load(pChild); } pChild = pChild->GetNext(); } }
//--------------------------------------------------------- void CSG_MetaData::_Load(wxXmlNode *pNode) { Set_Name (SG_UTF8_To_String(pNode->GetName ()).c_str()); Set_Content (SG_UTF8_To_String(pNode->GetNodeContent()).c_str()); //----------------------------------------------------- wxXmlProperty *pProperty = pNode->GetProperties(); while( pProperty ) { Add_Property(SG_UTF8_To_String(pProperty->GetName()).c_str(), SG_UTF8_To_String(pProperty->GetValue()).c_str()); pProperty = pProperty->GetNext(); } //----------------------------------------------------- wxXmlNode *pChild = pNode->GetChildren(); while( pChild ) { if( pChild->GetType() != wxXML_TEXT_NODE ) { Add_Child()->_Load(pChild); } pChild = pChild->GetNext(); } }
//--------------------------------------------------------- bool CSG_MetaData::Assign(const CSG_MetaData &MetaData, bool bAppend) { int i; if( !bAppend ) { Destroy(); Set_Name (MetaData.Get_Name ()); Set_Content (MetaData.Get_Content()); //------------------------------------------------- for(i=0; i<MetaData.Get_Property_Count(); i++) { Add_Property(MetaData.Get_Property_Name(i), MetaData.Get_Property(i)); } } //----------------------------------------------------- for(i=0; i<MetaData.Get_Children_Count(); i++) { Add_Child()->Assign(*MetaData.Get_Child(i), false); } return( true ); }
xmlpp::Element* cText_Box::Save_To_XML_Node(xmlpp::Element* p_element) { xmlpp::Element* p_node = cBaseBox::Save_To_XML_Node(p_element); // text Add_Property(p_node, "text", m_text); return p_node; }
xmlpp::Element* cRandom_Sound::Save_To_XML_Node(xmlpp::Element* p_element) { xmlpp::Element* p_node = cSprite::Save_To_XML_Node(p_element); // filename Add_Property(p_node, "file", m_filename); // continuous Add_Property(p_node, "continuous", m_continuous); // delay Add_Property(p_node, "delay_min", m_delay_min); Add_Property(p_node, "delay_max", m_delay_max); // volume Add_Property(p_node, "volume_min", m_volume_min); Add_Property(p_node, "volume_max", m_volume_max); // volume reduction Add_Property(p_node, "volume_reduction_begin", m_volume_reduction_begin); Add_Property(p_node, "volume_reduction_end", m_volume_reduction_end); return p_node; }
//--------------------------------------------------------- bool CSG_MetaData::Assign(const CSG_MetaData &MetaData, bool bAddChildren) { if( &MetaData != this ) { Destroy(); Set_Name (MetaData.Get_Name ()); Set_Content (MetaData.Get_Content()); for(int i=0; i<MetaData.Get_Property_Count(); i++) { Add_Property(MetaData.Get_Property_Name(i), MetaData.Get_Property(i)); } if( bAddChildren ) { Add_Children(MetaData); } } return( true ); }
void cBackground::Save_To_XML_Node(xmlpp::Element* p_parent) { if (m_type == BG_NONE) return; // <background> xmlpp::Element* p_node = p_parent->add_child("background"); Add_Property(p_node, "type", m_type); // gradient if (m_type == BG_GR_HOR || m_type == BG_GR_VER) { // background color 1 Add_Property(p_node, "bg_color_1_red", static_cast<int>(m_color_1.red)); Add_Property(p_node, "bg_color_1_green", static_cast<int>(m_color_1.green)); Add_Property(p_node, "bg_color_1_blue", static_cast<int>(m_color_1.blue)); // background color 2 Add_Property(p_node, "bg_color_2_red", static_cast<int>(m_color_2.red)); Add_Property(p_node, "bg_color_2_green", static_cast<int>(m_color_2.green)); Add_Property(p_node, "bg_color_2_blue", static_cast<int>(m_color_2.blue)); } // image else if (m_type == BG_IMG_BOTTOM || m_type == BG_IMG_TOP || m_type == BG_IMG_ALL) { // position Add_Property(p_node, "posx", m_start_pos_x); Add_Property(p_node, "posy", m_start_pos_y); Add_Property(p_node, "posz", m_pos_z); // image filename Add_Property(p_node, "image", path_to_utf8(m_image_1_filename)); // speed Add_Property(p_node, "speedx", m_speed_x); Add_Property(p_node, "speedy", m_speed_y); // constant velocity Add_Property(p_node, "const_velx", m_const_vel_x); Add_Property(p_node, "const_vely", m_const_vel_y); } else std::cerr << "Warning: Detected unknown background type '" << m_type << "' on saving." << std::endl; // </background> }
bool CSG_MetaData::Add_Property(const CSG_String &Name, int Value) { return( Add_Property(Name, CSG_String::Format(SG_T("%d"), Value)) ); }