Ooops, forgot to upload the actual Statistics implementation.
[supertux.git] / src / high_scores.cpp
index db3cbfe..1685e4b 100644 (file)
 #include <cstring>
 #include <cstdlib>
 
-#include "globals.h"
+#include "app/globals.h"
 #include "high_scores.h"
-#include "menu.h"
-#include "screen/drawing_context.h"
-#include "screen/screen.h"
-#include "screen/texture.h"
-#include "setup.h"
-#include "lispreader.h"
+#include "gui/menu.h"
+#include "video/drawing_context.h"
+#include "video/screen.h"
+#include "video/surface.h"
+#include "app/setup.h"
+#include "utils/lispreader.h"
+#include "resources.h"
+
+using namespace SuperTux;
 
 #ifdef WIN32
 const char * highscore_filename = "/st_highscore.dat";
@@ -86,16 +89,13 @@ void save_hs(int score)
   SDL_Event event;
 
   DrawingContext context;
-  bkgd = new Surface(datadir + "/images/highscore/highscore.png", IGNORE_ALPHA);
+  bkgd = new Surface(datadir + "/images/highscore/highscore.png", false);
 
   hs_score = 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())
@@ -121,8 +121,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;
         }
 
@@ -138,8 +137,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)