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.hxx,1.22,1.23 editor_ev


From: grumbel
Subject: [Pingus-CVS] CVS: Games/Pingus/src/editor editor.hxx,1.22,1.23 editor_event.cxx,1.43,1.44 object_manager.cxx,1.38,1.39 object_manager.hxx,1.24,1.25 object_selector_window.cxx,1.1,1.2 object_selector_window.hxx,1.1,1.2
Date: 3 Dec 2002 00:51:21 -0000

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

Modified Files:
        editor.hxx editor_event.cxx object_manager.cxx 
        object_manager.hxx object_selector_window.cxx 
        object_selector_window.hxx 
Log Message:
added more or less working GUI for inserting of objects


Index: editor.hxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/editor/editor.hxx,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -d -r1.22 -r1.23
--- editor.hxx  28 Nov 2002 20:09:54 -0000      1.22
+++ editor.hxx  3 Dec 2002 00:51:19 -0000       1.23
@@ -115,6 +115,8 @@
   void toggle_help_screen ();
 
   ObjectManager* get_object_manager() { return object_manager; }
+  ObjectSelector* get_object_selector() { return object_selector; }
+
   std::string save_tmp_level ();
   EditorEvent* get_event() { return event; }
 

Index: editor_event.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/editor/editor_event.cxx,v
retrieving revision 1.43
retrieving revision 1.44
diff -u -d -r1.43 -r1.44
--- editor_event.cxx    1 Dec 2002 17:08:47 -0000       1.43
+++ editor_event.cxx    3 Dec 2002 00:51:19 -0000       1.44
@@ -655,7 +655,7 @@
   if (!objs.empty ()) 
     {
       for (ObjectManager::EditorObjIter i = objs.begin (); i != objs.end (); 
++i)
-       object_manager->editor_objs.push_back(*i);
+       object_manager->add(*i);
     } 
   else 
     {

Index: object_manager.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/editor/object_manager.cxx,v
retrieving revision 1.38
retrieving revision 1.39
diff -u -d -r1.38 -r1.39
--- object_manager.cxx  29 Nov 2002 22:54:22 -0000      1.38
+++ object_manager.cxx  3 Dec 2002 00:51:19 -0000       1.39
@@ -308,6 +308,17 @@
   z_pos_sort();
 }
 
+void 
+ObjectManager::add (const EditorObjLst& lst)
+{
+  for (EditorObjLst::const_iterator i = lst.begin(); i != lst.end(); ++i)
+    {
+      editor_objs.push_back(*i);
+    }
+
+  z_pos_sort();
+}
+
 void
 ObjectManager::erase (EditorObj* obj)
 {

Index: object_manager.hxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/editor/object_manager.hxx,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -d -r1.24 -r1.25
--- object_manager.hxx  30 Nov 2002 17:11:55 -0000      1.24
+++ object_manager.hxx  3 Dec 2002 00:51:19 -0000       1.25
@@ -139,6 +139,9 @@
       needed! */
   void add (EditorObj*);
 
+  /** Add multiple objects at once */
+  void add (const EditorObjLst&);
+
   /** Erase the object from the ObjectManager and delete it */
   void erase (EditorObj*);
 

Index: object_selector_window.cxx
===================================================================
RCS file: 
/usr/local/cvsroot/Games/Pingus/src/editor/object_selector_window.cxx,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- object_selector_window.cxx  2 Dec 2002 10:40:19 -0000       1.1
+++ object_selector_window.cxx  3 Dec 2002 00:51:19 -0000       1.2
@@ -17,39 +17,134 @@
 //  along with this program; if not, write to the Free Software
 //  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 
+#include "editor.hxx"
+#include "object_selector.hxx"
+#include "object_manager.hxx"
+#include "../groundtype.hxx"
 #include "object_selector_window.hxx"
 
+using namespace EditorNS;
+
 ObjectSelectorWindow::ObjectSelectorWindow(CL_Component* parent)
   : CL_Window(CL_Rect(50, 50, 250, 410), "Object Inserter", parent),
-    y_pos(10),
-    groundpiece_ground_button(CL_Rect(10, y_pos, 190, y_pos += 20), 
"Groundpiece (ground)", get_client_area()),
-    groundpiece_solid_button(CL_Rect(10, y_pos, 190, y_pos += 20), 
"Groundpiece (solid)", get_client_area()),
-    groundpiece_transparent_button(CL_Rect(10, y_pos, 190, y_pos += 20), 
"Groundpiece (transparent)", get_client_area()),
-    groundpiece_remove_button(CL_Rect(10, y_pos, 190, y_pos += 20), 
"Groundpiece (remove)", get_client_area()),
+    y_pos(5)
+{
+  //close_button_slot = close_button.sig_clicked().connect(this, 
&ObjectSelectorWindow::on_close_press);
+  add_button("Groundpieces (ground)",      
&ObjectSelectorWindow::on_groundpiece_ground_press);
+  add_button("Groundpieces (solid)",       
&ObjectSelectorWindow::on_groundpiece_solid_press);
+  add_button("Groundpieces (transparent)", 
&ObjectSelectorWindow::on_groundpiece_transparent_press);
+  add_button("Groundpieces (remove)",      
&ObjectSelectorWindow::on_groundpiece_remove_press);
+  add_button("Hotspot",                    
&ObjectSelectorWindow::on_hotspot_press);
+  add_button("Entrance",                   
&ObjectSelectorWindow::on_entrance_press);
+  add_button("Exit",                       
&ObjectSelectorWindow::on_exit_press);
+  add_button("Liquid",                     
&ObjectSelectorWindow::on_liquid_press);
+  add_button("Weather",                    
&ObjectSelectorWindow::on_weather_press);
+  add_button("Trap",                       
&ObjectSelectorWindow::on_trap_press);
+  add_button("WorldObject",                
&ObjectSelectorWindow::on_worldobject_press);
+  add_button("Background",                 
&ObjectSelectorWindow::on_background_press);
+  add_button("Prefab",                     
&ObjectSelectorWindow::on_prefab_press);
+  add_button("From File",                  
&ObjectSelectorWindow::on_from_file_press);
+  y_pos += 10;
+  add_button("Close",                      
&ObjectSelectorWindow::on_close_press);
 
-    hotspot_button(CL_Rect(10, y_pos, 190, y_pos += 20), "Hotspot", 
get_client_area()),
-    entrance_button(CL_Rect(10, y_pos, 190, y_pos += 20), "Entrance", 
get_client_area()),
-    exit_button(CL_Rect(10, y_pos, 190, y_pos += 20), "Exit", 
get_client_area()),
+  set_client_size(200, y_pos + 10);
+}
 
-    liquid_button(CL_Rect(10, y_pos, 190, y_pos += 20), "Liquid", 
get_client_area()),
-    weather_button(CL_Rect(10, y_pos, 190, y_pos += 20), "Weather", 
get_client_area()),
-    trap_button(CL_Rect(10, y_pos, 190, y_pos += 20), "Trap", 
get_client_area()),
-    worldobj_button(CL_Rect(10, y_pos, 190, y_pos += 20), "Worldobject", 
get_client_area()),
+ObjectSelectorWindow::~ObjectSelectorWindow()
+{
+  for (std::vector<ButtonPair*>::iterator i = buttons.begin();  i != 
buttons.end(); ++i)
+    delete *i;
+}
 
-    background_button(CL_Rect(10, y_pos, 190, y_pos += 20), "Background", 
get_client_area()),
-    prefab_button(CL_Rect(10, y_pos, 190, y_pos += 20), "Prefab", 
get_client_area()),
-    file_button(CL_Rect(10, y_pos, 190, y_pos += 20), "From File", 
get_client_area()),
+void
+ObjectSelectorWindow::on_close_press()
+{
+  show(false);
+}
 
-    close_button(CL_Rect(10, y_pos + 10, 190, y_pos + 30), "Close", 
get_client_area())
+void
+ObjectSelectorWindow::add_button (const std::string& name, Callback callback)
 {
+  buttons.push_back(new ButtonPair(this, name, callback, y_pos));
+  y_pos += 20;
+}
 
-  close_button_slot = close_button.sig_clicked().connect(this, 
&ObjectSelectorWindow::on_close_press);
+void
+ObjectSelectorWindow::on_groundpiece_ground_press()
+{
+  Editor::instance()->get_object_manager()->add(
+  
Editor::instance()->get_object_selector()->get_groundpiece(Groundtype::GP_GROUND));
 }
 
 void
-ObjectSelectorWindow::on_close_press()
+ObjectSelectorWindow::on_groundpiece_solid_press()
+{
+  
Editor::instance()->get_object_selector()->get_groundpiece(Groundtype::GP_SOLID);
+}
+
+void
+ObjectSelectorWindow::on_groundpiece_transparent_press()
+{
+  
Editor::instance()->get_object_selector()->get_groundpiece(Groundtype::GP_TRANSPARENT);
+}
+
+void
+ObjectSelectorWindow::on_groundpiece_remove_press()
+{
+  
Editor::instance()->get_object_selector()->get_groundpiece(Groundtype::GP_REMOVE);
+}
+
+void
+ObjectSelectorWindow::on_hotspot_press()
+{
+  Editor::instance()->get_object_selector()->get_hotspot("hotspots");
+}
+
+void
+ObjectSelectorWindow::on_entrance_press()
+{
+  Editor::instance()->get_object_selector()->get_entrance();
+}
+
+void
+ObjectSelectorWindow::on_exit_press()
+{
+  Editor::instance()->get_object_selector()->get_exit();
+}
+
+void
+ObjectSelectorWindow::on_liquid_press()
+{
+}
+
+void
+ObjectSelectorWindow::on_weather_press()
+{
+}
+
+void
+ObjectSelectorWindow::on_trap_press()
+{
+}
+
+void
+ObjectSelectorWindow::on_worldobject_press()
+{
+}
+
+void
+ObjectSelectorWindow::on_background_press()
+{
+}
+
+void
+ObjectSelectorWindow::on_prefab_press()
+{
+}
+
+void
+ObjectSelectorWindow::on_from_file_press()
 {
-  show(false);
 }
 
 /* EOF */

Index: object_selector_window.hxx
===================================================================
RCS file: 
/usr/local/cvsroot/Games/Pingus/src/editor/object_selector_window.hxx,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- object_selector_window.hxx  2 Dec 2002 10:40:19 -0000       1.1
+++ object_selector_window.hxx  3 Dec 2002 00:51:19 -0000       1.2
@@ -20,43 +20,70 @@
 #ifndef HEADER_PINGUS_EDITOR_OBJECT_SELECTOR_WINDOW_HXX
 #define HEADER_PINGUS_EDITOR_OBJECT_SELECTOR_WINDOW_HXX
 
+#include <string>
+#include <vector>
 #include <ClanLib/GUI/window.h>
 #include <ClanLib/GUI/button.h>
 
-/** */
+/** A Little window that lets you select an object type to insert */
 class ObjectSelectorWindow : public CL_Window
 {
 private:
-  int y_pos;
-  
-  CL_Button groundpiece_ground_button;
-  CL_Button groundpiece_solid_button;
-  CL_Button groundpiece_transparent_button;
-  CL_Button groundpiece_remove_button;
-
-  CL_Button hotspot_button;
-  CL_Button entrance_button;
-  CL_Button exit_button;
+  typedef void (ObjectSelectorWindow::*Callback)();
 
-  CL_Button liquid_button;
-  CL_Button weather_button;
-  CL_Button trap_button;
-  CL_Button worldobj_button;
+  class ButtonPair {
+  private:
+    ObjectSelectorWindow* parent;
+    Callback callback;
+    CL_Button button;
+    CL_Slot button_click_slot;
 
-  CL_Button background_button;
-  CL_Button prefab_button;
-  CL_Button file_button;
+  public:
+    ButtonPair (ObjectSelectorWindow* p, const std::string& name, Callback c, 
int y_pos)
+      : parent (p), 
+        callback(c),
+        button (CL_Rect(10, y_pos, 190, y_pos + 20), name, 
parent->get_client_area())
+    {
+      button_click_slot = button.sig_clicked().connect(this, 
&ButtonPair::on_click);
+    }
 
-  CL_Button close_button;
+    void on_click() 
+    {
+      // Call the callback, yeah, func_ptr synaxt is cool...
+      ((*parent).*callback)();
+    }
+  };
 
-  CL_Slot close_button_slot;
+  /** Position for the next inserted button */
+  int y_pos;
+ 
+  /** container for buttons and callbacks */
+  std::vector<ButtonPair*> buttons;
 
 public:
   ObjectSelectorWindow(CL_Component*);
-  
+  ~ObjectSelectorWindow();
+
   void on_close_press();
   
+  void on_groundpiece_ground_press();
+  void on_groundpiece_solid_press();
+  void on_groundpiece_transparent_press();
+  void on_groundpiece_remove_press();
+  void on_hotspot_press();
+  void on_entrance_press();
+  void on_exit_press();
+  void on_liquid_press();
+  void on_weather_press();
+  void on_trap_press();
+  void on_worldobject_press();
+  void on_background_press();
+  void on_prefab_press();
+  void on_from_file_press();
+
 private:
+  void add_button (const std::string& name, Callback callback);
+  
   ObjectSelectorWindow (const ObjectSelectorWindow&);
   ObjectSelectorWindow& operator= (const ObjectSelectorWindow&);
 };





reply via email to

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