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 Makefile.am,1.17,1.18 action_w


From: grumbel
Subject: [Pingus-CVS] CVS: Games/Pingus/src/editor Makefile.am,1.17,1.18 action_window.cxx,1.3,1.4 action_window.hxx,1.3,1.4 object_manager.cxx,1.11,1.12
Date: 29 Jun 2002 14:01:34 -0000

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

Modified Files:
        Makefile.am action_window.cxx action_window.hxx 
        object_manager.cxx 
Log Message:
- action selection dialog is no working basically
- input bug due to a collision between the edtiors input handling and the gui 
one is still there and will not be that easy to solve

Index: Makefile.am
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/editor/Makefile.am,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -d -r1.17 -r1.18
--- Makefile.am 29 Jun 2002 11:54:22 -0000      1.17
+++ Makefile.am 29 Jun 2002 14:01:32 -0000      1.18
@@ -37,6 +37,6 @@
 editorobj.cxx              rect_editorobj.cxx    weather_obj.cxx \
     scroll_map.cxx \
   sprite_editorobj.cxx editorobj_group.hxx editorobj_group.cxx \
-groundpiece_window.hxx groundpiece_window.cxx
+groundpiece_window.hxx groundpiece_window.cxx 
 
 # EOF #

Index: action_window.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/editor/action_window.cxx,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- action_window.cxx   29 Jun 2002 11:54:22 -0000      1.3
+++ action_window.cxx   29 Jun 2002 14:01:32 -0000      1.4
@@ -31,6 +31,8 @@
  [    ok     ]  [  cancel  ]
 ****************************/
 
+using namespace Pingus::Actions;
+
 ActionWindow::ActionWindow (CL_Component* arg_parent, std::vector<ActionData>* 
arg_actions)
   : parent (arg_parent), actions (arg_actions)
 {
@@ -39,12 +41,13 @@
   
   //window = new CL_Frame (CL_Rect (0, 0, 200, (actions->size() * 20) + 80), 
parent);
   //window->enable_fill (true);
-  
+
+  // Create all the default gui stuff
   int y = 30;
-  for (std::vector<ActionData>::iterator i = actions->begin (); i != 
actions->end (); ++i)
+  for (std::vector<ActionData>::iterator i = default_actions.begin (); i != 
default_actions.end (); ++i)
     {
+      checkboxes.push_back(new CL_CheckBox(CL_Point (10, y), 
action_to_string(i->name), window));
       inputs.push_back(new CL_InputBox (CL_Rect(100, y, 190, 0), 
to_string(i->number_of), window));
-      labels.push_back(new CL_Label (CL_Point(10, y), 
action_to_string(i->name), window));
       y += 20;
     }
 
@@ -90,16 +93,71 @@
   hide ();
 }
 
+class is_equal
+{
+private:
+  ActionName action;
+
+public:
+  is_equal (ActionName a) : action (a)
+  {
+  }
+
+  bool operator() (const ActionData& b)
+  {
+    return action == b.name;
+  }
+};
+
 void
 ActionWindow::read_data ()
 {
   std::cout << "Reading data" << std::endl;
+  for (unsigned int i = 0; i <  default_actions.size(); ++i)
+    {
+      std::vector<ActionData>::iterator act = std::find_if (actions->begin (), 
actions->end (),
+                                                           is_equal 
(default_actions[i].name));
+      if (act == actions->end ())
+       {
+         checkboxes[i]->set_checked (false);
+         //inputs[i]->set_text (to_string(0));
+       }
+      else
+       {
+         checkboxes[i]->set_checked (true);
+         inputs[i]->set_text (to_string(act->number_of));
+       }
+    }
 }
 
 void
 ActionWindow::write_data ()
 {
   std::cout << "Writing data" << std::endl;
+  for (unsigned int i = 0; i < default_actions.size(); ++i)  
+    {
+      if (checkboxes[i]->is_checked ())
+       {
+         std::vector<ActionData>::iterator act = std::find_if (actions->begin 
(), actions->end (),
+                                                               is_equal 
(default_actions[i].name));
+         if (act == actions->end ())
+           {
+             ActionData data;
+             from_string(inputs[i]->get_text (), data.number_of);
+             data.name = default_actions[i].name;
+             
+             actions->push_back (data);
+           }
+         else
+           {
+             from_string(inputs[i]->get_text (), act->number_of); 
+           }
+       }
+      else
+       {
+         std::remove_if (actions->begin (), actions->end (), 
is_equal(default_actions[i].name));
+       }
+    }
 }
 
 /* EOF */

Index: action_window.hxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/editor/action_window.hxx,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- action_window.hxx   29 Jun 2002 11:54:22 -0000      1.3
+++ action_window.hxx   29 Jun 2002 14:01:32 -0000      1.4
@@ -30,8 +30,8 @@
   CL_Component* parent;
   std::vector<ActionData>* actions;
   CL_Window* window;
+  std::vector<CL_CheckBox*> checkboxes;
   std::vector<CL_InputBox*> inputs;
-  std::vector<CL_Label*> labels;
 
   CL_Button* ok_button;
   CL_Button* cancel_button;

Index: object_manager.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/editor/object_manager.cxx,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- object_manager.cxx  28 Jun 2002 22:21:59 -0000      1.11
+++ object_manager.cxx  29 Jun 2002 14:01:32 -0000      1.12
@@ -107,16 +107,7 @@
   editor_objs.push_back(boost::shared_ptr<EditorObj>(new StartPos(50, 50)));
 
   // Set some default actions
-  actions.clear();
-  actions.push_back(ActionData(Basher,  20));
-  actions.push_back(ActionData(Blocker, 20));
-  actions.push_back(ActionData(Bomber,  20));
-  actions.push_back(ActionData(Bridger, 20));
-  actions.push_back(ActionData(Climber, 20));
-  actions.push_back(ActionData(Digger,  20));
-  actions.push_back(ActionData(Floater, 20));
-  actions.push_back(ActionData(Jumper,  20));
-  actions.push_back(ActionData(Miner,   20));
+  actions = default_actions;
 }
 
 ///




reply via email to

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