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.50,1.51 obj


From: grumbel
Subject: [Pingus-CVS] CVS: Games/Pingus/src/editor editor_event.cxx,1.50,1.51 object_manager.cxx,1.41,1.42 object_selector.cxx,1.30,1.31 object_selector.hxx,1.13,1.14 object_selector_window.cxx,1.2,1.3
Date: 4 Mar 2003 12:53:49 -0000

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

Modified Files:
        editor_event.cxx object_manager.cxx object_selector.cxx 
        object_selector.hxx object_selector_window.cxx 
Log Message:
replaced:
EditorObjLst create_EditorObjs()
with
void insertEditorObjs(ObjectManager*)


Index: editor_event.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/editor/editor_event.cxx,v
retrieving revision 1.50
retrieving revision 1.51
diff -u -d -r1.50 -r1.51
--- editor_event.cxx    4 Mar 2003 10:26:18 -0000       1.50
+++ editor_event.cxx    4 Mar 2003 12:53:46 -0000       1.51
@@ -643,13 +643,13 @@
 {
   editor->save_tmp_level();
 
-  EditorObjLst objs;
   try 
     {
       disable();
       std::cout << "Object selector on" <<std::endl;
-      objs = editor->object_selector->get_obj(int(editor->view->get_offset 
().x + CL_Display::get_width ()/2),
-                                             int(editor->view->get_offset ().y 
+ CL_Display::get_height ()/2));
+      editor->object_selector->get_obj(object_manager,
+                                       int(editor->view->get_offset ().x + 
CL_Display::get_width ()/2),
+                                       int(editor->view->get_offset ().y + 
CL_Display::get_height ()/2));
       std::cout << "Object selector off" << std::endl;
       enable();
     }
@@ -658,16 +658,6 @@
     std::cout << "Editor: Error caught from ClanLib: " << err.message << 
std::endl;
     enable();
   }
-      
-  if (!objs.empty ()) 
-    {
-      for (ObjectManager::EditorObjIter i = objs.begin (); i != objs.end (); 
++i)
-       object_manager->add(*i);
-    } 
-  else 
-    {
-      std::cout << "EditorEvent: Something went wrong while inserting" << 
std::endl;
-    }
 }
 
 void

Index: object_manager.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/editor/object_manager.cxx,v
retrieving revision 1.41
retrieving revision 1.42
diff -u -d -r1.41 -r1.42
--- object_manager.cxx  19 Feb 2003 11:33:00 -0000      1.41
+++ object_manager.cxx  4 Mar 2003 12:53:47 -0000       1.42
@@ -129,16 +129,16 @@
 
   std::vector<WorldObjData*> temp_worldobj = plf->get_worldobjs_data();
 
-  for (std::vector<GroundpieceData>::iterator i = temp_surfaces.begin(); i != 
temp_surfaces.end(); ++i) {
-    const EditorObjLst& temp = i->create_EditorObj();
-    editor_objs.insert(editor_objs.end(), temp.begin(), temp.end() );
-  }
+  for (std::vector<GroundpieceData>::iterator i = temp_surfaces.begin(); i != 
temp_surfaces.end(); ++i) 
+    {
+      i->insert_EditorObjs(this);
+    }
 
   for (std::vector<WorldObjData*>::iterator i = temp_worldobj.begin();
        i != temp_worldobj.end();
-       ++i) {
-    const EditorObjLst& temp = (*i)->create_EditorObj();
-    editor_objs.insert(editor_objs.end(), temp.begin(), temp.end() );
+       ++i) 
+    {
+      (*i)->insert_EditorObjs(this);
   }
 
   std::stable_sort(editor_objs.begin (), editor_objs.end (), 
EditorObj_z_pos_sorter);

Index: object_selector.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/editor/object_selector.cxx,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -d -r1.30 -r1.31
--- object_selector.cxx 29 Dec 2002 23:29:01 -0000      1.30
+++ object_selector.cxx 4 Mar 2003 12:53:47 -0000       1.31
@@ -33,6 +33,7 @@
 #include "../string_converter.hxx"
 #include "../system.hxx"
 #include "object_selector.hxx"
+#include "object_manager.hxx"
 #include "string_reader.hxx"
 #include "thumb_cache.hxx"
 #include "weather_obj.hxx"
@@ -81,22 +82,23 @@
   
 /** FIXME: Ugly interface, the arguments should not be the offset, but
     instead the absolute position */
-EditorObjLst
-ObjectSelector::get_obj (int x_off, int y_off)
+void
+ObjectSelector::get_obj (ObjectManager* arg_obj_mgr,
+                         int x_off, int y_off)
 {
-
   // FIXME: Sick coordinate handling...
   x_offset = x_off;
   y_offset = y_off;
 
+  obj_mgr = arg_obj_mgr;
   pos = Vector (CL_Mouse::get_x () - x_offset,
-                  CL_Mouse::get_y () - y_offset, 
-                  0.0f);
+                CL_Mouse::get_y () - y_offset, 
+                0.0f);
 
-  return select_obj_type();
+  select_obj_type();
 }
 
-EditorObjLst
+void
 ObjectSelector::get_trap ()
 {
   CL_Display::clear_display();
@@ -114,26 +116,34 @@
       switch (read_key()) 
        {
        case CL_KEY_1:
-         return GuillotineObj::create(pos);
+         obj_mgr->add(GuillotineObj::create(pos));
+          return;
        case CL_KEY_2:
-         return HammerObj::create(pos);
+         obj_mgr->add(HammerObj::create(pos));
+          return;
        case CL_KEY_3:
-         return SpikeObj::create(pos);
+          obj_mgr->add(SpikeObj::create(pos));
+          return;
        case CL_KEY_4:
-         return LaserExitObj::create(pos);
+          obj_mgr->add(LaserExitObj::create(pos));
+          return;
        case CL_KEY_5:
-         return FakeExitObj::create(pos);
+         obj_mgr->add(FakeExitObj::create(pos));
+          return;
        case CL_KEY_6:
-         return SmasherObj::create(pos);
+         obj_mgr->add(SmasherObj::create(pos));
+          return;
        case CL_KEY_7:
-         return BumperObj::create(pos);
-       case CL_KEY_ESCAPE:
-         return EditorObjLst();
+         obj_mgr->add(BumperObj::create(pos));
+          return;
+        case CL_KEY_ESCAPE:
+         // do nothing
+          return;
        }
     }
 }
 
-EditorObjLst
+void
 ObjectSelector::get_groundpiece (const Groundtype::GPType& gptype)
 {
   GroundpieceData data;
@@ -143,21 +153,16 @@
 
   std::string str = select_surface(datafile);
 
-  EditorObjLst objs;
-
   if (!str.empty())
     {
       data.desc = ResDescriptor("resource:" + datafile, str);
       data.gptype = gptype;
 
-      objs.push_back(new EditorObjs::GroundpieceObj(data));
-      return objs;
+      obj_mgr->add(new EditorObjs::GroundpieceObj(data));
     }
-  
-  return objs;
 }
 
-EditorObjLst
+void
 ObjectSelector::get_hotspot (const std::string& filename)
 {
   HotspotData data;
@@ -168,13 +173,12 @@
     {
       data.desc = ResDescriptor("resource:" + filename, str);
       data.speed = -1;
-
-      return data.create_EditorObj();
     }
-  return EditorObjLst();
+  
+  data.insert_EditorObjs(obj_mgr);
 }
 
-EditorObjLst
+void
 ObjectSelector::get_worldobj ()
 {
   CL_Display::clear_display();
@@ -192,27 +196,32 @@
       switch (read_key()) 
        {
        case CL_KEY_1:
-         return TeleporterObj::create(pos);
+         obj_mgr->add(TeleporterObj::create(pos));
+         return;
          
-       case CL_KEY_2:
-         return SwitchDoorObj::create(pos);
-
-       case CL_KEY_3:
-         return ConveyorBeltObj::create(pos);
-
-       case CL_KEY_4:
-         return IceBlockObj::create(pos);
-
-       case CL_KEY_5:
-         return InfoBoxObj::create(pos);
+        case CL_KEY_2:
+          obj_mgr->add(SwitchDoorObj::create(pos));
+         return;
+          
+        case CL_KEY_3:
+          obj_mgr->add(ConveyorBeltObj::create(pos));
+          return;
+          
+        case CL_KEY_4:
+          obj_mgr->add(IceBlockObj::create(pos));
+          return;
+          
+        case CL_KEY_5:
+          obj_mgr->add(InfoBoxObj::create(pos));
+          return;
          
-       case CL_KEY_ESCAPE:
-         return EditorObjLst();
-       }
+        case CL_KEY_ESCAPE:
+          return;
+        }
     }
 }
 
-EditorObjLst
+void
 ObjectSelector::get_weather ()
 {
   std::string type;
@@ -240,10 +249,11 @@
     }
   
   std::cout << "Weather objects currently not implemented" << std::endl;
-  return EditorObjLst(1, new WeatherObj(type));
+
+  obj_mgr->add(new WeatherObj(type));
 }
 
-EditorObjLst
+void
 ObjectSelector::get_entrance ()
 {
   EntranceData entrance;
@@ -287,10 +297,10 @@
        }
     }
   
-  return entrance.create_EditorObj ();
+  entrance.insert_EditorObjs (obj_mgr);
 }
 
-EditorObjLst
+void
 ObjectSelector::get_exit ()
 {
   std::string str;
@@ -302,14 +312,14 @@
   last_object = str;
 
   if (str.empty())
-    return EditorObjLst();
+    return;
   
   data.desc = ResDescriptor("resource:exits", str);
   
-  return data.create_EditorObj ();
+  data.insert_EditorObjs (obj_mgr);
 }
 
-EditorObjLst
+void
 ObjectSelector::get_liquid ()
 {
   std::cout << "ObjectSelector::get_liquid() not implemented" << std::endl;
@@ -320,10 +330,10 @@
   data.width = 5;
   data.desc = ResDescriptor("Liquid/slime", "liquids", 
ResDescriptor::RD_RESOURCE);
 
-  return data.create_EditorObj ();
+  data.insert_EditorObjs (obj_mgr);
 }
 
-EditorObjLst
+void
 ObjectSelector::get_from_file ()
 {
   CL_Display::clear_display();
@@ -359,26 +369,24 @@
            // FIXME: Ugly hack, since ClanLib appends './'
            data.desc = ResDescriptor ("../../../../../../../../../../../" + 
file, 
                                       "", ResDescriptor::RD_FILE);
-
-           return data.create_EditorObj();
+            data.insert_EditorObjs(obj_mgr);
+           return;
          }
          break;
 
        case CL_KEY_G:
          console << "ObjectSelector: Inserting groundpieces is not 
implemented" << std::endl;
-         break;
+          return;
 
        case CL_KEY_ESCAPE:
-         return EditorObjLst (); 
+          return;
        }
     }
 }
 
-EditorObjLst
+void
 ObjectSelector::select_obj_type ()
 {
-  bool exit_loop;
-
   CL_Display::clear_display();
   font->print_left(20, 20, _("Which object do you want?"));
   font->print_left(20, 70, _("g - Groundpiece (ground)"));
@@ -398,9 +406,7 @@
   font->print_left(20,350, _("f - something from file (~/.pingus/images/)"));
   Display::flip_display();
 
-  exit_loop = false;
-    
-  while (!exit_loop) 
+  while (1) 
     {
       switch (read_key()) 
        {
@@ -408,58 +414,70 @@
          return get_trap();
 
        case CL_KEY_B:
-         return get_groundpiece(Groundtype::GP_BRIDGE);
+          get_groundpiece(Groundtype::GP_BRIDGE);
+          return;
          
        case CL_KEY_R:
-         return get_groundpiece(Groundtype::GP_REMOVE);
+          get_groundpiece(Groundtype::GP_REMOVE);
+          return;
          
        case CL_KEY_S:
-         return get_groundpiece(Groundtype::GP_SOLID);
+          get_groundpiece(Groundtype::GP_SOLID);
+          return;
 
        case CL_KEY_G:
-         return get_groundpiece(Groundtype::GP_GROUND);
+          get_groundpiece(Groundtype::GP_GROUND);
+          return;
 
        case CL_KEY_N:
-         return get_groundpiece(Groundtype::GP_TRANSPARENT);
+          get_groundpiece(Groundtype::GP_TRANSPARENT);
+          return;
 
        case CL_KEY_H:
-         return get_hotspot("hotspots");
+          get_hotspot("hotspots");
+          return;
                  
        case CL_KEY_E:
-         return get_entrance();
+          get_entrance();
+          return;
 
        case CL_KEY_X:
-         return get_exit();
+          get_exit();
+          return;
 
        case CL_KEY_L:
          std::cout << "ObjectSelector: Liquid not implemented" << std::endl;
-         return get_liquid();
+          get_liquid();
+          return;
 
        case CL_KEY_W:
-         return get_weather();
-
+          get_weather();
+          return;
+          
        case CL_KEY_P:
-         return get_prefab();
+          get_prefab();
+          return;
 
        case CL_KEY_O:
-         return get_worldobj();
+          get_worldobj();
+          return;
 
        case CL_KEY_Z:
-         return get_background();
+          get_background();
+          return;
                  
        case CL_KEY_F:
-         return get_from_file();
+          get_from_file();
+          return;
 
        case CL_KEY_ESCAPE:
-         exit_loop = true;
-         break;
+         return;
        }
     }
-  return EditorObjLst ();
 }
 
 
-EditorObjLst
+void
 ObjectSelector::get_prefab ()
 {
   CL_DirectoryScanner dir;
@@ -499,11 +517,9 @@
          break;
        }
     }
-
-  return EditorObjLst();
 }
 
-EditorObjLst
+void
 ObjectSelector::get_background ()
 {
   CL_Display::clear_display();
@@ -514,11 +530,7 @@
   font->print_left(20,110, _("4 - Thunderstorm Background"));
   Display::flip_display();
 
-  EditorObjLst lst;
-
-  bool exit_loop = false;
-    
-  while (!exit_loop) 
+  while (1) 
     {
       switch (read_key()) 
        {
@@ -530,27 +542,22 @@
 
            if (!data.desc.res_name.empty())
              {
-               lst = data.create_EditorObj ();
+               data.insert_EditorObjs(obj_mgr);
              }
-           
+           return;
          }
-         exit_loop = true;
-         break;
+          return;
        case CL_KEY_2:
-         lst = SolidColorBackgroundData().create_EditorObj();
-         exit_loop = true;
-         break;
+          SolidColorBackgroundData().insert_EditorObjs(obj_mgr);
+          return;
        case CL_KEY_3:
-         lst = StarfieldBackgroundData().create_EditorObj();
-         exit_loop = true;
-         break;
+          StarfieldBackgroundData().insert_EditorObjs(obj_mgr);
+          return;
        case CL_KEY_4:
-         lst = ThunderstormBackgroundData ().create_EditorObj();
-         exit_loop = true;
-         break;
+         ThunderstormBackgroundData ().insert_EditorObjs(obj_mgr);
+          return;
        }
     }
-  return lst;
 }
 
 std::string

Index: object_selector.hxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/editor/object_selector.hxx,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -d -r1.13 -r1.14
--- object_selector.hxx 28 Sep 2002 11:52:23 -0000      1.13
+++ object_selector.hxx 4 Mar 2003 12:53:47 -0000       1.14
@@ -32,6 +32,8 @@
 
 namespace EditorNS {
 
+class ObjectManager;
+
 /** The ObjectManager provides a graphical interface to select objects
     in the Editor from a list of objects and insert them into the
     level. */
@@ -43,6 +45,7 @@
   int x_offset;
   int y_offset;
 
+  ObjectManager* obj_mgr;
   Vector pos;
 
   std::string last_object;
@@ -52,24 +55,26 @@
   ObjectSelector();
   ~ObjectSelector();
   
-  EditorObjLst select_obj_type();
+  void get_obj(ObjectManager* obj_mgr, int, int);
+
+  // semi private stuff, only used by object_selector_window
   std::string select_surface(std::vector<surface_obj>& sur_list);
   std::string select_surface(const std::string & resource_file);
   int    read_key();
   std::string read_string(const std::string &, const std::string &);
-  
-  EditorObjLst get_obj(int, int);
-  EditorObjLst get_trap();
-  EditorObjLst get_groundpiece(const Groundtype::GPType& gptype);
-  EditorObjLst get_hotspot(const std::string&);
-  EditorObjLst get_entrance();
-  EditorObjLst get_exit();
-  EditorObjLst get_liquid();
-  EditorObjLst get_weather();
-  EditorObjLst get_worldobj();
-  EditorObjLst get_from_file();
-  EditorObjLst get_background();
-  EditorObjLst get_prefab();
+
+  void select_obj_type();
+  void get_trap();
+  void get_groundpiece(const Groundtype::GPType& gptype);
+  void get_hotspot(const std::string&);
+  void get_entrance();
+  void get_exit();
+  void get_liquid();
+  void get_weather();
+  void get_worldobj();
+  void get_from_file();
+  void get_background();
+  void get_prefab();
   
 private:
   ObjectSelector (const ObjectSelector&);

Index: object_selector_window.cxx
===================================================================
RCS file: 
/usr/local/cvsroot/Games/Pingus/src/editor/object_selector_window.cxx,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- object_selector_window.cxx  3 Dec 2002 00:51:19 -0000       1.2
+++ object_selector_window.cxx  4 Mar 2003 12:53:47 -0000       1.3
@@ -72,14 +72,13 @@
 void
 ObjectSelectorWindow::on_groundpiece_ground_press()
 {
-  Editor::instance()->get_object_manager()->add(
-  
Editor::instance()->get_object_selector()->get_groundpiece(Groundtype::GP_GROUND));
+  
Editor::instance()->get_object_selector()->get_groundpiece(Groundtype::GP_GROUND);
 }
 
 void
 ObjectSelectorWindow::on_groundpiece_solid_press()
 {
-  
Editor::instance()->get_object_selector()->get_groundpiece(Groundtype::GP_SOLID);
+ 
Editor::instance()->get_object_selector()->get_groundpiece(Groundtype::GP_SOLID);
 }
 
 void





reply via email to

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