pingus-cvs
[Top][All Lists]
Advanced

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

[Pingus-CVS] CVS: Games/Pingus/src/editor editor_event.cxx,1.6,1.7 objec


From: grumbel
Subject: [Pingus-CVS] CVS: Games/Pingus/src/editor editor_event.cxx,1.6,1.7 object_manager.cxx,1.6,1.7 object_manager.hxx,1.3,1.4 object_selector.cxx,1.3,1.4 object_selector.hxx,1.3,1.4
Date: 24 Jun 2002 23:31:26 -0000

Update of /usr/local/cvsroot/Games/Pingus/src/editor
In directory dark:/tmp/cvs-serv9583/editor

Modified Files:
        editor_event.cxx object_manager.cxx object_manager.hxx 
        object_selector.cxx object_selector.hxx 
Log Message:
some more prefab/objectgroup support

Index: editor_event.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/editor/editor_event.cxx,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- editor_event.cxx    24 Jun 2002 18:53:14 -0000      1.6
+++ editor_event.cxx    24 Jun 2002 23:31:24 -0000      1.7
@@ -43,8 +43,6 @@
 #include "panel.hxx"
 #include "object_selector.hxx"
 #include "editor.hxx"
-#include "../xml_helper.hxx"
-#include "../worldobj_group_data.hxx"
 
 EditorEvent::EditorEvent()
   : is_enabled (0)
@@ -755,20 +753,7 @@
 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;
+  editor->object_manager->add_object_group_from_file ("/tmp/metaobj.xml");
 }
 
 /* EOF */

Index: object_manager.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/editor/object_manager.cxx,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- object_manager.cxx  21 Jun 2002 08:11:27 -0000      1.6
+++ object_manager.cxx  24 Jun 2002 23:31:24 -0000      1.7
@@ -27,6 +27,8 @@
 #include "../xml_helper.hxx"
 #include "../pingus_resource.hxx"
 #include "../pingus_error.hxx"
+#include "../xml_helper.hxx"
+#include "../worldobj_group_data.hxx"
 #include "start_pos.hxx"
 #include "object_manager.hxx"
 #include "editor_view.hxx"
@@ -172,18 +174,18 @@
   }
 
   for (vector<WorldObjData*>::iterator i = temp_worldobj.begin();
-      i != temp_worldobj.end();
-      ++i) {
+       i != temp_worldobj.end();
+       ++i) {
     const list<boost::shared_ptr<EditorObj> > & temp = 
(*i)->create_EditorObj();
     editor_objs.insert(editor_objs.end(), temp.begin(), temp.end() );
   }
 
 #ifdef WIN32
-//FIXME: ingo: This is a workaround around the std::list::sort()
-//FIXME: problem under MSVC6. This is copy&paste from an usenet
-//FIXME: article, so it might work or not, never tested it.
-// Alpha notes that this does NOT work.
-//  world_obj.sort(std::greater<CWorldObjPtr>());
+  //FIXME: ingo: This is a workaround around the std::list::sort()
+  //FIXME: problem under MSVC6. This is copy&paste from an usenet
+  //FIXME: article, so it might work or not, never tested it.
+  // Alpha notes that this does NOT work.
+  //  world_obj.sort(std::greater<CWorldObjPtr>());
 #else
   editor_objs.sort(EditorObj_z_pos_sorter);
 #endif
@@ -213,16 +215,16 @@
 ObjectManager::draw_scroll_map(int /*x_pos*/, int /*y_pos*/, int 
/*arg_width*/, int /*arg_height*/)
 {
   /*
-  for (EditorObjIter i = editor_objs.begin(); i != editor_objs.end(); ++i) 
+    for (EditorObjIter i = editor_objs.begin(); i != editor_objs.end(); ++i) 
     {
-      (*i)->draw_scroll_map(x_pos, y_pos,
-                           arg_width, arg_height);
+    (*i)->draw_scroll_map(x_pos, y_pos,
+    arg_width, arg_height);
                            
-       Display::draw_rect(x_pos + (*i)->get_x_pos() * arg_width / width,
-       y_pos + (*i)->get_y_pos() * arg_height / height,
-       x_pos + (*i)->get_x_pos() * arg_width / width + 10,
-       y_pos + (*i)->get_y_pos() * arg_height / height + 10,
-       0.0, 1.0, 0.0, 1.0);
+    Display::draw_rect(x_pos + (*i)->get_x_pos() * arg_width / width,
+    y_pos + (*i)->get_y_pos() * arg_height / height,
+    x_pos + (*i)->get_x_pos() * arg_width / width + 10,
+    y_pos + (*i)->get_y_pos() * arg_height / height + 10,
+    0.0, 1.0, 0.0, 1.0);
     }*/
 }
 
@@ -291,8 +293,8 @@
       << std::endl;
   
   /*for (std::vector<boost::shared_ptr<BackgroundData> >::iterator i = 
backgrounds.begin();
-       i != backgrounds.end();
-       i++)
+    i != backgrounds.end();
+    i++)
     (*i)->write_xml(&xml);
   */
   /*  xml << "<background>\n";
@@ -377,10 +379,10 @@
 
   swap(*prev, *current);
   /* FIXME: not sure if we need this on windows, if not delete it
-  boost::shared_ptr<EditorObj> tmp = *prev;
-  *prev = *current;
-  *current = tmp;
-  */
+     boost::shared_ptr<EditorObj> tmp = *prev;
+     *prev = *current;
+     *current = tmp;
+     */
   return true;
 }
 
@@ -402,10 +404,10 @@
   
   swap(*next, *current);
   /* FIXME: not sure if we need this on windows, if not delete it
-  boost::shared_ptr<EditorObj> tmp = *next;
-  *next = *current;
-  *current = tmp;
-  */
+     boost::shared_ptr<EditorObj> tmp = *next;
+     *next = *current;
+     *current = tmp;
+     */
   return true;
 }
 
@@ -500,6 +502,26 @@
     return *current_objs.begin();
   else
     return boost::shared_ptr<EditorObj>();
+}
+
+void
+ObjectManager::add_object_group_from_file (const std::string& filename)
+{
+  std::cout << "ObjectManager::add_object_group_from_file(" << filename << ")" 
<< std::endl;
+  xmlDocPtr doc = xmlParseFile(filename.c_str ());
+
+  if (doc)
+    {
+      xmlNodePtr cur = doc->ROOT;
+      WorldObjGroupData* group = new WorldObjGroupData (doc, cur);
+      const std::list<boost::shared_ptr<EditorObj> >& temp = 
group->create_EditorObj ();
+      editor_objs.insert(editor_objs.end(),temp.begin(), temp.end());
+      delete group;
+    }
+  else
+    {
+      std::cout << "ObjectManager::add_object_group_from_file: read error: " 
<< filename << std::endl;
+    }
 }
 
 /* EOF */

Index: object_manager.hxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/editor/object_manager.hxx,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- object_manager.hxx  24 Jun 2002 22:52:58 -0000      1.3
+++ object_manager.hxx  24 Jun 2002 23:31:24 -0000      1.4
@@ -95,6 +95,8 @@
   void delete_selection();
   void delete_all_objs();
 
+  void add_object_group_from_file (const std::string& filename);
+
   void rect_get_current_objs(float x1, float y1, float x2, float y2);
 
   int get_width() { return width; }

Index: object_selector.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/editor/object_selector.cxx,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- object_selector.cxx 23 Jun 2002 12:47:50 -0000      1.3
+++ object_selector.cxx 24 Jun 2002 23:31:24 -0000      1.4
@@ -18,6 +18,7 @@
 //  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 
 #include <ClanLib/Core/System/system.h>
+#include <ClanLib/Core/IOData/directory_scanner.h>
 #include <ClanLib/Display/Input/mouse.h>
 #include <ClanLib/Display/Display/display.h>
 #include <ClanLib/Display/Font/font.h>
@@ -37,6 +38,7 @@
 #include "plfobj.hxx"
 #include "../my_gettext.hxx"
 #include "../system.hxx"
+#include "../path_manager.hxx"
 #include "../editor_hotspot.hxx"
 
 #include "../backgrounds/starfield_background.hxx"
@@ -405,7 +407,8 @@
   font->print_left(20,250, _("w - Weather"));
   font->print_left(20,270, _("o - WorldObject"));
   font->print_left(20,290, _("z - Background"));
-  font->print_left(20,310, _("f - something from file (~/.pingus/images/)"));
+  font->print_left(20,310, _("p - Prefab (ObjectGroup)"));
+  font->print_left(20,330, _("f - something from file (~/.pingus/images/)"));
   Display::flip_display();
 
   exit_loop = false;
@@ -448,6 +451,9 @@
        case CL_KEY_W:
          return get_weather();
 
+       case CL_KEY_P:
+         return get_prefab ();
+
        case CL_KEY_O:
          return get_worldobj();
 
@@ -465,10 +471,41 @@
   return std::list<boost::shared_ptr<EditorObj> > ();
 }
 
+
 std::list<boost::shared_ptr<EditorObj> >
-ObjectSelector::get_background()
+ObjectSelector::get_prefab()
 {
+  CL_Display::clear_display();
+  font->print_left(20, 20, _("Which prefab do you want?"));
 
+  CL_DirectoryScanner dir;
+  
+  int y = 60;
+  dir.scan(path_manager.complete ("prefabs/"), "*.xml");
+  while (dir.next ())
+    {
+      font->print_left(20, y, dir.get_name ().c_str ());
+      y += 30;
+    }
+  
+  Display::flip_display();
+
+  bool exit_loop = false;
+    
+  while (!exit_loop) 
+    {
+      switch (read_key()) 
+       {
+       default: 
+         exit_loop = true;
+       }      
+    }
+  return std::list<boost::shared_ptr<EditorObj> >();
+}
+
+std::list<boost::shared_ptr<EditorObj> >
+ObjectSelector::get_background()
+{
   CL_Display::clear_display();
   font->print_left(20, 20, _("Which object do you want?"));
   font->print_left(20, 50, _("1 - Surface Background"));

Index: object_selector.hxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/editor/object_selector.hxx,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- object_selector.hxx 24 Jun 2002 22:52:58 -0000      1.3
+++ object_selector.hxx 24 Jun 2002 23:31:24 -0000      1.4
@@ -62,6 +62,7 @@
   std::list<boost::shared_ptr<EditorObj> > get_worldobj();
   std::list<boost::shared_ptr<EditorObj> > get_from_file();
   std::list<boost::shared_ptr<EditorObj> > get_background();
+  std::list<boost::shared_ptr<EditorObj> > get_prefab();
 };
 
 #endif




reply via email to

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