mirror of
https://github.com/Garux/netradiant-custom.git
synced 2026-09-28 00:00:03 +02:00
my own uncrustify run
This commit is contained in:
+57
-66
@@ -1,23 +1,23 @@
|
||||
/*
|
||||
Copyright (C) 2001-2006, William Joseph.
|
||||
All Rights Reserved.
|
||||
Copyright (C) 2001-2006, William Joseph.
|
||||
All Rights Reserved.
|
||||
|
||||
This file is part of GtkRadiant.
|
||||
This file is part of GtkRadiant.
|
||||
|
||||
GtkRadiant is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
GtkRadiant is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
GtkRadiant 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 General Public License for more details.
|
||||
GtkRadiant 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 General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GtkRadiant; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GtkRadiant; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#include "plugin.h"
|
||||
|
||||
@@ -35,59 +35,51 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
|
||||
class MapXMLDependencies :
|
||||
public GlobalRadiantModuleRef,
|
||||
public GlobalBrushModuleRef,
|
||||
public GlobalFiletypesModuleRef,
|
||||
public GlobalEntityClassManagerModuleRef,
|
||||
public GlobalSceneGraphModuleRef
|
||||
public GlobalRadiantModuleRef,
|
||||
public GlobalBrushModuleRef,
|
||||
public GlobalFiletypesModuleRef,
|
||||
public GlobalEntityClassManagerModuleRef,
|
||||
public GlobalSceneGraphModuleRef
|
||||
{
|
||||
PatchModuleRef m_patchDef2Doom3Module;
|
||||
PatchModuleRef m_patchDoom3Module;
|
||||
PatchModuleRef m_patchDef2Doom3Module;
|
||||
PatchModuleRef m_patchDoom3Module;
|
||||
public:
|
||||
MapXMLDependencies() :
|
||||
GlobalBrushModuleRef(GlobalRadiant().getRequiredGameDescriptionKeyValue("brushtypes")),
|
||||
GlobalEntityClassManagerModuleRef(GlobalRadiant().getRequiredGameDescriptionKeyValue("entityclass")),
|
||||
m_patchDef2Doom3Module("def2doom3"),
|
||||
m_patchDoom3Module("doom3")
|
||||
{
|
||||
}
|
||||
BrushCreator& getBrushDoom3()
|
||||
{
|
||||
return GlobalBrushModule::getTable();
|
||||
}
|
||||
PatchCreator& getPatchDoom3()
|
||||
{
|
||||
return *m_patchDoom3Module.getTable();
|
||||
}
|
||||
PatchCreator& getPatchDef2Doom3()
|
||||
{
|
||||
return *m_patchDef2Doom3Module.getTable();
|
||||
}
|
||||
MapXMLDependencies() :
|
||||
GlobalBrushModuleRef( GlobalRadiant().getRequiredGameDescriptionKeyValue( "brushtypes" ) ),
|
||||
GlobalEntityClassManagerModuleRef( GlobalRadiant().getRequiredGameDescriptionKeyValue( "entityclass" ) ),
|
||||
m_patchDef2Doom3Module( "def2doom3" ),
|
||||
m_patchDoom3Module( "doom3" ){
|
||||
}
|
||||
BrushCreator& getBrushDoom3(){
|
||||
return GlobalBrushModule::getTable();
|
||||
}
|
||||
PatchCreator& getPatchDoom3(){
|
||||
return *m_patchDoom3Module.getTable();
|
||||
}
|
||||
PatchCreator& getPatchDef2Doom3(){
|
||||
return *m_patchDef2Doom3Module.getTable();
|
||||
}
|
||||
};
|
||||
|
||||
class MapXMLAPI : public TypeSystemRef, public MapFormat
|
||||
{
|
||||
public:
|
||||
typedef MapFormat Type;
|
||||
STRING_CONSTANT(Name, "xmldoom3");
|
||||
typedef MapFormat Type;
|
||||
STRING_CONSTANT( Name, "xmldoom3" );
|
||||
|
||||
MapXMLAPI()
|
||||
{
|
||||
GlobalFiletypesModule::getTable().addType(Type::Name(), Name(), filetype_t("xml doom3 maps", "*.xmap"));
|
||||
}
|
||||
MapFormat* getTable()
|
||||
{
|
||||
return this;
|
||||
}
|
||||
MapXMLAPI(){
|
||||
GlobalFiletypesModule::getTable().addType( Type::Name(), Name(), filetype_t( "xml doom3 maps", "*.xmap" ) );
|
||||
}
|
||||
MapFormat* getTable(){
|
||||
return this;
|
||||
}
|
||||
|
||||
void readGraph(scene::Node& root, TextInputStream& inputStream, EntityCreator& entityTable) const
|
||||
{
|
||||
Map_Read(root, inputStream, entityTable);
|
||||
}
|
||||
void writeGraph(scene::Node& root, GraphTraversalFunc traverse, TextOutputStream& outputStream) const
|
||||
{
|
||||
Map_Write(root, traverse, outputStream);
|
||||
}
|
||||
void readGraph( scene::Node& root, TextInputStream& inputStream, EntityCreator& entityTable ) const {
|
||||
Map_Read( root, inputStream, entityTable );
|
||||
}
|
||||
void writeGraph( scene::Node& root, GraphTraversalFunc traverse, TextOutputStream& outputStream ) const {
|
||||
Map_Write( root, traverse, outputStream );
|
||||
}
|
||||
};
|
||||
|
||||
typedef SingletonModule<MapXMLAPI, MapXMLDependencies> MapXMLModule;
|
||||
@@ -96,12 +88,11 @@ MapXMLModule g_MapXMLModule;
|
||||
|
||||
|
||||
|
||||
extern "C" void RADIANT_DLLEXPORT Radiant_RegisterModules(ModuleServer& server)
|
||||
{
|
||||
GlobalErrorStream::instance().setOutputStream(server.getErrorStream());
|
||||
GlobalOutputStream::instance().setOutputStream(server.getOutputStream());
|
||||
GlobalDebugMessageHandler::instance().setHandler(server.getDebugMessageHandler());
|
||||
GlobalModuleServer::instance().set(server);
|
||||
extern "C" void RADIANT_DLLEXPORT Radiant_RegisterModules( ModuleServer& server ){
|
||||
GlobalErrorStream::instance().setOutputStream( server.getErrorStream() );
|
||||
GlobalOutputStream::instance().setOutputStream( server.getOutputStream() );
|
||||
GlobalDebugMessageHandler::instance().setHandler( server.getDebugMessageHandler() );
|
||||
GlobalModuleServer::instance().set( server );
|
||||
|
||||
g_MapXMLModule.selfRegister();
|
||||
g_MapXMLModule.selfRegister();
|
||||
}
|
||||
|
||||
+16
-16
@@ -1,25 +1,25 @@
|
||||
/*
|
||||
Copyright (C) 2001-2006, William Joseph.
|
||||
All Rights Reserved.
|
||||
Copyright (C) 2001-2006, William Joseph.
|
||||
All Rights Reserved.
|
||||
|
||||
This file is part of GtkRadiant.
|
||||
This file is part of GtkRadiant.
|
||||
|
||||
GtkRadiant is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
GtkRadiant is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
GtkRadiant 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 General Public License for more details.
|
||||
GtkRadiant 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 General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GtkRadiant; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GtkRadiant; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#if !defined(INCLUDED_PLUGIN_H)
|
||||
#if !defined( INCLUDED_PLUGIN_H )
|
||||
#define INCLUDED_PLUGIN_H
|
||||
|
||||
#endif
|
||||
|
||||
+160
-196
@@ -1,23 +1,23 @@
|
||||
/*
|
||||
Copyright (C) 2001-2006, William Joseph.
|
||||
All Rights Reserved.
|
||||
Copyright (C) 2001-2006, William Joseph.
|
||||
All Rights Reserved.
|
||||
|
||||
This file is part of GtkRadiant.
|
||||
This file is part of GtkRadiant.
|
||||
|
||||
GtkRadiant is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
GtkRadiant is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
GtkRadiant 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 General Public License for more details.
|
||||
GtkRadiant 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 General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GtkRadiant; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GtkRadiant; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
//
|
||||
// parses xml tree format into internal objects
|
||||
@@ -42,236 +42,200 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
#define PARSE_ERROR "XML PARSE ERROR"
|
||||
|
||||
|
||||
inline XMLImporter* Node_getXMLImporter(scene::Node& node)
|
||||
{
|
||||
return NodeTypeCast<XMLImporter>::cast(node);
|
||||
inline XMLImporter* Node_getXMLImporter( scene::Node& node ){
|
||||
return NodeTypeCast<XMLImporter>::cast( node );
|
||||
}
|
||||
|
||||
|
||||
scene::Node& createPrimitive(const char* name)
|
||||
{
|
||||
if(string_equal(name, "brush"))
|
||||
{
|
||||
return GlobalBrushCreator().createBrush();
|
||||
}
|
||||
else if(string_equal(name, "patch"))
|
||||
{
|
||||
return GlobalPatchCreator().createPatch();
|
||||
}
|
||||
scene::Node& createPrimitive( const char* name ){
|
||||
if ( string_equal( name, "brush" ) ) {
|
||||
return GlobalBrushCreator().createBrush();
|
||||
}
|
||||
else if ( string_equal( name, "patch" ) ) {
|
||||
return GlobalPatchCreator().createPatch();
|
||||
}
|
||||
|
||||
ASSERT_MESSAGE(0, PARSE_ERROR << ": primitive type not supported: \"" << name << "\"\n");
|
||||
scene::Node* node = 0;
|
||||
return *node;
|
||||
ASSERT_MESSAGE( 0, PARSE_ERROR << ": primitive type not supported: \"" << name << "\"\n" );
|
||||
scene::Node* node = 0;
|
||||
return *node;
|
||||
}
|
||||
|
||||
class TreeXMLImporter : public XMLImporter
|
||||
{
|
||||
public:
|
||||
virtual TreeXMLImporter& child() = 0;
|
||||
virtual TreeXMLImporter& child() = 0;
|
||||
};
|
||||
|
||||
class SubPrimitiveImporter : public TreeXMLImporter
|
||||
{
|
||||
XMLImporter* m_importer;
|
||||
XMLImporter* m_importer;
|
||||
public:
|
||||
SubPrimitiveImporter(XMLImporter* importer) : m_importer(importer)
|
||||
{
|
||||
}
|
||||
void pushElement(const XMLElement& element)
|
||||
{
|
||||
m_importer->pushElement(element);
|
||||
}
|
||||
void popElement(const char* name)
|
||||
{
|
||||
m_importer->popElement(name);
|
||||
}
|
||||
std::size_t write(const char* buffer, std::size_t length)
|
||||
{
|
||||
return m_importer->write(buffer, length);
|
||||
}
|
||||
SubPrimitiveImporter& child()
|
||||
{
|
||||
return *this;
|
||||
}
|
||||
SubPrimitiveImporter( XMLImporter* importer ) : m_importer( importer ){
|
||||
}
|
||||
void pushElement( const XMLElement& element ){
|
||||
m_importer->pushElement( element );
|
||||
}
|
||||
void popElement( const char* name ){
|
||||
m_importer->popElement( name );
|
||||
}
|
||||
std::size_t write( const char* buffer, std::size_t length ){
|
||||
return m_importer->write( buffer, length );
|
||||
}
|
||||
SubPrimitiveImporter& child(){
|
||||
return *this;
|
||||
}
|
||||
};
|
||||
|
||||
class PrimitiveImporter : public TreeXMLImporter
|
||||
{
|
||||
scene::Node& m_parent;
|
||||
XMLImporter* m_importer;
|
||||
char m_child[sizeof(SubPrimitiveImporter)];
|
||||
scene::Node& m_parent;
|
||||
XMLImporter* m_importer;
|
||||
char m_child[sizeof( SubPrimitiveImporter )];
|
||||
|
||||
SubPrimitiveImporter& subprimitive()
|
||||
{
|
||||
return *reinterpret_cast<SubPrimitiveImporter*>(m_child);
|
||||
}
|
||||
SubPrimitiveImporter& subprimitive(){
|
||||
return *reinterpret_cast<SubPrimitiveImporter*>( m_child );
|
||||
}
|
||||
public:
|
||||
PrimitiveImporter(scene::Node& parent) : m_parent(parent), m_importer(0)
|
||||
{
|
||||
}
|
||||
void pushElement(const XMLElement& element)
|
||||
{
|
||||
if(string_equal(element.name(), "epair"))
|
||||
{
|
||||
ASSERT_MESSAGE(string_equal(element.name(), "epair"), PARSE_ERROR);
|
||||
Node_getEntity(m_parent)->setKeyValue(element.attribute("key"), element.attribute("value"));
|
||||
}
|
||||
else
|
||||
{
|
||||
NodeSmartReference node(createPrimitive(element.name()));
|
||||
PrimitiveImporter( scene::Node& parent ) : m_parent( parent ), m_importer( 0 ){
|
||||
}
|
||||
void pushElement( const XMLElement& element ){
|
||||
if ( string_equal( element.name(), "epair" ) ) {
|
||||
ASSERT_MESSAGE( string_equal( element.name(), "epair" ), PARSE_ERROR );
|
||||
Node_getEntity( m_parent )->setKeyValue( element.attribute( "key" ), element.attribute( "value" ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
NodeSmartReference node( createPrimitive( element.name() ) );
|
||||
|
||||
m_importer = Node_getXMLImporter(node);
|
||||
m_importer = Node_getXMLImporter( node );
|
||||
|
||||
constructor(subprimitive(), m_importer);
|
||||
constructor( subprimitive(), m_importer );
|
||||
|
||||
m_importer->pushElement(element);
|
||||
m_importer->pushElement( element );
|
||||
|
||||
Node_getTraversable(m_parent)->insert(node);
|
||||
}
|
||||
}
|
||||
void popElement(const char* name)
|
||||
{
|
||||
if(string_equal(name, "epair"))
|
||||
{
|
||||
}
|
||||
else
|
||||
{
|
||||
m_importer->popElement(name);
|
||||
Node_getTraversable( m_parent )->insert( node );
|
||||
}
|
||||
}
|
||||
void popElement( const char* name ){
|
||||
if ( string_equal( name, "epair" ) ) {
|
||||
}
|
||||
else
|
||||
{
|
||||
m_importer->popElement( name );
|
||||
|
||||
destructor(subprimitive());
|
||||
m_importer = 0;
|
||||
}
|
||||
}
|
||||
std::size_t write(const char* buffer, std::size_t length)
|
||||
{
|
||||
return m_importer->write(buffer, length);
|
||||
}
|
||||
TreeXMLImporter& child()
|
||||
{
|
||||
return subprimitive();
|
||||
}
|
||||
destructor( subprimitive() );
|
||||
m_importer = 0;
|
||||
}
|
||||
}
|
||||
std::size_t write( const char* buffer, std::size_t length ){
|
||||
return m_importer->write( buffer, length );
|
||||
}
|
||||
TreeXMLImporter& child(){
|
||||
return subprimitive();
|
||||
}
|
||||
};
|
||||
|
||||
class EntityImporter : public TreeXMLImporter
|
||||
{
|
||||
scene::Node& m_parent;
|
||||
char m_node[sizeof(NodeSmartReference)];
|
||||
char m_child[sizeof(PrimitiveImporter)];
|
||||
EntityCreator& m_entityTable;
|
||||
scene::Node& m_parent;
|
||||
char m_node[sizeof( NodeSmartReference )];
|
||||
char m_child[sizeof( PrimitiveImporter )];
|
||||
EntityCreator& m_entityTable;
|
||||
|
||||
NodeSmartReference& node()
|
||||
{
|
||||
return *reinterpret_cast<NodeSmartReference*>(m_node);
|
||||
}
|
||||
PrimitiveImporter& primitive()
|
||||
{
|
||||
return *reinterpret_cast<PrimitiveImporter*>(m_child);
|
||||
}
|
||||
NodeSmartReference& node(){
|
||||
return *reinterpret_cast<NodeSmartReference*>( m_node );
|
||||
}
|
||||
PrimitiveImporter& primitive(){
|
||||
return *reinterpret_cast<PrimitiveImporter*>( m_child );
|
||||
}
|
||||
|
||||
public:
|
||||
EntityImporter(scene::Node& parent, EntityCreator& entityTable) : m_parent(parent), m_entityTable(entityTable)
|
||||
{
|
||||
}
|
||||
void pushElement(const XMLElement& element)
|
||||
{
|
||||
ASSERT_MESSAGE(string_equal(element.name(), "entity"), PARSE_ERROR);
|
||||
constructor(node(), NodeSmartReference(m_entityTable.createEntity(GlobalEntityClassManager().findOrInsert("", true))));
|
||||
constructor(primitive(), makeReference(node().get()));
|
||||
}
|
||||
void popElement(const char* name)
|
||||
{
|
||||
ASSERT_MESSAGE(string_equal(name, "entity"), PARSE_ERROR);
|
||||
NodeSmartReference entity(m_entityTable.createEntity(GlobalEntityClassManager().findOrInsert(Node_getEntity(node())->getKeyValue("classname"), node_is_group(node()))));
|
||||
EntityImporter( scene::Node& parent, EntityCreator& entityTable ) : m_parent( parent ), m_entityTable( entityTable ){
|
||||
}
|
||||
void pushElement( const XMLElement& element ){
|
||||
ASSERT_MESSAGE( string_equal( element.name(), "entity" ), PARSE_ERROR );
|
||||
constructor( node(), NodeSmartReference( m_entityTable.createEntity( GlobalEntityClassManager().findOrInsert( "", true ) ) ) );
|
||||
constructor( primitive(), makeReference( node().get() ) );
|
||||
}
|
||||
void popElement( const char* name ){
|
||||
ASSERT_MESSAGE( string_equal( name, "entity" ), PARSE_ERROR );
|
||||
NodeSmartReference entity( m_entityTable.createEntity( GlobalEntityClassManager().findOrInsert( Node_getEntity( node() )->getKeyValue( "classname" ), node_is_group( node() ) ) ) );
|
||||
|
||||
{
|
||||
EntityCopyingVisitor visitor(*Node_getEntity(entity));
|
||||
Node_getEntity(node())->forEachKeyValue(visitor);
|
||||
}
|
||||
{
|
||||
EntityCopyingVisitor visitor( *Node_getEntity( entity ) );
|
||||
Node_getEntity( node() )->forEachKeyValue( visitor );
|
||||
}
|
||||
|
||||
if(Node_getTraversable(entity) != 0 && !Node_getEntity(entity)->getEntityClass().fixedsize)
|
||||
{
|
||||
parentBrushes(node(), entity);
|
||||
}
|
||||
if ( Node_getTraversable( entity ) != 0 && !Node_getEntity( entity )->getEntityClass().fixedsize ) {
|
||||
parentBrushes( node(), entity );
|
||||
}
|
||||
|
||||
Node_getTraversable(m_parent)->insert(entity);
|
||||
Node_getTraversable( m_parent )->insert( entity );
|
||||
|
||||
destructor(primitive());
|
||||
destructor(node());
|
||||
}
|
||||
std::size_t write(const char* buffer, std::size_t length)
|
||||
{
|
||||
return length;
|
||||
}
|
||||
TreeXMLImporter& child()
|
||||
{
|
||||
return primitive();
|
||||
}
|
||||
destructor( primitive() );
|
||||
destructor( node() );
|
||||
}
|
||||
std::size_t write( const char* buffer, std::size_t length ){
|
||||
return length;
|
||||
}
|
||||
TreeXMLImporter& child(){
|
||||
return primitive();
|
||||
}
|
||||
};
|
||||
|
||||
class MapDoom3Importer : public TreeXMLImporter
|
||||
{
|
||||
scene::Node& m_root;
|
||||
char m_child[sizeof(EntityImporter)];
|
||||
EntityCreator& m_entityTable;
|
||||
scene::Node& m_root;
|
||||
char m_child[sizeof( EntityImporter )];
|
||||
EntityCreator& m_entityTable;
|
||||
|
||||
EntityImporter& getEntity()
|
||||
{
|
||||
return *reinterpret_cast<EntityImporter*>(m_child);
|
||||
}
|
||||
EntityImporter& getEntity(){
|
||||
return *reinterpret_cast<EntityImporter*>( m_child );
|
||||
}
|
||||
public:
|
||||
MapDoom3Importer(scene::Node& root, EntityCreator& entityTable) : m_root(root), m_entityTable(entityTable)
|
||||
{
|
||||
}
|
||||
void pushElement(const XMLElement& element)
|
||||
{
|
||||
ASSERT_MESSAGE(string_equal(element.name(), "mapdoom3"), PARSE_ERROR);
|
||||
constructor(getEntity(), makeReference(m_root), makeReference(m_entityTable));
|
||||
}
|
||||
void popElement(const char* name)
|
||||
{
|
||||
ASSERT_MESSAGE(string_equal(name, "mapdoom3"), PARSE_ERROR);
|
||||
destructor(getEntity());
|
||||
}
|
||||
std::size_t write(const char* data, std::size_t length)
|
||||
{
|
||||
return length;
|
||||
}
|
||||
TreeXMLImporter& child()
|
||||
{
|
||||
return getEntity();
|
||||
}
|
||||
MapDoom3Importer( scene::Node& root, EntityCreator& entityTable ) : m_root( root ), m_entityTable( entityTable ){
|
||||
}
|
||||
void pushElement( const XMLElement& element ){
|
||||
ASSERT_MESSAGE( string_equal( element.name(), "mapdoom3" ), PARSE_ERROR );
|
||||
constructor( getEntity(), makeReference( m_root ), makeReference( m_entityTable ) );
|
||||
}
|
||||
void popElement( const char* name ){
|
||||
ASSERT_MESSAGE( string_equal( name, "mapdoom3" ), PARSE_ERROR );
|
||||
destructor( getEntity() );
|
||||
}
|
||||
std::size_t write( const char* data, std::size_t length ){
|
||||
return length;
|
||||
}
|
||||
TreeXMLImporter& child(){
|
||||
return getEntity();
|
||||
}
|
||||
};
|
||||
|
||||
class TreeXMLImporterStack : public XMLImporter
|
||||
{
|
||||
std::vector< Reference<TreeXMLImporter> > m_importers;
|
||||
std::vector< Reference<TreeXMLImporter> > m_importers;
|
||||
public:
|
||||
TreeXMLImporterStack(TreeXMLImporter& importer)
|
||||
{
|
||||
m_importers.push_back(makeReference(importer));
|
||||
}
|
||||
void pushElement(const XMLElement& element)
|
||||
{
|
||||
m_importers.back().get().pushElement(element);
|
||||
m_importers.push_back(makeReference(m_importers.back().get().child()));
|
||||
}
|
||||
void popElement(const char* name)
|
||||
{
|
||||
m_importers.pop_back();
|
||||
m_importers.back().get().popElement(name);
|
||||
}
|
||||
std::size_t write(const char* buffer, std::size_t length)
|
||||
{
|
||||
return (*(m_importers.end() - 2)).get().write(buffer, length);
|
||||
}
|
||||
TreeXMLImporterStack( TreeXMLImporter& importer ){
|
||||
m_importers.push_back( makeReference( importer ) );
|
||||
}
|
||||
void pushElement( const XMLElement& element ){
|
||||
m_importers.back().get().pushElement( element );
|
||||
m_importers.push_back( makeReference( m_importers.back().get().child() ) );
|
||||
}
|
||||
void popElement( const char* name ){
|
||||
m_importers.pop_back();
|
||||
m_importers.back().get().popElement( name );
|
||||
}
|
||||
std::size_t write( const char* buffer, std::size_t length ){
|
||||
return ( *( m_importers.end() - 2 ) ).get().write( buffer, length );
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
void Map_Read(scene::Node& root, TextInputStream& in, EntityCreator& entityTable)
|
||||
{
|
||||
XMLStreamParser parser(in);
|
||||
void Map_Read( scene::Node& root, TextInputStream& in, EntityCreator& entityTable ){
|
||||
XMLStreamParser parser( in );
|
||||
|
||||
MapDoom3Importer importer(root, entityTable);
|
||||
TreeXMLImporterStack stack(importer);
|
||||
parser.exportXML(stack);
|
||||
MapDoom3Importer importer( root, entityTable );
|
||||
TreeXMLImporterStack stack( importer );
|
||||
parser.exportXML( stack );
|
||||
}
|
||||
|
||||
+17
-17
@@ -1,29 +1,29 @@
|
||||
/*
|
||||
Copyright (C) 2001-2006, William Joseph.
|
||||
All Rights Reserved.
|
||||
Copyright (C) 2001-2006, William Joseph.
|
||||
All Rights Reserved.
|
||||
|
||||
This file is part of GtkRadiant.
|
||||
This file is part of GtkRadiant.
|
||||
|
||||
GtkRadiant is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
GtkRadiant is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
GtkRadiant 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 General Public License for more details.
|
||||
GtkRadiant 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 General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GtkRadiant; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GtkRadiant; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#if !defined(INCLUDED_XMLPARSE_H)
|
||||
#if !defined( INCLUDED_XMLPARSE_H )
|
||||
#define INCLUDED_XMLPARSE_H
|
||||
|
||||
#include "imap.h"
|
||||
|
||||
void Map_Read(scene::Node& root, TextInputStream& in, EntityCreator& entityTable);
|
||||
void Map_Read( scene::Node& root, TextInputStream& in, EntityCreator& entityTable );
|
||||
|
||||
#endif
|
||||
|
||||
+56
-64
@@ -1,23 +1,23 @@
|
||||
/*
|
||||
Copyright (C) 2001-2006, William Joseph.
|
||||
All Rights Reserved.
|
||||
Copyright (C) 2001-2006, William Joseph.
|
||||
All Rights Reserved.
|
||||
|
||||
This file is part of GtkRadiant.
|
||||
This file is part of GtkRadiant.
|
||||
|
||||
GtkRadiant is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
GtkRadiant is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
GtkRadiant 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 General Public License for more details.
|
||||
GtkRadiant 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 General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GtkRadiant; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GtkRadiant; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
//
|
||||
// writes xml tree format from internal objects
|
||||
@@ -29,63 +29,55 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
#include "scenelib.h"
|
||||
#include "entityxml.h"
|
||||
|
||||
inline XMLExporter* Node_getXMLExporter(scene::Node& node)
|
||||
{
|
||||
return NodeTypeCast<XMLExporter>::cast(node);
|
||||
inline XMLExporter* Node_getXMLExporter( scene::Node& node ){
|
||||
return NodeTypeCast<XMLExporter>::cast( node );
|
||||
}
|
||||
|
||||
|
||||
class write_all : public scene::Traversable::Walker
|
||||
{
|
||||
XMLImporter& m_importer;
|
||||
XMLImporter& m_importer;
|
||||
public:
|
||||
write_all(XMLImporter& importer) : m_importer(importer)
|
||||
{
|
||||
}
|
||||
bool pre(scene::Node& node) const
|
||||
{
|
||||
Entity* entity = Node_getEntity(node);
|
||||
if(entity != 0)
|
||||
{
|
||||
m_importer.write("\n", 1);
|
||||
StaticElement element("entity");
|
||||
m_importer.pushElement(element);
|
||||
entity_export exporter(*entity);
|
||||
exporter.exportXML(m_importer);
|
||||
}
|
||||
else
|
||||
{
|
||||
XMLExporter* exporter = Node_getXMLExporter(node);
|
||||
if(exporter != 0)
|
||||
{
|
||||
m_importer.write("\n", 1);
|
||||
exporter->exportXML(m_importer);
|
||||
m_importer.write("\n", 1);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
void post(scene::Node& node) const
|
||||
{
|
||||
if(Node_getEntity(node) != 0)
|
||||
{
|
||||
m_importer.write("\n", 1);
|
||||
m_importer.popElement("entity");
|
||||
}
|
||||
}
|
||||
write_all( XMLImporter& importer ) : m_importer( importer ){
|
||||
}
|
||||
bool pre( scene::Node& node ) const {
|
||||
Entity* entity = Node_getEntity( node );
|
||||
if ( entity != 0 ) {
|
||||
m_importer.write( "\n", 1 );
|
||||
StaticElement element( "entity" );
|
||||
m_importer.pushElement( element );
|
||||
entity_export exporter( *entity );
|
||||
exporter.exportXML( m_importer );
|
||||
}
|
||||
else
|
||||
{
|
||||
XMLExporter* exporter = Node_getXMLExporter( node );
|
||||
if ( exporter != 0 ) {
|
||||
m_importer.write( "\n", 1 );
|
||||
exporter->exportXML( m_importer );
|
||||
m_importer.write( "\n", 1 );
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
void post( scene::Node& node ) const {
|
||||
if ( Node_getEntity( node ) != 0 ) {
|
||||
m_importer.write( "\n", 1 );
|
||||
m_importer.popElement( "entity" );
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
void Map_Write(scene::Node& root, GraphTraversalFunc traverse, TextOutputStream& out)
|
||||
{
|
||||
XMLStreamWriter writer(out);
|
||||
writer.write("\n", 1);
|
||||
{
|
||||
StaticElement element("mapdoom3");
|
||||
writer.pushElement(element);
|
||||
void Map_Write( scene::Node& root, GraphTraversalFunc traverse, TextOutputStream& out ){
|
||||
XMLStreamWriter writer( out );
|
||||
writer.write( "\n", 1 );
|
||||
{
|
||||
StaticElement element( "mapdoom3" );
|
||||
writer.pushElement( element );
|
||||
|
||||
traverse(root, write_all(writer));
|
||||
traverse( root, write_all( writer ) );
|
||||
|
||||
writer.write("\n", 1);
|
||||
writer.popElement(element.name());
|
||||
}
|
||||
writer.write( "\n", 1 );
|
||||
writer.popElement( element.name() );
|
||||
}
|
||||
}
|
||||
|
||||
+17
-17
@@ -1,29 +1,29 @@
|
||||
/*
|
||||
Copyright (C) 2001-2006, William Joseph.
|
||||
All Rights Reserved.
|
||||
Copyright (C) 2001-2006, William Joseph.
|
||||
All Rights Reserved.
|
||||
|
||||
This file is part of GtkRadiant.
|
||||
This file is part of GtkRadiant.
|
||||
|
||||
GtkRadiant is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
GtkRadiant is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
GtkRadiant 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 General Public License for more details.
|
||||
GtkRadiant 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 General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GtkRadiant; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GtkRadiant; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#if !defined(INCLUDED_XMLWRITE_H)
|
||||
#if !defined( INCLUDED_XMLWRITE_H )
|
||||
#define INCLUDED_XMLWRITE_H
|
||||
|
||||
#include "imap.h"
|
||||
|
||||
void Map_Write(scene::Node& root, GraphTraversalFunc traverse, TextOutputStream& out);
|
||||
void Map_Write( scene::Node& root, GraphTraversalFunc traverse, TextOutputStream& out );
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user