X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=src%2Fhigh_scores.cpp;h=86b1eb699086ab285dc32a5313852a927c28fb4a;hb=6e843b1780f62f45b7021bd8c38181aa211588ee;hp=044c882f2c3a978520947663c4799f7820d21de2;hpb=03fe5c560a616e7d38a8b1d5d11bfe4675fa8896;p=supertux.git diff --git a/src/high_scores.cpp b/src/high_scores.cpp index 044c882f2..86b1eb699 100644 --- a/src/high_scores.cpp +++ b/src/high_scores.cpp @@ -20,17 +20,22 @@ /* Open the highscore file: */ -#include -#include +#include -#include "globals.h" +#include +#include + +#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"; @@ -70,8 +75,8 @@ 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); @@ -86,28 +91,25 @@ 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()) { 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(); @@ -121,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; } @@ -138,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)