pingus-cvs
[Top][All Lists]
Advanced

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

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


From: grumbel at BerliOS
Subject: [Pingus-CVS] r3499 - in trunk/pingus: . src src/components
Date: Wed, 7 Nov 2007 11:21:01 +0100

Author: grumbel
Date: 2007-11-07 11:21:00 +0100 (Wed, 07 Nov 2007)
New Revision: 3499

Added:
   trunk/pingus/src/components/label.cpp
Modified:
   trunk/pingus/SConstruct
   trunk/pingus/src/components/check_box.cpp
   trunk/pingus/src/components/check_box.hpp
   trunk/pingus/src/components/choice_box.hpp
   trunk/pingus/src/components/label.hpp
   trunk/pingus/src/option_menu.cpp
   trunk/pingus/src/option_menu.hpp
Log:
- added clickable CheckBoxes to OptionMenu

Modified: trunk/pingus/SConstruct
===================================================================
--- trunk/pingus/SConstruct     2007-11-07 09:05:31 UTC (rev 3498)
+++ trunk/pingus/SConstruct     2007-11-07 10:21:00 UTC (rev 3499)
@@ -63,6 +63,7 @@
 'src/colliders/pingu_collider.cpp', 
 'src/components/choice_box.cpp', 
 'src/components/slider_box.cpp', 
+'src/components/label.cpp', 
 'src/components/check_box.cpp', 
 'src/components/action_button.cpp', 
 'src/components/button_panel.cpp', 

Modified: trunk/pingus/src/components/check_box.cpp
===================================================================
--- trunk/pingus/src/components/check_box.cpp   2007-11-07 09:05:31 UTC (rev 
3498)
+++ trunk/pingus/src/components/check_box.cpp   2007-11-07 10:21:00 UTC (rev 
3499)
@@ -17,8 +17,31 @@
 //  along with this program; if not, write to the Free Software
 //  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 
+#include "fonts.hpp"
+#include "display/drawing_context.hpp"
 #include "check_box.hpp"
 
+CheckBox::CheckBox(const Rect& rect)
+  : RectComponent(rect),
+    state(false)
+{
+}
 
+void
+CheckBox::on_primary_button_press (int x, int y) 
+{
+  state = !state;
+}
 
+void
+CheckBox::draw(DrawingContext& gc)
+{
+  //gc.draw_rect(rect, Color(255, 255, 255));
+
+  if (state)
+    gc.print_center(Fonts::chalk_normal, rect.left+rect.get_width()/2, 
rect.top, "X");
+  gc.print_center(Fonts::chalk_normal, rect.left+rect.get_width()/2, rect.top, 
"[ ]");
+}
+
 /* EOF */
+

Modified: trunk/pingus/src/components/check_box.hpp
===================================================================
--- trunk/pingus/src/components/check_box.hpp   2007-11-07 09:05:31 UTC (rev 
3498)
+++ trunk/pingus/src/components/check_box.hpp   2007-11-07 10:21:00 UTC (rev 
3499)
@@ -20,13 +20,21 @@
 #ifndef HEADER_CHECK_BOX_HPP
 #define HEADER_CHECK_BOX_HPP
 
+#include <string>
+#include "gui/rect_component.hpp"
+
 /** */
-class CheckBox
+class CheckBox : public GUI::RectComponent
 {
 private:
+  bool state;
+
 public:
-  CheckBox();
-    
+  CheckBox(const Rect& rect);
+
+  void draw(DrawingContext& gc);
+  void on_primary_button_press(int x, int y);
+  void update_layout() {}
 private:
   CheckBox (const CheckBox&);
   CheckBox& operator= (const CheckBox&);

Modified: trunk/pingus/src/components/choice_box.hpp
===================================================================
--- trunk/pingus/src/components/choice_box.hpp  2007-11-07 09:05:31 UTC (rev 
3498)
+++ trunk/pingus/src/components/choice_box.hpp  2007-11-07 10:21:00 UTC (rev 
3499)
@@ -25,7 +25,7 @@
 {
 private:
 public:
-
+  
 private:
   ChoiceBox (const ChoiceBox&);
   ChoiceBox& operator= (const ChoiceBox&);

Added: trunk/pingus/src/components/label.cpp
===================================================================
--- trunk/pingus/src/components/label.cpp       2007-11-07 09:05:31 UTC (rev 
3498)
+++ trunk/pingus/src/components/label.cpp       2007-11-07 10:21:00 UTC (rev 
3499)
@@ -0,0 +1,37 @@
+//  $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.
+
+#include "fonts.hpp"
+#include "display/drawing_context.hpp"
+#include "label.hpp"
+
+Label::Label(const std::string& label, const Rect& rect)
+  : RectComponent(rect),
+    label(label)
+{
+}
+
+void
+Label::draw(DrawingContext& gc)
+{
+  //gc.draw_rect(rect, Color(255, 255, 255));
+  gc.print_left(Fonts::chalk_normal, rect.left, rect.top, label);
+}
+
+/* EOF */


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

Modified: trunk/pingus/src/components/label.hpp
===================================================================
--- trunk/pingus/src/components/label.hpp       2007-11-07 09:05:31 UTC (rev 
3498)
+++ trunk/pingus/src/components/label.hpp       2007-11-07 10:21:00 UTC (rev 
3499)
@@ -20,12 +20,22 @@
 #ifndef HEADER_LABEL_HPP
 #define HEADER_LABEL_HPP
 
+#include <string>
+#include "font.hpp"
+#include "gui/rect_component.hpp"
+
 /** */
-class Label
+class Label : public GUI::RectComponent
 {
 private:
+  std::string label;
+
 public:
+  Label(const std::string& label, const Rect& rect);
 
+  void draw(DrawingContext& gc);
+  void update_layout() {}
+
 private:
   Label (const Label&);
   Label& operator= (const Label&);

Modified: trunk/pingus/src/option_menu.cpp
===================================================================
--- trunk/pingus/src/option_menu.cpp    2007-11-07 09:05:31 UTC (rev 3498)
+++ trunk/pingus/src/option_menu.cpp    2007-11-07 10:21:00 UTC (rev 3499)
@@ -22,14 +22,52 @@
 #include "screen/screen_manager.hpp"
 #include "fonts.hpp"
 #include "display/drawing_context.hpp"
+#include "components/label.hpp"
+#include "components/check_box.hpp"
+#include "gui/gui_manager.hpp"
 #include "option_menu.hpp"
 
 OptionMenu::OptionMenu()
 {
   background = Resource::load_sprite("core/menu/optionmenu");
   ok_button  = Resource::load_sprite("core/start/ok");
+
+  x_pos = 0;
+  y_pos = 0;
+
+  add_item("Resolution:");
+  add_item("Fullscreen:");
+  add_item("Allow Resize:");
+  add_item("Fast Mode:");
+  add_item("Frame Skip:");
+  add_item("Software Cursor:");
+
+  add_item("Language:");
+  add_item("Master Volume:");
+  add_item("Sound Volume:");
+  add_item("Music Volume:");
+  add_item("Scroll Mode:");
+  add_item("Mouse Grab:");
 }
 
+void
+OptionMenu::add_item(const std::string& label)
+{
+  gui_manager->add(new Label(label, Rect(Vector2i(120 + x_pos * 312,
+                                                  177 + y_pos*32), Size(160, 
32))), true);
+
+  gui_manager->add(new CheckBox(Rect(Vector2i(120 + x_pos * 312 + 156 + 32+28,
+                                              177 + y_pos*32), 
+                                     Size(32, 32))), true);
+    
+  y_pos += 1;  
+  if (y_pos > 5)
+    {
+      y_pos = 0; 
+      x_pos += 1;
+    }
+}
+
 OptionMenu::~OptionMenu()
 {
 }
@@ -43,7 +81,7 @@
   
 struct OptionEntry {
   OptionEntry(const std::string& left_,
-        const std::string& right_)
+              const std::string& right_)
     : left(left_), right(right_)
   {}
   
@@ -70,7 +108,9 @@
   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);
+      //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);
     }
 
@@ -86,8 +126,10 @@
   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);
-      gc.print_right(Fonts::chalk_normal, gc.get_width()/2 + 280, y, i->right);
+      //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);
     }
 
 

Modified: trunk/pingus/src/option_menu.hpp
===================================================================
--- trunk/pingus/src/option_menu.hpp    2007-11-07 09:05:31 UTC (rev 3498)
+++ trunk/pingus/src/option_menu.hpp    2007-11-07 10:21:00 UTC (rev 3499)
@@ -29,7 +29,9 @@
 private:
   Sprite background;
   Sprite ok_button;
-
+  int x_pos;
+  int y_pos;
+  
 public:
   OptionMenu();
   ~OptionMenu();
@@ -38,6 +40,7 @@
   void update (const GameDelta& delta);
   void on_escape_press ();
 
+  void add_item(const std::string& label);
 private:
   OptionMenu (const OptionMenu&);
   OptionMenu& operator= (const OptionMenu&);





reply via email to

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