pingus-cvs
[Top][All Lists]
Advanced

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

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


From: grumbel at BerliOS
Subject: [Pingus-CVS] r3503 - in trunk/pingus: . src src/components
Date: Fri, 9 Nov 2007 09:38:26 +0100

Author: grumbel
Date: 2007-11-09 09:38:26 +0100 (Fri, 09 Nov 2007)
New Revision: 3503

Added:
   trunk/pingus/src/config_manager.cpp
   trunk/pingus/src/config_manager.hpp
Modified:
   trunk/pingus/SConstruct
   trunk/pingus/src/components/slider_box.cpp
   trunk/pingus/src/components/slider_box.hpp
   trunk/pingus/src/option_menu.cpp
   trunk/pingus/src/option_menu.hpp
Log:
- added ConfigManager, some more OptionMenu work

Modified: trunk/pingus/SConstruct
===================================================================
--- trunk/pingus/SConstruct     2007-11-08 18:18:03 UTC (rev 3502)
+++ trunk/pingus/SConstruct     2007-11-09 08:38:26 UTC (rev 3503)
@@ -60,6 +60,7 @@
 'src/client.cpp', 
 'src/col_map.cpp', 
 'src/collider.cpp', 
+'src/config_manager.cpp', 
 'src/colliders/pingu_collider.cpp', 
 'src/components/choice_box.cpp', 
 'src/components/slider_box.cpp', 

Modified: trunk/pingus/src/components/slider_box.cpp
===================================================================
--- trunk/pingus/src/components/slider_box.cpp  2007-11-08 18:18:03 UTC (rev 
3502)
+++ trunk/pingus/src/components/slider_box.cpp  2007-11-09 08:38:26 UTC (rev 
3503)
@@ -17,6 +17,7 @@
 //  along with this program; if not, write to the Free Software
 //  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 
+#include "math.hpp"
 #include "globals.hpp"
 #include "fonts.hpp"
 #include "display/drawing_context.hpp"
@@ -74,14 +75,16 @@
 {
   if (drag_drop)
     {
+      int old_value = value;
+
       x -= rect.left;
   
       value = 20 * x / (rect.get_width() - 12);
   
-      if (value > 20)
-        value = 20;
-      else if (value < 0)
-        value = 0; 
+      value = Math::clamp(0, value, 20);
+
+      if (value != old_value)
+        on_change(value*5); // scale to [0,100]
     }
 }
 

Modified: trunk/pingus/src/components/slider_box.hpp
===================================================================
--- trunk/pingus/src/components/slider_box.hpp  2007-11-08 18:18:03 UTC (rev 
3502)
+++ trunk/pingus/src/components/slider_box.hpp  2007-11-09 08:38:26 UTC (rev 
3503)
@@ -21,6 +21,7 @@
 #define HEADER_SLIDER_BOX_HPP
 
 #include <string>
+#include <boost/signal.hpp>
 #include "gui/rect_component.hpp"
 
 /** */
@@ -39,6 +40,8 @@
   void on_pointer_move(int x, int y);
   void update_layout() {}
 
+  boost::signal<void (int)> on_change;
+
 private:
   SliderBox (const SliderBox&);
   SliderBox& operator= (const SliderBox&);

Added: trunk/pingus/src/config_manager.cpp
===================================================================
--- trunk/pingus/src/config_manager.cpp 2007-11-08 18:18:03 UTC (rev 3502)
+++ trunk/pingus/src/config_manager.cpp 2007-11-09 08:38:26 UTC (rev 3503)
@@ -0,0 +1,160 @@
+/*  $Id$
+**   __      __ __             ___        __   __ __   __
+**  /  \    /  \__| ____    __| _/_______/  |_|__|  | |  |   ____
+**  \   \/\/   /  |/    \  / __ |/  ___/\   __\  |  | |  | _/ __ \
+**   \        /|  |   |  \/ /_/ |\___ \  |  | |  |  |_|  |_\  ___/
+**    \__/\  / |__|___|  /\____ /____  > |__| |__|____/____/\___  >
+**         \/          \/      \/    \/                         \/
+**  Copyright (C) 2007 Ingo Ruhnke <address@hidden>
+**
+**  This program is free software; you can redistribute it and/or
+**  modify it under the terms of the GNU General Public License
+**  as published by the Free Software Foundation; either version 2
+**  of the License, or (at your option) any later version.
+**
+**  This program is distributed in the hope that it will be useful,
+**  but WITHOUT ANY WARRANTY; without even the implied warranty of
+**  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+**  GNU General Public License for more details.
+** 
+**  You should have received a copy of the GNU General Public License
+**  along with this program; if not, write to the Free Software
+**  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+**  02111-1307, USA.
+*/
+
+#include "config_manager.hpp"
+
+void
+ConfigManager::set_master_volume(int v)
+{
+}
+
+int
+ConfigManager::get_master_volume()
+{
+  return 0;
+}
+
+void
+ConfigManager::set_sound_volume(int v)
+{
+}
+
+int
+ConfigManager::get_sound_volume()
+{
+  return 0;
+}
+
+void
+ConfigManager::set_music_volume(int v)
+{
+}
+
+int
+ConfigManager::get_music_volume()
+{
+  return 0;
+}
+
+void
+ConfigManager::set_resolution(const Size& size)
+{
+}
+
+Size
+ConfigManager::get_resolution()
+{
+  return Size();
+}
+
+void
+ConfigManager::set_fullscreen(bool)
+{
+}
+
+bool
+ConfigManager::get_fullscreen()
+{
+  return false;
+}
+
+void
+ConfigManager::set_allow_resize(bool)
+{
+}
+
+bool
+ConfigManager::get_allow_resize()
+{
+  return false;
+}
+
+void
+ConfigManager::set_fast_mode(bool)
+{
+}
+
+bool
+ConfigManager::get_fast_mode()
+{
+  return false;
+}
+
+void
+ConfigManager::set_mouse_grab(bool)
+{
+}
+
+bool
+ConfigManager::get_mouse_grab()
+{
+  return false;
+}
+
+void
+ConfigManager::set_print_fps(bool)
+{
+}
+
+bool
+ConfigManager::get_print_fps()
+{
+  return false;
+}
+
+void
+ConfigManager::set_language(const std::string&)
+{
+}
+
+std::string
+ConfigManager::get_language()
+{
+  return "";
+}
+
+void
+ConfigManager::set_swcursor(bool)
+{
+}
+
+bool
+ConfigManager::get_swcursor()
+{
+  return false;
+}
+
+void
+ConfigManager::set_autoscroll(bool)
+{
+}
+
+bool
+ConfigManager::get_autoscroll()
+{
+  return false;
+}
+
+/* EOF */


Property changes on: trunk/pingus/src/config_manager.cpp
___________________________________________________________________
Name: svn:keywords
   + Id
Name: svn:eol-style
   + native

Added: trunk/pingus/src/config_manager.hpp
===================================================================
--- trunk/pingus/src/config_manager.hpp 2007-11-08 18:18:03 UTC (rev 3502)
+++ trunk/pingus/src/config_manager.hpp 2007-11-09 08:38:26 UTC (rev 3503)
@@ -0,0 +1,93 @@
+//  $Id$
+//
+//  Pingus - A free Lemmings clone
+//  Copyright (C) 2007 Ingo Ruhnke <address@hidden>
+//
+//  This program is free software; you can redistribute it and/or
+//  modify it under the terms of the GNU General Public License
+//  as published by the Free Software Foundation; either version 2
+//  of the License, or (at your option) any later version.
+//
+//  This program is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+//  GNU General Public License for more details.
+//
+//  You should have received a copy of the GNU General Public License
+//  along with this program; if not, write to the Free Software
+//  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+
+#ifndef HEADER_CONFIG_MANAGER_HPP
+#define HEADER_CONFIG_MANAGER_HPP
+
+#include <string>
+#include <boost/signal.hpp>
+#include "math/size.hpp"
+
+/** */
+class ConfigManager
+{
+private:
+public:
+  ConfigManager();
+  ~ConfigManager();
+
+  /** Save the configuration to file */
+  void save();
+
+  void set_master_volume(int);
+  int  get_master_volume();
+  boost::signal<void(int)> on_master_volume_change();
+
+  void set_sound_volume(int);
+  int  get_sound_volume();
+  boost::signal<void(int)> on_sound_volume_change();
+
+  void set_music_volume(int);
+  int  get_music_volume();
+  boost::signal<void(int)> on_music_volume_change();
+
+  void set_resolution(const Size& size);
+  Size get_resolution();
+  boost::signal<void(Size)> on_resolution_change();
+
+  void set_fullscreen(bool);
+  bool get_fullscreen();
+  boost::signal<void(bool)> on_fullscreen_change();
+
+  void set_allow_resize(bool);
+  bool get_allow_resize();
+  boost::signal<void(bool)> on_allow_reszie_change();
+
+  void set_fast_mode(bool);
+  bool get_fast_mode();
+  boost::signal<void(bool)> on_fast_mode_change();
+
+  void set_mouse_grab(bool);
+  bool get_mouse_grab();
+  boost::signal<void(bool)> on_mouse_grab_change();
+
+  void set_print_fps(bool);
+  bool get_print_fps();
+  boost::signal<void(bool)> on_print_fps_change();
+
+  void set_language(const std::string&);
+  std::string get_language();
+  boost::signal<void(const std::string&)> on_language_change();
+
+  void set_swcursor(bool);
+  bool get_swcursor();
+  boost::signal<void(bool)> on_swcursor_change();
+
+  void set_autoscroll(bool);
+  bool get_autoscroll();
+  boost::signal<void(bool)> on_autoscroll_change();
+
+private:
+  ConfigManager (const ConfigManager&);
+  ConfigManager& operator= (const ConfigManager&);
+};
+
+#endif
+
+/* EOF */


Property changes on: trunk/pingus/src/config_manager.hpp
___________________________________________________________________
Name: svn:keywords
   + Id
Name: svn:eol-style
   + native

Modified: trunk/pingus/src/option_menu.cpp
===================================================================
--- trunk/pingus/src/option_menu.cpp    2007-11-08 18:18:03 UTC (rev 3502)
+++ trunk/pingus/src/option_menu.cpp    2007-11-09 08:38:26 UTC (rev 3503)
@@ -60,29 +60,44 @@
     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      = new CheckBox(Rect());
+  fullscreen_box    = new CheckBox(Rect());
+  autoscrolling_box = new CheckBox(Rect());
+  fastmode_box      = new CheckBox(Rect());
+  mousegrab_box     = new CheckBox(Rect());
+  printfps_box      = new CheckBox(Rect());
 
+  master_volume_box = new SliderBox(Rect());
+  sound_volume_box  = new SliderBox(Rect());
+  music_volume_box  = new SliderBox(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));
+  
autoscrolling_box->on_change.connect(boost::bind(&OptionMenu::on_autoscrolling_change,
 this, _1));
+  fastmode_box->on_change.connect(boost::bind(&OptionMenu::on_fastmode_change, 
this, _1));
+  
mousegrab_box->on_change.connect(boost::bind(&OptionMenu::on_mousegrab_change, 
this, _1));
+  printfps_box->on_change.connect(boost::bind(&OptionMenu::on_printfps_change, 
this, _1));
 
+  
master_volume_box->on_change.connect(boost::bind(&OptionMenu::on_master_volume_change,
 this, _1));
+  
sound_volume_box->on_change.connect(boost::bind(&OptionMenu::on_sound_volume_change,
 this, _1));
+  
music_volume_box->on_change.connect(boost::bind(&OptionMenu::on_music_volume_change,
 this, _1));
+
+  add_item(_("Language:"),        language_box);
+  add_item(_("Scroll Mode:"),     scroll_box);
   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(_("Autoscrolling:"),   autoscrolling_box);
+  add_item(_("Low Detail:"),      fastmode_box);
+
+  add_item(_("Master Volume:"),   master_volume_box);
+  add_item(_("Sound Volume:"),    sound_volume_box);
+  add_item(_("Music Volume:"),    music_volume_box);
+  add_item(_("Print FPS:"),       printfps_box);
+  add_item(_("Mouse Grab:"),      mousegrab_box);
   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
@@ -90,7 +105,7 @@
 {
   gui_manager->add(new Label(label, Rect(Vector2i(120 + x_pos * 312, 177 + 
y_pos*32), 
                                          Size(140, 32))),
-                             true);
+                   true);
   gui_manager->add(control, true);
 
   if (dynamic_cast<ChoiceBox*>(control))
@@ -145,49 +160,13 @@
 void
 OptionMenu::draw_background(DrawingContext& gc)
 {
+  gc.fill_screen(Color(0, 0, 0));
+
   // gc.draw_fillrect(Rect(100, 100, 400, 400), Color(255, 0, 0));
   gc.draw(background, Vector2i(gc.get_width()/2 - background.get_width()/2, 
gc.get_height()/2 - background.get_height()/2));
 
   gc.print_center(Fonts::chalk_large, gc.get_width()/2, 90, "Option Menu");
 
-  if (0)  
-    {
-      std::vector<OptionEntry> strs;
-      strs.push_back(OptionEntry("Resolution:",    "<800x600>"));
-      strs.push_back(OptionEntry("Fullscreen:",    "[X]"));
-      strs.push_back(OptionEntry("Allow Resize:",  "[X]"));
-      strs.push_back(OptionEntry("Fast Mode:",     "[X]"));
-      strs.push_back(OptionEntry("Frame Skip:",      "<5>"));
-      strs.push_back(OptionEntry("Software Cursor:", "[X]"));
-
-      int y = 145;
-      for(std::vector<OptionEntry>::iterator i = strs.begin(); i != 
strs.end(); ++i)
-        {
-          //gc.print_left(Fonts::chalk_normal,  120, y += 32, i->left);
-          y += 32;
-          if (i->right != "[X]")
-            gc.print_right(Fonts::chalk_normal, gc.get_width()/2 - 32, y, 
i->right);
-        }
-
-      std::vector<OptionEntry> strs2;
-      strs2.push_back(OptionEntry("Language:",        "<German>"));
-      strs2.push_back(OptionEntry("Master Volume:", 
"[||||||||||||||||||||||||||||||]"));
-      strs2.push_back(OptionEntry("Sound Volume:",  
"[||||||||||||||||||||||||||||||]"));
-      strs2.push_back(OptionEntry("Music Volume:",  
"[||||||||||||||||||||||||||||||]"));
-      strs2.push_back(OptionEntry("Scroll Mode:",     "<drag&drop>"));
-      strs2.push_back(OptionEntry("Mouse Grab:",     "[X]"));
-      //strs2.push_back(OptionEntry("Auto Online Updates:", "[X]"));
-
-      y = 145;
-      for(std::vector<OptionEntry>::iterator i = strs2.begin(); i != 
strs2.end(); ++i)
-        {
-          //gc.print_left(Fonts::chalk_normal,  gc.get_width()/2 + 32, y += 
32, i->left);
-          y += 32;
-          if (i->right != "[X]")
-            gc.print_right(Fonts::chalk_normal, gc.get_width()/2 + 280, y, 
i->right);
-        }
-    }
-
   gc.print_center(Fonts::chalk_normal, gc.get_width()/2 + 225 + 30, 
gc.get_height()/2 + 125 - 20, _("Close"));
   gc.draw(ok_button, Vector2i(gc.get_width()/2 + 225, gc.get_height()/2 + 
125));
 
@@ -210,14 +189,58 @@
 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;
+  fullscreen_enabled = v;
 }
 
+void
+OptionMenu::on_autoscrolling_change(bool v)
+{
+  auto_scrolling = v;
+}
+
+void
+OptionMenu::on_fastmode_change(bool v)
+{
+}
+
+void
+OptionMenu::on_mousegrab_change(bool v)
+{
+  // do stuff
+}
+
+void
+OptionMenu::on_printfps_change(bool v)
+{
+  //fps_counter.toggle_display();
+  std::cout << "PrintFPS: " << print_fps << std::endl;
+}
+
+void
+OptionMenu::on_master_volume_change(int v)
+{
+  if (maintainer_mode)
+    std::cout << "Master volume change: " << v << std::endl;
+}
+
+void
+OptionMenu::on_sound_volume_change(int v)
+{
+  if (maintainer_mode)
+    std::cout << "Sound volume change: " << v << std::endl;
+}
+
+void
+OptionMenu::on_music_volume_change(int v)
+{
+  if (maintainer_mode)
+    std::cout << "Music volume change: " << v << std::endl;
+}
+
 /* EOF */

Modified: trunk/pingus/src/option_menu.hpp
===================================================================
--- trunk/pingus/src/option_menu.hpp    2007-11-08 18:18:03 UTC (rev 3502)
+++ trunk/pingus/src/option_menu.hpp    2007-11-09 08:38:26 UTC (rev 3503)
@@ -26,6 +26,7 @@
 #include "gui/rect_component.hpp"
 
 class CheckBox;
+class SliderBox;
 
 /** */
 class OptionMenu : public GUIScreen
@@ -50,6 +51,14 @@
 
   CheckBox* fullscreen_box;
   CheckBox* swcursor_box;
+  CheckBox* autoscrolling_box;
+  CheckBox* fastmode_box;
+  CheckBox* mousegrab_box;
+  CheckBox* printfps_box;
+
+  SliderBox* master_volume_box;
+  SliderBox* sound_volume_box;
+  SliderBox* music_volume_box;
   
 public:
   OptionMenu();
@@ -65,6 +74,14 @@
 
   void on_swcursor_change(bool v);
   void on_fullscreen_change(bool v);
+  void on_autoscrolling_change(bool v);
+  void on_fastmode_change(bool v);
+  void on_mousegrab_change(bool v);
+  void on_printfps_change(bool v);
+
+  void on_master_volume_change(int v);
+  void on_sound_volume_change(int v);
+  void on_music_volume_change(int v);
 private:
   OptionMenu (const OptionMenu&);
   OptionMenu& operator= (const OptionMenu&);





reply via email to

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