pingus-cvs
[Top][All Lists]
Advanced

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

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


From: grumbel at BerliOS
Subject: [Pingus-CVS] r3103 - trunk/pingus/src/editor
Date: Fri, 7 Sep 2007 00:53:07 +0200

Author: grumbel
Date: 2007-09-07 00:53:07 +0200 (Fri, 07 Sep 2007)
New Revision: 3103

Modified:
   trunk/pingus/src/editor/editor_viewport.cpp
   trunk/pingus/src/editor/object_selector.cpp
   trunk/pingus/src/editor/object_selector.hpp
Log:
- added drag&drop for object insertion (very buggy and incomplete)

Modified: trunk/pingus/src/editor/editor_viewport.cpp
===================================================================
--- trunk/pingus/src/editor/editor_viewport.cpp 2007-09-06 22:35:34 UTC (rev 
3102)
+++ trunk/pingus/src/editor/editor_viewport.cpp 2007-09-06 22:53:07 UTC (rev 
3103)
@@ -36,7 +36,10 @@
 
 // Constructor
 EditorViewport::EditorViewport(EditorScreen* e) 
-  : rect(48, 38 + 48, Display::get_width() - 248 - 48, 600 - 48),
+  : rect(0,
+         38,
+         Display::get_width() - 244, 
+         600),
     state(rect.get_width(), rect.get_height()),
     drawing_context(new DrawingContext(rect)),
     editor(e),

Modified: trunk/pingus/src/editor/object_selector.cpp
===================================================================
--- trunk/pingus/src/editor/object_selector.cpp 2007-09-06 22:35:34 UTC (rev 
3102)
+++ trunk/pingus/src/editor/object_selector.cpp 2007-09-06 22:53:07 UTC (rev 
3103)
@@ -30,6 +30,9 @@
 #include "display/drawing_context.hpp"
 #include "fonts.hpp"
 #include "math.hpp"
+#include "editor_viewport.hpp"
+#include "editor_level.hpp"
+#include "level_objs.hpp"
 #include "display/drawing_context.hpp"
 #include "gui/gui_manager.hpp"
 #include "object_selector.hpp"
@@ -285,10 +288,14 @@
   if (mode == OBJECT_DRAG)
     {
       mode = NOTHING;
-
-      //LevelObj* obj = new LevelObj();
-      // find out mouse_co in the level
-      //editor->add_object(obj);
+      
+      if (current_object != -1)
+        {
+          LevelObj* obj = new LevelObj("groundpiece", 
editor->get_level()->get_level_impl());
+          obj->set_res_desc(objects[current_object].desc);
+          obj->set_pos(editor->get_viewport()->screen2world(x,y));
+          editor->add_object(obj);
+        }
     }
 }
 
@@ -342,7 +349,9 @@
       Sprite sprite = Resource::load_sprite(*i);
       //sprite.scale(48, 48);
       // need to reset the align to top/left
-      objects.push_back(Object(sprite));
+      Object obj(sprite);
+      obj.desc = ResDescriptor(*i);
+      objects.push_back(obj);
     }
 }
 

Modified: trunk/pingus/src/editor/object_selector.hpp
===================================================================
--- trunk/pingus/src/editor/object_selector.hpp 2007-09-06 22:35:34 UTC (rev 
3102)
+++ trunk/pingus/src/editor/object_selector.hpp 2007-09-06 22:53:07 UTC (rev 
3103)
@@ -27,7 +27,7 @@
 #define HEADER_OBJECT_SELECTOR_HPP
 
 #include "gui/component.hpp"
-
+#include "res_descriptor.hpp"
 class DrawingContext;
 
 namespace Editor {
@@ -53,8 +53,8 @@
 
   struct Object 
   {
-    Sprite sprite;
-    // add meta-info to track object type
+    Sprite      sprite;
+    ResDescriptor desc;
 
     Object(const Sprite& sprite_) 
       : sprite(sprite_)





reply via email to

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