diff --git a/code/nel/include/nel/gui/interface_parser.h b/code/nel/include/nel/gui/interface_parser.h index 7b32c59e7..d733f8749 100644 --- a/code/nel/include/nel/gui/interface_parser.h +++ b/code/nel/include/nel/gui/interface_parser.h @@ -151,6 +151,7 @@ namespace NLGUI bool setupTree (xmlNodePtr cur, CWidgetManager::SMasterGroup *parentGroup); bool setupTreeNode (xmlNodePtr cur, CGroupContainer *parentGroup); void savePointerSettings( xmlNodePtr node ); + void saveKeySettings( xmlNodePtr node ); void addModule( std::string name, IParserModule *module ); IParserModule* getModuleFor( std::string name ) const; @@ -350,6 +351,7 @@ namespace NLGUI bool editorMode; std::map< std::string, VariableData > variableCache; std::map< std::string, std::string > pointerSettings; + std::map< std::string, std::map< std::string, std::string > > keySettings; public: void initLUA(); @@ -379,6 +381,7 @@ namespace NLGUI bool serializeVariables( xmlNodePtr parentNode ) const; bool serializeProcs( xmlNodePtr parentNode ) const; bool serializePointerSettings( xmlNodePtr parentNode ) const; + bool serializeKeySettings( xmlNodePtr parentNode ) const; }; } diff --git a/code/nel/include/nel/gui/parser.h b/code/nel/include/nel/gui/parser.h index 21a2300d6..a63b84f1b 100644 --- a/code/nel/include/nel/gui/parser.h +++ b/code/nel/include/nel/gui/parser.h @@ -85,6 +85,7 @@ namespace NLGUI virtual bool serializeVariables( xmlNodePtr parentNode ) const = 0; virtual bool serializeProcs( xmlNodePtr parentNode ) const = 0; virtual bool serializePointerSettings( xmlNodePtr parentNode ) const = 0; + virtual bool serializeKeySettings( xmlNodePtr parentNode ) const = 0; }; } diff --git a/code/nel/src/gui/interface_parser.cpp b/code/nel/src/gui/interface_parser.cpp index 7d81c3504..2d4fc64c4 100644 --- a/code/nel/src/gui/interface_parser.cpp +++ b/code/nel/src/gui/interface_parser.cpp @@ -478,6 +478,11 @@ namespace NLGUI // todo hulud interface syntax error nlwarning ("could not read all styles"); } + if( !strcmp((char*)curNode->name,"key" ) ) + { + if( editorMode ) + saveKeySettings( curNode ); + } // If define and style oks, try to parse "1st pass" objets (define, options....). else if ( !strcmp((char*)curNode->name,"template") ) { @@ -1576,6 +1581,43 @@ namespace NLGUI } } + void CInterfaceParser::saveKeySettings( xmlNodePtr node ) + { + if( node == NULL ) + return; + + xmlAttrPtr prop = node->properties; + + std::string name( reinterpret_cast< char* >( xmlGetProp( node, BAD_CAST "name" ) ) ); + if( name.empty() ) + return; + + std::string key; + std::string value; + std::map< std::string, std::string > propMap; + + while( prop != NULL ) + { + key = std::string( reinterpret_cast< const char* >( prop->name ) ); + value = std::string( reinterpret_cast< char* >( prop->children->content ) ); + + if( key == "name" ) + { + prop = prop->next; + continue; + } + + propMap[ key ] = value; + + prop = prop->next; + } + + if( propMap.empty() ) + return; + + keySettings[ name ] = propMap; + } + void CInterfaceParser::addModule( std::string name, IParserModule *module ) { std::map< std::string, IParserModule* >::iterator itr = @@ -3071,5 +3113,36 @@ namespace NLGUI return true; } + + + bool CInterfaceParser::serializeKeySettings( xmlNodePtr parentNode ) const + { + if( parentNode == NULL ) + return false; + + std::map< std::string, std::map< std::string, std::string > >::const_iterator itr; + for( itr = keySettings.begin(); itr != keySettings.end(); ++itr ) + { + xmlNodePtr node = xmlNewNode( NULL, BAD_CAST "key" ); + if( node == NULL ) + return false; + + xmlAddChild( parentNode, node ); + xmlSetProp( node, BAD_CAST "name", BAD_CAST itr->first.c_str() ); + + const std::map< std::string, std::string > &settings = itr->second; + + std::map< std::string, std::string >::const_iterator itr2; + for( itr2 = settings.begin(); itr2 != settings.end(); ++itr2 ) + { + const std::string &key = itr2->first; + const std::string &value = itr2->second; + + xmlSetProp( node, BAD_CAST key.c_str(), BAD_CAST value.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 ceaa76c7d..3601ab0c7 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 @@ -50,6 +50,13 @@ namespace GUIEditor return false; } + if( !CWidgetManager::getInstance()->getParser()->serializeKeySettings( root ) ) + { + xmlFreeNode( root ); + out.close(); + return false; + } + if( !CWidgetManager::getInstance()->getParser()->serializePointerSettings( root ) ) {