[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Pingus-CVS] CVS: Games/Pingus/src/editor editor_event.cxx,1.5,1.6 edito
From: |
grumbel |
Subject: |
[Pingus-CVS] CVS: Games/Pingus/src/editor editor_event.cxx,1.5,1.6 editor_event.hxx,1.1,1.2 editorobj_group.cxx,1.1,1.2 editorobj_group.hxx,1.3,1.4 object_manager.hxx,1.1,1.2 |
Date: |
24 Jun 2002 18:53:16 -0000 |
Update of /usr/local/cvsroot/Games/Pingus/src/editor
In directory dark:/tmp/cvs-serv4405/editor
Modified Files:
editor_event.cxx editor_event.hxx editorobj_group.cxx
editorobj_group.hxx object_manager.hxx
Log Message:
- added proof-of-concept prefabs save/load support
- fixed a crash bug, which was caused while duplicating some objects in the
editor
- moved some parsing code where it belongs
Index: editor_event.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/editor/editor_event.cxx,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- editor_event.cxx 22 Jun 2002 17:40:56 -0000 1.5
+++ editor_event.cxx 24 Jun 2002 18:53:14 -0000 1.6
@@ -18,7 +18,7 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include <stdio.h>
-
+#include <fstream>
#include <ClanLib/Display/Input/input.h>
#include <ClanLib/Display/Input/keyboard.h>
#include <ClanLib/Core/System/error.h>
@@ -43,6 +43,8 @@
#include "panel.hxx"
#include "object_selector.hxx"
#include "editor.hxx"
+#include "../xml_helper.hxx"
+#include "../worldobj_group_data.hxx"
EditorEvent::EditorEvent()
: is_enabled (0)
@@ -86,6 +88,14 @@
{
switch (key.id)
{
+ case CL_KEY_I: // import meta-object
+ editor_import_object_group ();
+ break;
+
+ case CL_KEY_X: // export meta-object
+ editor_export_object_group_from_selection ();
+ break;
+
case CL_KEY_F3:
editor_toggle_background_color();
break;
@@ -607,10 +617,10 @@
boost::shared_ptr<EditorObj> obj = (*i)->duplicate();
- obj->set_position_offset (CL_Vector(8, 8));
-
- if (obj.get())
+ if (obj.get ())
{
+ obj->set_position_offset (CL_Vector(8, 8));
+
object_manager->editor_objs.insert(iter, obj);
new_objs.push_back(obj);
}
@@ -731,6 +741,34 @@
EditorEvent::zoom_mode ()
{
editor->zoom_mode ();
+}
+
+void
+EditorEvent::editor_export_object_group_from_selection ()
+{
+ std::cout << "EditorEvent:editor_export_object_group_from_selection ()" <<
std::endl;
+ EditorObjGroup group (editor->object_manager->current_objs);
+ std::ofstream xml ("/tmp/metaobj.xml");
+ group.write_xml (&xml);
+}
+
+void
+EditorEvent::editor_import_object_group ()
+{
+ std::cout << "EditorEvent:editor_import_object_group ()" << std::endl;
+ xmlDocPtr doc = xmlParseFile("/tmp/metaobj.xml");
+ xmlNodePtr cur = doc->ROOT;
+ WorldObjGroupData* group = new WorldObjGroupData (doc, cur);
+
+ std::list<boost::shared_ptr<EditorObj> > temp = group->create_EditorObj ();
+
+ std::cout << "Size: " << temp.size () << std::endl;
+
+ std::cout << "1 Size: " << editor->object_manager->editor_objs.size () <<
std::endl;
+
editor->object_manager->editor_objs.insert(editor->object_manager->editor_objs.end(),
temp.begin(), temp.end() );
+ std::cout << "1 Size: " << editor->object_manager->editor_objs.size () <<
std::endl;
+
+ delete group;
}
/* EOF */
Index: editor_event.hxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/editor/editor_event.hxx,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- editor_event.hxx 12 Jun 2002 19:11:31 -0000 1.1
+++ editor_event.hxx 24 Jun 2002 18:53:14 -0000 1.2
@@ -30,64 +30,43 @@
class EditorEvent //: public CL_Event_ButtonPress, public
CL_Event_ButtonRelease
{
private:
- ///
int is_enabled;
- ///
CL_Font* font;
+
public:
- ///
EditorEvent();
- ///
virtual ~EditorEvent();
- ///
Editor* editor;
- ///
ObjectManager* object_manager;
- ///
virtual void on_button_press(CL_InputDevice *device, const CL_Key &key);
- ///
virtual void on_button_release(CL_InputDevice *device, const CL_Key &key);
- ///
void enable();
- ///
void disable();
- ///
void set_editor(Editor* e);
- ///
void editor_convert_selection_to_group();
- ///
void editor_convert_group_to_selection();
- ///
void editor_exit();
- ///
void editor_mark_or_move_object();
- ///
void editor_mark_all_objects();
- ///
void editor_move_object();
- ///
void editor_toggle_background_color();
- ///
void editor_duplicate_current_selection();
- ///
void editor_delete_selected_objects();
- ///
void editor_start_current_level();
- ///
void editor_save_level_as();
- ///
void editor_load_level();
- ///
void editor_new_level();
- ///
void editor_insert_new_object();
- ///
void editor_display_help();
+
+ // Export the current selection to a meta-obj
+ void editor_export_object_group_from_selection ();
+ void editor_import_object_group ();
/** Decrease the owner number or another value specific to the
current object */
Index: editorobj_group.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/editor/editorobj_group.cxx,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- editorobj_group.cxx 12 Jun 2002 19:11:31 -0000 1.1
+++ editorobj_group.cxx 24 Jun 2002 18:53:14 -0000 1.2
@@ -28,6 +28,11 @@
{
}
+EditorObjGroup::EditorObjGroup(const std::list<boost::shared_ptr<EditorObj> >&
arg_objs)
+ : objs (arg_objs)
+{
+}
+
EditorObjGroup::~EditorObjGroup()
{
}
Index: editorobj_group.hxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/editor/editorobj_group.hxx,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- editorobj_group.hxx 19 Jun 2002 15:19:26 -0000 1.3
+++ editorobj_group.hxx 24 Jun 2002 18:53:14 -0000 1.4
@@ -35,6 +35,7 @@
//bool init;
public:
EditorObjGroup();
+ EditorObjGroup(const std::list<boost::shared_ptr<EditorObj> >& arg_objs);
virtual ~EditorObjGroup();
float get_z_pos();
@@ -53,6 +54,8 @@
void write_xml(std::ofstream* xml);
boost::shared_ptr<EditorObj> duplicate();
+
+ unsigned int size () { return objs.size (); }
};
#endif
Index: object_manager.hxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/editor/object_manager.hxx,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- object_manager.hxx 12 Jun 2002 19:11:31 -0000 1.1
+++ object_manager.hxx 24 Jun 2002 18:53:14 -0000 1.2
@@ -71,16 +71,11 @@
PLF* plf;
public:
- ///
typedef std::list<boost::shared_ptr<EditorObj> >::iterator EditorObjIter;
- ///
typedef std::list<boost::shared_ptr<EditorObj> >::reverse_iterator
EditorObjRIter;
- ///
typedef std::list<boost::shared_ptr<EditorObj> >::iterator CurrentObjIter;
- ///
ObjectManager();
- ///
~ObjectManager();
/// Create a new level
@@ -91,25 +86,18 @@
/// Save the current level in an xml file
void save_level_xml (const std::string & filename);
- ///
void draw(EditorView * view);
- ///
void draw_scroll_map(int x_pos, int y_pos, int arg_width, int arg_height);
-
- ///
+
bool object_selected(boost::shared_ptr<EditorObj> c_obj);
- ///
void move_obj();
- ///
+
void delete_selection();
- ///
void delete_all_objs();
- ///
+
void rect_get_current_objs(float x1, float y1, float x2, float y2);
- ///
int get_width() { return width; }
- ///
int get_height() { return height; }
/** Return the currently selected object, if none is selected or
@@ -123,14 +111,10 @@
void add_to_selection(boost::shared_ptr<EditorObj> obj);
void add_to_selection(std::list<boost::shared_ptr<EditorObj> > objs);
- ///
bool raise_obj(boost::shared_ptr<EditorObj> obj);
- ///
void raise_current_objs();
- ///
bool lower_obj(boost::shared_ptr<EditorObj> obj);
- ///
void lower_current_objs();
/** Remove an object from the current selection */
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Pingus-CVS] CVS: Games/Pingus/src/editor editor_event.cxx,1.5,1.6 editor_event.hxx,1.1,1.2 editorobj_group.cxx,1.1,1.2 editorobj_group.hxx,1.3,1.4 object_manager.hxx,1.1,1.2,
grumbel <=
- Prev by Date:
[Pingus-CVS] CVS: Games/Pingus/src groundpiece_data.cxx,1.2,1.3 groundpiece_data.hxx,1.3,1.4 worldobj_group_data.cxx,1.2,1.3 worldobj_group_data.hxx,1.1,1.2 xml_plf.cxx,1.3,1.4
- Next by Date:
[Pingus-CVS] CVS: Games/Pingus/src/entrances cloud.hxx,1.1,1.2 woodthing.hxx,1.1,1.2
- Previous by thread:
[Pingus-CVS] CVS: Games/Pingus/src groundpiece_data.cxx,1.2,1.3 groundpiece_data.hxx,1.3,1.4 worldobj_group_data.cxx,1.2,1.3 worldobj_group_data.hxx,1.1,1.2 xml_plf.cxx,1.3,1.4
- Next by thread:
[Pingus-CVS] CVS: Games/Pingus/src/entrances cloud.hxx,1.1,1.2 woodthing.hxx,1.1,1.2
- Index(es):