enigma-cvs
[Top][All Lists]
Advanced

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

[Enigma-cvs] enigma/src menus.cc,1.72,1.73


From: Ralf Westram <address@hidden>
Subject: [Enigma-cvs] enigma/src menus.cc,1.72,1.73
Date: Thu, 06 Nov 2003 07:20:29 +0000

Update of /cvsroot/enigma/enigma/src
In directory subversions:/tmp/cvs-serv14769/src

Modified Files:
        menus.cc 
Log Message:
- tuned and bugfixed time display
- only display medal of current difficulty mode



Index: menus.cc
===================================================================
RCS file: /cvsroot/enigma/enigma/src/menus.cc,v
retrieving revision 1.72
retrieving revision 1.73
diff -C2 -d -r1.72 -r1.73
*** menus.cc    3 Nov 2003 14:21:16 -0000       1.72
--- menus.cc    6 Nov 2003 07:20:27 -0000       1.73
***************
*** 159,173 ****
  }
  
! namespace {
!     void get_best_times(const LevelInfo *li, const LevelStatus *ls, int& 
best_par_time, int& best_user_time) {
          assert(li);
  
!         best_par_time  = options::Difficulty == DIFFICULTY_HARD ? 
li->best_time_easy : li->best_time_normal;
          best_user_time = -1;
  
          if (ls) {
              if (li->has_easymode) {
!                 if ((ls->finished&options::Difficulty)>0 && ls->time_hard>0)
!                     best_user_time = ls->time_hard;
              }
              else {
--- 159,188 ----
  }
  
! namespace levels {
!     void get_best_times(const LevelInfo *li, const LevelStatus *ls,
!                         int&             par_time, int& best_user_time, 
string *best_par_name)
!     {
          assert(li);
  
!         par_time = options::Difficulty == DIFFICULTY_HARD
!             ? li->best_time_normal
!             : li->best_time_easy;
! 
!         if (par_time == LevelInfo::DEFAULT_TIME)
!             par_time = -1;
! 
!         if (best_par_name) {
!             *best_par_name = options::Difficulty == DIFFICULTY_HARD
!                 ? li->best_time_normal_by
!                 : li->best_time_easy_by;
!         }
          best_user_time = -1;
  
          if (ls) {
              if (li->has_easymode) {
!                 if ((ls->finished&options::Difficulty)>0) {
!                     const int& what_time = options::Difficulty == 
DIFFICULTY_HARD ? ls->time_hard : ls->time_easy;
!                     if (what_time>0) best_user_time = what_time;
!                 }
              }
              else {
***************
*** 255,261 ****
                      level_changed = level_pack->get_revision_number(i) > 
ls->solved_revision;
  
!                     int best_par_time, best_user_time;
!                     get_best_times(levelinfo, ls, best_par_time, 
best_user_time);
!                     par_reached = best_user_time>0 && best_user_time <= 
best_par_time;
                  }
              }
--- 270,276 ----
                      level_changed = level_pack->get_revision_number(i) > 
ls->solved_revision;
  
!                     int par_time, best_user_time;
!                     get_best_times(levelinfo, ls, par_time, best_user_time, 
0);
!                     par_reached = best_user_time>0 && (par_time<0 || 
best_user_time <= par_time);
                  }
              }
***************
*** 277,285 ****
  
              // Draw solved/changed icons on top of level preview
!             if (finished)
                  blit (gc, imgx, imgy,
!                       levelinfo->has_easymode
!                       ? ((finished&DIFFICULTY_HARD) ? img_hard : img_easy )
!                       : (options::Difficulty == DIFFICULTY_HARD ? img_hard : 
img_easy));
  
              // Add warning sign if level has been changed since player solved 
it
--- 292,299 ----
  
              // Draw solved/changed icons on top of level preview
!             if (finished && (!levelinfo->has_easymode || 
(finished&options::Difficulty) != 0)) {
                  blit (gc, imgx, imgy,
!                       options::Difficulty == DIFFICULTY_HARD ? img_hard : 
img_easy);
!             }
  
              // Add warning sign if level has been changed since player solved 
it
***************
*** 945,968 ****
          }
          else {
!             int best_par_time, best_user_time;
!             get_best_times(li, options::GetLevelStatus (lp->get_name(), 
li->filename), best_par_time, best_user_time);
  
              if (best_user_time>0) {
!                 if (best_user_time <= best_par_time) {
!                     snprintf (txt, sizeof(txt), "Your time: %d:%02d",
!                               best_user_time/60, best_user_time % 60);
!                 }
!                 else {
!                     snprintf (txt, sizeof(txt), "Time to beat: %d:%02d  Your 
time: %d:%02d",
!                               best_par_time/60, best_par_time % 60,
!                               best_user_time/60, best_user_time % 60);
                  }
              }
!             else {
!                 snprintf (txt, sizeof(txt), "Time to beat: %d:%02d",
!                           best_par_time/60, best_par_time % 60);
              }
  
!             lbl_levelinfo->set_text(txt);
          }
      }
--- 959,994 ----
          }
          else {
!             int    par_time, best_user_time;
!             string par_name;
!             get_best_times(li, options::GetLevelStatus (lp->get_name(), 
li->filename),
!                            par_time, best_user_time, &par_name);
! 
!             string your_time;
!             string par_text;
  
              if (best_user_time>0) {
!                 your_time = strf("Your time: %d:%02d", best_user_time/60, 
best_user_time%60);
! 
!                 if (par_time>0) {
!                     int below = par_time-best_user_time;
!                     if (below == 0)
!                         par_text = "That's par.";
!                     else if (below>0)
!                         par_text = strf("That's %d:%02d below par.", 
below/60, below%60);
                  }
              }
! 
!             if (par_text.length() == 0 && par_time>0) {
!                 if (par_name.length())
!                     par_text = strf("Par by %s: %d:%02d", par_name.c_str(), 
par_time/60, par_time%60);
!                 else
!                     par_text = strf("Par: %d:%02d", par_time/60, par_time%60);
              }
  
!             string time_text;
!             if (your_time.length()>0)   time_text = your_time+"  "+par_text;
!             else                        time_text = your_time+par_text;
! 
!             lbl_levelinfo->set_text(time_text.c_str());
          }
      }





reply via email to

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