mirror of
https://port.numenaute.org/aleajactaest/khanat-code-old.git
synced 2024-11-23 07:16:15 +00:00
CHANGED: #1471 Keys are now parsed from the config files, and then serialized on save.
This commit is contained in:
parent
530a141bee
commit
c5a8cecf7e
4 changed files with 84 additions and 0 deletions
|
@ -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;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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 ) )
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue