1 // Object Viewer Qt GUI Editor plugin <http://dev.ryzom.com/projects/ryzom/>
2 // Copyright (C) 2010 Winch Gate Property Limited
4 // This source file has been modified by the following contributors:
5 // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) <dfighter1985@gmail.com>
7 // This program is free software: you can redistribute it and/or modify
8 // it under the terms of the GNU Affero General Public License as
9 // published by the Free Software Foundation, either version 3 of the
10 // License, or (at your option) any later version.
12 // This program is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // GNU Affero General Public License for more details.
17 // You should have received a copy of the GNU Affero General Public License
18 // along with this program. If not, see <http://www.gnu.org/licenses/>.
21 #include "widget_serializer.h"
22 #include "nel/gui/interface_group.h"
23 #include "nel/gui/widget_manager.h"
25 #include <libxml/xmlstring.h>
26 #include <libxml/tree.h>
30 bool WidgetSerializer::serialize( const std::string
&masterGroup
)
32 if( fileName
.empty() )
36 CWidgetManager::getInstance()->getMasterGroupFromId( masterGroup
);
41 CInterfaceElement
*ag
=
42 CWidgetManager::getInstance()->getElementFromId( activeGroup
);
46 out
.open( fileName
.c_str() );
50 xmlNodePtr root
= xmlNewNode( NULL
, BAD_CAST
"interface_config" );
57 if( mg
->serializeGroup( root
, "root" ) == NULL
)
64 if( !CWidgetManager::getInstance()->serializeOptions( root
) )
71 if( !CWidgetManager::getInstance()->getParser()->serializeKeySettings( root
) )
79 if( !CWidgetManager::getInstance()->getParser()->serializePointerSettings( root
) )
87 if( !CWidgetManager::getInstance()->getParser()->serializeVariables( root
) )
95 if( !CWidgetManager::getInstance()->getParser()->serializeProcs( root
) )
102 if( mg
->serializeSubGroups( root
) == NULL
)
104 ag
->setActive( true );
110 if( !mg
->serializeLinks( root
) )
117 if( !CWidgetManager::getInstance()->serializeTreeData( root
) )
125 serializeTree( root
);
134 bool WidgetSerializer::serializeTree( _xmlNode
*node
)
139 for( int i
= 0; i
< level
; i
++ )
140 tabs
.push_back( '\t' );
142 out
<< tabs
<< "<" << node
->name
;
144 xmlAttrPtr prop
= node
->properties
;
145 while( prop
!= NULL
)
148 std::string( reinterpret_cast< const char* >( prop
->name
) );
151 std::string( reinterpret_cast< const char* >( xmlGetProp( node
, BAD_CAST name
.c_str() ) ) );
153 out
<< " " << name
<< "=\"" << value
<< "\"" << std::endl
<< tabs
;
158 if( node
->children
!= NULL
)
160 out
<< tabs
<< ">" << std::endl
<< std::endl
;
162 xmlNodePtr child
= node
->children
;
163 while( child
!= NULL
)
165 serializeTree( child
);
169 out
<< tabs
<< "</" << node
->name
<< ">" << std::endl
<< std::endl
;
173 out
<< tabs
<< "/>" << std::endl
<< std::endl
;