X-Git-Url: https://git.xonotic.org/?a=blobdiff_plain;f=plugins%2Fentity%2Fmodel.h;h=75e442f1af068ff97241e9b27d59980ab3c44f5e;hb=b2d88d5f47228913aa7e147cec3e789efd974436;hp=4e23b93f1cb105c958f10950042e3cc66409e7a6;hpb=bfc8a12a6b315ae261101a34db8ba1b682c67bb7;p=xonotic%2Fnetradiant.git diff --git a/plugins/entity/model.h b/plugins/entity/model.h index 4e23b93f..75e442f1 100644 --- a/plugins/entity/model.h +++ b/plugins/entity/model.h @@ -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_MODEL_H) +#if !defined( INCLUDED_MODEL_H ) #define INCLUDED_MODEL_H #include "entitylib.h" @@ -31,94 +31,79 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA class EModel : public ModuleObserver { - ResourceReference m_resource; - scene::Traversable& m_traverse; - scene::Node* m_node; - Callback m_modelChanged; +ResourceReference m_resource; +scene::Traversable& m_traverse; +scene::Node* m_node; +Callback m_modelChanged; public: - EModel(scene::Traversable& traversable, const Callback& modelChanged) - : m_resource(""), m_traverse(traversable), m_node(0), m_modelChanged(modelChanged) - { - m_resource.attach(*this); - } - ~EModel() - { - m_resource.detach(*this); - } - - void realise() - { - m_resource.get()->load(); - m_node = m_resource.get()->getNode(); - if(m_node != 0) - { - m_traverse.insert(*m_node); - } - } - void unrealise() - { - if(m_node != 0) - { - m_traverse.erase(*m_node); - } - } - - void modelChanged(const char* value) - { - StringOutputStream cleaned(string_length(value)); - cleaned << PathCleaned(value); - m_resource.detach(*this); - m_resource.setName(cleaned.c_str()); - m_resource.attach(*this); - m_modelChanged(); - } - typedef MemberCaller1 ModelChangedCaller; - - const char* getName() const - { - return m_resource.getName(); - } - scene::Node* getNode() const - { - return m_node; - } +EModel( scene::Traversable& traversable, const Callback& modelChanged ) + : m_resource( "" ), m_traverse( traversable ), m_node( 0 ), m_modelChanged( modelChanged ){ + m_resource.attach( *this ); +} +~EModel(){ + m_resource.detach( *this ); +} + +void realise(){ + m_resource.get()->load(); + m_node = m_resource.get()->getNode(); + if ( m_node != 0 ) { + m_traverse.insert( *m_node ); + } +} +void unrealise(){ + if ( m_node != 0 ) { + m_traverse.erase( *m_node ); + } +} + +void modelChanged( const char* value ){ + StringOutputStream cleaned( string_length( value ) ); + cleaned << PathCleaned( value ); + m_resource.detach( *this ); + m_resource.setName( cleaned.c_str() ); + m_resource.attach( *this ); + m_modelChanged(); +} +typedef MemberCaller ModelChangedCaller; + +const char* getName() const { + return m_resource.getName(); +} +scene::Node* getNode() const { + return m_node; +} }; class SingletonModel { - TraversableNode m_traverse; - EModel m_model; +TraversableNode m_traverse; +EModel m_model; public: - SingletonModel() - : m_model(m_traverse, Callback()) - { - } - - void attach(scene::Traversable::Observer* observer) - { - m_traverse.attach(observer); - } - void detach(scene::Traversable::Observer* observer) - { - m_traverse.detach(observer); - } - - scene::Traversable& getTraversable() - { - return m_traverse; - } - - void modelChanged(const char* value) - { - m_model.modelChanged(value); - } - typedef MemberCaller1 ModelChangedCaller; - - scene::Node* getNode() const - { - return m_model.getNode(); - } +SingletonModel() + : m_model( m_traverse, Callback() ){ +} + +void attach( scene::Traversable::Observer* observer ){ + m_traverse.attach( observer ); +} +void detach( scene::Traversable::Observer* observer ){ + m_traverse.detach( observer ); +} + +scene::Traversable& getTraversable(){ + return m_traverse; +} + +void modelChanged( const char* value ){ + m_model.modelChanged( value ); +} +typedef MemberCaller ModelChangedCaller; + +scene::Node* getNode() const { + return m_model.getNode(); +} }; #endif