MODIFIED: #1471 Widget template changes can now be saved.
--HG-- branch : gsoc2012-gui-editorhg/feature/sse2
parent
6e1254b612
commit
7cad2331e7
@ -0,0 +1,77 @@
|
|||||||
|
// Object Viewer Qt GUI Editor plugin <http://dev.ryzom.com/projects/ryzom/>
|
||||||
|
// Copyright (C) 2010 Winch Gate Property Limited
|
||||||
|
//
|
||||||
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Affero General Public License as
|
||||||
|
// published by the Free Software Foundation, either version 3 of the
|
||||||
|
// License, or (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This program is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU Affero General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Affero General Public License
|
||||||
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
#include "widget_info_serializer.h"
|
||||||
|
#include "widget_info_tree.h"
|
||||||
|
#include <fstream>
|
||||||
|
|
||||||
|
namespace GUIEditor
|
||||||
|
{
|
||||||
|
void CWidgetInfoSerializer::serialize( CWidgetInfoTree *tree )
|
||||||
|
{
|
||||||
|
tree->accept( this );
|
||||||
|
}
|
||||||
|
|
||||||
|
void CWidgetInfoSerializer::visit( CWidgetInfoTreeNode *node )
|
||||||
|
{
|
||||||
|
std::fstream f;
|
||||||
|
std::string filename = "widgets/" + node->getInfo().name + ".xml";
|
||||||
|
SWidgetInfo &info = node->getInfo();
|
||||||
|
|
||||||
|
f.open( filename.c_str(), std::ios_base::out );
|
||||||
|
if( !f.is_open() )
|
||||||
|
{
|
||||||
|
nlinfo( "Failed to open %s for writing!\n", filename.c_str() );
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
f << "<widget>" << std::endl;
|
||||||
|
f << "\t<header>" << std::endl;
|
||||||
|
f << "\t\t<name>" << info.name << "</name>" << std::endl;
|
||||||
|
f << "\t\t<guiname>" << info.GUIName << "</guiname>" << std::endl;
|
||||||
|
f << "\t\t<ancestor>" << info.ancestor << "</ancestor>" << std::endl;
|
||||||
|
f << "\t\t<description>" << info.description << "</description>" << std::endl;
|
||||||
|
|
||||||
|
if( info.isAbstract )
|
||||||
|
f << "\t\t<abstract>" << "true" << "</abstract>" << std::endl;
|
||||||
|
else
|
||||||
|
f << "\t\t<abstract>" << "false" << "</abstract>" << std::endl;
|
||||||
|
|
||||||
|
f << "\t\t<icon>" << info.icon << "</icon>" << std::endl;
|
||||||
|
|
||||||
|
f << "\t</header>" << std::endl;
|
||||||
|
f << "\t<properties>" << std::endl;
|
||||||
|
|
||||||
|
for( std::vector< SPropEntry >::const_iterator itr = info.props.begin(); itr != info.props.end(); ++itr )
|
||||||
|
{
|
||||||
|
f << "\t\t<property>" << std::endl;
|
||||||
|
|
||||||
|
f << "\t\t\t<name>" << itr->propName << "</name>" << std::endl;
|
||||||
|
f << "\t\t\t<type>" << itr->propType << "</type>" << std::endl;
|
||||||
|
f << "\t\t\t<default>" << itr->propDefault << "</default>" << std::endl;
|
||||||
|
|
||||||
|
f << "\t\t</property>" << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
f << "\t</properties>" << std::endl;
|
||||||
|
f << "</widget>" << std::endl;
|
||||||
|
f << std::endl;
|
||||||
|
|
||||||
|
f.close();
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,37 @@
|
|||||||
|
// Object Viewer Qt GUI Editor plugin <http://dev.ryzom.com/projects/ryzom/>
|
||||||
|
// Copyright (C) 2010 Winch Gate Property Limited
|
||||||
|
//
|
||||||
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Affero General Public License as
|
||||||
|
// published by the Free Software Foundation, either version 3 of the
|
||||||
|
// License, or (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This program is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU Affero General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Affero General Public License
|
||||||
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
#ifndef WIDGET_INFO_SERIALIZER_H
|
||||||
|
#define WIDGET_INFO_SERIALIZER_H
|
||||||
|
|
||||||
|
#include "widget_info_tree_visitor.h"
|
||||||
|
|
||||||
|
namespace GUIEditor
|
||||||
|
{
|
||||||
|
class CWidgetInfoTree;
|
||||||
|
|
||||||
|
class CWidgetInfoSerializer : public CWidgetInfoTreeVisitor
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
void serialize( CWidgetInfoTree *tree );
|
||||||
|
void visit( CWidgetInfoTreeNode *node );
|
||||||
|
|
||||||
|
private:
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
@ -0,0 +1,34 @@
|
|||||||
|
// Object Viewer Qt GUI Editor plugin <http://dev.ryzom.com/projects/ryzom/>
|
||||||
|
// Copyright (C) 2010 Winch Gate Property Limited
|
||||||
|
//
|
||||||
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Affero General Public License as
|
||||||
|
// published by the Free Software Foundation, either version 3 of the
|
||||||
|
// License, or (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This program is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU Affero General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Affero General Public License
|
||||||
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
#ifndef WIDGET_INFO_TREE_VISITOR_H
|
||||||
|
#define WIDGET_INFO_TREE_VISITOR_H
|
||||||
|
|
||||||
|
namespace GUIEditor
|
||||||
|
{
|
||||||
|
class CWidgetInfoTreeNode;
|
||||||
|
|
||||||
|
/// Visitor base class for CWidgetInfoTree
|
||||||
|
class CWidgetInfoTreeVisitor
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
/// Visits a node
|
||||||
|
virtual void visit( CWidgetInfoTreeNode *node ) = 0;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue