[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Pingus-CVS] r3082 - trunk/pingus/src/editor
From: |
grumbel at BerliOS |
Subject: |
[Pingus-CVS] r3082 - trunk/pingus/src/editor |
Date: |
Wed, 5 Sep 2007 04:21:08 +0200 |
Author: grumbel
Date: 2007-09-05 04:21:07 +0200 (Wed, 05 Sep 2007)
New Revision: 3082
Modified:
trunk/pingus/src/editor/editor_screen.cpp
trunk/pingus/src/editor/editor_viewport.cpp
trunk/pingus/src/editor/editor_viewport.hpp
Log:
- implemented deletion of selected objects
- some code cleanup (no semantic changes)
Modified: trunk/pingus/src/editor/editor_screen.cpp
===================================================================
--- trunk/pingus/src/editor/editor_screen.cpp 2007-09-05 02:11:34 UTC (rev
3081)
+++ trunk/pingus/src/editor/editor_screen.cpp 2007-09-05 02:21:07 UTC (rev
3082)
@@ -219,7 +219,7 @@
void
EditorScreen::objects_delete()
{
- std::cout << "Function at '" << __FILE__ << ":" << __LINE__ << "' is
unimplemented" << std::endl;
+ viewport->delete_selected_objects();
}
void
@@ -271,21 +271,18 @@
std::cout << "Function at '" << __FILE__ << ":" << __LINE__ << "' is
unimplemented" << std::endl;
}
-
void
EditorScreen::toggle_grid_snap()
{
std::cout << "Function at '" << __FILE__ << ":" << __LINE__ << "' is
unimplemented" << std::endl;
}
-
void
EditorScreen::toggle_object_selector()
{
std::cout << "Function at '" << __FILE__ << ":" << __LINE__ << "' is
unimplemented" << std::endl;
}
-
void
EditorScreen::toggle_help()
{
Modified: trunk/pingus/src/editor/editor_viewport.cpp
===================================================================
--- trunk/pingus/src/editor/editor_viewport.cpp 2007-09-05 02:11:34 UTC (rev
3081)
+++ trunk/pingus/src/editor/editor_viewport.cpp 2007-09-05 02:21:07 UTC (rev
3082)
@@ -69,11 +69,11 @@
<< mouse_pos.y << std::endl;
// LevelObj* obj = object_at((int)mouse_pos.x, (int)mouse_pos.y);
- if (!current_objs.empty())
+ if (!selected_objs.empty())
{
// std::vector<LevelObj*> objs;
// objs.push_back(obj);
- context_menu = new ContextMenu(current_objs, Vector3f((float)x,
(float)y), this);
+ context_menu = new ContextMenu(selected_objs, Vector3f((float)x,
(float)y), this);
editor->get_gui_manager()->add(context_menu, true);
}
}
@@ -94,11 +94,11 @@
// If the currently selected object isn't selected, select it and
deselect the rest
if (!obj->is_selected())
{
- for (unsigned i = 0; i < current_objs.size(); i++)
- current_objs[i]->unselect();
- current_objs.clear();
+ for (unsigned i = 0; i < selected_objs.size(); i++)
+ selected_objs[i]->unselect();
+ selected_objs.clear();
obj->select();
- current_objs.push_back(obj);
+ selected_objs.push_back(obj);
}
// Allow dragging of the currently selected objects
current_action = DRAGGING;
@@ -106,7 +106,7 @@
}
else
{
- current_objs.clear();
+ selected_objs.clear();
current_action = HIGHLIGHTING;
highlighted_area.left = highlighted_area.right = x;
highlighted_area.top = highlighted_area.bottom = y;
@@ -114,7 +114,6 @@
}
}
-
void
EditorViewport::on_primary_button_release(int x, int y)
{
@@ -135,7 +134,7 @@
if (highlighted_area.is_inside(obj_pos))
{
- current_objs.push_back(objs[i]);
+ selected_objs.push_back(objs[i]);
objs[i]->select();
}
else
@@ -167,9 +166,9 @@
{
float new_x, new_y;
- for (unsigned i = 0; i < current_objs.size(); i++)
+ for (unsigned i = 0; i < selected_objs.size(); i++)
{
- Vector3f orig_pos(current_objs[i]->get_orig_pos());
+ Vector3f orig_pos(selected_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;
if (snap_to)
@@ -183,7 +182,7 @@
new_x = x_offset + orig_pos.x;
new_y = y_offset + orig_pos.y;
}
- current_objs[i]->set_pos(Vector3f(new_x, new_y, orig_pos.z));
+ selected_objs[i]->set_pos(Vector3f(new_x, new_y, orig_pos.z));
}
}
}
@@ -282,6 +281,15 @@
objs.push_back(obj);
}
+void
+EditorViewport::delete_selected_objects()
+{
+ for(std::vector<LevelObj*>::iterator i = selected_objs.begin(); i !=
selected_objs.end(); ++i)
+ {
+ (*i)->remove();
+ }
+}
+
} // Editor namespace
/* EOF */
Modified: trunk/pingus/src/editor/editor_viewport.hpp
===================================================================
--- trunk/pingus/src/editor/editor_viewport.hpp 2007-09-05 02:11:34 UTC (rev
3081)
+++ trunk/pingus/src/editor/editor_viewport.hpp 2007-09-05 02:21:07 UTC (rev
3082)
@@ -40,49 +40,9 @@
/** This class is where the actual level graphics will display in the
level editor. Objects can be added, deleted, moved, modified, etc.
inside of the EditorViewport */
-class EditorViewport : public GUI::Component {
-
-public:
- /** Constructor
- @param e The EditorScreen to which this viewport belongs */
- EditorViewport (EditorScreen* e);
-
- /** Destructor */
- ~EditorViewport ();
-
- /** Draws all of the objects in the viewport */
- void draw(DrawingContext &gc);
-
- /** Update information about scrolling, etc. */
- void update(float delta);
-
- /** Returns whether or not the mouse is inside the viewport */
- bool is_at(int x, int y);
-
- /** Emitted when the pointer moved, x and y are the new pointer
- coordinates */
- void on_pointer_move (int x, int y);
-
- /** Get rid of context menu if it exists */
- void remove_context_menu();
-
- /** Refresh the list of objects (do when loading or creating a new level) */
- void refresh();
-
- /** Turns the "snap-to-grid" option on or off */
- void set_snap_to(bool s) { snap_to = s; }
-
- /** Add an object to the currently displayed vector of objects */
- void add_object(LevelObj* obj);
-
- /** Return a pointer to the EditorScreen object */
- EditorScreen* get_screen() { return editor; }
-
-private:
- EditorViewport();
- EditorViewport (const EditorViewport&);
- EditorViewport& operator= (const EditorViewport&);
-
+class EditorViewport : public GUI::Component
+{
+private:
GraphicContextState state;
SceneContext* scene_context;
@@ -105,7 +65,7 @@
std::vector<LevelObj*> objs;
/** The currently selected LevelObjs */
- std::vector<LevelObj*> current_objs;
+ std::vector<LevelObj*> selected_objs;
/** The region that is currently highlighted */
Rect highlighted_area;
@@ -122,10 +82,53 @@
/** What is the currently selected action that the mouse is doing */
enum ActionType { NOTHING = 0, HIGHLIGHTING = 1, DRAGGING = 2 }
current_action;
+public:
+ /** Constructor
+ @param e The EditorScreen to which this viewport belongs */
+ EditorViewport (EditorScreen* e);
+
+ /** Destructor */
+ ~EditorViewport ();
+
+ /** Draws all of the objects in the viewport */
+ void draw(DrawingContext &gc);
+
+ /** Update information about scrolling, etc. */
+ void update(float delta);
+
+ /** Returns whether or not the mouse is inside the viewport */
+ bool is_at(int x, int y);
+
+ /** Emitted when the pointer moved, x and y are the new pointer
+ coordinates */
+ void on_pointer_move (int x, int y);
+
+ /** Get rid of context menu if it exists */
+ void remove_context_menu();
+
+ /** Refresh the list of objects (do when loading or creating a new level) */
+ void refresh();
+
+ /** Turns the "snap-to-grid" option on or off */
+ void set_snap_to(bool s) { snap_to = s; }
+
+ /** Add an object to the currently displayed vector of objects */
+ void add_object(LevelObj* obj);
+
+ /** Return a pointer to the EditorScreen object */
+ EditorScreen* get_screen() { return editor; }
+
/// Mouse actions
void on_primary_button_press(int x, int y);
void on_primary_button_release(int x, int y);
void on_secondary_button_click(int x, int y);
+
+ void delete_selected_objects();
+
+private:
+ EditorViewport();
+ EditorViewport (const EditorViewport&);
+ EditorViewport& operator= (const EditorViewport&);
};
} // Editor namespace
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Pingus-CVS] r3082 - trunk/pingus/src/editor,
grumbel at BerliOS <=