pingus-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Pingus-CVS] r3113 - trunk/pingus/src/editor


From: grumbel at BerliOS
Subject: [Pingus-CVS] r3113 - trunk/pingus/src/editor
Date: Sat, 8 Sep 2007 22:46:23 +0200

Author: grumbel
Date: 2007-09-08 22:46:22 +0200 (Sat, 08 Sep 2007)
New Revision: 3113

Modified:
   trunk/pingus/src/editor/editor_screen.cpp
   trunk/pingus/src/editor/editor_viewport.cpp
   trunk/pingus/src/editor/editor_viewport.hpp
   trunk/pingus/src/editor/object_properties.cpp
   trunk/pingus/src/editor/object_properties.hpp
Log:
- added signal to update object property dialog

Modified: trunk/pingus/src/editor/editor_screen.cpp
===================================================================
--- trunk/pingus/src/editor/editor_screen.cpp   2007-09-08 16:05:48 UTC (rev 
3112)
+++ trunk/pingus/src/editor/editor_screen.cpp   2007-09-08 20:46:22 UTC (rev 
3113)
@@ -19,6 +19,7 @@
 //  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 
 #include <iostream>
+#include <boost/bind.hpp>
 #include "../gui/display.hpp"
 #include "../system.hpp"
 #include "../sound/sound.hpp"
@@ -68,6 +69,8 @@
   file_load_dialog->set_directory(".");
   file_load_dialog->hide();
   gui_manager->add(file_load_dialog, true);
+
+  
viewport->selection_changed.connect(boost::bind(&ObjectProperties::set_objects, 
object_properties, _1));
 }
 
 // Destructor

Modified: trunk/pingus/src/editor/editor_viewport.cpp
===================================================================
--- trunk/pingus/src/editor/editor_viewport.cpp 2007-09-08 16:05:48 UTC (rev 
3112)
+++ trunk/pingus/src/editor/editor_viewport.cpp 2007-09-08 20:46:22 UTC (rev 
3113)
@@ -128,6 +128,8 @@
               selected_objs.clear();
               obj->select();
               selected_objs.push_back(obj);
+
+              selection_changed(selected_objs);
             }
 
           // Allow dragging of the currently selected objects
@@ -140,6 +142,8 @@
           current_action = HIGHLIGHTING;
           highlighted_area.left = highlighted_area.right  = mouse_world_pos.x;
           highlighted_area.top  = highlighted_area.bottom = mouse_world_pos.y;
+
+          selection_changed(selected_objs);
         }
     }
 }
@@ -164,6 +168,8 @@
           else
             objs[i]->unselect();
         }
+
+      selection_changed(selected_objs);
     }
   else if (current_action == DRAGGING)
     {
@@ -323,6 +329,8 @@
     {
       (*i)->remove();
     }
+  selected_objs.clear();
+  selection_changed(selected_objs);
 }
 
 void

Modified: trunk/pingus/src/editor/editor_viewport.hpp
===================================================================
--- trunk/pingus/src/editor/editor_viewport.hpp 2007-09-08 16:05:48 UTC (rev 
3112)
+++ trunk/pingus/src/editor/editor_viewport.hpp 2007-09-08 20:46:22 UTC (rev 
3113)
@@ -23,6 +23,7 @@
 
 #include "../gui/component.hpp"
 #include "../graphic_context_state.hpp"
+#include <boost/signal.hpp>
 #include <vector>
 #include <string>
 
@@ -135,6 +136,8 @@
   void rotate_270_selected_objects();
 
   Vector2i screen2world(int x, int y) const;
+
+  boost::signal<void (const std::vector<LevelObj*>&)> selection_changed;
 private:
   EditorViewport();
   EditorViewport (const EditorViewport&);

Modified: trunk/pingus/src/editor/object_properties.cpp
===================================================================
--- trunk/pingus/src/editor/object_properties.cpp       2007-09-08 16:05:48 UTC 
(rev 3112)
+++ trunk/pingus/src/editor/object_properties.cpp       2007-09-08 20:46:22 UTC 
(rev 3113)
@@ -19,6 +19,8 @@
 
 #include "button.hpp"
 #include "editor_screen.hpp"
+#include "level_objs.hpp"
+#include "fonts.hpp"
 #include "object_properties.hpp"
 
 namespace Editor {
@@ -27,8 +29,7 @@
   : GUI::GroupComponent(rect),
     editor(editor_)
 {
-  add(new Button(Rect(10, 10, 100, 20), "Test"), true);
-  add(new Button(Rect(10, 100, 100, 220), "Test 2"), true);
+  add(new Button(Rect(10, 50, 100, 70), "Test 2"), true);
 }
 
 ObjectProperties::~ObjectProperties()
@@ -45,7 +46,29 @@
 {
   gc.draw_fillrect(0,0, rect.get_width(), rect.get_height(), 
                    Color(255, 255, 0));
+
+  std::string obj_type;
+  if (objects.empty())
+    {
+      obj_type = "[Empty]";
+    }
+  else if (objects.size() > 1)
+    {
+      obj_type = "[Group]";
+    }
+  else
+    {
+      obj_type = objects.front()->get_section_name();
+    }
+  gc.print_center(Fonts::courier_small, rect.get_width()/2, 10, 
+                  obj_type);
 }
+
+void
+ObjectProperties::set_objects(const std::vector<LevelObj*>& objs)
+{
+  objects = objs;
+}
 
 } // namespace Editor
 

Modified: trunk/pingus/src/editor/object_properties.hpp
===================================================================
--- trunk/pingus/src/editor/object_properties.hpp       2007-09-08 16:05:48 UTC 
(rev 3112)
+++ trunk/pingus/src/editor/object_properties.hpp       2007-09-08 20:46:22 UTC 
(rev 3113)
@@ -32,7 +32,7 @@
 {
 private:
   EditorScreen* editor;
-  LevelObj* current_object;
+  std::vector<LevelObj*> objects;
   
 public:
   ObjectProperties(EditorScreen* editor, const Rect& rect);
@@ -41,6 +41,7 @@
   void set_object(LevelObj* obj);
   void draw_background(DrawingContext& gc);
 
+  void set_objects(const std::vector<LevelObj*>& objs);
 private:
   ObjectProperties (const ObjectProperties&);
   ObjectProperties& operator= (const ObjectProperties&);





reply via email to

[Prev in Thread] Current Thread [Next in Thread]