]> git.tdb.fi Git - r2c2.git/blobdiff - source/designer/objectproperties.cpp
Add property editing for terrain
[r2c2.git] / source / designer / objectproperties.cpp
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);
+}