[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Pingus-CVS] CVS: Games/Pingus/src/editor editor.cxx,1.16,1.17 editor.hx
From: |
grumbel |
Subject: |
[Pingus-CVS] CVS: Games/Pingus/src/editor editor.cxx,1.16,1.17 editor.hxx,1.7,1.8 editor_event.cxx,1.20,1.21 object_manager.cxx,1.17,1.18 object_manager.hxx,1.10,1.11 selection.cxx,1.6,1.7 selection.hxx,1.5,1.6 |
Date: |
2 Jul 2002 09:14:22 -0000 |
Update of /usr/local/cvsroot/Games/Pingus/src/editor
In directory dark:/tmp/cvs-serv682/editor
Modified Files:
editor.cxx editor.hxx editor_event.cxx object_manager.cxx
object_manager.hxx selection.cxx selection.hxx
Log Message:
some more bug fixes
Index: editor.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/editor/editor.cxx,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -d -r1.16 -r1.17
--- editor.cxx 1 Jul 2002 16:47:30 -0000 1.16
+++ editor.cxx 2 Jul 2002 09:14:20 -0000 1.17
@@ -420,9 +420,6 @@
{
CL_Vector start_pos (CL_Mouse::get_x(),
CL_Mouse::get_y ());
-
- //std::cout << "Editor: Selecting rectangle... " << std::flush;
-
CL_Vector end_pos;
while (CL_Mouse::middle_pressed())
@@ -447,9 +444,8 @@
start_pos = view->screen_to_world (start_pos);
end_pos = view->screen_to_world (end_pos);
- selection->select_rect(start_pos.x, start_pos.y, end_pos.x, end_pos.y);
-
- //std::cout << "finished" << std::endl;
+ selection->select_rect(start_pos.x, start_pos.y,
+ end_pos.x, end_pos.y);
}
bool
@@ -509,18 +505,6 @@
CL_System::keep_alive();
}
selection->drop ();
-}
-
-void
-Editor::edit_current_objs()
-{
- std::cout << "Editor::edit_current_objs(): Not implemented" << std::endl;
- /* boost::shared_ptr<EditorObj> obj = object_manager->get_current_obj();
-
- if (obj.get())
- obj->gui_edit_obj();
- else
- std::cout << "No single object selected" << std::endl;*/
}
void
Index: editor.hxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/editor/editor.hxx,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- editor.hxx 1 Jul 2002 16:10:29 -0000 1.7
+++ editor.hxx 2 Jul 2002 09:14:20 -0000 1.8
@@ -109,7 +109,6 @@
bool mouse_moved();
void scroll();
- void edit_current_objs();
void zoom_mode ();
void load_level (const std::string& str);
Index: editor_event.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/editor/editor_event.cxx,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -d -r1.20 -r1.21
--- editor_event.cxx 1 Jul 2002 18:36:39 -0000 1.20
+++ editor_event.cxx 2 Jul 2002 09:14:20 -0000 1.21
@@ -386,15 +386,13 @@
{
if (selection->get_current_obj())
{
- boost::shared_ptr<EditorObj> obj(selection->get_current_obj());
- EditorObjGroup* group = dynamic_cast<EditorObjGroup*>(obj.get());
+ EditorObj* obj = selection->get_current_obj();
+ EditorObjGroup* group = dynamic_cast<EditorObjGroup*>(obj);
if (group)
{
std::vector<EditorObj*>* objs = group->get_objs();
-
object_manager->editor_objs.erase(std::find(object_manager->editor_objs.begin(),
-
object_manager->editor_objs.end(),
- obj));
+ object_manager->erase (*objs);
selection->clear();
for(std::vector<EditorObj*>::iterator i = objs->begin();
i != objs->end();
@@ -431,7 +429,6 @@
if (selection->size() > 1)
{
EditorObjGroup* group = new EditorObjGroup();
- boost::shared_ptr<EditorObj> group_obj(group);
std::vector<EditorObj*> to_erase;
// We need to collect the objects out of the editor_objs list to keep
the correct sorting
@@ -456,9 +453,9 @@
i++)
object_manager->erase(*i);
- object_manager->editor_objs.push_back(group_obj);
+ object_manager->add (group);
selection->clear();
- selection->add(group_obj.get());
+ selection->add(group);
}
else
{
@@ -699,13 +696,13 @@
if (editor->tool != Editor::SELECTOR_TOOL)
return;
- boost::shared_ptr<EditorObj> obj
+ EditorObj* obj
= object_manager->find_object(editor->view->screen_to_world
(CL_Vector(CL_Mouse::get_x(),
-
CL_Mouse::get_y())));
+
CL_Mouse::get_y())));
- if (obj.get())
+ if (obj)
{
- if (selection->object_selected(obj.get()))
+ if (selection->object_selected(obj))
{
editor->interactive_move_object();
}
@@ -714,7 +711,7 @@
if (!CL_Keyboard::get_keycode(CL_KEY_LSHIFT))
selection->clear();
- selection->add(obj.get());
+ selection->add(obj);
}
}
else
Index: object_manager.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/editor/object_manager.cxx,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -d -r1.17 -r1.18
--- object_manager.cxx 1 Jul 2002 18:36:40 -0000 1.17
+++ object_manager.cxx 2 Jul 2002 09:14:20 -0000 1.18
@@ -331,42 +331,6 @@
xml << "</pingus-level>\n" << std::endl;
}
-/*
-void
-ObjectManager::delete_selection()
-{
- current_objs.erase(current_objs.begin(), current_objs.end());
-}
-*/
-
-/*
-void
-ObjectManager::unselect_object(boost::shared_ptr<EditorObj> c_obj)
-{
- current_objs.erase(std::find(current_objs.begin(), current_objs.end(),
- c_obj));
-}
-
-
-void
-ObjectManager::raise_current_objs()
-{
- for(CurrentObjIter i = current_objs.begin(); i != current_objs.end(); ++i)
- {
- raise_obj(*i);
- }
-}
-
-void
-ObjectManager::lower_current_objs()
-{
- for(CurrentObjIter i = current_objs.begin(); i != current_objs.end(); i++)
- {
- lower_obj(*i);
- }
-}
-*/
-
bool
ObjectManager::lower_obj(EditorObj* obj)
{
@@ -445,7 +409,7 @@
{
vector<EditorObj*> retval;
- for (EditorObjIter it = editor_objs.begin(); it != editor_objs.end(); it++)
+ for (EditorObjIter it = editor_objs.begin(); it != editor_objs.end(); ++it)
if ((*it)->is_in_rect(CL_Rect(x1, y1, x2, y2)))
retval.push_back(it->get ());
@@ -453,21 +417,27 @@
}
void
-ObjectManager::add (EditorObj*)
+ObjectManager::add (EditorObj* obj)
{
std::cout << "ObjectManager::add (EditorObj*)" << std::endl;
+ editor_objs.push_back (boost::shared_ptr<EditorObj>(obj));
}
void
-ObjectManager::erase (EditorObj*)
+ObjectManager::erase (EditorObj* obj)
{
- std::cout << "ObjectManager::erase (EditorObj*): Not implemented" <<
std::endl;
+ editor_objs.erase(std::remove_if (editor_objs.begin(), editor_objs.end(),
EditorObj_finder(obj)),
+ editor_objs.end ());
}
void
-ObjectManager::erase (std::vector<EditorObj*> obj)
+ObjectManager::erase (const std::vector<EditorObj*>& objs)
{
- std::cout << "ObjectManager::erase (std::vector<EditorObj*> obj): Not
implemented" << std::endl;
+ for (std::vector<EditorObj*>::const_iterator i = objs.begin (); i !=
objs.end (); ++i)
+ {
+ editor_objs.erase(std::remove_if (editor_objs.begin(),
editor_objs.end(), EditorObj_finder(*i)),
+ editor_objs.end ());
+ }
}
/*
@@ -483,18 +453,18 @@
}
*/
-boost::shared_ptr<EditorObj>
-ObjectManager::find_object(const CL_Vector & pos)
+EditorObj*
+ObjectManager::find_object(const CL_Vector& pos)
{
for(EditorObjRIter i = editor_objs.rbegin(); i != editor_objs.rend(); ++i)
{
if ((*i)->is_over(pos))
{
- return *i;
+ return i->get ();
}
}
- return boost::shared_ptr<EditorObj>();
+ return 0;
}
/*
Index: object_manager.hxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/editor/object_manager.hxx,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- object_manager.hxx 1 Jul 2002 18:36:40 -0000 1.10
+++ object_manager.hxx 2 Jul 2002 09:14:20 -0000 1.11
@@ -36,9 +36,7 @@
class ObjectManager
{
private:
- ///
friend class EditorEvent;
- ///
friend class Editor;
/// Other Level data
@@ -128,7 +126,7 @@
void erase (EditorObj*);
/** Erase objects from the ObjectManager and delete them */
- void erase (std::vector<EditorObj*>);
+ void erase (const std::vector<EditorObj*>&);
//void lower_current_objs();
@@ -136,7 +134,7 @@
//void unselect_object(boost::shared_ptr<EditorObj> c_obj);
/** Add the object at the given position to the selection */
- boost::shared_ptr<EditorObj> find_object(const CL_Vector & pos);
+ EditorObj* find_object(const CL_Vector & pos);
std::vector<ActionData>* get_actions ();
};
Index: selection.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/editor/selection.cxx,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- selection.cxx 2 Jul 2002 08:58:22 -0000 1.6
+++ selection.cxx 2 Jul 2002 09:14:20 -0000 1.7
@@ -27,61 +27,59 @@
using namespace std;
void
-EditorSelection::move(float x, float y) {
-
+EditorSelection::move(float x, float y)
+{
for (vector<EditorObj*>::iterator it = obj_list.begin(); it !=
obj_list.end(); it++)
(*it)->set_position_offset(CL_Vector(x, y));
}
void
-EditorSelection::move(const CL_Vector& pos) {
-
+EditorSelection::move(const CL_Vector& pos)
+{
for (vector<EditorObj*>::iterator it = obj_list.begin(); it !=
obj_list.end(); it++)
(*it)->set_position_offset(pos);
}
void
-EditorSelection::drag() {
-
+EditorSelection::drag()
+{
for (vector<EditorObj*>::iterator it = obj_list.begin(); it !=
obj_list.end(); it++)
(*it)->drag();
}
-void
-EditorSelection::drop() {
-
+void EditorSelection::drop()
+{
for (vector<EditorObj*>::iterator it = obj_list.begin(); it !=
obj_list.end(); it++)
(*it)->drop();
}
-void
-EditorSelection::add(EditorObj* obj) {
-
+void EditorSelection::add(EditorObj* obj)
+{
obj_list.push_back(obj);
}
void
-EditorSelection::add(vector<EditorObj*> objs) {
-
+EditorSelection::add(vector<EditorObj*> objs)
+{
obj_list.insert(obj_list.end(), objs.begin(), objs.end());
}
void
-EditorSelection::remove(EditorObj* obj) {
-
+EditorSelection::remove(EditorObj* obj)
+{
obj_list.erase(std::find(obj_list.begin(), obj_list.end(), obj));
}
void
-EditorSelection::raise() {
-
+EditorSelection::raise()
+{
for (vector<EditorObj*>::iterator it = obj_list.begin(); it !=
obj_list.end(); it++)
object_manager->raise_obj(*it);
}
void
-EditorSelection::lower() {
-
+EditorSelection::lower()
+{
for (vector<EditorObj*>::iterator it = obj_list.begin(); it !=
obj_list.end(); it++)
object_manager->lower_obj(*it);
}
@@ -95,13 +93,19 @@
&& !CL_Keyboard::get_keycode(CL_KEY_RSHIFT))
clear();
+ // Rotate the rectangle, so that x1,y1 is top/left und x2,y2 is
+ // bottom right
x1 = static_cast<int> (Math::min(x1_, x2_));
x2 = static_cast<int> (Math::max(x1_, x2_));
y1 = static_cast<int> (Math::min(y1_, y2_));
y2 = static_cast<int> (Math::max(y1_, y2_));
+
+ std::cout << "Rect: " << x1 << " " << y1 << " " << x2 << " " << y2 << " "
<< std::endl;
const vector<EditorObj*> & erg = object_manager->rect_get_objs(x1, x2, y1,
y2);
+ std::cout << "Size: " << erg.size () << std::endl;
+
obj_list.insert(obj_list.end(), erg.begin(), erg.end());
}
Index: selection.hxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/editor/selection.hxx,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- selection.hxx 1 Jul 2002 18:36:40 -0000 1.5
+++ selection.hxx 2 Jul 2002 09:14:20 -0000 1.6
@@ -56,6 +56,7 @@
void raise();
void lower();
+ /** Coordinates must be given in world-co not screen-co */
void select_rect(float x1_, float y1_, float x2_, float y2_);
bool object_selected(EditorObj* obj);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Pingus-CVS] CVS: Games/Pingus/src/editor editor.cxx,1.16,1.17 editor.hxx,1.7,1.8 editor_event.cxx,1.20,1.21 object_manager.cxx,1.17,1.18 object_manager.hxx,1.10,1.11 selection.cxx,1.6,1.7 selection.hxx,1.5,1.6,
grumbel <=
- Prev by Date:
[Pingus-CVS] CVS: Games/Pingus/src/editor selection.cxx,1.5,1.6
- Next by Date:
[Pingus-CVS] CVS: Games/Pingus/src/editor object_manager.cxx,1.18,1.19 selection.cxx,1.7,1.8
- Previous by thread:
[Pingus-CVS] CVS: Games/Pingus/src/editor selection.cxx,1.5,1.6
- Next by thread:
[Pingus-CVS] CVS: Games/Pingus/src/editor object_manager.cxx,1.18,1.19 selection.cxx,1.7,1.8
- Index(es):