pingus-cvs
[Top][All Lists]
Advanced

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

[Pingus-CVS] r3502 - in trunk/pingus/src: . components


From: grumbel at BerliOS
Subject: [Pingus-CVS] r3502 - in trunk/pingus/src: . components
Date: Thu, 8 Nov 2007 19:18:04 +0100

Author: grumbel
Date: 2007-11-08 19:18:03 +0100 (Thu, 08 Nov 2007)
New Revision: 3502

Modified:
   trunk/pingus/src/components/check_box.cpp
   trunk/pingus/src/components/check_box.hpp
   trunk/pingus/src/components/choice_box.cpp
   trunk/pingus/src/components/choice_box.hpp
   trunk/pingus/src/components/slider_box.cpp
   trunk/pingus/src/option_menu.cpp
   trunk/pingus/src/option_menu.hpp
Log:
- some more option menu stuff

Modified: trunk/pingus/src/components/check_box.cpp
===================================================================
--- trunk/pingus/src/components/check_box.cpp   2007-11-08 14:24:30 UTC (rev 
3501)
+++ trunk/pingus/src/components/check_box.cpp   2007-11-08 18:18:03 UTC (rev 
3502)
@@ -32,6 +32,7 @@
 CheckBox::on_primary_button_press (int x, int y) 
 {
   state = !state;
+  on_change(state);
 }
 
 void

Modified: trunk/pingus/src/components/check_box.hpp
===================================================================
--- trunk/pingus/src/components/check_box.hpp   2007-11-08 14:24:30 UTC (rev 
3501)
+++ trunk/pingus/src/components/check_box.hpp   2007-11-08 18:18:03 UTC (rev 
3502)
@@ -20,6 +20,7 @@
 #ifndef HEADER_CHECK_BOX_HPP
 #define HEADER_CHECK_BOX_HPP
 
+#include <boost/signal.hpp>
 #include <string>
 #include "gui/rect_component.hpp"
 
@@ -36,6 +37,8 @@
   void on_primary_button_press(int x, int y);
   void update_layout() {}
 
+  boost::signal<void (bool)> on_change;
+
 private:
   CheckBox (const CheckBox&);
   CheckBox& operator= (const CheckBox&);

Modified: trunk/pingus/src/components/choice_box.cpp
===================================================================
--- trunk/pingus/src/components/choice_box.cpp  2007-11-08 14:24:30 UTC (rev 
3501)
+++ trunk/pingus/src/components/choice_box.cpp  2007-11-08 18:18:03 UTC (rev 
3502)
@@ -26,9 +26,7 @@
   : RectComponent(rect)
 {
   current_choice = 0;
-  choices.push_back("Choice 1");
-  choices.push_back("Choice 2");
-  choices.push_back("Choice 3");
+
 }
 
 void
@@ -37,34 +35,50 @@
   if (maintainer_mode)
     gc.draw_rect(rect, Color(0, 255, 255));  
 
-  if (current_choice >= 0 && current_choice < int(choices.size()))
+  if (!choices.empty())
     {
-      gc.print_left(Fonts::chalk_normal,  rect.left,  rect.top, "<");
-      gc.print_right(Fonts::chalk_normal, rect.right, rect.top, ">");
+      if (current_choice >= 0 && current_choice < int(choices.size()))
+        {
+          //if (current_choice != 0) 
+            gc.print_left(Fonts::chalk_normal,  rect.left,  rect.top, "<");
 
+            //if (current_choice != int(choices.size())-1)
+            gc.print_right(Fonts::chalk_normal, rect.right, rect.top, ">");
 
-      gc.print_center(Fonts::chalk_normal, rect.left + rect.get_width()/2, 
rect.top, 
-                      choices[current_choice]);
+          gc.print_center(Fonts::chalk_normal, rect.left + rect.get_width()/2, 
rect.top, 
+                          choices[current_choice]);
+        }
     }
 }
 
 void
 ChoiceBox::on_primary_button_press(int x, int y)
 {
-  x -= rect.left;
+  if (!choices.empty())
+    {
+      x -= rect.left;
   
-  if (x > rect.get_width()/2)
-    {   
-      current_choice += 1;
-      if (current_choice >= int(choices.size()))
-        current_choice = choices.size() - 1;
+      if (x > rect.get_width()/2)
+        {   
+          current_choice += 1;
+          if (current_choice >= int(choices.size()))
+            current_choice = 0;
+            //current_choice = choices.size() - 1;
+        }
+      else
+        {
+          current_choice -= 1;
+          if (current_choice < 0)
+            current_choice = choices.size()-1;
+            //current_choice = 0;
+        }
     }
-  else
-    {
-      current_choice -= 1;
-      if (current_choice < 0)
-        current_choice = 0;
-    }
 }
 
+void
+ChoiceBox::add_choice(const std::string& str)
+{
+  choices.push_back(str);
+}
+
 /* EOF */

Modified: trunk/pingus/src/components/choice_box.hpp
===================================================================
--- trunk/pingus/src/components/choice_box.hpp  2007-11-08 14:24:30 UTC (rev 
3501)
+++ trunk/pingus/src/components/choice_box.hpp  2007-11-08 18:18:03 UTC (rev 
3502)
@@ -37,7 +37,8 @@
   void draw(DrawingContext& gc);
   void on_primary_button_press(int x, int y);
   void update_layout() {}
-
+  void add_choice(const std::string& str);
+  
 private:
   ChoiceBox (const ChoiceBox&);
   ChoiceBox& operator= (const ChoiceBox&);

Modified: trunk/pingus/src/components/slider_box.cpp
===================================================================
--- trunk/pingus/src/components/slider_box.cpp  2007-11-08 14:24:30 UTC (rev 
3501)
+++ trunk/pingus/src/components/slider_box.cpp  2007-11-08 18:18:03 UTC (rev 
3502)
@@ -76,7 +76,7 @@
     {
       x -= rect.left;
   
-      value = 20 * x / rect.get_width();
+      value = 20 * x / (rect.get_width() - 12);
   
       if (value > 20)
         value = 20;

Modified: trunk/pingus/src/option_menu.cpp
===================================================================
--- trunk/pingus/src/option_menu.cpp    2007-11-08 14:24:30 UTC (rev 3501)
+++ trunk/pingus/src/option_menu.cpp    2007-11-08 18:18:03 UTC (rev 3502)
@@ -17,6 +17,9 @@
 //  along with this program; if not, write to the Free Software
 //  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 
+#include <set>
+#include <boost/bind.hpp>
+#include "globals.hpp"
 #include "gettext.h"
 #include "resource.hpp"
 #include "screen/screen_manager.hpp"
@@ -27,8 +30,11 @@
 #include "components/slider_box.hpp"
 #include "components/choice_box.hpp"
 #include "gui/gui_manager.hpp"
+#include "tinygettext/dictionary_manager.hpp"
 #include "option_menu.hpp"
 
+extern TinyGetText::DictionaryManager dictionary_manager;
+
 OptionMenu::OptionMenu()
 {
   background = Resource::load_sprite("core/menu/optionmenu");
@@ -37,19 +43,46 @@
   x_pos = 0;
   y_pos = 0;
 
-  add_item("Resolution:",      new ChoiceBox(Rect()));
-  add_item("Fullscreen:",      new CheckBox(Rect()));
-  add_item("Allow Resize:",    new CheckBox(Rect()));
-  add_item("Fast Mode:",       new CheckBox(Rect()));
-  add_item("Frame Skip:",      new CheckBox(Rect()));
-  add_item("Software Cursor:", new CheckBox(Rect()));
+  ChoiceBox* resolution_box = new ChoiceBox(Rect());
+  resolution_box->add_choice("640x480");
+  resolution_box->add_choice("800x480");
+  resolution_box->add_choice("800x600");
+  resolution_box->add_choice("1024x768");
+  resolution_box->add_choice("1152x864");
+  resolution_box->add_choice("1280x960");
+  resolution_box->add_choice("1280x1024");
+  resolution_box->add_choice("1600x1200");
+  resolution_box->add_choice("1920x1080");
 
-  add_item("Language:",        new ChoiceBox(Rect()));
-  add_item("Master Volume:",   new SliderBox(Rect()));
-  add_item("Sound Volume:",    new SliderBox(Rect()));
-  add_item("Music Volume:",    new SliderBox(Rect()));
-  add_item("Scroll Mode:",     new ChoiceBox(Rect()));
-  add_item("Mouse Grab:",      new CheckBox(Rect()));
+  ChoiceBox* language_box = new ChoiceBox(Rect());
+  std::set<std::string> lst = dictionary_manager.get_languages();
+  for (std::set<std::string>::iterator i = lst.begin(); i != lst.end(); ++i)
+    language_box->add_choice(TinyGetText::get_language_def(*i)->name);
+
+  ChoiceBox* scroll_box = new ChoiceBox(Rect());
+  scroll_box->add_choice("Auto-Scroll");
+  scroll_box->add_choice("Drag&Drop");
+  scroll_box->add_choice("Rubberband");
+  
+  swcursor_box   = new CheckBox(Rect());
+  fullscreen_box = new CheckBox(Rect());
+
+  swcursor_box->on_change.connect(boost::bind(&OptionMenu::on_swcursor_change, 
this, _1));
+  
fullscreen_box->on_change.connect(boost::bind(&OptionMenu::on_fullscreen_change,
 this, _1));
+
+  add_item(_("Resolution:"),      resolution_box);
+  add_item(_("Fullscreen:"),      fullscreen_box);
+  add_item(_("Allow Resize:"),    new CheckBox(Rect()));
+  add_item(_("Fast Mode:"),       new CheckBox(Rect()));
+  add_item(_("Frame Skip:"),      new CheckBox(Rect()));
+  add_item(_("Software Cursor:"), swcursor_box);
+
+  add_item(_("Language:"),        language_box);
+  add_item(_("Master Volume:"),   new SliderBox(Rect()));
+  add_item(_("Sound Volume:"),    new SliderBox(Rect()));
+  add_item(_("Music Volume:"),    new SliderBox(Rect()));
+  add_item(_("Scroll Mode:"),     scroll_box);
+  add_item(_("Mouse Grab:"),      new CheckBox(Rect()));
 }
 
 void
@@ -172,7 +205,19 @@
 void
 OptionMenu::resize(const Size&)
 {
-  
 }
 
+void
+OptionMenu::on_swcursor_change(bool v)
+{
+  std::cout << "v: " << v << std::endl;
+  swcursor_enabled = v;
+}
+
+void
+OptionMenu::on_fullscreen_change(bool v)
+{
+  fullscreen_enabled = true;
+}
+
 /* EOF */

Modified: trunk/pingus/src/option_menu.hpp
===================================================================
--- trunk/pingus/src/option_menu.hpp    2007-11-08 14:24:30 UTC (rev 3501)
+++ trunk/pingus/src/option_menu.hpp    2007-11-08 18:18:03 UTC (rev 3502)
@@ -25,6 +25,8 @@
 #include "components/label.hpp"
 #include "gui/rect_component.hpp"
 
+class CheckBox;
+
 /** */
 class OptionMenu : public GUIScreen
 {
@@ -45,6 +47,9 @@
 
   typedef std::vector<Option> Options;
   Options options;
+
+  CheckBox* fullscreen_box;
+  CheckBox* swcursor_box;
   
 public:
   OptionMenu();
@@ -57,6 +62,9 @@
   void add_item(const std::string& label, GUI::RectComponent* control);
 
   void resize(const Size&);
+
+  void on_swcursor_change(bool v);
+  void on_fullscreen_change(bool v);
 private:
   OptionMenu (const OptionMenu&);
   OptionMenu& operator= (const OptionMenu&);





reply via email to

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