Now the growings animation looks pretty cool :)
[supertux.git] / src / high_scores.cpp
index c32b48c..af4f754 100644 (file)
@@ -1,9 +1,22 @@
-/*
-  by Adam Czachorowski
-  gislan@o2.pl
-*/
+//  $Id$
+// 
+//  SuperTux
+//  Copyright (C) 2004 Adam Czachorowski <gislan@o2.pl>
+//
+//  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.
 
 /* Open the highscore file: */
 
@@ -13,8 +26,9 @@
 #include "globals.h"
 #include "high_scores.h"
 #include "menu.h"
-#include "screen.h"
-#include "texture.h"
+#include "screen/drawing_context.h"
+#include "screen/screen.h"
+#include "screen/texture.h"
 #include "setup.h"
 #include "lispreader.h"
 
@@ -56,14 +70,12 @@ void load_hs(void)
   if (strcmp(lisp_symbol(lisp_car(root_obj)), "supertux-highscore") == 0)
     {
       LispReader reader(lisp_cdr(root_obj));
-      reader.read_int("score",  &hs_score);
-      reader.read_string("name", &hs_name);
+      reader.read_int("score",  hs_score);
+      reader.read_string("name", hs_name);
     }
  
   fclose(fi);
-
-printf("name=%s\n", hs_name.c_str());
-printf("score=%i\n\n", hs_score);
+  lisp_free(root_obj);
 }
 
 void save_hs(int score)
@@ -73,6 +85,7 @@ void save_hs(int score)
   Surface* bkgd;
   SDL_Event event;
 
+  DrawingContext context;
   bkgd = new Surface(datadir + "/images/highscore/highscore.png", IGNORE_ALPHA);
 
   hs_score = score;
@@ -87,17 +100,19 @@ void save_hs(int score)
   /* ask for player's name */
   while(Menu::current())
     {
-      bkgd->draw_bg();
+      context.draw_surface(bkgd, Vector(0, 0), LAYER_BACKGROUND0);
 
-      blue_text->drawf("Congratulations", 0, 130, A_HMIDDLE, A_TOP, 2, NO_UPDATE);
-      blue_text->draw("Your score:", 150, 180, 1, NO_UPDATE);
+      context.draw_text_center(blue_text, "Congratulations", 
+          Vector(0, 130), LAYER_FOREGROUND1);
+      context.draw_text(blue_text, "Your score:", Vector(150, 180),
+          LAYER_FOREGROUND1);
       sprintf(str, "%d", hs_score);
-      yellow_nums->draw(str, 350, 170, 1, NO_UPDATE);
+      context.draw_text(yellow_nums, str, Vector(250, 170), LAYER_FOREGROUND1);
 
-      Menu::current()->draw();
+      Menu::current()->draw(context);
       Menu::current()->action();
 
-      flipscreen();
+      context.do_drawing();
 
       while(SDL_PollEvent(&event))
         if(event.type == SDL_KEYDOWN)
@@ -145,18 +160,4 @@ void save_hs(int score)
       fprintf( fi,")");
       fclose(fi);
     }
-
-/*
-  fi = opendata(highscore_filename, "w");
-  if (fi != NULL)
-    {
-      fprintf(fi, "# Supertux highscore file\n\n");
-
-      fprintf(fi, "name=%s\n", hs_name);
-      fprintf(fi, "highscore=%d\n", hs_score);
-
-      fprintf(fi, "# (File automatically created.)\n");
-
-      fclose(fi);
-    }*/
 }