]> de.git.xonotic.org Git - xonotic/netradiant.git/blobdiff - plugins/entity/colour.h
reformat code! now the code is only ugly on the *inside*
[xonotic/netradiant.git] / plugins / entity / colour.h
index 86e0deb60037900f6e2c863a239dc3c1946135d9..ae209d239e29425a70110c77215a8b7ab5b3da4c 100644 (file)
 #include "generic/callback.h"
 #include "stringio.h"
 
-inline void default_colour( Vector3& colour ){
-       colour = Vector3( 1, 1, 1 );
-}
-inline void read_colour( Vector3& colour, const char* value ){
-       if ( !string_parse_vector3( value, colour ) ) {
-               default_colour( colour );
-       }
+inline void default_colour(Vector3 &colour)
+{
+    colour = Vector3(1, 1, 1);
 }
-inline void write_colour( const Vector3& colour, Entity* entity ){
-       char value[64];
 
-       sprintf( value, "%f %f %f", colour[0], colour[1], colour[2] );
-       entity->setKeyValue( "_color", value );
+inline void read_colour(Vector3 &colour, const char *value)
+{
+    if (!string_parse_vector3(value, colour)) {
+        default_colour(colour);
+    }
 }
 
-class Colour
+inline void write_colour(const Vector3 &colour, Entity *entity)
 {
-Callback<void()> m_colourChanged;
-Shader* m_state;
+    char value[64];
 
-void capture_state(){
-       m_state = colour_capture_state_fill( m_colour );
-}
-void release_state(){
-       colour_release_state_fill( m_colour );
+    sprintf(value, "%f %f %f", colour[0], colour[1], colour[2]);
+    entity->setKeyValue("_color", value);
 }
 
+class Colour {
+    Callback<void()> m_colourChanged;
+    Shader *m_state;
+
+    void capture_state()
+    {
+        m_state = colour_capture_state_fill(m_colour);
+    }
+
+    void release_state()
+    {
+        colour_release_state_fill(m_colour);
+    }
+
 public:
-Vector3 m_colour;
+    Vector3 m_colour;
 
-Colour( const Callback<void()>& colourChanged )
-       : m_colourChanged( colourChanged ){
-       default_colour( m_colour );
-       capture_state();
-}
-~Colour(){
-       release_state();
-}
+    Colour(const Callback<void()> &colourChanged)
+            : m_colourChanged(colourChanged)
+    {
+        default_colour(m_colour);
+        capture_state();
+    }
 
-void colourChanged( const char* value ){
-       release_state();
-       read_colour( m_colour, value );
-       capture_state();
+    ~Colour()
+    {
+        release_state();
+    }
 
-       m_colourChanged();
-}
-typedef MemberCaller<Colour, void(const char*), &Colour::colourChanged> ColourChangedCaller;
+    void colourChanged(const char *value)
+    {
+        release_state();
+        read_colour(m_colour, value);
+        capture_state();
 
+        m_colourChanged();
+    }
 
-void write( Entity* entity ) const {
-       write_colour( m_colour, entity );
-}
+    typedef MemberCaller<Colour, void(const char *), &Colour::colourChanged> ColourChangedCaller;
 
-Shader* state() const {
-       return m_state;
-}
+
+    void write(Entity *entity) const
+    {
+        write_colour(m_colour, entity);
+    }
+
+    Shader *state() const
+    {
+        return m_state;
+    }
 };
 
 #endif