[Super-tux-commit] supertux/src worldmap.cpp,1.40,1.41 worldmap.h,1.20,1.21
Brought to you by:
wkendrick
From: Ricardo C. <rm...@us...> - 2004-04-21 11:18:13
|
Update of /cvsroot/super-tux/supertux/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2177/src Modified Files: worldmap.cpp worldmap.h Log Message: Now, the worldmap displays the Level's name, instead of the path. Index: worldmap.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/worldmap.cpp,v retrieving revision 1.40 retrieving revision 1.41 diff -u -d -r1.40 -r1.41 --- worldmap.cpp 20 Apr 2004 16:26:08 -0000 1.40 +++ worldmap.cpp 21 Apr 2004 11:17:31 -0000 1.41 @@ -281,7 +281,7 @@ input_direction = NONE; enter_level = false; - name = "<no name>"; + name = "<no file>"; music = "SALCON.MOD"; song = 0; @@ -345,6 +345,9 @@ reader.read_string("name", &level.name); reader.read_int("x", &level.x); reader.read_int("y", &level.y); + + get_level_title(&level); // get level's title + levels.push_back(level); } @@ -361,6 +364,38 @@ } } +void WorldMap::get_level_title(Levels::pointer level) +{ +/** get level's title */ +level->title = "<no title>"; + +FILE * fi; +lisp_object_t* root_obj = 0; +fi = fopen((datadir + "levels/" + level->name).c_str(), "r"); +if (fi == NULL) + { + perror((datadir + "levels/" + level->name).c_str()); + return; + } + +lisp_stream_t stream; +lisp_stream_init_file (&stream, fi); +root_obj = lisp_read (&stream); + +if (root_obj->type == LISP_TYPE_EOF || root_obj->type == LISP_TYPE_PARSE_ERROR) + { + printf("World: Parse Error in file %s", level->name.c_str()); + } + +if (strcmp(lisp_symbol(lisp_car(root_obj)), "supertux-level") == 0) + { + LispReader reader(lisp_cdr(root_obj)); + reader.read_string("name", &level->title); + } + +fclose(fi); +} + void WorldMap::on_escape_press() { @@ -676,7 +711,7 @@ if (i->x == tux->get_tile_pos().x && i->y == tux->get_tile_pos().y) { - white_text->draw_align(i->name.c_str(), screen->w/2, screen->h, A_HMIDDLE, A_BOTTOM); + white_text->draw_align(i->title.c_str(), screen->w/2, screen->h, A_HMIDDLE, A_BOTTOM); break; } } Index: worldmap.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/worldmap.h,v retrieving revision 1.20 retrieving revision 1.21 diff -u -d -r1.20 -r1.21 --- worldmap.h 19 Apr 2004 19:06:45 -0000 1.20 +++ worldmap.h 21 Apr 2004 11:17:31 -0000 1.21 @@ -139,6 +139,7 @@ int x; int y; std::string name; + std::string title; bool solved; // Directions which are walkable from this level @@ -160,6 +161,8 @@ Point offset; std::string savegame_file; + void get_level_title(Levels::pointer level); + void draw_status(); public: WorldMap(); |