]> git.tdb.fi Git - r2c2.git/commitdiff
Add property editing for terrain
authorMikko Rasa <tdb@tdb.fi>
Fri, 22 Nov 2013 09:39:23 +0000 (11:39 +0200)
committerMikko Rasa <tdb@tdb.fi>
Fri, 22 Nov 2013 09:39:23 +0000 (11:39 +0200)
source/designer/objectproperties.cpp
source/designer/objectproperties.h

index af090335cf10313afc15e430c8e25e5b33215dee..70ddb600e953cca5f24f72853fcd34ed6d664095 100644 (file)
@@ -63,6 +63,11 @@ ObjectProperties::ObjectProperties(const Selection &selection):
                        lbl_title->set_text("Beam gate properties");
                        properties = new BeamGateProperties(*this, *gate);
                }
+               else if(Terrain *terrain = dynamic_cast<Terrain *>(object))
+               {
+                       lbl_title->set_text("Terrain properties");
+                       properties = new TerrainProperties(*this, *terrain);
+               }
        }
 
        if(!properties)
@@ -169,3 +174,17 @@ void ObjectProperties::BeamGateProperties::apply()
 {
        gate.set_address(lexical_cast<unsigned>(ent_address->get_text()));
 }
+
+
+ObjectProperties::TerrainProperties::TerrainProperties(ObjectProperties &p, Terrain &t):
+       terrain(t),
+       ent_width(p.add_property("Width", lexical_cast<string>(terrain.get_width()), 4)),
+       ent_height(p.add_property("Height", lexical_cast<string>(terrain.get_height()), 4))
+{ }
+
+void ObjectProperties::TerrainProperties::apply()
+{
+       unsigned width = lexical_cast<unsigned>(ent_width->get_text());
+       unsigned height = lexical_cast<unsigned>(ent_height->get_text());
+       terrain.set_size(width, height);
+}
index 9180206bd2f8aa5989f3654b4b78d0a2ca746f41..8433b68386dbbacdaa607ea37a45fcae71a5c64b 100644 (file)
@@ -5,6 +5,7 @@
 #include <msp/gltk/entry.h>
 #include "libr2c2/beamgate.h"
 #include "libr2c2/signal.h"
+#include "libr2c2/terrain.h"
 #include "libr2c2/track.h"
 
 class Selection;
@@ -70,6 +71,19 @@ private:
                virtual void apply();
        };
 
+       class TerrainProperties: public Properties
+       {
+       private:
+               R2C2::Terrain &terrain;
+               Msp::GLtk::Entry *ent_width;
+               Msp::GLtk::Entry *ent_height;
+
+       public:
+               TerrainProperties(ObjectProperties &, R2C2::Terrain &);
+
+               virtual void apply();
+       };
+
        Properties *properties;
        Msp::GLtk::Widget *prev_widget;