fixed broken 1-time animations in sprites, fixed collision code returning no-collisio...
[supertux.git] / src / high_scores.cpp
index 4e1dceb..86b1eb6 100644 (file)
@@ -20,6 +20,8 @@
 
 /* Open the highscore file: */
 
+#include <config.h>
+
 #include <cstring>
 #include <cstdlib>
 
@@ -95,22 +97,19 @@ void save_hs(int score)
 
   Menu::set_current(highscore_menu);
 
-  if(!highscore_menu->item[0].input)
-    highscore_menu->item[0].input = (char*) malloc(strlen(hs_name.c_str()) + 1);
-
-  strcpy(highscore_menu->item[0].input,hs_name.c_str());
+  highscore_menu->item[0].input = hs_name;
 
   /* ask for player's name */
   while(Menu::current())
     {
       context.draw_surface(bkgd, Vector(0, 0), LAYER_BACKGROUND0);
 
-      context.draw_text_center(blue_text, "Congratulations", 
-          Vector(0, 130), LAYER_FOREGROUND1);
+      context.draw_text(blue_text, "Congratulations", 
+          Vector(screen->w/2, 130), CENTER_ALLIGN, LAYER_FOREGROUND1);
       context.draw_text(blue_text, "Your score:", Vector(150, 180),
-          LAYER_FOREGROUND1);
+          LEFT_ALLIGN, LAYER_FOREGROUND1);
       sprintf(str, "%d", hs_score);
-      context.draw_text(yellow_nums, str, Vector(250, 170), LAYER_FOREGROUND1);
+      context.draw_text(yellow_nums, str, Vector(250, 170), LEFT_ALLIGN, LAYER_FOREGROUND1);
 
       Menu::current()->draw(context);
       Menu::current()->action();
@@ -124,8 +123,7 @@ void save_hs(int score)
       switch (highscore_menu->check())
         {
         case 0:
-          if(highscore_menu->item[0].input != NULL)
-            hs_name = highscore_menu->item[0].input;
+          hs_name = highscore_menu->item[0].input;
           break;
         }
 
@@ -141,8 +139,8 @@ void save_hs(int score)
   /* Save data file: */
   filename = highscore_filename;
 
-  fcreatedir(filename.c_str());
-  if(fwriteable(filename.c_str()))
+  FileSystem::fcreatedir(filename.c_str());
+  if(FileSystem::fwriteable(filename.c_str()))
     {
       fi = fopen(filename.c_str(), "w");
       if (fi == NULL)