pingus-cvs
[Top][All Lists]
Advanced

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

[Pingus-CVS] r2574 - trunk/src/editor


From: jave27
Subject: [Pingus-CVS] r2574 - trunk/src/editor
Date: Tue, 3 Jan 2006 22:53:03 +0100

Author: jave27
Date: 2006-01-03 22:52:59 +0100 (Tue, 03 Jan 2006)
New Revision: 2574

Modified:
   trunk/src/editor/editor_viewport.cxx
   trunk/src/editor/level_objs.hxx
   trunk/src/editor/xml_level.cxx
Log:
Re-enabled snap-to when dragging objects around.

Modified: trunk/src/editor/editor_viewport.cxx
===================================================================
--- trunk/src/editor/editor_viewport.cxx        2006-01-03 21:06:48 UTC (rev 
2573)
+++ trunk/src/editor/editor_viewport.cxx        2006-01-03 21:52:59 UTC (rev 
2574)
@@ -131,7 +131,7 @@
                        CL_Point obj_pos((int)objs[i]->get_pos().x + 
(state.get_width()/2 - 
                                (int)state.get_pos().x), 
(int)objs[i]->get_pos().y + (state.get_height()/2 - 
                                (int)state.get_pos().y));
-                       //CL_Point obj_pos((int)objs[i]->get_pos().x, 
(int)objs[i]->get_pos().y);
+                       
                        if (highlighted_area.is_inside(obj_pos))
                        {
                                current_objs.push_back(objs[i]);
@@ -141,8 +141,13 @@
                                objs[i]->unselect();
                }
        }
+       else if (current_action == DRAGGING)
+       {
+               // Set the objects' positions for good
+               for (unsigned i = 0; i < objs.size(); i++)
+                       objs[i]->set_orig_pos(objs[i]->get_pos());
+       }
        current_action = NOTHING;
-       //highlighted_area.set_size(CL_Size(0,0));
 }
 
 void
@@ -163,12 +168,10 @@
 
                for (unsigned i = 0; i < current_objs.size(); i++)
                {
-                       Vector orig_pos(current_objs[i]->get_pos());
+                       Vector orig_pos(current_objs[i]->get_orig_pos());
                        float x_offset = mouse_at_world.x - drag_start_pos.x;
                        float y_offset = mouse_at_world.y - drag_start_pos.y;
-                       // FIXME: Snap_to not working correctly with offsets.
-                       //if (snap_to)
-                       if (0)
+                       if (snap_to)
                        {
                                // FIXME: May need to adjust the snap-to offset 
here.
                                new_x = (float)((int)((x_offset + orig_pos.x) / 
10) * 10);
@@ -181,10 +184,10 @@
                        }
                        current_objs[i]->set_pos(Vector(new_x, new_y, 
orig_pos.z));
                }
-               drag_start_pos = mouse_at_world;
        }
 }
 
+
 // Draws all of the objects in the viewport and the background (if any)
 void
 EditorViewport::draw(DrawingContext &gc)
@@ -218,6 +221,8 @@
 void
 EditorViewport::update(float delta)
 {
+       UNUSED_ARG(delta);
+
        // Autoscroll if necessary
        if (autoscroll)
        {

Modified: trunk/src/editor/level_objs.hxx
===================================================================
--- trunk/src/editor/level_objs.hxx     2006-01-03 21:06:48 UTC (rev 2573)
+++ trunk/src/editor/level_objs.hxx     2006-01-03 21:52:59 UTC (rev 2574)
@@ -87,6 +87,9 @@
        /** Location of this object in the World */
        Vector pos;
 
+       /** Location of this object before moving it around */
+       Vector orig_pos;
+
        /** Name of the section header for this object (hotspot, groundpiece, 
etc.) */
        std::string section_name;
 
@@ -153,6 +156,7 @@
 public:
        /** Retrieve the object's position */
        Vector get_pos() const { return pos; }
+       Vector get_orig_pos() const { return orig_pos; }
 
        /** Retrieve this object's attribute number */
        unsigned get_attribs() const { return attribs; }
@@ -216,6 +220,7 @@
 public:
        /** Set the object's position */
        void set_pos(const Vector p) { pos = p; }
+       void set_orig_pos(const Vector p) { orig_pos = p; }
 
        /** Set the object's resource name */
        void set_res_desc(const ResDescriptor d);

Modified: trunk/src/editor/xml_level.cxx
===================================================================
--- trunk/src/editor/xml_level.cxx      2006-01-03 21:06:48 UTC (rev 2573)
+++ trunk/src/editor/xml_level.cxx      2006-01-03 21:52:59 UTC (rev 2574)
@@ -166,6 +166,7 @@
 
                // All objects have a position - get that.
                i->read_vector("position", p);
+               obj->set_orig_pos(p);
                obj->set_pos(p);
 
                // Get optional attributes based on the attribs value





reply via email to

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