diff --git a/code/nel/include/nel/gui/interface_parser.h b/code/nel/include/nel/gui/interface_parser.h index 060e2395a..7167757a2 100644 --- a/code/nel/include/nel/gui/interface_parser.h +++ b/code/nel/include/nel/gui/interface_parser.h @@ -100,6 +100,20 @@ namespace NLGUI virtual void setupOptions() = 0; }; + + struct VariableData + { + std::string entry; + std::string type; + std::string value; + uint32 size; + + VariableData() + { + size = 0; + } + }; + CInterfaceParser(); virtual ~CInterfaceParser(); @@ -333,6 +347,7 @@ namespace NLGUI std::map< uint32, SLinkData > links; bool editorMode; + std::map< std::string, VariableData > variableCache; public: void initLUA(); @@ -358,6 +373,8 @@ namespace NLGUI void updateLinkData( uint32 id, const SLinkData &linkData ); void setEditorMode( bool b ){ editorMode = b; } + + bool serializeVariables( xmlNodePtr parentNode ) const; }; } diff --git a/code/nel/include/nel/gui/parser.h b/code/nel/include/nel/gui/parser.h index 5cc2652d4..bfc9d2628 100644 --- a/code/nel/include/nel/gui/parser.h +++ b/code/nel/include/nel/gui/parser.h @@ -82,6 +82,7 @@ namespace NLGUI virtual void removeLinkData( uint32 id ) = 0; virtual bool getLinkData( uint32 id, SLinkData &linkData ) = 0; virtual void updateLinkData( uint32 id, const SLinkData &linkData ) = 0; + virtual bool serializeVariables( xmlNodePtr parentNode ) const = 0; }; } diff --git a/code/nel/src/gui/interface_parser.cpp b/code/nel/src/gui/interface_parser.cpp index 608035771..c579fa8da 100644 --- a/code/nel/src/gui/interface_parser.cpp +++ b/code/nel/src/gui/interface_parser.cpp @@ -1061,7 +1061,9 @@ namespace NLGUI value = entry; } else + { value = string((const char*)ptr); + } // Array definition sint size= 1; @@ -1073,6 +1075,7 @@ namespace NLGUI { ArrayMode= true; fromString((const char*)ptr, size); + string::size_type pos= entry.find("$i"); if( pos==string::npos ) { @@ -1118,6 +1121,24 @@ namespace NLGUI } } + if( editorMode ) + { + VariableData data; + + data.entry = entry; + data.type = type; + + ptr = xmlGetProp( cur, BAD_CAST "value" ); + if( ptr != NULL ) + data.value = std::string( ptr ); + + ptr = xmlGetProp( cur, BAD_CAST "size" ); + if( ptr != NULL ) + fromString( std::string( ptr ), data.size ); + + variableCache[ data.entry ] = data; + } + return true; } @@ -2557,6 +2578,7 @@ namespace NLGUI NLMISC::contReset (_ParentSizesMap); NLMISC::contReset (_ParentSizesMaxMap); NLMISC::contReset (_LuaClassAssociation); + variableCache.clear(); } @@ -2917,5 +2939,38 @@ namespace NLGUI return; itr->second = linkData; } + + + bool CInterfaceParser::serializeVariables( xmlNodePtr parentNode ) const + { + if( parentNode == NULL ) + return false; + + xmlNodePtr node = NULL; + + std::map< std::string, VariableData >::const_iterator itr; + for( itr = variableCache.begin(); itr != variableCache.end(); ++itr ) + { + const VariableData &data = itr->second; + + node = xmlNewNode( NULL, BAD_CAST "variable" ); + if( node == NULL ) + return false; + + xmlAddChild( parentNode, node ); + + xmlSetProp( node, BAD_CAST "entry", BAD_CAST data.entry.c_str() ); + xmlSetProp( node, BAD_CAST "type", BAD_CAST data.type.c_str() ); + + if( !data.value.empty() ) + xmlSetProp( node, BAD_CAST "value", BAD_CAST data.value.c_str() ); + + if( data.size != 0 ) + xmlSetProp( node, BAD_CAST "size", BAD_CAST toString( data.size ).c_str() ); + + } + + return true; + } } diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/widget_serializer.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/widget_serializer.cpp index bd7428ee6..9fe1268f9 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/widget_serializer.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/widget_serializer.cpp @@ -43,6 +43,13 @@ namespace GUIEditor return false; } + if( !CWidgetManager::getInstance()->getParser()->serializeVariables( root ) ) + { + xmlFreeNode( root ); + out.close(); + return false; + } + if( !CWidgetManager::getInstance()->serializeOptions( root ) ) { xmlFreeNode( root );