From c532f23ac137c0259e9199344b46bbe23562f644 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Sat, 18 Aug 2012 18:39:45 +0200 Subject: [PATCH] CHANGED: #1471 Pointer settings are now parsed even when the particular pointer cannot be instantiated. They are also serialized when serializing the GUI. --HG-- branch : gsoc2012-gui-editor --- code/nel/include/nel/gui/interface_parser.h | 3 ++ code/nel/include/nel/gui/parser.h | 1 + code/nel/src/gui/interface_parser.cpp | 49 +++++++++++++++++++ .../plugins/gui_editor/widget_serializer.cpp | 8 +++ 4 files changed, 61 insertions(+) diff --git a/code/nel/include/nel/gui/interface_parser.h b/code/nel/include/nel/gui/interface_parser.h index d74a372de..7b32c59e7 100644 --- a/code/nel/include/nel/gui/interface_parser.h +++ b/code/nel/include/nel/gui/interface_parser.h @@ -150,6 +150,7 @@ namespace NLGUI bool parseLUAScript (xmlNodePtr cur); bool setupTree (xmlNodePtr cur, CWidgetManager::SMasterGroup *parentGroup); bool setupTreeNode (xmlNodePtr cur, CGroupContainer *parentGroup); + void savePointerSettings( xmlNodePtr node ); void addModule( std::string name, IParserModule *module ); IParserModule* getModuleFor( std::string name ) const; @@ -348,6 +349,7 @@ namespace NLGUI bool editorMode; std::map< std::string, VariableData > variableCache; + std::map< std::string, std::string > pointerSettings; public: void initLUA(); @@ -376,6 +378,7 @@ namespace NLGUI bool serializeVariables( xmlNodePtr parentNode ) const; bool serializeProcs( xmlNodePtr parentNode ) const; + bool serializePointerSettings( xmlNodePtr parentNode ) const; }; } diff --git a/code/nel/include/nel/gui/parser.h b/code/nel/include/nel/gui/parser.h index 868a06c2b..21a2300d6 100644 --- a/code/nel/include/nel/gui/parser.h +++ b/code/nel/include/nel/gui/parser.h @@ -84,6 +84,7 @@ namespace NLGUI virtual void updateLinkData( uint32 id, const SLinkData &linkData ) = 0; virtual bool serializeVariables( xmlNodePtr parentNode ) const = 0; virtual bool serializeProcs( xmlNodePtr parentNode ) const = 0; + virtual bool serializePointerSettings( xmlNodePtr parentNode ) const = 0; }; } diff --git a/code/nel/src/gui/interface_parser.cpp b/code/nel/src/gui/interface_parser.cpp index 90b2c3953..7d81c3504 100644 --- a/code/nel/src/gui/interface_parser.cpp +++ b/code/nel/src/gui/interface_parser.cpp @@ -1363,6 +1363,9 @@ namespace NLGUI if ( !strcmp(ptr,"pointer")) { + if( editorMode ) + savePointerSettings( cur ); + CWidgetManager::getInstance()->setPointer( dynamic_cast(view) ); } @@ -1552,6 +1555,27 @@ namespace NLGUI return true; } + void CInterfaceParser::savePointerSettings( xmlNodePtr node ) + { + if( node == NULL ) + return; + + xmlAttrPtr prop = node->properties; + + std::string key; + std::string value; + + while( prop != NULL ) + { + key = std::string( reinterpret_cast< const char* >( prop->name ) ); + value = std::string( reinterpret_cast< char* >( prop->children->content ) ); + + pointerSettings[ key ] = value; + + prop = prop->next; + } + } + void CInterfaceParser::addModule( std::string name, IParserModule *module ) { std::map< std::string, IParserModule* >::iterator itr = @@ -2582,6 +2606,7 @@ namespace NLGUI NLMISC::contReset (_ParentSizesMaxMap); NLMISC::contReset (_LuaClassAssociation); variableCache.clear(); + pointerSettings.clear(); } @@ -3022,5 +3047,29 @@ namespace NLGUI return true; } + + + bool CInterfaceParser::serializePointerSettings( xmlNodePtr parentNode ) const + { + if( parentNode == NULL ) + return false; + + xmlNodePtr node = xmlNewNode( NULL, BAD_CAST "view" ); + if( node == NULL ) + return false; + + xmlAddChild( parentNode, node ); + + std::map< std::string, std::string >::const_iterator itr; + for( itr = pointerSettings.begin(); itr != pointerSettings.end(); ++itr ) + { + const std::string &key = itr->first; + const std::string &value = itr->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 097055dca..ceaa76c7d 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 @@ -51,6 +51,14 @@ namespace GUIEditor } + if( !CWidgetManager::getInstance()->getParser()->serializePointerSettings( root ) ) + { + xmlFreeNode( root ); + out.close(); + return false; + } + + if( !CWidgetManager::getInstance()->getParser()->serializeVariables( root ) ) { xmlFreeNode( root );