pingus-cvs
[Top][All Lists]
Advanced

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

[Pingus-CVS] CVS: Games/Pingus/src start_screen.cxx,1.5,1.6


From: grumbel
Subject: [Pingus-CVS] CVS: Games/Pingus/src start_screen.cxx,1.5,1.6
Date: 30 Mar 2003 14:49:51 -0000

Update of /var/lib/cvs/Games/Pingus/src
In directory dark:/tmp/cvs-serv11356

Modified Files:
        start_screen.cxx 
Log Message:
- added minutes/seconds time display to the start screen

Index: start_screen.cxx
===================================================================
RCS file: /var/lib/cvs/Games/Pingus/src/start_screen.cxx,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- start_screen.cxx    30 Mar 2003 14:24:24 -0000      1.5
+++ start_screen.cxx    30 Mar 2003 14:49:49 -0000      1.6
@@ -31,12 +31,14 @@
 #include "plf.hxx"
 #include "pingus_resource.hxx"
 #include "start_screen.hxx"
+#include "sound/sound.hxx"
 
 class StartScreenComponent : public GUI::Component
 {
 private:
   PLFHandle plf;
   CL_Surface background;
+  char time_str[10];
 public:
   StartScreenComponent(PLFHandle plf);
   virtual ~StartScreenComponent() {}
@@ -59,6 +61,7 @@
 
   void on_click() 
   {
+    PingusSound::play_sound("yipee");
     parent->start_game();
   }
 };
@@ -74,6 +77,24 @@
   : plf(p)
 {
   background = PingusResource::load_surface("menu/startscreenbg", "core");
+
+  int time_value = plf->get_time();
+  if (time_value == -1)
+    {
+      snprintf(time_str, 10, "unlimited");
+    }
+  else
+    {
+      int seconds   = (time_value / game_speed % 60);
+      int minutes   = (time_value / (60 * game_speed));
+  
+      // Stop displaying negative seconds, which can happen if armageddon is
+      // clicked with 1 second left.
+      if (seconds < 0)
+        seconds = 0;
+  
+      snprintf(time_str, 8, "%2d:%02d", minutes, seconds);
+    }
 }
 
 void
@@ -92,7 +113,7 @@
   gc.print_right(Fonts::chalk_normal, 500, 340, 
to_string(plf->get_number_to_save()));
 
   gc.print_left (Fonts::chalk_normal, 300, 370, _("Time: "));
-  gc.print_right(Fonts::chalk_normal, 500, 370, to_string(plf->get_time()));
+  gc.print_right(Fonts::chalk_normal, 500, 370, time_str);
   
   gc.print_left (Fonts::chalk_normal, 300, 400, _("Difficulty:"));
   gc.print_right(Fonts::chalk_normal, 500, 400, 
to_string(plf->get_difficulty()) + "/100");





reply via email to

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