pingus-cvs
[Top][All Lists]
Advanced

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

[Pingus-CVS] r3126 - in trunk/pingus/src: components editor


From: grumbel at BerliOS
Subject: [Pingus-CVS] r3126 - in trunk/pingus/src: components editor
Date: Tue, 11 Sep 2007 18:25:17 +0200

Author: grumbel
Date: 2007-09-11 18:25:16 +0200 (Tue, 11 Sep 2007)
New Revision: 3126

Modified:
   trunk/pingus/src/components/button_panel.cpp
   trunk/pingus/src/components/button_panel.hpp
   trunk/pingus/src/editor/action_properties.cpp
   trunk/pingus/src/editor/action_properties.hpp
   trunk/pingus/src/editor/editor_level.cpp
   trunk/pingus/src/editor/editor_level.hpp
   trunk/pingus/src/editor/editor_screen.cpp
   trunk/pingus/src/editor/level_properties.cpp
   trunk/pingus/src/editor/level_properties.hpp
Log:
- hocked up some parts of LevelProperties

Modified: trunk/pingus/src/components/button_panel.cpp
===================================================================
--- trunk/pingus/src/components/button_panel.cpp        2007-09-11 15:03:27 UTC 
(rev 3125)
+++ trunk/pingus/src/components/button_panel.cpp        2007-09-11 16:25:16 UTC 
(rev 3126)
@@ -36,7 +36,6 @@
 ButtonPanel::ButtonPanel(Client* c, int arg_x_pos, int arg_y_pos)
   : client(c),
     server(client->get_server()),
-    armageddon_pressed(false),
     left_pressed(0),
     last_press(0),
     x_pos (arg_x_pos),
@@ -67,24 +66,8 @@
     }
 
   pressed_button = 0;
-  ////wheel_slot = CL_Mouse::sig_key_down().connect(this, 
&ButtonPanel::on_wheel_move);
 }
 
-#if 0
-void
-ButtonPanel::on_wheel_move(const CL_InputEvent& key)
-{
-  if (key.id == CL_MOUSE_WHEEL_DOWN)
-    {
-      next_action();
-    }
-  else if (key.id == CL_MOUSE_WHEEL_UP)
-    {
-      previous_action();
-    }
-}
-#endif
-
 ButtonPanel::~ButtonPanel()
 {
   for (AButtonIter it = a_buttons.begin(); it != a_buttons.end(); ++it)
@@ -96,18 +79,17 @@
 void
 ButtonPanel::update(float delta)
 {
-  a_buttons[pressed_button]->update(delta);
-
-  if (last_press + 350 < SDL_GetTicks())
-    {
-      armageddon_pressed = 0;
-    }
+  if (!a_buttons.empty())
+    a_buttons[pressed_button]->update(delta);
 }
 
 ActionName
 ButtonPanel::get_action_name()
 {
-  return a_buttons[pressed_button]->get_action_name();
+  if (!a_buttons.empty())
+    return a_buttons[pressed_button]->get_action_name();
+  else
+    return Actions::Bridger;
 }
 
 void

Modified: trunk/pingus/src/components/button_panel.hpp
===================================================================
--- trunk/pingus/src/components/button_panel.hpp        2007-09-11 15:03:27 UTC 
(rev 3125)
+++ trunk/pingus/src/components/button_panel.hpp        2007-09-11 16:25:16 UTC 
(rev 3126)
@@ -39,15 +39,11 @@
   typedef std::vector<ActionButton*>::iterator AButtonIter;
   int pressed_button;
 
-  int  armageddon_pressed;
-
   bool left_pressed;
   unsigned int  last_press;
 
   int x_pos, y_pos;
 
-  ////CL_Slot wheel_slot;
-  ////void on_wheel_move(const CL_InputEvent& key);
 public:
   ButtonPanel(Client* c, int arg_x_pos, int arg_y_pos);
   virtual ~ButtonPanel();

Modified: trunk/pingus/src/editor/action_properties.cpp
===================================================================
--- trunk/pingus/src/editor/action_properties.cpp       2007-09-11 15:03:27 UTC 
(rev 3125)
+++ trunk/pingus/src/editor/action_properties.cpp       2007-09-11 16:25:16 UTC 
(rev 3126)
@@ -27,6 +27,7 @@
 #include <boost/bind.hpp>
 #include "gui_style.hpp"
 #include "checkbox.hpp"
+#include "editor_level.hpp"
 #include "pingu_enums.hpp"
 #include "inputbox.hpp"
 #include "action_properties.hpp"
@@ -91,6 +92,12 @@
 }
 
 void
+ActionProperties::set_level(EditorLevel* level_)
+{
+  level = level_;
+}
+
+void
 ActionProperties::on_checkbox_change(bool t, Actions::ActionName id)
 {
   std::cout << "ActionProperties::on_checkbox_change: " << id << " " << t << 
std::endl;
@@ -101,6 +108,7 @@
 {
   std::cout << "ActionProperties::on_inputbox_change: " << id << " " << value 
<< std::endl;
 }
+
 
 } // namespace Editor
 

Modified: trunk/pingus/src/editor/action_properties.hpp
===================================================================
--- trunk/pingus/src/editor/action_properties.hpp       2007-09-11 15:03:27 UTC 
(rev 3125)
+++ trunk/pingus/src/editor/action_properties.hpp       2007-09-11 16:25:16 UTC 
(rev 3126)
@@ -32,12 +32,14 @@
 namespace Editor {
 
 class EditorScreen;
+class EditorLevel;
 
 /** */
 class ActionProperties : public GUI::GroupComponent
 {
 private:
   EditorScreen* editor;
+  EditorLevel*  level;
   int y_pos;
 
 public:
@@ -49,6 +51,8 @@
   
   void add_action(Actions::ActionName id);
 
+  void set_level(EditorLevel* level);
+
   void on_checkbox_change(bool t, Actions::ActionName id);
   void on_inputbox_change(const std::string& str, Actions::ActionName id);
 private:

Modified: trunk/pingus/src/editor/editor_level.cpp
===================================================================
--- trunk/pingus/src/editor/editor_level.cpp    2007-09-11 15:03:27 UTC (rev 
3125)
+++ trunk/pingus/src/editor/editor_level.cpp    2007-09-11 16:25:16 UTC (rev 
3126)
@@ -103,7 +103,8 @@
   for (std::map<std::string, int>::const_iterator i = impl->actions.begin();
        i != impl->actions.end(); i++)
     {
-      fw.write_int(i->first.c_str(), i->second);
+      if (i->second > 0)
+        fw.write_int(i->first.c_str(), i->second);
     }
   fw.end_section();    // actions
 
@@ -253,6 +254,78 @@
   impl->objects.push_back(obj);
 }
 
+void
+EditorLevel::set_description(const std::string& str)
+{
+  impl->description = str;
+}
+
+void
+EditorLevel::set_levelname(const std::string& str)
+{
+  impl->levelname = str;
+}
+
+void
+EditorLevel::set_author(const std::string& str)
+{
+  impl->author = str;
+}
+
+std::string
+EditorLevel::get_description() const
+{
+  return impl->description;
+}
+
+std::string
+EditorLevel::get_levelname() const
+{
+  return impl->levelname;
+}
+
+std::string
+EditorLevel::get_author() const
+{
+  return impl->author;
+}
+
+int
+EditorLevel::get_number_of_pingus() const
+{
+  return impl->number_of_pingus;
+}
+
+int
+EditorLevel::get_number_to_save() const
+{
+  return impl->number_to_save;
+}
+
+void
+EditorLevel::set_number_of_pingus(int i)
+{
+  impl->number_of_pingus = i;
+}
+
+void
+EditorLevel::set_number_to_save(int i)
+{
+  impl->number_to_save = i;
+}
+
+void
+EditorLevel::set_action(const std::string& actionname, int count)
+{
+  impl->actions[actionname] = count;
+}
+
+std::map<std::string, int>
+EditorLevel::get_actions() const
+{
+  return impl->actions;
+}
+
 } // namespace Editor
 
 /* EOF */

Modified: trunk/pingus/src/editor/editor_level.hpp
===================================================================
--- trunk/pingus/src/editor/editor_level.hpp    2007-09-11 15:03:27 UTC (rev 
3125)
+++ trunk/pingus/src/editor/editor_level.hpp    2007-09-11 16:25:16 UTC (rev 
3126)
@@ -59,6 +59,23 @@
   /** Return LevelImpl */
   LevelImpl* get_level_impl() { return impl; }
 
+  void set_description(const std::string& str);
+  void set_levelname(const std::string& str);
+  void set_author(const std::string& str);
+
+  std::string get_description() const;
+  std::string get_levelname() const;
+  std::string get_author() const;
+
+  void set_number_of_pingus(int i);
+  void set_number_to_save(int i);
+
+  int get_number_of_pingus() const;
+  int get_number_to_save() const;
+
+  void set_action(const std::string& actionname, int count); 
+  std::map<std::string, int> get_actions() const;
+
 private:
   LevelImpl* impl;
 

Modified: trunk/pingus/src/editor/editor_screen.cpp
===================================================================
--- trunk/pingus/src/editor/editor_screen.cpp   2007-09-11 15:03:27 UTC (rev 
3125)
+++ trunk/pingus/src/editor/editor_screen.cpp   2007-09-11 16:25:16 UTC (rev 
3126)
@@ -83,6 +83,7 @@
 
   level_properties = new LevelProperties(this, Rect(Vector2i(0,38), 
Size(Display::get_width()-244,280)));
   level_properties->hide();
+  level_properties->set_level(plf);
   gui_manager->add(level_properties, true);
 }
 
@@ -118,6 +119,7 @@
 EditorScreen::load(const Pathname& file)
 {
   plf->load_level(file);
+  level_properties->set_level(plf);
   viewport->refresh();
 }
 

Modified: trunk/pingus/src/editor/level_properties.cpp
===================================================================
--- trunk/pingus/src/editor/level_properties.cpp        2007-09-11 15:03:27 UTC 
(rev 3125)
+++ trunk/pingus/src/editor/level_properties.cpp        2007-09-11 16:25:16 UTC 
(rev 3126)
@@ -23,9 +23,13 @@
 **  02111-1307, USA.
 */
 
+#include <iostream>
+#include <boost/bind.hpp>
+#include "string_util.hpp"
 #include "label.hpp"
 #include "inputbox.hpp"
 #include "gui_style.hpp"
+#include "editor_level.hpp"
 #include "level_properties.hpp"
 
 /*
@@ -41,21 +45,23 @@
 namespace Editor {
 
 LevelProperties::LevelProperties(EditorScreen* editor, const Rect& rect)
-  : GroupComponent(rect)
+  : GroupComponent(rect),
+    level(0)
 {
   int w = rect.get_width() - 120;
   add(new Label   (Rect(Vector2i( 10,  10), Size( 80, 20)), "Author:"), true);
-  add(new Inputbox(Rect(Vector2i(110,  10), Size(  w, 20))), true);
+  add(author = new Inputbox(Rect(Vector2i(110,  10), Size(  w, 20))), true);
   add(new Label   (Rect(Vector2i( 10,  32), Size( 80, 20)), "Levelname:"), 
true);
-  add(new Inputbox(Rect(Vector2i(110,  32), Size(  w, 20))), true);
+  add(levelname = new Inputbox(Rect(Vector2i(110,  32), Size(  w, 20))), true);
   add(new Label   (Rect(Vector2i( 10,  54), Size( 80, 20)), "Description:"), 
true);
-  add(new Inputbox(Rect(Vector2i(110,  54), Size(  w, 20*3))), true);
-  
+  add(description = new Inputbox(Rect(Vector2i(110,  54), Size(  w, 20*3))), 
true);
+
   int y = 116;
   add(new Label   (Rect(Vector2i( 10,  y), Size( 80, 20)), "Pingus Count:"), 
true);
-  add(new Inputbox(Rect(Vector2i(110,  y), Size(  w, 20))), true);
+  add(number_of_pingus = new Inputbox(Rect(Vector2i(110,  y), Size(  w, 20))), 
true);
   add(new Label   (Rect(Vector2i( 10,  y+22), Size( 80, 20)), "Pingus to 
Save:"), true);
-  add(new Inputbox(Rect(Vector2i(110,  y+22), Size(  w, 20))), true);
+  add(number_to_save = new Inputbox(Rect(Vector2i(110,  y+22), Size(  w, 
20))), true);
+
   add(new Label   (Rect(Vector2i( 10,  y+44), Size( 80, 20)), "Time:"), true);
   add(new Inputbox(Rect(Vector2i(110,  y+44), Size(  w, 20))), true);
   add(new Label   (Rect(Vector2i( 10,  y+66), Size( 80, 20)), "Width:"), true);
@@ -67,6 +73,13 @@
   add(new Inputbox(Rect(Vector2i(110, y+110), Size(  w, 20))), true);
   add(new Label   (Rect(Vector2i( 10, y+132), Size( 80, 20)), "Comment:"), 
true);
   add(new Inputbox(Rect(Vector2i(110, y+132), Size(  w, 20))), true);
+
+  author->on_change.connect(boost::bind(&LevelProperties::on_author_change, 
this, _1));
+  
levelname->on_change.connect(boost::bind(&LevelProperties::on_levelname_change, 
this, _1));
+  
description->on_change.connect(boost::bind(&LevelProperties::on_description_change,
 this, _1));
+
+  
number_to_save->on_change.connect(boost::bind(&LevelProperties::on_number_to_save_change,
 this, _1));
+  
number_of_pingus->on_change.connect(boost::bind(&LevelProperties::on_number_of_pingus_change,
 this, _1));
 }
 
 LevelProperties::~LevelProperties()
@@ -83,20 +96,35 @@
 LevelProperties::update(float delta)
 {
 }
+
+void
+LevelProperties::set_level(EditorLevel* level_)
+{
+  level = level_;
+  description->set_text(level->get_description());
+  levelname->set_text(level->get_levelname());
+  author->set_text(level->get_author());
+
+  
number_of_pingus->set_text(StringUtil::to_string(level->get_number_of_pingus()));
+  number_to_save->set_text(StringUtil::to_string(level->get_number_to_save()));
+}
 
 void
 LevelProperties::on_author_change(const std::string& str)
 {
+  level->set_author(str);
 }
 
 void
 LevelProperties::on_levelname_change(const std::string& str)
 {
+  level->set_levelname(str);
 }
 
 void
 LevelProperties::on_description_change(const std::string& str)
 {
+  level->set_description(str);
 }
 
 void
@@ -108,6 +136,35 @@
 LevelProperties::on_height_change(const std::string& str)
 {
 }
+
+void
+LevelProperties::on_number_to_save_change(const std::string& str)
+{
+  int num;
+  if (StringUtil::from_string(str, num))
+    {
+      level->set_number_to_save(num);
+    }
+  else
+    {
+      std::cout << "LevelProperties::on_number_to_save_change: '" << str << "' 
not an integer" << std::endl;
+    }
+  
+}
+
+void
+LevelProperties::on_number_of_pingus_change(const std::string& str)
+{
+  int num;
+  if (StringUtil::from_string(str, num))
+    {
+      level->set_number_of_pingus(num);
+    }
+  else
+    {
+      std::cout << "LevelProperties::on_number_of_pingus_change: '" << str << 
"' not an integer" << std::endl;
+    }
+}
 
 } // namespace Editor
 

Modified: trunk/pingus/src/editor/level_properties.hpp
===================================================================
--- trunk/pingus/src/editor/level_properties.hpp        2007-09-11 15:03:27 UTC 
(rev 3125)
+++ trunk/pingus/src/editor/level_properties.hpp        2007-09-11 16:25:16 UTC 
(rev 3126)
@@ -31,13 +31,23 @@
 namespace Editor {
 
 class EditorScreen;
+class EditorLevel;
+class Inputbox;
 
 /** */
 class LevelProperties : public GUI::GroupComponent
 {
 private:
   EditorScreen* editor;
+  EditorLevel*  level;
 
+  Inputbox* author;
+  Inputbox* levelname;
+  Inputbox* description;
+
+  Inputbox* number_of_pingus;
+  Inputbox* number_to_save;
+
 public:
   LevelProperties(EditorScreen* editor, const Rect& rect);
   ~LevelProperties();
@@ -45,6 +55,8 @@
   void draw_background (DrawingContext& gc);
   void update (float delta); 
 
+  void set_level(EditorLevel* level);
+
   void on_author_change(const std::string& str);
   void on_levelname_change(const std::string& str);
   void on_description_change(const std::string& str);
@@ -52,6 +64,8 @@
   void on_width_change(const std::string& str);
   void on_height_change(const std::string& str);
 
+  void on_number_to_save_change(const std::string& str);
+  void on_number_of_pingus_change(const std::string& str);
 private:
   LevelProperties (const LevelProperties&);
   LevelProperties& operator= (const LevelProperties&);





reply via email to

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