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
This commit is contained in:
parent
0d4c4cd56d
commit
c532f23ac1
4 changed files with 61 additions and 0 deletions
|
@ -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;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -1363,6 +1363,9 @@ namespace NLGUI
|
|||
|
||||
if ( !strcmp(ptr,"pointer"))
|
||||
{
|
||||
if( editorMode )
|
||||
savePointerSettings( cur );
|
||||
|
||||
CWidgetManager::getInstance()->setPointer( dynamic_cast<CViewPointer*>(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;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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 );
|
||||
|
|
Loading…
Reference in a new issue