X-Git-Url: http://git.xonotic.org/?a=blobdiff_plain;f=plugins%2Fentity%2Fnamedentity.h;h=857b10b44a5e41a0066da12e01fc5fc8feb0a08a;hb=18d60f90d7603cb420150739251cf98519c57406;hp=6258d1ce523213aeede24867b6e2dfbbb7f69d0d;hpb=bfc8a12a6b315ae261101a34db8ba1b682c67bb7;p=xonotic%2Fnetradiant.git diff --git a/plugins/entity/namedentity.h b/plugins/entity/namedentity.h index 6258d1ce..857b10b4 100644 --- a/plugins/entity/namedentity.h +++ b/plugins/entity/namedentity.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_NAMEDENTITY_H) +#if !defined( INCLUDED_NAMEDENTITY_H ) #define INCLUDED_NAMEDENTITY_H #include "entitylib.h" @@ -31,81 +31,69 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA class NameCallbackSet { - typedef std::set NameCallbacks; - NameCallbacks m_callbacks; +typedef std::set NameCallbacks; +NameCallbacks m_callbacks; public: - void insert(const NameCallback& callback) - { - m_callbacks.insert(callback); - } - void erase(const NameCallback& callback) - { - m_callbacks.erase(callback); - } - void changed(const char* name) const - { - for(NameCallbacks::const_iterator i = m_callbacks.begin(); i != m_callbacks.end(); ++i) - { - (*i)(name); - } - } +void insert( const NameCallback& callback ){ + m_callbacks.insert( callback ); +} +void erase( const NameCallback& callback ){ + m_callbacks.erase( callback ); +} +void changed( const char* name ) const { + for ( NameCallbacks::const_iterator i = m_callbacks.begin(); i != m_callbacks.end(); ++i ) + { + ( *i )( name ); + } +} }; class NamedEntity : public Nameable { - EntityKeyValues& m_entity; - NameCallbackSet m_changed; - CopiedString m_name; +EntityKeyValues& m_entity; +NameCallbackSet m_changed; +CopiedString m_name; public: - NamedEntity(EntityKeyValues& entity) : m_entity(entity) - { - } - const char* name() const - { - if(string_empty(m_name.c_str())) - { - return m_entity.getEntityClass().name(); - } - return m_name.c_str(); - } - void attach(const NameCallback& callback) - { - m_changed.insert(callback); - } - void detach(const NameCallback& callback) - { - m_changed.erase(callback); - } +NamedEntity( EntityKeyValues& entity ) : m_entity( entity ){ +} +const char* name() const { + if ( string_empty( m_name.c_str() ) ) { + return m_entity.getEntityClass().name(); + } + return m_name.c_str(); +} +void attach( const NameCallback& callback ){ + m_changed.insert( callback ); +} +void detach( const NameCallback& callback ){ + m_changed.erase( callback ); +} - void identifierChanged(const char* value) - { - if(string_empty(value)) - { - m_changed.changed(m_entity.getEntityClass().name()); - } - else - { - m_changed.changed(value); - } - m_name = value; - } - typedef MemberCaller1 IdentifierChangedCaller; +void identifierChanged( const char* value ){ + if ( string_empty( value ) ) { + m_changed.changed( m_entity.getEntityClass().name() ); + } + else + { + m_changed.changed( value ); + } + m_name = value; +} +typedef MemberCaller IdentifierChangedCaller; }; class RenderableNamedEntity : public OpenGLRenderable { - const NamedEntity& m_named; - const Vector3& m_position; +const NamedEntity& m_named; +const Vector3& m_position; public: - RenderableNamedEntity(const NamedEntity& named, const Vector3& position) - : m_named(named), m_position(position) - { - } - void render(RenderStateFlags state) const - { - glRasterPos3fv(vector3_to_array(m_position)); - GlobalOpenGL().drawString(m_named.name()); - } +RenderableNamedEntity( const NamedEntity& named, const Vector3& position ) + : m_named( named ), m_position( position ){ +} +void render( RenderStateFlags state ) const { + glRasterPos3fv( vector3_to_array( m_position ) ); + GlobalOpenGL().drawString( m_named.name() ); +} };