pingus-cvs
[Top][All Lists]
Advanced

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

[Pingus-CVS] r4176 - branches/pingus-hanusz/src


From: grumbel
Subject: [Pingus-CVS] r4176 - branches/pingus-hanusz/src
Date: Sat, 13 Aug 2011 16:59:03 +0200

Author: grumbel
Date: 2011-08-13 16:59:03 +0200 (Sat, 13 Aug 2011)
New Revision: 4176

Modified:
   branches/pingus-hanusz/src/level_menu.cpp
   branches/pingus-hanusz/src/level_menu.hpp
   branches/pingus-hanusz/src/statistics.cpp
   branches/pingus-hanusz/src/statistics.hpp
Log:
Added input box to change the number of tries


Modified: branches/pingus-hanusz/src/level_menu.cpp
===================================================================
--- branches/pingus-hanusz/src/level_menu.cpp   2011-07-09 17:43:23 UTC (rev 
4175)
+++ branches/pingus-hanusz/src/level_menu.cpp   2011-08-13 14:59:03 UTC (rev 
4176)
@@ -281,11 +281,13 @@
 
   m_username_inputbox = new GUI::InputBox(350, Vector2i(x_pos + 300, y_pos + 
300), "");
   m_time_inputbox = new GUI::InputBox(350, Vector2i(x_pos + 300, y_pos + 350), 
"15");
+  m_tries_inputbox = new GUI::InputBox(350, Vector2i(x_pos + 300, y_pos + 
400), "3");
 
   gui_manager->add(levelset_selector, true);
   gui_manager->add(level_selector,    true);
   gui_manager->add(m_username_inputbox,    true);
   gui_manager->add(m_time_inputbox,    true);
+  gui_manager->add(m_tries_inputbox,    true);
   gui_manager->add(m_abort_button = new LevelMenuAbortButton(this), true);
 
   level_selector->hide();
@@ -337,6 +339,9 @@
 
     gc.print_right(Fonts::chalk_small, gc.get_width()/2 - 160, 
gc.get_height()/2 + 50, 
                    "Time:");
+
+    gc.print_right(Fonts::chalk_small, gc.get_width()/2 - 160, 
gc.get_height()/2 + 100, 
+                   "Tries:");
   }
 
   SDL_Delay(10);
@@ -387,16 +392,28 @@
         
         ScreenManager::instance()->set_time_limit(time_limit);
 
-        level_selector->set_levelset(levelset);
-        levelset_selector->hide();
-        m_abort_button->hide();
+        int num_tries;
+        if (!StringUtil::from_string(m_tries_inputbox->get_string(), 
num_tries))
+        {
+          m_tries_inputbox->set_string("err");
+        }
+        else
+        {
+          LevelStat::set_max_play_count(num_tries);
 
-        level_selector->show();
+          // handle the switch
+          level_selector->set_levelset(levelset);
+          levelset_selector->hide();
+          m_abort_button->hide();
 
-        m_username_inputbox->hide();
-        m_time_inputbox->hide();
+          level_selector->show();
 
-        start_time = SDL_GetTicks();
+          m_username_inputbox->hide();
+          m_time_inputbox->hide();
+          m_tries_inputbox->hide();
+
+          start_time = SDL_GetTicks();
+        }
       }
     }
   }
@@ -413,6 +430,7 @@
     m_username_inputbox->show();
     m_username_inputbox->set_string("");
     m_time_inputbox->show(); 
+    m_tries_inputbox->show(); 
   }
 }
 

Modified: branches/pingus-hanusz/src/level_menu.hpp
===================================================================
--- branches/pingus-hanusz/src/level_menu.hpp   2011-07-09 17:43:23 UTC (rev 
4175)
+++ branches/pingus-hanusz/src/level_menu.hpp   2011-08-13 14:59:03 UTC (rev 
4176)
@@ -45,6 +45,7 @@
   LevelMenuAbortButton* m_abort_button;
   GUI::InputBox* m_username_inputbox;
   GUI::InputBox* m_time_inputbox;
+  GUI::InputBox* m_tries_inputbox;
 
   enum { kLevelsetSelector, kLevelSelector} m_mode;
 

Modified: branches/pingus-hanusz/src/statistics.cpp
===================================================================
--- branches/pingus-hanusz/src/statistics.cpp   2011-07-09 17:43:23 UTC (rev 
4175)
+++ branches/pingus-hanusz/src/statistics.cpp   2011-08-13 14:59:03 UTC (rev 
4176)
@@ -22,6 +22,8 @@
 
 Statistics* Statistics::s_instance = 0;
 
+int LevelStat::s_max_number_of_tries = 3;
+
 LevelStat::LevelStat() :
   m_play_count(0),
   m_finished(false)
@@ -61,8 +63,14 @@
 int
 LevelStat::get_max_play_count() const
 {
-  return 3;
+  return s_max_number_of_tries;
 }
+
+void
+LevelStat::set_max_play_count(int v)
+{
+  s_max_number_of_tries = v;
+}
 
 Statistics::Statistics() :
   m_filename("statistics.txt"),

Modified: branches/pingus-hanusz/src/statistics.hpp
===================================================================
--- branches/pingus-hanusz/src/statistics.hpp   2011-07-09 17:43:23 UTC (rev 
4175)
+++ branches/pingus-hanusz/src/statistics.hpp   2011-08-13 14:59:03 UTC (rev 
4176)
@@ -27,6 +27,7 @@
   int m_play_count;
   bool m_finished;
 
+  static int s_max_number_of_tries;
 public:
   LevelStat();
 
@@ -39,6 +40,7 @@
 
   /** Maximum number of times a user is allowed to retry the given level */
   int get_max_play_count() const;
+  static void set_max_play_count(int v);
 };
 
 class Statistics




reply via email to

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