mirror of
https://port.numenaute.org/aleajactaest/khanat-code-old.git
synced 2024-11-05 14:59:01 +00:00
CHANGED: #1471 CCtrlBase fields can now be serialized.
This commit is contained in:
parent
936260d54f
commit
5895d198d0
5 changed files with 60 additions and 7 deletions
|
@ -63,6 +63,8 @@ namespace NLGUI
|
|||
|
||||
void setProperty( const std::string &name, const std::string &value );
|
||||
|
||||
xmlNodePtr serialize( xmlNodePtr parentNode, const char *type ) const;
|
||||
|
||||
// special parse
|
||||
virtual bool parse(xmlNodePtr cur, CInterfaceGroup *parentGroup);
|
||||
|
||||
|
@ -171,6 +173,8 @@ namespace NLGUI
|
|||
THotSpot _ToolTipPosRefAlt : 6;
|
||||
protected:
|
||||
void convertTooltipHotSpot(const char *prop, THotSpot &parentHS, THotSpot &childHS);
|
||||
static std::string TooltipHotSpotToString( THotSpot parent, THotSpot child );
|
||||
|
||||
bool resizer;
|
||||
};
|
||||
|
||||
|
|
|
@ -127,7 +127,7 @@ namespace NLGUI
|
|||
|
||||
virtual void setProperty( const std::string &name, const std::string &value );
|
||||
|
||||
virtual bool serialize( xmlNodePtr parentNode, const char *type ) const;
|
||||
virtual xmlNodePtr serialize( xmlNodePtr parentNode, const char *type ) const;
|
||||
|
||||
/// Parse the element and initalize it
|
||||
virtual bool parse (xmlNodePtr cur, CInterfaceGroup *parentGroup);
|
||||
|
|
|
@ -313,6 +313,33 @@ namespace NLGUI
|
|||
CInterfaceElement::setProperty( name, value );
|
||||
}
|
||||
|
||||
|
||||
xmlNodePtr CCtrlBase::serialize( xmlNodePtr parentNode, const char *type ) const
|
||||
{
|
||||
xmlNodePtr node =
|
||||
CInterfaceElement::serialize( parentNode, type );
|
||||
|
||||
if( node == NULL )
|
||||
return NULL;
|
||||
|
||||
xmlNewProp( node, BAD_CAST "tooltip", BAD_CAST _ContextHelp.toString().c_str() );
|
||||
xmlNewProp( node, BAD_CAST "tooltip_i18n", BAD_CAST _ContextHelp.toString().c_str() );
|
||||
xmlNewProp( node, BAD_CAST "on_tooltip", BAD_CAST _OnContextHelp.toString().c_str() );
|
||||
xmlNewProp( node, BAD_CAST "on_tooltip_params", BAD_CAST _OnContextHelpParams.toString().c_str() );
|
||||
xmlNewProp( node, BAD_CAST "tooltip_parent", BAD_CAST tooltipParentToString( _ToolTipParent ).c_str() );
|
||||
xmlNewProp( node, BAD_CAST "tooltip_special_parent", BAD_CAST _ToolTipSpecialParent.toString().c_str() );
|
||||
|
||||
xmlNewProp( node, BAD_CAST "tooltip_posref",
|
||||
BAD_CAST TooltipHotSpotToString( _ToolTipParentPosRef, _ToolTipPosRef ).c_str() );
|
||||
|
||||
xmlNewProp( node, BAD_CAST "tooltip_posref_alt",
|
||||
BAD_CAST TooltipHotSpotToString( _ToolTipParentPosRefAlt, _ToolTipPosRefAlt ).c_str() );
|
||||
|
||||
xmlNewProp( node, BAD_CAST "instant_help", BAD_CAST toString( _ToolTipInstant ).c_str() );
|
||||
|
||||
return node;
|
||||
}
|
||||
|
||||
// ***************************************************************************
|
||||
void CCtrlBase::convertTooltipHotSpot(const char *prop, THotSpot &parentHS, THotSpot &childHS)
|
||||
{
|
||||
|
@ -339,6 +366,24 @@ namespace NLGUI
|
|||
}
|
||||
|
||||
|
||||
std::string CCtrlBase::TooltipHotSpotToString( THotSpot parent, THotSpot child )
|
||||
{
|
||||
std::string s;
|
||||
|
||||
if( ( parent == Hotspot_TTAuto ) && ( child == Hotspot_TTAuto ) )
|
||||
{
|
||||
s = "auto";
|
||||
}
|
||||
else
|
||||
{
|
||||
s = CInterfaceElement::HotSpotToString( parent );
|
||||
s += " ";
|
||||
s += CInterfaceElement::HotSpotToString( child );
|
||||
}
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
// ***************************************************************************
|
||||
bool CCtrlBase::emptyContextHelp() const
|
||||
{
|
||||
|
|
|
@ -259,11 +259,11 @@ namespace NLGUI
|
|||
nlwarning( "Tried to set invalid property '%s' for widget '%s'", name.c_str(), _Id.c_str() );
|
||||
}
|
||||
|
||||
bool CInterfaceElement::serialize( xmlNodePtr parentNode, const char *type ) const
|
||||
xmlNodePtr CInterfaceElement::serialize( xmlNodePtr parentNode, const char *type ) const
|
||||
{
|
||||
xmlNodePtr node = xmlNewNode( NULL, BAD_CAST type );
|
||||
if( node == NULL )
|
||||
return false;
|
||||
return NULL;
|
||||
|
||||
xmlAddChild( parentNode, node );
|
||||
|
||||
|
@ -284,7 +284,7 @@ namespace NLGUI
|
|||
xmlNewProp( node, BAD_CAST "render_layer", BAD_CAST toString( _RenderLayer ).c_str() );
|
||||
xmlNewProp( node, BAD_CAST "avoid_resize_parent", BAD_CAST toString( _AvoidResizeParent ).c_str() );
|
||||
|
||||
return true;
|
||||
return node;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
|
|
|
@ -43,7 +43,7 @@ namespace GUIEditor
|
|||
return false;
|
||||
}
|
||||
|
||||
if( !mg->serialize( root, "root" ) )
|
||||
if( mg->serialize( root, "root" ) == NULL )
|
||||
{
|
||||
xmlFreeNode( root );
|
||||
out.close();
|
||||
|
@ -66,8 +66,12 @@ namespace GUIEditor
|
|||
xmlAttrPtr prop = node->properties;
|
||||
while( prop != NULL )
|
||||
{
|
||||
std::string name = std::string( (const char*)prop->name );
|
||||
std::string value = std::string( (const char*)xmlGetProp( node, BAD_CAST name.c_str() ) );
|
||||
std::string name =
|
||||
std::string( reinterpret_cast< const char* >( prop->name ) );
|
||||
|
||||
std::string value =
|
||||
std::string( reinterpret_cast< const char* >( xmlGetProp( node, BAD_CAST name.c_str() ) ) );
|
||||
|
||||
out << " " << name << "=\"" << value << "\"" << std::endl;
|
||||
|
||||
prop = prop->next;
|
||||
|
|
Loading…
Reference in a new issue